@codeyam-editor/codeyam-editor 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm/cloud.js +377 -21
- package/npm/editor-dev.js +24 -2
- package/npm/editor.js +15 -5
- package/npm/fleet-add-failure.js +355 -21
- package/npm/fleet-auth-account.js +61 -0
- package/npm/fleet-auth.js +69 -1
- package/npm/fleet-branch.js +124 -1
- package/npm/fleet-build-data.js +12 -1
- package/npm/fleet-cleanup.js +84 -3
- package/npm/fleet-datastore-health.js +107 -0
- package/npm/fleet-public-url.js +81 -12
- package/npm/fleet-reconcile.js +46 -11
- package/npm/fleet-revision.js +108 -0
- package/npm/fleet-run-setup.js +66 -0
- package/npm/fleet-session-activity.js +162 -0
- package/npm/fleet-vm-readiness.js +57 -16
- package/npm/group-bounded-spawn.js +111 -0
- package/npm/launch-config.js +216 -23
- package/npm/orphan-ssh-reaper.js +81 -0
- package/npm/scenario-check.js +697 -34
- package/npm/scenario-interactivity.js +477 -23
- package/npm/scenario-issues.js +61 -0
- package/npm/scenario-playwright.js +174 -20
- package/npm/utils.js +262 -22
- package/package.json +5 -5
- package/ui/dist/assets/{ContainerInspector-DSVZvEkB.js → ContainerInspector-DiN91foX.js} +1 -1
- package/ui/dist/assets/EditorShell-BEIdHnHd.css +1 -0
- package/ui/dist/assets/EditorShell-CPV5vhjo.js +330 -0
- package/ui/dist/assets/ScenarioDataPanel-DHAHyraq.js +18 -0
- package/ui/dist/assets/{ScenarioDataPanelFullPage-Cyk6efiI.js → ScenarioDataPanelFullPage-CHIWip3n.js} +1 -1
- package/ui/dist/assets/ScenarioRenderer-D9a91iwS.js +21 -0
- package/ui/dist/assets/index--cE0hUJw.css +1 -0
- package/ui/dist/assets/{index-BPLKgwon.js → index-sW8wcg7v.js} +9 -9
- package/ui/dist/index.html +2 -2
- package/ui/dist/preview-subdir-demo/index.html +62 -0
- package/ui/dist/preview-subdir-demo/sibling.html +48 -0
- package/ui/dist/assets/EditorShell-DnXdHrar.js +0 -256
- package/ui/dist/assets/EditorShell-FvbXyqqD.css +0 -1
- package/ui/dist/assets/ScenarioDataPanel-6qJE-0lA.js +0 -15
- package/ui/dist/assets/ScenarioRenderer-Uyt54vHI.js +0 -21
- package/ui/dist/assets/index-DKpgJLo3.css +0 -1
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
var C1=Object.defineProperty;var T1=(t,n,s)=>n in t?C1(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var Lt=(t,n,s)=>T1(t,typeof n!="symbol"?n+"":n,s);import{j as e}from"./markdown-C9tbsVHX.js";import{b as l,c as Nn,R as pt}from"./react-nrLBr15I.js";import{r as P1,i as Vo,n as Yo,a as Ot,b as Ar,c as Na,d as Ca,s as O1}from"./useEvents-S3Qk1Y_d.js";import{s as On,ap as $t,bt as Ue,bu as A1,S as R1,bv as jt,bw as E1,bx as M1,by as xs,bz as Xd,bA as Qd,bB as Va,bC as I1,bD as Ko,bE as L1,u as D1,bF as F1,bG as z1,bH as Jo,bI as Xo,bJ as Qo,bK as Zo,bL as $1,bM as gc,al as B1,ak as H1,aj as q1,bN as W1,bO as G1,bP as U1,bQ as V1,bR as Y1,bS as ei,bT as Us,bU as K1,b as J1,bV as Zd,bW as Gn,bX as ys,bY as X1,bZ as Q1,b_ as bc,b$ as Z1,c0 as xc,c1 as ek,f as Ya,c2 as tk,e as ti,c3 as eu,c4 as nk,c5 as sk,k as rk,c6 as yc,c7 as ak,c8 as ok,aq as ik,ao as lk,c9 as ck,ca as vc,cb as dk,cc as uk,cd as jc,ce as hk,cf as pk,cg as mk,ch as fk,ci as gk,A as bk,F as xk}from"./ScenarioDataPanel-DHAHyraq.js";import{a as yk,e as vk,b as jk,c as ni,i as tu,g as si,d as wk,l as re,p as rn,t as _k,P as Cn,w as kk,f as Sk,u as Nk}from"./index-sW8wcg7v.js";import{a as at,C as ft,c as ri,u as ai,d as Ck}from"./useServerIdentity-CVuHTzjg.js";import{M as Bt}from"./Markdown-Chgdf3PW.js";function nu({message:t}){return e.jsx("div",{className:"flex h-full items-center justify-center px-10",children:e.jsx(On,{severity:"error",testId:"build-launch-error",headline:"The session did not start",explanation:t,nextAction:"Run the plan again from the Plan tab or the completion menu. If it keeps failing, copy this report and send it to whoever set up this machine."})})}const WE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLaunchError:nu},Symbol.toStringTag,{value:"Module"})),Tk=1;function su({maxHeight:t,fadeColor:n="var(--bg-surface)",testId:s,children:r}){const a=l.useRef(null),o=l.useRef(null),[i,c]=l.useState(!1),[d,u]=l.useState(!1),h=l.useCallback(()=>{const p=a.current;if(!p)return;const m=p.scrollHeight-p.clientHeight;c(m>0),u(p.scrollTop>=m-Tk)},[]);return l.useEffect(()=>{h();const p=new ResizeObserver(h);return a.current&&p.observe(a.current),o.current&&p.observe(o.current),()=>p.disconnect()},[h,r]),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:a,"data-testid":s,onScroll:h,className:"overflow-y-auto",style:{maxHeight:`${t}px`},tabIndex:i?0:void 0,children:e.jsx("div",{ref:o,children:r})}),i&&!d&&e.jsx("div",{"aria-hidden":!0,"data-testid":s?`${s}-fade`:void 0,style:{position:"absolute",bottom:0,left:0,right:0,height:"2rem",background:`linear-gradient(transparent, ${n})`,pointerEvents:"none"}})]})}const GE=Object.freeze(Object.defineProperty({__proto__:null,ScrollFadeRegion:su},Symbol.toStringTag,{value:"Module"})),Pk={"no-surface":"No surface for this yet","no-mock-seam":"No way to mock this yet","real-process":"Needs two live processes","real-external":"Needs a real external system"},Ok=["no-surface","no-mock-seam"];function ru(t){return Ok.includes(t)}function au({barrier:t}){const n=ru(t);return e.jsx("span",{className:`mtest-barrier ${n?"gap":"inherent"}`,"data-barrier":t,children:Pk[t]})}const UE=Object.freeze(Object.defineProperty({__proto__:null,ManualTestBarrierTag:au,isCodeyamGap:ru},Symbol.toStringTag,{value:"Module"}));function ou({title:t,onClick:n}){return e.jsxs("button",{type:"button",className:"mtest-delete","data-testid":"manual-test-delete",onClick:n,title:`Delete "${t}" — removes the test, not just its check`,"aria-label":`Delete "${t}"`,children:[e.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:e.jsx("path",{d:"M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1L5 6"})}),"Delete"]})}const VE=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteButton:ou},Symbol.toStringTag,{value:"Module"}));function iu({busy:t,onCancel:n,onConfirm:s}){return e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:n,disabled:t,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:t?"wait":"pointer",opacity:t?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:s,disabled:t,"data-testid":"manual-test-delete-confirm-button",style:{padding:"8px 18px",background:"var(--accent-red, #ff5c5c)",color:"#fff",border:"1px solid var(--accent-red, #ff5c5c)",borderRadius:6,fontSize:13,fontWeight:600,cursor:t?"wait":"pointer",opacity:t?.5:1,fontFamily:"inherit"},children:t?"Deleting…":"Delete test"})]})}const YE=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmActions:iu},Symbol.toStringTag,{value:"Module"}));function lu({completed:t}){return t?e.jsx("p",{style:{margin:0,color:"var(--accent-red, #ff5c5c)",fontSize:13},"data-testid":"manual-test-delete-receipt-warning",children:"This test was verified. Its receipt — who confirmed it, and when — is deleted with it."}):null}const KE=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteReceiptWarning:lu},Symbol.toStringTag,{value:"Module"}));function cu({title:t}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Delete manual test?"}),e.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13},children:t}),e.jsx("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"This removes the test from the repo and stages the deletion in git. Nothing is committed — the removal lands with your next commit. If the test was never committed, it is gone for good."})]})}const JE=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmHeader:cu},Symbol.toStringTag,{value:"Module"}));function An(){const[t,n]=l.useState(()=>Date.now());return l.useEffect(()=>{const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[]),t}function dn(t,n=Date.now()){if(!t)return"unknown";const s=Date.parse(t);if(Number.isNaN(s))return t;const r=Math.round((n-s)/1e3);if(r<60)return"just now";const a=Math.round(r/60);if(a<60)return`${a}m ago`;const o=Math.round(a/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function oi({uuid:t,markedForRelease:n,onToggle:s,alwaysVisible:r=!1}){if(n)return e.jsx("button",{type:"button",className:"text-xs px-2 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:text-[var(--text-default)] cursor-pointer","data-testid":`commit-queue-undo-release-${t}`,onClick:s,title:"Keep this entry in the queue",children:"Undo remove"});const a=r?"":"opacity-0 group-hover:opacity-100 transition-opacity ";return e.jsx("button",{type:"button",className:`${a}text-xs px-2 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:border-[var(--accent-danger)] hover:text-[var(--accent-danger)] cursor-pointer`,"data-testid":`commit-queue-release-${t}`,onClick:s,title:"Mark this entry for removal",children:"Force release"})}const XE=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueReleaseButton:oi},Symbol.toStringTag,{value:"Module"}));function du({entry:t,markedForRelease:n,onToggleRelease:s}){const r=An(),a=t.meta,o=a.startedAt??t.committerDate,i=[{key:"machine",label:"machine",value:a.machine},{key:"agent",label:"agent",value:a.agentProvider??"agent"},{key:"version",label:"editor version",value:a.codeyamEditorVersion??"unknown"},{key:"session",label:"session",value:a.sessionId},{key:"pid",label:"pid",value:String(a.pid)},{key:"step",label:"step",value:a.currentStep??"unknown"},{key:"started",label:"started",value:`${o} (${dn(o,r)})`},{key:"ref",label:"ref",value:t.refName},{key:"uuid",label:"uuid",value:t.uuid}];return e.jsxs("div",{className:"w-full","data-testid":`commit-queue-details-${t.uuid}`,children:[e.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:i.map(c=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-[var(--text-dim)]",children:c.label}),e.jsx("dd",{className:"font-mono break-all text-[var(--text-default)]","data-testid":`commit-queue-detail-${c.key}-${t.uuid}`,children:c.value})]},c.key))}),e.jsx("div",{className:"mt-3",children:e.jsx(oi,{uuid:t.uuid,markedForRelease:n,onToggle:s,alwaysVisible:!0})})]})}const QE=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowDetails:du},Symbol.toStringTag,{value:"Module"}));function uu({state:t}){return e.jsx("div",{style:{padding:"var(--spacing-lg, 16px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:t==="resolving"?"Finding the active round…":"No active round."})}const ZE=Object.freeze(Object.defineProperty({__proto__:null,DesignRoundEmptyState:uu},Symbol.toStringTag,{value:"Module"}));function hu({providerLabel:t,open:n,onClick:s}){return e.jsxs("button",{type:"button",onClick:s,"aria-expanded":n,className:"mtest-ask"+(n?" open":""),"data-testid":"manual-test-ask",title:`Ask ${t} how to run this test, or have it fix the test`,children:[e.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:e.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"})}),"Ask about this test"]})}const eM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestAskChatButton:hu},Symbol.toStringTag,{value:"Module"}));function pu(t){return t.cliInstalled&&t.pluginInstalled&&t.projectInitialized}function Ak(t){return t.cliInstalled||t.projectInitialized}function Ka({note:t}){return t?e.jsx("p",{className:"xsvc-broker-note",children:t}):null}function mu({broker:t,category:n,onStart:s}){const r=n.toLowerCase();return!t.cliInstalled||!t.pluginInstalled?e.jsxs("div",{className:"xsvc-broker xsvc-broker-blocked",children:[e.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",t.name]}),e.jsxs("p",{className:"xsvc-broker-body",children:[t.cliInstalled?`The ${t.name} CLI is installed, but its projects plugin is not.`:`The ${t.name} CLI is not installed on this machine.`," ","Install it and this page will offer to set up ",r," for you. This installs software on your computer; it creates nothing on your"," ",t.name," account and costs nothing."]}),e.jsx("code",{className:"xsvc-broker-cmd",children:t.installHint}),e.jsx(Ka,{note:t.note})]}):t.projectInitialized?e.jsxs("div",{className:"xsvc-broker",children:[e.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",t.name]}),e.jsxs("p",{className:"xsvc-broker-body",children:[t.projectName?`This project is connected to ${t.name} as "${t.projectName}".`:`This project is connected to ${t.name}.`," ",t.resourceCount>0?`${t.resourceCount} service${t.resourceCount===1?"":"s"} already provisioned.`:"Nothing provisioned through it yet."," ","Opening a session hands the work to the agent, which shows you every command and waits for a yes before running it."]}),e.jsx(Ka,{note:t.note}),e.jsx("button",{type:"button",className:"xsvc-broker-go",onClick:s,disabled:!pu(t),children:"Start setup"})]}):e.jsxs("div",{className:"xsvc-broker",children:[e.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",t.name]}),e.jsxs("p",{className:"xsvc-broker-body",children:["This project has not been connected to ",t.name," yet. The first step creates a project on your ",t.name," account and writes its records into this repository. A browser window may open for you to sign in."]}),e.jsx("p",{className:"xsvc-broker-body",children:"Nothing runs until you approve it: the session shows you each command and waits for a yes before running it, one command at a time."}),e.jsx("button",{type:"button",className:"xsvc-broker-go",onClick:s,children:"Start setup"})]})}const tM=Object.freeze(Object.defineProperty({__proto__:null,BrokerNote:Ka,ProvisionWithBrokerCta:mu},Symbol.toStringTag,{value:"Module"}));function fu({title:t,onClose:n,children:s}){return e.jsxs("div",{role:"dialog","aria-label":t,children:[e.jsxs("div",{className:"xsvc-chatdock-head",children:[e.jsx("span",{children:t}),e.jsx("button",{type:"button",className:"xsvc-chatdock-close",onClick:n,children:"Close ✕"})]}),s]})}const nM=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesChatDock:fu},Symbol.toStringTag,{value:"Module"}));function gu({onClose:t,slashCommand:n,seedText:s}){const r=l.useRef(null);return l.useEffect(()=>{const a=r.current;a&&typeof a.scrollIntoView=="function"&&a.scrollIntoView({block:"nearest",behavior:"smooth"})},[]),e.jsx("div",{ref:r,children:e.jsx($t,{chatName:"manual-tests",slashCommand:n,seedText:s,height:360,onClose:t})})}const sM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestsChat:gu},Symbol.toStringTag,{value:"Module"}));function Rk(t){const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function bu({steps:t}){const[n,s]=l.useState(!1),r=t.length>1,a=n?t:t.slice(0,1);return e.jsxs(e.Fragment,{children:[e.jsx("ol",{className:"mtest-steps",children:a.map((o,i)=>e.jsx("li",{children:o},i))}),r?e.jsx("button",{type:"button",className:"mtest-disclose",onClick:()=>s(o=>!o),"aria-expanded":n,children:n?"Show less":`Show all ${t.length} steps`}):null]})}const rM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestSteps:bu},Symbol.toStringTag,{value:"Module"}));function Ja({surface:t,slot:n,onOpenUncovered:s}){if(t.kind==="scenario"){if(n==="context")return null;const r=t.scenarioType==="component";return e.jsxs("a",{className:"mtest-open primary",href:yk(t.slug),target:"_blank",rel:"noopener noreferrer",title:t.reason,children:["Open scenario",e.jsx("span",{className:"sname",children:t.name}),r?e.jsx("span",{className:"stype",children:"component"}):null,e.jsxs("svg",{className:"ext",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})}return n==="action"?null:t.kind==="uncovered"?e.jsxs("div",{className:"mtest-uncovered",children:[e.jsx("span",{className:"lbl",children:"No scenario yet"}),e.jsx("span",{className:"uname",children:t.name}),e.jsx("span",{className:"ufile",children:t.file}),s?e.jsx("button",{type:"button",className:"mtest-uncovered-cta",onClick:()=>s(t.name),children:"Find it in Explore →"}):null]}):e.jsxs("div",{className:"mtest-nosurface",children:[t.barrier?e.jsx(au,{barrier:t.barrier}):null,e.jsx("span",{className:"note",children:t.note}),t.barrierDetail?e.jsx("span",{className:"bdetail",children:t.barrierDetail}):null]})}const aM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestSurfaceControl:Ja},Symbol.toStringTag,{value:"Module"})),wc=["#7a4f6d","#4f6a7a","#6d7a4f","#7a5f4f","#5f4f7a","#4f7a63"];function xu(t){const n=t.trim().toLowerCase();let s=0;for(let r=0;r<n.length;r+=1)s=(s+n.charCodeAt(r)*(r+1))%1e5;return wc[s%wc.length]}function Rr({author:t}){const n=t.email?`${t.name} <${t.email}>`:t.name;return e.jsx("span",{"data-testid":"plan-author-avatar",title:n,"aria-label":`Author: ${n}`,style:{backgroundColor:xu(t.email)},className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10px] font-medium uppercase tracking-tight text-white/90 select-none",children:t.initials})}const oM=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthorAvatar:Rr,avatarTone:xu},Symbol.toStringTag,{value:"Module"}));function ii({test:t,onToggle:n,onOpenUncovered:s,onAskAbout:r,onDelete:a,askProviderLabel:o,chatOpen:i=!1,chatSlot:c,busy:d=!1,departing:u=!1}){const h=t.status==="completed";return e.jsxs("div",{className:"mtest-row"+(h?" done":"")+(u?" leaving":"")+(u==="pinned"?" pinned":""),"data-testid":"manual-test-row","data-test-id":t.id,"data-departing":u?u==="pinned"?"pinned":"true":void 0,children:[e.jsx("label",{className:"mtest-check",children:e.jsx("input",{type:"checkbox",checked:h,disabled:d,onChange:p=>n(t.id,p.target.checked),"aria-label":`Mark "${t.title}" verified`})}),e.jsxs("div",{className:"mtest-main",children:[e.jsx("div",{className:"mtest-title",children:t.title}),e.jsx("div",{className:"mtest-intent",children:t.intent}),e.jsx(Ja,{surface:t.surface,slot:"action"}),e.jsx(bu,{steps:t.steps}),e.jsxs("div",{className:"mtest-expected",children:[e.jsx("span",{className:"lbl",children:"Expected"})," ",t.expected]}),e.jsx(Ja,{surface:t.surface,slot:"context",onOpenUncovered:s}),r||a?e.jsxs("div",{className:"mtest-ask-row",children:[r?e.jsx(hu,{providerLabel:o??Ue(null),open:i,onClick:()=>r(t.id)}):null,a?e.jsx(ou,{title:t.title,onClick:()=>a(t.id)}):null]}):null,h&&t.completion?e.jsxs("div",{className:"mtest-receipt","data-testid":"manual-test-receipt",children:[e.jsx(Rr,{author:{name:t.completion.completedByName,email:t.completion.completedByEmail,initials:t.completion.completedByInitials??"?"}}),"verified ",Rk(t.completion.completedAt)]}):null,c?e.jsx("div",{className:"mtest-row-chat","data-testid":"manual-test-row-chat",children:c}):null]})]})}const iM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRow:ii},Symbol.toStringTag,{value:"Module"}));function yu({tests:t,busyIds:n,onToggle:s,onOpenUncovered:r,onAskAboutTest:a,onDeleteTest:o,askProviderLabel:i,openTestChatId:c=null,testChatSlot:d}){const[u,h]=l.useState(!1),p=new Set(n);return t.length===0?null:e.jsxs("div",{className:"mtest-completed",children:[e.jsxs("button",{type:"button",className:"mtest-disclose",onClick:()=>h(m=>!m),"aria-expanded":u,"data-testid":"home-testing-completed-toggle",children:[u?"Hide":"Show"," ",t.length," completed"]}),u?e.jsx("div",{className:"mtest-list",children:t.map(m=>e.jsx(ii,{test:m,onToggle:s,onOpenUncovered:r,onAskAbout:a,onDelete:o,askProviderLabel:i,chatOpen:c===m.id,chatSlot:c===m.id?d:null,busy:p.has(m.id)},m.id))}):null]})}const lM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestCompletedGroup:yu},Symbol.toStringTag,{value:"Module"}));function vu({status:t}){return t?t.neverGenerated?e.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:"No tests generated yet"}):t.lastGeneratedShaUnreachable?e.jsx("span",{className:"mtest-count warn","data-testid":"manual-tests-count-line",title:"The commit the last generation was anchored to is no longer reachable — a rebase or squash dropped it.",children:"Anchor commit is gone — regenerate to re-anchor"}):t.commitsSince==null?e.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:"Commits since last generated: unknown"}):e.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:t.commitsSince===0?"Up to date — 0 commits since tests were last generated":`${t.commitsSince} commit${t.commitsSince===1?"":"s"} since tests were last generated`}):null}const cM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestCountLine:vu},Symbol.toStringTag,{value:"Module"}));function sr({value:t,label:n,detail:s,checked:r,enabled:a=!0,disabled:o=!1,onSelect:i}){return e.jsxs("label",{className:"mtest-range-opt"+(a?"":" disabled"),children:[e.jsx("input",{type:"radio",name:"mtest-range-choice",checked:r,disabled:o||!a,onChange:i}),e.jsx("span",{className:"mtest-range-opt-lbl",children:n}),s?e.jsx("span",{className:"mtest-range-opt-detail",children:s}):null]})}const dM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeOption:sr},Symbol.toStringTag,{value:"Module"})),Ek=[10,25];function Mk(t,n){switch(t){case"marker":return n.defaultRange?{range:n.defaultRange,label:"since tests were last generated",adHoc:!1}:null;case"count-10":case"count-25":{const s=t==="count-10"?10:25;return{range:`HEAD~${s}..HEAD`,label:`last ${s} commits`,adHoc:!0}}case"commit":return n.selectedCommit?{range:`${n.selectedCommit.shortSha}..HEAD`,label:`since “${n.selectedCommit.subject}”`,adHoc:!0}:null;case"custom":{const s=n.customRange.trim();return s?{range:s,label:s,adHoc:!0}:null}}}function ju({choice:t,onChoose:n,hasDefaultRange:s,commitCount:r=null,commitsLoaded:a,disabled:o=!1}){const i=s?r!=null?`${r} commit${r===1?"":"s"}`:"":"no anchor — nothing has been generated yet";return e.jsxs("div",{className:"mtest-range-opts",children:[e.jsx(sr,{value:"marker",label:"Since tests were last generated",detail:i,checked:t==="marker",enabled:s,disabled:o,onSelect:()=>n("marker")}),Ek.map(c=>{const d=c===10?"count-10":"count-25";return e.jsx(sr,{value:d,label:`Last ${c} commits`,checked:t===d,disabled:o,onSelect:()=>n(d)},d)}),e.jsx(sr,{value:"commit",label:"Since a specific change…",detail:a?"":"no commits loaded",checked:t==="commit",enabled:a,disabled:o,onSelect:()=>n("commit")})]})}const uM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeOptions:ju},Symbol.toStringTag,{value:"Module"}));function Ik(t,n=Date.now()){const s=new Date(t).getTime();if(Number.isNaN(s))return"";const r=Math.floor((n-s)/864e5);if(r<=0)return"today";if(r===1)return"yesterday";if(r<30)return`${r} days ago`;const a=Math.round(r/30);return a===1?"1 month ago":`${a} months ago`}function wu({commit:t,selected:n,disabled:s=!1,onSelect:r}){return e.jsxs("button",{type:"button",className:"mtest-range-commit"+(n?" selected":""),onClick:r,disabled:s,"aria-pressed":n,children:[e.jsx("span",{className:"mtest-range-commit-subject",children:t.subject}),e.jsxs("span",{className:"mtest-range-commit-meta",children:[t.shortSha," · ",Ik(t.timestamp)]})]})}const hM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCommitRow:wu},Symbol.toStringTag,{value:"Module"}));function _u({commits:t,hiddenCount:n=0,selectedSha:s,onSelect:r,disabled:a=!1}){return e.jsxs(e.Fragment,{children:[t.length>0?e.jsx("div",{className:"mtest-range-commits","data-testid":"manual-tests-commits",children:t.map(o=>e.jsx(wu,{commit:o,selected:s===o.sha,disabled:a,onSelect:()=>r(o.sha)},o.sha))}):null,n>0?e.jsxs("span",{className:"mtest-range-hidden",children:[n," bookkeeping commit",n===1?"":"s"," hidden"]}):null]})}const pM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCommitList:_u},Symbol.toStringTag,{value:"Module"}));function ku({value:t,onChange:n,onSubmit:s,onCancel:r,disabled:a=!1}){return e.jsxs("div",{className:"mtest-range-field",children:[e.jsx("label",{className:"mtest-range-lbl",htmlFor:"mtest-range-input",children:"Range"}),e.jsx("input",{id:"mtest-range-input",className:"mtest-range-input",type:"text",value:t,spellCheck:!1,autoComplete:"off",placeholder:"e.g. main..HEAD",onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s(),o.key==="Escape"&&(r==null||r())},disabled:a})]})}const mM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCustomField:ku},Symbol.toStringTag,{value:"Module"}));function Su({resolved:t,awaitingCommit:n}){const s=t==null?n?"Pick a change to generate from.":"Name a range to generate from.":t.adHoc?"This run won’t move the last-generated marker.":"The usual run — moves the marker when it finishes.";return e.jsx("span",{className:"mtest-range-hint",children:s})}const fM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeHint:Su},Symbol.toStringTag,{value:"Module"}));function Nu({canGenerate:t,onGenerate:n,onShowCustom:s,showCustomButton:r,onCancel:a,disabled:o=!1}){return e.jsxs("div",{className:"mtest-range-actions",children:[r?e.jsx("button",{type:"button",className:"mtest-btn subtle",onClick:s,disabled:o,children:"Type a range"}):null,a?e.jsx("button",{type:"button",className:"mtest-btn subtle",onClick:a,disabled:o,children:"Cancel"}):null,e.jsx("button",{type:"button",className:"mtest-btn primary",onClick:n,disabled:o||!t,"data-testid":"manual-tests-range-generate",children:"Generate"})]})}const gM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeActions:Nu},Symbol.toStringTag,{value:"Module"}));function Lk(t){return/^chore: update codeyam state\b/i.test(t.trim())}function Cu({defaultRange:t,commitCount:n,recentCommits:s=[],onGenerate:r,onCancel:a,disabled:o=!1,initialChoice:i,initialSelectedSha:c=null}){const[d,u]=l.useState(i??(t?"marker":"commit")),[h,p]=l.useState(c??null),[m,f]=l.useState(""),[g,b]=l.useState(!1),x=s.filter(j=>!Lk(j.subject)),y=s.find(j=>j.sha===h)??null,v=Mk(d,{defaultRange:t,selectedCommit:y,customRange:m}),_=()=>{v&&!o&&r(v)};return e.jsxs("div",{className:"mtest-range","data-testid":"manual-tests-range",children:[e.jsx("div",{className:"mtest-range-title",children:"Which commits should it read?"}),e.jsx(ju,{choice:d,onChoose:u,hasDefaultRange:t!=null,commitCount:n??null,commitsLoaded:s.length>0,disabled:o}),d==="commit"?e.jsx(_u,{commits:x,hiddenCount:s.length-x.length,selectedSha:h,onSelect:p,disabled:o}):null,g?e.jsx(ku,{value:m,onChange:j=>{f(j),u("custom")},onSubmit:_,onCancel:a,disabled:o}):null,e.jsxs("div",{className:"mtest-range-foot",children:[e.jsx(Su,{resolved:v,awaitingCommit:d==="commit"}),e.jsx(Nu,{canGenerate:v!=null,onGenerate:_,onShowCustom:()=>b(!0),showCustomButton:!g,onCancel:a,disabled:o})]})]})}const bM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeControl:Cu},Symbol.toStringTag,{value:"Module"}));function Tu({range:t}){return t?e.jsxs("span",{className:"mtest-adhoc","data-testid":"manual-tests-adhoc-note",children:["Last run: ",t]}):null}const xM=Object.freeze(Object.defineProperty({__proto__:null,ManualTestAdHocNote:Tu},Symbol.toStringTag,{value:"Module"}));function br({label:t,entries:n,labelColor:s,entryColor:r,labelTestId:a,entryTestId:o,entryKeyPrefix:i}){return n.length===0?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:s},"data-testid":a,children:t}),e.jsx("ul",{className:"list-disc pl-4 flex flex-col gap-1",children:n.map(c=>e.jsx("li",{className:"text-xs leading-relaxed",style:{color:r},"data-testid":o,children:c},`${i}-${c}`))})]})}const yM=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteBannerSection:br},Symbol.toStringTag,{value:"Module"}));function Pu({minorWarnings:t,followUps:n}){return t.length===0&&n.length===0?null:e.jsxs("div",{className:"mt-4 pt-3 flex flex-col gap-2.5",style:{borderTop:"1px solid var(--border-default)"},"data-testid":"feature-complete-secondary",children:[e.jsx(br,{label:"Minor warnings",entries:t,labelColor:"var(--text-dim)",entryColor:"var(--text-dim)",labelTestId:"feature-complete-minor-warnings-label",entryTestId:"feature-complete-minor-warning",entryKeyPrefix:"minor-warning"}),e.jsx(br,{label:"Deferred for later",entries:n,labelColor:"var(--text-dim)",entryColor:"var(--text-secondary)",labelTestId:"feature-complete-follow-ups-label",entryTestId:"feature-complete-follow-up",entryKeyPrefix:"follow-up"})]})}const vM=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteSecondary:Pu},Symbol.toStringTag,{value:"Module"})),Ou="Help me figure out what to do next.";function Au({onSubmitPrompt:t,disabled:n}){return e.jsx("div",{className:"mt-4 pt-3 border-t border-[var(--border-subtle)] text-center",children:e.jsx("button",{type:"button",onClick:()=>t(Ou),disabled:n,className:"text-xs underline underline-offset-2 text-[var(--text-muted)] hover:text-[var(--text-primary)] transition cursor-pointer disabled:cursor-not-allowed disabled:opacity-50","data-testid":"build-launch-modal-not-sure",children:"Not sure what you need? Help me figure it out"})})}const jM=Object.freeze(Object.defineProperty({__proto__:null,NOT_SURE_PROMPT:Ou,NotSurePrompt:Au},Symbol.toStringTag,{value:"Module"}));function Ru({severeWarnings:t}){return t.length===0?null:e.jsx("div",{className:"mb-3 p-3 rounded-md flex flex-col gap-2.5",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)"},"data-testid":"feature-complete-banner",children:e.jsx(br,{label:"Read this first",entries:t,labelColor:"var(--accent-danger, #f87171)",entryColor:"var(--accent-danger, #f87171)",labelTestId:"feature-complete-warnings-label",entryTestId:"feature-complete-warning",entryKeyPrefix:"warning"})})}const wM=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteBanner:Ru},Symbol.toStringTag,{value:"Module"}));function Eu({summary:t}){return e.jsxs("div",{className:"mb-6","data-testid":"feature-complete-summary",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-[var(--text-dim)] mb-1",children:"Feature complete"}),e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-3",children:t.title}),e.jsx(Ru,{severeWarnings:t.severeWarnings??[]}),t.summary&&e.jsx(Bt,{variant:"compact",children:t.summary}),e.jsx(Pu,{minorWarnings:t.minorWarnings??[],followUps:t.followUps??[]})]})}const _M=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteSummary:Eu},Symbol.toStringTag,{value:"Module"}));function Mu(){return e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm opacity-70",children:"No page selected."})}const kM=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlEmptyState:Mu},Symbol.toStringTag,{value:"Module"}));function Iu({warnings:t}){return t.length===0?null:e.jsx("ul",{className:"px-3 py-2 border-b text-xs opacity-80 list-disc list-inside",children:t.map(n=>e.jsx("li",{children:n},n))})}const SM=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlLintWarnings:Iu},Symbol.toStringTag,{value:"Module"}));function Lu({title:t,onBackToApp:n}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 border-b text-sm",children:[e.jsx("span",{className:"font-medium truncate",title:t,children:t}),e.jsx("button",{type:"button",onClick:n,className:"shrink-0 px-2 py-1 rounded border text-xs",children:"Back to app"})]})}const NM=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlPaneHeader:Lu},Symbol.toStringTag,{value:"Module"})),_c=5173;function li(t){if(t.startsWith("http"))try{return new URL(t).pathname}catch{return t}return t.split("?")[0]??t}function ci(t){return t?parseInt(t.port||(t.protocol==="https:"?"443":"80"),10):0}function di(t,{appPort:n,currentPort:s,previewOrigin:r}){return t.startsWith("http")?t:r?`${r}${t}`:s===n?t:`http://localhost:${n}${t}`}function Du(t,n,s,r,a){if(s&&s.length>0)return di(s,{appPort:r,currentPort:n,previewOrigin:a});const o=`/scenario/${t}`;return a?`${a}${o}`:n===_c?o:`http://localhost:${_c}${o}`}const Dk=["/apps","/entities","/app","/build","/history","/settings","/plan"];function Fu(t){if(!t)return!1;const n=li(t);return Dk.some(s=>n===s||n.startsWith(`${s}/`))}function zu(t,n,s){const r=typeof window<"u"?ci(window.location):0;let a="";if(P1(t)==="component"?a=Du(t.slug,r,t.url,n,s):t.url&&(a=di(t.url,{appPort:n,currentPort:r,previewOrigin:s})),a&&!Fu(a))try{const o=!a.startsWith("http"),i=typeof window<"u"?window.location.origin:"http://localhost",c=new URL(a,i);return c.searchParams.set("_codeyam_scenario",t.slug),o?c.pathname+c.search+c.hash:c.toString()}catch{return a}return a}function Fk(t){return t==="/design-exploration"||t==="/design-round"||ui(t)}function ui(t){const n=t.split("?")[0]??t;return n==="/agent-html"||n.startsWith("/agent-html/")}function $u(t){const n=t.split("?")[0]??t;if(!n.startsWith("/agent-html/"))return null;const s=n.slice(12);return s.length>0?s:null}function zk(t){const n=$u(t);return n?`/api/editor-preview-html/${n}.html`:null}function $k(t,n,s){return t.startsWith("http")||t?t:s?`${s}/results`:`http://127.0.0.1:${n}/results`}function Bk(t,n,s){return t.startsWith("http")||t?t:s?`${s}/plan-preview`:`http://127.0.0.1:${n}/plan-preview`}function Bu(t,n){if(!n)return null;for(const s of t)for(const r of s.scenarios)if(r.slug===n||r.id===n)return r;return null}function Hk({directPreviewPath:t,fallbackPreviewPath:n,previewKind:s,selectedScenario:r,port:a,previewOrigin:o}){return s==="blank"?"":t&&(s==="application"||s==="results"||s==="plan-preview"||s==="agent-html")?s==="results"?$k(t,a,o):s==="plan-preview"?Bk(t,a,o):t.startsWith("http")||Fk(t)?t:o?`${o}${t}`:`http://127.0.0.1:${a}${t}`:r?zu({slug:r.slug,scenarioType:r.scenarioType,componentName:r.componentName,url:r.url},a,o):n?n.startsWith("http")?n:o?`${o}${n}`:`http://127.0.0.1:${a}${n}`:""}function qk(t,n=Date.now()){const s=t.includes("?")?"&":"?";return`${t}${s}_cb=${n}`}function Wk(t,n){const[s,r]=l.useState(null);return l.useEffect(()=>{if(!t){r(null);return}let a=!1;return fetch("/api/editor-preview-html").then(o=>o.ok?o.json():[]).then(o=>{a||r(Array.isArray(o)?o.find(i=>i.name===t)??null:null)}).catch(()=>{}),()=>{a=!0}},[t,n]),s}function Hu({previewPath:t,onBackToApp:n,commandNonce:s}){const r=$u(t),a=zk(t),o=Wk(r,s);if(!r||!a)return e.jsx(Mu,{});const i=()=>{fetch("/api/dev-mode-preview-nav",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:"/",dimension:"Desktop"})}).catch(()=>{})},c=(o==null?void 0:o.title)??r,d=(o==null?void 0:o.url)??a;return e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsx(Lu,{title:c,onBackToApp:n??i}),e.jsx(Iu,{warnings:(o==null?void 0:o.warnings)??[]}),e.jsx("iframe",{src:d,title:c,sandbox:"allow-scripts",className:"flex-1 w-full border-0 bg-white"},d)]})}const CM=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlPreviewPane:Hu},Symbol.toStringTag,{value:"Module"}));function rr({variant:t,color:n,testId:s,title:r,pulse:a=!1}){const o=t==="ring"?{borderColor:n,backgroundColor:"transparent"}:{backgroundColor:n};return e.jsx("span",{"data-testid":s,title:r,style:o,className:`mr-1 inline-block w-2 h-2 rounded-full ${t==="ring"?"border-2":""} ${a?"animate-pulse":""}`})}const TM=Object.freeze(Object.defineProperty({__proto__:null,NavTabDot:rr},Symbol.toStringTag,{value:"Module"})),Gk={display:"block",width:"100%",padding:"var(--spacing-xs, 4px) var(--spacing-sm, 8px)",fontSize:"var(--text-xs, 12px)",color:"var(--text-primary)",border:"none",borderRadius:4,cursor:"pointer",textAlign:"left",whiteSpace:"nowrap"};function Xa({label:t,onSelect:n}){const[s,r]=l.useState(!1);return e.jsx("button",{type:"button",role:"menuitem",onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{...Gk,background:s?"var(--bg-input)":"transparent"},children:t})}const PM=Object.freeze(Object.defineProperty({__proto__:null,AssetPickerMenuItem:Xa},Symbol.toStringTag,{value:"Module"}));function qu({busy:t,onCancel:n,onConfirm:s}){return e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:n,disabled:t,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:t?"wait":"pointer",opacity:t?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:s,disabled:t,"data-testid":"plan-delete-confirm-button",style:{padding:"8px 18px",background:"var(--accent-red, #ff5c5c)",color:"#fff",border:"1px solid var(--accent-red, #ff5c5c)",borderRadius:6,fontSize:13,fontWeight:600,cursor:t?"wait":"pointer",opacity:t?.5:1,fontFamily:"inherit"},children:t?"Deleting…":"Delete plan"})]})}const OM=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmActions:qu},Symbol.toStringTag,{value:"Module"}));function Wu({dependents:t}){if(t.length===0)return null;const n=t.length===1;return e.jsxs("div",{"data-testid":"plan-delete-dependents",style:{display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",border:"1px solid var(--accent-red, #ff5c5c)",borderRadius:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[e.jsxs("span",{style:{color:"var(--accent-red)",fontSize:12},children:[t.length," queued plan",n?"":"s"," depend",n?"s":""," ","on this one and will stay blocked"]}),e.jsx(at,{variant:"subtle",ariaLabel:"Copy the list of blocked plans",text:t.map(s=>`${s.title} (${s.slug})`).join(`
|
|
2
|
+
`)})]}),e.jsx("ul",{style:{margin:0,paddingLeft:18,color:"var(--text-secondary)",fontSize:12},children:t.map(s=>e.jsx("li",{children:s.title},s.slug))})]})}const AM=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteDependentsWarning:Wu},Symbol.toStringTag,{value:"Module"}));function Gu({title:t,filePath:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Delete queued plan?"}),e.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13},children:t}),e.jsx("p",{style:{margin:0,color:"var(--text-muted)",fontSize:12},"data-testid":"plan-delete-file-path",children:n}),e.jsx("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"This removes the plan file and any co-located assets, and stages the deletion in git. Nothing is committed — the removal lands with your next commit."})]})}const RM=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmHeader:Gu},Symbol.toStringTag,{value:"Module"}));function Uu({title:t,slug:n,filePath:s,dependents:r,busy:a,error:o,onCancel:i,onConfirm:c}){return l.useEffect(()=>{const d=u=>{u.key==="Escape"&&!a&&i()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,i]),e.jsx("div",{role:"presentation",onClick:()=>{a||i()},style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:24},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Delete queued plan?","data-slug":n,onClick:d=>d.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(460px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsx(Gu,{title:t,filePath:s}),e.jsx(Wu,{dependents:r}),o&&e.jsx(On,{severity:"error",testId:"plan-delete-error",headline:"The plan wasn't deleted",explanation:"CodeYam asked the editor to remove this plan and the request came back with an error. The plan is still queued and nothing on disk was changed.",nextAction:"Try Delete plan again. If it keeps failing, copy this report — the plan file may have been moved or removed outside the editor.",diagnostics:o}),e.jsx(qu,{busy:a,onCancel:i,onConfirm:c})]})})}const EM=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmModal:Uu},Symbol.toStringTag,{value:"Module"}));function Vu({onClick:t,disabled:n}){return e.jsx("button",{type:"button",onClick:t,disabled:n,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--accent-red)] hover:border-[var(--accent-red)] disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:"Delete"})}const MM=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDeleteButton:Vu},Symbol.toStringTag,{value:"Module"})),Uk="editor",Vk="preview";function Yk(t){if(!t)return null;let n;try{n=new URL(t)}catch{return null}const s=n.hostname.split(".");if(s.length<3||s[1]!==Uk)return null;const r=[s[0],Vk,...s.slice(2)].join(".");return`${n.protocol}//${r}`}async function Kk(t,n=4e3){if(!t)return"unknown";const s=new AbortController,r=setTimeout(()=>s.abort(),n);try{return await fetch(t,{credentials:"include",mode:"no-cors",redirect:"follow",signal:s.signal}),"answers"}catch{return s.signal.aborted?"unknown":"absent"}finally{clearTimeout(r)}}function xr(t){return`codeyam-editor editor config-override previewOrigin ${t}`}function hi(t,n=!0){const s=Yk(t),[r,a]=l.useState(!1);return l.useEffect(()=>{if(!n||!s){a(!1);return}let o=!1;return Kk(s).then(i=>{o||a(i==="answers")}),()=>{o=!0}},[n,s]),r&&s?s:null}function Jk(t){return`This editor is running on ${t.provider}, which can serve the preview on a public address — it just needs to be told which port to front. Add the block below to ${t.file}, or run this, which adds it for you after confirming: ${t.setupCommand}`}function Xk(t){return t?"Nothing to do, and nothing you did caused this — this machine is one we run, and a preview host is being provisioned for it automatically. The preview will move to it on its own, without a restart or a reload.":"Not something you can change from here: a dedicated preview host has to be provisioned for this machine — a preview subdomain alongside the editor's — and the preview will move to it on its own. Copy this report and send it to whoever set the machine up."}function Yu({onDismiss:t,hint:n=null,onManagedFleetVm:s=!1,editorOrigin:r}){const a=r??(typeof window<"u"?window.location.origin:null),o=hi(a),i=o!==null,c=i?`A preview host for this machine already exists and is answering: ${o}. Point the preview at it with:
|
|
3
|
+
|
|
4
|
+
${xr(o)}
|
|
5
|
+
|
|
6
|
+
It takes effect immediately — the editor reloads its config in place, so no restart is needed.`:n?Jk(n):Xk(s);return e.jsx(On,{severity:"warning",testId:"preview-dedicated-origin-notice",className:"flex w-full flex-col gap-3 border-b border-l-4 px-4 py-3 text-sm",headline:i?"The preview is not using this machine's preview host":"No dedicated preview origin is provisioned",explanation:i?"This app is set to preview from its own origin, and this machine has one — but the preview is still being served from the /__codeyam_preview subpath, so deep links and reloads may mis-route.":"This app is set to preview from its own origin, but this host has none that your browser can reach — so the preview is still being served from the /__codeyam_preview subpath. It works, but deep links and reloads may mis-route.",nextAction:c,diagnostics:i?xr(o):(n==null?void 0:n.stanza)??void 0,actions:[{label:"Dismiss",onClick:t,variant:"secondary",ariaLabel:"Dismiss preview origin notice",testId:"preview-dedicated-origin-notice-dismiss"}]})}const IM=Object.freeze(Object.defineProperty({__proto__:null,PreviewDedicatedOriginNotice:Yu},Symbol.toStringTag,{value:"Module"}));function Ku({restartCount:t}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-[10px] font-bold text-primary",children:t>0?`#${t}`:""})]})}const LM=Object.freeze(Object.defineProperty({__proto__:null,RestartSpinner:Ku},Symbol.toStringTag,{value:"Module"}));function Ju({title:t,body:n,spinner:s,restartCount:r,variant:a}){return e.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":a,className:"absolute inset-0 bg-white/90 dark:bg-gray-900/90 backdrop-blur-sm flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4 text-center max-w-md p-6",children:[s?e.jsx(Ku,{restartCount:r}):e.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6 text-gray-500 dark:text-gray-400","aria-hidden":"true",children:[e.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),e.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:t}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:n})]})]})})}const DM=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingOverlay:Ju},Symbol.toStringTag,{value:"Module"}));function et({widthPct:t,heightPx:n,variant:s="surface"}){const r=s==="overlay"?"linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.12) 45%, rgba(255,255,255,0.04) 90%)":"linear-gradient(90deg, var(--bg-surface) 0%, var(--border-default) 45%, var(--bg-surface) 90%)";return e.jsx("div",{style:{width:`${t}%`,height:n,borderRadius:4,background:r,backgroundSize:"200% 100%",animation:"mockup-skeleton-shimmer 1.6s linear infinite",opacity:s==="surface"?.85:1}})}const FM=Object.freeze(Object.defineProperty({__proto__:null,SkeletonBar:et},Symbol.toStringTag,{value:"Module"}));function Er(){return e.jsx("style",{children:`
|
|
7
|
+
@keyframes mockup-skeleton-shimmer {
|
|
8
|
+
0% { background-position: -200% 0; }
|
|
9
|
+
100% { background-position: 200% 0; }
|
|
10
|
+
}
|
|
11
|
+
`})}const zM=Object.freeze(Object.defineProperty({__proto__:null,SkeletonShimmerKeyframes:Er},Symbol.toStringTag,{value:"Module"}));function Xu(){return e.jsx("li",{"aria-hidden":"true",className:"border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)]",children:e.jsxs("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(et,{widthPct:42,heightPx:14})}),e.jsx(et,{widthPct:6,heightPx:12})]})})}function pi({count:t,testId:n,label:s="Loading plans"}){return e.jsxs(e.Fragment,{children:[e.jsx(Er,{}),e.jsxs("div",{role:"status","aria-busy":"true",children:[e.jsx("span",{className:"sr-only",children:s}),e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":n??"plan-row-skeleton-list",children:Array.from({length:Math.max(t,1)},(r,a)=>e.jsx(Xu,{},a))})]})]})}const $M=Object.freeze(Object.defineProperty({__proto__:null,PlanRowSkeleton:Xu,PlanRowSkeletonList:pi},Symbol.toStringTag,{value:"Module"}));function Qu({count:t}){return e.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:t===1?"1 file queued":`${t} files queued`})}const BM=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCountLine:Qu},Symbol.toStringTag,{value:"Module"}));function Mr(t,n,s){l.useEffect(()=>{const r=o=>{const i=o.target;t.current&&t.current.contains(i)||s!=null&&s.current&&s.current.contains(i)||n()},a=o=>{o.key==="Escape"&&n()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",a)}},[t,n,s])}function Zu({onChooseFiles:t,onChooseFolder:n,onClose:s,triggerRef:r}){const a=l.useRef(null);return Mr(a,s,r),e.jsxs("div",{ref:a,role:"menu",style:{position:"absolute",top:"100%",left:0,marginTop:"var(--spacing-xs, 4px)",minWidth:140,padding:"var(--spacing-xs, 4px)",background:"var(--bg-elevated, #222)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0, 0, 0, 0.4)",zIndex:50},children:[e.jsx(Xa,{label:"Files…",onSelect:()=>{t(),s()}}),e.jsx(Xa,{label:"Folder…",onSelect:()=>{n(),s()}})]})}const HM=Object.freeze(Object.defineProperty({__proto__:null,AssetPickerMenu:Zu},Symbol.toStringTag,{value:"Module"})),Qk={webkitdirectory:""};function eh({fileInputRef:t,folderInputRef:n,onFolderPick:s}){const[r,a]=l.useState(!1),o=l.useRef(null);return e.jsxs("div",{style:{position:"relative",marginTop:"var(--spacing-xs, 4px)",marginBottom:"var(--spacing-sm, 8px)"},children:[e.jsx("input",{ref:n,type:"file",...Qk,onChange:s,style:{display:"none"}}),e.jsx("button",{ref:o,type:"button","aria-haspopup":"menu","aria-expanded":r,onClick:()=>a(i=>!i),style:{padding:0,fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer",textDecoration:"underline"},children:"or choose files or a folder ▾"}),r&&e.jsx(Zu,{onChooseFiles:()=>{var i;return(i=t.current)==null?void 0:i.click()},onChooseFolder:()=>{var i;return(i=n.current)==null?void 0:i.click()},onClose:()=>a(!1),triggerRef:o})]})}const qM=Object.freeze(Object.defineProperty({__proto__:null,ChooseAssetsButton:eh},Symbol.toStringTag,{value:"Module"}));function th({value:t}){const[n,s]=l.useState(!1),r=async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),2e3)}catch{}};return e.jsx("button",{type:"button",onClick:r,"data-testid":"copy-path-button",title:n?"Copied":`Copy ${t}`,"aria-label":n?"Copied":`Copy ${t}`,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-[var(--border-default)] bg-[var(--bg-card)] text-[10px] leading-none text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer transition-colors",children:n?"✓":"⧉"})}const WM=Object.freeze(Object.defineProperty({__proto__:null,CopyPathButton:th},Symbol.toStringTag,{value:"Module"}));function nh({slug:t,count:n,tooltip:s}){return n<=0?null:e.jsxs("span",{"data-testid":`plan-row-blocked-${t}`,title:s,className:"text-[10px] whitespace-nowrap px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] inline-flex items-center gap-1",children:["🔒 blocked · ",n," dep",n===1?"":"s"]})}const GM=Object.freeze(Object.defineProperty({__proto__:null,PlanRowBlockedChip:nh},Symbol.toStringTag,{value:"Module"}));function mi({children:t,testId:n}){return e.jsx("span",{"data-testid":n,className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border border-[var(--border-default)] bg-[var(--bg-card)] text-[var(--text-dim)]",children:t})}const UM=Object.freeze(Object.defineProperty({__proto__:null,PlanRowTag:mi},Symbol.toStringTag,{value:"Module"}));function fi({mode:t}){return e.jsx(mi,{children:t})}const VM=Object.freeze(Object.defineProperty({__proto__:null,PlanModeBadge:fi},Symbol.toStringTag,{value:"Module"}));function Ir({expanded:t,testId:n}){return e.jsx("span",{"aria-hidden":"true","data-testid":n,className:"inline-block shrink-0 text-xs leading-none text-[var(--text-dim)] transition-transform "+(t?"rotate-180":"rotate-0"),children:"⌄"})}const YM=Object.freeze(Object.defineProperty({__proto__:null,PlanDisclosureChevron:Ir},Symbol.toStringTag,{value:"Module"}));function gi({title:t,timestamp:n,tone:s="primary"}){return e.jsxs("span",{className:"flex items-baseline gap-2 min-w-0",children:[e.jsx("span",{className:"min-w-0 truncate text-sm "+(s==="muted"?"text-[var(--text-muted)]":"text-[var(--text-primary)]"),children:t}),e.jsx("span",{className:"shrink-0 text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:dn(n)})]})}const KM=Object.freeze(Object.defineProperty({__proto__:null,PlanRowTitleWithAge:gi},Symbol.toStringTag,{value:"Module"}));function sh({slug:t,handleRef:n,attributes:s,listeners:r}){return e.jsx("span",{ref:n,"data-testid":`plan-drag-${t}`,"aria-label":"Reorder plan",...s??{},...r??{},onClick:a=>a.stopPropagation(),className:"cursor-grab active:cursor-grabbing text-[var(--text-dim)] select-none leading-none px-1 -ml-1",children:"⋮⋮"})}const JM=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDragHandle:sh},Symbol.toStringTag,{value:"Module"}));function Ts({title:t,count:n,expanded:s,onToggle:r,testId:a}){return e.jsxs("button",{type:"button",onClick:r,"aria-expanded":s,"data-testid":a,className:"flex w-full items-center gap-2 bg-transparent py-1 text-left cursor-pointer group",children:[e.jsx("span",{"aria-hidden":"true",className:"text-[var(--text-dim)] text-xs leading-none transition-transform group-hover:text-[var(--text-primary)] "+(s?"rotate-0":"-rotate-90"),children:"⌄"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)] "+(s?"font-medium":"font-normal"),children:t}),e.jsxs("span",{className:"text-sm text-[var(--text-dim)]",children:["(",n,")"]})]})}const XM=Object.freeze(Object.defineProperty({__proto__:null,PlanSectionHeader:Ts},Symbol.toStringTag,{value:"Module"}));function rh({slug:t,identity:n,step:s,age:r,dead:a}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{"data-testid":`plan-claim-identity-${t}`,children:["claimed by ",n]}),s&&e.jsx("span",{"data-testid":`plan-claim-step-${t}`,children:s}),e.jsxs("span",{"data-testid":`plan-claim-started-${t}`,children:["started ",r]}),a&&e.jsx("span",{className:"text-[var(--text-muted)]",children:"(inactive)"})]})}const QM=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRowMeta:rh},Symbol.toStringTag,{value:"Module"}));function ah({slug:t,title:n,timestamp:s,position:r,author:a,dragHandleRef:o,dragHandleAttributes:i,dragHandleListeners:c}){return e.jsxs(e.Fragment,{children:[o&&e.jsx(sh,{slug:t,handleRef:o,attributes:i,listeners:c}),typeof r=="number"&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)] tabular-nums min-w-[1.25rem]",children:[r,"."]}),a&&e.jsx(Rr,{author:a}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsx(gi,{title:n,timestamp:s})})]})}const ZM=Object.freeze(Object.defineProperty({__proto__:null,PlanRowIdentity:ah},Symbol.toStringTag,{value:"Module"}));function oh(t){return{dead:t.sessionAlive===!1}}function ih({claim:t,staleFetch:n=!1}){const s=An(),{dead:r}=oh(t),a=t.claimedBy.agentProvider??"agent",o=r?" (inactive)":"",i=dn(t.claimedBy.startedAt,s),c=t.source==="local"?`● this session · started ${i}`:t.source==="same-machine"?`claimed by ${a}@${t.claimedBy.machine} (same machine) · ${i}`:`claimed by ${a}@${t.claimedBy.machine} · ${i}`;return e.jsxs("span",{"data-testid":`plan-row-claim-badge-${t.slug}`,title:`Source: ${t.source}${o}${n?" (data may be stale)":""}`,className:"text-[10px] font-medium whitespace-nowrap px-1.5 py-0.5 rounded border",style:{borderColor:"var(--accent-orange)",backgroundColor:"color-mix(in srgb, var(--accent-orange) 12%, transparent)",color:"var(--text-primary)"},children:[c,o]})}const eI=Object.freeze(Object.defineProperty({__proto__:null,PlanRowClaimBadge:ih},Symbol.toStringTag,{value:"Module"})),lh="You'll be able to run a plan once the current build finishes.",Zk="This plan is waiting on earlier plans that haven't finished yet.",eS="Another session is already working on this plan.";function tS(t){switch(t){case"building":return lh;case"dependencies":return Zk;case"claimed":return eS}}function ch({message:t}){return e.jsx("span",{"aria-hidden":"true","data-testid":"plan-run-blocked-tooltip",className:"absolute bottom-full right-0 z-20 mb-2 w-max max-w-[15rem] rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] px-3 py-2 text-left text-[11px] normal-case tracking-normal leading-snug text-[var(--text-secondary)] shadow-lg",children:t})}const tI=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedTooltip:ch},Symbol.toStringTag,{value:"Module"}));function dh({slug:t,onRun:n,launching:s=!1,blockedReason:r=null}){const a=g=>{g.stopPropagation(),!s&&n(t)},o="text-[10px] uppercase tracking-wide px-2 py-0.5 rounded border cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed transition",i=" border-[var(--accent-primary)] text-[var(--accent-primary)] hover:bg-[var(--accent-primary)] hover:text-[var(--surface-bg)]",c=" border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed hover:bg-transparent",d=s,u=r!==null&&!s,[h,p]=l.useState(!1),m=r?tS(r):null,f=u&&h;return e.jsxs("button",{type:"button",onClick:a,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),onFocus:()=>p(!0),onBlur:()=>p(!1),disabled:d,"data-testid":`plan-run-${t}`,"aria-label":u&&m?`Run — ${m}`:void 0,className:"relative "+o+(u?c:i),children:[s?"Launching…":"Run",f&&m?e.jsx(ch,{message:m}):null]})}const nI=Object.freeze(Object.defineProperty({__proto__:null,PlanRunButton:dh},Symbol.toStringTag,{value:"Module"}));function nS({isAgentBuilding:t=!1,unsatisfiedDepCount:n=0,claim:s}){return t?"building":n>0?"dependencies":s&&s.source!=="local"?"claimed":null}function uh({slug:t,mode:n,expanded:s,onRun:r,launching:a=!1,blocked:o=!1,unsatisfiedDepCount:i=0,unsatisfiedDepTooltip:c,claim:d,staleFetch:u=!1}){return e.jsxs(e.Fragment,{children:[e.jsx(fi,{mode:n}),e.jsx(nh,{slug:t,count:i,tooltip:c}),d&&e.jsx(ih,{claim:d,staleFetch:u}),r&&e.jsx(dh,{slug:t,onRun:r,launching:a,blockedReason:nS({isAgentBuilding:o,unsatisfiedDepCount:i,claim:d})}),e.jsx(Ir,{expanded:s,testId:`plan-row-chevron-${t}`})]})}const sI=Object.freeze(Object.defineProperty({__proto__:null,PlanRowControls:uh},Symbol.toStringTag,{value:"Module"}));function Qa({children:t,tone:n,spacing:s="normal",testId:r}){const a=n==="error"?"text-[var(--accent-red)]":"text-[var(--text-muted)]",o=s==="tight"?"mt-2":"mt-3";return e.jsx("p",{"data-testid":r,className:`${o} text-sm ${a}`,children:t})}const rI=Object.freeze(Object.defineProperty({__proto__:null,PlanSectionStatus:Qa},Symbol.toStringTag,{value:"Module"}));function Lr({value:t,onChange:n,testId:s,placeholder:r="Describe the change you want"}){return e.jsx("textarea",{value:t,onChange:a=>n(a.target.value),placeholder:r,rows:4,"data-testid":s,"aria-label":r,className:"mt-4 w-full resize-y rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-3 py-2.5 text-sm text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:outline-none"})}const aI=Object.freeze(Object.defineProperty({__proto__:null,ChangeDescriptionInput:Lr},Symbol.toStringTag,{value:"Module"})),bi=e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})}),hh=e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 2.5c.35 3.1.9 5 2 6.1s3 1.65 6.1 2c-3.1.35-5 .9-6.1 2s-1.65 3-2 6.1c-.35-3.1-.9-5-2-6.1s-3-1.65-6.1-2c3.1-.35 5-.9 6.1-2s1.65-3 2-6.1z"})}),ph=e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M6 9.5l6 6 6-6"})}),mh=e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.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"})}),fh=e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),gh=e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 3l18 18M10.6 10.6a3 3 0 0 0 4.2 4.2M9.9 5.2A9.6 9.6 0 0 1 12 5c6.5 0 10 7 10 7a15.4 15.4 0 0 1-3.3 4M6.2 6.2A15.5 15.5 0 0 0 2 12s3.5 7 10 7a9.7 9.7 0 0 0 3.1-.5"})}),bh=e.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 3a9 9 0 1 0 9 9"}),e.jsx("path",{d:"M12 3v9l6 3"}),e.jsx("path",{d:"M16 4h5V9"})]}),oI=Object.freeze(Object.defineProperty({__proto__:null,CHAT_ICON:mh,CHEVRON_ICON:ph,EMPTY_MARK_ICON:bh,EYE_ICON:fh,EYE_OFF_ICON:gh,SEND_ICON:bi,SPARKLE_ICON:hh},Symbol.toStringTag,{value:"Module"})),sS=[{prompt:"Import my services from .env",label:"Import from .env"},{prompt:"Scan package.json and Cargo.toml for services",label:e.jsx(e.Fragment,{children:"Scan package.json & Cargo.toml"})},{prompt:"Help me add a service manually",label:"Add one manually"}];function xh({draft:t,onDraftChange:n,onSubmit:s,onAsk:r,brokerStarter:a}){return e.jsx("div",{className:"xsvc-empty-wrap",children:e.jsxs("div",{className:"xsvc-empty-card",children:[e.jsx("div",{className:"xsvc-empty-mark","aria-hidden":"true",children:bh}),e.jsx("h2",{children:"No external services mapped yet"}),e.jsx("p",{children:"Tell the AI what this project relies on and it keeps everything organized: it tracks renewals, flags missing keys, and answers questions about your stack."}),e.jsxs("div",{className:"xsvc-chat-hero",children:[e.jsxs("div",{className:"xsvc-lead",children:[mh,"Chat with the AI"]}),e.jsxs("form",{className:"xsvc-composer",onSubmit:s,children:[e.jsx("input",{className:"xsvc-cinput",type:"text",value:t,onChange:o=>n(o.target.value),placeholder:"e.g. We use Anthropic for the AI, Vercel for hosting, and our domain is codeyam.com"}),e.jsx("button",{type:"submit",className:"send","aria-label":"Send to the AI",children:bi})]}),e.jsxs("div",{className:"xsvc-chips",children:[sS.map(o=>e.jsxs("button",{type:"button",className:"xsvc-chip",onClick:()=>r==null?void 0:r(o.prompt),children:[e.jsx("span",{className:"g",children:"↳"}),o.label]},o.prompt)),a?e.jsxs("button",{type:"button",className:"xsvc-chip",onClick:a.onSelect,children:[e.jsx("span",{className:"g",children:"✦"}),a.label]}):null]})]})]})})}const iI=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesEmptyState:xh},Symbol.toStringTag,{value:"Module"})),Me=({children:t})=>e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t}),kc={vercel:e.jsx(Me,{children:e.jsx("path",{d:"M12 4l8 14H4z",fill:"currentColor",stroke:"none"})}),netlify:e.jsxs(Me,{children:[e.jsx("path",{d:"M12 3l9 9-9 9-9-9z"}),e.jsx("path",{d:"M12 8v8M8 12h8"})]}),cloudflare:e.jsx(Me,{children:e.jsx("path",{d:"M6 16h11a3 3 0 0 0 .3-6A5 5 0 0 0 8 9.2 4 4 0 0 0 6 16z"})}),fly:e.jsxs(Me,{children:[e.jsx("circle",{cx:"12",cy:"10",r:"6"}),e.jsx("path",{d:"M9 15l-1 5 4-2 4 2-1-5"})]}),github:e.jsxs(Me,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M9 20v-3c0-1 .5-1.6 1-2-2.3-.3-3.8-1.2-3.8-4a3 3 0 0 1 .8-2 2.8 2.8 0 0 1 .1-2s.8-.2 2.2.9a8 8 0 0 1 4 0c1.4-1.1 2.2-.9 2.2-.9a2.8 2.8 0 0 1 .1 2 3 3 0 0 1 .8 2c0 2.8-1.5 3.7-3.8 4 .5.4 1 1 1 2v3"})]}),anthropic:e.jsx(Me,{children:e.jsx("path",{d:"M12 4v16M4 12h16M6.3 6.3l11.4 11.4M17.7 6.3L6.3 17.7"})}),neon:e.jsx(Me,{children:e.jsx("path",{d:"M5 19V5l14 14V5"})}),stripe:e.jsx(Me,{children:e.jsx("path",{d:"M6 8.5c0-1.4 1.5-2.5 3.5-2.5S13 6.8 13.4 8M6 15.5c0 1.4 1.5 2.5 3.5 2.5S13 17.2 13.4 16M9.5 6v12"})})},Sc={"Code hosting":e.jsxs(Me,{children:[e.jsx("circle",{cx:"6",cy:"7",r:"2.4"}),e.jsx("circle",{cx:"6",cy:"17",r:"2.4"}),e.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),e.jsx("path",{d:"M6 9.4v5.2M17 11.4c0 3-3 3.6-6 4.2"})]}),"Package registry":e.jsxs(Me,{children:[e.jsx("path",{d:"M12 3l8 4.2v9.6L12 21l-8-4.2V7.2z"}),e.jsx("path",{d:"M4 7.2l8 4.3 8-4.3M12 11.5V21"})]}),"Cloud platform":e.jsx(Me,{children:e.jsx("path",{d:"M7 18h10a3.6 3.6 0 0 0 .3-7.2A5.6 5.6 0 0 0 6.8 9.6 3.9 3.9 0 0 0 7 18z"})}),"AI provider":e.jsxs(Me,{children:[e.jsx("path",{d:"M12 3v3.5M12 17.5V21M3 12h3.5M17.5 12H21"}),e.jsx("path",{d:"M6.3 6.3l2.5 2.5M15.2 15.2l2.5 2.5M17.7 6.3l-2.5 2.5M8.8 15.2l-2.5 2.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Cache & queue":e.jsxs(Me,{children:[e.jsx("path",{d:"M4 7h16M4 12h16M4 17h16"}),e.jsx("circle",{cx:"8",cy:"7",r:"1.3",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"14",cy:"12",r:"1.3",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"10",cy:"17",r:"1.3",fill:"currentColor",stroke:"none"})]}),"Storage & media":e.jsxs(Me,{children:[e.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"2"}),e.jsx("circle",{cx:"9",cy:"10",r:"1.8"}),e.jsx("path",{d:"M4 17l4.5-4.5L13 17M13 14l2.5-2.5L20 16"})]}),Messaging:e.jsx(Me,{children:e.jsx("path",{d:"M21 14a2 2 0 0 1-2 2H8l-4 4V5a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2z"})}),Search:e.jsxs(Me,{children:[e.jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),e.jsx("path",{d:"M15 15l5 5"})]}),Containers:e.jsxs(Me,{children:[e.jsx("rect",{x:"3",y:"10",width:"5",height:"5",rx:"0.8"}),e.jsx("rect",{x:"9.5",y:"10",width:"5",height:"5",rx:"0.8"}),e.jsx("rect",{x:"9.5",y:"4.5",width:"5",height:"5",rx:"0.8"}),e.jsx("path",{d:"M3 17.5c3 2.5 12 2.5 15.5-3a3.4 3.4 0 0 0 2.5.4"})]}),"CI/CD":e.jsxs(Me,{children:[e.jsx("path",{d:"M4 12a8 8 0 0 1 13.7-5.6M20 12a8 8 0 0 1-13.7 5.6"}),e.jsx("path",{d:"M17 3v4h-4M7 21v-4h4"})]}),Domain:e.jsxs(Me,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8.5"}),e.jsx("path",{d:"M3.5 12h17M12 3.5c2.5 2.3 2.5 14.7 0 17M12 3.5c-2.5 2.3-2.5 14.7 0 17"})]}),Hosting:e.jsxs(Me,{children:[e.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"6",rx:"1.5"}),e.jsx("rect",{x:"3.5",y:"13.5",width:"17",height:"6",rx:"1.5"}),e.jsx("path",{d:"M7 7.5h.01M7 16.5h.01"})]}),Payments:e.jsxs(Me,{children:[e.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),e.jsx("path",{d:"M3 9.5h18"})]}),Database:e.jsxs(Me,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Database ORM":e.jsxs(Me,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Backend platform":e.jsxs(Me,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),Authentication:e.jsxs(Me,{children:[e.jsx("circle",{cx:"9",cy:"9",r:"4"}),e.jsx("path",{d:"M12 12l7 7M16 16l2-2M18.5 13.5l1.5 1.5"})]}),"Transactional email":e.jsxs(Me,{children:[e.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),e.jsx("path",{d:"M3.5 7l8.5 6 8.5-6"})]}),"Product analytics":e.jsxs(Me,{children:[e.jsx("path",{d:"M4 20V4M4 20h16"}),e.jsx("path",{d:"M8 16v-3M12 16V8M16 16v-6"})]}),"Error monitoring":e.jsxs(Me,{children:[e.jsx("path",{d:"M12 3l8 4v5c0 5-3.5 8-8 9-4.5-1-8-4-8-9V7z"}),e.jsx("path",{d:"M12 8.5v4M12 15.5h.01"})]})},rS={vercel:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},github:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},resend:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},anthropic:{fg:"#d97757",bg:"rgba(217,119,87,0.14)"},neon:{fg:"#00e599",bg:"rgba(0,229,153,0.13)"},stripe:{fg:"#635bff",bg:"rgba(99,91,255,0.15)"},netlify:{fg:"#32e6e2",bg:"rgba(50,230,226,0.13)"},cloudflare:{fg:"#f38020",bg:"rgba(243,128,32,0.14)"},fly:{fg:"#8b5cf6",bg:"rgba(139,92,246,0.14)"},gitlab:{fg:"#fc6d26",bg:"rgba(252,109,38,0.14)"},openai:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},aws:{fg:"#ff9900",bg:"rgba(255,153,0,0.13)"},gcp:{fg:"#4285f4",bg:"rgba(66,133,244,0.14)"},supabase:{fg:"#3ecf8e",bg:"rgba(62,207,142,0.13)"},firebase:{fg:"#ffca28",bg:"rgba(255,202,40,0.13)"},mongodb:{fg:"#00ed64",bg:"rgba(0,237,100,0.12)"},redis:{fg:"#ff4438",bg:"rgba(255,68,56,0.13)"},docker:{fg:"#2496ed",bg:"rgba(36,150,237,0.14)"},twilio:{fg:"#f22f46",bg:"rgba(242,47,70,0.13)"},slack:{fg:"#e01e5a",bg:"rgba(224,30,90,0.13)"},algolia:{fg:"#5468ff",bg:"rgba(84,104,255,0.14)"},cloudinary:{fg:"#3448c5",bg:"rgba(52,72,197,0.16)"},sentry:{fg:"#a07cff",bg:"rgba(160,124,255,0.14)"},posthog:{fg:"#f9bd2b",bg:"rgba(249,189,43,0.13)"},clerk:{fg:"#6c47ff",bg:"rgba(108,71,255,0.15)"}};function yh(t){return t&&rS[t]||null}function vh({providerId:t,category:n}){return t&&kc[t]?kc[t]:n&&Sc[n]?Sc[n]:null}const lI=Object.freeze(Object.defineProperty({__proto__:null,G:Me,ProviderLogo:vh,providerBrand:yh},Symbol.toStringTag,{value:"Module"}));function jh(t){return t.length<=10?"•".repeat(Math.max(t.length,6)):`${t.slice(0,6)}••••••••••${t.slice(-4)}`}function xi({apiKey:t}){const[n,s]=l.useState(!1);return e.jsxs("div",{className:"xsvc-detrow",children:[e.jsx("span",{className:"xsvc-detlabel",children:"API key"}),e.jsxs("button",{type:"button",className:"xsvc-keyval",onClick:()=>s(r=>!r),"aria-label":n?"Hide API key":"Reveal API key",title:n?"Click to hide":"Click to reveal",children:[e.jsx("span",{className:"mono",children:n?t:jh(t)}),e.jsx("span",{className:"eye","aria-hidden":"true",children:n?gh:fh})]})]})}const cI=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:xi,maskKey:jh},Symbol.toStringTag,{value:"Module"}));function yi({svc:t,expanded:n,onToggle:s,onAction:r}){var i,c,d;const a=vh({providerId:t.providerId,category:t.category}),o=yh(t.providerId);return e.jsxs("div",{className:`xsvc-rowwrap${n?" open":""}`,children:[e.jsxs("div",{className:`xsvc-row${t.attn?" attn":""}${t.pending?" pending":""}`,role:"button",tabIndex:0,"aria-expanded":n,onClick:s,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s())},children:[e.jsx("div",{className:`xsvc-tile t-${t.tone??"lime"}`,style:o?{background:o.bg,color:o.fg}:void 0,children:a??t.monogram??t.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"xsvc-rmain",children:[e.jsxs("div",{className:"xsvc-rname",children:[t.name,(i=t.tags)==null?void 0:i.map((u,h)=>e.jsx("span",{className:`xsvc-tag ${u.kind}`,children:u.text},h))]}),e.jsx("div",{className:"xsvc-rdesc",children:t.desc})]}),e.jsxs("div",{className:"xsvc-rright",children:[t.actionLabel?e.jsx("button",{type:"button",className:"xsvc-addkey",onClick:u=>{u.stopPropagation(),t.actionKey&&r&&r(t.actionKey)},children:t.actionLabel}):e.jsxs("div",{className:"xsvc-rmeta",children:[t.metaBig?e.jsx("div",{className:"big",children:t.metaBig}):null,t.metaLil?e.jsx("div",{className:"lil",children:t.metaLil}):null]}),e.jsx("span",{className:`xsvc-arr${n?" down":""}`,"aria-hidden":"true",children:ph})]})]}),n?e.jsxs("div",{className:"xsvc-detail",children:[(c=t.detail)==null?void 0:c.map((u,h)=>e.jsxs("div",{className:"xsvc-detrow",children:[e.jsx("span",{className:"xsvc-detlabel",children:u.label}),e.jsx("span",{className:`xsvc-detval${u.mono?" mono":""}`,children:u.value})]},h)),t.apiKey?e.jsx(xi,{apiKey:t.apiKey}):null,!((d=t.detail)!=null&&d.length)&&!t.apiKey?e.jsx("div",{className:"xsvc-detrow",children:e.jsx("span",{className:"xsvc-detval",children:t.desc})}):null]}):null]})}const dI=Object.freeze(Object.defineProperty({__proto__:null,ServiceRow:yi},Symbol.toStringTag,{value:"Module"}));function wh({groups:t,onAction:n}){const[s,r]=l.useState(null);return e.jsx("div",{className:"xsvc-groups",children:t.map(a=>e.jsxs("div",{className:"xsvc-group",children:[e.jsxs("div",{className:"xsvc-group-head",children:[e.jsx("span",{className:"xsvc-seclabel",children:a.label}),e.jsx("span",{className:"xsvc-seccount",children:a.items.length})]}),e.jsx("div",{className:"xsvc-rows",children:a.items.map((o,i)=>{const c=`${a.label}:${o.name}:${i}`;return e.jsx(yi,{svc:o,expanded:s===c,onToggle:()=>r(d=>d===c?null:c),onAction:n},c)})})]},a.label))})}const uI=Object.freeze(Object.defineProperty({__proto__:null,ExternalServiceGroupList:wh},Symbol.toStringTag,{value:"Module"}));function vi({sort:t,onSortChange:n}){return e.jsxs("div",{className:"xsvc-toolbar",children:[e.jsx("span",{className:"xsvc-sortlbl",children:"Sort by"}),e.jsxs("div",{className:"xsvc-seg",children:[e.jsx("button",{type:"button",className:t==="type"?"on":"",onClick:()=>n("type"),children:"Type"}),e.jsx("button",{type:"button",className:t==="provider"?"on":"",onClick:()=>n("provider"),children:"Provider"})]})]})}const hI=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSortToolbar:vi},Symbol.toStringTag,{value:"Module"})),aS=["When does codeyam.com renew?","What's my monthly spend?","Anything missing a key?"];function _h({onPick:t}){return e.jsx("span",{className:"xsvc-chips",children:aS.map(n=>e.jsx("button",{type:"button",className:"xsvc-chip",onClick:()=>t(n),children:n},n))})}const pI=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSuggestionChips:_h},Symbol.toStringTag,{value:"Module"}));function kh({draft:t,onDraftChange:n,onSubmit:s,onAsk:r,chatSlot:a,bare:o=!1}){const i=!a&&t.trim()==="";return e.jsxs("div",{className:o?"xsvc-askcard xsvc-askcard-bare":"xsvc-askcard",children:[e.jsxs("form",{className:"xsvc-ask-composer",onSubmit:s,children:[e.jsx("span",{className:"ai","aria-hidden":"true",children:hh}),e.jsx("input",{className:"xsvc-cinput",type:"text",value:t,onChange:c=>n(c.target.value),placeholder:"Ask the AI about your domains, keys, subscriptions…"}),i?e.jsx(_h,{onPick:c=>{n(c),r==null||r(c)}}):null,e.jsx("button",{type:"submit",className:"send","aria-label":"Send to the AI",children:bi})]}),a?e.jsx("div",{className:"xsvc-ask-chat",children:a}):null]})}const mI=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesAskCard:kh},Symbol.toStringTag,{value:"Module"}));function Sh(){const t="M2 2 h4.5 v1.6 h-2.9 v2.9 h-1.6 z";return e.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:[0,90,180,270].map(n=>e.jsx("path",{d:t,transform:`rotate(${n} 8 8)`},n))})}const fI=Object.freeze(Object.defineProperty({__proto__:null,FullScreenIcon:Sh},Symbol.toStringTag,{value:"Module"}));function Rn(t,n){if(t.startsWith("http"))return t;const s=`/api/screenshots/${t}`;return typeof n=="number"?`${s}?cb=${n}`:s}function At({screenshotPath:t,cacheBuster:n,alt:s,className:r="",title:a}){const[o,i]=l.useState("loading"),[c,d]=l.useState(!1),u=l.useRef(null),h=t?Rn(t,n):"",p=()=>{i("success"),d(!0)},m=()=>{i("error"),d(!1)};return l.useEffect(()=>{i("loading"),d(!1);const f=u.current;f!=null&&f.complete&&(f.naturalHeight!==0?(i("success"),d(!0)):(i("error"),d(!1)))},[h]),t?e.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",title:a,children:[e.jsx("img",{ref:u,src:h,alt:s,onLoad:p,onError:m,className:r||"max-w-full max-h-full object-contain",style:{opacity:c?1:0,position:c?"relative":"absolute"}}),o==="loading"&&e.jsx("div",{className:"absolute inset-0 bg-[var(--bg-card)] animate-pulse rounded flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-[var(--text-dim)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),o==="error"&&e.jsxs("div",{className:"absolute inset-0 border border-[var(--border-subtle)] bg-[var(--bg-card)] rounded flex flex-col items-center justify-center text-xs gap-1",children:[e.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"}),e.jsx("span",{className:"text-[var(--text-dim)] whitespace-nowrap",children:"No Screenshot"})]})]}):e.jsx("div",{className:"w-full h-full border border-[var(--border-subtle)] bg-[var(--bg-card)] rounded flex flex-col items-center justify-center text-xs gap-1",title:a,children:e.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"})})}const gI=Object.freeze(Object.defineProperty({__proto__:null,SafeScreenshot:At},Symbol.toStringTag,{value:"Module"}));function Nh({shots:t,initialIndex:n=0,onSelect:s,onClose:r}){const a=t.length-1,o=l.useCallback(g=>Math.max(0,Math.min(a,g)),[a]),[i,c]=l.useState(()=>o(n)),d=l.useCallback(g=>c(b=>o(b+g)),[o]),u=l.useCallback(g=>{g.key==="Escape"?(g.preventDefault(),r()):g.key==="ArrowLeft"?(g.preventDefault(),d(-1)):g.key==="ArrowRight"&&(g.preventDefault(),d(1))},[r,d]);if(l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]),t.length===0)return null;const h=t[i],p=i===0,m=i===a,f="flex h-14 w-14 flex-none items-center justify-center rounded-full border-2 border-[var(--border-subtle)] bg-[var(--bg-card)] text-3xl text-[var(--text-primary)] transition hover:border-[var(--text-primary)] hover:bg-[var(--bg-surface)] disabled:cursor-default disabled:opacity-25 disabled:hover:border-[var(--border-subtle)] disabled:hover:bg-[var(--bg-card)]";return e.jsx("div",{className:"fixed inset-0 z-[70] flex flex-col",style:{background:"rgba(30, 30, 30, 0.90)"},role:"dialog","aria-label":"Scenario gallery","data-testid":"scenario-gallery-modal",onClick:r,children:e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col px-6 py-4",onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[11px] font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:h.routeLabel}),e.jsx("p",{className:"truncate text-lg font-semibold text-[var(--text-primary)]",children:h.name})]}),e.jsxs("span",{className:"flex-none text-xs font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:[i+1," / ",t.length]}),e.jsx("button",{type:"button",onClick:r,"aria-label":"Close gallery",className:"flex-none text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"✕"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-4",children:[e.jsx("button",{type:"button",onClick:()=>d(-1),disabled:p,"aria-label":"Previous scenario",className:f,children:"‹"}),e.jsx("button",{type:"button",onClick:()=>{s(h.slug),r()},"aria-label":`Open ${h.name} live`,className:"flex min-h-0 flex-1 cursor-pointer items-center justify-center self-stretch",children:e.jsx("div",{className:"flex max-h-[80vh] max-w-[90vw] items-center justify-center",children:e.jsx(At,{screenshotPath:h.screenshotPath??void 0,cacheBuster:h.screenshotCapturedAtMs??void 0,alt:h.name,className:"max-h-[80vh] max-w-[90vw] object-contain"})})}),e.jsx("button",{type:"button",onClick:()=>d(1),disabled:m,"aria-label":"Next scenario",className:f,children:"›"})]}),e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>{s(h.slug),r()},className:"rounded bg-[var(--lime-300)] px-4 py-2 font-semibold text-black transition hover:brightness-110",children:"Open Live Preview"})})]})})}const bI=Object.freeze(Object.defineProperty({__proto__:null,ScenarioGalleryModal:Nh},Symbol.toStringTag,{value:"Module"}));function Ch({reason:t}){const{headline:n,detail:s}=Th(t);return e.jsxs("div",{className:"py-4 text-sm text-[var(--text-dim)]",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:n}),s?e.jsx("p",{className:"mt-1",children:s}):null]})}function Th(t){switch(t.kind){case"no-component-scenarios":return{headline:"No components yet.",detail:"Capture a component scenario and it will appear here — a scenario is what marks a component as browsable."};case"missing-from-glossary":return{headline:`${t.count} component ${$n(t.count,"scenario")} name ${$n(t.count,"a component","components")} not in the glossary${Nc(t.examples)}.`,detail:"Deconstruct or register those components so they can be surfaced here."};case"not-visual-components":return{headline:`${t.count} ${$n(t.count,"component")} matched glossary ${$n(t.count,"entry","entries")} but ${$n(t.count,"is","are")} not recognized as visual ${$n(t.count,"component","components")}${Nc(t.examples)}.`,detail:"Check `components.fileExtensions` in .codeyam/stack.json — a stack whose components are not .tsx/.jsx must list its own extensions."}}}function $n(t,n,s){return t===1?n:s??`${n}s`}function Nc(t){return t.length===0?"":` (e.g. ${t.join(", ")})`}const xI=Object.freeze(Object.defineProperty({__proto__:null,ComponentSurfaceReasonNote:Ch,describeReason:Th},Symbol.toStringTag,{value:"Module"})),oS="Good question. We'll explain this plainly as we go, and you can ask anything at any step. Nothing happens until you say go.",iS=[{keywords:["free","cost","pay","price"],answer:"Yes, it's genuinely free to start. Vercel's free tier comfortably covers an app like yours with no credit card. If it ever grew into heavy traffic we'd tell you long before any cost."},{keywords:["domain","url","address","name"],answer:"You can. You'll launch on a free link like your-app.vercel.app today, then connect your own address whenever you're ready. We'll walk you through it."},{keywords:["move","switch","leave","lock"],answer:"You're never locked in. Your app and its code stay yours, and you can move to another host at any time."},{keywords:["safe","secure","break","data"],answer:"It's safe. Going live doesn't change your app or your data, it just makes a copy reachable by a link. You can take it offline again anytime."}];function lS(t){const n=t.toLowerCase();for(const s of iS)if(s.keywords.some(r=>n.includes(r)))return s.answer;return oS}const cS={"clerk.freeTier":{value:"50,000 monthly active users free (Clerk bills by MAU)",verified:"2026-06",source:"https://clerk.com/pricing",staleness:"high"},"auth0.freeTier":{value:"25,000 monthly active users free, then paid from ~$35/mo",verified:"2026-06",source:"https://auth0.com/pricing",staleness:"med"},"resend.free":{value:"3,000 emails/mo and 100/day free",verified:"2026-06",source:"https://resend.com/pricing",staleness:"med"},"vercel.hobby":{value:"Hobby is free for non-commercial use; commercial needs Pro (~$20/user/mo)",verified:"2026-06",source:"https://vercel.com/pricing",staleness:"med"},"supabase.free":{value:"Free projects pause after ~1 week idle and have no automatic backups (Pro adds 7-day)",verified:"2026-06",source:"https://supabase.com/pricing",staleness:"med"},"netlify.free":{value:"New accounts use a monthly-credit model (legacy accounts: ~100GB/mo bandwidth)",verified:"2026-06",source:"https://www.netlify.com/pricing/",staleness:"med"},"cloudflarePages.free":{value:"Unlimited static bandwidth and requests on the free plan",verified:"2026-06",source:"https://pages.cloudflare.com/",staleness:"med"},"netlifyForms.free":{value:"100 submissions/mo",verified:"2026-06",source:"https://www.netlify.com/pricing/",staleness:"med"},"flyio.pricing":{value:"Pay-as-you-go; no standing always-free allowance since Oct 2024",verified:"2026-06",source:"https://fly.io/docs/about/pricing/",staleness:"low"},"stripe.usCardFee":{value:"2.9% + 30¢",verified:"2026-06",source:"https://stripe.com/pricing",staleness:"low"},"appleDeveloper.fee":{value:"$99 / year",verified:"2026-06",source:"https://developer.apple.com/support/compare-memberships/",staleness:"low"},"googlePlay.fee":{value:"$25 once",verified:"2026-06",source:"https://support.google.com/googleplay/android-developer/answer/6112435",staleness:"low"},"appStore.commission":{value:"15–30% (15% under the Small Business Program and on subscriptions after year one)",verified:"2026-06",source:"https://developer.apple.com/app-store/small-business-program/",staleness:"med"},"googlePlay.commission":{value:"15–30% (15% on the first $1M/year and on all subscriptions)",verified:"2026-06",source:"https://support.google.com/googleplay/android-developer/answer/112622",staleness:"med"},"chromeStore.fee":{value:"$5",verified:"2026-06",source:"https://developer.chrome.com/docs/webstore/register/",staleness:"low"},"playStore.closedTestGate":{value:"Personal accounts (created after 2023-11-13) need ≥12 testers opted in for 14 continuous days before production",verified:"2026-06",source:"https://support.google.com/googleplay/android-developer/answer/14151465",staleness:"med"},"appleScreenshots.iphone":{value:"6.9″ 1320×2868 (older 6.7″/6.5″ accepted as a fallback)",verified:"2026-06",source:"https://developer.apple.com/help/app-store-connect/reference/screenshot-specifications/",staleness:"med"},"appleScreenshots.ipad":{value:"13″ 2064×2752 (legacy 12.9″ 2048×2732 accepted)",verified:"2026-06",source:"https://developer.apple.com/help/app-store-connect/reference/screenshot-specifications/",staleness:"med"},"registry.twoFactor":{value:"npm enforces 2FA for publishing (required on high-impact packages); crates.io, PyPI, and RubyGems all support 2FA and increasingly require it for publishing",verified:"2026-06",source:"https://docs.npmjs.com/requiring-2fa-for-package-publishing-and-settings-modification",staleness:"med"},"registry.oidc":{value:"PyPI and npm support OIDC “trusted publishing” — CI authenticates with a short-lived identity, no long-lived token. Caveat: npm trusted publishing cannot perform a package's first publish; that initial release still needs a token",verified:"2026-06",source:"https://docs.pypi.org/trusted-publishers/",staleness:"med"},"supplyChain.signedReleases":{value:"npm publishes provenance attestations (Sigstore) for packages built in trusted CI, and PyPI attaches PEP 740 attestations on trusted-publisher uploads — both verifiable back to the source commit and workflow",verified:"2026-06",source:"https://docs.npmjs.com/generating-provenance-statements",staleness:"med"}};function xe(t){return cS[t]}const dS=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function uS(t){const n=/^(\d{4})-(\d{2})$/.exec(t);if(!n)return t;const s=Number(n[2])-1;return s<0||s>11?t:`${dS[s]} ${n[1]}`}function hS(t,n){const s=/^(\d{4})-(\d{2})$/.exec(t);if(!s)return 0;const r=Number(s[1]),a=Number(s[2])-1,o=(n.getFullYear()-r)*12+(n.getMonth()-a);return o<0?0:o}const pS=12;function mS(t,n){return t.staleness==="low"?!1:hS(t.verified,n)>pS}function un({fact:t,asOf:n=new Date}){if(t.staleness==="low")return null;const s=mS(t,n);return e.jsxs("span",{className:"fact-fresh"+(s?" stale":""),title:`Source: ${t.source}`,children:[s?"needs re-check · ":"verified ",uS(t.verified)]})}const yI=Object.freeze(Object.defineProperty({__proto__:null,FactFreshness:un},Symbol.toStringTag,{value:"Module"}));function Qe({size:t=15,color:n="var(--green-300)"}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:n,strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M3 8.4l3 3 7-7.4"})})}function Dr(){return e.jsx("div",{className:"pv-logo",children:e.jsx("svg",{width:"26",height:"22",viewBox:"0 0 26 22",fill:"#0a0a0a","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})})})}function Ph(){return e.jsx("div",{className:"journey",children:e.jsxs("div",{className:"jrow",children:[e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile",children:"💻"}),e.jsx("div",{className:"jlbl",children:"Your computer"}),e.jsx("div",{className:"jsub",children:"Only you can see it"})]}),e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket"}),e.jsx("span",{children:"→"})]}),e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile lime",children:"☁️"}),e.jsx("div",{className:"jlbl",children:"Hosting"}),e.jsx("div",{className:"jsub",children:"A home on the internet"})]}),e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket",style:{animationDelay:"1.8s"}}),e.jsx("span",{children:"→"})]}),e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile",children:"🌍"}),e.jsx("div",{className:"jlbl",children:"Anyone, anywhere"}),e.jsx("div",{className:"jsub",children:"Opens with a link"})]})]})})}function Oh(){const t=xe("vercel.hobby");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"reasons",children:[e.jsxs("div",{className:"reason",children:[e.jsx(Qe,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Free to start."})," No credit card, no surprise bills for an app this size."]})]}),e.jsxs("div",{className:"reason",children:[e.jsx(Qe,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Built for how your app is made."})," It deploys the way your app already works, so it just runs."]})]}),e.jsxs("div",{className:"reason",children:[e.jsx(Qe,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Your own web address later."})," Launch on a free link today, add a custom domain whenever you like."]})]})]}),e.jsxs("p",{className:"reason-foot",children:["One catch worth knowing: ",t.value,". So the free link is perfect for trying it out and sharing, but once your app is charging money you'll want the paid tier.",e.jsx(un,{fact:t})]})]})}function Ah(){return e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Free tier"}),e.jsx("span",{className:"chip",children:"Custom domain later"}),e.jsx("span",{className:"chip",children:"~5 min to set up"})]})}function Rh(){const[t,n]=l.useState(!1);return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>n(s=>!s),children:[t?"Hide other options":"Vercel not for you? See other options",e.jsx("span",{className:"chev",style:{transform:t?"rotate(180deg)":"none"},children:"⌄"})]}),t?e.jsxs("div",{className:"alts",children:[e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#16a3a3,#0d6e6e)"},children:"N"}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:"Netlify"}),e.jsx("div",{className:"altdesc",children:"Also free to start and very similar to set up. A solid pick if you'd rather use it."})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]}),e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#f6821f,#c25e0a)"},children:"C"}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:"Cloudflare Pages"}),e.jsx("div",{className:"altdesc",children:"Best if you expect heavy worldwide traffic. A little more to learn up front."})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]})]}):null]})}const fS=[{t:'What does "going live" actually do?',a:"It puts a copy of your app on the internet at a web address, so anyone you share the link with can open it. Your version on your computer keeps working exactly as before."},{t:"Can I undo it or take it offline?",a:"Anytime. You can unpublish with one click, and it goes back to running only on your computer. Nothing is permanent."},{t:"Do I need to understand servers?",a:"No. That's the whole point of letting us set it up. We handle the technical parts and explain each step in plain language as it happens."}];function Eh(){const[t,n]=l.useState(-1);return e.jsx("div",{className:"faq",children:fS.map((s,r)=>e.jsxs("div",{className:"faqitem",children:[e.jsxs("button",{type:"button",className:"faqq"+(t===r?" open":""),onClick:()=>n(t===r?-1:r),children:[s.t,e.jsx("span",{className:"chev",children:"⌄"})]}),t===r?e.jsx("div",{className:"faqa",children:s.a}):null]},s.t))})}function Mh(){const[t,n]=l.useState(""),[s,r]=l.useState(null),a=o=>{r(lS(o)),n("")};return e.jsxs("div",{className:"ask",children:[e.jsxs("div",{className:"askrow",children:[e.jsx("input",{value:t,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&t.trim()&&a(t)},placeholder:'Ask anything, e.g. "Is it really free?" or "Can I use my own domain?"'}),e.jsx("button",{type:"button",onClick:()=>t.trim()&&a(t),"aria-label":"Ask",children:"↑"})]}),e.jsx("div",{className:"asknote",children:"Ask before you commit to anything."}),s?e.jsxs("div",{className:"askans",children:[e.jsx("span",{className:"askav",children:"‹Y"}),e.jsx("div",{className:"at",children:s})]}):null]})}const vI=Object.freeze(Object.defineProperty({__proto__:null,Alts:Rh,AskBox:Mh,Check:Qe,Chips:Ah,Faq:Eh,Journey:Ph,Reasons:Oh,VercelMark:Dr},Symbol.toStringTag,{value:"Module"})),gS={"chrome.devConsole":{url:"https://chrome.google.com/webstore/devconsole",label:"Open the Chrome Web Store developer dashboard"},"chrome.register":{url:xe("chromeStore.fee").source,label:"Chrome Web Store registration guide"},"google.oauthConsent":{url:"https://console.cloud.google.com/apis/credentials/consent",label:"Open the OAuth consent screen (Google Cloud console)"},"firefox.amoDevHub":{url:"https://addons.mozilla.org/developers/",label:"Firefox Add-ons (AMO) developer hub"},"edge.partnerDashboard":{url:"https://partner.microsoft.com/dashboard/microsoftedge",label:"Edge Add-ons partner dashboard"}};function bS(t){return gS[t]}function Ct({linkKey:t,label:n}){const s=bS(t);return e.jsxs("a",{className:"setup-extlink",href:s.url,target:"_blank",rel:"noreferrer noopener",children:[e.jsx("span",{className:"setup-extlink-label",children:n??s.label}),e.jsx("span",{className:"setup-extlink-glyph","aria-hidden":"true",children:"↗"})]})}function he({children:t}){return e.jsx("div",{className:"reasons",children:t})}function A({lead:t,children:n}){return e.jsxs("div",{className:"reason",children:[e.jsx(Qe,{}),e.jsxs("span",{children:[e.jsx("b",{children:t})," ",n]})]})}function ji({spaced:t=!1,children:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",style:t?{marginTop:24}:void 0,children:"Keep a changelog"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"One CHANGELOG.md, grouped by version.",children:["Follow the ",e.jsx("b",{children:"Keep a Changelog"})," convention: Added / Changed / Fixed / Removed under each release, newest first. Write it for the person deciding whether to upgrade."]}),e.jsxs(A,{lead:"Or generate it from your commits.",children:["If you write ",e.jsx("b",{children:"Conventional Commits"})," (",e.jsx("code",{children:"feat:"}),","," ",e.jsx("code",{children:"fix:"}),", ",e.jsx("code",{children:"feat!:"})," for breaking), tools like release-please or git-cliff assemble the changelog — and even the next version number — for you."]}),n]})]})}function Fr(){return e.jsxs("div",{className:"setup-note",style:{marginTop:14},children:[e.jsxs("p",{children:["Publishing to ",e.jsx("b",{children:"Firefox Add-ons (AMO)"})," or ",e.jsx("b",{children:"Edge Add-ons"})," ","follows an analogous path — a developer account, store assets, and a review — with its own console. The steps below are written for the Chrome Web Store."]}),e.jsxs("p",{children:[e.jsx("b",{children:"Fees differ:"})," the"," ",e.jsx("b",{children:xe("chromeStore.fee").value})," registration fee is Chrome-only and one-time — Firefox AMO and Edge Add-ons charge no developer fee."]}),e.jsxs("div",{className:"setup-note-links",children:[e.jsx(Ct,{linkKey:"firefox.amoDevHub"}),e.jsx(Ct,{linkKey:"edge.partnerDashboard"})]})]})}const jI=Object.freeze(Object.defineProperty({__proto__:null,ChangelogSection:ji,ReqItem:A,ReqList:he,SetupExternalLink:Ct,StoreAlternativesNote:Fr},Symbol.toStringTag,{value:"Module"}));function Ta(t){const n=vk(t);if(n)return{selectedAppDir:n,selectedEntityHash:null};const s=jk(t);return s?{selectedAppDir:null,selectedEntityHash:s}:{selectedAppDir:null,selectedEntityHash:null}}function Pa(t){return`${ni()}/apps/${t}`}function Ih(t){return`${ni()}/entities/${t}`}function Ps(t,n){const s=`${t}:${n}`;let r=2166136261;for(let a=0;a<s.length;a++)r^=s.charCodeAt(a),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}function En(t){return(t.split("/").pop()??t).replace(/\.[^.]+$/,"")}function Za(t){if(!t.pageFilePath)return null;const n=t.entityName??En(t.pageFilePath);return Ps(t.pageFilePath,n)}function Lh(t){const n=Za(t);return n===null?null:Ih(n)}function yr({href:t,onNavigate:n,children:s,...r}){return e.jsx("a",{...r,href:t,onClick:a=>{a.button===0&&!a.metaKey&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&(a.preventDefault(),n())},children:s})}const wI=Object.freeze(Object.defineProperty({__proto__:null,NavLink:yr},Symbol.toStringTag,{value:"Module"}));function Dh({scenario:t,onSelect:n}){const s=t.screenshotPaths[0]??null;return e.jsxs("button",{type:"button",onClick:n,className:`relative text-left w-full${n?" cursor-pointer group/thumb":""}`,children:[e.jsx("div",{className:"aspect-[16/10] w-full flex items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] transition group-hover/thumb:border-[var(--text-dim)]",children:e.jsx(At,{screenshotPath:s??void 0,alt:t.name})}),t.dimensions.length>0?e.jsx("span",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1 py-0.5 text-[8px] text-white",children:t.dimensions[0]}):null,e.jsx("p",{className:"mt-1.5 truncate text-[13px] text-[var(--text-dim)]",children:t.name})]})}const _I=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardThumbnail:Dh},Symbol.toStringTag,{value:"Module"}));function Fh({routeEntity:t,variant:n}){const s=t.scenarios.length;return n==="explore"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-bold uppercase tracking-wider text-[var(--text-primary)] group-hover:underline",children:t.displayName}),s>0?e.jsxs("span",{className:"text-sm text-[var(--text-dim)]",children:["(",s,")"]}):null]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] transition",children:t.displayName}),e.jsx("span",{className:"font-mono text-xs text-[var(--text-dim)]",children:t.route}),s>0?e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["[",s,"]"]}):null,e.jsx("span",{className:"ml-auto text-xs text-[var(--text-dim)] group-hover:text-[var(--text-muted)] transition",children:"›"})]})}const kI=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardHeading:Fh},Symbol.toStringTag,{value:"Module"}));function zh({collapsed:t,onToggle:n,disclosable:s}){return s?e.jsx("button",{type:"button",onClick:n,"aria-label":t?"Expand group":"Collapse group",className:"shrink-0 w-5 text-[var(--text-dim)] hover:text-[var(--text-primary)] transition text-xs",children:t?"▸":"▾"}):e.jsx("span",{className:"shrink-0 w-5"})}const SI=Object.freeze(Object.defineProperty({__proto__:null,RouteGroupDisclosure:zh},Symbol.toStringTag,{value:"Module"})),Cc={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5"};function wi({routeEntity:t,onSelectRoute:n,onSelectScenario:s,columns:r=4,defaultCollapsed:a=!1,headingVariant:o="default"}){const i=t.scenarios.length,[c,d]=l.useState(a),u=Lh(t),h=o==="explore",p=h?"group flex min-w-0 cursor-pointer items-baseline gap-2 text-left":"group flex flex-1 min-w-0 cursor-pointer items-center gap-2 text-left",m=e.jsx(Fh,{routeEntity:t,variant:o}),f=e.jsx(zh,{collapsed:c,onToggle:()=>d(b=>!b),disclosable:i>0}),g=u?e.jsx(yr,{href:u,onNavigate:()=>n(t.route),className:p,children:m}):e.jsx("button",{onClick:()=>n(t.route),className:p,type:"button",children:m});return e.jsxs("div",{className:"mb-10 border-b border-[var(--border-subtle)] pb-8",children:[e.jsx("div",{className:"flex items-center gap-2",children:h?e.jsxs(e.Fragment,{children:[g,f]}):e.jsxs(e.Fragment,{children:[f,g]})}),i>0&&!c?e.jsx("div",{className:`mt-4 grid gap-x-5 gap-y-9 ${Cc[r]??Cc[4]}`,children:t.scenarios.map(b=>e.jsx(Dh,{scenario:b,onSelect:s?()=>s(b.slug):void 0},b.slug))}):i===0?e.jsx("p",{className:`mt-1 text-[10px] text-[var(--text-dim)]${h?"":" pl-7"}`,children:"No scenarios yet"}):null]})}const NI=Object.freeze(Object.defineProperty({__proto__:null,RouteListCard:wi},Symbol.toStringTag,{value:"Module"}));function $h({active:t,onChange:n}){const s=r=>`rounded-lg px-5 py-1.5 text-sm font-medium transition ${r?"bg-[var(--bg-card)] text-[var(--text-primary)]":"text-[var(--text-dim)] hover:text-[var(--text-secondary)]"}`;return e.jsxs("div",{role:"tablist","aria-label":"Simulation kind",className:"flex items-center gap-1 rounded-xl bg-[var(--bg-surface,transparent)] border border-[var(--border-subtle)] p-1 shrink-0",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":t==="pages",onClick:()=>n("pages"),className:s(t==="pages"),children:"Pages"}),e.jsx("button",{type:"button",role:"tab","aria-selected":t==="components",onClick:()=>n("components"),className:s(t==="components"),children:"Components"})]})}const CI=Object.freeze(Object.defineProperty({__proto__:null,RouteKindToggle:$h},Symbol.toStringTag,{value:"Module"}));function Bh(){return e.jsxs("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"7",cy:"7",r:"4.5"}),e.jsx("path",{d:"M10.4 10.4 L14 14"})]})}const TI=Object.freeze(Object.defineProperty({__proto__:null,SearchIcon:Bh},Symbol.toStringTag,{value:"Module"}));function Hh({value:t,onChange:n,scopeLabel:s}){return e.jsxs("div",{className:"relative ml-auto w-full max-w-sm min-w-0",children:[e.jsx("span",{className:"pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-[var(--text-dim)]",children:e.jsx(Bh,{})}),e.jsx("input",{type:"search",value:t,onChange:r=>n(r.target.value),placeholder:"Search","aria-label":`Search ${s}`,className:"w-full rounded-xl border border-[var(--border-subtle)] bg-[var(--bg-surface,transparent)] py-2.5 pl-11 pr-4 text-sm text-[var(--text-secondary)] placeholder:text-[var(--text-dim)] focus:border-[var(--lime-300)] focus:outline-none"})]})}const PI=Object.freeze(Object.defineProperty({__proto__:null,RouteSearchField:Hh},Symbol.toStringTag,{value:"Module"}));function qh({columns:t}){const a=(12-(t-1)*1.6)/t;return e.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:Array.from({length:t},(o,i)=>e.jsx("rect",{x:2+i*(a+1.6),y:3,width:a,height:10,rx:.7},i))})}const OI=Object.freeze(Object.defineProperty({__proto__:null,GridColumnsIcon:qh},Symbol.toStringTag,{value:"Module"}));function Wh({columns:t,onChange:n,options:s=[2,3,4,5]}){return e.jsxs("div",{className:"flex items-center gap-1.5",title:"Thumbnails per row",children:[e.jsx("span",{className:"text-[11px] font-semibold tracking-widest uppercase text-[var(--text-dim)] mr-0.5",children:"Grid"}),s.map(r=>e.jsx("button",{type:"button",onClick:()=>n(r),"aria-label":`${r} per row`,"aria-pressed":t===r,className:`w-7 h-6 rounded flex items-center justify-center transition ${t===r?"bg-[var(--lime-300)] text-black":"text-[var(--text-dim)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card)]"}`,children:e.jsx(qh,{columns:r})},r))]})}const AI=Object.freeze(Object.defineProperty({__proto__:null,GridDensityControl:Wh},Symbol.toStringTag,{value:"Module"}));function Gh({columns:t,onColumnsChange:n,onOpenGallery:s}){return e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[s?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:s,"aria-label":"Full screen",title:"Full screen",className:"w-7 h-6 rounded flex items-center justify-center transition text-[var(--text-dim)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card)]",children:e.jsx(Sh,{})}),e.jsx("div",{className:"h-5 w-px bg-[var(--border-subtle)]"})]}):null,e.jsx(Wh,{columns:t,onChange:n})]})}const RI=Object.freeze(Object.defineProperty({__proto__:null,RouteViewControls:Gh},Symbol.toStringTag,{value:"Module"}));function xS(t){const n=[];for(const s of t)for(const r of s.scenarios)n.push({slug:r.slug,name:r.name,routeLabel:s.route||s.displayName,screenshotPath:r.screenshotPaths[0]??null,screenshotCapturedAtMs:r.screenshotCapturedAtMs??null});return n}function Uh({pages:t,components:n,componentSurfaceReason:s=null,onSelectRoute:r,onSelectScenario:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(4),[u,h]=l.useState(""),[p,m]=l.useState(!1),f=o==="components",g=f?n:t,b=l.useMemo(()=>xS(g),[g]),x=b.length>0&&!!a,y=l.useMemo(()=>{const v=u.trim().toLowerCase();return v?g.filter(_=>_.displayName.toLowerCase().includes(v)):g},[g,u]);return e.jsxs("div",{children:[p&&x?e.jsx(Nh,{shots:b,onSelect:v=>a==null?void 0:a(v),onClose:()=>m(!1)}):null,e.jsxs("div",{className:"flex items-center gap-5 mb-9",children:[e.jsx($h,{active:o,onChange:i}),e.jsx(Hh,{value:u,onChange:h,scopeLabel:f?"components":"pages"}),e.jsx(Gh,{columns:c,onColumnsChange:d,onOpenGallery:x?()=>m(!0):void 0})]}),y.length>0?y.map((v,_)=>e.jsx(wi,{routeEntity:v,onSelectRoute:r,onSelectScenario:a,columns:c,defaultCollapsed:f,headingVariant:"explore"},v.route??v.displayName??_)):g.length>0?e.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",f?"components":"pages"," match “",u.trim(),"”."]}):f&&s?e.jsx(Ch,{reason:s}):e.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",f?"components":"pages"," yet."]})]})}const EI=Object.freeze(Object.defineProperty({__proto__:null,RouteListTabs:Uh},Symbol.toStringTag,{value:"Module"}));function _i(t,n){const s=t.url??"Uncategorized",r=n.find(o=>o.route===s),a=(r==null?void 0:r.scenarios)??[t];if(!t.url&&t.componentName){const o=a.filter(i=>i.componentName===t.componentName);return o.length?o:[t]}return a}function eo(t){const n=t.replace(/\s*\[[^\]]*\]\s*$/,""),s=n.indexOf(" - ");return s===-1?{pageName:null,stateName:n}:{pageName:n.slice(0,s),stateName:n.slice(s+3)}}function Vh(t){return Vo(t)?t.componentName??eo(t.name).pageName:eo(t.name).pageName}function zr(t){return eo(t.name).stateName}function Yh({currentScenario:t,scenarioGroups:n,onSelect:s,onCreateNew:r,onClose:a}){const[i,c]=l.useState(()=>({x:typeof window<"u"?Math.max(16,window.innerWidth-320-24):800,y:64})),d=l.useRef(null),u=f=>{d.current={dx:f.clientX-i.x,dy:f.clientY-i.y},f.currentTarget.setPointerCapture(f.pointerId)},h=f=>{d.current&&c({x:f.clientX-d.current.dx,y:f.clientY-d.current.dy})},p=f=>{d.current=null,f.currentTarget.releasePointerCapture(f.pointerId)},m=l.useMemo(()=>_i(t,n),[t,n]);return e.jsxs("div",{className:"fixed z-50 flex flex-col rounded-xl border border-[#3d3d3d] bg-[#1b1b1b] shadow-2xl",style:{left:i.x,top:i.y,width:320,maxHeight:"70vh"},role:"dialog","aria-label":"Scenarios",children:[e.jsxs("div",{onPointerDown:u,onPointerMove:h,onPointerUp:p,className:"flex items-center justify-between px-3 py-2 border-b border-[#3d3d3d] cursor-move select-none",children:[e.jsx("span",{className:"text-[11px] font-mono font-semibold tracking-widest text-gray-300",children:"SCENARIOS"}),e.jsx("button",{type:"button",onClick:a,onPointerDown:f=>f.stopPropagation(),"aria-label":"Close scenarios",className:"text-gray-400 hover:text-white text-lg leading-none px-1 cursor-pointer",children:"×"})]}),e.jsx("div",{className:"overflow-y-auto p-2 flex flex-col gap-2 flex-1 min-h-0",children:m.map(f=>{const g=f.slug===t.slug,b=f.screenshotPaths[0];return e.jsxs("button",{type:"button",onClick:()=>s(f.slug),className:`flex items-center gap-3 w-full p-2 rounded-lg text-left transition-colors cursor-pointer border ${g?"border-[var(--lime-300)] bg-[#1a2a30]":"border-[#333] hover:bg-[#242424]"}`,children:[e.jsx("div",{className:"w-24 h-16 shrink-0 rounded-md overflow-hidden border border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:b?e.jsx("img",{src:Rn(b),alt:"",className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-[10px] text-gray-600",children:"No preview"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[11px] text-gray-500 truncate",children:f.url??"component"}),e.jsx("div",{className:`text-sm font-medium truncate ${g?"text-white":"text-gray-200"}`,children:zr(f)})]})]},f.slug)})}),e.jsx("button",{type:"button",onClick:r,className:"border-t border-[#3d3d3d] px-3 py-2.5 text-left text-[11px] font-mono tracking-wide text-[var(--accent-active)] hover:bg-[var(--accent-active)]/10 cursor-pointer",children:"+ CREATE NEW STATE"})]})}const MI=Object.freeze(Object.defineProperty({__proto__:null,LivePageScenariosModal:Yh},Symbol.toStringTag,{value:"Module"})),Mn={apps:[],isSingleApp:!1,onSelectApps:()=>{},onSelectApp:()=>{},onSelectRoute:()=>{}};function pn(){const[t,n]=l.useState({}),s=l.useRef({});return l.useEffect(()=>A1(r=>{if(!r.ok)return;const a=r.data,o=typeof a.scenariosVersion=="number"?a.scenariosVersion:void 0,i=typeof a.plansVersion=="number"?a.plansVersion:void 0,c=typeof a.manualTestsVersion=="number"?a.manualTestsVersion:void 0,d=typeof a.testsVersion=="number"?a.testsVersion:void 0,u=typeof a.claimsVersion=="number"?a.claimsVersion:void 0,h=typeof a.sourceVersion=="number"?a.sourceVersion:void 0,p=typeof a.liveReloadEnabled=="boolean"?a.liveReloadEnabled:void 0;(o!==s.current.scenariosVersion||i!==s.current.plansVersion||c!==s.current.manualTestsVersion||d!==s.current.testsVersion||u!==s.current.claimsVersion||h!==s.current.sourceVersion||p!==s.current.liveReloadEnabled)&&(s.current={scenariosVersion:o,plansVersion:i,manualTestsVersion:c,testsVersion:d,claimsVersion:u,sourceVersion:h,liveReloadEnabled:p},n(s.current))}),[]),t}function yS(t){const[n,s]=l.useState({status:"idle"}),{scenariosVersion:r}=pn();return l.useEffect(()=>{if(!t){s({status:"idle"});return}let a=!1;return s({status:"loading"}),(async()=>{try{const o=await fetch(`/api/entities/${t}`);if(a)return;if(o.status===404){s({status:"not-found"});return}if(!o.ok){s({status:"error",message:`HTTP ${o.status}`});return}const i=await o.json(),c={...i,scenarios:Array.isArray(i.scenarios)?i.scenarios.map(Yo):[]};s({status:"loaded",entity:c})}catch(o){if(a)return;s({status:"error",message:o instanceof Error?o.message:"Failed to load entity"})}})(),()=>{a=!0}},[t,r]),n}function ar({message:t}){return e.jsx("div",{className:"px-5 py-8",children:e.jsx(ft,{text:t,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}const II=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentError:ar},Symbol.toStringTag,{value:"Module"}));function to(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"Loading routes..."})}const LI=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentLoading:to},Symbol.toStringTag,{value:"Module"}));function vS(t){return t.kind==="function"?"Functions don't have visual scenarios. Coverage for this function lives in its unit tests.":t.kind==="component"?`No component scenarios for ${t.displayName}. Create one with \`codeyam-editor editor register\` or capture from the live preview.`:"No scenarios for this entity yet."}function Kh({entityRef:t,onNavigate:n}){return e.jsxs("button",{type:"button",onClick:()=>n(t.hash),className:"w-full rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 text-left transition hover:border-[var(--border-default)]",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"rounded-md border border-[var(--border-subtle)] bg-[var(--bg-page)] px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[var(--text-dim)]",children:t.kind}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.name})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath})]})}const DI=Object.freeze(Object.defineProperty({__proto__:null,EntityRefCard:Kh},Symbol.toStringTag,{value:"Module"}));function or({refs:t,onNavigate:n}){return e.jsx("ul",{className:"grid grid-cols-1 gap-1",children:t.map(s=>e.jsx("li",{children:e.jsx(Kh,{entityRef:s,onNavigate:n})},s.hash))})}const FI=Object.freeze(Object.defineProperty({__proto__:null,EntityRefList:or},Symbol.toStringTag,{value:"Module"}));function jS(t,n,s){const[r,a]=l.useState(!1),[o,i]=l.useState(""),[c,d]=l.useState(!1),u=l.useCallback(()=>{a(!0),i(n)},[n]),h=l.useCallback(()=>{a(!1)},[]),p=l.useCallback(async()=>{if(!(!o.trim()||c)){d(!0);try{const m=await fetch(`/api/scenarios/${encodeURIComponent(t)}`);if(!m.ok)throw new Error(`HTTP ${m.status}`);const f=await m.json();f.name=o.trim(),await fetch(`/api/scenarios/${encodeURIComponent(t)}`,{method:"DELETE"}),await fetch("/api/scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),a(!1),s()}catch{}finally{d(!1)}}},[o,c,t,s]);return{renaming:r,renameName:o,renameSaving:c,setRenameName:i,startRename:u,cancelRename:h,submitRename:p}}function wS(t,n,s){const[r,a]=l.useState(!1),o=l.useCallback(async i=>{if(i.stopPropagation(),!!confirm(`Delete scenario "${n}"?`)){a(!0);try{await fetch(`/api/scenarios/${encodeURIComponent(t)}`,{method:"DELETE"}),s()}catch{}finally{a(!1)}}},[n,t,s]);return{deleting:r,handleDelete:o}}function _S({mocks:t,seeds:n}){const s=[];return t>0&&s.push(`${t} ${t===1?"mock":"mocks"} overridden`),n>0&&s.push(`${n} ${n===1?"seed":"seeds"} overridden`),s.length===0?null:s.join(" · ")}function Jh({overrideCounts:t}){const n=t?_S(t):null;return n?e.jsx("div",{className:"text-xs text-[var(--text-dim)] mt-1",children:n}):null}const zI=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowOverrideBadge:Jh},Symbol.toStringTag,{value:"Module"})),kS=new Set(["Desktop"]);function Xh(t){var n,s;return(n=t.componentName)!=null&&n.trim()?`Isolated ${t.componentName.trim()} component`:(s=t.url)!=null&&s.trim()?`Renders ${t.url.trim()}`:t.scenarioType==="component"?"Component scenario":"Application scenario"}function Qh({scenario:t,isSelected:n}){var r;const s=t.dimensions.length>0&&!(t.dimensions.length===1&&kS.has(t.dimensions[0]));return e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-base font-medium truncate ${n?"text-[var(--accent-active)]":"text-[var(--text-primary)]"}`,children:t.name}),(r=t.description)!=null&&r.trim()?e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1 whitespace-pre-line",children:t.description}):e.jsx("div",{className:"text-sm text-[var(--text-dim)] italic mt-1",children:Xh(t)}),e.jsx(Jh,{overrideCounts:t.overrideCounts}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:t.dimensions.join(", ")}):null,t.componentName?e.jsx("span",{className:"text-xs text-[var(--accent-purple)]",children:t.componentName}):null]})]})}const $I=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowMeta:Qh,deriveRowLabel:Xh},Symbol.toStringTag,{value:"Module"}));function Zh({screenshotPath:t,cacheBuster:n}){return e.jsx("div",{className:"h-[180px] w-[288px] shrink-0 flex items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-surface)]",children:e.jsx(At,{screenshotPath:t??void 0,cacheBuster:n??void 0,alt:""})})}const BI=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowThumbnail:Zh},Symbol.toStringTag,{value:"Module"}));function ep({onViewData:t,onRename:n,onDelete:s,deleting:r}){return e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("button",{onClick:t,className:"text-xs text-[var(--accent-active)] hover:opacity-70 cursor-pointer bg-transparent border-none p-0",children:"View / Edit Data"}),e.jsx("button",{onClick:n,className:"text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer bg-transparent border-none p-0",children:"Rename"}),e.jsx("button",{onClick:s,disabled:r,className:"text-xs text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none p-0 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-red-400/60",children:"Delete"})]})}const HI=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowActions:ep},Symbol.toStringTag,{value:"Module"}));function tp({name:t,saving:n,onChange:s,onSubmit:r,onCancel:a}){return e.jsxs("form",{className:"flex items-center gap-2",onSubmit:r,onClick:o=>o.stopPropagation(),children:[e.jsx("input",{type:"text",value:t,onChange:o=>s(o.target.value),className:"flex-1 px-2 py-1.5 text-sm bg-[var(--bg-input)] text-[var(--text-primary)] border border-[var(--border-default)] rounded outline-none focus:border-[var(--accent-active)] min-w-0",autoFocus:!0,disabled:n}),e.jsx("button",{type:"submit",disabled:n||!t.trim(),className:"px-3 py-1.5 text-xs bg-[var(--accent-active)] text-[var(--bg-base)] rounded hover:opacity-90 disabled:opacity-40 cursor-pointer border-none",children:n?"...":"Save"}),e.jsx("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer bg-transparent border-none",children:"Cancel"})]})}const qI=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRenameForm:tp},Symbol.toStringTag,{value:"Module"}));function np({scenario:t,isSelected:n,onSelect:s,onViewData:r,onScenariosChanged:a,children:o}){const i=jS(t.slug,t.name,a),{deleting:c,handleDelete:d}=wS(t.slug,t.name,a);return e.jsxs("div",{onClick:i.renaming?void 0:s,className:`rounded-lg p-3 text-left transition cursor-pointer ${n?"bg-[#1a2e1a] border border-[var(--accent-active)]/40":"bg-[var(--bg-card)] border border-transparent hover:bg-[var(--bg-input)]"}`,style:{opacity:c?.4:1},children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Zh,{screenshotPath:t.screenshotPaths[0]??null,cacheBuster:t.screenshotCapturedAtMs}),e.jsx("div",{className:"flex-1 min-w-0",children:i.renaming?e.jsx(tp,{name:i.renameName,saving:i.renameSaving,onChange:i.setRenameName,onSubmit:u=>{u.preventDefault(),i.submitRename()},onCancel:i.cancelRename}):e.jsxs(e.Fragment,{children:[e.jsx(Qh,{scenario:t,isSelected:n}),n&&e.jsx(ep,{onViewData:u=>{u.stopPropagation(),r()},onRename:u=>{u.stopPropagation(),i.startRename()},onDelete:d,deleting:c})]})})]}),o&&e.jsx("div",{className:"mt-3 cursor-default",onClick:u=>u.stopPropagation(),children:o})]})}const WI=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRow:np},Symbol.toStringTag,{value:"Module"}));function sp(){return e.jsx("div",{className:"rounded-xl border border-dashed border-[var(--border-default)] px-4 py-5 text-sm text-[var(--text-dim)]",children:"No scenarios registered for this route yet."})}const GI=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioEmptyState:sp},Symbol.toStringTag,{value:"Module"}));function ki({scenarios:t,selectedSlug:n,onSelectScenario:s,onScenariosChanged:r}){const[a,o]=l.useState(null);return t.length===0?e.jsx(sp,{}):e.jsx("div",{className:"grid grid-cols-1 gap-2",children:t.map(i=>e.jsx(np,{scenario:i,isSelected:i.slug===n,onSelect:()=>{a&&a!==i.slug&&o(null),s(i.slug)},onViewData:()=>o(a===i.slug?null:i.slug),onScenariosChanged:r,children:a===i.slug&&e.jsx(R1,{variant:"inline",slug:i.slug,scenarioName:i.name,onClose:()=>o(null)})},i.slug))})}const UI=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioList:ki},Symbol.toStringTag,{value:"Module"})),SS="This component renders no other tracked components.",NS="This component imports no tracked functions.",CS="Not called from any tracked entity. This may be a public export, an unused function, or a function whose callers haven't been re-analyzed yet.";function rp({activeTab:t,entity:n,componentRefs:s,functionRefs:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){return e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[t==="scenarios"&&(n.scenarios.length===0?e.jsx(us,{copy:vS(n)}):e.jsx(ki,{scenarios:n.scenarios,selectedSlug:a,onSelectScenario:o,onScenariosChanged:c})),t==="components"&&(s.length===0?e.jsx(us,{copy:SS}):e.jsx(or,{refs:s,onNavigate:i})),t==="functions"&&(r.length===0?e.jsx(us,{copy:NS}):e.jsx(or,{refs:r,onNavigate:i})),t==="callers"&&(n.callers.length===0?e.jsx(us,{copy:CS}):e.jsx(or,{refs:n.callers,onNavigate:i}))]})}function us({copy:t}){return e.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:t})}const VI=Object.freeze(Object.defineProperty({__proto__:null,EmptyTabCopy:us,EntityDetailContent:rp},Symbol.toStringTag,{value:"Module"}));function TS(t){return typeof t!="string"&&typeof t.onClick=="function"}function PS(t){return typeof t=="string"?t:t.label}function OS(t,n){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),n())}function ap({segments:t}){if(t.length===0)return null;const n=t.length-1;return e.jsx("span",{className:"text-sm",style:{color:"var(--text-muted)"},children:t.map((s,r)=>{const a=PS(s),o=r===n,i=!o&&TS(s);return e.jsxs("span",{children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:" / "}),i?e.jsx("button",{type:"button",onClick:s.onClick,onKeyDown:c=>OS(c,s.onClick),className:"cursor-pointer hover:text-[var(--text-primary)] transition",style:{color:"inherit",background:"none",padding:0},children:a}):e.jsx("span",{style:o?{color:"var(--text-primary)"}:void 0,children:a})]},r)})})}const YI=Object.freeze(Object.defineProperty({__proto__:null,BreadcrumbNav:ap},Symbol.toStringTag,{value:"Module"}));function $r({apps:t,selectedApp:n,selectedRouteEntity:s,currentEntity:r,isSingleApp:a,onSelectApps:o,onSelectApp:i,onSelectRoute:c}){const d=[];if(!a&&t.length>0&&d.push({label:"Apps",onClick:o}),n){const h=s!==null||r!=null;a&&!h||d.push({label:n.name,onClick:()=>i(n.dir)})}return s!==null&&r!=null&&s?d.push({label:s.displayName,onClick:()=>c(s.route)}):s&&d.push({label:s.displayName}),r&&d.push({label:r.displayName}),e.jsx(ap,{segments:d})}const KI=Object.freeze(Object.defineProperty({__proto__:null,EntityBreadcrumb:$r},Symbol.toStringTag,{value:"Module"}));function op({entity:t,app:n=null,routeEntity:s=null,navContext:r=Mn}){var o;const a=t.kind==="component"?"Component":"Function";return e.jsxs("header",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[e.jsx("div",{className:"mb-1",children:e.jsx($r,{apps:r.apps,selectedApp:n,selectedRouteEntity:s,currentEntity:t,isSingleApp:r.isSingleApp,onSelectApps:r.onSelectApps,onSelectApp:r.onSelectApp,onSelectRoute:r.onSelectRoute})}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"rounded-md border border-[var(--border-subtle)] bg-[var(--bg-card)] px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[var(--text-dim)]",children:a}),e.jsx("h2",{className:"text-base font-semibold text-[var(--text-primary)]",children:t.displayName})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath}),((o=t.glossaryEntry)==null?void 0:o.description)&&e.jsx("p",{className:"mt-2 text-xs text-[var(--text-secondary)]",children:t.glossaryEntry.description})]})}const JI=Object.freeze(Object.defineProperty({__proto__:null,EntityDetailHeader:op},Symbol.toStringTag,{value:"Module"})),AS=["scenarios","components","functions"];function Si({activeTab:t,onTabChange:n,scenarioCount:s,componentCount:r=0,functionCount:a=0,callersCount:o=0,tabs:i=AS}){const c={scenarios:"Scenarios",components:"Components",functions:"Functions",callers:"Callers"},d={scenarios:s,components:r,functions:a,callers:o};return e.jsx("div",{className:"flex w-full border-t border-b border-[var(--border-default)]",children:i.map(u=>e.jsxs("button",{onClick:()=>n(u),className:`cursor-pointer px-4 py-2 font-mono text-xs font-medium uppercase tracking-wider transition border-b-2 ${t===u?"text-[var(--accent-active)] border-[var(--accent-active)]":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-muted)]"}`,type:"button",children:[c[u]," (",d[u],")"]},u))})}const XI=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityTabs:Si},Symbol.toStringTag,{value:"Module"})),RS=["scenarios","components","functions"],ES=["scenarios","callers"];function ip({app:t=null,navContext:n=Mn,routeEntity:s=null,entity:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){const[d,u]=l.useState("scenarios"),{componentRefs:h,functionRefs:p}=l.useMemo(()=>{const f=[],g=[];for(const b of r.directImports)b.kind==="function"?g.push(b):f.push(b);return{componentRefs:f,functionRefs:g}},[r.directImports]),m=r.kind==="function"?ES:RS;return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(op,{app:t,navContext:n,routeEntity:s,entity:r}),e.jsx(Si,{activeTab:d,onTabChange:u,scenarioCount:r.scenarios.length,componentCount:h.length,functionCount:p.length,callersCount:r.callers.length,tabs:m}),e.jsx(rp,{activeTab:d,entity:r,componentRefs:h,functionRefs:p,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c})]})}const QI=Object.freeze(Object.defineProperty({__proto__:null,EntityDetail:ip},Symbol.toStringTag,{value:"Module"}));function MS(t){const n=[],s=[];for(const r of t)tu(r.url)||(r.scenarioType==="component"?s.push(r):n.push(r));return{application:n,component:s}}function lp({scenario:t,onPreview:n}){const s=t.screenshotPaths.length>0,[r,a]=l.useState(!1),o=s&&!r;return e.jsxs("div",{className:`rounded-lg border border-[var(--border-default)] bg-[var(--bg-surface)] p-3 ${n?"cursor-pointer hover:border-[var(--border-subtle)]":""}`,onClick:n,children:[o?e.jsx("img",{src:Rn(t.screenshotPaths[0],t.screenshotCapturedAtMs),alt:t.name,className:"mb-2 w-full rounded border border-[var(--border-default)]",onError:()=>a(!0)}):e.jsx("div",{className:"mb-2 flex h-32 items-center justify-center rounded border border-dashed border-[var(--border-default)] text-sm text-[var(--text-dim)]",children:"No screenshot"}),e.jsx("p",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t.name}),e.jsxs("div",{className:"mt-1 flex gap-1",children:[t.hasMocks&&e.jsx("span",{className:"rounded bg-[var(--accent-blue)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-blue)]",children:"mocks"}),t.hasSeed&&e.jsx("span",{className:"rounded bg-[var(--accent-purple)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-purple)]",children:"seed"}),t.dimensions.map(i=>e.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 text-xs text-[var(--text-muted)]",children:i},i))]})]})}const ZI=Object.freeze(Object.defineProperty({__proto__:null,ScenarioCard:lp},Symbol.toStringTag,{value:"Module"}));function no({label:t,scenarios:n,onSelectScenario:s,className:r}){return e.jsxs("section",{className:r,children:[e.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:t}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.map(a=>e.jsx(lp,{scenario:a,onPreview:()=>s(a.slug)},a.slug))})]})}const e7=Object.freeze(Object.defineProperty({__proto__:null,ScenarioTypeSection:no},Symbol.toStringTag,{value:"Module"}));function cp({feature:t,passed:n,failed:s,total:r}){return e.jsxs("div",{className:"px-5 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t}),e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[r," test",r!==1?"s":""]}),r>0&&e.jsxs("span",{className:`text-xs font-medium ${s>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]"}`,children:[n,"/",r]})]})}const t7=Object.freeze(Object.defineProperty({__proto__:null,TestGroupHeader:cp},Symbol.toStringTag,{value:"Module"}));function dp({test:t}){const n=(t.description??"").length>0,s=t.status==="passed"?"text-[var(--accent-green)]":t.status==="failed"?"text-[var(--accent-red)]":"text-[var(--text-dim)]",r=t.status==="passed"?"✓":t.status==="failed"?"✗":"○";return e.jsxs("div",{className:"flex items-start gap-2 py-1 px-3",children:[e.jsx("span",{className:`text-xs leading-5 ${s}`,children:r}),e.jsx("div",{className:"min-w-0",children:n?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:t.description}),e.jsx("p",{className:"font-mono text-[10px] text-[var(--text-dim)] truncate",children:t.key})]}):e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:t.key})})]})}const n7=Object.freeze(Object.defineProperty({__proto__:null,TestGroupRow:dp},Symbol.toStringTag,{value:"Module"}));function up({groups:t}){return t.length===0?e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No tests found."}):e.jsx("div",{className:"py-3",children:t.map(n=>{const s=n.tests.filter(o=>o.status==="passed").length,r=n.tests.filter(o=>o.status==="failed").length,a=n.tests.length;return e.jsxs("div",{className:"mb-1",children:[e.jsx(cp,{feature:n.feature,passed:s,failed:r,total:a}),e.jsx("div",{className:"px-5 pb-2",children:n.tests.map((o,i)=>e.jsx(dp,{test:o},`${o.file}-${o.key??o.line??i}`))})]},n.feature)})})}const s7=Object.freeze(Object.defineProperty({__proto__:null,TestGroupList:up},Symbol.toStringTag,{value:"Module"}));function hp({allScenarios:t,testGroups:n,onSelectScenario:s}){const{application:r,component:a}=MS(t),o=r.length>0||a.length>0;return e.jsxs("div",{className:"px-5 py-5",children:[o?e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx(no,{label:"Application",scenarios:r,onSelectScenario:s}),a.length>0&&e.jsx(no,{label:"Component",scenarios:a,onSelectScenario:s,className:r.length>0?"mt-8":void 0})]}):e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No scenarios yet"}),e.jsx("div",{className:"mt-8",children:e.jsx(up,{groups:n})})]})}const r7=Object.freeze(Object.defineProperty({__proto__:null,NonWebAppDetail:hp},Symbol.toStringTag,{value:"Module"}));function IS(t,n){const s=[],r=[];for(const a of t){const o=En(a);/^[A-Z]/.test(o)&&!o.startsWith("use")?s.push(a):r.push(a)}return{componentImports:s,functionImports:r}}function pp({ancestor:t,onNavigateToEntity:n}){const s=n?()=>n(Ps(t.filePath,En(t.filePath))):void 0;return e.jsxs("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:r=>{s&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s())},className:"cursor-pointer rounded-md border border-[var(--border-subtle)] bg-[var(--bg-card)] px-3 py-2 transition hover:border-[var(--border-default)]",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.displayName}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath})]})}const a7=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainCard:pp},Symbol.toStringTag,{value:"Module"}));function mp({layoutChain:t,onNavigateToEntity:n}){return t.length===0?null:e.jsxs("section",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[e.jsx("h3",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:"Layout chain"}),e.jsx("div",{className:"flex flex-col gap-1",children:t.map(s=>e.jsx(pp,{ancestor:s,onNavigateToEntity:n},`${s.kind}:${s.filePath}`))})]})}const o7=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainSection:mp},Symbol.toStringTag,{value:"Module"}));function LS({importPath:t,derivedName:n,allScenarios:s,routeEntities:r}){const a=s.filter(i=>i.scenarioType==="component"&&(i.pageFilePath===t||i.componentName===n)),o=r.filter(i=>i.directImports.length===1&&i.directImports[0]===t&&En(i.directImports[0])===n);if(o.length===1){const i=o[0].scenarios,c=[...a];for(const d of i)c.some(u=>u.slug===d.slug)||c.push(d);return c}return a}function ir(t){const n=[];for(const s of t.split("/"))s===""||s==="."||(s===".."?n.pop():n.push(s));return n.join("/")}function DS(t){const n=new Map;for(const[s,r]of Object.entries(t)){const a=ir(s),o=En(a),i=Ps(a,o);n.has(i)||n.set(i,{hash:i,filePath:a,entityName:o,imports:r.imports.map(ir),importedBy:r.importedBy.map(ir)})}return n}function FS(t,n){if(!t)return null;const s=ir(n);for(const r of t.values())if(r.filePath===s)return r;return null}function fp(t,n){if(!t)return[];const s=[];for(const r of n){const a=FS(t,r);a&&s.push(a)}return s}function zS(t,n){return t.find(s=>s.pageFilePath===n)??null}function gp(t){const n=t.split("/"),s=n.pop()??t,r=n.join("/");return{fileName:s,dirPath:r}}function bp({displayName:t,entity:n,isNavigable:s}){return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-lg font-semibold text-[var(--text-secondary)]",children:t}),n?e.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 font-mono text-[9px] text-[var(--text-dim)]",children:n.hash.slice(0,8)}):null,s?e.jsx("span",{className:"ml-auto text-[10px] text-[var(--text-dim)]",children:"→"}):null]})}const i7=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCardHeader:bp},Symbol.toStringTag,{value:"Module"}));function xp({scenarios:t,onSelectScenario:n}){return t.length===0?e.jsx("p",{className:"mt-1 text-[10px] text-[var(--text-dim)]",children:"No scenarios"}):e.jsxs("div",{className:"mt-2 flex flex-row gap-1.5",children:[t.slice(0,4).map(s=>{const r=s.screenshotPaths[0]??null;return e.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),n(s.slug)},className:"flex w-[192px] shrink-0 flex-col gap-1 transition",children:[e.jsx("div",{className:"flex h-[120px] w-[192px] items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] transition hover:border-[var(--border-default)]",children:e.jsx(At,{screenshotPath:r??void 0,alt:s.name})}),e.jsx("span",{className:"w-full truncate text-center text-[10px] text-[var(--text-secondary)]",children:s.name})]},s.slug)}),t.length>4&&e.jsx("div",{className:"flex h-[120px] items-center px-1",children:e.jsxs("span",{className:"text-[10px] text-[var(--text-dim)]",children:["+",t.length-4]})})]})}const l7=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyScenarioStrip:xp},Symbol.toStringTag,{value:"Module"}));function yp({importPath:t,entity:n,scenarios:s,onNavigate:r,onSelectScenario:a}){const{fileName:o,dirPath:i}=gp(t),c=(n==null?void 0:n.entityName)??o.replace(/\.[^.]+$/,"");return e.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r??void 0,onKeyDown:r?d=>{(d.key==="Enter"||d.key===" ")&&r()}:void 0,className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 transition hover:border-[var(--border-default)] ${r?"cursor-pointer":""}`,children:[e.jsx(bp,{displayName:c,entity:n,isNavigable:r!==null}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[i,"/"]}),e.jsx(xp,{scenarios:s,onSelectScenario:a})]})}const c7=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCard:yp},Symbol.toStringTag,{value:"Module"}));function vp(){return e.jsx("p",{className:"py-4 text-center text-xs text-[var(--text-dim)]",children:"No dependencies found"})}const d7=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyEmptyState:vp},Symbol.toStringTag,{value:"Module"}));function jp({directImports:t,entityLookup:n,allScenarios:s,routeEntities:r,onNavigateToRoute:a,onNavigateToEntity:o,onSelectScenario:i}){const c=l.useMemo(()=>fp(n,t),[n,t]);return t.length===0?e.jsx(vp,{}):e.jsx("div",{className:"grid grid-cols-1 gap-1",children:t.map(d=>{const u=c.find(b=>b.filePath===d)??null,h=(u==null?void 0:u.entityName)??En(d),p=LS({importPath:d,derivedName:h,allScenarios:s??[],routeEntities:r??[]}),m=zS(r??[],d),f=Ps(d,h),g=m?()=>a(m.route):o?()=>o(f):null;return e.jsx(yp,{importPath:d,entity:u,scenarios:p,onNavigate:g,onSelectScenario:i},d)})})}const u7=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyList:jp},Symbol.toStringTag,{value:"Module"}));function $S(t,n,s){const r=new Set,a=t.replace(/\.(ts|tsx)$/,"");r.add(`${a}.test.ts`),r.add(`${a}.test.tsx`);const o=n.get(t);if(o!=null&&o.importedBy)for(const c of o.importedBy)/\.test\.(ts|tsx)$/.test(c)&&r.add(c);return s.flatMap(c=>c.tests).filter(c=>r.has(c.file))}function wp({status:t}){return t==="passed"?e.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-green)]",children:"✓"}):t==="failed"?e.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-red)]",children:"✗"}):e.jsx("span",{className:"mt-0.5 text-xs text-[var(--text-dim)]",children:"○"})}const h7=Object.freeze(Object.defineProperty({__proto__:null,TestStatusIcon:wp},Symbol.toStringTag,{value:"Module"}));function _p({test:t}){const n=t.description.length>0;return e.jsxs("div",{className:"flex items-start gap-2 py-1",children:[e.jsx(wp,{status:t.status}),e.jsx("div",{children:n?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.description}),e.jsx("p",{className:"font-mono text-xs text-[var(--text-dim)]",children:t.key})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.key}),e.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:"no description"})]})})]})}const p7=Object.freeze(Object.defineProperty({__proto__:null,TestItem:_p},Symbol.toStringTag,{value:"Module"}));function kp({importPath:t,entityName:n,tests:s,onNavigate:r}){const{dirPath:a}=gp(t);return e.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r??void 0,onKeyDown:r?o=>{(o.key==="Enter"||o.key===" ")&&r()}:void 0,className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 transition hover:border-[var(--border-default)] ${r?"cursor-pointer":""}`,children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:n}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[a,"/"]}),e.jsx("div",{className:"mt-2",children:s.length>0?e.jsx("div",{className:"space-y-0.5",children:s.map((o,i)=>e.jsx(_p,{test:o},`${o.file}:${o.key??o.line??i}`))}):e.jsx("p",{className:"text-xs text-[var(--text-dim)] italic",children:"No tests"})})]})}const m7=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionCard:kp},Symbol.toStringTag,{value:"Module"}));function Sp(){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No function imports found"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-dim)]",children:"This component only imports other components"})]})}const f7=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionEmptyState:Sp},Symbol.toStringTag,{value:"Module"}));function Np({functionImports:t,entityLookup:n,testGroups:s,onNavigateToEntity:r}){const a=l.useMemo(()=>fp(n,t),[n,t]);return t.length===0?e.jsx(Sp,{}):e.jsx("div",{className:"grid grid-cols-1 gap-1",children:t.map(o=>{const i=a.find(h=>h.filePath===o)??null,c=(i==null?void 0:i.entityName)??En(o),d=$S(o,n,s),u=r?()=>r(Ps(o,c)):null;return e.jsx(kp,{importPath:o,entityName:c,tests:d,onNavigate:u},o)})})}const g7=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionList:Np},Symbol.toStringTag,{value:"Module"}));function Cp({activeTab:t,routeEntity:n,componentImports:s,functionImports:r,testGroups:a,selectedSlug:o,entityLookup:i,allScenarios:c,routeEntities:d,onSelectScenario:u,onNavigateToRoute:h,onNavigateToEntity:p,onScenariosChanged:m}){return e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[t==="scenarios"&&e.jsx(ki,{scenarios:n.scenarios,selectedSlug:o,onSelectScenario:u,onScenariosChanged:m}),t==="components"&&e.jsx(jp,{directImports:s,entityLookup:i,allScenarios:c,routeEntities:d,onNavigateToRoute:h,onNavigateToEntity:p,onSelectScenario:u}),t==="functions"&&e.jsx(Np,{functionImports:r,entityLookup:i,testGroups:a,onNavigateToEntity:p})]})}const b7=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailContent:Cp},Symbol.toStringTag,{value:"Module"}));function Tp({displayName:t,pageFilePath:n,app:s=null,routeEntity:r=null,navContext:a=Mn}){return e.jsxs("div",{className:"px-5 py-4",children:[e.jsx("div",{className:"mb-2",children:e.jsx($r,{apps:a.apps,selectedApp:s,selectedRouteEntity:r,isSingleApp:a.isSingleApp,onSelectApps:a.onSelectApps,onSelectApp:a.onSelectApp,onSelectRoute:a.onSelectRoute})}),e.jsx("h2",{className:"text-xl font-medium text-[var(--text-primary)]",children:t}),n?e.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--text-dim)]",children:n}):null]})}const x7=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailHeader:Tp},Symbol.toStringTag,{value:"Module"}));function Pp({app:t=null,navContext:n=Mn,routeEntity:s,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,testGroups:c,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:h,onScenariosChanged:p}){const[m,f]=l.useState("scenarios"),{componentImports:g,functionImports:b}=l.useMemo(()=>IS(s.directImports),[s.directImports]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(Tp,{app:t,navContext:n,routeEntity:s,displayName:s.displayName,pageFilePath:s.pageFilePath}),e.jsx(mp,{layoutChain:s.layoutChain??[],onNavigateToEntity:h}),e.jsx(Si,{activeTab:m,onTabChange:f,scenarioCount:s.scenarios.length,componentCount:g.length,functionCount:b.length}),e.jsx(Cp,{activeTab:m,routeEntity:s,componentImports:g,functionImports:b,testGroups:c,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:h,onScenariosChanged:p})]})}const y7=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetail:Pp},Symbol.toStringTag,{value:"Module"}));function Op(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No routes discovered yet."})}const v7=Object.freeze(Object.defineProperty({__proto__:null,RouteListEmptyState:Op},Symbol.toStringTag,{value:"Module"}));function Ap({label:t="Pages"}={}){return e.jsx("div",{className:"mb-3",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)]",children:t})})}const j7=Object.freeze(Object.defineProperty({__proto__:null,RouteListSectionHeader:Ap},Symbol.toStringTag,{value:"Module"}));function so({label:t,routeEntities:n,onSelectRoute:s,onSelectScenario:r,className:a}){return e.jsxs("div",{className:a,children:[e.jsx(Ap,{label:t}),e.jsx("div",{children:n.map(o=>e.jsx(wi,{routeEntity:o,onSelectRoute:s,onSelectScenario:r},o.route))})]})}const w7=Object.freeze(Object.defineProperty({__proto__:null,RouteListSection:so},Symbol.toStringTag,{value:"Module"}));function Rp({providerLabel:t,chatOpen:n,onToggleChat:s}){const r=n?"border-[var(--accent-active)] bg-[var(--accent-active)]/15 text-[var(--accent-active)]":"border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40";return e.jsxs("button",{type:"button",onClick:s,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors ${r}`,title:`Open a chat with ${t} to investigate why this page is not shown`,children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.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"})}),n?"Close":`Investigate with ${t}`]})}const _7=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageInvestigateButton:Rp},Symbol.toStringTag,{value:"Module"}));function Ep({displayName:t,path:n}){return e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--text-primary)] truncate",children:t}),e.jsx("p",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:n})]})}const k7=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRowSummary:Ep},Symbol.toStringTag,{value:"Module"}));function BS(t,n){return n==="scaffold"?[`The page \`${t}\` is marked \`untestabilityReason.kind = scaffold\` in the glossary, so it is intentionally excluded from the App tab's product route list.`,"Confirm that marking is correct: read the file and decide whether it is genuinely a scaffold / dev-only shim rather than product surface.","If it IS a real product route, remove the scaffold marking and register it properly (deconstruct it into the glossary and capture at least one scenario for it). If the marking is correct, say so and explain in one line why — no changes needed."].join(`
|
|
12
|
+
|
|
13
|
+
`):[`The page \`${t}\` is discovered on disk but has NO glossary entry, so codeyam cannot tell whether it is product surface — it is excluded from the App tab's route list until it is registered.`,"Investigate whether it is a real product route.","If it IS product surface, deconstruct and register it in the glossary and capture at least one scenario for it so it appears in the route list. If it is instead a scaffold or dev-only shim, add it to the glossary marked `untestabilityReason.kind = scaffold` with a justification."].join(`
|
|
14
|
+
|
|
15
|
+
`)}function HS({path:t,reason:n}){return["You are helping inside the user's actual codeyam project — this is real work in a real repository, not a hypothetical.","Before doing anything, read `.codeyam/stack.json` and the page file itself so your fix fits this project's stack.",BS(t,n),"Propose the concrete change and, once the user agrees, make it. Prefer real edits and commands over generic advice."].join(`
|
|
16
|
+
|
|
17
|
+
`)}function Mp(t){return t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}function Ip({page:t}){const[n,s]=l.useState(!1),{config:r}=jt(),a=Ue(r==null?void 0:r.provider);return e.jsxs("div",{className:"border border-[var(--border-subtle)] rounded mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsx(Ep,{displayName:t.displayName,path:t.path}),e.jsx(Rp,{providerLabel:a,chatOpen:n,onToggleChat:()=>s(o=>!o)})]}),n&&e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:e.jsx($t,{chatName:`fix-unsurfaced-${Mp(t.path)}`,prompt:HS({path:t.path,reason:t.reason}),height:360,onClose:()=>s(!1)})})]})}const S7=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRow:Ip,chatSlug:Mp},Symbol.toStringTag,{value:"Module"}));function Lp({label:t,pages:n}){return n.length===0?null:e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-2 text-xs text-[var(--text-dim)]",children:t}),n.map(s=>e.jsx(Ip,{page:s},s.path))]})}const N7=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageGroup:Lp},Symbol.toStringTag,{value:"Module"}));function Dp({count:t,collapsed:n,onToggle:s}){return e.jsxs("button",{type:"button",onClick:s,className:"mb-3 flex items-center gap-2 cursor-pointer group","aria-expanded":!n,children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`text-[var(--text-dim)] transition-transform ${n?"":"rotate-90"}`,children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)] group-hover:text-[var(--text-primary)]",children:["Not shown (",t,")"]})]})}const C7=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSectionHeader:Dp},Symbol.toStringTag,{value:"Module"})),qS=[{reason:"missing-from-glossary",label:"Missing from glossary"},{reason:"scaffold",label:"Marked as scaffold"}];function Fp({pages:t}){const[n,s]=l.useState(!0);return t.length===0?null:e.jsxs("div",{className:"mt-8",children:[e.jsx(Dp,{count:t.length,collapsed:n,onToggle:()=>s(r=>!r)}),!n&&e.jsx("div",{children:qS.map(({reason:r,label:a})=>e.jsx(Lp,{label:a,pages:t.filter(o=>o.reason===r)},r))})]})}const T7=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSection:Fp},Symbol.toStringTag,{value:"Module"}));function zp({routeEntities:t,unsurfacedPages:n=[],componentSurfaceReason:s=null,onSelectRoute:r,onSelectScenario:a,tabbed:o=!1}){if(t.length===0&&n.length===0)return e.jsx(Op,{});const i=t.filter(d=>(d.kind??"application")==="application"),c=t.filter(d=>d.kind==="component");return o?e.jsx("div",{className:"px-5 pb-5",children:e.jsx(Uh,{pages:i,components:c,componentSurfaceReason:s,onSelectRoute:r,onSelectScenario:a})}):e.jsxs("div",{className:"px-5 py-5",children:[t.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No routes are being shown — every discovered page was excluded. See below."}),i.length>0&&e.jsx(so,{label:"Pages",routeEntities:i,onSelectRoute:r,onSelectScenario:a}),c.length>0&&e.jsx(so,{label:"Components",routeEntities:c,onSelectRoute:r,onSelectScenario:a,className:i.length>0?"mt-8":void 0}),e.jsx(Fp,{pages:n})]})}const P7=Object.freeze(Object.defineProperty({__proto__:null,RouteList:zp},Symbol.toStringTag,{value:"Module"}));function Ni({app:t=null,navContext:n=Mn,isWeb:s,routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,routesLoading:i,routesError:c,selectedEntityHash:d,selectedRouteEntity:u,testGroups:h,selectedSlug:p,entityLookup:m,allScenarios:f,onSelectScenario:g,onSelectRoute:b,onSelectEntity:x,onBackToRoutes:y,onScenariosChanged:v,routeListTabbed:_=!1}){const j=yS(d&&!u?d:null);return s?i?e.jsx(to,{}):c?e.jsx(ar,{message:c}):u?e.jsx(Pp,{app:t,navContext:n,routeEntity:u,selectedSlug:p,entityLookup:m,allScenarios:f,routeEntities:r,testGroups:h,onSelectScenario:g,onNavigateToRoute:b,onNavigateToEntity:x,onScenariosChanged:v}):d?j.status==="loading"||j.status==="idle"?e.jsx(to,{}):j.status==="not-found"?e.jsx(ar,{message:"Entity not found. The dependency graph may need to be refreshed."}):j.status==="error"?e.jsx(ar,{message:j.message}):e.jsx(ip,{app:t,navContext:n,routeEntity:u,entity:j.entity,selectedSlug:p,onSelectScenario:g,onNavigateToEntity:x??(()=>{}),onScenariosChanged:v}):e.jsx(zp,{routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,onSelectRoute:b,onSelectScenario:g,tabbed:_}):e.jsx(hp,{allScenarios:f,testGroups:h,onSelectScenario:g})}const O7=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContent:Ni},Symbol.toStringTag,{value:"Module"}));function WS(t){const n=(t??"").split("·").map(a=>a.trim()).filter(Boolean);if(n.length===0)return{tally:"",attention:null};const[s,...r]=n;return{tally:s,attention:r.length>0?r.join(" · "):null}}function $p({summary:t}){const{tally:n,attention:s}=WS(t);return n?e.jsxs("p",{className:"xsvc-count xsvc-count-row",children:[e.jsx("b",{children:n}),s?e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"attn",children:s})]}):null]}):null}const A7=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSummary:$p},Symbol.toStringTag,{value:"Module"}));function Bp({summary:t,sort:n,onSortChange:s}){return e.jsxs("div",{className:"xsvc-listbar",children:[e.jsx($p,{summary:t}),e.jsx(vi,{sort:n,onSortChange:s})]})}const R7=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesListBar:Bp},Symbol.toStringTag,{value:"Module"})),GS="All providers";function US(t,n){const s=t??[];return n==="type"?s.filter(r=>r.items.length>0):[{label:GS,items:s.flatMap(r=>r.items).slice().sort((r,a)=>r.name.localeCompare(a.name))}]}function Hp({groups:t,summary:n,onBack:s,onOpenChat:r,onAction:a,defaultSort:o="type",chatSlot:i,embedded:c=!1,brokerStarter:d}){const u=Array.isArray(t)&&t.some(x=>x.items.length>0),[h,p]=l.useState(o),[m,f]=l.useState(""),g=x=>{x.preventDefault(),r==null||r(m.trim()||void 0)},b=u?US(t,h):[];return e.jsx("div",{className:c?"xsvc xsvc-embedded":"xsvc",children:e.jsxs("div",{className:"xsvc-scroll",children:[c?null:e.jsx("div",{className:"xsvc-crumbs",children:e.jsx("button",{type:"button",className:"xsvc-back",onClick:s,"aria-label":"Back to Home",children:"‹ Home"})}),e.jsxs("div",{className:"xsvc-head",children:[c?null:e.jsxs("div",{className:"xsvc-titlerow",children:[e.jsx("h1",{children:"External Services"}),u?e.jsx("span",{className:"xsvc-count",children:n??"Every outside service, in one place."}):null]}),c||!u?e.jsx("p",{className:c?"xsvc-sub xsvc-sub-lead":"xsvc-sub",children:"Every outside service this project depends on: domains, hosting, API keys, payments, and the database. Anything it talks to that lives beyond its own code."}):null]}),u?e.jsxs(e.Fragment,{children:[e.jsx(kh,{draft:m,onDraftChange:f,onSubmit:g,onAsk:r,chatSlot:i,bare:c}),e.jsx("div",{className:"xsvc-divider",role:"presentation"}),c?e.jsx(Bp,{summary:n,sort:h,onSortChange:p}):e.jsx(vi,{sort:h,onSortChange:p}),e.jsx(wh,{groups:b,onAction:a})]}):e.jsx(xh,{draft:m,onDraftChange:f,onSubmit:g,onAsk:r,brokerStarter:d})]})})}const E7=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:xi,ExternalServicesScreen:Hp,ServiceRow:yi},Symbol.toStringTag,{value:"Module"}));function Br({target:t,onStored:n,onClose:s}){const[r,a]=l.useState(""),[o,i]=l.useState(!1),[c,d]=l.useState(null),[u,h]=l.useState(!1),p=l.useCallback(async()=>{if(r.trim()){i(!0),d(null),h(!1);try{const m=await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t.topic,provider:"passthrough",credential:r.trim(),credential_fields:{envVar:t.envVar}})});if(!m.ok){if(E1(m.status)==="transient"){h(!0),d(`The editor was briefly unreachable (HTTP ${m.status}). Your key wasn't rejected — try again.`);return}const g=await m.json().catch(()=>({}));d(g.error??`Could not store the key (HTTP ${m.status}).`);return}const f=await m.json().catch(()=>({}));if(f.success===!1||f.status==="error"){d(f.message??f.error??"The key was rejected.");return}a(""),n()}catch{h(!0),d("Could not reach the editor to store the key. Try again.")}finally{i(!1)}}},[r,t,n]);return e.jsx("div",{"data-testid":"app-service-credential-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:e.jsxs("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-[#3A3A3A] bg-[#161616] p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-white",children:["Add your ",t.serviceName," API key"]}),e.jsx("button",{"data-testid":"app-service-credential-close",onClick:s,className:"text-[#8E8E8E] hover:text-white cursor-pointer","aria-label":"Close",children:"✕"})]}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["The key is stored in",e.jsx("code",{className:"mx-1 text-[#D7FF63]",children:".codeyam/setup-connections.json"}),"(owner-only, gitignored) and injected into your app as",e.jsx("code",{className:"mx-1 text-[#D7FF63]",children:t.envVar})," — never committed."]}),t.docsUrl?e.jsx("a",{href:t.docsUrl,target:"_blank",rel:"noreferrer",className:"inline-block text-sm text-[#7EA6FF] hover:underline",children:"Where to find this key →"}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:r,onChange:m=>a(m.target.value),placeholder:`${t.serviceName} API key`,className:"flex-1 min-w-0 px-2 py-1.5 rounded bg-black border border-[#3A3A3A] text-white text-sm"}),e.jsx("button",{onClick:()=>void p(),disabled:o||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:o?"Saving…":"Save"})]}),c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-[#FF8B43]",children:c}),u?e.jsx("button",{"data-testid":"app-service-credential-retry",onClick:()=>void p(),disabled:o||!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:o?"Saving…":"Retry"}):null]}):null]})})}const M7=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialModal:Br},Symbol.toStringTag,{value:"Module"}));function Ci(){const[t,n]=l.useState(null),s=l.useCallback(async()=>{try{const a=await fetch("/api/setup-services");if(!a.ok)throw new Error(`HTTP ${a.status}`);const o=await a.json();n(Array.isArray(o)?o:[])}catch{n([])}},[]);l.useEffect(()=>{s()},[s]);const r=l.useCallback(a=>{n(o=>o&&o.map(i=>i.key===a?{...i,status:"dismissed"}:i)),fetch(`/api/setup-services/${encodeURIComponent(a)}/dismiss`,{method:"POST"}).catch(()=>{s()})},[s]);return{services:t,dismiss:r,refetch:s}}function VS(){const[t,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/service-brokers");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();n(Array.isArray(a)?a:[])}catch{n([])}},[]);return l.useEffect(()=>{s()},[s]),{brokers:t,refetch:s}}const YS={Domain:"blue",Hosting:"blue","Code hosting":"indigo","Package registry":"indigo","Cloud platform":"blue",Payments:"green",Database:"indigo","Database ORM":"indigo","Backend platform":"indigo","Cache & queue":"indigo",Authentication:"amber","AI provider":"lime","Transactional email":"lime","Product analytics":"lime","Storage & media":"lime",Messaging:"lime",Search:"lime",Containers:"indigo","CI/CD":"indigo","Error monitoring":"amber"},Tc=["Domain","Hosting","Cloud platform","Code hosting","Package registry","Database","Database ORM","Backend platform","Cache & queue","Authentication","Payments","AI provider","Transactional email","Messaging","Storage & media","Search","Containers","CI/CD","Product analytics","Error monitoring"];function Hr(t){return t.source==="pending"||t.confidence==="suggested"}function qp(t){var s;if(Hr(t))return"suggested";if(t.confidence==="inferred")return"found in code";const n=(s=t.evidence[0])==null?void 0:s.source;return n?n==="git remote"?"from git remote":n==="config file"?"from config":`from ${n}`:"declared"}function KS(t){var s;const n=t.trim().split(/\s+/).filter(Boolean);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():(((s=n[0])==null?void 0:s[0])??"?").toUpperCase()}function Wp(t){return t.envVars.length>0&&!t.credentialPresent}function JS(t){if(t.note)return t.note;const n=t.evidence[0];if(!n)return t.category;const s=t.evidence.length>1?` · +${t.evidence.length-1} more`:"";return`${n.value} in ${n.source}${s}`}function XS(t){const n=[{label:"Category",value:t.category}];if(Hr(t))return n.push({label:"Status",value:"Not set up yet"}),n.push({label:"Source",value:"Suggested — no evidence in this repo"}),n;n.push({label:"Origin",value:qp(t)}),t.envVars.length>0&&n.push({label:"Env vars",value:t.envVars.join(", "),mono:!0}),n.push({label:t.credentialPresent?"Key":"Key status",value:t.credentialPresent?"Configured":"Not set yet"});for(const s of t.evidence.slice(0,4))n.push({label:"Detected in",value:`${s.value} · ${s.source}`,mono:!0});return t.docsUrl&&n.push({label:"Docs",value:t.docsUrl}),n}function QS(t){const n=[],s=Hr(t);n.push({text:qp(t),kind:"origin"}),s&&n.push({text:"not set up",kind:"miss"});const r=t.envVars[0];r&&n.push({text:r,kind:"env"}),t.envVars.length>0&&t.credentialPresent&&n.push({text:"Key set",kind:"set"});const a=Wp(t),o=s?"Set up":a?"Add key":void 0;return{monogram:KS(t.name),providerId:t.key,category:t.category,tone:YS[t.category]??"lime",name:t.name,desc:JS(t),tags:n.length?n:void 0,actionLabel:o,actionKey:o?t.key:void 0,attn:a,pending:s,detail:XS(t)}}function Pc(t){const n=Tc.indexOf(t);return n===-1?Tc.length:n}function ZS(t){const n=(t??[]).filter(h=>h.status!=="dismissed");if(n.length===0)return{groups:[],summary:""};const s=new Map;for(const h of n){const p=s.get(h.category);p?p.push(h):s.set(h.category,[h])}const r=[...s.entries()].sort(([h],[p])=>Pc(h)-Pc(p)||h.localeCompare(p)).map(([h,p])=>({label:h,items:p.slice().sort((m,f)=>m.name.localeCompare(f.name)).map(QS)})),a=n.filter(h=>!Hr(h)),o=n.length-a.length,i=a.filter(Wp).length,c=a.length===1?"service":"services",d=i>0?`${a.length} ${c} · ${i} need${i===1?"s":""} your attention`:`${a.length} ${c} detected`,u=o>0?`${d} · ${o} not set up yet`:d;return{groups:r,summary:u}}function eN(t){return t.credentialPresent?" (key configured)":t.envVars.length>0?" (needs a key)":""}function tN(t,n){const s=(t??[]).filter(o=>o.status!=="dismissed"),r=s.length?`
|
|
18
|
+
|
|
19
|
+
Detected in this project so far:
|
|
20
|
+
${s.map(o=>`- ${o.name} (${o.category})${eN(o)}`).join(`
|
|
21
|
+
`)}`:`
|
|
22
|
+
|
|
23
|
+
No external services have been auto-detected in this project yet.`,a=n!=null&&n.trim()?`
|
|
24
|
+
|
|
25
|
+
The user opened this chat with the following message. Respond to it directly and helpfully as your FIRST reply, before anything else:
|
|
26
|
+
"${n.trim()}"`:`
|
|
27
|
+
|
|
28
|
+
Greet the user briefly and ask what they'd like to know or change about their external services.`;return["You are helping the user understand and manage this project's EXTERNAL SERVICES, ","the outside things it depends on: domains, hosting, API keys, payments (e.g. Stripe), ","databases, auth, transactional email, analytics, error monitoring, and any paid subscriptions.",r,`
|
|
29
|
+
|
|
30
|
+
Help with whatever they want here: what's wired up, what's missing an API key, `,"how to add or remove a service, and renewals or monthly cost. Those last two are NOT in ","the repo, so ASK the user rather than guessing. Be concise and concrete.",a].join("")}const nN=`<!--
|
|
31
|
+
The seed prompt for a broker provisioning session, and the ONE place its text
|
|
32
|
+
lives. Two consumers substitute the same four placeholders into it:
|
|
33
|
+
|
|
34
|
+
* the UI, via \`ui/src/helpers/buildStripeProjectsChatPrompt.ts\`, which imports
|
|
35
|
+
this file with Vite's \`?raw\` (the same mechanism
|
|
36
|
+
\`ui/src/helpers/errorCaptureShim.test.ts\` uses to read a Rust crate's
|
|
37
|
+
JavaScript shim);
|
|
38
|
+
* the CLI, via \`include_str!\` in \`broker_session.rs\`, so
|
|
39
|
+
\`codeyam-editor editor broker-session\` emits a byte-identical seed.
|
|
40
|
+
|
|
41
|
+
Keeping the text here rather than in either consumer is the point. A prompt
|
|
42
|
+
that tells an agent when it may spend the user's money is not something to
|
|
43
|
+
maintain in two languages: a rule tightened in the UI copy and missed in the
|
|
44
|
+
CLI copy is a rule that silently does not apply to half the entry points.
|
|
45
|
+
|
|
46
|
+
Placeholders, all four required, each substituted verbatim:
|
|
47
|
+
{{CATEGORY}} what the user is setting up, e.g. "hosting"
|
|
48
|
+
{{PROBE_STATE}} what the broker probe found on this machine
|
|
49
|
+
{{RESOURCES}} what this broker has already provisioned
|
|
50
|
+
{{OPENING}} the agent's instruction for its very first reply
|
|
51
|
+
-->
|
|
52
|
+
You are helping the user set up **{{CATEGORY}}** for this project using Stripe
|
|
53
|
+
Projects, a provisioning CLI that creates real resources on the user's Stripe
|
|
54
|
+
account and can cost them real money.
|
|
55
|
+
|
|
56
|
+
## What is already true on this machine
|
|
57
|
+
|
|
58
|
+
{{PROBE_STATE}}
|
|
59
|
+
|
|
60
|
+
{{RESOURCES}}
|
|
61
|
+
|
|
62
|
+
## Rules
|
|
63
|
+
|
|
64
|
+
These are not suggestions, and they hold for every command in this session.
|
|
65
|
+
|
|
66
|
+
- **Hand off to the local skill.** \`stripe projects init\` writes a
|
|
67
|
+
\`stripe-projects\` skill into this repository. It is the authoritative
|
|
68
|
+
reference for every subsequent Stripe Projects command — use it rather than
|
|
69
|
+
your memory of the CLI's flags. Do not install the skill globally unless the
|
|
70
|
+
user explicitly asks for it; the repo-local skill is the default because it
|
|
71
|
+
changes nothing outside this checkout.
|
|
72
|
+
- **Environment variable NAMES only, never values.** You may say that
|
|
73
|
+
\`DATABASE_URL\` is set. You may never print, echo, log, or repeat what it is
|
|
74
|
+
set to, not even partially.
|
|
75
|
+
- **Never hand-edit \`.projects/\` or \`.env\`.** The CLI owns those files. If
|
|
76
|
+
something in them is wrong, fix it with a CLI command, not an editor.
|
|
77
|
+
- **Ask before anything irreversible.** Every command that creates, links,
|
|
78
|
+
upgrades, or removes a resource spends the user's money or changes their
|
|
79
|
+
account. Show the exact command you intend to run, say plainly what it will
|
|
80
|
+
create and what it will cost, and wait for an explicit yes. One approval
|
|
81
|
+
covers exactly one command — approval to install the CLI is not approval to
|
|
82
|
+
initialize the project, and neither is approval to provision anything.
|
|
83
|
+
- **A browser window means STOP.** The Stripe CLI opens a browser to
|
|
84
|
+
authenticate. When that happens, tell the user a browser window is waiting
|
|
85
|
+
for them and run nothing further until they confirm they have finished. Do
|
|
86
|
+
not poll, do not retry, and do not work around it.
|
|
87
|
+
- **Pass \`--json\` where the CLI supports it** and read the structured output
|
|
88
|
+
rather than parsing human-formatted text.
|
|
89
|
+
- **Never re-provision.** The resources listed above already exist. Adding a
|
|
90
|
+
second one because you did not read the list is the most expensive mistake
|
|
91
|
+
available to you here.
|
|
92
|
+
|
|
93
|
+
## Start here
|
|
94
|
+
|
|
95
|
+
{{OPENING}}
|
|
96
|
+
`;function sN(t){const n=t.indexOf("-->");return t.startsWith("<!--")&&n!==-1?t.slice(n+3).trimStart():t}function rN(t){const n=[`- ${t.name} CLI: ${t.cliInstalled?`installed${t.cliVersion?` (${t.cliVersion})`:""}`:`NOT installed. The user would install it with: ${t.installHint}`}`,`- Its \`projects\` plugin: ${t.pluginInstalled?"installed":"NOT installed"}`,`- This directory: ${t.projectInitialized?`initialized${t.projectName?` as "${t.projectName}"`:""}`:"NOT initialized — `stripe projects init` has not been run here"}`];return t.note&&n.push(`- Note from the probe: ${t.note}`),n.join(`
|
|
97
|
+
`)}function aN(t){const n=(t??[]).filter(s=>s.status!=="dismissed");return n.length===0?"This project has no external services recorded yet.":["Already recorded for this project — do NOT provision these again:",...n.map(s=>`- ${s.name} (${s.category})${s.credentialPresent?" — credential configured":s.envVars.length>0?` — needs ${s.envVars.join(", ")}`:""}`)].join(`
|
|
98
|
+
`)}function oN(t,n,s,r){const a=r!=null&&r.trim()?`The user opened this session with the following message. Respond to it directly as your FIRST reply, before anything else:
|
|
99
|
+
"${r.trim()}"`:`Tell the user in one or two sentences what you are about to do to set up ${n.toLowerCase()} for them, name the first command you would run, and ask whether to run it. Run nothing before they answer.`;return sN(nN).replace("{{CATEGORY}}",n.toLowerCase()).replace("{{PROBE_STATE}}",rN(t)).replace("{{RESOURCES}}",aN(s)).replace("{{OPENING}}",a)}function Gp({onBack:t,embedded:n=!1}){const{services:s,refetch:r}=Ci(),{brokers:a}=VS(),[o,i]=l.useState(!1),[c,d]=l.useState(void 0),[u,h]=l.useState(null),[p,m]=l.useState(null),[f,g]=l.useState(!1),{groups:b,summary:x}=l.useMemo(()=>ZS(s),[s]),y=l.useMemo(()=>(a??[]).find(Ak)??null,[a]),v=l.useMemo(()=>(a??[]).find(pu)??null,[a]),_=()=>{i(!1),m(null),g(!1)},j=k=>{var C;const S=(s??[]).find(P=>P.key===k);if(!S)return;const w=(C=S.envVars)==null?void 0:C[0];if(!w){if(y){m({broker:y,category:S.category}),g(!1),d(void 0),i(!0);return}d(`Help me set up ${S.category.toLowerCase()} for this project`),i(!0);return}h({serviceName:S.name,envVar:w,topic:S.topic,docsUrl:S.docsUrl})};return e.jsxs("div",{className:"xsvc-connected",children:[e.jsx(Hp,{groups:b,summary:x,onBack:t,embedded:n,onOpenChat:k=>{m(null),g(!1),d(k),i(!0)},onAction:j,brokerStarter:v?{label:`Set up with ${v.name}`,onSelect:()=>{m({broker:v,category:"External services"}),g(!1),d(void 0),i(!0)}}:void 0,chatSlot:o?e.jsx(fu,{title:p?`Set up ${p.category.toLowerCase()} with ${p.broker.name}`:"Chat about your external services",onClose:_,children:p&&!f?e.jsx(mu,{broker:p.broker,category:p.category,onStart:()=>g(!0)}):e.jsx($t,{chatName:p?`external-services-${p.broker.id}`:"external-services",prompt:p?oN(p.broker,p.category,s,c):tN(s,c),height:380,onClose:_})}):void 0}),u?e.jsx(Br,{target:u,onStored:()=>{h(null),r()},onClose:()=>h(null)}):null]})}const I7=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesScreenConnected:Gp},Symbol.toStringTag,{value:"Module"}));function Up({children:t}){return e.jsx("h2",{style:{fontSize:27,fontWeight:700,letterSpacing:"-0.02em",color:"var(--text-strong)",margin:"0 0 20px"},children:t})}const L7=Object.freeze(Object.defineProperty({__proto__:null,ExploreSectionHeading:Up},Symbol.toStringTag,{value:"Module"})),Oc=[{id:"simulations",label:"Simulations"},{id:"external-services",label:"External Services"}],iN={id:"setup",label:"Setup"};function Vp({active:t,onChange:n,showSetup:s=!1,children:r}){const a=s?[...Oc,iN]:Oc;return e.jsxs("div",{children:[e.jsx("div",{role:"tablist","aria-label":"Explore your app",className:"flex items-center gap-6 border-b border-[var(--border-subtle)] mb-5",children:a.map(o=>{const i=o.id===t;return e.jsx("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>n(o.id),className:`font-sans text-xs font-semibold tracking-wide uppercase pb-2 -mb-px border-b-2 transition ${i?"text-[var(--text-primary)] border-[var(--text-primary)]":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-secondary)]"}`,children:o.label},o.id)})}),e.jsx("div",{role:"tabpanel",children:r})]})}const D7=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreTabs:Vp},Symbol.toStringTag,{value:"Module"}));function Yp({appDetailProps:t,selectedApp:n,setupSlot:s}){const[r,a]=l.useState("simulations");return e.jsx("div",{style:{padding:"8px 10% 50px"},children:e.jsxs("div",{style:{width:"100%",maxWidth:2200,marginInline:"auto"},children:[e.jsx(Up,{children:"Explore your app"}),e.jsxs(Vp,{active:r,onChange:a,showSetup:!!s,children:[r==="simulations"?e.jsx("div",{className:"-mx-5",children:e.jsx(Ni,{...t,app:n,isWeb:(n==null?void 0:n.type)==="web",selectedEntityHash:t.selectedEntityHash??null,routeListTabbed:!0})}):null,r==="external-services"?e.jsx(Gp,{embedded:!0}):null,r==="setup"?s:null]})]})})}const F7=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreSection:Yp},Symbol.toStringTag,{value:"Module"}));function pe({icon:t,title:n,meta:s,onBack:r,crumbLabel:a,assistKey:o}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:r,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:r,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:r,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:a??n})]}),e.jsxs("div",{className:"htitle",children:[e.jsx("div",{className:"hic",children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"h",children:n}),e.jsx("div",{className:"hmeta",children:s})]})]})]})}function an({topic:t,step:n,onBack:s}){return e.jsxs("div",{className:"crumbs",children:[s?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:s,children:t})]}):e.jsx("span",{children:t}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:n})]})}function Yt({steps:t,currentKey:n}){const s=t.findIndex(r=>r.key===n);return e.jsx("div",{className:"flowbar",children:t.map((r,a)=>e.jsxs("span",{style:{display:"contents"},children:[a>0?e.jsx("span",{className:"fsep"}):null,e.jsxs("span",{className:"fstep"+(a<s?" done":a===s?" active":""),children:[e.jsx("span",{className:"fn",children:a<s?"✓":a+1}),r.label]})]},r.key))})}function we({label:t,note:n,status:s,onComplete:r,onRevert:a,onBack:o,doneLabel:i="Completed"}){const[c,d]=l.useState(!1);return s==="done"||c?e.jsx("div",{className:"cta-wrap",children:e.jsxs("div",{className:"cta-done",children:[e.jsxs("span",{className:"cta-done-check",children:[e.jsx("span",{className:"ce",children:"✓"})," ",i]}),e.jsxs("div",{className:"cta-done-actions",children:[o?e.jsx("button",{type:"button",className:"lf-back",onClick:o,children:"Back to Setup"}):null,a?e.jsx("button",{type:"button",className:"cta-revert",onClick:()=>{a(),d(!1)},children:"Mark as not complete"}):null]})]})}):e.jsxs("div",{className:"cta-wrap",children:[e.jsxs("button",{type:"button",className:"cta",onClick:()=>{r(),d(!0)},children:[e.jsx("span",{className:"ce",children:"✓"})," ",t]}),e.jsx("div",{className:"cta-note",children:n})]})}const z7=Object.freeze(Object.defineProperty({__proto__:null,SetupCompleteCta:we,SetupDetailHeader:pe,SetupFlowBar:Yt,SetupSubCrumb:an},Symbol.toStringTag,{value:"Module"}));function qr({initial:t,color:n}){return e.jsx("div",{className:"altmark",style:{background:n,width:46,height:46},children:t})}function Ti({provider:t}){return e.jsxs("div",{className:"provcard"+(t.bestFit?" best":""),children:[e.jsx(qr,{initial:t.initial,color:t.color}),e.jsxs("div",{className:"provbody",children:[e.jsxs("div",{className:"provtop",children:[e.jsx("span",{className:"provname",children:t.name}),t.bestFit?e.jsx("span",{className:"bestfit",children:"Best fit"}):null]}),e.jsx("div",{className:"provdesc",children:t.description}),e.jsx("div",{className:"reasons",children:t.reasons.map(n=>e.jsxs("div",{className:"reason",children:[e.jsx(Qe,{}),e.jsxs("span",{children:[e.jsx("b",{children:n.lead})," ",n.rest]})]},n.lead))}),e.jsx("div",{className:"chips",children:t.chips.map(n=>e.jsx("span",{className:"chip",children:n},n))})]})]})}function Kp({alts:t}){const[n,s]=l.useState(!1);return t.length===0?null:e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>s(r=>!r),children:[n?"Hide other options":"Not for you? See other options",e.jsx("span",{className:"chev",style:{transform:n?"rotate(180deg)":"none"},children:"⌄"})]}),n?e.jsx("div",{className:"alts",children:t.map(r=>e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:r.color},children:r.initial}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:r.name}),e.jsx("div",{className:"altdesc",children:r.description})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]},r.name))}):null]})}function ot({items:t}){return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),e.jsx(Jp,{items:t})]})}function Jp({items:t}){const[n,s]=l.useState(-1);return t.length===0?null:e.jsx("div",{className:"faq",children:t.map((r,a)=>e.jsxs("div",{className:"faqitem",children:[e.jsxs("button",{type:"button",className:"faqq"+(n===a?" open":""),onClick:()=>s(n===a?-1:a),children:[r.q,e.jsx("span",{className:"chev",children:"⌄"})]}),n===a?e.jsx("div",{className:"faqa",children:r.a}):null]},r.q))})}const $7=Object.freeze(Object.defineProperty({__proto__:null,Alternatives:Kp,FaqSection:ot,ProviderCard:Ti,ProviderMark:qr,TopicFaq:Jp},Symbol.toStringTag,{value:"Module"}));function Pi({icon:t,title:n,meta:s,crumbLabel:r,assistKey:a,onBack:o,lead:i,illustration:c,chatPrompt:d,onChatWithAI:u,faqs:h}){return e.jsxs("div",{className:"hosting-screen setup-topic",children:[e.jsx(pe,{icon:t,title:n,meta:s,crumbLabel:r,onBack:o,assistKey:a}),e.jsx("div",{className:"lead",children:i}),c,e.jsx("div",{className:"cta-wrap",children:e.jsx("button",{type:"button",className:"cta",onClick:()=>u==null?void 0:u(d),children:"Chat with the AI about this"})}),e.jsx(ot,{items:h})]})}const B7=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPage:Pi},Symbol.toStringTag,{value:"Module"}));function _n({before:t,after:n}){return e.jsxs("div",{className:"setup-ill ill-split",children:[e.jsxs("div",{className:"isplit",children:[e.jsx("div",{className:"isplit-tag",children:t.tag}),t.items.map(s=>e.jsxs("div",{className:"isplit-row",children:[e.jsx("span",{className:"mk",children:"✕"}),e.jsx("span",{children:s})]},s))]}),e.jsx("div",{className:"isplit-arrow",children:"→"}),e.jsxs("div",{className:"isplit after",children:[e.jsx("div",{className:"isplit-tag",children:n.tag}),n.items.map(s=>e.jsxs("div",{className:"isplit-row",children:[e.jsx("span",{className:"mk",children:"✓"}),e.jsx("span",{children:s})]},s))]})]})}function kn({rows:t}){return e.jsx("div",{className:"setup-ill",children:e.jsx("div",{className:"ill-stack",children:t.map(n=>e.jsxs("div",{className:n.lime?"istack-row lime":"istack-row",children:[e.jsx("span",{className:"istack-emoji",children:n.emoji}),e.jsx("span",{className:"istack-lbl",children:n.label}),n.sub?e.jsx("span",{className:"istack-sub",children:n.sub}):null]},n.label))})})}function Sn({center:t,satellites:n}){return e.jsx("div",{className:"setup-ill",children:e.jsxs("div",{className:"ill-orbit",children:[e.jsxs("div",{className:"iorbit-center",children:[e.jsx("div",{className:"iorbit-tile",children:t.emoji}),e.jsx("div",{className:"iorbit-lbl",children:t.label})]}),e.jsx("div",{className:"iorbit-sats",children:n.map(s=>e.jsx("div",{className:"iorbit-sat",children:s},s))})]})})}function lr({bars:t}){return e.jsx("div",{className:"setup-ill",children:e.jsx("div",{className:"ill-bars",children:t.map(n=>e.jsxs("div",{className:n.lime?"ibar lime":"ibar",children:[e.jsx("div",{className:"ibar-fill",style:{height:`${n.pct}%`}}),e.jsx("div",{className:"ibar-lbl",children:n.label})]},n.label))})})}function Qt({emoji:t,caption:n,chips:s}){return e.jsxs("div",{className:"setup-ill",children:[e.jsxs("div",{className:"ill-emblem",children:[e.jsx("div",{className:"iemblem-tile",children:t}),e.jsx("div",{className:"iemblem-chips",children:s.map(r=>e.jsx("span",{className:"iemblem-chip",children:r},r))})]}),e.jsx("div",{className:"ill-cap",children:n})]})}function ro({channels:t}){return e.jsx("div",{className:"setup-ill",children:e.jsx("div",{className:"ill-channels",children:t.map(n=>e.jsxs("div",{className:n.on?"ichan on":"ichan",children:[e.jsx("div",{className:"ichan-lbl",children:n.label}),e.jsx("div",{className:"ichan-track",children:Array.from({length:n.dots}).map((s,r)=>e.jsxs(l.Fragment,{children:[r>0?e.jsx("span",{className:"ichan-line"}):null,e.jsx("span",{className:"ichan-dot"})]},r))})]},n.label))})})}const H7=Object.freeze(Object.defineProperty({__proto__:null,SetupBars:lr,SetupChannels:ro,SetupEmblem:Qt,SetupOrbit:Sn,SetupSplit:_n,SetupStack:kn},Symbol.toStringTag,{value:"Module"}));function Zt({nodes:t}){return e.jsx("div",{className:"journey",children:e.jsx("div",{className:"jrow",children:t.map((n,s)=>e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:n.lime?"jtile lime":"jtile",children:n.emoji}),e.jsx("div",{className:"jlbl",children:n.label}),e.jsx("div",{className:"jsub",children:n.sub})]}),s===t.length-1?null:e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket"}),e.jsx("span",{children:"→"})]})]},n.label))})})}const q7=Object.freeze(Object.defineProperty({__proto__:null,SetupJourney:Zt},Symbol.toStringTag,{value:"Module"}));function Xp(t){var a;const n=Object.values(((a=t.tests)==null?void 0:a.byRunner)??{}),s=n.reduce((o,i)=>o+(i.passed??0),0),r=n.reduce((o,i)=>o+(i.failed??0),0);return{total:s+r,passed:s,failed:r}}function Qp(t){const n=t??[];return{changed:n.filter(s=>s.status==="changed"),created:n.filter(s=>s.status==="new"),unchanged:n.filter(s=>s.status!=="changed"&&s.status!=="new")}}const lN=5e3,Ac={headSha:null,branch:null};function cN(){const[t,n]=l.useState([]),[s,r]=l.useState(Ac),[a,o]=l.useState(!0),[i,c]=l.useState(null),d=l.useRef(!1),u=l.useCallback(async p=>{if(!d.current){d.current=!0,p&&o(!0);try{const m=await fetch("/api/reviews");if(!m.ok)throw new Error(`HTTP ${m.status}`);const f=await m.json();n(f.reviews??[]),r(f.repoState??Ac),c(f.error??null)}catch(m){c(m instanceof Error?m.message:"Failed to load reviews")}finally{p&&o(!1),d.current=!1}}},[]),h=l.useCallback(()=>u(!0),[u]);return l.useEffect(()=>{u(!0);const p=setInterval(()=>{u(!1)},lN);return()=>clearInterval(p)},[u]),{reviews:t,repoState:s,loading:a,error:i,reload:h}}function dN(t,n){var r;const s=(r=t.pr)==null?void 0:r.headRef;return!!s&&!!n.branch&&n.branch===s}const uN=192;function Wr({children:t,variant:n="compact",maxHeight:s=uN,moreLabel:r="Show more",lessLabel:a="Show less",fadeColor:o="var(--bg-card)"}){const i=l.useRef(null),[c,d]=l.useState(!1),[u,h]=l.useState(!1);return l.useEffect(()=>{const p=i.current;if(!p)return;const m=()=>h(p.scrollHeight>s);m();const f=new ResizeObserver(m);return f.observe(p),()=>f.disconnect()},[t,s]),e.jsxs("div",{children:[e.jsxs("div",{ref:i,style:{maxHeight:c?"none":`${s}px`,overflow:"hidden",position:"relative"},children:[e.jsx(Bt,{variant:n,children:t}),!c&&u&&e.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2rem",background:`linear-gradient(transparent, ${o})`,pointerEvents:"none"}})]}),u&&e.jsx("button",{onClick:()=>d(p=>!p),className:"text-xs cursor-pointer mt-1",style:{color:"var(--accent-blue)",background:"none",border:"none",padding:0},children:c?a:r})]})}const W7=Object.freeze(Object.defineProperty({__proto__:null,CollapsibleMarkdown:Wr},Symbol.toStringTag,{value:"Module"}));function nn({label:t,children:n}){return e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:t}),e.jsx("div",{className:"mt-0.5",children:n})]})}const G7=Object.freeze(Object.defineProperty({__proto__:null,LabeledSection:nn},Symbol.toStringTag,{value:"Module"}));function Gr({status:t}){const n=t==="added"?"var(--accent-green)":t==="deleted"?"var(--accent-red)":"var(--accent-blue)",s=t==="added"?"+":t==="deleted"?"-":"~";return e.jsx("span",{className:"font-mono text-xs font-semibold",style:{color:n,minWidth:"0.75rem",textAlign:"center"},children:s})}const U7=Object.freeze(Object.defineProperty({__proto__:null,FileStatusIndicator:Gr},Symbol.toStringTag,{value:"Module"}));function Zp({files:t}){return t.length===0?null:e.jsx("div",{className:"max-h-32 overflow-y-auto",children:t.map(n=>e.jsxs("p",{className:"font-mono text-xs text-[var(--text-muted)]",children:[e.jsx(Gr,{status:n.status})," ",n.path]},n.path))})}const V7=Object.freeze(Object.defineProperty({__proto__:null,ModifiedFilesList:Zp},Symbol.toStringTag,{value:"Module"}));function hN(t){switch(t){case"blocker":return{bg:"var(--accent-red)",fg:"#fff"};case"concern":return{bg:"var(--accent-orange)",fg:"#111"};case"praise":return{bg:"var(--accent-green)",fg:"#111"};case"nit":default:return{bg:"var(--bg-subtle)",fg:"var(--text-muted)"}}}function em({finding:t}){const n=hN(t.severity),s=t.file&&(t.line!=null?`${t.file}:${t.line}`:t.file);return e.jsxs("div",{className:"flex flex-col gap-1 rounded border px-3 py-2",style:{borderColor:"var(--border-subtle)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",style:{background:n.bg,color:n.fg},children:t.severity}),s&&e.jsx("span",{className:"font-mono text-xs truncate",style:{color:"var(--text-secondary)"},children:s})]}),e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.comment})]})}const Y7=Object.freeze(Object.defineProperty({__proto__:null,ReviewFindingRow:em},Symbol.toStringTag,{value:"Module"}));function pN(t){switch(t){case"changed":return{bg:"var(--accent-orange)",fg:"#111",label:"changed"};case"new":return{bg:"var(--accent-green)",fg:"#111",label:"new"};case"unchanged":default:return{bg:"var(--bg-subtle)",fg:"var(--text-muted)",label:t}}}function ao({label:t,path:n,onPreview:s}){const r=`${t} capture`,a=!!n&&!!s;return e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide",style:{color:"var(--text-dim)"},children:t}),e.jsx("button",{type:"button",disabled:!a,onClick:a?()=>s(n,r):void 0,className:"relative h-32 w-full overflow-hidden rounded border p-0",style:{borderColor:"var(--border-subtle)",background:"var(--bg-subtle)",cursor:a?"zoom-in":"default"},title:a?"Click to view full size":void 0,children:e.jsx(At,{screenshotPath:n,alt:r})})]})}function tm({pair:t,walkable:n,headRef:s,prNumber:r,onPreviewImage:a}){const o=pN(t.status),i=t.status==="new",c=t.diffRatio!=null?`${(t.diffRatio*100).toFixed(1)}% changed`:null;return e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border p-3",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-medium",style:{color:"var(--text-primary)"},children:t.slug}),e.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",style:{background:o.bg,color:o.fg},children:o.label}),t.beforeStale&&e.jsx("span",{"data-testid":"before-stale-badge",className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{background:"var(--bg-subtle)",color:"var(--accent-orange)"},title:"The before capture was already stale at the merge base — treat the comparison with caution.",children:"before stale"}),c&&e.jsx("span",{className:"text-[10px]",style:{color:"var(--text-dim)"},children:c})]}),e.jsxs("div",{className:"flex gap-2",children:[!i&&e.jsx(ao,{label:"Before",path:t.beforePath,onPreview:a}),e.jsx(ao,{label:"After",path:t.afterPath,onPreview:a})]}),t.note&&e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.note}),n?e.jsx("a",{href:`/scenario/${encodeURIComponent(t.slug)}`,"data-testid":"view-live-link",className:"self-start rounded border px-2 py-1 text-xs",style:{borderColor:"var(--border-default)",color:"var(--accent-blue)"},children:"View live →"}):e.jsxs("p",{"data-testid":"walk-hint",className:"text-[11px]",style:{color:"var(--text-dim)"},children:["Check out the PR to walk this scenario live",r!=null?e.jsxs(e.Fragment,{children:[" — ",e.jsxs("span",{className:"font-mono",children:["gh pr checkout ",r]})]}):s?e.jsxs(e.Fragment,{children:[" — ",e.jsxs("span",{className:"font-mono",children:["git checkout ",s]})]}):null]})]})}const K7=Object.freeze(Object.defineProperty({__proto__:null,CapturePane:ao,ScenarioComparisonRow:tm},Symbol.toStringTag,{value:"Module"}));function nm({scenarios:t,walkable:n,headRef:s,prNumber:r,onPreviewImage:a}){const[o,i]=l.useState(!1),{changed:c,created:d,unchanged:u}=Qp(t);if((t??[]).length===0)return e.jsx(nn,{label:"Impacted scenarios",children:e.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No UI-impacting scenarios — this digest leads with tests and blast radius below."})});const h=p=>e.jsx(tm,{pair:p,walkable:n,headRef:s,prNumber:r,onPreviewImage:a},p.slug);return e.jsx(nn,{label:"Impacted scenarios",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[c.map(h),d.map(h),u.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i(p=>!p),"data-testid":"toggle-unchanged",className:"self-start text-xs",style:{color:"var(--accent-blue)"},children:[o?"Hide":"Show"," ",u.length," unchanged downstream scenario",u.length===1?"":"s"]}),o&&u.map(h)]})]})})}const J7=Object.freeze(Object.defineProperty({__proto__:null,ScenarioImpactSection:nm},Symbol.toStringTag,{value:"Module"}));function Ur({total:t,passed:n,failed:s}){if(t===0)return null;const r=s>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]";return e.jsxs("span",{className:`text-xs ${r}`,children:[n,"/",t," passed"]})}const X7=Object.freeze(Object.defineProperty({__proto__:null,TestResultsBadge:Ur},Symbol.toStringTag,{value:"Module"}));function sm({review:t,repoState:n,onPreviewImage:s}){var d,u,h,p,m,f,g,b,x;const r=Xp(t),a=dN(t,n),o=t.findings??[],i=((d=t.tests)==null?void 0:d.added)??[],c=(((u=t.blastRadius)==null?void 0:u.changedFiles)??[]).map(y=>({path:y,status:"modified"}));return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((h=t.pr)==null?void 0:h.number)!=null&&e.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",t.pr.number]}),((p=t.pr)==null?void 0:p.author)&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",t.pr.author]}),((m=t.pr)==null?void 0:m.url)&&e.jsx("a",{href:t.pr.url,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"View PR ↗"}),t.postedCommentUrl&&e.jsx("a",{href:t.postedCommentUrl,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"Posted comment ↗"})]}),((f=t.pr)==null?void 0:f.title)&&e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:t.pr.title})]}),e.jsx(nm,{scenarios:t.scenarios??[],walkable:a,headRef:(g=t.pr)==null?void 0:g.headRef,prNumber:(b=t.pr)==null?void 0:b.number,onPreviewImage:s}),t.narrative&&e.jsx(nn,{label:"What this PR does",children:e.jsx(Wr,{children:t.narrative})}),e.jsx(nn,{label:"Tests",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ur,{total:r.total,passed:r.passed,failed:r.failed}),i.length>0?e.jsx("ul",{className:"flex flex-col gap-1.5",children:i.map((y,v)=>e.jsxs("li",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:y.name??y.file??"test"}),y.description&&e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:y.description})]},y.file??y.name??v))}):e.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No new tests added."})]})}),o.length>0&&e.jsx(nn,{label:`Findings (${o.length})`,children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((y,v)=>e.jsx(em,{finding:y},`${y.file??"f"}-${v}`))})}),((x=t.alignment)==null?void 0:x.summary)&&e.jsx(nn,{label:"Codeyam alignment",children:e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.alignment.summary})}),c.length>0&&e.jsx(nn,{label:"Changed files",children:e.jsx(Zp,{files:c})})]})}const Q7=Object.freeze(Object.defineProperty({__proto__:null,ReviewDetailCard:sm},Symbol.toStringTag,{value:"Module"}));function mN(t){const n=t.findings??[];return{blocker:n.filter(s=>s.severity==="blocker").length,concern:n.filter(s=>s.severity==="concern").length,total:n.length}}function fN(t){return t==null?null:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function rm({review:t,repoState:n,expanded:s,onToggle:r}){var d,u,h;if(t.parseError)return e.jsxs("div",{className:"rounded-lg border p-4",style:{borderColor:"var(--accent-red)",background:"var(--bg-card)"},children:[e.jsxs("p",{className:"text-sm font-medium",style:{color:"var(--accent-red)"},children:[t.id,": could not read digest"]}),e.jsx(ft,{text:t.parseError,copyText:`${t.id}: could not read digest
|
|
100
|
+
${t.parseError??""}`,className:"text-xs text-[var(--text-dim)]",rowClassName:"mt-1"})]});const a=Qp(t.scenarios),o=mN(t),i=Xp(t),c=fN(t.createdAtMs);return e.jsxs("div",{className:"rounded-lg border",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("button",{type:"button",onClick:r,className:"flex w-full flex-col gap-2 px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((d=t.pr)==null?void 0:d.number)!=null&&e.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",t.pr.number]}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:((u=t.pr)==null?void 0:u.title)??t.id}),((h=t.pr)==null?void 0:h.author)&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",t.pr.author]}),c&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["· ",c]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[e.jsxs("span",{style:{color:"var(--accent-orange)"},children:[a.changed.length," changed"]}),e.jsxs("span",{style:{color:"var(--accent-green)"},children:[a.created.length," new"]}),e.jsxs("span",{style:{color:"var(--text-dim)"},children:[a.unchanged.length," unchanged"]}),o.total>0&&e.jsxs("span",{style:{color:"var(--text-muted)"},children:[o.blocker>0&&`${o.blocker} blocker · `,o.concern>0&&`${o.concern} concern · `,o.total," finding",o.total===1?"":"s"]}),i.total>0&&e.jsxs("span",{style:{color:i.failed>0?"var(--accent-red)":"var(--accent-green)"},children:[i.passed,"/",i.total," passed"]})]})]}),s&&e.jsx("div",{className:"px-4 pb-4 pt-1",style:{borderTop:"1px solid var(--border-subtle)"},children:e.jsx(sm,{review:t,repoState:n})})]})}const Z7=Object.freeze(Object.defineProperty({__proto__:null,ReviewCard:rm},Symbol.toStringTag,{value:"Module"}));function am({deviceLabel:t,actions:n}){return e.jsxs("div",{role:"note",className:"flex items-center gap-2 border-b border-l-4 px-3 py-2 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9"}),e.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"}),e.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"font-semibold",children:["Web preview — no ",t," running."]})," ",e.jsx("span",{style:{color:"var(--text-dim)"},children:"Boot a simulator for native fidelity (gestures, haptics, native storage)."})]}),n?e.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:n}):null]})}const e8=Object.freeze(Object.defineProperty({__proto__:null,WebFallbackNotice:am},Symbol.toStringTag,{value:"Module"}));function om({previewOrigin:t,onRecheck:n}){const s=()=>{window.open(t,"_blank","noopener")};return e.jsx("div",{role:"dialog","aria-label":"Preview sign-in required",className:"absolute inset-0 z-40 flex items-center justify-center p-8",style:{background:"var(--bg-surface)"},children:e.jsxs("div",{className:"flex max-w-md flex-col items-start gap-4 rounded-lg border border-l-4 p-6",style:{background:"var(--bg-base)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),e.jsx("span",{className:"text-base font-semibold",children:"Sign in to see the Live Preview"})]}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-dim)"},children:"This preview runs on a separate secured host that needs its own sign-in. Sign-in can’t happen inside this frame, so open the preview host in a new tab, sign in, then reload."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",onClick:s,className:"rounded px-3 py-2 text-sm font-medium",style:{background:"var(--accent-primary)",color:"var(--bg-base)"},children:"Open preview to sign in"}),e.jsx("button",{type:"button",onClick:n,className:"rounded border px-3 py-2 text-sm",style:{borderColor:"var(--border-default)",color:"var(--text-primary)"},children:"I’ve signed in — reload preview"})]})]})})}const t8=Object.freeze(Object.defineProperty({__proto__:null,PreviewSignInNotice:om},Symbol.toStringTag,{value:"Module"}));function Oi(){return e.jsxs("div",{style:{padding:"var(--spacing-lg, 16px)"},children:[e.jsx("h3",{style:{margin:0,color:"var(--text-primary)"},children:"Design exploration"}),e.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5,marginTop:"var(--spacing-sm, 8px)"},children:"Generating mockups — they'll appear here as the agent writes them."})]})}const n8=Object.freeze(Object.defineProperty({__proto__:null,MockupGridEmptyState:Oi},Symbol.toStringTag,{value:"Module"}));function oo({onRunTests:t,disabled:n,currentRunner:s}){return n?e.jsxs("span",{className:"text-xs font-medium text-[var(--text-dim)] inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-current border-r-transparent"}),s?`Running ${s}…`:"Running…"]}):e.jsx("span",{role:"button",tabIndex:0,onClick:r=>{r.stopPropagation(),t()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.stopPropagation(),t())},className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer",children:"Run Tests"})}const s8=Object.freeze(Object.defineProperty({__proto__:null,RunTestsButton:oo},Symbol.toStringTag,{value:"Module"}));function im({passed:t,failed:n,notRun:s}){const r=t+n+s;if(r===0)return null;const a=2,o=[{count:t,color:"var(--accent-green)"},{count:n,color:"var(--accent-red)"},{count:s,color:"var(--text-dim)"}].filter(u=>u.count>0),i=o.map(u=>Math.max(u.count/r*100,a)),c=i.reduce((u,h)=>u+h,0),d=i.map(u=>u/c*100);return e.jsx("div",{className:"h-1.5 flex-1 rounded-full bg-[var(--bg-input)] overflow-hidden max-w-32",children:e.jsx("div",{className:"h-full flex",children:o.map((u,h)=>e.jsx("div",{className:"h-full transition-all",style:{width:`${d[h]}%`,background:u.color}},u.color))})})}const r8=Object.freeze(Object.defineProperty({__proto__:null,TestBar:im},Symbol.toStringTag,{value:"Module"}));function Ai({tests:t,loading:n,refreshing:s,onRunTests:r,currentRunner:a}){const o=t.total>0,i=t.discovered>0,c=t.discovered>t.total?t.discovered-t.total:0;return n?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"h-1.5 w-16 rounded-full bg-[var(--bg-input)] animate-pulse"}),e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:s?"Running tests…":"Loading tests…"})]}):o?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx(im,{passed:t.passed,failed:t.failed,notRun:c}),e.jsxs("span",{className:"text-xs font-medium text-[var(--accent-green)]",children:[t.passed," passed"]}),t.failed>0&&e.jsxs("span",{className:"text-xs font-medium text-[var(--accent-red)]",children:["· ",t.failed," failed"]}),t.ignored>0&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",t.ignored," skipped"]}),c>0&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",c," not run"]}),r&&e.jsx(oo,{onRunTests:r,disabled:s,currentRunner:a})]}):i?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[t.discovered," ",t.discovered===1?"test":"tests"," (not run)"]}),r&&e.jsx(oo,{onRunTests:r})]}):e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"No tests"})}const a8=Object.freeze(Object.defineProperty({__proto__:null,AppTestSummary:Ai},Symbol.toStringTag,{value:"Module"}));function lm({tests:t,loading:n,refreshing:s,onRunTests:r,currentRunner:a}){return e.jsxs("div",{className:"px-5 pb-5 pt-2 flex items-center gap-5 border-t border-[var(--border-default)]",children:[e.jsx(Ai,{tests:t,loading:n,refreshing:s,onRunTests:r,currentRunner:a}),e.jsx("span",{className:"text-[var(--text-dim)] group-hover:text-[var(--accent-active)] transition ml-auto text-sm",children:"→"})]})}const o8=Object.freeze(Object.defineProperty({__proto__:null,AppCardFooter:lm},Symbol.toStringTag,{value:"Module"}));function Ri({type:t}){const n=t==="web";return e.jsx("span",{className:`rounded px-1.5 py-0.5 text-xs font-medium ${n?"bg-[var(--accent-blue)]/20 text-[var(--accent-blue)]":"bg-[var(--accent-purple)]/20 text-[var(--accent-purple)]"}`,children:n?"web":"backend"})}const i8=Object.freeze(Object.defineProperty({__proto__:null,AppTypeBadge:Ri},Symbol.toStringTag,{value:"Module"}));function cm({app:t}){return e.jsxs("div",{className:"px-5 pt-5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t.name}),e.jsx(Ri,{type:t.type})]}),t.description?e.jsx("p",{className:"text-sm text-[var(--text-muted)] leading-relaxed",children:t.description}):null]})}const l8=Object.freeze(Object.defineProperty({__proto__:null,AppCardHeader:cm},Symbol.toStringTag,{value:"Module"}));function dm({thumbnails:t}){return e.jsx("div",{className:"flex gap-2 overflow-hidden",children:t.map((n,s)=>e.jsx("div",{className:"h-20 w-32 shrink-0 flex items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:e.jsx(At,{screenshotPath:n.path,cacheBuster:n.cacheBuster??void 0,alt:""})},`${n.path}:${s}`))})}const c8=Object.freeze(Object.defineProperty({__proto__:null,ThumbnailStrip:dm},Symbol.toStringTag,{value:"Module"}));function um({thumbnails:t}){return e.jsx("div",{className:"px-5 py-3 flex-1",children:t.length>0?e.jsx(dm,{thumbnails:t.slice(0,4)}):e.jsx("div",{className:"h-20"})})}const d8=Object.freeze(Object.defineProperty({__proto__:null,AppCardScenarioStrip:um},Symbol.toStringTag,{value:"Module"}));function hm({stats:t,onClick:n,testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o}){const{app:i,tests:c,scenarios:d}=t;return e.jsxs("button",{onClick:n,className:"group flex w-full cursor-pointer flex-col rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] text-left transition hover:border-[var(--accent-active)]/40 hover:bg-[var(--bg-surface)]",children:[e.jsx(cm,{app:i}),e.jsx(um,{thumbnails:d.thumbnails}),e.jsx(lm,{tests:c,loading:s,refreshing:r,onRunTests:a,currentRunner:o})]})}const u8=Object.freeze(Object.defineProperty({__proto__:null,AppCard:hm},Symbol.toStringTag,{value:"Module"}));function Ei({coverage:t,prefix:n,testId:s,className:r,onClick:a}){if(!t||t.totalLines===0)return null;const o=`${Math.round(t.percent)}% coverage`,i=e.jsxs(e.Fragment,{children:[n??"",o]}),c=`${t.hitLines}/${t.totalLines} lines covered`;return a?e.jsx("span",{role:"button",tabIndex:0,className:r??"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":s??"coverage-badge",title:c,onClick:d=>{d.stopPropagation(),a()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.stopPropagation(),d.preventDefault(),a())},children:i}):e.jsx("span",{className:r??"text-xs font-medium text-[var(--text-secondary)]","data-testid":s??"coverage-badge",title:c,children:i})}const h8=Object.freeze(Object.defineProperty({__proto__:null,CoverageBadge:Ei},Symbol.toStringTag,{value:"Module"}));function pm({app:t,showDetail:n,navContext:s=Mn,stats:r,testsLoading:a,testsRefreshing:o,onRunTests:i,currentRunner:c,coverage:d,onCoverageClick:u}){if(n)return null;const h=!!(d&&d.totalLines>0);return e.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-default)]",children:[e.jsx("div",{className:"mb-2",children:e.jsx($r,{apps:s.apps,selectedApp:t,selectedRouteEntity:null,isSingleApp:s.isSingleApp,onSelectApps:s.onSelectApps,onSelectApp:s.onSelectApp,onSelectRoute:s.onSelectRoute})}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:t.name}),e.jsx(Ri,{type:t.type})]}),h?e.jsx(Ei,{coverage:d,testId:"app-detail-coverage",onClick:u}):null]}),t.description?e.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:t.description}):null,r?e.jsx("div",{className:"mt-3",children:e.jsx(Ai,{tests:r.tests,loading:a,refreshing:o,onRunTests:i,currentRunner:c})}):null]})}const p8=Object.freeze(Object.defineProperty({__proto__:null,AppDetailHeader:pm},Symbol.toStringTag,{value:"Module"}));function mm({name:t,id:n,capabilitiesTally:s,expanded:r,onToggle:a}){const o=t??n;return e.jsxs("button",{type:"button",onClick:a,className:"flex w-full items-center gap-2 text-left text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)]","data-testid":"stack-summary","aria-expanded":r,children:[e.jsx("span",{className:`inline-block transition-transform ${r?"rotate-90":""}`,children:"▶"}),e.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["Stack",o?` — ${o}`:""]}),t&&n?e.jsxs("span",{className:"text-[var(--text-dim)]",children:["(",n,")"]}):null,e.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",s]})]})}const m8=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelSummary:mm},Symbol.toStringTag,{value:"Module"})),io=["layout-web","interactions-click","interactions-touch-gestures","native-haptics","native-geolocation","native-clipboard","native-network","native-storage","routing","http-mocks","real-device"],fm={"layout-web":{label:"Web layout",description:"Visual layout and styling rendered in the web preview"},"interactions-click":{label:"Click interactions",description:"Pointer / click-driven UI behavior"},"interactions-touch-gestures":{label:"Touch gestures",description:"Swipe, pinch, and other multi-touch gestures"},"native-haptics":{label:"Haptic feedback",description:"Vibration / tactile feedback APIs"},"native-geolocation":{label:"Geolocation",description:"Device location APIs"},"native-clipboard":{label:"Clipboard",description:"Native copy / paste access"},"native-network":{label:"Network status",description:"Connectivity / reachability APIs"},"native-storage":{label:"Persistent storage",description:"On-device persistence (preferences, local DB, secure store). A 'manual' state here flags real-device verification — it does NOT mean the web preview can't be seeded; the editor still seeds storage from the adapter"},routing:{label:"Routing",description:"Navigation between screens / pages"},"http-mocks":{label:"HTTP mocking",description:"Network requests intercepted and replayed from scenarios"},"real-device":{label:"Real-device behavior",description:"Behavior that only manifests on a physical device or native build"}},gm={verified:{label:"Verified",badgeClass:"bg-[var(--accent-green)]/20 text-[var(--accent-green)]",meaning:"The editor's scenarios actually exercise this — a regression fails a test."},stubbed:{label:"Stubbed",badgeClass:"bg-[var(--accent-orange)]/20 text-[var(--accent-orange)]",meaning:"No-op'd in web preview (e.g. a native API logged to console). Tests don't fail, but nothing is really verified — check on a real device."},manual:{label:"Manual",badgeClass:"bg-[var(--accent-blue)]/20 text-[var(--accent-blue)]",meaning:"Must be checked by hand on a real device or native build target. This is orthogonal to seeding: the editor still seeds this into the web preview — 'manual' only flags the real-device check."},"not-applicable":{label:"N/A",badgeClass:"bg-[var(--bg-subtle)] text-[var(--text-dim)]",meaning:"This stack doesn't expose the capability."}};function gN(t){var n;return((n=fm[t])==null?void 0:n.label)??t}function bN(t,n){var a,o;const s=(a=fm[t])==null?void 0:a.description,r=((o=gm[n])==null?void 0:o.meaning)??"";return s?`${s}. ${r}`:r}function bm({capabilities:t,defaultExpanded:n=!1}){const[s,r]=l.useState(n),a=io.filter(c=>c in t),o=Object.keys(t).filter(c=>!io.includes(c)),i={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const c of a){const d=t[c];d in i&&(i[d]+=1)}return e.jsxs("div",{className:"px-5 py-2","data-testid":"capabilities-panel",children:[e.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:"flex w-full items-center gap-2 text-left text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)]","data-testid":"capabilities-summary","aria-expanded":s,children:[e.jsx("span",{className:`inline-block transition-transform ${s?"rotate-90":""}`,children:"▶"}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Stack capabilities"}),e.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",i.verified," verified · ",i.stubbed," stubbed ·"," ",i.manual," manual · ",i["not-applicable"]," n/a"]})]}),s?e.jsxs("div",{className:"mt-2 space-y-1","data-testid":"capabilities-rows",children:[a.map(c=>e.jsx(lo,{token:c,state:t[c]},c)),o.length>0?e.jsxs("div",{className:"mt-3","data-testid":"capabilities-unknown-group",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-[var(--accent-warn)]",children:[e.jsx("span",{title:"These tokens aren't recognized — likely typos",children:"⚠"}),"Unknown capabilities"]}),o.map(c=>e.jsx(lo,{token:c,state:t[c],unknown:!0},c))]}):null]}):null]})}function lo({token:t,state:n,unknown:s}){const r=gm[n],a=s?"This token isn't recognized — may be a typo.":bN(t,n);return e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs","data-testid":`capability-row-${t}`,children:[e.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-secondary)]",children:[gN(t),e.jsx("span",{className:"cursor-help text-[var(--text-dim)]",title:a,"aria-label":a,children:"ⓘ"})]}),e.jsx("span",{className:`rounded px-1.5 py-0.5 ${(r==null?void 0:r.badgeClass)??"bg-[var(--bg-subtle)] text-[var(--text-dim)]"}`,children:(r==null?void 0:r.label)??n})]})}const f8=Object.freeze(Object.defineProperty({__proto__:null,AppCapabilitiesPanel:bm,CapabilityRow:lo},Symbol.toStringTag,{value:"Module"}));function xm({capabilities:t}){return t&&Object.keys(t).length>0?e.jsx(bm,{capabilities:t,defaultExpanded:!1}):e.jsxs("div",{className:"text-xs text-[var(--text-dim)]","data-testid":"stack-capabilities-empty-hint",children:["Capabilities not declared. Run"," ",e.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5 text-[var(--text-secondary)]",children:"codeyam-editor editor capabilities-list"})," ","to learn more."]})}const g8=Object.freeze(Object.defineProperty({__proto__:null,AppStackCapabilitiesSlot:xm},Symbol.toStringTag,{value:"Module"}));function ym({fields:t,capabilities:n}){return e.jsxs("div",{className:"mt-2 space-y-2","data-testid":"stack-body",children:[t.description?e.jsx("p",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-description",children:t.description}):null,t.technologies.length>0?e.jsx("ul",{className:"flex flex-wrap gap-1","data-testid":"stack-technologies",children:t.technologies.map(s=>e.jsx("li",{className:"rounded bg-[var(--bg-subtle)] px-1.5 py-0.5 text-[10px] text-[var(--text-secondary)]",children:s},s))}):null,t.commands.length>0?e.jsx("dl",{className:"space-y-0.5 text-xs","data-testid":"stack-commands",children:t.commands.map(({key:s,value:r})=>e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("dt",{className:"w-10 text-[var(--text-dim)]",children:s}),e.jsx("dd",{className:"text-[var(--text-secondary)]",children:e.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5",children:r})})]},s))}):null,t.routingSummary?e.jsxs("div",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-routing",children:[e.jsx("span",{className:"text-[var(--text-dim)]",children:"routing"})," ",t.routingSummary]}):null,e.jsx("div",{className:"border-t border-[var(--border-subtle)] pt-2",children:e.jsx(xm,{capabilities:n})})]})}const b8=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelBody:ym},Symbol.toStringTag,{value:"Module"}));function vm({skip:t=!1}={}){const[n,s]=l.useState(null);return l.useEffect(()=>{if(t)return;let r=!1;return fetch("/api/project-stack").then(a=>a.ok?a.json():{}).then(a=>{r||s(a&&typeof a=="object"&&!Array.isArray(a)?a:{})}).catch(()=>{r||s({})}),()=>{r=!0}},[t]),n}const xN=["dev","test","build"];function on(t){return typeof t=="string"&&t.length>0?t:null}function jm(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function yN(t){return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function vN(t){const n=jm(t);if(!n)return[];const s=[];for(const r of xN){const a=on(n[r]);a&&s.push({key:r,value:a})}return s}function jN(t){const n=jm(t);if(!n)return null;const s=on(n.type);if(!s)return null;const r=on(n.pagesDir)??on(n.isolationRoute)??on(n.componentManifest);return r?`${s} (${r})`:s}function wN(t){const n=t.capabilities;return!n||typeof n!="object"||Array.isArray(n)?null:n}function _N(t){if(!t||Object.keys(t).length===0)return"capabilities not declared";const n={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const s of io){const r=t[s];r&&r in n&&(n[r]+=1)}return`${n.verified} verified · ${n.stubbed} stubbed · ${n.manual} manual · ${n["not-applicable"]} n/a`}function kN(t){return t?{id:on(t.id),name:on(t.name),description:on(t.description),technologies:yN(t.technologies),commands:vN(t.commands),routingSummary:jN(t.routing)}:{id:null,name:null,description:null,technologies:[],commands:[],routingSummary:null}}function wm({stack:t,defaultExpanded:n=!1}){const s=t!==void 0,[r,a]=l.useState(n),o=vm({skip:s}),i=s?t:o;if(!i||Object.keys(i).length===0)return null;const c=kN(i),d=wN(i);return e.jsxs("div",{className:"px-5 py-2","data-testid":"stack-panel",children:[e.jsx(mm,{name:c.name,id:c.id,capabilitiesTally:_N(d),expanded:r,onToggle:()=>a(u=>!u)}),r?e.jsx(ym,{fields:c,capabilities:d}):null]})}const x8=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanel:wm},Symbol.toStringTag,{value:"Module"}));function _m({app:t,navContext:n=Mn,routeEntities:s,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesRefreshing:i,routesError:c,selectedEntityHash:d,selectedRouteEntity:u,testGroups:h,selectedSlug:p,entityLookup:m,allScenarios:f,onSelectScenario:g,onSelectRoute:b,onSelectEntity:x,onBackToRoutes:y,onScenariosChanged:v,coverage:_,showProjectBand:j,onCoverageClick:k,stats:S,testsLoading:w,testsRefreshing:C,onRunTests:P,currentRunner:T}){const O=t.type==="web",N=!!j&&!u;return e.jsxs("div",{children:[N?e.jsx(wm,{}):null,e.jsx(pm,{app:t,showDetail:!!(u||d),navContext:n,stats:S,testsLoading:w,testsRefreshing:C,onRunTests:P,currentRunner:T,coverage:N?_:void 0,onCoverageClick:k}),e.jsx(Ni,{app:t,navContext:n,isWeb:O,routeEntities:s,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesRefreshing:i,routesError:c,selectedEntityHash:d??null,selectedRouteEntity:u,testGroups:h,selectedSlug:p,entityLookup:m,allScenarios:f,onSelectScenario:g,onSelectRoute:b,onSelectEntity:x,onBackToRoutes:y,onScenariosChanged:v})]})}const y8=Object.freeze(Object.defineProperty({__proto__:null,AppDetail:_m},Symbol.toStringTag,{value:"Module"}));function km(t){const n=new Date(t);if(isNaN(n.getTime()))return t;const s=new Date,r=s.getTime()-n.getTime(),a=Math.floor(r/6e4),o=Math.floor(r/36e5),i=Math.floor(r/864e5);return a<1?"just now":a<60?`${a}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:n.getFullYear()!==s.getFullYear()?"numeric":void 0})}function Sm(t){switch(t){case"feature":return"text-[#D7FF63]";case"fix":return"text-red-400";case"refactor":return"text-purple-400";case"milestone":return"text-yellow-400";default:return"text-gray-400"}}function v8(t){let n=0,s=0,r=0;for(const a of t)a.status==="added"?n++:a.status==="deleted"?r++:s++;return{added:n,modified:s,deleted:r}}function Mi({screenshots:t,onSelect:n}){return t.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map((s,r)=>{const a=!!n&&!!s.screenshotPath,o=e.jsx("div",{className:"flex h-16 w-24 items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:e.jsx(At,{screenshotPath:s.screenshotPath,cacheBuster:s.screenshotCapturedAtMs??void 0,alt:s.name})});return e.jsxs("div",{className:"text-center",children:[a?e.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(s),"aria-label":`Preview ${s.name}`,className:"block cursor-pointer rounded transition hover:ring-2 hover:ring-[var(--accent-primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-primary)]",children:o}):o,e.jsx("p",{className:"mt-0.5 text-xs text-[var(--text-dim)] truncate w-24",children:s.name})]},`${s.screenshotPath??"missing"}:${s.name}:${r}`)})})}const j8=Object.freeze(Object.defineProperty({__proto__:null,ScenarioThumbnailGrid:Mi},Symbol.toStringTag,{value:"Module"}));function Dt({children:t,testId:n}){return e.jsx("div",{className:"overflow-y-auto px-4 py-4",style:{maxHeight:"calc(100vh - 110px)"},"data-testid":n,children:t})}const w8=Object.freeze(Object.defineProperty({__proto__:null,TabScrollPanel:Dt},Symbol.toStringTag,{value:"Module"}));function Nm(){const{reviews:t,repoState:n,loading:s,error:r}=cN(),[a,o]=l.useState(null);return s?e.jsx(Dt,{children:e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading reviews..."})}):r&&t.length===0?e.jsx(Dt,{children:e.jsx("div",{className:"py-12",children:e.jsx(ft,{text:`Failed to load reviews: ${r}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}):t.length===0?e.jsx(Dt,{children:e.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No PR digests yet."}),e.jsxs("p",{className:"mt-2 text-sm",children:["Run"," ",e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:"/codeyam-review-pr"})," ","to digest an incoming pull request."]})]})}):e.jsx(Dt,{children:e.jsx("div",{className:"flex flex-col gap-3",children:t.map(i=>e.jsx(rm,{review:i,repoState:n,expanded:a===i.id,onToggle:()=>o(c=>c===i.id?null:i.id)},i.id))})})}const _8=Object.freeze(Object.defineProperty({__proto__:null,ReviewsTab:Nm},Symbol.toStringTag,{value:"Module"}));function SN({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]})}function NN({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),e.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M9 12h6"}),e.jsx("path",{d:"M9 16h6"})]})}function Tn({size:t=20}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"})})}function Os({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function Ge({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function Jn({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}function Xe({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),e.jsx("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),e.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),e.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function Ii({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),e.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),e.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),e.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),e.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),e.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),e.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]})}function Un({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Jt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]})}function Tt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),e.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),e.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function Be({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),e.jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]})}function ln({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function mt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),e.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),e.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})}function Li({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),e.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}const k8=Object.freeze(Object.defineProperty({__proto__:null,BellIcon:Li,BoxIcon:mt,CardIcon:Jt,ChartIcon:Tt,CloudIcon:Tn,DatabaseIcon:Os,DocIcon:Be,ExploreIcon:SN,GlobeIcon:ln,LockIcon:Ge,MailIcon:Jn,PlansIcon:NN,RocketIcon:Xe,SetupIcon:Ii,TerminalIcon:Un},Symbol.toStringTag,{value:"Module"})),CN=[{key:"box",label:"General"},{key:"cloud",label:"Hosting"},{key:"database",label:"Data"},{key:"lock",label:"Accounts / security"},{key:"mail",label:"Email"},{key:"card",label:"Payments"},{key:"chart",label:"Analytics"},{key:"doc",label:"Docs / legal"},{key:"globe",label:"Domain / web"},{key:"bell",label:"Notifications"},{key:"rocket",label:"Release"}],TN={add:{title:"Add a setup topic",lead:"Have something this list doesn't cover yet? Add it and it becomes part of your setup checklist.",submit:"Add topic",submitting:"Adding…"},ask:{title:"Ask about a service or topic",lead:"Tell us what you're curious about. We'll add it to your setup list so the assistant can explain it and help you set it up.",submit:"Add & ask",submitting:"Adding…"}};function Cm({intent:t="add",onSubmit:n,onCancel:s}){const r=TN[t],[a,o]=l.useState(""),[i,c]=l.useState(""),[d,u]=l.useState("box"),[h,p]=l.useState(!1),[m,f]=l.useState(null),g=a.trim(),b=g.length>0&&!h,x=async y=>{if(y.preventDefault(),!b){g.length===0&&f("Please enter a name.");return}p(!0),f(null);try{await n({name:g,desc:i.trim(),icon:d})}catch(v){f(v instanceof Error?v.message:"Something went wrong."),p(!1)}};return e.jsxs("div",{className:"learn-screen",children:[e.jsx("div",{className:"atf-backdrop",role:"presentation",onClick:s}),e.jsxs("div",{className:"atf-modal",role:"dialog","aria-modal":"true","aria-label":r.title,children:[e.jsx("div",{className:"atf-title",children:r.title}),e.jsx("p",{className:"atf-lead",children:r.lead}),e.jsxs("form",{onSubmit:x,children:[e.jsxs("label",{className:"atf-field",children:[e.jsx("span",{className:"atf-label",children:"Name"}),e.jsx("input",{className:"atf-input",type:"text",value:a,autoFocus:!0,placeholder:t==="ask"?"e.g. Cloudflare, a regional payment processor…":"e.g. Error monitoring, a custom step…",onChange:y=>o(y.target.value)})]}),e.jsxs("label",{className:"atf-field",children:[e.jsxs("span",{className:"atf-label",children:["What is it for? ",e.jsx("span",{className:"atf-optional",children:"(optional)"})]}),e.jsx("textarea",{className:"atf-input atf-textarea",value:i,rows:2,placeholder:"One line on what this is for.",onChange:y=>c(y.target.value)})]}),e.jsxs("label",{className:"atf-field",children:[e.jsx("span",{className:"atf-label",children:"Icon"}),e.jsx("select",{className:"atf-input",value:d,onChange:y=>u(y.target.value),children:CN.map(y=>e.jsx("option",{value:y.key,children:y.label},y.key))})]}),m?e.jsx("div",{className:"atf-error",children:e.jsx(ft,{text:m,className:""})}):null,e.jsxs("div",{className:"atf-actions",children:[e.jsx("button",{type:"button",className:"atf-btn atf-btn-ghost",onClick:s,disabled:h,children:"Cancel"}),e.jsx("button",{type:"submit",className:"atf-btn atf-btn-primary",disabled:!b,children:h?r.submitting:r.submit})]})]})]})]})}const S8=Object.freeze(Object.defineProperty({__proto__:null,AddTopicForm:Cm},Symbol.toStringTag,{value:"Module"}));function Tm({onAdd:t,onAsk:n}){return e.jsxs("div",{className:"setup-addrow",children:[e.jsx("div",{className:"setup-addrow-copy",children:"Don't see what you need? Add an off-list service or topic — or ask the assistant about one."}),e.jsxs("div",{className:"setup-addrow-btns",children:[e.jsx("button",{type:"button",className:"setup-addbtn",onClick:t,children:"+ Add a topic"}),e.jsx("button",{type:"button",className:"setup-addbtn setup-addbtn-ask",onClick:n,children:"Ask the AI about a service"})]})]})}const N8=Object.freeze(Object.defineProperty({__proto__:null,SetupAddTopicRow:Tm},Symbol.toStringTag,{value:"Module"}));function PN(){const[t,n]=l.useState(null);l.useEffect(()=>{let r=!1;return(async()=>{try{const a=await fetch("/api/setup-concepts");if(!a.ok)throw new Error(`HTTP ${a.status}`);const o=await a.json();r||n(Array.isArray(o)?o:[])}catch{r||n([])}})(),()=>{r=!0}},[]);const s=l.useMemo(()=>{const r=new Map;for(const a of t??[])r.set(a.key,a);return r},[t]);return{concepts:t,byKey:r=>s.get(r)}}const ON={concepts:[],byKey:()=>{}},Vr=l.createContext(ON);function Pm({children:t}){const n=PN();return e.jsx(Vr.Provider,{value:n,children:t})}function Om(){return l.useContext(Vr)}function Am(t){return l.useContext(Vr).byKey(t)}const C8=Object.freeze(Object.defineProperty({__proto__:null,ConceptsContext:Vr,ConceptsProvider:Pm,useConcept:Am,useConceptIndex:Om},Symbol.toStringTag,{value:"Module"}));function cr({k:t,children:n}){const s=Am(t),[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useId(),d=r!==null,u=()=>{var p;const h=(p=o.current)==null?void 0:p.getBoundingClientRect();h&&a({top:h.bottom+6,left:h.left})};return l.useEffect(()=>{if(!d)return;const h=m=>{var g,b;const f=m.target;!((g=o.current)!=null&&g.contains(f))&&!((b=i.current)!=null&&b.contains(f))&&a(null)},p=m=>{m.key==="Escape"&&a(null)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",p)}},[d]),s?e.jsxs("span",{className:"concept-term-wrap",children:[e.jsx("button",{type:"button",ref:o,className:"concept-term","aria-expanded":d,"aria-controls":d?c:void 0,onClick:()=>d?a(null):u(),children:n}),d&&r?Nn.createPortal(e.jsxs("div",{ref:i,className:"concept-popover",id:c,role:"dialog",style:{top:r.top,left:r.left},children:[e.jsx("span",{className:"concept-popover-term",children:s.term}),s.category?e.jsx("span",{className:"concept-popover-cat",children:s.category}):null,e.jsx("div",{className:"concept-popover-body",children:e.jsx(Bt,{variant:"compact",children:s.body})})]}),document.body):null]}):e.jsx(e.Fragment,{children:n})}const T8=Object.freeze(Object.defineProperty({__proto__:null,ConceptTerm:cr},Symbol.toStringTag,{value:"Module"}));function Rm(t){const n=t.evidence[0];return n?`found ${n.value} in ${n.source}`:t.source==="declared"?"declared by the agent":"detected in this project"}function Em({service:t,onDismiss:n,onAddCredential:s}){var i;const r=(((i=t.envVars)==null?void 0:i.length)??0)>0,a=r&&!t.credentialPresent,o=r&&t.credentialPresent;return e.jsxs("div",{className:"detected-service",children:[e.jsx("span",{className:"ds-tag",children:t.source}),e.jsx("span",{className:"ds-name",children:t.name}),e.jsx("span",{className:"ds-why",children:Rm(t)}),o?e.jsx("span",{className:"ds-key-set","data-testid":`ds-key-set-${t.key}`,children:"Key set"}):null,a&&s?e.jsx("button",{type:"button",className:"ds-add-key",onClick:()=>s(t),"aria-label":`Add key for ${t.name}`,children:"Add key"}):null,n?e.jsx("button",{type:"button",className:"ds-dismiss",onClick:()=>n(t.key),"aria-label":`Dismiss ${t.name}`,children:"Dismiss"}):null]})}const P8=Object.freeze(Object.defineProperty({__proto__:null,DetectedServiceRow:Em,evidenceSummary:Rm},Symbol.toStringTag,{value:"Module"})),AN={terminal:Un,cloud:Tn,database:Os,lock:Ge,mail:Jn,card:Jt,chart:Tt,doc:Be,globe:ln,box:mt,bell:Li,rocket:Xe};function RN(t){return AN[t]??Ii}function EN(t){return t==="done"?"trow done":t==="next"||t==="in-progress"?"trow next":"trow soon"}function MN(t){return t==="done"?"set up":t==="in-progress"?"in progress":t==="next"?"next":"explore"}function dr({topics:t,detectedServices:n,onBack:s,onOpenHosting:r,onOpenTopic:a,onOpenLibraries:o,onDismissService:i,onAddCredential:c,onCreateTopic:d,onOpenConcepts:u}){const h=b=>{b.key==="hosting"?r():a==null||a(b.key)},p=new Map;for(const b of n??[]){if(b.status==="dismissed")continue;const x=p.get(b.topic)??[];x.push(b),p.set(b.topic,x)}const[m,f]=l.useState(null),g=async b=>{if(!d)return;const x=await d(b);f(null),a==null||a(x.key)};return e.jsxs("div",{className:"learn-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:s,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Setup"})]}),e.jsx("div",{className:"h",children:"Setup"}),e.jsx("div",{className:"hsub",children:"The things this kind of app eventually needs, explained simply. Learn about each, set it up here, and see what's already configured. No rush."}),u?e.jsxs("div",{className:"concepts-nudge",children:["New to terms like ",e.jsx(cr,{k:"hosting",children:"hosting"}),", a"," ",e.jsx(cr,{k:"domain",children:"domain"}),", or"," ",e.jsx(cr,{k:"ssl-https",children:"HTTPS"}),"? Tap any underlined word for a plain-language explainer, or"," ",e.jsx("button",{type:"button",className:"concepts-nudge-link",onClick:u,children:"browse what these words mean"}),"."]}):null,e.jsx("div",{className:"tlist",children:t===null?Array.from({length:5}).map((b,x)=>e.jsxs("div",{className:"trow soon","aria-hidden":"true",children:[e.jsx("div",{className:"tic"}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:" "}),e.jsx("div",{className:"td",children:" "})]})]},x)):t.map(b=>{const x=RN(b.icon),y=p.get(b.key)??[];return e.jsxs("div",{className:"trow-group",children:[e.jsxs("button",{type:"button",className:EN(b.status),onClick:()=>h(b),children:[e.jsx("div",{className:"tic",children:e.jsx(x,{size:20})}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:b.name}),e.jsx("div",{className:"td",children:b.desc})]}),e.jsx("span",{className:"tt",children:MN(b.status)}),e.jsx("span",{className:"arrow",children:"→"})]}),y.length>0?e.jsx("div",{className:"detected-services",children:y.map(v=>e.jsx(Em,{service:v,onDismiss:i,onAddCredential:c},v.key))}):null]},b.key)})}),o&&e.jsxs("div",{className:"setup-libraries-section",children:[e.jsx("div",{className:"seclabel",children:"Libraries"}),e.jsxs("button",{type:"button",className:"trow",onClick:o,children:[e.jsx("div",{className:"tic",children:e.jsx(mt,{size:20})}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:"Libraries you depend on"}),e.jsx("div",{className:"td",children:"Every third-party library your app pulls in — what it is, its version, and how to update it."})]}),e.jsx("span",{className:"tt",children:"auto"}),e.jsx("span",{className:"arrow",children:"→"})]})]}),d?e.jsx(Tm,{onAdd:()=>f("add"),onAsk:()=>f("ask")}):null,m&&d?e.jsx(Cm,{intent:m,onSubmit:g,onCancel:()=>f(null)}):null]})}const O8=Object.freeze(Object.defineProperty({__proto__:null,LearnSetupScreen:dr},Symbol.toStringTag,{value:"Module"}));function ms({command:t,writer:n}){const{copied:s,copy:r}=ri({writer:n});return e.jsxs("div",{className:"rl-cmd",children:[e.jsx("code",{className:"rl-cmd-text",children:t}),e.jsx("button",{type:"button",className:"rl-copy",onClick:()=>{r(t).catch(()=>{})},"aria-label":`Copy command: ${t}`,children:s?"Copied!":"Copy"})]})}const A8=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyCommandRow:ms},Symbol.toStringTag,{value:"Module"}));function IN(t){return t==="dev"?"dev":t==="transitive"?"transitive":"direct"}function Mm({lib:t,copyWriter:n}){return e.jsxs("div",{className:"lib-row",children:[e.jsxs("div",{className:"lib-head",children:[e.jsx("span",{className:"lib-name",children:t.name}),e.jsx("span",{className:"lib-version",children:t.version||"—"}),e.jsx("span",{className:`lib-kind ${t.kind}`,children:IN(t.kind)}),t.outdated&&e.jsx("span",{className:"lib-outdated",title:"A newer version is available",children:"outdated"})]}),t.description?e.jsx("div",{className:"lib-desc",children:t.description}):e.jsx("div",{className:"lib-desc muted",children:"A library this project depends on. No description on file yet."}),e.jsxs("div",{className:"lib-meta",children:[t.category&&e.jsx("span",{className:"lib-tag",children:t.category}),t.license&&e.jsxs("span",{className:"lib-license",children:["License: ",t.license]}),t.homepage&&e.jsx("a",{className:"lib-docs",href:t.homepage,target:"_blank",rel:"noreferrer",children:"Docs ↗"})]}),e.jsx(ms,{command:t.updateCommand,writer:n})]})}const R8=Object.freeze(Object.defineProperty({__proto__:null,LibraryRow:Mm},Symbol.toStringTag,{value:"Module"}));function LN(t,n){return n?`${t.name} ${t.description??""} ${t.category??""}`.toLowerCase().includes(n):!0}function Im({group:t,query:n,forceOpen:s,copyWriter:r}){const[a,o]=l.useState(t.libraries.length<=8),i=t.libraries.filter(d=>LN(d,n));if(n&&i.length===0)return null;const c=s||a;return e.jsxs("section",{className:"lib-group",children:[e.jsxs("button",{type:"button",className:"lib-group-head","aria-expanded":c,onClick:()=>o(d=>!d),children:[e.jsx("span",{className:"lib-group-icon",children:e.jsx(mt,{size:18})}),e.jsx("span",{className:"lib-group-title",children:t.ecosystem}),e.jsxs("span",{className:"lib-group-count",children:[i.length," ",i.length===1?"library":"libraries"]}),e.jsx("span",{className:"lib-group-path",children:t.manifestPath}),e.jsx("span",{className:"lib-group-chevron",children:c?"▾":"▸"})]}),c&&e.jsx("div",{className:"lib-rows",children:i.map(d=>e.jsx(Mm,{lib:d,copyWriter:r},d.name))})]})}const E8=Object.freeze(Object.defineProperty({__proto__:null,LibraryGroupSection:Im},Symbol.toStringTag,{value:"Module"}));function Lm({groups:t,onBack:n,copyWriter:s}){const[r,a]=l.useState(""),o=r.trim().toLowerCase(),i=l.useMemo(()=>(t??[]).reduce((c,d)=>c+d.libraries.length,0),[t]);return e.jsxs("div",{className:"learn-screen libraries-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:n,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:n,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Libraries"})]}),e.jsx("div",{className:"h",children:"Libraries"}),e.jsx("div",{className:"hsub",children:"These are the third-party libraries your app uses — code other people wrote that you depend on instead of building it yourself. You didn't configure most of these; they came along with the tools you're using. This list is read straight from your project's manifests, so it's always up to date."}),t===null?e.jsx("div",{className:"lib-loading","aria-hidden":"true",children:"Reading your project's libraries…"}):t.length===0?e.jsxs("div",{className:"lib-empty",children:[e.jsx("div",{className:"lib-empty-title",children:"No libraries yet"}),e.jsx("div",{className:"lib-empty-body",children:"This project doesn't declare any third-party libraries in a manifest we recognize (package.json, Cargo.toml, requirements.txt, Podfile). When it does, they'll show up here automatically."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"lib-searchbar",children:e.jsx("input",{type:"search",className:"lib-search",placeholder:`Search ${i} libraries…`,value:r,onChange:c=>a(c.target.value),"aria-label":"Search libraries"})}),e.jsx("div",{className:"lib-groups",children:t.map(c=>e.jsx(Im,{group:c,query:o,forceOpen:o.length>0,copyWriter:s},c.manifestPath))})]})]})}const M8=Object.freeze(Object.defineProperty({__proto__:null,LibrariesCatalogScreen:Lm},Symbol.toStringTag,{value:"Module"}));function Di(t){switch(t){case"real-data":return e.jsx(_n,{before:{tag:"Now · in the code",items:["Resets on refresh","A developer must edit"]},after:{tag:"After · in a database",items:["Saved for good","You edit it yourself"]}});case"performance-images":return e.jsx(_n,{before:{tag:"Heavy",items:["Full-size images","Slow first paint"]},after:{tag:"Optimized",items:["Right-sized & lazy","Fast on any device"]}});case"cli-ux":return e.jsx(_n,{before:{tag:"Cryptic",items:["Confusing errors","Guess the flags"]},after:{tag:"Polished",items:["Clear help & output","Helpful messages"]}});case"forms":return e.jsx(_n,{before:{tag:"Without setup",items:["Submissions lost","Spam gets through"]},after:{tag:"With setup",items:["Reliably delivered","Spam filtered out"]}});case"custom-domain":return e.jsx(_n,{before:{tag:"Default link",items:["Generic address","Hard to remember"]},after:{tag:"Your domain",items:["yourname.com","Secure & trusted"]}});case"accounts":return e.jsx(Sn,{center:{emoji:"🔑",label:"Sign-in"},satellites:["✉️ Email link","🔵 Google","🍎 Apple","🔒 Password"]});case"emails":return e.jsx(Sn,{center:{emoji:"✉️",label:"Your app sends"},satellites:["👋 Welcome","🔑 Password reset","🧾 Receipt","🔔 Notification"]});case"api-auth":return e.jsx(Sn,{center:{emoji:"🛡️",label:"Your API"},satellites:["🎟️ API key","🪪 Token","⛔ Revoke anytime"]});case"cors-origins":return e.jsx(Sn,{center:{emoji:"🚦",label:"Your API"},satellites:["✅ your-site.com","✅ app.your-site.com","⛔ everyone else"]});case"comments-search":return e.jsx(Sn,{center:{emoji:"📚",label:"Your content"},satellites:["🔍 Fast search","💬 Comments","🛡️ Moderation"]});case"analytics-monitoring":return e.jsx(lr,{bars:[{label:"Visits",pct:62},{label:"Signups",pct:40},{label:"Active",pct:78,lime:!0},{label:"Errors",pct:16}]});case"analytics-seo":return e.jsx(lr,{bars:[{label:"Search",pct:70,lime:!0},{label:"Direct",pct:45},{label:"Social",pct:30},{label:"Referral",pct:22}]});case"logging-monitoring":return e.jsx(lr,{bars:[{label:"Mon",pct:30},{label:"Tue",pct:44},{label:"Wed",pct:88,lime:!0},{label:"Thu",pct:36},{label:"Fri",pct:52}]});case"database-backups":return e.jsx(kn,{rows:[{emoji:"🗄️",label:"Live data",sub:"The real thing"},{emoji:"💾",label:"Daily backup",sub:"Safe copy",lime:!0},{emoji:"💾",label:"Yesterday",sub:"Restore point"},{emoji:"💾",label:"Last week",sub:"Restore point"}]});case"release-builds":return e.jsx(kn,{rows:[{emoji:"🧾",label:"Your source",sub:"One codebase"},{emoji:"🍎",label:"macOS build",sub:"Ready to run",lime:!0},{emoji:"🪟",label:"Windows build",sub:"Ready to run"},{emoji:"🐧",label:"Linux build",sub:"Ready to run"}]});case"staging-environment":return e.jsx(kn,{rows:[{emoji:"🏭",label:"Production",sub:"Real users"},{emoji:"🏗️",label:"Staging",sub:"Rehearse here",lime:!0},{emoji:"💻",label:"Local",sub:"Your machine"}]});case"publish-registry":return e.jsx(kn,{rows:[{emoji:"📦",label:"your-package",sub:"v1.2.0",lime:!0},{emoji:"🏷️",label:"Registry",sub:"Public listing"},{emoji:"⬇️",label:"npm install",sub:"One command"}]});case"semver-policy":return e.jsx(kn,{rows:[{emoji:"🟥",label:"Major · 2.0.0",sub:"May break"},{emoji:"🟨",label:"Minor · 1.3.0",sub:"New features"},{emoji:"🟩",label:"Patch · 1.2.1",sub:"Safe fix",lime:!0}]});case"versioning-changelog":return e.jsx(kn,{rows:[{emoji:"🆕",label:"v1.3.0",sub:"Added, fixed",lime:!0},{emoji:"📝",label:"v1.2.0",sub:"Changed"},{emoji:"📝",label:"v1.1.0",sub:"Fixed"}]});case"pre-release-channel":return e.jsx(ro,{channels:[{label:"Stable",dots:5},{label:"Beta",dots:5,on:!0}]});case"pre-release-versions":return e.jsx(ro,{channels:[{label:"latest",dots:4},{label:"next",dots:4,on:!0}]});case"legal":return e.jsx(Qt,{emoji:"⚖️",caption:"Clear, honest, above board",chips:["Privacy policy","Terms of service","Plain language"]});case"data-safety":return e.jsx(Qt,{emoji:"🛡️",caption:"Collect less, protect the rest",chips:["Minimize","Encrypt","Declare clearly"]});case"supply-chain":return e.jsx(Qt,{emoji:"🔗",caption:"Trust the code you depend on",chips:["Scan for risk","Pin versions","Verify builds"]});case"secrets":return e.jsx(Qt,{emoji:"🔑",caption:"Out of the code, in a safe store",chips:["Never committed","Easy to rotate","Per-environment"]});case"readme-license":return e.jsx(Qt,{emoji:"📖",caption:"The first things visitors read",chips:["What it is","How to use it","What's allowed"]});case"install-docs":return e.jsx(Qt,{emoji:"📘",caption:"From zero to running, fast",chips:["Install","First example","Common task"]});case"examples":return e.jsx(Qt,{emoji:"🧩",caption:"Show it solving real tasks",chips:["Runnable","Real use cases","Copy & tweak"]});case"publish":return e.jsx(Zt,{nodes:[{emoji:"💻",label:"Your computer",sub:"Only you see it"},{emoji:"☁️",label:"Published",sub:"A home online",lime:!0},{emoji:"🌍",label:"Anyone, anywhere",sub:"Opens with a link"}]});case"deploy-target":return e.jsx(Zt,{nodes:[{emoji:"📦",label:"Your app",sub:"Ready to ship"},{emoji:"🎯",label:"Deploy target",sub:"Where it runs",lime:!0},{emoji:"🔁",label:"Ship anytime",sub:"One repeatable step"}]});case"deploy-previews":return e.jsx(Zt,{nodes:[{emoji:"✏️",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"See it live",lime:!0},{emoji:"🚀",label:"Publish",sub:"Once it's right"}]});case"staging-preview":return e.jsx(Zt,{nodes:[{emoji:"🧪",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"Share & try it",lime:!0},{emoji:"🚀",label:"Ship it",sub:"Only once it's right"}]});case"background-jobs":return e.jsx(Zt,{nodes:[{emoji:"⏳",label:"Slow work",sub:"Blocks the user"},{emoji:"📮",label:"Queued",sub:"Runs in the background",lime:!0},{emoji:"✅",label:"Done later",sub:"App stays fast"}]});case"changelog-ci":return e.jsx(Zt,{nodes:[{emoji:"🧑💻",label:"You merge",sub:"That's the trigger"},{emoji:"🤖",label:"CI runs",sub:"Build · test · notes",lime:!0},{emoji:"🚀",label:"Released",sub:"Every time"}]});case"payments":return e.jsx(Sn,{center:{emoji:"💳",label:"Secure checkout"},satellites:["💳 One-off","🔁 Subscriptions","🧾 Receipts","↩️ Refunds"]});case"shell-completions":return e.jsx(_n,{before:{tag:"Without",items:["Memorize flags","Typos & retries"]},after:{tag:"With completions",items:["Tab to complete","Commands & options"]}});default:return null}}const I8=Object.freeze(Object.defineProperty({__proto__:null,illustrationForTopic:Di},Symbol.toStringTag,{value:"Module"})),DN="Right now your app's information lives inside the code, so anything people enter disappears when they reload. A real database gives your app a memory: what people save stays saved — safely, and for good.",FN=[{q:"What is a database, really?",a:"A labelled place your app remembers things — like a spreadsheet it can read from and write to instantly. Instead of resetting when someone reloads, everything they saved is still there next time."},{q:"Do I have to run or manage a server?",a:"No. The database is hosted for you, so there's nothing to install, patch, or keep online. You connect it once and codeyam holds the keys — you never touch a server."},{q:"Is people's data kept private?",a:"Yes. Access rules decide who can see and change what, so one person can't read another person's information. You set the rules in plain terms and the database enforces them."},{q:"What does it cost to start?",a:"You can start on a free tier that comfortably covers a new app — no card needed. You only pay once the app grows popular, and you'll see it coming before you do."},{q:"Can I move my data somewhere else later?",a:"Yes. Your core data lives in a standard database, so it's yours to export and move whenever you like — you're never locked in."}],zN=["You are helping inside my actual codeyam project — this is real work in a real repository, not a hypothetical.","Before doing anything, read `.codeyam/stack.json` and the relevant source and config files so your help fits this project's stack. Prefer concrete edits and commands over generic advice.","","I want to set up **real data** — move my app's information out of the code and into a real database so it's saved for good, with private per-user access.","","Walk me through it and make the changes you safely can in my project: pick a suitable database for my stack, wire the connection, define the tables my app needs, and set up basic access rules. Ask me before anything destructive."].join(`
|
|
101
|
+
`);function Dm({onBack:t,onChatWithAI:n}){return e.jsx(Pi,{icon:e.jsx(Os,{size:26}),title:"Use real data",crumbLabel:"Real data",meta:"Foundation · about 10 minutes",assistKey:"real-data",onBack:t,lead:DN,illustration:Di("real-data"),chatPrompt:zN,onChatWithAI:n,faqs:FN})}const L8=Object.freeze(Object.defineProperty({__proto__:null,RealDataScreen:Dm},Symbol.toStringTag,{value:"Module"})),Yr={entitySingular:"item",entityPlural:"items",savedThings:"saved items",purchaseNoun:"purchase"},$N=800;function Rc(t){switch(t){case"ready":return"ready";case"error":return"error";case"connected":case"provisioning":return"provisioning";default:return"provisioning"}}function Fi(t,n){const[s,r]=l.useState("idle"),[a,o]=l.useState(null),[i,c]=l.useState(null),d=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&(clearInterval(d.current),d.current=null)},[]),h=l.useCallback(g=>{var x,y;const b=Rc(g.status);b==="ready"?(u(),o({label:((x=g.result)==null?void 0:x.label)??"",value:((y=g.result)==null?void 0:y.value)??""}),r("ready")):b==="error"?(u(),c(g.message??"Connection failed."),r("error")):r("provisioning")},[u]),p=l.useCallback(async()=>{try{const g=await fetch(`/api/setup/connection-status?topic=${encodeURIComponent(t)}`);if(!g.ok)return;h(await g.json())}catch{}},[t,h]),m=l.useCallback(g=>{u(),c(null),o(null),r("connecting"),(async()=>{try{const x=await(await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t,provider:n,credential:g})})).json().catch(()=>({}));h(x),Rc(x.status)==="provisioning"&&(d.current=setInterval(()=>void p(),$N))}catch(b){u(),c(b instanceof Error?b.message:"Connection failed."),r("error")}})()},[t,n,h,p,u]),f=l.useCallback(()=>{u(),r("idle"),o(null),c(null)},[u]);return l.useEffect(()=>u,[u]),{stage:s,result:a,error:i,connect:m,reset:f}}const BN="accounts";function HN(t){switch(t){case"clerk":return"Clerk";case"supabase_auth":return"Supabase Auth";default:return t}}function Fm({provider:t,app:n=Yr,startedOn:s="recently",onComplete:r}){const{stage:a,result:o,error:i,connect:c,reset:d}=Fi(BN,t),[u,h]=l.useState(""),p=HN(t);return a==="ready"?e.jsxs(e.Fragment,{children:[o&&(o.label||o.value)&&e.jsxs("div",{className:"url-card",role:"status",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:o.label||"Connected"}),e.jsx("div",{className:"uc-u",children:o.value})]})]}),e.jsx(Wi,{app:n,startedOn:s,onComplete:r})]}):a==="error"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"real-error-title",children:["Couldn’t connect ",p]}),e.jsx(at,{variant:"icon",text:`Couldn’t connect ${p}: ${i}`})]}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{h(""),d()},children:"Try again"})]}):a==="connecting"||a==="provisioning"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsxs("div",{className:"deploy-t",children:["Setting up ",p]}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?`Connecting to ${p}…`:"Provisioning your sign-in keys…"})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]}):e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"ph",children:["Connect ",p]}),e.jsxs("div",{className:"psub",children:["Paste your ",p," secret key to wire real accounts into your app. CodeYam holds the key and injects it into the running app — you never touch a server."]}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("label",{className:"real-token-label",htmlFor:"accounts-secret-key",children:[p," secret key"]}),e.jsx("input",{id:"accounts-secret-key",type:"password",className:"real-token-input",placeholder:`Paste your ${p} secret key`,value:u,onChange:m=>h(m.target.value)}),e.jsxs("button",{type:"button",className:"auth-btn",disabled:u.trim().length===0,onClick:()=>c(u.trim()),children:["Connect ",p]})]}),e.jsx("div",{className:"reassure",children:"🔒 Your key is stored locally and never shown."})]})}const D8=Object.freeze(Object.defineProperty({__proto__:null,AccountsRealConnect:Fm},Symbol.toStringTag,{value:"Module"}));function Ht(t,n,s){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",children:s})}function Vn({size:t=16}){return Ht(t,1.9,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2 4 5v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V5z"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}))}function zi({size:t=16}){return Ht(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1.5 1.5"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1.5-1.5"})]}))}function $i({size:t=16}){return Ht(t,1.8,e.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}))}function Bi({size:t=16}){return Ht(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),e.jsx("path",{d:"M3 9h18"})]}))}function qN({size:t=16}){return Ht(t,2,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 16v-4M12 8h.01"})]}))}function WN({size:t=16}){return Ht(t,2,e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-4 4V5a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2z"}))}function GN({size:t=16}){return Ht(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2 3 7v10l9 5 9-5V7z"}),e.jsx("path",{d:"M3 7l9 5 9-5M12 12v10"})]}))}function UN({size:t=16}){return Ht(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 7v5l3 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"9"})]}))}function VN({size:t=13}){return Ht(t,2,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"m15 9-6 6M9 9l6 6"})]}))}function Pn({size:t=13}){return Ht(t,2.5,e.jsx("path",{d:"m5 12 5 5L20 6"}))}function zm({size:t=16}){return e.jsxs("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:2,className:"rd-spin",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeOpacity:".3"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",strokeLinecap:"round"})]})}const F8=Object.freeze(Object.defineProperty({__proto__:null,ChatIcon:WN,CheckGlyph:Pn,ClockIcon:UN,CubeIcon:GN,InfoCircleIcon:qN,LinkIcon:zi,ListLinesIcon:$i,ScreenIcon:Bi,ShieldCheckIcon:Vn,SpinnerIcon:zm,XCircleIcon:VN},Symbol.toStringTag,{value:"Module"})),YN={"real-data":[{id:"wire-real-database",label:"Wire up a real database",body:"Help me move off seed/mock data onto a real persistence layer. Read `.codeyam/stack.json` and the current data shapes, recommend a database that fits this stack (and my hosting), then scaffold the connection, the schema/migrations matching my existing data shapes, and the data-access layer. Offer to migrate the current seeded data over so nothing is lost."}],accounts:[{id:"add-auth",label:"Add authentication",body:"Help me add real sign-in. Recommend an auth approach for this stack (hosted provider vs. self-rolled), wire the sign-up/sign-in/sign-out flow, protect the routes that need a session, and expose the current user to the app. Tell me which provider/console steps I must do myself."}],emails:[{id:"setup-transactional-email",label:"Set up transactional email",body:"Help me send real transactional email (verification, password reset, receipts). Pick a provider that fits the stack, wire the send API with the key in env/secrets (never hard-coded), template the messages, and give me a way to fire a test send. Note the DNS/domain-verification steps I'll complete with my provider."}],payments:[{id:"integrate-payments",label:"Integrate payments",body:"Help me accept payments. Wire the checkout flow for a provider that fits the stack (Stripe is the usual default), handle the webhook that confirms payment server-side, and gate the paid outcome on it. Keep keys in secrets and use test mode first; I'll connect my real account."}],"analytics-monitoring":[{id:"add-analytics-monitoring",label:"Add analytics & monitoring",body:"Help me add product analytics and uptime/error monitoring. Install and initialize tools that fit the stack, instrument a few key events and the error boundary, and confirm data is flowing. Keep any keys in env/secrets and respect the privacy choices the app already makes."}],legal:[{id:"draft-legal-pages",label:"Draft privacy & terms pages",body:"Draft a privacy policy and terms of service grounded in what the app actually does — scan the code for what data is collected and which third parties (analytics, payments, email) receive it. Render them as real pages/routes in the app and link them from the footer."}],"data-safety":[{id:"complete-data-safety",label:"Complete the data-safety review",body:"Inventory what data this app and its dependencies collect, store, and transmit, and to whom. Produce an honest data-safety summary I can use for a disclosure form or privacy page, and flag anything collected that the app doesn't actually need."}],publish:[{id:"publish-static-site",label:"Deploy the static site",body:"Help me publish this static build. Confirm the production build command and output directory, pick a static host that fits, wire the deploy (config file or CLI), and do a first deploy so I get a live URL. Note any account/DNS steps I complete in the host's dashboard."}],"custom-domain":[{id:"setup-custom-domain",label:"Set up a custom domain",body:"Help me put the app on a custom domain. Tell me exactly which DNS records to add for my host (A/AAAA/CNAME), update any in-app config that hard-codes the URL, and make sure HTTPS/cert provisioning is handled. I'll add the records at my registrar; give me the precise values."}],forms:[{id:"wire-form-handling",label:"Wire up form handling",body:"Help me make the site's forms actually submit. Pick an approach that fits a static/SSR site (a forms service or a serverless endpoint), wire the submission, add validation and a success/error state, and add basic spam protection. Confirm a test submission arrives where I expect."}],"analytics-seo":[{id:"improve-seo-analytics",label:"Improve SEO & analytics",body:"Help me improve SEO and add analytics. Audit and fix per-page titles, meta descriptions, Open Graph tags, a sitemap and robots.txt, then wire a privacy-respecting analytics tool. Show me before/after on the key pages."}],"staging-preview":[{id:"setup-preview-deploys",label:"Set up preview deploys",body:"Help me get a prod-like preview URL for changes before they hit prod. Wire per-branch / per-PR preview deploys on my host (or a shared staging environment if previews aren't available), and make sure previews use safe, non-prod data and secrets. Tell me the host dashboard step I do myself."}]},KN={"deploy-target":[{id:"setup-deploy-target",label:"Set up a deploy target",body:"Help me deploy this service. Read stack.json, recommend a target that fits (container host, PaaS, serverless), write the deploy config (Dockerfile/Procfile/platform file), wire required env/secrets, and do a first deploy that passes a health check. Note which dashboard/billing steps I do myself."}],"database-backups":[{id:"configure-db-backups",label:"Configure database backups",body:"Help me make the database recoverable. Set up automated backups (provider-managed if available, else a scheduled dump), define a retention window, and — critically — give me a documented, tested RESTORE procedure. A backup nobody has restored isn't a backup; walk me through one restore."}],secrets:[{id:"setup-secrets",label:"Set up secrets management",body:"Audit the repo for hard-coded secrets and any committed to git history, move them to a proper secrets mechanism for this stack/host, wire the app to read them from the environment, and add a committed `.env.example` documenting the required keys without their values."}],"api-auth":[{id:"add-api-auth",label:"Add API authentication",body:"Help me secure the API. Pick an auth scheme that fits (API keys, JWT, OAuth/session), add the middleware that enforces it, protect the routes that need it while leaving public ones open, and return correct 401/403 responses. Add a quick way for me to test an authed request."}],"cors-origins":[{id:"configure-cors",label:"Configure CORS",body:"Help me set CORS correctly. Identify which front-end origins must call this API, configure an allow-list (not a blanket wildcard when credentials are involved), set the allowed methods/headers, and verify a preflight request succeeds from an allowed origin and is rejected from an unlisted one."}],"background-jobs":[{id:"add-background-jobs",label:"Add background jobs",body:"Help me move slow or scheduled work off the request path. Pick a queue/worker approach that fits the stack, wire a worker process, move one real slow operation into a job as the worked example, and add retry and failure handling."}],"logging-monitoring":[{id:"setup-logging-monitoring",label:"Set up logging & monitoring",body:"Help me make this service observable. Add structured logging with request ids, wire error tracking and an uptime/health check, and set up at least one alert for the failure I'd most want to know about. Keep any keys in secrets."}],"api-docs":[{id:"generate-api-docs",label:"Generate API reference docs",body:"Help me produce API reference docs. Read stack.json to tell which shape this is: for a running HTTP service, generate/curate an OpenAPI (Swagger) spec from the routes and serve a docs UI; for a published library, generate reference docs from the public API and doc comments. Wire it so the docs regenerate as the API changes."}],"staging-environment":[{id:"standup-staging",label:"Stand up a staging environment",body:"Help me create a prod-like staging environment with its own data and secrets, a way to rehearse migrations before prod, and a clear promote-to-prod path. Wire the config so deploys can target staging first."}]},JN={"redirects-404":[{id:"configure-redirects-404",label:"Configure redirects & a 404 page",body:"Help me handle redirects and not-found. Add the redirect rules in the form my host expects (e.g. `_redirects`, `netlify.toml`, `vercel.json`, or framework config — read stack.json/host), migrate any old paths I tell you about, and add a real styled 404 page wired to the site's layout."}],"performance-images":[{id:"optimize-images",label:"Optimize images & performance",body:"Audit the site's images and obvious performance wins: convert/serve modern formats, add width/height and lazy-loading, generate responsive sizes where the framework supports it, and flag oversized assets. Make the changes and tell me the rough before/after weight."}],"comments-search":[{id:"add-comments-search",label:"Add comments or search",body:"Help me add a comments widget and/or client-side search to the static site. Pick an approach that needs no backend (a hosted comments service; a prebuilt search index), wire it into the relevant pages/layout, and confirm it renders and works in the preview."}],"deploy-previews":[{id:"setup-deploy-previews",label:"Set up deploy previews",body:"Help me get a preview URL for every branch/PR of this static site. Wire the host's deploy-preview feature (or equivalent config), confirm the build runs for previews, and make sure preview builds don't leak production-only config."}]},XN={"publish-registry":[{id:"prepare-registry-publish",label:"Prepare a registry publish",body:"Help me publish to the right registry for this stack (npm, crates.io, PyPI, …). Verify the package metadata (name, version, license, description, entry points), make sure only the intended files ship (ignore/include lists), do a dry-run pack and show me what's in it, and outline the auth/token step I do myself before the real publish."}],"versioning-changelog":[{id:"setup-versioning-changelog",label:"Set up versioning & changelog",body:"Help me adopt a clear versioning + changelog workflow. Establish semver for this project, set up a changelog (Keep a Changelog or a conventional-commits generator), and give me a single command to cut a release that bumps the version, updates the changelog, and tags."}],"install-docs":[{id:"write-install-docs",label:"Write install docs",body:"Write clear install/quick-start docs for this tool: the one-line install per supported method (the registry, a binary download, from source), a copy-pasteable first-run example, and the prerequisites. Put it in the README (and docs site if there is one) and verify the commands actually work as written."}],"release-builds":[{id:"setup-release-builds",label:"Set up cross-platform builds",body:"Help me produce release binaries. Set up the build matrix for the targets I care about (OS/arch), wire it into CI so a tag produces attached artifacts, and add checksums. Tell me about any signing/notarization steps (esp. macOS/Windows) I must do with my own credentials."}],"shell-completions":[{id:"generate-completions",label:"Generate shell completions",body:"Help me ship shell completions. Generate completion scripts for bash, zsh, and fish from the CLI's argument definitions (most arg frameworks can emit these), wire a command or build step that regenerates them, and document where users install each."}],"cli-ux":[{id:"polish-cli-ux",label:"Polish the CLI UX",body:"Audit the command-line UX and improve it: consistent and helpful `--help` output, clear actionable error messages with non-zero exit codes, `--version`, sensible defaults, and respect for NO_COLOR / piped output. Make the changes and show me a few before/after invocations."}],"supply-chain":[{id:"harden-supply-chain",label:"Harden the supply chain",body:"Help me harden the release supply chain: pin and audit dependencies, add a lockfile-checked CI step, generate an SBOM, and set up artifact signing/provenance for releases. Walk me through any key-management step that has to be mine."}],"pre-release-channel":[{id:"setup-prerelease-channel",label:"Set up a pre-release channel",body:"Help me offer a pre-release (next/beta) channel testers can opt into WITHOUT moving the stable `latest`. Set up the pre-release version scheme and the publish flag/tag for it on this registry, and document the one command to cut a pre-release and how users install it."}]},QN={"readme-license":[{id:"write-readme-license",label:"Write the README & pick a license",body:"Help me give this package a strong README and a license. Write a README with a one-line description, install, a minimal usage example, and a features/API summary drawn from the actual public API. Recommend a license that fits my intent (permissive vs. copyleft), add the LICENSE file, and set the license field in the package manifest."}],"changelog-ci":[{id:"setup-changelog-ci",label:"Set up changelog & release CI",body:"Help me automate releases. Add a changelog workflow and a CI pipeline that, on a version tag, runs tests, builds, and publishes to the registry. Keep the publish token in CI secrets and show me the one action I take to trigger a release."}],"semver-policy":[{id:"document-semver-policy",label:"Document a versioning policy",body:"Help me define and document a semver policy: what counts as a breaking change for THIS package's public API, the deprecation path before removals, and the support window. Write it into the docs and, if feasible, add a public-API surface check that flags an accidental breaking change in review."}],examples:[{id:"add-examples-doctests",label:"Add runnable examples & doctests",body:"Help me add examples that can't rot. Write runnable examples for the main entry points, turn the key README snippets into doctests/tested examples where the language supports it, and wire them into CI so a broken example fails the build."}],"pre-release-versions":[{id:"setup-prerelease-versions",label:"Set up pre-release versions",body:"Help me publish pre-release versions (alpha/beta/rc) that early adopters opt into WITHOUT moving the stable `latest`. Set up the pre-release version scheme and the registry tag/flag for it, and document the cut command and how users install a pre-release."}]},ZN={"dev-accounts":[{id:"guide-dev-enrollment",label:"Guide me through developer enrollment",body:"Guide me through enrolling as a developer with Apple and/or Google — advice and a checklist, not performing the paid identity work for me. Help me decide individual vs. organisation enrollment; walk the Apple D-U-N-S lookup/registration and how long it takes (issuance can run up to ~2 weeks); plan the timeline so identity/business verification isn't the launch blocker; and explain the Google Play closed-testing gate (12 testers opted in for 14 continuous days, for personal accounts created after 2023-11-13). Produce a checklist and the decisions I need to make, and be explicit that I complete the actual paid enrollment and identity verification myself in the Apple/Google consoles."}],"store-assets":[{id:"generate-mobile-store-assets",label:"Generate store screenshots & icon",body:"Help me produce the App Store / Play Store assets: the app icon at the required sizes, device-frame screenshots for each required display size, and the feature graphic. Use the app's existing icon/branding as the source and generate or resize to the EXACT per-store dimensions; flag any size I'll need to capture from a running device."}],"store-listing":[{id:"draft-mobile-listing",label:"Draft the store listing copy",body:"Draft the store listing from what the app actually does: title, subtitle, the short and full descriptions, keywords, and the what's-new text. Keep within each store's character limits and avoid the copy patterns (keyword stuffing, competitor names) that draw rejections."}],"testing-distribution":[{id:"prep-testflight",label:"Prep a TestFlight upload",body:"Help me get a build to TestFlight. Before any iOS build, run the MOBILE_SETUP.md iOS pre-flight checks (a missing platform SDK surfaces in seconds via `xcrun simctl list devices available`; surface the 8–12 GB / 10–30 min `xcodebuild -downloadPlatform iOS` cost to me BEFORE kicking it off). Then produce the archive, confirm the bundle id / signing, and walk me through the App Store Connect upload and adding internal testers."},{id:"prep-play-internal",label:"Set up Play internal testing",body:"Help me ship an internal-testing track on Google Play. Produce a signed AAB, confirm the applicationId and version code are bumped, and prepare the internal-testing release notes and the tester list. I'll create the track in the Play Console myself; prep the artifact and metadata."},{id:"prep-store-review",label:"Get ready for store review",body:"Run a pre-review checklist across both stores: privacy/data-safety answers match the code, required usage-description strings are present (iOS Info.plist), no debug/placeholder content ships, deep links and permissions actually work, and the listing matches the build. Give me a pass/fail list so I submit only when it's clean."}],"push-notifications":[{id:"wire-push",label:"Wire up push notifications",body:"Help me add push notifications end to end for this stack: register for the OS push token, wire the credentials (APNs key for iOS, FCM for Android), add the client-side receive/handle code, and give me a way to send a test notification. Note which credential steps I must do in the Apple/Firebase consoles myself."}],"crash-reporting":[{id:"add-crash-reporting",label:"Add a crash reporter",body:"Help me add crash and error reporting (e.g. Sentry/Crashlytics — pick what fits the stack). Install and initialize the SDK, wire source-map / dSYM upload so stack traces symbolicate, and trigger a test crash to confirm it lands in the dashboard."}],"in-app-purchases":[{id:"scaffold-iap",label:"Scaffold in-app purchases",body:"Help me scaffold in-app purchases/subscriptions for this stack: add the purchasing library, define the product ids, wire the buy + restore + receipt-validation flow, and gate the paid feature behind entitlement. I'll create the products in App Store Connect / Play Console myself; build the client and server-side pieces."}],"app-privacy":[{id:"fill-privacy-form",label:"Fill out the data-safety form",body:"Help me answer Apple's App Privacy and Google's Data Safety questionnaires accurately. Scan the code and dependencies (SDKs frequently collect data you didn't write code for) to determine what data is actually collected, why, and whether it's linked to identity or used for tracking, then give me the exact answers to enter."}],"app-review":[{id:"pre-review-checklist",label:"Run a pre-review checklist",body:"Audit the app against the guideline issues that most often cause rejection: a working demo account if login is required, no broken links, permission prompts with clear purpose strings, no private APIs, and a complete privacy answer set. Give me a checklist with what's done and what still needs fixing."}]},e2={"share-testing":[{id:"zip-load-unpacked",label:"Zip a load-unpacked build",body:'Help me hand a tester an unpacked build they can side-load. Produce the production build, confirm `manifest.json` sits at the ROOT of the zipped output (not nested under a build folder — that is the #1 load-unpacked mistake), zip the build directory, and write a two-line tester instruction: open chrome://extensions, enable Developer mode, click "Load unpacked" (or drag the zip). Call out that this build does NOT auto-update — testers re-load a new zip each time.'},{id:"unlisted-listing",label:"Set up an unlisted listing",body:"Help me prepare an unlisted (private-link) Chrome Web Store upload. Assemble everything that can be readied before the manual upload: the packaged zip, a version bump in `manifest.json`, the icon set and screenshots the listing requires, and a short description. Explain the one-time paid developer-account requirement and that an unlisted item STILL goes through Google's review — unlisted only hides it from search, it is not an instant private channel. I'll do the actual upload and account steps myself; prep the rest."},{id:"self-host-crx",label:"Self-host a .crx + update_url",body:"Help me self-host a packed `.crx` with auto-updates. Pack the `.crx`, generate the `update.xml` update manifest, and wire `update_url` into `manifest.json` pointing at where I'll host it. Be explicit that this path is really for MANAGED / enterprise force-install (via policy): Chrome blocks off-store `.crx` installs for ordinary user profiles, so this is not a substitute for the Web Store for normal users."}],"store-accounts":[{id:"prep-developer-account",label:"Prep my developer account",body:"Help me get ready to register as a Chrome Web Store developer. I'll pay the one-time fee and verify my identity myself — you can't do those. What you CAN do: draft a short public developer display name and the contact-email blurb the profile asks for, based on this project; explain individual vs group publisher and recommend one for my situation; and lay out the registration steps in order with the exact console URL so I can click through and complete them. Be explicit about which steps are manual."}],"extension-store-assets":[{id:"generate-store-assets",label:"Prepare the store assets",body:"Help me assemble the Chrome Web Store listing assets: the 128px store icon, the screenshots (1280×800 or 640×400), and any promo tiles. Use the extension's existing icons/branding as the source, generate or resize what's missing to the exact required dimensions, and draft the short + detailed listing descriptions from what the extension actually does."}],"permissions-justification":[{id:"draft-permission-justifications",label:"Draft permission justifications",body:'Read the `permissions` and `host_permissions` in `manifest.json`, then for EACH one draft the single-sentence justification the Web Store review requires ("why does this extension need it"). Flag any permission you can\'t tie to actual code — an unused permission is a common rejection reason, so propose removing it.'}],"oauth-verification":[{id:"prep-oauth-consent",label:"Prep the OAuth consent materials",body:"Help me get ready for Google's OAuth verification. Inventory the OAuth scopes the extension requests, separate sensitive/restricted scopes from basic ones, and draft the scope-justification text and the data-usage explanation the consent-screen review asks for. I'll submit in the Cloud console myself; prepare everything that goes into it."}],"privacy-policy":[{id:"draft-privacy-policy",label:"Draft a privacy policy",body:'Draft a privacy policy for this extension grounded in what it ACTUALLY does: scan the code for what data it reads, stores, or transmits and to where. Write a policy that honestly reflects that (including "collects nothing" if true), and save it somewhere I can host and link from the store listing.'}],"single-purpose-listing":[{id:"write-single-purpose",label:"Write the single-purpose description",body:"The Web Store requires a clear single purpose. From the code and manifest, articulate the extension's one narrow purpose in a sentence, then write a listing description that stays consistent with it. Flag any feature that reads as scope-creep beyond that single purpose (a common rejection reason) so I can decide whether to cut or re-frame it."}],"manifest-versioning":[{id:"bump-and-version",label:"Bump the version & set a scheme",body:"Help me manage the extension version. Bump the `version` in `manifest.json` correctly (4-part dot-separated, monotonically increasing — the store rejects a re-used or lower version), and if I don't have one, propose a simple versioning convention and a one-command way to bump it for each submission."}],"submit-review":[{id:"pre-submission-audit",label:"Run a pre-submission audit",body:`Before I submit, audit the package against the common rejection causes: manifest at the zip root, version bumped, every permission justified and used, a reachable privacy policy, listing assets at the right dimensions, and the single-purpose description consistent. Give me a checked/failed list so I only hit "Submit" when it's clean.`}]},t2={hosting:[{id:"deploy-and-go-live",label:"Deploy & go live",body:"Help me deploy this app and get a live URL. Read stack.json to find the build command and output, recommend a host that fits the stack, wire the deploy config (and any required env/secrets), and do a first deploy. Confirm the deployed URL actually serves the app, and tell me which account/billing steps I complete in the host's dashboard."}]},n2={"run-locally":[{id:"get-it-running",label:"Get it running on my machine",body:"Help me run this app on my own machine, outside the Live Preview. Read `.codeyam/stack.json` to learn the stack, confirm or install the prerequisites it needs, run the install step and then the project's configured run/build command, and fix any errors that come up so it actually starts. If it serves on a port, tell me the URL to open. If this project is a browser extension, build it and walk me through loading it unpacked (open chrome://extensions, enable Developer mode, and Load unpacked on the built output directory)."}]},s2={...YN,...KN,...JN,...XN,...QN,...ZN,...e2,...t2,...n2};function $m(t){return s2[t]??[]}function r2({topicName:t,goal:n}){const s=[];return s.push("You are helping inside the user's actual codeyam project — this is real work in a real repository, not a hypothetical."),s.push("Before doing anything, read `.codeyam/stack.json` and the relevant source and config files so your help fits this project's stack. Prefer concrete edits and commands over generic advice."),s.push(""),s.push(`You're helping with **${t}** — specifically: **${n.label}**.`),s.push(""),s.push(n.body),s.push(""),s.push("Walk me through it and make the changes you safely can in my project, asking before anything destructive."),s.join(`
|
|
102
|
+
`)}function cn({assistKey:t,topicName:n,goalId:s,buttonLabel:r}){const a=$m(t).find(c=>c.id===s),[o,i]=l.useState(!1);return a?e.jsxs("div",{className:"setup-goal-assist mt-4",children:[e.jsx("button",{type:"button",className:"w-full rounded-lg bg-[var(--blue-300)] px-4 py-2.5 text-sm font-semibold text-[var(--text-on-accent)] transition-opacity hover:opacity-90","aria-pressed":o,onClick:()=>i(c=>!c),children:r}),o&&e.jsx("div",{className:"mt-3 rounded-md border border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:e.jsx($t,{chatName:`setup-${t}-${a.id}`,prompt:r2({topicName:n,goal:a}),height:360,onClose:()=>i(!1)})})]}):null}const z8=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssist:cn},Symbol.toStringTag,{value:"Module"}));function ye({assistKey:t,topicName:n}){const s=$m(t);return s.length===0?null:e.jsx(e.Fragment,{children:s.map(r=>e.jsx(cn,{assistKey:t,topicName:n,goalId:r.id,buttonLabel:`Ask AI to help: ${r.label}`},r.id))})}const $8=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssistList:ye},Symbol.toStringTag,{value:"Module"})),a2=1800;function Kr({config:t,onConnect:n}){const[s,r]=l.useState(!1),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=()=>{s||(r(!0),window.setTimeout(n,a2))},u=t.connectColor==="green"?{"--connect":"var(--green)"}:void 0;return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:t.badge}),e.jsxs("div",{children:[e.jsxs("h1",{className:"su-title",children:[t.title," ",e.jsx("span",{className:"su-chip notset",children:"Not set up"})]}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:t.providerName})]}),e.jsx("p",{className:"su-lead",children:t.lead})]})]}),e.jsxs("div",{className:"su-explain",children:[e.jsxs("div",{className:"su-eh",children:[e.jsx("span",{className:"su-q",children:"?"}),t.explainerHeading]}),e.jsx("div",{className:"su-lede",children:t.lede}),e.jsx("div",{className:"su-erows",children:t.explainerRows.map(h=>e.jsxs("div",{className:"su-erow",children:[e.jsx("div",{className:"su-en",children:h.icon}),e.jsxs("div",{className:"su-et",children:[e.jsx("b",{children:h.title}),e.jsx("span",{children:h.desc})]})]},h.title))}),e.jsxs("div",{className:"su-why",children:[e.jsxs("div",{className:"su-wh",children:[e.jsx(Vn,{size:15}),t.whyHeading]}),t.whyRows.map(h=>e.jsxs("div",{className:"su-whyrow",children:[e.jsx("span",{className:"su-wc",children:e.jsx(Pn,{size:11})}),e.jsxs("p",{children:[e.jsx("b",{children:h.lead})," ",h.rest]})]},h.lead))]})]}),e.jsxs("div",{className:"su-connect",style:u,children:[e.jsx("div",{className:"su-ct",children:t.connectTitle}),e.jsx("div",{className:"su-cd",children:t.connectDesc}),e.jsx("button",{type:"button",className:"su-cbtn",onClick:d,disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(zm,{size:16}),"Opening ",t.providerName,"…"]}):e.jsxs(e.Fragment,{children:[e.jsx(zi,{size:16}),t.connectButtonLabel]})}),e.jsx("div",{className:"su-reassure",children:t.reassure.map(h=>e.jsxs("span",{children:[e.jsx(Pn,{size:13}),h]},h))})]}),t.alternatives&&t.alternatives.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"su-alt-toggle",onClick:()=>o(h=>!h),children:[a?"Hide other options":t.altToggleLabel," ",e.jsx("span",{className:"su-chev"+(a?" open":""),children:"⌄"})]}),a?e.jsx("div",{className:"su-alts",children:t.alternatives.map(h=>e.jsxs("div",{className:"su-altrow",children:[e.jsx("div",{className:"su-altmark",style:{background:h.color},children:h.monogram}),e.jsxs("div",{className:"su-altbody",children:[e.jsx("div",{className:"su-altname",children:h.name}),e.jsx("div",{className:"su-altdesc",children:h.desc}),h.factKey?e.jsxs("div",{className:"su-altfact",children:[xe(h.factKey).value,e.jsx(un,{fact:xe(h.factKey)})]}):null]}),e.jsx("button",{type:"button",className:"su-altpick"+(i===h.name?" picked":""),onClick:()=>c(h.name),children:i===h.name?"Selected ✓":"Use this"})]},h.name))}):null]}):null,e.jsx("div",{className:"su-uplabel",children:t.lockedLabel}),e.jsx("div",{className:"su-locked",children:t.lockedSteps.map(h=>e.jsxs("div",{className:"su-lrow",children:[e.jsx("div",{className:"su-ln",children:h.icon}),e.jsxs("div",{className:"su-lt",children:[e.jsx("b",{children:h.title}),e.jsx("span",{children:h.desc})]}),e.jsx("span",{className:"su-lk",children:e.jsx(Ge,{size:15})})]},h.title))}),t.faq&&t.faq.length>0?e.jsx(ot,{items:t.faq}):null,t.assistKey?e.jsx(ye,{assistKey:t.assistKey,topicName:t.title}):null]})}const B8=Object.freeze(Object.defineProperty({__proto__:null,SetupNotConnected:Kr},Symbol.toStringTag,{value:"Module"}));function Jr({children:t}){return e.jsx("div",{className:"su-steps",children:t})}function Ft({state:t,num:n,title:s,pill:r,desc:a,children:o}){return e.jsxs("div",{className:"su-step",children:[e.jsxs("div",{className:"su-rail",children:[e.jsx("div",{className:"su-node "+t,children:t==="done"?e.jsx(Pn,{size:15}):n}),e.jsx("div",{className:"su-line"})]}),e.jsxs("div",{className:"su-scon",children:[e.jsxs("div",{className:"su-stitle",children:[s,r?e.jsx("span",{className:"su-pill",children:r}):null]}),e.jsx("div",{className:"su-sdesc",children:a}),o]})]})}function Hi({monogram:t,name:n,detail:s,monogramStyle:r}){return e.jsxs("div",{className:"su-acct",children:[e.jsx("div",{className:"su-av",style:r,children:t}),e.jsxs("div",{className:"su-ainfo",children:[e.jsx("b",{children:n}),e.jsx("span",{children:s})]}),e.jsx("button",{type:"button",className:"su-chg",children:"Change"})]})}function Bm({methods:t,initialSelected:n}){const[s,r]=l.useState(()=>new Set(n)),a=o=>r(i=>{const c=new Set(i);return c.has(o)?c.delete(o):c.add(o),c});return e.jsx("div",{className:"su-methods",children:t.map(o=>e.jsxs("button",{type:"button",className:"su-mchip"+(s.has(o.key)?" on":""),onClick:()=>a(o.key),"aria-pressed":s.has(o.key),children:[e.jsx("span",{className:"su-ck",children:e.jsx(Pn,{size:11})}),o.icon,o.label]},o.key))})}function Xr({children:t}){return e.jsxs("div",{className:"su-field",children:[e.jsx("span",{className:"su-edit",children:"Edit"}),t]})}function Hm({examples:t}){const[n,s]=l.useState(new Set),r=a=>s(o=>{const i=new Set(o);return i.has(a)?i.delete(a):i.add(a),i});return e.jsx("div",{className:"su-examples",children:t.map((a,o)=>e.jsxs("button",{type:"button",className:"su-ex"+(n.has(o)?" added":""),onClick:()=>r(o),children:[e.jsx("span",{className:"su-plus",children:n.has(o)?"✓":"+"}),a]},a))})}function Qr({items:t}){return e.jsx("div",{className:"su-builds",children:t.map(n=>e.jsxs("div",{className:"su-bitem",children:[e.jsx("div",{className:"su-bx",children:e.jsx(Pn,{size:13})}),e.jsxs("div",{className:"su-bmain",children:[e.jsx("b",{children:n.title}),e.jsx("span",{children:n.caption})]}),e.jsx("span",{className:"su-where",children:n.where})]},n.title))})}function Zr({accent:t,icon:n,children:s}){const r={"--note-accent":t==="amber"?"var(--amber)":"var(--blue)"};return e.jsxs("div",{className:"su-note",style:r,children:[n,e.jsx("p",{children:s})]})}function ea({label:t,note:n,onPlan:s}){const[r,a]=l.useState(!1),o=()=>{r||(a(!0),s==null||s())};return e.jsxs("div",{className:"su-foot",children:[e.jsx("button",{type:"button",className:"su-cta",onClick:o,disabled:r,children:r?"Added to your plans ✓":e.jsxs(e.Fragment,{children:[t," ",e.jsx("span",{className:"su-ar",children:"→"})]})}),e.jsx("div",{className:"su-fnote",children:n})]})}const H8=Object.freeze(Object.defineProperty({__proto__:null,BuildList:Qr,ControlNote:Zr,EditableField:Xr,ExampleChips:Hm,MethodChips:Bm,SetupAccountRow:Hi,SetupPlanFooter:ea,SetupStep:Ft,SetupStepper:Jr},Symbol.toStringTag,{value:"Module"}));function Xn(t,n,s){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",children:s})}function vr({size:t=16}){return Xn(t,1.7,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),e.jsx("path",{d:"M5 20a7 7 0 0 1 14 0"})]}))}function qm({size:t=16}){return Xn(t,1.8,e.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"}))}function qi({size:t=16}){return Xn(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 2 11 13"}),e.jsx("path",{d:"M22 2 15 22l-4-9-9-4z"})]}))}function Wm({size:t=16}){return Xn(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 9v4M12 17h.01"}),e.jsx("path",{d:"M10.3 4.3 2.6 18a1.5 1.5 0 0 0 1.3 2.2h16.2a1.5 1.5 0 0 0 1.3-2.2L13.7 4.3a1.5 1.5 0 0 0-2.6 0z"})]}))}function co({size:t=16}){return Xn(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m22 7-10 6L2 7"}),e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"})]}))}function Gm({size:t=16}){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"currentColor",children:e.jsx("path",{d:"M21.35 11.1H12v2.9h5.35c-.25 1.45-1.7 4.25-5.35 4.25-3.2 0-5.85-2.65-5.85-5.9s2.65-5.9 5.85-5.9c1.85 0 3.05.8 3.75 1.45l2.55-2.45C16.6 3.6 14.55 2.7 12 2.7 6.95 2.7 2.9 6.75 2.9 12s4.05 9.3 9.1 9.3c5.25 0 8.7-3.7 8.7-8.9 0-.6-.05-1.05-.35-1.3z"})})}function Um({size:t=16}){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"currentColor",children:e.jsx("path",{d:"M16.4 12.8c0-2.2 1.8-3.3 1.9-3.3-1-1.5-2.6-1.7-3.2-1.7-1.4-.1-2.6.8-3.3.8-.7 0-1.7-.8-2.8-.8-1.4 0-2.8.8-3.5 2.1-1.5 2.6-.4 6.5 1.1 8.6.7 1 1.6 2.2 2.7 2.1 1.1 0 1.5-.7 2.8-.7s1.6.7 2.8.7c1.1 0 1.9-1 2.6-2.1.8-1.2 1.2-2.3 1.2-2.4-.1 0-2.3-.9-2.3-3.4zM14.2 6.3c.6-.7 1-1.7.9-2.7-.9 0-2 .6-2.6 1.3-.6.6-1.1 1.6-.9 2.6 1 .1 2-.5 2.6-1.2z"})})}function Vm({size:t=16}){return Xn(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3 3 8l9 5 9-5-9-5z"}),e.jsx("path",{d:"M3 8v5l9 5 9-5V8"})]}))}const q8=Object.freeze(Object.defineProperty({__proto__:null,AppleGlyph:Um,ArrowRightIcon:qm,GoogleGlyph:Gm,GraduationIcon:Vm,MagicLinkIcon:co,PaperPlaneIcon:qi,PersonIcon:vr,WarningTriangleIcon:Wm},Symbol.toStringTag,{value:"Module"}));function ta({topic:t}){const{services:n}=Ci();if(!n)return null;const s=n.find(a=>a.topic===t&&a.status!=="dismissed");if(!s)return null;const r=s.evidence.map(a=>a.value).join(", ");return e.jsxs("div",{className:"wired-provider",role:"note",children:[e.jsxs("div",{className:"wired-provider-title",children:[e.jsx("b",{children:s.name})," is already wired in this project"]}),e.jsx("div",{className:"wired-provider-detail",children:r?`We found ${r} in your project — here's how to finish setting it up.`:"Here's how to finish setting it up."})]})}const W8=Object.freeze(Object.defineProperty({__proto__:null,WiredProviderBanner:ta},Symbol.toStringTag,{value:"Module"}));function o2(t){return{accent:"blue",assistKey:"accounts",badge:e.jsx(vr,{size:25}),title:"Let people sign in",providerName:"Supabase",connectColor:"lime",lead:`Right now everyone using your app is anonymous, so a ${t.entitySingular} they save vanishes the moment they close the tab. Give people their own account and their ${t.savedThings} and settings follow them on any device. CodeYam uses Supabase.`,explainerHeading:"New to accounts? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"An account is how your app knows who someone is."})," Instead of every visitor being a stranger, each person gets a private space — their"," ",t.savedThings,", their profile — that they can reach from any phone or laptop by signing in. Supabase is the secure tech that handles the signing-in part for you."]}),explainerRows:[{icon:e.jsx(vr,{size:16}),title:"Everything stays tied to them",desc:e.jsxs(e.Fragment,{children:["Their ",t.savedThings," and profile are remembered"," ",e.jsx("em",{children:"even after they close the app"}),", instead of resetting."]})},{icon:e.jsx(qm,{size:16}),title:"It follows them across devices",desc:e.jsxs(e.Fragment,{children:["Sign in on a phone, see the same ",t.savedThings," on a laptop,"," ",e.jsx("em",{children:"anywhere they sign in"}),"."]})},{icon:e.jsx(Ge,{size:16}),title:"It keeps private things private",desc:e.jsxs(e.Fragment,{children:["Accounts let you say ",e.jsx("em",{children:'"only this person can see their data,"'})," ","which you'll want before real money or personal info is involved."]})}],whyHeading:"Why CodeYam picks Supabase for you",whyRows:[{lead:"Free to start, no card needed.",rest:"A generous free tier covers a new app comfortably. You only pay once you have a lot of users, and you'll see it coming."},{lead:"Security handled for you.",rest:"Passwords, Google and Apple sign-in, and resets are managed by Supabase, so the risky parts aren't yours to get right. Social logins do need a one-time developer setup with each provider — see the FAQ below."},{lead:"Nothing for you to manage.",rest:"No servers, no security patches. CodeYam handles the wiring, you just decide who gets to sign in."}],connectTitle:"Connect or create your Supabase project",connectDesc:"A new window opens on Supabase. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it and holds the keys, so you never touch a server.",connectButtonLabel:"Connect Supabase",reassure:["Free to start, no card needed","Takes about 3 minutes","Disconnect any time"],altToggleLabel:"Supabase not for you? See other options",alternatives:[{monogram:"C",color:"linear-gradient(140deg,#6c47ff,#4b2fcc)",name:"Clerk",desc:"Polished sign-in screens and user management out of the box. A great pick if you want the slickest ready-made experience.",factKey:"clerk.freeTier"},{monogram:"A",color:"linear-gradient(140deg,#eb5424,#b53a13)",name:"Auth0",desc:"A long-established choice with deep enterprise controls. Worth it if you'll need that later, a little more to set up.",factKey:"auth0.freeTier"}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx($i,{size:15}),title:"Choose how people sign in",desc:`Google, Apple, email, magic link — pick as many as you like. Then say when to ask, like "only when someone saves an ${t.entitySingular}."`},{icon:e.jsx(Bi,{size:15}),title:"CodeYam builds your sign-in screens",desc:`A sign-in screen, a "sign in to save" prompt, per-person ${t.savedThings}, and a profile menu — each a plan you preview before it ships.`}],faq:[{q:"Do Google and Apple sign-in need extra setup?",a:`Yes — each social login is registered with that provider, so Google and Apple sign-in need OAuth credentials created in the provider's developer console (a one-time setup CodeYam walks you through). "Sign in with Apple" also requires a paid Apple Developer account (${xe("appleDeveloper.fee").value}). Email and magic-link sign-in have no such requirement, so they're the quickest way to launch.`},{q:"Can I add more sign-in options later?",a:"Yes. You can start with just email or a magic link and add Google, Apple, or others whenever you're ready — each is its own small plan you preview before it ships."}]}}const i2=[{key:"google",label:"Google",icon:e.jsx(Gm,{size:15})},{key:"apple",label:"Apple",icon:e.jsx(Um,{size:15})},{key:"email",label:"Email",icon:e.jsx(co,{size:15})},{key:"magic",label:"Magic link",icon:e.jsx(co,{size:15})}];function Wi({app:t,startedOn:n,onComplete:s}){const r=[{title:"A sign-in & sign-up screen",caption:"Google, Apple, and email, matched to your app's look.",where:"/signin"},{title:'A "sign in to save" prompt',caption:"Shown the first time someone taps save or buy, never before.",where:`/${t.entitySingular}`},{title:`Each person's own ${t.savedThings}`,caption:"Their list follows them on phone, laptop, anywhere they sign in.",where:"/saved"},{title:"A profile & sign-out menu",caption:"So people can manage their account and leave safely.",where:"/profile"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(vr,{size:25})}),e.jsxs("div",{children:[e.jsx("h1",{className:"su-title",children:"Let people sign in"}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Supabase"})," · the sign-in tech behind modern apps"]}),e.jsxs("p",{className:"su-lead",children:["Give people their own account so their ",t.savedThings," and settings follow them on any device. CodeYam builds the screens and handles the security, you just decide who gets in."]})]})]}),e.jsxs("div",{className:"su-remember",children:[e.jsx("span",{className:"su-rdot"}),e.jsxs("div",{className:"su-widget-body",children:[e.jsxs("b",{children:["You started this on ",n,"."]}),e.jsx("span",{children:"Sign-in methods are chosen — one step left before you can plan it."})]}),e.jsx("span",{className:"su-ago",children:"resumed today"})]}),e.jsxs("div",{className:"su-learn",children:[e.jsxs("div",{className:"su-lhd",children:[e.jsx(Vm,{size:15}),'What "accounts" actually means']}),e.jsxs("p",{children:["Right now everyone using your app is ",e.jsx("b",{children:"anonymous"})," — nothing they do is tied to them, so a saved ",t.entitySingular," disappears when they close the tab."]}),e.jsxs("p",{children:["Accounts give each person a ",e.jsx("b",{children:"private space"}),": their own"," ",t.savedThings,`, their profile. It also lets you say "only this person can see their data," which you'll want before real money or personal info is involved.`]})]}),e.jsx("div",{className:"su-seclabel",children:"Set it up"}),e.jsxs(Jr,{children:[e.jsx(Ft,{state:"done",num:1,title:"How should people sign in?",pill:"Chosen",desc:"Pick as many as you like. Most apps offer one tap with Google or Apple, plus email as a fallback.",children:e.jsx(Bm,{methods:i2,initialSelected:["google","apple","email"]})}),e.jsx(Ft,{state:"done",num:2,title:"When should people be asked to sign in?",desc:"Plain language is fine — this is the instruction CodeYam follows.",children:e.jsxs(Xr,{children:["Let people ",e.jsx("b",{children:"browse freely"})," without an account. Only ask them to sign in when they ",e.jsxs("b",{children:["save an ",t.entitySingular]})," or"," ",e.jsxs("b",{children:["buy a ",t.purchaseNoun]}),"."]})}),e.jsx(Ft,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four changes. Each becomes a plan you can preview, reorder, or drop before it ships.",children:e.jsx(Qr,{items:r})})]}),e.jsxs(Zr,{accent:"blue",icon:e.jsx(Ge,{size:17}),children:[e.jsx("b",{children:"Nothing is locked down yet."})," People keep using your app exactly as they do now until you plan and build these. You can preview every screen first."]}),e.jsx(ea,{label:"Plan these 4 changes",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, ready to build after your current session."]}),onPlan:s})]})}function Ym({onBack:t,onComplete:n,app:s=Yr,initialConnected:r=!1,startedOn:a="recently",connector:o}){const[i,c]=l.useState(r),d=!!o&&!i;return e.jsxs("div",{className:"setup-screen accent-blue",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Accounts & sign-in"})]}),e.jsx(ta,{topic:"accounts"}),i?e.jsx(Wi,{app:s,startedOn:a,onComplete:n}):d?e.jsx(Fm,{provider:o.provider,app:s,startedOn:a,onComplete:n}):e.jsx(Kr,{config:o2(s),onConnect:()=>c(!0)})]})}const G8=Object.freeze(Object.defineProperty({__proto__:null,AccountsConnected:Wi,AccountsScreen:Ym},Symbol.toStringTag,{value:"Module"})),l2="hello@your-app.com",c2={monogram:"R",name:"Your app",detail:"you@your-app.com · re_live_…"};function d2(t){return{accent:"amber",assistKey:"emails",badge:e.jsx(Jn,{size:25}),title:"Send emails from your app",providerName:"Resend",connectColor:"green",lead:"Right now your app can't email anyone. To send things like receipts, sign-in links, and welcome notes, it needs an email service — the part that actually delivers messages. CodeYam uses Resend.",explainerHeading:"New to Resend? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Resend is the part that actually sends your email."})," When your app needs to email someone, Resend takes the message and makes sure it lands in their inbox, not the spam folder, from an address that looks like you."]}),explainerRows:[{icon:e.jsx(qi,{size:16}),title:"It sends reliably",desc:e.jsxs(e.Fragment,{children:["Receipts, password resets, and welcome notes go out"," ",e.jsx("em",{children:"the instant your app asks"}),", from your own address."]})},{icon:e.jsx(Vn,{size:16}),title:"It stays out of spam",desc:e.jsxs(e.Fragment,{children:["Resend handles the technical reputation work behind the scenes, so your emails ",e.jsx("em",{children:"actually arrive"})," instead of vanishing."]})},{icon:e.jsx(Tt,{size:16}),title:"It shows you what happened",desc:e.jsxs(e.Fragment,{children:["See what was sent, delivered, or opened ",e.jsx("em",{children:"in one simple log"}),", so you're never guessing if a message went through."]})}],whyHeading:"Why CodeYam picks Resend for you",whyRows:[{lead:"Free to start, no card needed.",rest:`Resend's free tier gives you ${xe("resend.free").value} — plenty for a new app, and the daily cap is the one to watch on launch day. You only pay once you send more.`},{lead:"Use your own address.",rest:"Send from your own domain so it looks like you, not a robot or a no-reply. This needs a one-time domain verification (a few DNS records) — see the steps below."},{lead:"Nothing to wire up.",rest:"CodeYam connects it and writes the emails for you. You just say what each one should say."}],connectTitle:"Connect or create your Resend account",connectDesc:"A new window opens on Resend. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it and holds the keys, so you never touch a server.",connectButtonLabel:"Connect Resend",reassure:["Free to start, no card needed","Connecting takes minutes — verifying your domain in DNS can take longer","Disconnect any time"],altToggleLabel:"Resend not for you? See other options",alternatives:[{monogram:"P",color:"#ffd400",name:"Postmark",desc:"Built for receipts and sign-in links, with a reputation for landing in the inbox fast. A great pick if reliable delivery matters most."},{monogram:"SG",color:"#1a82e2",name:"SendGrid",desc:"A long-established service that scales to very high volume. Handy if you already have an account you'd rather reuse."},{monogram:"SES",color:"#ff9900",name:"Amazon SES",desc:"The cheapest once you're sending a lot, with a little more setup. Best for high volume when you want to trim cost."}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Vn,{size:15}),title:"Verify your sending domain",desc:"Add a few DNS records (SPF, DKIM, DMARC) so providers trust your mail. This can take from a few minutes to a few hours to take effect — until it does, you can only send from Resend's test address, not your own domain."},{icon:e.jsx($i,{size:15}),title:"Tell us which emails to send",desc:`Plain language, like "a receipt after each ${t.purchaseNoun}, and a welcome note on sign-up."`},{icon:e.jsx(Bi,{size:15}),title:"CodeYam writes and wires each email",desc:"The wording, the design, and when it sends — each a plan you preview before a single message goes out."}],faq:[{q:"Why are my emails going to spam?",a:"Almost always because your sending domain isn't verified yet. Until you add the SPF, DKIM, and DMARC DNS records Resend gives you, inbox providers can't confirm the mail is really from you, so they filter it. Verifying your own domain — and sending from it rather than a free inbox address like gmail.com — is what gets you reliably into the inbox."},{q:"Do I need my own domain to send email?",a:"To send from your own address (hello@your-app.com) and stay out of spam, yes — you verify a domain you own. Before that's set up you can still send from Resend's shared test address to try the flow, but real launch email should go from your verified domain."}]}}function Km({app:t,verifiedAddress:n,account:s,onComplete:r}){const a=[{title:"A welcome email",caption:"Sent the moment someone signs up, in your voice.",where:"on sign-up"},{title:`A receipt & ${t.purchaseNoun} email`,caption:`With the ${t.entitySingular} details and a ${t.purchaseNoun}, after each purchase.`,where:"on purchase"},{title:"A password reset link",caption:"A secure, single-use link when someone asks to reset.",where:"on request"},{title:"A simple sent log",caption:"See what was sent, delivered, or opened, in one screen.",where:"/emails"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(Jn,{size:25})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"su-title",children:["Send emails from your app"," ",e.jsxs("span",{className:"su-chip connected",children:[e.jsx(Pn,{size:11}),"Connected"]})]}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Resend"})]}),e.jsx("p",{className:"su-lead",children:"Your app can send email now. Tell CodeYam which emails to send, in plain language, and it writes and wires each one. You preview every message before a single one goes out."})]})]}),e.jsxs("div",{className:"su-statusbar",children:[e.jsx("div",{className:"su-widget-ic",children:e.jsx(Vn,{size:16})}),e.jsxs("div",{className:"su-widget-body",children:[e.jsx("b",{children:"Your sending address is verified"}),e.jsxs("span",{children:["Emails go out from ",e.jsx("code",{children:n}),", so they look like you, not a robot."]})]}),e.jsx("button",{type:"button",className:"su-chg",children:"Manage"})]}),e.jsxs(Jr,{children:[e.jsx(Ft,{state:"done",num:1,title:"Connect your Resend account",pill:"Connected",desc:"CodeYam holds the keys and does the wiring — you never touch a server or a config file.",children:e.jsx(Hi,{monogram:s.monogram,name:s.name,detail:s.detail,monogramStyle:{background:"#ffd400",color:"#1a1a1a"}})}),e.jsxs(Ft,{state:"done",num:2,title:"Which emails should your app send?",desc:"Plain language is fine — this is what shapes the emails below.",children:[e.jsxs(Xr,{children:["A ",e.jsx("b",{children:"welcome note"})," when someone signs up, a"," ",e.jsxs("b",{children:["receipt with their ",t.purchaseNoun]})," after a purchase, and a"," ",e.jsx("b",{children:"password reset link"})," when they ask for one."]}),e.jsx(Hm,{examples:[`A reminder the day before an ${t.entitySingular}`,`A note when an ${t.entitySingular} is cancelled`,`A monthly "what's on" roundup`]})]}),e.jsx(Ft,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four emails, each a plan you can preview, reword, or drop before it ever sends.",children:e.jsx(Qr,{items:a})})]}),e.jsxs(Zr,{accent:"amber",icon:e.jsx(qi,{size:17}),children:[e.jsx("b",{children:"No email sends yet."})," These four are built as drafts so you can read every word and see how each looks. When it feels right, turn them on and your app starts emailing."]}),e.jsx(ea,{label:"Plan these 4 emails",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, previewable before anything sends, and easy to reword anytime."]}),onPlan:r})]})}function Jm({onBack:t,onComplete:n,app:s=Yr,initialConnected:r=!1,verifiedAddress:a=l2,account:o=c2}){const[i,c]=l.useState(r);return e.jsxs("div",{className:"setup-screen accent-amber",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Sending emails"})]}),e.jsx(ta,{topic:"emails"}),i?e.jsx(Km,{app:s,verifiedAddress:a,account:o,onComplete:n}):e.jsx(Kr,{config:d2(s),onConnect:()=>c(!0)})]})}const U8=Object.freeze(Object.defineProperty({__proto__:null,EmailsConnected:Km,EmailsScreen:Jm},Symbol.toStringTag,{value:"Module"}));function Vs(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function Gi({config:t,provider:n,onBack:s,onComplete:r,onRevert:a}){const{stage:o,result:i,error:c,connect:d,reset:u}=Fi(t.key,n),[h,p]=l.useState("");return o==="idle"?e.jsxs(e.Fragment,{children:[e.jsx(an,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:s}),e.jsx(Yt,{steps:Vs(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:t.connect.heading}),e.jsx("div",{className:"psub",children:t.connect.sub}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(qr,{initial:t.recommended.initial,color:t.recommended.color}),e.jsxs("div",{children:[e.jsxs("div",{className:"cbt",children:["Connect ",t.recommended.name]}),e.jsxs("div",{className:"cbd",children:["Paste a ",t.recommended.name," API token to connect your real account."]})]})]}),e.jsx("label",{className:"real-token-label",htmlFor:"real-token",children:"API token"}),e.jsx("input",{id:"real-token",type:"password",className:"real-token-input",placeholder:`Paste your ${t.recommended.name} token`,value:h,onChange:m=>p(m.target.value)}),e.jsx("button",{type:"button",className:"auth-btn",disabled:h.trim().length===0,onClick:()=>d(h.trim()),children:t.connect.continueLabel})]}),e.jsxs("div",{className:"reassure",children:["🔒 ",t.connect.reassure]})]})]}):o==="error"?e.jsxs(e.Fragment,{children:[e.jsx(an,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:s}),e.jsx(Yt,{steps:Vs(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t connect"}),e.jsx(at,{variant:"icon",text:`Couldn’t connect: ${c}`})]}),e.jsx("div",{className:"real-error-msg",children:c})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{p(""),u()},children:"Try again"})]})]}):o==="ready"?e.jsxs(e.Fragment,{children:[e.jsx(an,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(Yt,{steps:Vs(t),currentKey:"ready"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:t.ready.title}),e.jsx("div",{className:"lh-d",children:t.ready.desc})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:(i==null?void 0:i.label)||t.ready.resultLabel}),e.jsx("div",{className:"uc-u",children:(i==null?void 0:i.value)||t.ready.resultValue})]})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx(Qe,{})," ",t.ready.donePill]}),e.jsx("button",{type:"button",className:"lf-back",onClick:()=>r==null?void 0:r(),children:"Back to Setup"}),a?e.jsx("button",{type:"button",className:"lf-revert",onClick:a,children:"Mark as not complete"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(an,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(Yt,{steps:Vs(t),currentKey:"provision"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:t.provisionTitle}),e.jsx("div",{className:"deploy-d",children:o==="connecting"?`Connecting to ${t.recommended.name}…`:t.provisionDesc})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const V8=Object.freeze(Object.defineProperty({__proto__:null,RealSetupFlow:Gi},Symbol.toStringTag,{value:"Module"})),u2={monogram:"AC",name:"Your app",detail:"you@your-app.com · acct_…"};function h2(t){return{accent:"indigo",assistKey:"payments",badge:e.jsx(Jt,{size:25}),title:"Accept payments",providerName:"Stripe",connectColor:"lime",lead:"You'd like people to be able to pay inside your app. To move money safely, apps don't handle cards themselves — they hand that part to a trusted service. CodeYam uses Stripe.",explainerHeading:"New to Stripe? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Stripe is the part that actually moves the money."})," Think of it as the card machine and the bank, run by someone else, so you never have to touch a customer's card details yourself."]}),explainerRows:[{icon:e.jsx(Ge,{size:16}),title:"It takes the payment safely",desc:e.jsxs(e.Fragment,{children:["The buyer types their card into ",e.jsx("em",{children:"Stripe's"})," secure screen, not yours. Sensitive numbers never sit in your app."]})},{icon:e.jsx(Jt,{size:16}),title:"It charges the card",desc:e.jsxs(e.Fragment,{children:["Stripe talks to the banks and approves the payment in"," ",e.jsx("em",{children:"a few seconds"}),", then tells your app it went through."]})},{icon:e.jsx(Tt,{size:16}),title:"It pays you",desc:e.jsxs(e.Fragment,{children:["The money lands in ",e.jsx("em",{children:"your bank account"}),", usually within a couple of days. You can watch every sale from your dashboard."]})}],whyHeading:"What it costs",whyRows:[{lead:"It's free to start.",rest:`No monthly fee. Stripe keeps a small cut of each sale (${xe("stripe.usCardFee").value} for US cards; international cards and currency conversion cost more, and a disputed charge carries a fee), so you only pay when you actually get paid. It's trusted by millions of businesses, from corner shops to Amazon.`}],connectTitle:"Connect or create your Stripe account",connectDesc:"A new window opens on Stripe. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it; we never see card numbers.",connectButtonLabel:"Connect Stripe",reassure:["Start in test mode, no real card or bank details needed yet","Connecting takes minutes — activating live payments takes longer","Disconnect any time"],altToggleLabel:"Selling internationally or digital goods? See tax-handling options",alternatives:[{monogram:"LS",color:"linear-gradient(140deg,#ffc233,#e0a000)",name:"Lemon Squeezy",desc:"Acts as the merchant of record, so it collects and remits sales tax/VAT for you worldwide. A strong pick for digital goods or selling outside the US, in exchange for a higher per-sale fee."},{monogram:"P",color:"linear-gradient(140deg,#1b6dff,#0b46c4)",name:"Paddle",desc:"Also a merchant of record handling global tax compliance and invoicing. Built for software and subscriptions where you'd rather not track tax rules in dozens of countries."}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Vn,{size:15}),title:"Activate live payments",desc:"Test mode works right away, but before you can charge a real card Stripe has to verify your business: legal entity, a bank account to pay out to, and sometimes tax info. That review can take a day or two, so it's worth starting early — going live is not just flipping a switch."},{icon:e.jsx(zi,{size:15}),title:"Tell us what you're selling",desc:`A sentence in plain language, like "${t.entitySingular} ${t.purchaseNoun}s, $10 to $45."`},{icon:e.jsx(Jt,{size:15}),title:"CodeYam builds your checkout",desc:`A "Get ${t.purchaseNoun}s" button, a payment screen, and an emailed receipt — each one a plan you preview before it ships.`}]}}function p2(t){return{key:"payments",connector:{provider:"stripe"},Icon:Jt,title:"Accept payments",crumbLabel:"Payments",meta:"Foundation · about 10 minutes",leads:[{text:"Connect a real Stripe Sandbox so you can run the whole purchase flow against test cards."}],recommendLabel:"Recommended for your app",recommended:{...{initial:"S",color:"linear-gradient(140deg,#635bff,#4b45c6)",name:"Stripe"},bestFit:!0,description:"The payments tech behind millions of apps. Start in a Sandbox with test cards, go live once your business is activated.",reasons:[],chips:["Test cards","Sample products","No real money in Sandbox"]},alternatives:[],ctaLabel:"Set up payments with Stripe",ctaNote:"Nothing charges a real card in a Sandbox.",faq:[],flowLabels:["Connect","Provision","Ready"],connect:{heading:"Connect your Stripe Sandbox",sub:"Create or open a Sandbox in your Stripe Dashboard, then paste that Sandbox's restricted test key (rk_test_…).",grants:["Create sample test products and prices in the Sandbox","Read back the Sandbox so we can link you to it"],continueLabel:"Connect Stripe Sandbox",reassure:"We only accept a test key (rk_test_…). Live keys are rejected — live needs Stripe business activation first."},provisionTitle:"Setting up your Sandbox store",provisionDesc:`Creating sample ${t.purchaseNoun} products and prices in your Stripe Sandbox…`,provisionSteps:["Validating your Sandbox key","Creating sample products","Adding test prices"],ready:{title:"Your Stripe Sandbox is ready",desc:"Sample products and prices are set up. Open the Sandbox to see them and run a test purchase.",resultLabel:"Stripe sandbox",resultValue:"dashboard.stripe.com/test/products",donePill:"Payments connected in test mode"}}}function Xm(){const[t,n]=l.useState("test");return e.jsxs("div",{className:"su-modebar",children:[e.jsx("div",{className:"su-widget-ic",children:e.jsx(Wm,{size:16})}),e.jsxs("div",{className:"su-widget-body",children:[e.jsx("b",{children:t==="test"?"You're in test mode":"You're live"}),e.jsx("span",{children:t==="test"?"Use test cards to try the whole flow. No real money moves until you switch to live — and live needs Stripe to verify your business first (legal entity, bank account, sometimes tax info), which can take a day or two.":"Real cards are charged now. Every sale moves real money to your account."})]}),e.jsxs("div",{className:"su-seg",children:[e.jsx("button",{type:"button",className:t==="test"?"on":"",onClick:()=>n("test"),children:"Test"}),e.jsx("button",{type:"button",className:"live"+(t==="live"?" on":""),onClick:()=>n("live"),children:"Live"})]})]})}function Qm({app:t,account:n,onComplete:s}){const r=[{title:`A "Get ${t.purchaseNoun}s" button`,caption:`Added to each ${t.entitySingular} so people can buy in one tap.`,where:`/${t.entitySingular}`},{title:"A checkout screen",caption:"Card payment, Apple Pay, and Google Pay, hosted by Stripe.",where:"/checkout"},{title:`An emailed receipt & ${t.purchaseNoun}`,caption:`Stripe sends the card payment receipt automatically; CodeYam adds your own branded confirmation with the ${t.purchaseNoun} (this is the Sending-emails topic, not Stripe).`,where:"email"},{title:"A simple sales view",caption:"See what sold and refund with one click, in your dashboard.",where:"/sales"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(Jt,{size:25})}),e.jsxs("div",{children:[e.jsx("h1",{className:"su-title",children:"Accept payments"}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Stripe"})," · the payments tech behind millions of apps"]}),e.jsxs("p",{className:"su-lead",children:["Let people pay inside your app — buy a ",t.purchaseNoun,", leave a tip, subscribe. CodeYam handles the wiring; you just describe what you're selling and preview every screen before it goes live."]})]})]}),e.jsx(Xm,{}),e.jsxs(Jr,{children:[e.jsx(Ft,{state:"done",num:1,title:"Connect your Stripe account",pill:"Connected",desc:"CodeYam never sees your customers' card numbers — Stripe handles that part.",children:e.jsx(Hi,{monogram:n.monogram,name:n.name,detail:n.detail})}),e.jsx(Ft,{state:"done",num:2,title:"What are you selling?",desc:"Plain language is fine — this is what shapes the screens below.",children:e.jsxs(Xr,{children:[t.entitySingular," ",t.purchaseNoun,"s, one-off purchases from"," ",e.jsx("b",{children:"$10 to $45"}),". Buyers get a ",t.purchaseNoun," by email."]})}),e.jsx(Ft,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four small changes. Each becomes a plan you can preview, reorder, or drop before it ships.",children:e.jsx(Qr,{items:r})})]}),e.jsxs(Zr,{accent:"amber",icon:e.jsx(Ge,{size:17}),children:[e.jsx("b",{children:"Nothing charges a real card yet."})," These four changes build in test mode so you can click through the whole purchase. When it feels right, switch to live and your store is open."]}),e.jsx(ea,{label:"Plan these 4 changes",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, ready to build after your current session, and previewable before anything ships."]}),onPlan:s})]})}function Zm({onBack:t,onComplete:n,onRevert:s,app:r=Yr,initialConnected:a=!1,account:o=u2,connector:i}){const[c,d]=l.useState(a);let u;return i&&c?u=e.jsx(Gi,{config:p2(r),provider:i.provider,onBack:()=>d(!1),onComplete:n,onRevert:s}):c?u=e.jsx(Qm,{app:r,account:o,onComplete:n}):u=e.jsx(Kr,{config:h2(r),onConnect:()=>d(!0)}),e.jsxs("div",{className:"setup-screen accent-indigo",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Payments"})]}),e.jsx(ta,{topic:"payments"}),u]})}const Y8=Object.freeze(Object.defineProperty({__proto__:null,ModeBar:Xm,PaymentsConnected:Qm,PaymentsScreen:Zm},Symbol.toStringTag,{value:"Module"}));function ut({config:t,onBack:n,onComplete:s,status:r,onRevert:a}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(t.Icon,{size:26}),title:t.title,crumbLabel:t.crumbLabel,meta:t.meta,onBack:n,assistKey:t.key}),t.leads.map(o=>e.jsx("p",{className:"lead"+(o.dim?" dim":""),children:o.text},o.text)),t.sections.map(o=>e.jsxs("div",{children:[e.jsx("div",{className:"seclabel",children:o.heading}),o.body?e.jsx("p",{className:"lead dim",children:o.body}):null,o.bullets?e.jsx("div",{className:"reasons",children:o.bullets.map(i=>e.jsxs("div",{className:"reason",children:[e.jsx(Qe,{}),e.jsxs("span",{children:[i.lead?e.jsxs("b",{children:[i.lead," "]}):null,i.text]})]},i.text))}):null]},o.heading)),t.options&&t.options.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:t.optionsLabel??"Your options"}),t.options.map(o=>e.jsx(Ti,{provider:o},o.name))]}):null,e.jsx(ot,{items:t.faq}),e.jsx(ye,{assistKey:t.key,topicName:t.title}),e.jsx(we,{label:t.doneLabel,note:t.doneNote??"You can revisit this anytime.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const K8=Object.freeze(Object.defineProperty({__proto__:null,TeachSetupScreen:ut},Symbol.toStringTag,{value:"Module"})),m2={key:"analytics-monitoring",Icon:Tt,title:"Analytics & monitoring",crumbLabel:"Analytics",meta:"Recommended · about 10 minutes",leads:[{text:"Two different questions, two different tools. Analytics tells you what people do in your app — which pages they visit, where they drop off. Monitoring tells you when something breaks — the errors real users hit before they email you."},{text:"You don't need both on day one, but adding them early means you're never flying blind once people show up.",dim:!0}],sections:[{heading:"Analytics — understand usage",bullets:[{lead:"See what's used.",text:"Which features people actually open, and which they ignore."},{lead:"Find drop-off.",text:"Where people get stuck or leave, so you know what to fix."},{lead:"Privacy-first options exist.",text:"Lightweight analytics can skip cookies entirely and respect visitors."}]},{heading:"Monitoring — catch errors early",bullets:[{lead:"Know before they tell you.",text:"Get alerted when real users hit an error, with the details to fix it."},{lead:"See the full picture.",text:"What the user did, on what device, and the exact line that failed."}]}],optionsLabel:"Popular tools",options:[{initial:"P",color:"linear-gradient(140deg,#1d4ed8,#1e3a8a)",name:"PostHog",bestFit:!0,description:"Product analytics, session replay, and feature flags in one free-to-start tool. A great all-rounder for understanding usage.",reasons:[{lead:"Generous free tier.",rest:"Plenty for a new app's traffic."},{lead:"More than page views.",rest:"Funnels, replays, and flags when you're ready."},{lead:"Session replay is metered.",rest:"Its free quota of recordings is modest — fine for spot-checking, but it's billed past the cap, so leave always-on replay off until you need it."}],chips:["Analytics","Free tier","Privacy options"]},{initial:"S",color:"linear-gradient(140deg,#362d59,#1b1633)",name:"Sentry",description:"The standard for error monitoring. Catches exceptions with the context to reproduce and fix them fast.",reasons:[{lead:"Real-user errors.",rest:"See failures as they happen in production."},{lead:"Free to start.",rest:"A free tier that covers early traffic."}],chips:["Monitoring","Free tier","Alerts"]}],faq:[{q:"Do I need analytics AND monitoring?",a:"They answer different questions. Analytics is about behavior (what people do); monitoring is about health (what's breaking). Many apps add a lightweight analytics tool first, then error monitoring as traffic grows."},{q:"Will this slow my app down or hurt privacy?",a:"Modern tools are tiny and load in the background. Privacy-first analytics options avoid cookies and personal data entirely — a good default if you'd rather not show a consent banner."}],doneLabel:"Mark analytics & monitoring as set up"};function ef({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:m2,onBack:t,onComplete:n,status:s,onRevert:r})}const J8=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsMonitoringScreen:ef},Symbol.toStringTag,{value:"Module"})),f2={key:"legal",Icon:Be,title:"Privacy & legal",crumbLabel:"Legal",meta:"Recommended · about 20 minutes",leads:[{text:"Once real people use your app, a little legal groundwork protects both them and you. The good news: for most apps it's two short documents and a couple of small habits — not a lawyer on retainer."},{text:"This is guidance, not legal advice. If you handle sensitive data or money at scale, it's worth a professional review.",dim:!0}],sections:[{heading:"The two documents most apps need",bullets:[{lead:"Privacy policy —",text:"what information you collect, why, and what you do with it. Required the moment you collect emails or use analytics."},{lead:"Terms of service —",text:"the rules for using your app: what's allowed, what you promise, and what you don't. It sets expectations and limits your liability."}]},{heading:"Good habits that matter",bullets:[{lead:"Collect only what you need.",text:"Less data means less risk and a simpler policy."},{lead:"Say it in plain language.",text:"A clear, honest policy beats dense legalese for trust and compliance."},{lead:"Add a cookie/consent notice",text:"if you use analytics or tracking, especially for visitors in the EU. You can often skip the banner entirely by picking a cookieless analytics tool — see Analytics & monitoring."},{lead:"Honor data requests.",text:"Under GDPR and CCPA, people can ask to see, export, or delete the data you hold on them. Keep a simple way to remove an account and its data — this is where Accounts, Payments, and your database meet."}]},{heading:"Getting the documents",body:"You don't have to write these from scratch. Generators produce a solid starting policy from a short questionnaire — but check what's actually free. GetTerms and privacypolicies.com have genuinely free basic tiers; Termly and iubenda are freemium and gate some clauses (or removal of their attribution) behind a paid plan. Paste the result into a /privacy and /terms page and link them in your footer."}],faq:[{q:"Do I really need this for a small app?",a:"If you collect any personal data — even just email sign-ups or analytics — a privacy policy is expected and often legally required. Terms are optional but strongly recommended once people rely on your app."},{q:"Where do the pages go?",a:"Add two simple pages, usually /privacy and /terms, and link them from your footer and your sign-up screen. They don't need fancy design — clarity is what counts."}],doneLabel:"Mark privacy & legal as handled"};function tf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:f2,onBack:t,onComplete:n,status:s,onRevert:r})}const X8=Object.freeze(Object.defineProperty({__proto__:null,LegalScreen:tf},Symbol.toStringTag,{value:"Module"}));function nf({config:t,onBack:n,onSetup:s}){return e.jsxs(e.Fragment,{children:[e.jsx(pe,{icon:e.jsx(t.Icon,{size:26}),title:t.title,crumbLabel:t.crumbLabel,meta:t.meta,onBack:n,assistKey:t.key}),t.leads.map(r=>e.jsx("p",{className:"lead"+(r.dim?" dim":""),children:r.text},r.text)),e.jsx("div",{className:"seclabel",children:t.recommendLabel}),e.jsx(Ti,{provider:t.recommended}),e.jsx(Kp,{alts:t.alternatives}),e.jsxs("div",{className:"cta-wrap",children:[e.jsx("button",{type:"button",className:"cta",onClick:s,children:t.ctaLabel}),e.jsx("div",{className:"cta-note",children:t.ctaNote})]}),e.jsx(ot,{items:t.faq}),e.jsx(ye,{assistKey:t.key,topicName:t.title})]})}const Q8=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupOverview:nf},Symbol.toStringTag,{value:"Module"})),Ec=1100,g2=700;function Ui(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function sf({config:t,onBack:n,onContinue:s}){return e.jsxs(e.Fragment,{children:[e.jsx(an,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:n}),e.jsx(Yt,{steps:Ui(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:t.connect.heading}),e.jsx("div",{className:"psub",children:t.connect.sub}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(qr,{initial:t.recommended.initial,color:t.recommended.color}),e.jsxs("div",{children:[e.jsxs("div",{className:"cbt",children:["Sign in with ",t.recommended.name]}),e.jsxs("div",{className:"cbd",children:["We'll open ",t.recommended.name," in a new tab and bring you right back."]})]})]}),e.jsx("div",{className:"grant",children:t.connect.grants.map(r=>e.jsxs("div",{className:"grantrow",children:[e.jsx(Qe,{color:"var(--blue-300)"}),e.jsx("span",{children:r})]},r))}),e.jsx("button",{type:"button",className:"auth-btn",onClick:s,children:t.connect.continueLabel}),e.jsxs("div",{className:"auth-row",children:[e.jsx("button",{type:"button",className:"auth-ghost",onClick:s,children:"I already have an account"}),e.jsx("button",{type:"button",className:"auth-ghost",onClick:s,children:"Create one for me"})]})]}),e.jsxs("div",{className:"reassure",children:["🔒 ",t.connect.reassure]})]})]})}function rf({config:t,onDone:n}){const s=t.provisionSteps,[r,a]=l.useState(0),o=l.useRef(n);o.current=n,l.useEffect(()=>{const c=[];for(let d=1;d<=s.length;d++)c.push(setTimeout(()=>a(d),d*Ec));return c.push(setTimeout(()=>o.current(),s.length*Ec+g2)),()=>c.forEach(clearTimeout)},[s.length]);const i=Math.round(r/s.length*100);return e.jsxs(e.Fragment,{children:[e.jsx(an,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(Yt,{steps:Ui(t),currentKey:"provision"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:t.provisionTitle}),e.jsx("div",{className:"deploy-d",children:t.provisionDesc})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{style:{width:i+"%"}})}),e.jsx("div",{className:"dep-steps",children:s.map((c,d)=>e.jsxs("div",{className:"dep-step "+(d<r?"done":d===r?"active":"todo"),children:[e.jsx("div",{className:"dot",children:d<r?e.jsx(Qe,{size:12,color:"#0a0a0a"}):null}),e.jsx("div",{className:"sl",children:c})]},c))})]})]})}function af({config:t,onFinish:n,onRevert:s}){return e.jsxs(e.Fragment,{children:[e.jsx(an,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(Yt,{steps:Ui(t),currentKey:"ready"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:t.ready.title}),e.jsx("div",{className:"lh-d",children:t.ready.desc})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:t.ready.resultLabel}),e.jsx("div",{className:"uc-u",children:t.ready.resultValue})]})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx(Qe,{})," ",t.ready.donePill]}),e.jsx("button",{type:"button",className:"lf-back",onClick:n,children:"Back to Setup"}),s?e.jsx("button",{type:"button",className:"lf-revert",onClick:s,children:"Mark as not complete"}):null]})]})]})}const Z8=Object.freeze(Object.defineProperty({__proto__:null,SimulatedConnect:sf,SimulatedProvision:rf,SimulatedReady:af},Symbol.toStringTag,{value:"Module"}));function As({config:t,onBack:n,onComplete:s,onRevert:r}){const[a,o]=l.useState("overview");let i;return a==="overview"?i=e.jsx(nf,{config:t,onBack:n,onSetup:()=>o("connect")}):t.connector?i=e.jsx(Gi,{config:t,provider:t.connector.provider,onBack:()=>o("overview"),onComplete:()=>{s==null||s(),n()},onRevert:r?()=>{r(),n()}:void 0}):a==="connect"?i=e.jsx(sf,{config:t,onBack:()=>o("overview"),onContinue:()=>o("provision")}):a==="provision"?i=e.jsx(rf,{config:t,onDone:()=>o("ready")}):i=e.jsx(af,{config:t,onFinish:()=>{s==null||s(),n()},onRevert:r?()=>{r(),n()}:void 0}),e.jsx("div",{className:"hosting-screen",children:i})}const eL=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupScreen:As},Symbol.toStringTag,{value:"Module"})),b2={key:"publish",Icon:Tn,title:"Publish the site",crumbLabel:"Publish",meta:"Foundation · about 10 minutes",leads:[{text:"Your site is a set of files that, right now, live on your computer. Publishing builds those files and copies them to the internet, so anyone with the link can open your pages."},{text:"Static sites are perfect for this — there's no server to run, just files served fast from everywhere. Hosting them is usually free.",dim:!0}],recommendLabel:"Recommended for your site",recommended:{initial:"C",color:"linear-gradient(140deg,#f6821f,#c25e0a)",name:"Cloudflare Pages",bestFit:!0,description:"Built for static sites: connect once, and every change you push is built and published automatically. Free with no bandwidth ceiling.",reasons:[{lead:"Free, with no traffic ceiling.",rest:`${xe("cloudflarePages.free").value}, so a sudden traffic spike won't cost you.`},{lead:"Auto-publish on every change.",rest:"Push an update and it rebuilds and goes live on its own."},{lead:"Fast everywhere.",rest:"Your pages are served from Cloudflare's global network, close to your visitors."}],chips:["Free tier","Unlimited bandwidth","Global CDN"]},alternatives:[{initial:"N",color:"linear-gradient(140deg,#16a3a3,#0d6e6e)",name:"Netlify",description:`Also built for static sites with automatic publishing. ${xe("netlify.free").value} — plenty for a personal or small site.`},{initial:"V",color:"linear-gradient(140deg,#0a0a0a,#000)",name:"Vercel",description:"Also free and excellent for static sites, especially if you later add dynamic pages. Very similar to set up."},{initial:"G",color:"linear-gradient(140deg,#24292f,#0d1117)",name:"GitHub Pages",description:"Free hosting straight from a GitHub repo. Great if your code already lives there and your needs are simple — but it has no built-in form handling and a stricter build environment."}],ctaLabel:"☁️ Publish with Cloudflare Pages",ctaNote:"We'll publish this site only. Nothing goes live until the build finishes.",faq:[{q:'What does "building" the site mean?',a:"Building turns your source files into the finished pages a browser shows — combining templates, optimizing images, and bundling styles. The host does this for you each time you publish."},{q:"Do I have to republish every time I change something?",a:"No. Once connected, the host watches for changes and republishes automatically. You make an edit, and a minute later it's live."},{q:"Is it really free?",a:`For a typical static site, yes. Cloudflare Pages: ${xe("cloudflarePages.free").value.toLowerCase()}, so traffic spikes won't cost you. Netlify's free tier: ${xe("netlify.free").value.toLowerCase()}. You'd only pay if you needed advanced features.`}],flowLabels:["Connect","Build","Live"],connect:{heading:"🔗 Connect your Cloudflare account",sub:"This free account hosts your live site. You'll create it in a few clicks if you don't have one.",grants:["Publish this one site","Rebuild it when you make changes","Nothing else — your other sites stay untouched"],continueLabel:"Continue with Cloudflare",reassure:"We only publish this site. You can unpublish or disconnect anytime."},provisionTitle:"Building and publishing…",provisionDesc:"This usually takes under a minute. You can keep working — we'll let you know.",provisionSteps:["Building your pages","Optimizing images and styles","Uploading to the network","Giving it a web address"],ready:{title:"Your site is live",desc:"Anyone with this link can open your site right now.",resultLabel:"Your link",resultValue:"your-site.pages.dev",donePill:"Publishing is now set up"}};function of({onBack:t,onComplete:n,onRevert:s}){return e.jsx(As,{config:b2,onBack:t,onComplete:n,onRevert:s})}const tL=Object.freeze(Object.defineProperty({__proto__:null,PublishScreen:of},Symbol.toStringTag,{value:"Module"})),x2={key:"custom-domain",Icon:ln,title:"Custom domain",crumbLabel:"Domain",meta:"Optional · about 15 minutes",leads:[{text:"Right now your site lives at a free address like your-site.netlify.app. A custom domain swaps that for your own — yourname.com — which looks more professional and is easier to remember."},{text:"You buy a domain once a year, then point it at your site. We'll handle the technical part (DNS) and turn on the padlock (HTTPS) for you.",dim:!0}],recommendLabel:"Recommended registrar",recommended:{initial:"C",color:"linear-gradient(140deg,#f6821f,#c25e0a)",name:"Cloudflare Registrar",bestFit:!0,description:"Buy your domain at cost with no markup, with DNS that's fast and easy to point at your site.",reasons:[{lead:"At-cost pricing.",rest:"No upsells or inflated renewal fees — you pay what the domain costs."},{lead:"Easy to point at your site.",rest:"A couple of records and your domain shows your pages."},{lead:"Free HTTPS.",rest:"The padlock that tells visitors your site is secure, set up for you."}],chips:["At-cost","Free HTTPS","~15 min to set up"]},alternatives:[{initial:"N",color:"linear-gradient(140deg,#1a1a1a,#000)",name:"Namecheap",description:"A popular, affordable registrar with a friendly dashboard. A solid alternative if you prefer it."},{initial:"P",color:"linear-gradient(140deg,#00a98f,#007a68)",name:"Porkbun",description:"Low prices and free extras like WHOIS privacy. Great value for a personal site."}],ctaLabel:"🌐 Set up a custom domain",ctaNote:"We'll guide you through buying and connecting your domain.",faq:[{q:"What is DNS?",a:`DNS is the internet's address book. It maps your domain name (yourname.com) to where your site actually lives. "Pointing" your domain means adding a couple of records so the address book sends visitors to your pages. You'll usually set up both the root (yourname.com, via an A or ALIAS record) and the www version (www.yourname.com, via a CNAME) — most registrars cover both in a couple of clicks.`},{q:"What is HTTPS / the padlock?",a:"HTTPS encrypts the connection between your visitors and your site, and shows a padlock in the browser. It's expected today, and your host turns it on automatically once your domain is connected."},{q:"How much does a domain cost?",a:"Most common domains run roughly $10–15 per year. You renew yearly to keep it. Some endings (.io, .ai) cost more; a plain .com is usually the safe, affordable pick."}],flowLabels:["Choose","Connect","Live"],connect:{heading:"🔗 Point your domain at your site",sub:"We'll add the DNS records that connect your new domain to your published site, then turn on HTTPS.",grants:["Add records that point this domain at your site","Request a free HTTPS certificate","Nothing else — we won't change your other domains"],continueLabel:"Connect my domain",reassure:"You own the domain. We only add the records needed to show your site."},provisionTitle:"Connecting your domain…",provisionDesc:"DNS can take a few minutes to spread, but usually it's quick. We'll let you know.",provisionSteps:["Adding your DNS records","Waiting for them to take effect","Issuing your HTTPS certificate","Pointing the domain at your site"],ready:{title:"Your domain is live",desc:"Your site now opens at your own secure web address.",resultLabel:"Your address",resultValue:"https://your-name.com",donePill:"Custom domain is now set up"}};function lf({onBack:t,onComplete:n,onRevert:s}){return e.jsx(As,{config:x2,onBack:t,onComplete:n,onRevert:s})}const nL=Object.freeze(Object.defineProperty({__proto__:null,CustomDomainScreen:lf},Symbol.toStringTag,{value:"Module"})),y2={key:"data-safety",Icon:Os,title:"Data backups & deletion",crumbLabel:"Data safety",meta:"Recommended · about 15 minutes",leads:[{text:"Once real people trust your app with their data, two responsibilities follow: keep it safe so a bad day doesn't lose it, and give people control over it. Both are small, one-time habits — not a second job."},{text:"This is guidance, not legal advice. If you handle sensitive data or operate at scale, a professional review is worth it.",dim:!0}],sections:[{heading:"Back up your data",bullets:[{lead:"Turn on automated backups.",text:"Most managed databases take daily snapshots on paid tiers — switch them on and confirm the retention window. A backup you've never restored is a guess, so test a restore once."},{lead:"Mind the free tier.",text:"Free database tiers often pause or expire after inactivity and may not back up at all. If real users depend on the data, that's the signal to move to a paid plan."},{lead:"Keep a copy you control.",text:"An occasional export you store yourself protects you even if the provider's account or project goes away."}]},{heading:"Honor delete & export requests",body:"Under GDPR and CCPA, people can ask to see, export, or permanently delete the data you hold on them — and you're expected to be able to do it. This is where Accounts, Payments, and your database meet.",bullets:[{lead:"Make deletion possible.",text:"Have one reliable way to remove an account and the records tied to it — orders, profile, analytics identifiers. Remember backups and third-party tools (email, payments) hold copies too."},{lead:"Make export easy.",text:"Be able to hand someone a copy of their data in a common format. A simple admin action or even a manual query is enough to start."},{lead:"Write down your retention.",text:"Decide how long you keep data and say so in your privacy policy — see Privacy & legal."}]}],faq:[{q:"Isn't my database already backed up?",a:"Don't assume so. Paid tiers usually offer daily snapshots but they're often off by default; free tiers frequently have none and can pause. Check the dashboard and turn backups on explicitly."},{q:"Do small apps really get deletion requests?",a:"It only takes one. The obligation applies the moment you store personal data, so it's far easier to build a simple delete-and-export path early than to scramble when the first request arrives."}],doneLabel:"Mark data backups & deletion as handled"};function cf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:y2,onBack:t,onComplete:n,status:s,onRevert:r})}const sL=Object.freeze(Object.defineProperty({__proto__:null,DataSafetyScreen:cf},Symbol.toStringTag,{value:"Module"})),v2={key:"forms",Icon:Jn,title:"Contact & forms",crumbLabel:"Forms",meta:"Optional · about 10 minutes",leads:[{text:"A static site has no server to receive a contact form, so the form needs somewhere to send messages. A form service catches submissions and emails them to you — no backend required."},{text:"You keep your simple, fast static site and still hear from visitors. Most services are free for the volume a small site sees.",dim:!0}],recommendLabel:"Recommended for your site",recommended:{initial:"F",color:"linear-gradient(140deg,#e5422b,#b02f1d)",name:"Formspree",bestFit:!0,description:"Point your form at a Formspree address and submissions arrive in your inbox. The simplest way to add a contact form.",reasons:[{lead:"No backend to build.",rest:"Your existing HTML form just works — only the destination changes."},{lead:"Spam filtering included.",rest:"Built-in protection so you're not flooded with junk."},{lead:"Free to start.",rest:"A monthly free allowance that suits a small site."}],chips:["Free tier","No backend","Spam protection"]},alternatives:[{initial:"N",color:"linear-gradient(140deg,#16a3a3,#0d6e6e)",name:"Netlify Forms",description:`Built in if you publish with Netlify — add one attribute to your form and you're done. Great if you're already there, though its free tier caps submissions at ${xe("netlifyForms.free").value}.`},{initial:"W",color:"linear-gradient(140deg,#7c3aed,#5b21b6)",name:"Web3Forms",description:"A fully free, no-account form endpoint — paste an access key and submissions email straight to you. Good when you want zero cost and no dashboard."},{initial:"B",color:"linear-gradient(140deg,#3b82f6,#1d4ed8)",name:"Basin",description:"A privacy-friendly form backend with a clean dashboard. A solid alternative to Formspree."}],ctaLabel:"✉️ Set up forms with Formspree",ctaNote:"We'll connect your contact form only. Messages go straight to you.",faq:[{q:"How can a static site receive form submissions?",a:"The form posts to the service's address instead of a server you run. The service receives the message, screens it for spam, and forwards it to your email. Your site stays a set of static files."},{q:"Will I get spam?",a:"Far less than you'd fear. These services include spam filtering and a honeypot, and you can add a captcha if needed. Most junk is stopped before it reaches you."},{q:"Where do the messages go?",a:"To whatever email you choose. You can also forward them to a spreadsheet or a tool like Slack if you'd rather not use your inbox."}],flowLabels:["Connect","Verify","Ready"],connect:{heading:"🔗 Connect your Formspree account",sub:"This free account catches your form submissions. You'll create it in a few clicks if you don't have one.",grants:["Receive submissions from this site's form","Forward them to your email","Nothing else — no access to the rest of your site"],continueLabel:"Continue with Formspree",reassure:"We only connect this one form. You can disconnect it anytime."},provisionTitle:"Setting up your form…",provisionDesc:"This takes under a minute. We'll bring you right back.",provisionSteps:["Creating your form endpoint","Turning on spam protection","Pointing your contact form at it","Sending a test message"],ready:{title:"Your form is ready",desc:"Visitors can now message you, and submissions land in your inbox.",resultLabel:"Submissions go to",resultValue:"you@your-name.com",donePill:"Contact & forms are now set up"}};function df({onBack:t,onComplete:n,onRevert:s}){return e.jsx(As,{config:v2,onBack:t,onComplete:n,onRevert:s})}const rL=Object.freeze(Object.defineProperty({__proto__:null,FormsScreen:df},Symbol.toStringTag,{value:"Module"})),j2={key:"analytics-seo",Icon:Tt,title:"Analytics & SEO",crumbLabel:"Analytics & SEO",meta:"Recommended · about 15 minutes",leads:[{text:"Two jobs that help people find and understand your site. Analytics tells you who's visiting and what they read. SEO — search engine optimization — helps your pages show up when someone searches for what you offer."},{text:"For a static site, most of this is a handful of one-time additions to your pages. Do them once and they keep working.",dim:!0}],sections:[{heading:"SEO — get found in search",bullets:[{lead:"Page titles and descriptions.",text:"Give each page a clear <title> and meta description — this is what shows in search results."},{lead:"A sitemap.",text:"A simple sitemap.xml lists your pages so search engines can find them all."},{lead:"Social cards.",text:"Open Graph tags make your links look great when shared on social media, with a title, image, and summary."},{lead:"Submit to Search Console.",text:"Tell Google your site exists and see which searches bring people in."}]},{heading:"Analytics — know your visitors",bullets:[{lead:"Count visits, respect privacy.",text:"A lightweight analytics script shows traffic without cookies or personal data."},{lead:"See what resonates.",text:"Which pages people read, where they come from, and what they ignore."}]}],optionsLabel:"Privacy-friendly analytics",options:[{initial:"C",color:"linear-gradient(140deg,#f6821f,#c25e0a)",name:"Cloudflare Web Analytics",bestFit:!0,description:"Free, cookie-free visitor analytics you can turn on without paying for a service. No consent banner, no personal data.",reasons:[{lead:"Genuinely free.",rest:"No trial clock — the core visitor analytics are free to use."},{lead:"Cookie-free.",rest:"Privacy-friendly by default, so no consent popup."}],chips:["Free","Cookie-free","No banner"]},{initial:"P",color:"linear-gradient(140deg,#5850ec,#3730a3)",name:"Plausible",description:"A tiny, cookie-free analytics script with a single clear dashboard. Paid after a free trial.",reasons:[{lead:"No cookies.",rest:"Privacy-friendly by default, so no annoying consent popup."},{lead:"Paid after a trial.",rest:"Free to try, then a monthly subscription — worth it for the polished dashboard."}],chips:["Cookie-free","Lightweight","Paid after trial"]},{initial:"F",color:"linear-gradient(140deg,#f59e0b,#b45309)",name:"Fathom",description:"Another privacy-first, fast analytics option with a clean dashboard. Paid after a free trial, like Plausible.",reasons:[{lead:"Privacy-first.",rest:"No personal data collected."},{lead:"Paid after a trial.",rest:"Free to try, then a flat monthly fee."}],chips:["Privacy-first","Fast","Paid after trial"]}],faq:[{q:"What's the single most important SEO step?",a:"Clear, unique page titles and descriptions. They're what search engines and people read first. After that, a sitemap and submitting to Google Search Console make the biggest difference."},{q:"Do I need analytics that uses cookies?",a:"No. Cookie-free tools count visits without cookies or personal data, so you get the insight without a consent banner or privacy headaches. Cloudflare Web Analytics is free; Plausible and Fathom are paid after a trial but add a more polished dashboard."}],doneLabel:"Mark analytics & SEO as set up"};function uf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:j2,onBack:t,onComplete:n,status:s,onRevert:r})}const aL=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsSeoScreen:uf},Symbol.toStringTag,{value:"Module"})),w2={key:"redirects-404",Icon:ln,title:"Redirects & 404 page",crumbLabel:"Redirects & 404",meta:"Recommended · about 10 minutes",leads:[{text:"A static site serves files exactly as they're named, so a visitor who mistypes a URL or follows an old link hits a blank, unstyled error. A custom 404 page and a few redirect rules keep people on your site instead of bouncing."},{text:"These are one-time files you add to your project. Your host reads them at deploy and applies them to every request — nothing runs at request time.",dim:!0}],sections:[{heading:"A custom 404 page",bullets:[{lead:"Make the dead end friendly.",text:"Add a 404.html (Netlify, GitHub Pages) or a 404 route (most generators) with your site's header, a search box or link home, and a clear 'page not found' message."},{lead:"Match your brand.",text:"The default host error page looks broken. A styled 404 reassures visitors the site is fine — they just took a wrong turn."}]},{heading:"Redirects — don't break old links",bullets:[{lead:"Keep old URLs working.",text:"When you rename or move a page, add a redirect from the old path to the new one so bookmarks and search results still land somewhere useful."},{lead:"One rules file.",text:"A _redirects file (Netlify/Cloudflare Pages) or a netlify.toml / vercel.json block lists each from → to rule. A permanent move uses a 301 so search engines update."}]},{heading:"Trailing slashes & headers",bullets:[{lead:"Pick one URL shape.",text:"Decide whether pages live at /about or /about/ and redirect the other form to it — serving both splits your SEO and confuses analytics."},{lead:"Custom headers (optional).",text:"A _headers file lets you set caching and security headers per path without a server — useful once the basics are in place."}]}],faq:[{q:"Why doesn't my custom 404 show up?",a:"Each host has its own convention for the not-found file — a 404.html at the site root for GitHub Pages and Netlify, a 404 page/route for most generators. If yours isn't appearing, check your host's docs for the exact filename and location it expects."},{q:"When should a redirect be permanent (301) vs temporary (302)?",a:"Use a permanent 301 when a page has truly moved for good — search engines then transfer the old page's ranking to the new URL. Use a temporary 302 for short-lived redirects, like pointing to a promo page for a week."},{q:"Do I have to choose trailing slash or no trailing slash?",a:"It's worth deciding once. Serving the same page at both /about and /about/ means search engines may treat them as duplicates. Pick one and redirect the other — your generator usually has a single setting for this."}],doneLabel:"Mark redirects & 404 as set up"};function hf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:w2,onBack:t,onComplete:n,status:s,onRevert:r})}const oL=Object.freeze(Object.defineProperty({__proto__:null,RedirectsNotFoundScreen:hf},Symbol.toStringTag,{value:"Module"})),_2={key:"performance-images",Icon:Xe,title:"Performance & images",crumbLabel:"Performance",meta:"Recommended · about 15 minutes",leads:[{text:"A static site is already fast to serve, so its speed comes down to weight — and images are almost always the heaviest thing on the page. Get images right and most performance worries disappear."},{text:"Most of this is set up once: a build step that optimizes images and a host that caches them. After that every new page benefits automatically.",dim:!0}],sections:[{heading:"Images — the biggest win",bullets:[{lead:"Use modern formats.",text:"Serve WebP or AVIF instead of JPEG/PNG — often half the size at the same quality. Most generators have an image component or plugin that does this at build time."},{lead:"Size them to fit.",text:"Don't ship a 4000px photo into a 600px slot. Generate a few sizes and let the browser pick with srcset, so phones download a small version."},{lead:"Lazy-load below the fold.",text:`Add loading="lazy" to images that aren't visible on first paint so the page becomes interactive before they all download.`}]},{heading:"Caching & delivery",bullets:[{lead:"Let the CDN do the work.",text:"Static hosts like Netlify, Vercel, and Cloudflare Pages serve your files from a global edge network, so visitors download from a server near them."},{lead:"Cache static assets hard.",text:"Fingerprinted files (style.abc123.css) can be cached for a year — set long cache headers so repeat visits load instantly. Your generator usually fingerprints automatically."}]},{heading:"Check your work",bullets:[{lead:"Measure, don't guess.",text:"Run Lighthouse (built into Chrome DevTools) or PageSpeed Insights to see your real numbers and the few changes that would help most."}]}],faq:[{q:"What's the single biggest speed win for a static site?",a:"Optimizing images — converting to WebP/AVIF, sizing them for where they're shown, and lazy-loading the ones below the fold. Images are usually the heaviest part of a page, so this moves the needle more than anything else."},{q:"Do I need a separate CDN?",a:"Usually not. The major static hosts — Netlify, Vercel, Cloudflare Pages, GitHub Pages — already serve your site from a global edge network. A separate CDN only helps if you're hosting the files yourself on a single server."},{q:"How do I know if my site is fast enough?",a:"Run Lighthouse in Chrome DevTools or paste your URL into PageSpeed Insights. Both give you a score plus a prioritized list of fixes. Aim for the green range; chasing a perfect 100 rarely matters for visitors."}],doneLabel:"Mark performance & images as set up"};function pf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:_2,onBack:t,onComplete:n,status:s,onRevert:r})}const iL=Object.freeze(Object.defineProperty({__proto__:null,PerformanceImagesScreen:pf},Symbol.toStringTag,{value:"Module"})),k2={key:"comments-search",Icon:Be,title:"Comments & search",crumbLabel:"Comments & search",meta:"Optional · about 15 minutes",leads:[{text:"A static site has no server, but it can still feel interactive. A comments widget lets readers reply without you running anything, and a client-side search index lets them find pages instantly — both work as a drop-in script."},{text:"Neither needs a backend or a database. The comments live in a third-party service or your GitHub Discussions; the search index is built from your pages at deploy time.",dim:!0}],sections:[{heading:"Comments without a backend",bullets:[{lead:"A widget does the work.",text:"Drop a small script into your post template. The service stores and renders the thread; your page just hosts it."},{lead:"Decide who can post.",text:"GitHub-based options (Giscus, Utterances) ask readers to sign in with GitHub — great for a dev audience, less so for a general one. Hosted services accept anyone."}]},{heading:"Search across your pages",bullets:[{lead:"Build the index at deploy.",text:"A tool like Pagefind crawls your built HTML and produces a small static index. The search box loads it in the browser — no server query, no API."},{lead:"Keep it lightweight.",text:"Client-side search only loads the slice of the index it needs, so even a large site stays fast. For a huge catalog, a hosted search service is the next step up."}]}],optionsLabel:"Comment widgets",options:[{initial:"G",color:"linear-gradient(140deg,#6e40c9,#4c2889)",name:"Giscus",bestFit:!0,description:"Comments backed by your repo's GitHub Discussions — free, open-source, no ads, and no separate account to manage. Readers sign in with GitHub.",reasons:[{lead:"No service to pay for.",rest:"The threads live in your own GitHub Discussions, so there's no subscription and nothing to host."},{lead:"Privacy-friendly.",rest:"No tracking or ads — a clean fit for a personal or project site."}],chips:["Free","Open-source","GitHub login"]},{initial:"D",color:"linear-gradient(140deg,#2e9fff,#1f6fd0)",name:"Disqus",description:"The best-known hosted comments widget. Anyone can post and it's quick to add, but the free tier shows ads and loads more script.",reasons:[{lead:"Anyone can comment.",rest:"No GitHub account needed, so it suits a general audience."},{lead:"Ads on the free tier.",rest:"Removing ads and tracking means upgrading to a paid plan."}],chips:["Hosted","Open to all","Ads on free tier"]},{initial:"U",color:"linear-gradient(140deg,#24292f,#57606a)",name:"Utterances",description:"A tiny widget that stores each thread as a GitHub Issue. Even simpler than Giscus, though Discussions (Giscus) is the more modern home for comments.",reasons:[{lead:"Featherweight.",rest:"One script, threads stored as GitHub Issues."},{lead:"GitHub login.",rest:"Readers comment with their GitHub account."}],chips:["Free","Open-source","GitHub login"]}],faq:[{q:"How can a static site have comments with no backend?",a:"The comments aren't stored on your site — a third-party widget stores and renders them. Your page embeds a small script that talks to the service (or to your GitHub Discussions). Your site stays a set of static files."},{q:"Does search really work without a server?",a:"Yes. A tool like Pagefind builds a static search index from your pages when you deploy. The search box downloads just the part of the index it needs and runs the query in the browser — no server or API call."},{q:"Should I require GitHub sign-in to comment?",a:"It depends on your audience. For a developer or project site, GitHub-based comments (Giscus, Utterances) cut spam to near zero. For a general audience, a hosted widget that lets anyone post will get more participation."}],doneLabel:"Mark comments & search as set up"};function mf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:k2,onBack:t,onComplete:n,status:s,onRevert:r})}const lL=Object.freeze(Object.defineProperty({__proto__:null,CommentsSearchScreen:mf},Symbol.toStringTag,{value:"Module"})),Bn={crates:{kind:"crates",name:"crates.io",ecosystem:"Rust",publishCommand:"cargo publish",installCommand:"cargo add <name>",packagePage:"https://crates.io/crates/<name>"},npm:{kind:"npm",name:"npm",ecosystem:"Node.js",publishCommand:"npm publish",installCommand:"npm install <name>",packagePage:"https://www.npmjs.com/package/<name>"},pypi:{kind:"pypi",name:"PyPI",ecosystem:"Python",publishCommand:"python -m build && python -m twine upload dist/*",installCommand:"pip install <name>",packagePage:"https://pypi.org/project/<name>",note:"twine only uploads — `python -m build` has to produce the dist/ artifacts first. `uv build` then `uv publish` is the modern single-toolchain alternative."},rubygems:{kind:"rubygems",name:"RubyGems",ecosystem:"Ruby",publishCommand:"gem push <name>-<version>.gem",installCommand:"gem install <name>",packagePage:"https://rubygems.org/gems/<name>",note:"`gem build <name>.gemspec` packages the .gem first; `gem push` uploads it."},homebrew:{kind:"homebrew",name:"Homebrew",ecosystem:"macOS / Linux CLI",publishCommand:"open a formula PR to your tap (later: brew bump-formula-pr)",installCommand:"brew install <name>",packagePage:"https://formulae.brew.sh/formula/<name>",note:"Homebrew distributes binaries — it isn't a peer package registry. The initial release is a formula in your own tap repo (or a PR to homebrew-core); `brew bump-formula-pr` only bumps a formula that already exists."}},S2=[Bn.crates,Bn.npm,Bn.pypi,Bn.rubygems,Bn.homebrew];function ff(t){return Bn[t]}function gf({registry:t,onBack:n,onComplete:s,status:r,onRevert:a}){const o=t?ff(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(mt,{size:26}),title:"Publish to a registry",meta:"Foundation · about 20 minutes",onBack:n,assistKey:"publish-registry"}),e.jsxs("p",{className:"lead",children:["This kind of project doesn't go live at a web address — it ships to a"," ",e.jsx("b",{children:"package registry"}),", where people install it with a single command or add it as a dependency. Publishing is how your work reaches its users."]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"seclabel",children:["Your registry: ",o.name," (",o.ecosystem,")"]}),e.jsxs(he,{children:[e.jsxs(A,{lead:`Publish with \`${o.publishCommand}\`.`,children:["From a clean, committed working tree, this packages the release and uploads it to ",o.name,". Get an account and an API token first.",o.note?e.jsxs(e.Fragment,{children:[" ",o.note]}):null]}),e.jsx(A,{lead:`Users then run \`${o.installCommand}\`.`,children:"Once published, anyone can install your package with one command — no clone, no build from source."}),e.jsxs(A,{lead:"Your package gets a public page.",children:[o.name," hosts a page at"," ",e.jsx("code",{children:o.packagePage})," — the link you share so people can find, install, and trust the package."]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Before your first publish"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Claim the name before someone else does.",children:["The package name is first-come, first-served and is your public identity — squatting is common on crates.io and PyPI. If the bare name is taken (or to protect a brand), publish under a namespace: an npm scope (",e.jsx("code",{children:"@you/tool"}),") or an org account."]}),e.jsxs(A,{lead:"Turn on two-factor auth — registries expect it.",children:[xe("registry.twoFactor").value,"."," ",e.jsx(un,{fact:xe("registry.twoFactor")})," A token alone often isn't enough; set up 2FA before the release deadline, not during it."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:o.publishCommand}),e.jsx("span",{className:"chip",children:"Tokened account"}),e.jsx("span",{className:"chip",children:"Public package page"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:"Pick your registry"}),e.jsx(he,{children:S2.map(i=>e.jsxs(A,{lead:`${i.name} — ${i.ecosystem}.`,children:["Publish with ",e.jsx("code",{children:i.publishCommand}),"; users install with"," ",e.jsx("code",{children:i.installCommand}),".",i.note?e.jsxs(e.Fragment,{children:[" ",i.note]}):null]},i.kind))}),e.jsx("div",{className:"asknote",style:{marginTop:14},children:"Every registry follows the same shape: an account with an API token, one publish command, and a public package page you share. Match the registry to your toolchain."})]}),e.jsx(ye,{assistKey:"publish-registry",topicName:"Publish to a registry"}),e.jsx(we,{label:"My package is published",note:"You can publish new versions anytime, but you can never re-publish a version once it's released — crates.io is yank-only (the release stays, just hidden from new resolves), and PyPI can delete a release but can never reuse that version number or filename. Get the first one right.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const cL=Object.freeze(Object.defineProperty({__proto__:null,PublishRegistryScreen:gf},Symbol.toStringTag,{value:"Module"}));function bf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"Versioning & changelog",meta:"About 20 minutes",onBack:t,assistKey:"versioning-changelog"}),e.jsxs("p",{className:"lead",children:["A version number is a promise. ",e.jsx("b",{children:"Semantic versioning"})," (MAJOR.MINOR.PATCH) lets people upgrade with confidence: a patch is safe, a minor adds features, a major may break them."]}),e.jsx("div",{className:"seclabel",children:"The three numbers"}),e.jsxs(he,{children:[e.jsx(A,{lead:"PATCH (1.2.x) — bug fixes only.",children:"Nothing user-visible changes except that something broken now works. Always safe to take."}),e.jsx(A,{lead:"MINOR (1.x.0) — new, backward-compatible features.",children:"Existing usage keeps working; there's just more available."}),e.jsx(A,{lead:"MAJOR (x.0.0) — breaking changes.",children:"You removed or changed something people relied on. Bumping major is how you warn them."}),e.jsxs(A,{lead:"Before 1.0.0 (0.x) — anything may break.",children:["The most-missed rule for new tools: while you're on a"," ",e.jsx("code",{children:"0.x"})," version, semver lets a ",e.jsx("i",{children:"minor"})," bump break things. Releasing 1.0.0 is the moment you commit to the stability promise above — don't ship it until you're ready to keep it."]})]}),e.jsx(ji,{spaced:!0,children:e.jsxs(A,{lead:"Tag each release in git.",children:["A ",e.jsx("code",{children:"v1.2.0"}),' tag ties the version to the exact commit, so a report against "1.2.0" is reproducible. Make the tag the trigger: pushing it kicks off the CI release job that publishes that same version to the registry and attaches the binaries — so the git tag, the published version, and the release artifacts can never disagree.']})}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"MAJOR.MINOR.PATCH"}),e.jsx("span",{className:"chip",children:"CHANGELOG.md"}),e.jsx("span",{className:"chip",children:"git tag vX.Y.Z"})]}),e.jsx(ye,{assistKey:"versioning-changelog",topicName:"Versioning & changelog"}),e.jsx(we,{label:"My versioning scheme is set",note:"Pick the scheme once; every future release just follows the same rules.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const dL=Object.freeze(Object.defineProperty({__proto__:null,VersioningChangelogScreen:bf},Symbol.toStringTag,{value:"Module"}));function xf({registry:t,onBack:n,onComplete:s,status:r,onRevert:a}){const o=t?ff(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"Install docs",meta:"About 30 minutes · writing time",onBack:n,assistKey:"install-docs"}),e.jsxs("p",{className:"lead",children:["Your README is the front page of the package. A new user decides whether to try it in the first few lines, so lead with the"," ",e.jsx("b",{children:"install command"})," and a tiny working example."]}),e.jsx("div",{className:"seclabel",children:"A good README opens with"}),e.jsxs(he,{children:[e.jsx(A,{lead:o?`The install command — \`${o.installCommand}\`.`:"The exact install command.",children:"One copy-pasteable line. Don't make people guess the package name or the registry it lives on."}),e.jsxs(A,{lead:"A real first command to run.",children:["For a CLI, show an actual invocation — a quickstart like"," ",e.jsx("code",{children:"yourtool init"})," and the always-works"," ",e.jsx("code",{children:"yourtool --help"})," — not a library-style code snippet. The smallest thing that does something real; people skim, so show, don't describe."]}),e.jsx(A,{lead:"Supported platforms or versions.",children:"Which OSes, language versions, or runtimes you support, so users know before they install whether it'll work for them."}),e.jsxs(A,{lead:"Badges and a link to the package page.",children:["A version / build / license badge row at the top signals the package is current and maintained, and a link to its"," ",o?o.name:"registry"," page (",e.jsx("code",{children:o?o.packagePage:"the registry listing"}),") gives readers the canonical source."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Install line first"}),e.jsx("span",{className:"chip",children:"Real command, not a snippet"}),e.jsx("span",{className:"chip",children:"Badges + package link"}),e.jsx("span",{className:"chip",children:o?o.name:"Any registry"})]}),e.jsx(ye,{assistKey:"install-docs",topicName:"Install docs"}),e.jsx(we,{label:"My install docs are ready",note:"Docs evolve with the project — update the README whenever the install or usage changes.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const uL=Object.freeze(Object.defineProperty({__proto__:null,InstallDocsScreen:xf},Symbol.toStringTag,{value:"Module"}));function yf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Xe,{size:26}),title:"Release builds",meta:"About 45 minutes · CI setup",onBack:t,assistKey:"release-builds"}),e.jsxs("p",{className:"lead",children:["Not everyone installs from a registry — many people just want a binary they can run. ",e.jsx("b",{children:"Cross-platform release builds"})," produce that binary for each operating system, so users download one file and go."]}),e.jsx("div",{className:"seclabel",children:"What to produce"}),e.jsxs(he,{children:[e.jsx(A,{lead:"One binary per target platform.",children:"Typically macOS (Intel + Apple Silicon), Linux (x86_64 + arm64), and Windows. Build each in its own job rather than cross-compiling blindly."}),e.jsx(A,{lead:"Sign and notarize the binaries.",children:"The biggest real-world gap: an unsigned download is quarantined by macOS Gatekeeper and flagged by Windows SmartScreen, so users see a scary warning instead of your tool. Sign (and notarize on macOS) as part of the release job, or distribute via Homebrew/winget where the channel handles trust."}),e.jsxs(A,{lead:"Build on a git tag, in CI.",children:["A push of ",e.jsx("code",{children:"v1.2.0"})," triggers the release workflow, so binaries always match a real, tagged version — no laptop builds. A tool like ",e.jsx("code",{children:"cargo-dist"}),", ",e.jsx("code",{children:"goreleaser"}),", or electron-builder wires up the whole matrix-build-sign-publish flow instead of you hand-writing it."]}),e.jsxs(A,{lead:"Attach them to a GitHub Release.",children:["Upload the binaries (and their checksums) to the tagged"," ",e.jsx("b",{children:"GitHub Release"})," — the common path — so the download links live next to the changelog. A package channel (Homebrew tap, winget) is the usual alternative."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"macOS · Linux · Windows"}),e.jsx("span",{className:"chip",children:"Signed + notarized"}),e.jsx("span",{className:"chip",children:"Tag-triggered CI"}),e.jsx("span",{className:"chip",children:"GitHub Releases"}),e.jsx("span",{className:"chip",children:"Checksums"})]}),e.jsx(ye,{assistKey:"release-builds",topicName:"Release builds"}),e.jsx(we,{label:"My release builds are set up",note:"Once the workflow exists, every future tag produces binaries automatically.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const hL=Object.freeze(Object.defineProperty({__proto__:null,ReleaseBuildsScreen:yf},Symbol.toStringTag,{value:"Module"}));function vf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Un,{size:26}),title:"Shell completions",meta:"About 30 minutes · polish",onBack:t,assistKey:"shell-completions"}),e.jsx("p",{className:"lead",children:"Tab completion is the difference between a tool people tolerate and one they enjoy. Press Tab and the shell offers your subcommands and flags — no need to remember exact spellings."}),e.jsx("div",{className:"seclabel",children:"How it works"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Generate a completion script per shell.",children:["Most CLI frameworks emit completion scripts for ",e.jsx("code",{children:"bash"}),","," ",e.jsx("code",{children:"zsh"}),", ",e.jsx("code",{children:"fish"}),", and PowerShell from your command definitions — you don't hand-write them."]}),e.jsxs(A,{lead:"Ship a `completions` subcommand.",children:["A ",e.jsx("code",{children:"yourtool completions zsh"})," command lets users (and your install docs) print the script for their shell on demand."]}),e.jsx(A,{lead:"Document where each shell loads them.",children:"Each shell reads completions from its own directory. A short table in your README saves users the lookup."}),e.jsxs(A,{lead:"Generate a man page from the same source.",children:["The sibling polish step: most CLI frameworks also emit a"," ",e.jsx("code",{children:"man"})," page from your command definitions, so"," ",e.jsx("code",{children:"man yourtool"})," works the way completions do — generated, not hand-written."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"bash · zsh · fish"}),e.jsx("span",{className:"chip",children:"Generated, not hand-written"}),e.jsx("span",{className:"chip",children:"completions subcommand"})]}),e.jsx(ye,{assistKey:"shell-completions",topicName:"Shell completions"}),e.jsx(we,{label:"My shell completions are ready",note:"Completions regenerate from your commands — they stay in sync as the CLI grows.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const pL=Object.freeze(Object.defineProperty({__proto__:null,ShellCompletionsScreen:vf},Symbol.toStringTag,{value:"Module"}));function jf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Un,{size:26}),title:"Command-line UX",meta:"About 30 minutes · the interface contract",onBack:t,assistKey:"cli-ux"}),e.jsx("p",{className:"lead",children:"A CLI's interface isn't its code — it's how it behaves at the prompt. The same four conventions show up in every tool people trust, because both a human and a shell script read your tool through them."}),e.jsx("div",{className:"seclabel",children:"The conventions every CLI follows"}),e.jsxs(he,{children:[e.jsx(A,{lead:"`--help` and `-h` always work, on every subcommand.",children:"The first thing anyone types at an unfamiliar tool. Each subcommand gets its own help with a one-line summary, usage, and examples — not just the top-level command."}),e.jsx(A,{lead:"`--version` prints a single line and exits 0.",children:"Scripts and bug reports parse it; keep it to just the version string so it stays machine-readable."}),e.jsxs(A,{lead:"Exit codes mean something.",children:[e.jsx("code",{children:"0"})," for success, non-zero for failure — and ideally distinct codes for distinct failures. This is how"," ",e.jsx("code",{children:"cmd && next"})," and CI know whether to continue, so an error that exits 0 silently breaks every script wrapping you."]}),e.jsx(A,{lead:"Results on stdout, diagnostics on stderr.",children:`Stdout is the data a user pipes into the next command; progress, warnings, and errors go to stderr so they don't corrupt that pipe. Getting this backwards is the most common reason a tool "doesn't work in a pipeline."`})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"--help · --version"}),e.jsx("span",{className:"chip",children:"Meaningful exit codes"}),e.jsx("span",{className:"chip",children:"stdout = data, stderr = noise"})]}),e.jsx(ye,{assistKey:"cli-ux",topicName:"Command-line UX"}),e.jsx(we,{label:"My command-line UX is solid",note:"Nail the contract first; shell completions and man pages are the polish on top of it.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const mL=Object.freeze(Object.defineProperty({__proto__:null,CliUxScreen:jf},Symbol.toStringTag,{value:"Module"}));function wf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Ge,{size:26}),title:"Security & supply chain",meta:"About 45 minutes · trust",onBack:t,assistKey:"supply-chain"}),e.jsx("p",{className:"lead",children:"The moment you publish, your code becomes a dependency in someone else's build — and your security becomes part of theirs. A few habits make what you ship trustworthy: audit what you depend on, catch known vulnerabilities before release, and sign the release so users can verify it's really yours."}),e.jsx("div",{className:"seclabel",children:"What a published artifact owes its users"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Audit your own dependencies.",children:["Run ",e.jsx("code",{children:"cargo audit"})," (Rust) or ",e.jsx("code",{children:"npm audit"})," /"," ",e.jsx("code",{children:"pip-audit"})," in CI so a known-vulnerable transitive dependency fails the build instead of shipping. Wire it into the same workflow that runs your tests."]}),e.jsx(A,{lead:"Scan continuously, not just once.",children:"New CVEs are disclosed against dependencies you already shipped. A scanner like Dependabot or Renovate opens update PRs as advisories land, so you're patching on the advisory's clock, not discovering it from a user's bug report."}),e.jsxs(A,{lead:"Publish an SBOM.",children:["A Software Bill of Materials lists every component and version in your release. Downstream users — especially in regulated shops — scan it to decide whether your release is safe to adopt. Most toolchains generate one (",e.jsx("code",{children:"cargo sbom"}),", ",e.jsx("code",{children:"npm sbom"}),","," ",e.jsx("code",{children:"syft"}),")."]}),e.jsxs(A,{lead:"Sign your releases so they can be verified.",children:[xe("supplyChain.signedReleases").value,"."," ",e.jsx(un,{fact:xe("supplyChain.signedReleases")})," ","Pair that with published checksums (and a ",e.jsx("code",{children:"cosign"})," signature for binaries) so an install can prove it got exactly what you built."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"audit in CI"}),e.jsx("span",{className:"chip",children:"SBOM per release"}),e.jsx("span",{className:"chip",children:"Signed & verifiable"})]}),e.jsx(ye,{assistKey:"supply-chain",topicName:"Security & supply chain"}),e.jsx(we,{label:"My supply chain is covered",note:"Wire audit + signing into CI once; every future release inherits it automatically.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const fL=Object.freeze(Object.defineProperty({__proto__:null,SupplyChainScreen:wf},Symbol.toStringTag,{value:"Module"}));function _f({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"Examples & doctests",meta:"About 40 minutes · adoption",onBack:t,assistKey:"examples"}),e.jsxs("p",{className:"lead",children:["Reference docs say what each function does; ",e.jsx("b",{children:"examples"})," show how the pieces fit together to do something real. Most people copy a working example before they ever read the API reference — it's the single biggest thing you can add to make a library easy to adopt."]}),e.jsx("div",{className:"seclabel",children:"What to ship"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Runnable examples, not snippets in a README.",children:["Put complete programs in an ",e.jsx("code",{children:"examples/"})," directory that build and run as-is (",e.jsx("code",{children:"cargo run --example quickstart"}),"). A snippet a user has to assemble themselves is a snippet that's subtly wrong."]}),e.jsx(A,{lead:"Start with the one-minute quickstart.",children:"The first example should be the shortest path from install to a result. Show the 80% use case end to end before any advanced configuration — that's the example most people will actually run."}),e.jsxs(A,{lead:"Make the docs themselves runnable with doctests.",children:["A doctest is an example embedded in a doc comment that the test runner actually executes (",e.jsx("code",{children:"cargo test --doc"}),", Python's"," ",e.jsx("code",{children:"doctest"}),"). It means the snippet in your reference can't silently rot — if the API changes, the doctest fails CI."]}),e.jsxs(A,{lead:"Run examples and doctests in CI.",children:["An example that no longer compiles is worse than none — it tells users the library is unmaintained. Build the ",e.jsx("code",{children:"examples/"})," and run the doctests on every commit so a broken one fails the build."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"examples/ directory"}),e.jsx("span",{className:"chip",children:"One-minute quickstart"}),e.jsx("span",{className:"chip",children:"Doctests run in CI"})]}),e.jsx(ye,{assistKey:"examples",topicName:"Examples & doctests"}),e.jsx(we,{label:"My examples & doctests are ready",note:"Tie them into CI once; a broken example then fails the build instead of misleading a new user.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const gL=Object.freeze(Object.defineProperty({__proto__:null,ExamplesScreen:_f},Symbol.toStringTag,{value:"Module"}));function kf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"API docs",meta:"Foundation · about 30 minutes",onBack:t,assistKey:"api-docs"}),e.jsxs("p",{className:"lead",children:["For a library, the public API ",e.jsx("i",{children:"is"})," the product — so its reference docs matter as much as the code. The trick is to"," ",e.jsx("b",{children:"generate docs from the source"}),", so they can't drift out of date."]}),e.jsx("div",{className:"seclabel",children:"Generate, don't hand-write"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Doc comments on every public item.",children:"Document each exported function, type, and field where it's defined. The generator turns those comments into the reference site."}),e.jsxs(A,{lead:"A generator for your language.",children:[e.jsx("code",{children:"docs.rs"})," for Rust, ",e.jsx("code",{children:"TypeDoc"})," for TypeScript,"," ",e.jsx("code",{children:"Sphinx"})," (or the more modern"," ",e.jsx("code",{children:"MkDocs + mkdocstrings"}),") for Python — each reads your source and produces a browsable site."]}),e.jsx(A,{lead:"Publish on every release.",children:"Many registries (docs.rs) build docs automatically on publish; for others, a CI step deploys them. Either way, the live docs track the released version."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"docs.rs · TypeDoc · Sphinx"}),e.jsx("span",{className:"chip",children:"From doc comments"}),e.jsx("span",{className:"chip",children:"Auto-built on publish"})]}),e.jsx(ye,{assistKey:"api-docs",topicName:"API docs"}),e.jsx(we,{label:"My API docs are published",note:"Because they're generated from source, the docs refresh themselves on every release.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const bL=Object.freeze(Object.defineProperty({__proto__:null,ApiDocsScreen:kf},Symbol.toStringTag,{value:"Module"})),N2={key:"api-docs",Icon:Be,title:"API docs",crumbLabel:"API docs",meta:"Foundation · about 8 minutes",leads:[{text:"Your service speaks HTTP, but a URL alone tells a caller nothing about which routes exist, what to send, or what comes back. API docs are that contract — one machine-readable description of every endpoint that humans can read and tools can consume."},{text:"The standard is OpenAPI (the spec format Swagger tools read). One OpenAPI document becomes browsable docs, a try-it console, and client code — all from the same source of truth.",dim:!0}],sections:[{heading:"What goes in the docs",bullets:[{lead:"Every route.",text:"The method and path (GET /orders, POST /orders/{id}/refund), what each one does, and which need authentication."},{lead:"Request & response shapes.",text:"The fields, types, and examples for what a caller sends and what they get back — including the error responses, not just the happy path."},{lead:"Auth.",text:"How a caller proves who they are — the API key header or bearer token your endpoints expect."}]},{heading:"Generate it, don't hand-maintain it",bullets:[{lead:"From your code.",text:"Most frameworks emit the OpenAPI spec from the routes you already wrote — FastAPI and NestJS produce it automatically; Express adds it with a plugin. The docs can't drift from the code because they come from the code."},{lead:"Or author it by hand.",text:"For a small or contract-first API you can write the OpenAPI YAML yourself. It's more work to keep in sync, so reserve it for when you're designing the API before building it."}]},{heading:"Serve it so people can use it",bullets:[{lead:"An interactive console.",text:"Swagger UI, Redoc, or Scalar turn the spec into a browsable page with a try-it form — a caller can hit a real endpoint without writing any code first."},{lead:"Keep it from drifting.",text:"Regenerate the spec in CI and fail the build if it changes unexpectedly, so the published docs always match the deployed API."}]}],faq:[{q:"Isn't this the same as the library 'API docs'?",a:"No. A library's API docs (docs.rs, TypeDoc, Sphinx) describe code others import into their own program. A service's API docs describe HTTP endpoints others call over the network — different audience, different format. OpenAPI/Swagger is the service one."},{q:"Swagger or OpenAPI — what's the difference?",a:"OpenAPI is the specification (the document format). Swagger is the family of tools — Swagger UI, Swagger Editor — that read and render an OpenAPI document. You write OpenAPI; you view it with Swagger UI (or Redoc, or Scalar)."},{q:"Do I have to write the spec by hand?",a:"Usually not. If your framework can emit OpenAPI from your route definitions, let it — generated docs stay in sync automatically. Hand-authoring is for contract-first designs where the spec comes before the implementation."}],doneLabel:"Mark API docs as set up",doneNote:"Generate the spec from your code where you can — auto-generated docs can't fall out of sync with the API."};function Sf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:N2,onBack:t,onComplete:n,status:s,onRevert:r})}const xL=Object.freeze(Object.defineProperty({__proto__:null,BackendApiDocsScreen:Sf},Symbol.toStringTag,{value:"Module"}));function Nf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"Versioning policy",meta:"About 20 minutes · a decision",onBack:t,assistKey:"semver-policy"}),e.jsxs("p",{className:"lead",children:["Other people's code depends on yours. A breaking change you ship quietly breaks their builds. A written ",e.jsx("b",{children:"versioning policy"})," is the promise that makes your library safe to depend on."]}),e.jsx("div",{className:"seclabel",children:"Decide and write down"}),e.jsxs(he,{children:[e.jsx(A,{lead:"What counts as a breaking change.",children:"Removing or renaming a public item, changing a signature, tightening accepted input. Anything a user's code could rely on is part of the contract."}),e.jsx(A,{lead:"How you signal it.",children:"Breaking changes mean a MAJOR bump. Spell out that the public API is covered and what's explicitly *not* (internal modules, anything marked unstable)."}),e.jsx(A,{lead:"Your deprecation path.",children:"Mark an item deprecated for at least one minor release before removing it, so users get a warning and time to migrate — not a surprise."}),e.jsxs(A,{lead:"Let a tool catch breaks for you.",children:["You don't have to spot every breaking change by eye:"," ",e.jsx("code",{children:"cargo-semver-checks"})," (Rust) and"," ",e.jsx("code",{children:"api-extractor"})," (TypeScript) diff your public API against the last release and fail CI when a change needs a MAJOR bump."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Public API = the contract"}),e.jsx("span",{className:"chip",children:"Breaking → MAJOR"}),e.jsx("span",{className:"chip",children:"Deprecate before removing"})]}),e.jsx(ye,{assistKey:"semver-policy",topicName:"Versioning policy"}),e.jsx(we,{label:"My versioning policy is set",note:"Write it in the README once; it guides every release decision afterward.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const yL=Object.freeze(Object.defineProperty({__proto__:null,SemverPolicyScreen:Nf},Symbol.toStringTag,{value:"Module"}));function Cf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"Readme & license",meta:"About 30 minutes",onBack:t,assistKey:"readme-license"}),e.jsxs("p",{className:"lead",children:["Two files decide whether someone adopts your library: the"," ",e.jsx("b",{children:"README"})," tells them what it does, and the ",e.jsx("b",{children:"license"}),` tells them whether they're allowed to use it. Skip the license and the legal default is "all rights reserved" — nobody can.`]}),e.jsx("div",{className:"seclabel",children:"A README that earns trust"}),e.jsxs(he,{children:[e.jsx(A,{lead:"One sentence: what it is and who it's for.",children:"The first line should let a reader decide in seconds whether to keep reading."}),e.jsx(A,{lead:"Install + a minimal example.",children:'The fastest path from "interested" to "it works on my machine".'})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Pick a license"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Permissive (MIT, Apache-2.0) — easiest to adopt.",children:"Lets people use your library in almost any project. Apache-2.0 also grants patent rights, which some companies require."}),e.jsxs(A,{lead:"Library copyleft (LGPL, MPL-2.0) — share changes, not callers.",children:["For a library, the relevant copyleft is ",e.jsx("b",{children:"LGPL"})," or"," ",e.jsx("b",{children:"MPL-2.0"}),": changes to your code stay open, but code that merely links to or imports it doesn't have to be. Full ",e.jsx("b",{children:"GPL"})," forces every consumer to be GPL too, which usually kills adoption for a library — reach for it only on purpose."]})]}),e.jsx(he,{children:e.jsxs(A,{lead:"Declare the license in your package manifest, too.",children:["A LICENSE file alone isn't enough — set the ",e.jsx("code",{children:"license"})," field in your manifest (",e.jsx("code",{children:"Cargo.toml"}),", ",e.jsx("code",{children:"package.json"}),","," ",e.jsx("code",{children:"pyproject.toml"}),") so the registry detects and displays it on the package page."]})}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"README first line"}),e.jsx("span",{className:"chip",children:"LICENSE file + manifest field"}),e.jsx("span",{className:"chip",children:"MIT · Apache-2.0 · LGPL/MPL"})]}),e.jsx(ye,{assistKey:"readme-license",topicName:"Readme & license"}),e.jsx(we,{label:"My readme & license are in place",note:"A LICENSE file is a one-time decision that unblocks everyone who wants to use your work.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const vL=Object.freeze(Object.defineProperty({__proto__:null,ReadmeLicenseScreen:Cf},Symbol.toStringTag,{value:"Module"}));function Tf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Tt,{size:26}),title:"Changelog & CI",meta:"About 40 minutes · automation",onBack:t,assistKey:"changelog-ci"}),e.jsx("p",{className:"lead",children:"A changelog tells people what changed before they upgrade; CI makes sure every release is tested and published the same way. Together they turn releasing from a careful manual ritual into a tagged, repeatable step."}),e.jsx(ji,{}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Automate the release"}),e.jsxs(he,{children:[e.jsx(A,{lead:"CI runs tests on every change.",children:"A green pipeline is the precondition for any release — no publishing from an untested commit."}),e.jsxs(A,{lead:"A tag triggers publish.",children:["Pushing ",e.jsx("code",{children:"v1.2.0"})," runs the release job: test, build, and publish to the registry. The version published always matches the tag."]}),e.jsxs(A,{lead:"Give CI a way to authenticate.",children:["The release job needs publish credentials. The classic path is a registry token in a CI secret (",e.jsx("code",{children:"CARGO_REGISTRY_TOKEN"}),","," ",e.jsx("code",{children:"NPM_TOKEN"}),"). The current best practice is"," ",e.jsx("b",{children:"OIDC trusted publishing"}),": ",xe("registry.oidc").value,"."," ",e.jsx(un,{fact:xe("registry.oidc")})]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"CHANGELOG.md"}),e.jsx("span",{className:"chip",children:"Tests on every push"}),e.jsx("span",{className:"chip",children:"Tag → publish"}),e.jsx("span",{className:"chip",children:"OIDC or token"})]}),e.jsx(ye,{assistKey:"changelog-ci",topicName:"Changelog & CI"}),e.jsx(we,{label:"My changelog & CI are set up",note:"Once the pipeline exists, releasing is just pushing a tag — the rest runs itself.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const jL=Object.freeze(Object.defineProperty({__proto__:null,ChangelogCiScreen:Tf},Symbol.toStringTag,{value:"Module"})),C2=xe("flyio.pricing"),T2={key:"deploy-target",connector:{provider:"render"},Icon:Tn,title:"Deploy target",meta:"Foundation · about 10 minutes",leads:[{text:"Right now your service only runs on your machine. A deploy target is where it runs for real — always on, with a public endpoint other apps can call."},{text:"You don't need to manage servers. A container host runs your service the way it already works locally; we'll walk through each step.",dim:!0}],recommendLabel:"Recommended for your service",recommended:{initial:"F",color:"linear-gradient(140deg,#7c4dff,#5b2ecc)",name:"Fly.io",bestFit:!0,description:"A container host that runs your service close to your users — a good fit when low latency or running near your data matters. A simple, standard home for a long-running API.",reasons:[{lead:"Pricing.",rest:C2.value},{lead:"Runs your container as-is.",rest:"It behaves just like it does locally — no proprietary runtime to learn."},{lead:"A public endpoint included.",rest:"Your service gets an HTTPS URL other apps can call right away."}],chips:["Edge / low-latency","Always-on","~5 min to set up"]},alternatives:[{initial:"R",color:"linear-gradient(140deg,#22c55e,#15803d)",name:"Render",description:"Beginner-friendly: connect your repo and every git push deploys. Managed Postgres lives in the same dashboard, so your DB and service sit side by side. A good first deploy if you don't need edge locality."},{initial:"R",color:"linear-gradient(140deg,#6366f1,#4338ca)",name:"Railway",description:"Also git-push to deploy with managed Postgres in-dashboard. Quick to wire up a service plus its database; usage-based pricing once you're past the starter allowance."},{initial:"S",color:"linear-gradient(140deg,#f59e0b,#b45309)",name:"Serverless",description:"Spins up per request and scales to zero. Cheapest when traffic is spiky — but a long-running, stateful service that holds database connection pools fits it poorly: each cold start reconnects, and execution limits cut off long requests."},{initial:"V",color:"linear-gradient(140deg,#16a3a3,#0d6e6e)",name:"Virtual machine",description:"A full server you control end to end. Most flexible, but you own patching, scaling, and uptime yourself."}],ctaLabel:"📦 Deploy to a container host",ctaNote:"We'll deploy this one service. Nothing else is touched.",faq:[{q:"What does deploying actually do?",a:"It packages your service into a container, runs it on an always-on host, and gives it a public endpoint. Your local copy keeps working exactly as before."},{q:"Do I need to understand servers?",a:"No. The container host handles the machines, networking, and restarts. You ship your service and get back a URL."},{q:"Can I take it down?",a:"Anytime. You can stop or delete the deployment with one action and it goes back to running only on your machine."},{q:"Will it reach my database once it's deployed?",a:"Only after you point it there. The deployed service reads DATABASE_URL from its host's secret store — set that to your managed database's connection string (see the Real data step), not the localhost URL you use on your machine."}],flowLabels:["Connect","Deploy","Go live"],connect:{heading:"🔗 Connect your container host",sub:"This account holds your running service. If you don't have one yet, you'll create it in a few clicks.",grants:["Create one app to run your service","Give it a public endpoint","Nothing else — we can't touch your other resources"],continueLabel:"Continue with Fly.io",reassure:"We only ask for what's needed to run this one service. You can disconnect anytime."},provisionTitle:"Putting your service online…",provisionDesc:"This usually takes under a minute. We'll let you know when the endpoint is live.",provisionSteps:["Building your container image","Pushing it to the host","Assigning a public endpoint","Starting the service"],ready:{title:"Your service is live",desc:"It's running on a container host and reachable at this endpoint.",resultLabel:"Service endpoint",resultValue:"your-service.onrender.com",donePill:"Deploy target is now set up"}};function Pf({onBack:t,onComplete:n,onRevert:s}){return e.jsx(As,{config:T2,onBack:t,onComplete:n,onRevert:s})}const wL=Object.freeze(Object.defineProperty({__proto__:null,DeployTargetScreen:Pf},Symbol.toStringTag,{value:"Module"})),P2={key:"database-backups",Icon:Os,title:"Backups & migrations",crumbLabel:"Backups",meta:"Foundation · about 10 minutes",leads:[{text:"Once a real database holds data people care about, two things keep it safe: backups, so a bad deploy or a dropped table is recoverable, and migrations, so changing the database's shape never loses what's already stored."},{text:"Most managed databases take automated backups for you — your job is to know how far back they reach and to practice restoring one before you need it.",dim:!0}],sections:[{heading:"Backups: the safety net",bullets:[{lead:"Automated daily backups —",text:"your host snapshots the whole database on a schedule, with no action from you."},{lead:"Point-in-time recovery —",text:"rewind the database to any moment (e.g. just before a bad migration), not just to last night's snapshot."},{lead:"Test the restore —",text:"a backup you've never restored is a guess. Restore one into a scratch database once so you know the steps work."}]},{heading:"Migrations: changing the shape safely",bullets:[{lead:"Versioned, in source control —",text:"each change to the schema is a small, ordered file checked in with your code, so every environment applies the same steps."},{lead:"Run on deploy —",text:"the migration runs as part of shipping, before the new code serves traffic, so the database and the code always match."},{lead:"Forward-only and reversible —",text:"prefer additive changes (add a column, backfill, then drop the old one) so a rollback never strands data."}]}],faq:[{q:"Doesn't my database host already back up for me?",a:"Usually yes — but the retention window varies, and free tiers often keep little or nothing. Check how many days you can recover, and whether point-in-time recovery is included or a paid add-on."},{q:"What's the difference between a backup and a migration?",a:"A backup protects the data you already have. A migration changes the structure that holds it (new tables, new columns). You need both: migrations to evolve the schema, backups in case a migration — or anything else — goes wrong."},{q:"Can I just edit the database by hand when I need a change?",a:"It works once, then bites you: other environments drift, and there's no record of what changed. A migration file makes the change repeatable and reviewable, and runs the same way everywhere."}],doneLabel:"Mark backups & migrations as set up",doneNote:"Confirm your backup retention window and run your first migration on deploy — you can revisit both anytime."};function Of({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:P2,onBack:t,onComplete:n,status:s,onRevert:r})}const _L=Object.freeze(Object.defineProperty({__proto__:null,DatabaseBackupsScreen:Of},Symbol.toStringTag,{value:"Module"}));function O2(){const[t,n]=l.useState(null);return l.useEffect(()=>{let s=!1;return(async()=>{try{const r=await fetch("/api/setup-env");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();s||n(a)}catch{s||n(null)}})(),()=>{s=!0}},[]),{env:t}}const A2={heading:"The secrets a service usually needs",bullets:[{lead:"DATABASE_URL —",text:"the connection string for your managed database."},{lead:"JWT_SECRET / API keys —",text:"the values that sign tokens and authenticate callers."},{lead:"Third-party keys —",text:"Stripe, email, or other provider credentials your service calls."}]};function Af(t,n){const s=[...t,...n];return s.length===0?A2:{heading:"This project's secrets",bullets:s.map(r=>({lead:`${r} —`,text:n.includes(r)?"needed by a service this project already uses; set its value in your host's secret store.":"from your .env.example; set its value in your host's secret store, never in source control."}))}}function Rf(t,n){return{key:"secrets",Icon:Ge,title:"Secrets & config",crumbLabel:"Secrets",meta:"Foundation · about 5 minutes",leads:[{text:"Your service needs passwords, API keys, and connection strings to do its job — but those must never live in your code. You set them once per environment, and the host hands them to your service at runtime."},{text:"The names come from your .env.example; the real values stay in your host's secret store, never in source control.",dim:!0}],sections:[Af(t,n),{heading:"How it works",bullets:[{lead:"One set per environment.",text:"Development, staging, and production each get their own values, so a test key can't leak into production."},{lead:"Set, don't commit.",text:"You paste each value into the host's secret store once. Rotating a key later is a one-field change, no redeploy of code."}]}],faq:[{q:"Why not just put them in a config file?",a:"A committed secret is a leaked secret — anyone with repo access (or a fork, or git history) has it forever. Secret stores keep values out of source and let you rotate without a code change."},{q:"How does my service read them?",a:"The host injects each secret as an environment variable at runtime. Your code reads them the same way it reads your local .env — nothing app-side changes between environments."}],doneLabel:"Mark secrets as set up",doneNote:"You can add or rotate individual secrets anytime without touching code."}}function Ef({onBack:t,onComplete:n,status:s,onRevert:r}){const{env:a}=O2(),o=Rf((a==null?void 0:a.envKeys)??[],(a==null?void 0:a.serviceEnvVars)??[]);return e.jsx(ut,{config:o,onBack:t,onComplete:n,status:s,onRevert:r})}const kL=Object.freeze(Object.defineProperty({__proto__:null,SecretsScreen:Ef,buildConfig:Rf,secretsSection:Af},Symbol.toStringTag,{value:"Module"})),R2={key:"api-auth",Icon:Ge,title:"API authentication",crumbLabel:"API auth",meta:"Foundation · about 8 minutes",leads:[{text:"An open endpoint is a public endpoint. Authentication decides who may call your service, and rate limiting decides how often — together they keep your API from being abused or accidentally hammered."},{text:"A service authenticates callers — other services, scripts, partners — not interactive human logins.",dim:!0}],sections:[{heading:"Who may call — two kinds of credential",bullets:[{lead:"Static API keys.",text:"An opaque secret string each caller sends on every request. Simple to issue; you revoke a leaked one server-side. Best for trusted clients you control."},{lead:"Signed tokens (JWT).",text:"A bearer token that carries claims (who, what scope) and expires on its own, so a leaked one stops working without a server lookup. Best when callers come and go or need scoped access."}]},{heading:"How often — rate limiting",bullets:[{lead:"Per-key limits.",text:"Cap authenticated callers per window — e.g. 100 / minute. Fixed-window is simplest; token-bucket smooths bursts by refilling allowance steadily instead of resetting on a hard clock edge. Either way overflow gets a clean 429 Too Many Requests instead of taking the service down."},{lead:"Limit unauthenticated traffic too.",text:"Throttle by client IP before auth runs, so a flood of un-keyed requests can't exhaust the service trying to log in or hammer public routes."}]},{heading:"Verifying it's really them — request signing",bullets:[{lead:"HMAC signatures.",text:"For service-to-service and webhooks, the caller signs each request body with a shared secret (the Stripe-webhook / AWS-style scheme) and you verify the signature — proving the payload wasn't tampered with, not just that a key was presented."},{lead:"mTLS (optional).",text:"For high-trust internal calls, both sides present certificates so the connection itself authenticates the caller before any request is read."}]},{heading:"Sensible defaults",body:"Start with API keys or short-lived JWTs, per-key limits with an IP limit on unauthenticated routes, and a 429 on overflow. Keep keys and signing secrets in your secret store so you can rotate them without a redeploy."}],faq:[{q:"Keys or OAuth?",a:"For service-to-service calls, API keys or signed tokens are simpler and enough. Reach for OAuth when third parties act on behalf of your users, not just for machine callers."},{q:"Where do limits live?",a:"Usually at the edge or in middleware, keyed by the caller's API key. That way a noisy client is throttled before it reaches your handlers."}],doneLabel:"Mark API auth as set up",doneNote:"Start strict — loosening a limit later is easy; tightening one after launch is harder."};function Mf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:R2,onBack:t,onComplete:n,status:s,onRevert:r})}const SL=Object.freeze(Object.defineProperty({__proto__:null,ApiAuthScreen:Mf},Symbol.toStringTag,{value:"Module"})),E2={key:"cors-origins",Icon:ln,title:"Allowed origins (CORS)",crumbLabel:"CORS",meta:"Common · about 5 minutes",leads:[{text:"If a website running in someone's browser calls your API, the browser first checks whether your API allows that website. CORS — Cross-Origin Resource Sharing — is how your API answers 'yes, this origin is allowed.' Get it wrong and the browser blocks the call before your code ever sees it."},{text:"This only affects browser calls. Requests from your own server, a mobile app, or a tool like curl aren't subject to CORS at all.",dim:!0}],sections:[{heading:"What an 'origin' is",bullets:[{lead:"Scheme + host + port —",text:"https://app.example.com is one origin; http://app.example.com and https://example.com are different origins."},{lead:"You list the ones you trust —",text:"your API replies with an Access-Control-Allow-Origin header naming the sites permitted to read its responses."},{lead:"Don't reflect everything —",text:"allowing every origin (a wildcard) defeats the point and breaks cookies/credentials. List the specific front-ends you control."}]},{heading:"Getting it right per environment",bullets:[{lead:"Local + production differ.",text:"http://localhost:5173 in development, https://your-app.com in production — both go on the allow-list, ideally read from config, not hard-coded."},{lead:"Credentials need extra care.",text:"If the browser sends cookies or an auth header, you must name the exact origin (no wildcard) and set the allow-credentials flag."},{lead:"Preflight is automatic.",text:"For anything beyond a simple GET, the browser sends an OPTIONS 'preflight' first. Your CORS layer answers it — you rarely write that by hand."}]}],faq:[{q:"I got a 'blocked by CORS policy' error — what does it mean?",a:"The browser asked your API whether the current website is allowed, and your API didn't say yes for that origin. Add the website's exact origin (scheme, host, and port) to your allow-list and the call will go through."},{q:"Why not just allow all origins with a wildcard?",a:"A wildcard lets any site on the internet call your API from a user's browser, and it can't be combined with cookies or credentials. List the specific front-ends you own instead."},{q:"My API works from curl but not the browser — why?",a:"CORS is a browser rule, not a server rule. curl and your own backend ignore it; only browser JavaScript is gated. That's why a missing origin shows up only once a web front-end calls the API."}],doneLabel:"Mark allowed origins as set up",doneNote:"Add each front-end's origin to the allow-list per environment — you can adjust the list anytime without a code change beyond config."};function If({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:E2,onBack:t,onComplete:n,status:s,onRevert:r})}const NL=Object.freeze(Object.defineProperty({__proto__:null,CorsOriginsScreen:If},Symbol.toStringTag,{value:"Module"})),M2={key:"background-jobs",Icon:Xe,title:"Background jobs",crumbLabel:"Background jobs",meta:"Common · about 10 minutes",leads:[{text:"Some work shouldn't happen while a user waits for a response — sending a welcome email, resizing an upload, calling a slow third-party API, or running a nightly cleanup. Background jobs move that work onto a queue so your API answers immediately and the work happens just after."},{text:"A job runner gives you three things a plain request can't: it retries on failure, it survives a restart, and it can run on a schedule.",dim:!0}],sections:[{heading:"What you'd push to the background",bullets:[{lead:"Anything slow —",text:"emails, webhooks, image/video processing, report generation. The user gets an instant 'on its way' instead of a spinner."},{lead:"Anything scheduled —",text:"nightly cleanup, daily digests, expiring old sessions. A cron-style timer enqueues the job for you."},{lead:"Anything that can fail and retry —",text:"a flaky external API is fine in a job: it retries with backoff instead of failing the user's request."}]},{heading:"How a job queue works",bullets:[{lead:"Enqueue, don't block.",text:"Your endpoint adds a job to the queue and returns. The caller doesn't wait for the work to finish."},{lead:"A worker picks it up.",text:"A separate worker process pulls jobs off the queue and runs them — you scale workers independently of your API."},{lead:"Retries with backoff.",text:"If a job throws, the runner re-runs it after a growing delay, up to a limit, then parks it in a dead-letter queue for you to inspect."}]}],faq:[{q:"Can't I just run the work in the request and not worry about a queue?",a:"For something instant, yes. But slow work makes every caller wait, and a crash mid-request loses the work with no retry. A queue keeps responses fast and makes the work durable."},{q:"Do I need a separate server for workers?",a:"Not necessarily — a worker can be a second process on the same host. What matters is that it's separate from the web process, so a burst of jobs doesn't slow down serving requests."},{q:"What happens if a job keeps failing?",a:"After the retry limit it lands in a dead-letter queue: it stops retrying, and you get a record to investigate instead of an infinite loop or silent loss."}],doneLabel:"Mark background jobs as set up",doneNote:"Start with one job — a welcome email is a good first move — then add scheduled and retrying jobs as you need them."};function Lf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:M2,onBack:t,onComplete:n,status:s,onRevert:r})}const CL=Object.freeze(Object.defineProperty({__proto__:null,BackgroundJobsScreen:Lf},Symbol.toStringTag,{value:"Module"})),I2={key:"logging-monitoring",Icon:Tt,title:"Logging & monitoring",crumbLabel:"Monitoring",meta:"Foundation · about 8 minutes",leads:[{text:"A service has no screen to glance at — observability is how you know it's alive and well. You wire up logs, metrics, alerts, and uptime checks once, then you find out about problems before your users do."},{text:"You don't have to build this yourself — hosts and tools provide it; you decide what to watch.",dim:!0}],sections:[{heading:"The four things to watch",bullets:[{lead:"Logs.",text:"A searchable record of what happened — every request, error, and warning. The first place you look when something breaks."},{lead:"Metrics.",text:"Numbers over time: request rate, error rate, latency. They show trends a single log line can't."},{lead:"Alerts.",text:"Rules that page you when a metric crosses a line, so you don't have to stare at dashboards."},{lead:"Uptime checks.",text:"An outside service pings a health endpoint on a schedule and tells you the moment the service stops responding."}]},{heading:"Tools that do this for you",bullets:[{lead:"Errors —",text:"Sentry captures every exception with the stack trace and the request that caused it."},{lead:"Metrics & dashboards —",text:"Grafana + Prometheus (self-hosted), or Datadog / Better Stack (managed) for request-rate, error-rate, and latency graphs."},{lead:"Logs —",text:"Axiom or Loki to search structured logs, or your host's built-in log viewer to start."},{lead:"Uptime —",text:"UptimeRobot or Better Stack pings your /health endpoint and alerts you the moment it stops answering."}]},{heading:"One standard to instrument with",body:"Instrument your service with OpenTelemetry — the vendor-neutral standard for emitting logs, metrics, and traces. You add it once, then point it at whichever backend above you choose, and you can switch tools later without re-instrumenting your code."},{heading:"A good starting point",body:"Ship structured logs, expose request-rate / error-rate / latency metrics, add one error-rate alert, and point an uptime check at a /health endpoint. That covers the most common 3am surprises."}],faq:[{q:"Isn't this overkill for a small service?",a:"Even one error-rate alert and an uptime check pay for themselves the first time the service goes down while you're asleep. Start small; add detail as you grow."},{q:"What's a health endpoint?",a:"A tiny route (often /health) that returns 200 when the service can serve traffic. Uptime checks and load balancers ping it to decide if the service is alive."}],doneLabel:"Mark monitoring as set up",doneNote:"Start with logs, one alert, and an uptime check — you can always add more signals later."};function Df({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsx(ut,{config:I2,onBack:t,onComplete:n,status:s,onRevert:r})}const TL=Object.freeze(Object.defineProperty({__proto__:null,LoggingMonitoringScreen:Df},Symbol.toStringTag,{value:"Module"}));function uo({onBack:t,onComplete:n,status:s,onRevert:r}){const a=[{q:"Is a preview the same build as production?",a:"If you wire it up right, yes — a preview deploy runs the same build command and the same framework output as production, just on a throwaway URL. That's the whole point: what you click on the preview is what ships. Where it can differ is data and secrets — a preview usually points at a staging database, not prod — so test behavior on the preview, but don't trust preview data as if it were live."},{q:"Can I share it without making it public?",a:"Yes. Most hosts let you password-protect a preview or restrict it to your team's accounts, so you can hand a reviewer or a client a working link before the production domain points anywhere. Protect previews by default if the build exposes anything you wouldn't want indexed — search engines and link unfurlers will otherwise crawl an open preview URL."},{q:"Do I need a separate staging environment too?",a:"Per-branch previews are throwaway and rebuilt on every push. A longer-lived staging environment is the complement: one stable URL, its own data, that behaves like prod and stays up between deploys — useful for QA sign-off, demos, and integrations that need a fixed address. Many teams use preview deploys for review and one staging environment as the final gate before production."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Xe,{size:26}),title:"Staging & preview deploys",meta:"About 15 minutes · then automatic on every push",onBack:t,assistKey:"staging-preview"}),e.jsx("p",{className:"lead",children:"Before you point your real domain at anything, give yourself a prod-like URL to test on and share. Most hosts can build one for you on every push, so you and your reviewers see the exact build that will go live — without anyone touching production."}),e.jsx("div",{className:"seclabel",children:"Per-branch preview deploys"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Get a URL for every branch or pull request.",children:["Hosts like ",e.jsx("b",{children:"Vercel"})," and ",e.jsx("b",{children:"Netlify"})," build a fresh deploy each time you push and give it its own URL. The preview runs the same build as production, so it's the real thing on a throwaway address — not a local approximation."]}),e.jsx(A,{lead:"Review the change on the preview, not on prod.",children:"Open the preview URL for the branch, click through the actual change, and only merge once it looks right. This is where you catch a broken build or a layout regression before it can reach a visitor."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"A shared staging environment"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Keep one stable, prod-like URL with its own data.",children:"A longer-lived staging environment behaves like production — same build, its own database and config — but stays up between deploys. It's the fixed address QA, demos, and integrations point at while per-branch previews come and go."}),e.jsx(A,{lead:"Promote the same build to production.",children:"When staging looks right, promote that build to production rather than rebuilding from scratch. What you signed off on is what ships, so going live is a flip of the switch, not a fresh roll of the dice."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Share it privately"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Password-protect or restrict the preview.",children:"So you can hand a working link to a client or teammate before going public, protect the preview with a password or limit it to your team's accounts. Most hosts offer this as a one-click setting per deploy."}),e.jsx(A,{lead:"Keep previews out of search.",children:"A protected preview won't get indexed or unfurled. Turn protection on by default if the build shows anything you wouldn't want a crawler to find before launch day."})]}),e.jsx(ot,{items:a}),e.jsx(ye,{assistKey:"staging-preview",topicName:"Staging & preview deploys"}),e.jsx(we,{label:"I've set up staging & previews",note:"From here, every push gives you a prod-like URL to test and share before anything reaches your real domain.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const PL=Object.freeze(Object.defineProperty({__proto__:null,StagingPreviewScreen:uo},Symbol.toStringTag,{value:"Module"}));function Ff({onBack:t,onComplete:n,status:s,onRevert:r}){const a=[{q:"Why not just point staging at the production database?",a:"Because a staging environment exists to let you break things safely, and the fastest way to lose that is to share prod's data. A bad migration, a destructive test, or a runaway job on staging would then corrupt or leak real customer data. Staging gets its own database — ideally seeded from a sanitized copy of prod so it's realistic — and its own secrets, so nothing you do there can touch production."},{q:"What does staging actually catch that local doesn't?",a:"The things that only exist once you deploy: the real migration running against a populated database, environment variables and secrets resolved the production way, the actual platform's networking and timeouts, and the deploy pipeline itself. Local runs against a tiny dev database and your own machine's config — staging runs the same pipeline you'll run for prod, so a green deploy there is real evidence prod will be green too."},{q:"How do I get a build from staging to production?",a:"Promote the exact artifact you validated rather than rebuilding for prod. Run the migration on staging first, confirm the service is healthy, then promote that same build to production and run the same migration there. Because staging already rehearsed every step, the production deploy is a repeat of something that just worked — not a first attempt under pressure."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Xe,{size:26}),title:"Staging environment",meta:"About 30 minutes · a one-time environment to stand up",onBack:t,assistKey:"staging-environment"}),e.jsx("p",{className:"lead",children:"A staging environment is a full, prod-like copy of your service you can deploy to and exercise before anything reaches real users. It runs the same pipeline as production but has its own data and secrets — so a deploy there is a rehearsal, not a gamble."}),e.jsx("div",{className:"seclabel",children:"Make it prod-like, but isolated"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Give staging its own database and secrets.",children:"Never point staging at production data. Stand up a separate database — ideally seeded from a sanitized copy of prod so it's realistic — and a separate set of secrets, so anything you break on staging can't touch a real customer."}),e.jsx(A,{lead:"Run the same deploy pipeline as production.",children:"Deploy to staging with the exact build and release steps you'll use for prod. The value is in the sameness: if the pipeline is green on staging, that's real evidence it'll be green on production."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Rehearse the risky parts"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Run schema migrations on staging first.",children:"A migration against a populated database is where deploys most often go wrong. Run it on staging — with prod-like data volume — and you find the slow lock or the bad backfill before it's holding up real traffic."}),e.jsx(A,{lead:"Spin up a per-branch environment when you need one.",children:"For a risky change, an ephemeral environment built just for that branch lets you test it in isolation and tear it down afterward — the backend analog of a per-branch preview deploy."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to production"}),e.jsx(he,{children:e.jsx(A,{lead:"Ship the build you already validated.",children:"When staging is healthy, promote that same build to production rather than rebuilding. Run the migration on prod just as you rehearsed on staging — going live becomes a repeat of something that just worked."})}),e.jsx(ot,{items:a}),e.jsx(ye,{assistKey:"staging-environment",topicName:"Staging environment"}),e.jsx(we,{label:"I've set up a staging environment",note:"From here, every change can be deployed and exercised on staging — migrations and all — before you promote it to production.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const OL=Object.freeze(Object.defineProperty({__proto__:null,StagingEnvironmentScreen:Ff},Symbol.toStringTag,{value:"Module"}));function ho({onBack:t,onComplete:n,status:s,onRevert:r}){const a=[{q:"Will a pre-release accidentally become what everyone installs?",a:"Not if you publish it correctly. A plain install (`install pkg`) resolves the `latest` tag, and a pre-release is published under a different tag — `next` or `beta` — so it never moves `latest`. On top of that, a semver pre-release version like `1.2.0-rc.1` is excluded from normal version ranges by default, so a dependent on `^1.1.0` won't auto-adopt it. You have to opt in twice to get a pre-release, which is the whole point."},{q:"How does a tester actually get the pre-release?",a:"They opt in explicitly. For a package, that's installing the tag — `install pkg@next` — or pinning the exact pre-release version. For a binary, it's downloading the build attached to a GitHub pre-release rather than the latest stable release. Either way it's a deliberate choice, so the people on the pre-release channel are exactly the people who asked to test it."},{q:"How do I promote a pre-release to stable?",a:"When the pre-release has held up, cut the stable version (drop the `-rc.1` suffix, e.g. `1.2.0`) and publish it to `latest` — or mark the GitHub release as the latest, not a pre-release. Everyone on a normal install picks it up from there. The pre-release channel keeps running for the next round; promoting one build to stable doesn't shut it down."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Xe,{size:26}),title:"Pre-release channel",meta:"About 15 minutes · then one extra command per pre-release",onBack:t,assistKey:"pre-release-channel"}),e.jsxs("p",{className:"lead",children:["A pre-release lets people test the next version before it's stable — without changing what everyone gets by default. You publish it on a separate channel, testers opt in, and your ",e.jsx("code",{children:"latest"})," stays exactly where it is until you're ready to promote."]}),e.jsx("div",{className:"seclabel",children:"Publish on a separate channel"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Use a next / beta tag instead of latest.",children:["Publish the pre-release under a dist-tag like ",e.jsx("code",{children:"next"})," or"," ",e.jsx("code",{children:"beta"})," (npm), a ",e.jsx("code",{children:"--pre"})," flag on other registries, or a GitHub ",e.jsx("b",{children:"pre-release"})," for binaries. A normal install still resolves ",e.jsx("code",{children:"latest"}),", so the default install is untouched."]}),e.jsxs(A,{lead:"Tag a semver pre-release version.",children:["Version it with a pre-release identifier — ",e.jsx("code",{children:"1.2.0-rc.1"}),","," ",e.jsx("code",{children:"1.2.0-beta.2"}),". Semver excludes these from ordinary version ranges, so a dependent on ",e.jsx("code",{children:"^1.1.0"})," won't pull it in by accident. It takes a deliberate opt-in to land on a pre-release."]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Let testers opt in"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Tell testers the one install command.",children:["A tester installs the channel explicitly — ",e.jsx("code",{children:"install pkg@next"})," ","— or downloads the build attached to the GitHub pre-release. The people on the channel are exactly the ones who asked to be there."]}),e.jsx(A,{lead:"Gather feedback before it's everyone's problem.",children:"Because the pre-release reaches only opt-in testers, a rough edge gets caught by people who expect a rough edge — not by your whole user base on a normal install."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to stable"}),e.jsx(he,{children:e.jsxs(A,{lead:"Cut the stable version when it holds up.",children:["Drop the pre-release suffix (",e.jsx("code",{children:"1.2.0-rc.1"})," →"," ",e.jsx("code",{children:"1.2.0"}),") and publish it to ",e.jsx("code",{children:"latest"}),", or mark the GitHub release as latest. Everyone on a normal install picks it up — and the channel stays open for the next round."]})}),e.jsx(ot,{items:a}),e.jsx(ye,{assistKey:"pre-release-channel",topicName:"Pre-release channel"}),e.jsx(we,{label:"I've set up a pre-release channel",note:"From here, testers can opt into the next version on its own tag while your latest stays stable until you promote.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const AL=Object.freeze(Object.defineProperty({__proto__:null,PreReleaseScreen:ho},Symbol.toStringTag,{value:"Module"}));function ke(t,n){return["You are helping inside my actual codeyam project — this is real work in a real repository, not a hypothetical.","Before doing anything, read `.codeyam/stack.json` and the relevant source and config files so your help fits this project's stack. Prefer concrete edits and commands over generic advice.","",`I want to set up **${t}**. ${n}`,"","Walk me through it and make the changes you safely can in my project, asking me before anything destructive."].join(`
|
|
103
|
+
`)}const L2={"staging-preview":{Icon:Xe,title:"Staging & preview deploys",crumbLabel:"Staging & previews",meta:"Recommended · about 5 minutes",lead:"Get a private link for every change before it goes public. You (or a teammate) can open the app exactly as it will ship, try it, and share it for feedback — without touching what real visitors see.",journey:[{emoji:"🧪",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"Share and try it",lime:!0},{emoji:"🚀",label:"Ship it",sub:"Only once it's right"}],chatPrompt:ke("staging & preview deploys","I want a private preview URL for each change and a staging environment I can share before anything goes public."),faqs:[{q:"How is a preview different from the live app?",a:"A preview is a private copy of one specific change, at its own link. Real visitors never see it — you use it to check and share a change before it becomes the live app everyone sees."},{q:"Do I need a separate staging environment too?",a:"A per-change preview covers most feedback. A longer-lived staging environment is useful when you want a stable, shareable place that mirrors production for testing over time — you can have both."},{q:"Will previews affect real data?",a:"No. Previews are isolated, so trying things in one can't change what real visitors see or the data they rely on."}]},"custom-domain":{Icon:ln,title:"Custom domain",meta:"Optional · about 10 minutes",lead:"Put your app on your own web address instead of the default link. Visitors see a name that's yours — easier to remember, trust, and share.",journey:[{emoji:"🔗",label:"Default link",sub:"Works, but generic"},{emoji:"🌐",label:"Your domain",sub:"yourname.com",lime:!0},{emoji:"🤝",label:"People trust it",sub:"Easy to remember"}],chatPrompt:ke("a custom domain","I want my app to live on my own web address. Help me point a domain I own (or pick one) at my app and set it up so it loads securely."),faqs:[{q:"Do I need to buy a domain first?",a:"Yes — you register the name you want with any domain registrar (usually a few dollars a year). After that, you point it at your app once and it's live on your address."},{q:"Is it secure (https)?",a:"Yes. A security certificate is set up for your domain automatically, so visitors get the padlock and an encrypted connection with nothing to manage."},{q:"Can I keep the old link too?",a:"Yes. The default link keeps working; your custom domain is an additional, friendlier front door."}]},accounts:{Icon:Ge,title:"Accounts & sign-in",meta:"Foundation · about 10 minutes",lead:"Let people create an account and sign in safely, so the app can remember who they are and keep each person's things private to them.",journey:[{emoji:"🙋",label:"A visitor",sub:"Anonymous"},{emoji:"🔑",label:"Signs in",sub:"Safely, once",lime:!0},{emoji:"🗂️",label:"Their own space",sub:"Private to them"}],chatPrompt:ke("accounts & sign-in","I want people to be able to sign up and log in securely, so the app knows who each person is and keeps their data private."),faqs:[{q:"Do I have to handle passwords myself?",a:"No. Sign-in is handled by a trusted service, so passwords are stored and checked securely for you — you never keep raw passwords, and you can offer options like email links or Google sign-in."},{q:"How does the app keep one person's data private?",a:"Once someone signs in, the app knows which records are theirs and only shows those. Access rules enforce it, so one person can never see another's information."},{q:"Can people sign in with Google or email?",a:"Yes. You can offer several ways to sign in — email link, password, or providers like Google — and add more later without changing the rest of the app."}]},emails:{Icon:Jn,title:"Sending emails",meta:"Recommended · about 5 minutes",lead:"Send the everyday emails an app needs — a welcome, a password reset, a receipt — reliably, so they land in the inbox instead of spam.",journey:[{emoji:"⚡",label:"Something happens",sub:"A signup, a reset"},{emoji:"✉️",label:"An email is sent",sub:"Automatically",lime:!0},{emoji:"📥",label:"In their inbox",sub:"Not spam"}],chatPrompt:ke("sending emails","I want my app to send transactional emails (welcome, password reset, receipts) reliably so they reach the inbox."),faqs:[{q:"Why not just send email from my own server?",a:"Mail sent that way usually lands in spam. A dedicated sending service builds the reputation and authentication that gets your emails delivered to the inbox."},{q:"What emails will my app actually send?",a:"The common ones: a welcome or verification message, password resets, and receipts or notifications. You add more as your app grows."},{q:"Can I design how the emails look?",a:"Yes. Emails use templates you can style to match your app, with the person's details filled in automatically."}]},payments:{Icon:Jt,title:"Accept payments",meta:"Optional · about 15 minutes",lead:"Charge for your product or service safely. People pay with a card and the money reaches you — you never handle or store card numbers yourself.",journey:[{emoji:"🛒",label:"They want to buy",sub:"Product or plan"},{emoji:"💳",label:"Pay securely",sub:"Card handled for you",lime:!0},{emoji:"💰",label:"You get paid",sub:"Money reaches you"}],chatPrompt:ke("accepting payments","I want to charge for my product or service — one-off payments or subscriptions — with card details handled securely by a payment provider."),faqs:[{q:"Is it safe to take card payments?",a:"Yes. A payment provider collects and stores the card details on secure, certified systems. Your app never sees or stores a card number, which keeps you safe and compliant."},{q:"One-off payments or subscriptions?",a:"Both. You can charge once for a purchase or set up recurring subscriptions — the provider handles renewals, receipts, and failed-payment retries."},{q:"What does it cost?",a:"Providers take a small percentage per transaction with no monthly fee to start, so you only pay when you actually get paid."}]},"analytics-monitoring":{Icon:Tt,title:"Analytics & monitoring",crumbLabel:"Analytics",meta:"Recommended · about 5 minutes",lead:"See how people use your app and catch errors early. Instead of guessing, you get simple numbers on what's used — and an alert when something breaks.",journey:[{emoji:"👀",label:"People use the app",sub:"Every day"},{emoji:"📊",label:"You see what happens",sub:"Usage and errors",lime:!0},{emoji:"🛠️",label:"Fix it early",sub:"Before it spreads"}],chatPrompt:ke("analytics & monitoring","I want to see how people use my app and get alerted when errors happen, so I can catch problems early."),faqs:[{q:"What's the difference between analytics and monitoring?",a:"Analytics tells you what people do — which pages and features they use. Monitoring watches for errors and slowdowns and alerts you when something breaks. You usually want both."},{q:"Is this respectful of privacy?",a:"You can use privacy-friendly analytics that measure usage without tracking individuals, and keep error reports free of personal data. It's about patterns, not spying."},{q:"Will it slow my app down?",a:"No. These tools are lightweight and load in the background, so visitors don't notice them."}]},"database-backups":{Icon:mt,title:"Data backups & deletion",crumbLabel:"Backups & deletion",meta:"Recommended · about 10 minutes",lead:"Keep safe copies of your data so nothing is lost, and be able to honor a person's request to export or delete their information.",journey:[{emoji:"🗄️",label:"Your data",sub:"The real thing"},{emoji:"💾",label:"Backed up",sub:"Safe copies",lime:!0},{emoji:"♻️",label:"Restore or delete",sub:"On request"}],chatPrompt:ke("data backups & deletion","I want regular backups of my data plus a way to export or delete a person's information when they ask (GDPR/CCPA)."),faqs:[{q:"How often should I back up?",a:"Automatic daily backups cover most apps, with the ability to restore to a recent point if something goes wrong. Keep your own periodic export too, especially on free tiers."},{q:"Why do I need export and delete?",a:"Privacy laws like GDPR and CCPA give people the right to get a copy of their data or have it deleted. Being able to honor those requests keeps you compliant and trustworthy."},{q:"Does deleting one person's data break anything?",a:"Handled properly, no. Their records are removed while shared data stays intact, so the app keeps working for everyone else."}]},legal:{Icon:Be,title:"Privacy & legal",meta:"Recommended · about 10 minutes",lead:"Give your app the basics it needs to be trustworthy and above-board: a privacy policy and terms, written in plain language, that say what you collect and how you use it.",journey:[{emoji:"❓",label:"What do you collect?",sub:"People wonder"},{emoji:"📄",label:"Privacy & terms",sub:"Clear answers",lime:!0},{emoji:"✅",label:"Trusted & compliant",sub:"Above board"}],chatPrompt:ke("privacy & legal","I want a plain-language privacy policy and terms of service that match what my app actually collects and does."),faqs:[{q:"Do I really need a privacy policy?",a:"If your app collects any personal data — even just emails — most laws and app stores require one. It also builds trust by being upfront about what you do with people's information."},{q:"Can I just copy someone else's?",a:"It's better to generate one that matches what your app actually collects and uses. A copied policy that doesn't fit your app can be misleading and legally risky."},{q:"Is this legal advice?",a:"No — these are sensible defaults to get you started. For anything high-stakes, have a professional review the final wording."}]},forms:{Icon:Be,title:"Forms",meta:"Optional · about 5 minutes",lead:"Collect what people type — a contact message, a signup, feedback — and make sure it actually reaches you, cleanly and without spam.",journey:[{emoji:"⌨️",label:"They fill it in",sub:"A message, a signup"},{emoji:"📨",label:"It reaches you",sub:"Clean, no spam",lime:!0},{emoji:"📬",label:"You follow up",sub:"Nothing lost"}],chatPrompt:ke("forms","I want the forms in my app (contact, signup, feedback) to reliably deliver what people submit to me, with basic validation and spam protection."),faqs:[{q:"Where do form submissions go?",a:"You choose — an email to you, a saved record, or both. The important part is that nothing gets silently dropped."},{q:"How do I keep out spam?",a:"Basic protection like a hidden check or a light challenge blocks most automated spam without annoying real people."},{q:"Can I require certain fields?",a:"Yes. Validation makes sure required fields are filled and formatted correctly before a submission goes through, so you get usable information."}]},"data-safety":{Icon:Ge,title:"Data safety",meta:"Recommended · about 10 minutes",lead:"Be clear and careful about the information your app handles: collect only what you need, keep it protected, and be able to explain exactly what you store and why.",journey:[{emoji:"📥",label:"You collect data",sub:"Only what's needed"},{emoji:"🔒",label:"Kept protected",sub:"Access controlled",lime:!0},{emoji:"📋",label:"Explained clearly",sub:"Nothing hidden"}],chatPrompt:ke("data safety","I want to review what personal data my app collects and stores, minimize it, protect it, and be able to declare it clearly (e.g. for an app store data-safety form)."),faqs:[{q:"What counts as sensitive data?",a:"Anything that identifies a person — names, emails, location, payment details — plus anything private they share. The safest rule is to collect only what your app truly needs."},{q:"Why declare what I collect?",a:"App stores and privacy laws expect an honest summary of what you collect and why. A clear declaration builds trust and avoids removal or fines."},{q:"How is the data protected?",a:"It's encrypted in transit and at rest, and access rules limit who and what can read it — so even stored data isn't freely readable."}]},secrets:{Icon:Ge,title:"Secrets & API keys",crumbLabel:"Secrets",meta:"Foundation · about 5 minutes",lead:"Keep the keys and passwords your app depends on out of the code and in a safe place, so they're never exposed and easy to rotate.",journey:[{emoji:"🔑",label:"Keys & passwords",sub:"Your app needs them"},{emoji:"🗝️",label:"In a safe store",sub:"Never in code",lime:!0},{emoji:"🔄",label:"Easy to rotate",sub:"One place to change"}],chatPrompt:ke("secrets & API keys","I want my app's secrets (API keys, tokens, passwords) kept out of the code in a secure store, and easy to rotate."),faqs:[{q:"Why can't I just put keys in the code?",a:"Anything in the code can leak — through your repository, your build, or the browser. Secrets belong in a separate secure store the app reads at runtime, never in the source."},{q:"What is 'rotating' a key?",a:"Replacing a secret with a fresh one — routine hygiene, or urgent if one leaks. When secrets live in one store, rotating is a single change with no code edit."},{q:"Do different environments need different keys?",a:"Usually yes. Test and production use separate keys so a mistake in testing can't touch real data or real charges."}]},publish:{Icon:Xe,title:"Publish & go live",meta:"Foundation · about 10 minutes",lead:"Take your app from running only on your machine to a real link anyone can open. You don't need to understand servers — it's set up for you.",journey:[{emoji:"💻",label:"Your computer",sub:"Only you can see it"},{emoji:"☁️",label:"Published",sub:"A home online",lime:!0},{emoji:"🌍",label:"Anyone, anywhere",sub:"Opens with a link"}],chatPrompt:ke("publishing my app","I want to put my app online so anyone can open it with a link."),faqs:[{q:"Do I need to understand servers?",a:"No. Publishing is handled for you — you connect a host once and your app goes live on a link, with nothing to run or maintain yourself."},{q:"Is there a cost to publish?",a:"You can start on a free tier that comfortably covers a new app. You only pay once it grows, and you'll see it coming."},{q:"Can I use my own web address?",a:"Yes. You launch on a free link today and can add a custom domain whenever you like."}]},"analytics-seo":{Icon:ln,title:"Analytics & SEO",meta:"Recommended · about 10 minutes",lead:"Help people find your app and understand what they do once they arrive. Good SEO gets you into search results; analytics shows you what's working.",journey:[{emoji:"🔎",label:"People search",sub:"For what you offer"},{emoji:"📈",label:"Found & measured",sub:"Ranked and tracked",lime:!0},{emoji:"🎯",label:"You improve",sub:"Based on real data"}],chatPrompt:ke("analytics & SEO","I want my app to show up well in search results and to see how visitors find and use it."),faqs:[{q:"What actually helps SEO?",a:"Clear titles and descriptions, fast pages, sensible links, and a sitemap search engines can read. Most of it is set-and-forget once configured."},{q:"How is this different from analytics-only?",a:"SEO is about being found; analytics is about understanding what happens after. Together they close the loop from discovery to improvement."},{q:"Can I do this privately?",a:"Yes. Privacy-friendly analytics measure traffic and behavior in aggregate without tracking individuals."}]},"comments-search":{Icon:mt,title:"Comments & search",meta:"Optional · about 15 minutes",lead:"Let people discuss your content and find things quickly. Comments add a conversation; search helps visitors get to what they want in seconds.",journey:[{emoji:"📚",label:"Lots of content",sub:"Hard to navigate"},{emoji:"🔍",label:"Search & comments",sub:"Find and discuss",lime:!0},{emoji:"💬",label:"People engage",sub:"And stick around"}],chatPrompt:ke("comments & search","I want visitors to be able to search my content and leave comments."),faqs:[{q:"Do I have to build search myself?",a:"No. A search service indexes your content and returns fast, typo-tolerant results, which is far better than a hand-rolled search."},{q:"How do I keep comments civil?",a:"You can require sign-in, add moderation, and filter spam, so the conversation stays useful without constant babysitting."},{q:"Will search slow my app down?",a:"No. Search runs on a dedicated service, so results are fast even as your content grows."}]},"performance-images":{Icon:Xe,title:"Performance & images",crumbLabel:"Performance",meta:"Recommended · about 10 minutes",lead:"Make your app fast, especially its images. Faster pages feel better, keep people around, and rank higher — and images are usually the biggest win.",journey:[{emoji:"🐌",label:"Heavy pages",sub:"Slow to load"},{emoji:"🗜️",label:"Optimized",sub:"Right-sized images",lime:!0},{emoji:"⚡",label:"Fast for everyone",sub:"On any device"}],chatPrompt:ke("performance & images","I want my app to load fast — especially by optimizing and right-sizing images and cutting anything that slows pages down."),faqs:[{q:"Why are images such a big deal?",a:"Images are usually the heaviest thing on a page. Right-sizing and compressing them, and loading them only when needed, is the single biggest speed win."},{q:"How do I know if my app is slow?",a:"A quick performance check gives you a score plus a prioritized list of fixes. Aim for the green range; chasing a perfect score rarely matters."},{q:"Will optimizing hurt image quality?",a:"No, when done right. Modern formats keep images looking sharp at a fraction of the size."}]},"background-jobs":{Icon:mt,title:"Background jobs",meta:"Optional · about 15 minutes",lead:"Do slow or scheduled work out of the way of the person waiting — sending a batch of emails, resizing uploads, running a nightly task — so the app stays snappy.",journey:[{emoji:"⏳",label:"Slow work",sub:"Blocks the user"},{emoji:"📮",label:"Queued",sub:"Runs in the background",lime:!0},{emoji:"✅",label:"Done later",sub:"App stays fast"}],chatPrompt:ke("background jobs","I want to run slow or scheduled work (emails, image processing, nightly tasks) in the background so requests stay fast."),faqs:[{q:"When do I need background jobs?",a:"Whenever work takes more than a moment — sending many emails, processing files, or anything on a schedule. Doing it inline makes people wait or times out."},{q:"What if a job fails?",a:"A queue retries failed jobs and keeps a record, so a temporary hiccup doesn't silently drop work."},{q:"Can I run tasks on a schedule?",a:"Yes. You can run jobs at set times — nightly cleanups, weekly digests — without anyone triggering them."}]},"logging-monitoring":{Icon:Tt,title:"Logging & monitoring",crumbLabel:"Logging",meta:"Recommended · about 10 minutes",lead:"Know what your app is doing and hear about problems fast. Logs record what happened; monitoring alerts you when something breaks or slows down.",journey:[{emoji:"🌫️",label:"Something breaks",sub:"You don't know"},{emoji:"📡",label:"Logged & watched",sub:"Alerts you fast",lime:!0},{emoji:"🔧",label:"You fix it",sub:"Before users notice"}],chatPrompt:ke("logging & monitoring","I want centralized logs and alerts so I hear about errors and slowdowns quickly and can trace what happened."),faqs:[{q:"Aren't logs just noise?",a:"Structured logs, searchable in one place, turn noise into answers — you can trace exactly what happened around an error instead of guessing."},{q:"What should alert me?",a:"Errors, crashes, and unusual slowness. Good alerting tells you about real problems without crying wolf."},{q:"Does this expose user data?",a:"It shouldn't. Logs are set up to avoid capturing personal or secret data, so they're safe to keep and search."}]},"cors-origins":{Icon:ln,title:"CORS & allowed origins",crumbLabel:"CORS",meta:"Foundation · about 5 minutes",lead:"Decide which websites are allowed to call your app's API. Set it too open and anyone can use your backend; too strict and your own site breaks.",journey:[{emoji:"🌐",label:"Requests arrive",sub:"From many sites"},{emoji:"🚦",label:"Origins checked",sub:"Allow the right ones",lime:!0},{emoji:"🛡️",label:"Safe & working",sub:"Your site only"}],chatPrompt:ke("CORS & allowed origins","I want to configure which origins are allowed to call my API — permissive enough for my own site, strict enough to keep others out."),faqs:[{q:"What is an 'origin'?",a:"The website an API request comes from. CORS rules say which origins your API will answer, so only your app (and any you approve) can use it from a browser."},{q:"Why not just allow everything?",a:"Allowing every origin lets any site call your API from a user's browser, which can be abused. Listing the ones you actually use is safer."},{q:"My site's requests are being blocked — why?",a:"Usually the origin isn't on the allow list, or a preflight check isn't handled. Adding your origin and allowing the right methods fixes it."}]},"api-auth":{Icon:Ge,title:"API authentication",crumbLabel:"API auth",meta:"Foundation · about 10 minutes",lead:"Make sure only the right callers can use your API. Each request proves who it is with a key or token, so your backend isn't open to the world.",journey:[{emoji:"📨",label:"A request",sub:"Who's calling?"},{emoji:"🎟️",label:"Proves identity",sub:"Key or token",lime:!0},{emoji:"✅",label:"Allowed in",sub:"Only if valid"}],chatPrompt:ke("API authentication","I want my API to require a key or token so only authorized callers can use it, with a safe way to issue and revoke access."),faqs:[{q:"Keys or tokens — what's the difference?",a:"An API key is a simple secret for server-to-server use. Tokens (like JWTs) carry identity and expire, which fits user-facing apps. Many APIs use both."},{q:"How do I revoke access?",a:"Issue credentials you can turn off individually, so if one leaks you disable just that key without affecting everyone else."},{q:"Is an API key enough on its own?",a:"For internal use, often yes. For sensitive actions, combine it with per-user permissions so a valid key can't do more than it should."}]},"deploy-target":{Icon:Tn,title:"Deploy target",meta:"Foundation · about 10 minutes",lead:"Choose where your app runs when it's live and wire it up once. After that, shipping an update is a single, repeatable step.",journey:[{emoji:"📦",label:"Your app",sub:"Ready to ship"},{emoji:"🎯",label:"A deploy target",sub:"Where it runs",lime:!0},{emoji:"🔁",label:"Ship anytime",sub:"One repeatable step"}],chatPrompt:ke("a deploy target","I want to pick where my app runs in production for my stack and set up a repeatable way to deploy to it."),faqs:[{q:"How do I pick a target?",a:"It depends on your stack — some hosts specialize in certain frameworks or containers. The goal is a place that runs your app well with the least setup."},{q:"What makes deploys repeatable?",a:"Wiring the target once so every deploy runs the same build and release steps, which removes surprises and lets you ship confidently."},{q:"Can I move hosts later?",a:"Yes, especially if your app is packaged in a standard way. Choosing a portable setup keeps your options open."}]},"deploy-previews":{Icon:Xe,title:"Deploy previews",meta:"Recommended · about 5 minutes",lead:"Get a private link for every change before it's public, so you can see the site exactly as it will ship and share it for feedback.",journey:[{emoji:"✏️",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"See it live",lime:!0},{emoji:"🚀",label:"Publish",sub:"Once it's right"}],chatPrompt:ke("deploy previews","I want a private preview link generated for each change so I can review and share the site before it goes public."),faqs:[{q:"How is a preview different from the live site?",a:"A preview is a private build of one change at its own link. Visitors never see it — it's for checking and sharing before it becomes the public site."},{q:"Do previews cost extra?",a:"Usually they're included with hosting and clean themselves up, so you get the safety net without ongoing cost or clutter."},{q:"Can I share a preview with a client?",a:"Yes. Send the preview link and they see the exact change, with no effect on the live site."}]},"staging-environment":{Icon:Tn,title:"Staging environment",crumbLabel:"Staging",meta:"Recommended · about 15 minutes",lead:"A full, prod-like copy of your app with its own data, where you can rehearse changes and migrations safely before promoting them to production.",journey:[{emoji:"🧱",label:"A real change",sub:"Risky in prod"},{emoji:"🏗️",label:"Try it in staging",sub:"Prod-like, own data",lime:!0},{emoji:"⬆️",label:"Promote",sub:"Confidently to prod"}],chatPrompt:ke("a staging environment","I want a production-like staging environment with its own data where I can rehearse changes and migrations before promoting to production."),faqs:[{q:"How is staging different from a preview?",a:"A preview is a throwaway link for one change. Staging is a stable, long-lived environment that mirrors production — ideal for testing data migrations and integrations over time."},{q:"Does staging need its own data?",a:"Yes. Separate, realistic data lets you rehearse safely without touching real users' information."},{q:"What does 'promote' mean?",a:"Moving a verified change from staging to production in a controlled step, so what you tested is exactly what ships."}]},"publish-registry":{Icon:mt,title:"Publish to a registry",crumbLabel:"Publish package",meta:"Foundation · about 10 minutes",lead:"Make your package installable by others. Publishing to a registry means anyone can add it to their project with a single install command.",journey:[{emoji:"📦",label:"Your package",sub:"On your machine"},{emoji:"🏷️",label:"Published",sub:"To a registry",lime:!0},{emoji:"⬇️",label:"Others install it",sub:"One command"}],chatPrompt:ke("publishing to a registry","I want to publish my package to the right registry for my ecosystem so others can install it, with sensible metadata and access set up."),faqs:[{q:"Which registry should I use?",a:"The standard one for your language or ecosystem, so people can install with the tool they already use. codeyam can pick the right one for your stack."},{q:"What metadata matters?",a:"A clear name, description, version, license, and links. Good metadata helps people find and trust your package."},{q:"Can I publish privately?",a:"Yes. Registries support private or scoped packages when you only want your team to install it."}]},"readme-license":{Icon:Be,title:"README & license",meta:"Foundation · about 10 minutes",lead:"Give your project the two things every visitor looks for first: a README that explains what it is and how to use it, and a license that says what people may do with it.",journey:[{emoji:"❓",label:"What is this?",sub:"Visitors wonder"},{emoji:"📖",label:"README & license",sub:"Clear answers",lime:!0},{emoji:"🤝",label:"People use it",sub:"With confidence"}],chatPrompt:ke("a README & license","I want a clear README that explains what my project is and how to use it, plus an appropriate open-source license."),faqs:[{q:"What should a README cover?",a:"What the project does, how to install and use it, a quick example, and where to get help. First-time visitors decide in seconds, so lead with the essentials."},{q:"Which license should I pick?",a:"It depends on how open you want to be. Permissive licenses let people do almost anything; copyleft ones require sharing changes. codeyam can suggest one for your goals."},{q:"Do I really need a license?",a:"Yes — without one, others legally can't reuse your code. A license removes that doubt and sets clear terms."}]},"semver-policy":{Icon:mt,title:"Versioning policy",crumbLabel:"Versioning",meta:"Foundation · about 5 minutes",lead:"Number your releases so people know what to expect. A clear policy tells users when an update is safe and when it might break something.",journey:[{emoji:"🔢",label:"You release",sub:"Again and again"},{emoji:"📐",label:"Versioned clearly",sub:"Major.minor.patch",lime:!0},{emoji:"😌",label:"Users upgrade safely",sub:"No surprises"}],chatPrompt:ke("a versioning policy","I want to adopt a clear version-numbering policy (like semver) so users know when an update is a safe fix versus a breaking change."),faqs:[{q:"What does major.minor.patch mean?",a:"Patch is a safe bug fix, minor adds features without breaking anything, and major may break existing use. The numbers set expectations at a glance."},{q:"When do I bump the major version?",a:"Only when you change or remove something people depend on. Reserving major bumps for real breaks keeps upgrades low-stress."},{q:"Do I have to follow semver exactly?",a:"It's the widely understood default, so following it means fewer surprises. You can adapt it, but document whatever policy you choose."}]},"versioning-changelog":{Icon:Be,title:"Versioning & changelog",crumbLabel:"Changelog",meta:"Recommended · about 5 minutes",lead:"Keep a running list of what changed in each release, so users can see what's new, what's fixed, and what to watch out for before they upgrade.",journey:[{emoji:"🔁",label:"You ship changes",sub:"Every release"},{emoji:"📝",label:"Recorded",sub:"In a changelog",lime:!0},{emoji:"👀",label:"Users know",sub:"What changed & why"}],chatPrompt:ke("a changelog","I want to maintain a clear changelog of what changes in each release so users can see what's new, fixed, or breaking."),faqs:[{q:"What goes in a changelog?",a:"Grouped notes per version — added, changed, fixed, and removed — written for the people who use your project, not raw commit messages."},{q:"Can it be generated automatically?",a:"Partly. Structured commits or release notes can draft the changelog for you; a human pass keeps it readable."},{q:"Why not just use commit history?",a:"Commits are for developers. A changelog is a curated, user-facing summary that's far easier to scan before upgrading."}]},"changelog-ci":{Icon:Be,title:"Changelog & CI",meta:"Recommended · about 10 minutes",lead:"Automate the boring parts of releasing: let your pipeline build, test, and assemble release notes so shipping a version is reliable and repeatable.",journey:[{emoji:"🧑💻",label:"You merge a change",sub:"That's the trigger"},{emoji:"🤖",label:"CI runs",sub:"Build, test, notes",lime:!0},{emoji:"🚀",label:"Released",sub:"Reliably, every time"}],chatPrompt:ke("changelog & CI","I want a CI pipeline that builds, tests, and helps assemble release notes so releasing a version is automated and reliable."),faqs:[{q:"What is CI, simply?",a:"Continuous integration: an automated pipeline that builds and tests every change, so problems are caught early and releases are consistent."},{q:"How does it help the changelog?",a:"CI can gather release notes from your changes and publish them alongside the build, so the changelog stays current without manual effort."},{q:"Is this overkill for a small project?",a:"Even a minimal pipeline that runs tests on every change pays off quickly by catching breakage before your users do."}]},"install-docs":{Icon:Be,title:"Install & usage docs",crumbLabel:"Docs",meta:"Recommended · about 10 minutes",lead:"Show people how to install and use your project, with copy-paste steps and a working example. Good docs are the difference between adoption and abandonment.",journey:[{emoji:"🤔",label:"How do I use this?",sub:"Newcomers ask"},{emoji:"📘",label:"Clear docs",sub:"Install & examples",lime:!0},{emoji:"🚀",label:"Up and running",sub:"In minutes"}],chatPrompt:ke("install & usage docs","I want clear installation and usage documentation with copy-paste steps and a working example so people can get started fast."),faqs:[{q:"What makes docs good?",a:"A fast path from zero to a working example, exact commands people can copy, and answers to the first questions they'll hit. Show, don't just tell."},{q:"How much is enough to start?",a:"Install, a minimal usage example, and one common task. You can expand as questions come in."},{q:"Where should docs live?",a:"Start in the README so they're the first thing visitors see; move to a docs site once there's more than a page or two."}]},examples:{Icon:mt,title:"Examples",meta:"Optional · about 10 minutes",lead:"Give people runnable examples that show your project solving real tasks. A working sample teaches faster than paragraphs of explanation.",journey:[{emoji:"📄",label:"Just docs",sub:"Abstract"},{emoji:"🧩",label:"Runnable examples",sub:"Real tasks",lime:!0},{emoji:"💡",label:"It clicks",sub:"People get it fast"}],chatPrompt:ke("examples","I want a set of runnable examples that show my project solving real tasks, so people learn it by seeing it work."),faqs:[{q:"How many examples do I need?",a:"A few that cover the most common uses beat a dozen niche ones. Start with the tasks people ask about most."},{q:"Should examples be runnable?",a:"Ideally yes — a sample people can run and tweak teaches far faster than a snippet they have to assemble themselves."},{q:"Where do examples belong?",a:"In an examples folder or a docs section, linked from the README so newcomers find them immediately."}]},"release-builds":{Icon:Xe,title:"Release builds",meta:"Foundation · about 10 minutes",lead:"Turn your source into the finished artifacts people actually download and run — for each platform — in a repeatable, trustworthy way.",journey:[{emoji:"🧾",label:"Your source",sub:"Not yet packaged"},{emoji:"🏭",label:"Built for release",sub:"Every platform",lime:!0},{emoji:"⬇️",label:"People run it",sub:"Ready to download"}],chatPrompt:ke("release builds","I want a repeatable way to produce release artifacts for each platform my project targets, ready for people to download and run."),faqs:[{q:"Why not just share the source?",a:"Most users want something ready to run, not to build it themselves. Release builds give them a finished artifact for their platform."},{q:"How do I build for multiple platforms?",a:"An automated pipeline can produce builds for each target in one go, so you don't need every platform on your own machine."},{q:"How do people trust a build?",a:"Publishing checksums or signatures lets people verify a download is genuine and unmodified."}]},"shell-completions":{Icon:Un,title:"Shell completions",crumbLabel:"Completions",meta:"Optional · about 5 minutes",lead:"Let your command-line tool autocomplete its own commands and options, so users tab through it instead of memorizing flags.",journey:[{emoji:"⌨️",label:"They type",sub:"And guess flags"},{emoji:"⇥",label:"Tab completes",sub:"Commands & options",lime:!0},{emoji:"😎",label:"Faster, no memorizing",sub:"It just flows"}],chatPrompt:ke("shell completions","I want my CLI to provide tab-completion for its commands and options across common shells, with simple install instructions."),faqs:[{q:"Which shells should I support?",a:"The common ones your users have — typically bash, zsh, and fish. Most CLI frameworks can generate completions for all of them."},{q:"How do users enable them?",a:"Usually one command that installs the completion file for their shell. Clear instructions make it a one-time step."},{q:"Do completions stay in sync with my commands?",a:"When generated from your CLI's own definitions, yes — they update as your commands change, so they never drift."}]},"cli-ux":{Icon:Un,title:"CLI experience",crumbLabel:"CLI UX",meta:"Recommended · about 10 minutes",lead:"Make your command-line tool a pleasure to use: clear help, helpful errors, sensible defaults, and output that reads well. Good CLI UX earns loyal users.",journey:[{emoji:"😕",label:"Cryptic tool",sub:"Confusing errors"},{emoji:"✨",label:"Polished CLI",sub:"Clear help & output",lime:!0},{emoji:"❤️",label:"Users love it",sub:"And recommend it"}],chatPrompt:ke("the CLI experience","I want to polish my CLI's usability — clear help text, helpful error messages, sensible defaults, and readable output."),faqs:[{q:"What separates a good CLI from a bad one?",a:"Discoverable help, errors that say how to fix the problem, sensible defaults, and output that's easy to read or pipe. Small touches add up."},{q:"Should output be colored?",a:"Color helps readability but should degrade gracefully when piped or unsupported, so scripts and plain terminals still work."},{q:"How important are good error messages?",a:"Very. An error that names the problem and the fix turns a frustrated user into a productive one."}]},"supply-chain":{Icon:Ge,title:"Supply-chain security",crumbLabel:"Supply chain",meta:"Recommended · about 10 minutes",lead:"Keep the code you depend on trustworthy. Know what's in your dependencies, catch known vulnerabilities, and make sure what you ship is what you built.",journey:[{emoji:"📥",label:"Dependencies",sub:"Code you didn't write"},{emoji:"🔍",label:"Checked & pinned",sub:"Scanned for risk",lime:!0},{emoji:"🛡️",label:"Trustworthy ship",sub:"What you built"}],chatPrompt:ke("supply-chain security","I want to know what's in my dependencies, catch known vulnerabilities, pin versions, and verify that what I ship is what I built."),faqs:[{q:"Why worry about dependencies?",a:"Most of your app is code you didn't write. A vulnerability or tampered package upstream becomes your problem, so keeping an eye on them matters."},{q:"How do I catch vulnerabilities?",a:"Automated scanning flags known issues in your dependencies and suggests safe upgrades, ideally on every change."},{q:"What does 'pinning' mean?",a:"Locking exact dependency versions so builds are reproducible and a surprise update can't quietly change what you ship."}]},"pre-release-channel":{Icon:Xe,title:"Pre-release channel",crumbLabel:"Pre-release",meta:"Optional · about 10 minutes",lead:"Give testers a next/beta version to opt into, so you can trial changes with willing users before they reach everyone on the stable release.",journey:[{emoji:"🧪",label:"A risky change",sub:"Needs real testing"},{emoji:"📡",label:"Beta channel",sub:"Opt-in testers",lime:!0},{emoji:"✅",label:"Then stable",sub:"For everyone"}],chatPrompt:ke("a pre-release channel","I want a next/beta channel that testers can opt into, so I can trial changes before promoting them to the stable release."),faqs:[{q:"How is a beta channel different from just releasing?",a:"Only users who opt in get pre-releases, and the stable channel keeps moving separately — so testing new changes never disrupts everyone else."},{q:"Who uses pre-releases?",a:"Willing testers and power users who want early features and don't mind rough edges, giving you real feedback before a wide launch."},{q:"Does this move my 'latest'?",a:"No. Pre-releases are tagged separately, so people installing the default still get the stable version."}]},"pre-release-versions":{Icon:Xe,title:"Pre-release versions",crumbLabel:"Pre-release",meta:"Optional · about 10 minutes",lead:"Publish next/beta versions of your package that testers can install on purpose, without moving the default that everyone else gets.",journey:[{emoji:"🧪",label:"A new version",sub:"Not ready for all"},{emoji:"🏷️",label:"Tagged pre-release",sub:"Opt-in install",lime:!0},{emoji:"✅",label:"Promote to latest",sub:"When it's proven"}],chatPrompt:ke("pre-release versions","I want to publish beta/next versions of my package under a separate tag so testers can opt in without changing what the default install gets."),faqs:[{q:"How do testers get a pre-release?",a:"They install a specific tag (like `next` or `beta`) on purpose. The plain install keeps returning your stable version."},{q:"How do I mark a version as pre-release?",a:"Use a pre-release version number and publish it under a separate tag, so registries don't treat it as the latest stable."},{q:"When do I promote it?",a:"Once it's proven with testers, you republish it as the stable latest — the same build, now the default."}]}},D2={"real-data":Dm,accounts:Ym,emails:Jm,payments:Zm,"analytics-monitoring":ef,legal:tf,"data-safety":cf,publish:of,"custom-domain":lf,forms:df,"analytics-seo":uf,"redirects-404":hf,"performance-images":pf,"comments-search":mf,"publish-registry":gf,"versioning-changelog":bf,"install-docs":xf,"release-builds":yf,"shell-completions":vf,"cli-ux":jf,"api-docs":kf,examples:_f,"semver-policy":Nf,"readme-license":Cf,"supply-chain":wf,"changelog-ci":Tf,"deploy-target":Pf,"database-backups":Of,secrets:Ef,"api-auth":Mf,"cors-origins":If,"background-jobs":Lf,"logging-monitoring":Df,"staging-preview":uo,"deploy-previews":uo,"staging-environment":Ff,"pre-release-channel":ho,"pre-release-versions":ho};function zf({onBack:t,topicKey:n,topicName:s,topicDesc:r}){const a=(s==null?void 0:s.trim())||"This setup step",o=(r==null?void 0:r.trim())||"There isn't a guided screen for this step here yet. You can still set it up — check the project's setup notes — and we'll add a walkthrough soon.";return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Ii,{size:26}),title:a,meta:"Guided screen coming soon",onBack:t,assistKey:n??""}),e.jsx("p",{className:"lead",children:o}),e.jsx("div",{className:"cta-wrap",children:e.jsx("button",{type:"button",className:"cta",onClick:t,children:"Back to Setup"})})]})}function $f({topicKey:t,topicName:n,topicDesc:s,isBackend:r=!1,onBack:a,onComplete:o,onChatWithAI:i}){const c=L2[t];if(c)return e.jsx(Pi,{icon:e.jsx(c.Icon,{size:26}),title:c.title,crumbLabel:c.crumbLabel,meta:c.meta,assistKey:t,onBack:a,lead:c.lead,illustration:Di(t)??e.jsx(Zt,{nodes:c.journey}),chatPrompt:c.chatPrompt,onChatWithAI:i,faqs:c.faqs});const d=t==="api-docs"&&r?Sf:D2[t];return d?e.jsx(d,{onBack:a,onComplete:()=>o==null?void 0:o(t),onChatWithAI:i}):e.jsx(zf,{onBack:a,topicKey:t,topicName:n,topicDesc:s})}const RL=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPlaceholder:zf,SetupTopicRouter:$f},Symbol.toStringTag,{value:"Module"}));function Bf({onBack:t}){const{concepts:n}=Om(),[s,r]=l.useState(""),[a,o]=l.useState(null),i=l.useMemo(()=>{const c=s.trim().toLowerCase();return!c||!n?n??[]:n.filter(d=>[d.term,d.category,...d.aka].join(" ").toLowerCase().includes(c))},[n,s]);return e.jsxs("div",{className:"learn-screen concepts-glossary",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"What these words mean"})]}),e.jsx("div",{className:"h",children:"What these words mean"}),e.jsx("div",{className:"hsub",children:"Plain-language explainers for the terms you'll run into while setting up your app. No jargon — just what each thing is, whether you need it, and what it costs."}),e.jsx("input",{type:"search",className:"concept-search",placeholder:"Search terms…",value:s,onChange:c=>r(c.target.value),"aria-label":"Search terms"}),e.jsx("div",{className:"tlist",children:n===null?Array.from({length:6}).map((c,d)=>e.jsx("div",{className:"trow soon","aria-hidden":"true",children:e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:" "}),e.jsx("div",{className:"td",children:" "})]})},d)):i.length===0?e.jsxs("div",{className:"concept-empty",children:['No terms match "',s,'".']}):i.map(c=>{const d=a===c.key;return e.jsxs("div",{className:"concept-row",children:[e.jsxs("button",{type:"button",className:"trow soon","aria-expanded":d,onClick:()=>o(d?null:c.key),children:[e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:c.term}),c.category?e.jsx("div",{className:"td",children:c.category}):null]}),e.jsx("span",{className:"arrow",children:d?"−":"+"})]}),d?e.jsx("div",{className:"concept-row-body",children:e.jsx(Bt,{variant:"compact",children:c.body})}):null]},c.key)})})]})}const EL=Object.freeze(Object.defineProperty({__proto__:null,ConceptsGlossaryScreen:Bf},Symbol.toStringTag,{value:"Module"})),vs="your-app.vercel.app",F2=[{key:"connect",label:"Connect"},{key:"deploying",label:"Deploy"},{key:"live",label:"Go live"}];function Vi({onBack:t}){return e.jsx(pe,{icon:e.jsx(Tn,{size:26}),title:"Hosting & going live",crumbLabel:"Hosting",meta:"Foundation · about 10 minutes",onBack:t,assistKey:"hosting"})}function Yn({stage:t}){return e.jsx(Yt,{steps:F2,currentKey:t})}const ML=Object.freeze(Object.defineProperty({__proto__:null,FlowBar:Yn,HSHeader:Vi,HS_URL:vs},Symbol.toStringTag,{value:"Module"}));function z2(){const[t,n]=l.useState(null);return l.useEffect(()=>{let s=!1;return(async()=>{try{const r=await fetch("/api/hosting-target");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();s||n(a)}catch{s||n(null)}})(),()=>{s=!0}},[]),{target:t}}function Hf({onBack:t,onSetup:n}){const{target:s}=z2(),r=(s==null?void 0:s.detectedHost)??null;return e.jsxs(e.Fragment,{children:[e.jsx(Vi,{onBack:t}),e.jsxs("p",{className:"lead",children:["Right now your app only runs on ",e.jsx("b",{children:"your computer"}),". Hosting puts it online so anyone can open it with a link, like renting a small plot of land where your app lives."]}),e.jsx("p",{className:"lead dim",children:"You don't need to understand servers. We'll set it up for you and explain each step in plain language."}),e.jsx(Ph,{}),r&&e.jsxs("div",{className:"hosting-detected",role:"note",children:[e.jsxs("div",{className:"hosting-detected-title",children:["This project is already configured for ",e.jsx("b",{children:r.name})]}),e.jsxs("div",{className:"hosting-detected-detail",children:["We found ",e.jsx("code",{children:r.evidence})," in your project — let's use"," ",r.name,".",(s==null?void 0:s.buildCommand)&&e.jsxs(e.Fragment,{children:[" ","It builds with ",e.jsx("code",{children:s.buildCommand}),s.outputDir&&e.jsxs(e.Fragment,{children:[" ","into ",e.jsx("code",{children:s.outputDir})]}),"."]})]})]}),e.jsx("div",{className:"seclabel",children:r?"Or start fresh with our recommendation":"Recommended for your app"}),e.jsxs("div",{className:"provcard best",children:[e.jsx(Dr,{}),e.jsxs("div",{className:"provbody",children:[e.jsxs("div",{className:"provtop",children:[e.jsx("span",{className:"provname",children:"Vercel"}),e.jsx("span",{className:"bestfit",children:"Best fit"})]}),e.jsx("div",{className:"provdesc",children:"Free to start, fast, and it works the way your app is already built. Most people in your spot pick this."}),e.jsx(Oh,{}),e.jsx(Ah,{})]})]}),e.jsx(Rh,{}),e.jsxs("div",{className:"cta-wrap",children:[e.jsxs("button",{type:"button",className:"cta",onClick:n,children:[e.jsx("span",{className:"ce",children:"☁️"})," Set up hosting with Vercel"]}),e.jsx("div",{className:"cta-note",children:"We'll walk you through every step. Nothing goes live until you say so."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),e.jsx(Eh,{}),e.jsx(Mh,{}),e.jsx(ye,{assistKey:"hosting",topicName:"Hosting & going live"})]})}const IL=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewGuided:Hf},Symbol.toStringTag,{value:"Module"}));function qf({onBack:t,onContinue:n,tokenMode:s=!1}){const[r,a]=l.useState("");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Connect Vercel"})]}),e.jsx(Yn,{stage:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:"🔗 Connect your Vercel account"}),e.jsx("div",{className:"psub",children:"This is a free account that holds your live app. If you don't have one yet, you'll make it in a few clicks, no setup required."}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(Dr,{}),e.jsxs("div",{children:[e.jsx("div",{className:"cbt",children:"Sign in with Vercel"}),e.jsx("div",{className:"cbd",children:s?"Paste a Vercel access token to deploy your real app.":"We'll open Vercel in a new tab and bring you right back."})]})]}),s?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"real-token-label",htmlFor:"hosting-token",children:"Vercel access token"}),e.jsx("input",{id:"hosting-token",type:"password",className:"real-token-input",placeholder:"Paste your Vercel token",value:r,onChange:o=>a(o.target.value)}),e.jsxs("button",{type:"button",className:"auth-btn",disabled:r.trim().length===0,onClick:()=>n(r.trim()),children:[e.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})}),"Deploy with Vercel"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grant",children:[e.jsxs("div",{className:"grantrow",children:[e.jsx(Qe,{color:"var(--blue-300)"}),e.jsx("span",{children:"Create one project to hold your app"})]}),e.jsxs("div",{className:"grantrow",children:[e.jsx(Qe,{color:"var(--blue-300)"}),e.jsx("span",{children:"Publish updates when you choose to go live"})]}),e.jsxs("div",{className:"grantrow",children:[e.jsx(Qe,{color:"var(--blue-300)"}),e.jsx("span",{children:"Nothing else. We can't touch your other accounts or files"})]})]}),e.jsxs("button",{type:"button",className:"auth-btn",onClick:()=>n(),children:[e.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})}),"Continue with Vercel"]}),e.jsxs("div",{className:"auth-row",children:[e.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>n(),children:"I already have an account"}),e.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>n(),children:"Create one for me"})]})]})]}),e.jsx("div",{className:"reassure",children:"🔒 We only ask for what's needed to put this one app online. You can disconnect at any time from settings."})]})]})}const LL=Object.freeze(Object.defineProperty({__proto__:null,HostingConnectStep:qf},Symbol.toStringTag,{value:"Module"})),Ys=["Packaging up your app","Uploading it to Vercel","Giving it a web address","Turning it on"],Mc=1100,$2=700;function Wf({onDone:t}){const[n,s]=l.useState(0),r=l.useRef(t);r.current=t,l.useEffect(()=>{const o=[];for(let i=1;i<=Ys.length;i++)o.push(setTimeout(()=>s(i),i*Mc));return o.push(setTimeout(()=>r.current(),Ys.length*Mc+$2)),()=>o.forEach(clearTimeout)},[]);const a=Math.round(n/Ys.length*100);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(Yn,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),e.jsx("div",{className:"deploy-d",children:"This usually takes under a minute. You can keep working, we'll let you know."})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{style:{width:a+"%"}})}),e.jsx("div",{className:"dep-steps",children:Ys.map((o,i)=>e.jsxs("div",{className:"dep-step "+(i<n?"done":i===n?"active":"todo"),children:[e.jsx("div",{className:"dot",children:i<n?e.jsx(Qe,{size:12,color:"#0a0a0a"}):null}),e.jsx("div",{className:"sl",children:o})]},o))})]})]})}const DL=Object.freeze(Object.defineProperty({__proto__:null,HostingDeployStep:Wf},Symbol.toStringTag,{value:"Module"})),B2="hosting";function Gf({provider:t,credential:n,onDone:s,onRetry:r}){const{stage:a,result:o,error:i,connect:c}=Fi(B2,t),d=l.useRef(!1);l.useEffect(()=>{d.current||(d.current=!0,c(n))},[c,n]);const u=l.useRef(s);return u.current=s,l.useEffect(()=>{a==="ready"&&o&&u.current(o.value)},[a,o]),a==="error"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(Yn,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t put your app online"}),e.jsx(at,{variant:"icon",text:`Couldn’t put your app online: ${i}`})]}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:r,children:"Try again"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(Yn,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?"Connecting to your hosting account…":"Building and publishing your app. This usually takes under a minute."})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const FL=Object.freeze(Object.defineProperty({__proto__:null,HostingRealDeployStep:Gf},Symbol.toStringTag,{value:"Module"})),H2=1600;function Uf(t){const{copied:n,copy:s}=ri({resetMs:H2}),r=l.useCallback(()=>{s(t)},[s,t]);return{copied:n,copy:r}}function Vf({onFinish:t,liveUrl:n}){const s=n??vs,r=n??"https://"+vs,{copied:a,copy:o}=Uf(r);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Live"})]}),e.jsx(Yn,{stage:"live"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:"Your app is live"}),e.jsx("div",{className:"lh-d",children:"Anyone with this link can open your app right now."})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"🌍"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:"Your link"}),e.jsx("div",{className:"uc-u",children:s})]}),e.jsxs("div",{className:"uc-actions",children:[e.jsx("button",{type:"button",className:"btn-copy",onClick:o,children:a?"✓ Copied":"Copy link"}),e.jsx("button",{type:"button",className:"btn-visit",disabled:!n,onClick:n?()=>window.open(n,"_blank","noopener"):void 0,children:"Visit →"})]})]}),e.jsxs("div",{className:"domain-row",children:[e.jsx("span",{className:"dre",children:"🏷️"}),e.jsxs("div",{children:[e.jsx("div",{className:"drt",children:"Want your own web address?"}),e.jsx("div",{className:"drd",children:"Connect a custom domain. Optional, and you can do it anytime."})]}),e.jsx("button",{type:"button",className:"drbtn",children:"Add a domain"})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx(Qe,{})," Hosting is now set up"]}),e.jsx("button",{type:"button",className:"lf-back",onClick:t,children:"Back to Setup"})]})]})]})}const zL=Object.freeze(Object.defineProperty({__proto__:null,HostingLiveStep:Vf},Symbol.toStringTag,{value:"Module"}));function Yf({onBack:t,onRedeploy:n}){const{copied:s,copy:r}=Uf("https://"+vs),[a,o]=l.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsx(Vi,{onBack:t}),e.jsxs("div",{className:"conn-card",children:[e.jsx(Dr,{}),e.jsxs("div",{className:"conn-body",children:[e.jsxs("div",{className:"conn-top",children:[e.jsx("span",{className:"conn-name",children:"Connected to Vercel"}),e.jsxs("span",{className:"conn-live",children:[e.jsx("span",{className:"lbdot"}),"Live"]})]}),e.jsxs("div",{className:"conn-acct",children:["Account ",e.jsx("b",{children:"your-app"})," · connected today"]})]}),e.jsx("button",{type:"button",className:"conn-disc",children:"Disconnect"})]}),e.jsx("div",{className:"seclabel",children:"Your live app"}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"🌍"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:"Your link"}),e.jsx("div",{className:"uc-u",children:vs})]}),e.jsxs("div",{className:"uc-actions",children:[e.jsx("button",{type:"button",className:"btn-copy",onClick:r,children:s?"✓ Copied":"Copy link"}),e.jsx("button",{type:"button",className:"btn-visit",children:"Visit →"})]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:28},children:"Latest deploy"}),e.jsxs("div",{className:"dep-card",children:[e.jsxs("div",{className:"depc-row",children:[e.jsx("span",{className:"depc-dot"}),e.jsxs("div",{className:"depc-main",children:[e.jsx("div",{className:"depc-t",children:"Live · deployed 2 minutes ago"}),e.jsx("div",{className:"depc-d",children:"Built and published from your latest changes."})]}),e.jsx("button",{type:"button",className:"depc-btn",onClick:n,children:"Redeploy"})]}),e.jsxs("div",{className:"depc-toggle",children:[e.jsxs("div",{children:[e.jsx("div",{className:"depc-tt",children:"Publish changes automatically"}),e.jsx("div",{className:"depc-td",children:"When you make changes, we'll put them live for you. Turn this off to publish by hand."})]}),e.jsx("span",{className:"toggle"+(a?" on":""),onClick:()=>o(i=>!i),role:"switch","aria-checked":a,tabIndex:0,children:e.jsx("span",{})})]})]})]})}const $L=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewConnected:Yf},Symbol.toStringTag,{value:"Module"}));function Kf({direction:t="guided",onBack:n,onComplete:s,connector:r,onOpenSharedBrowser:a}){const[o,i]=l.useState("overview"),[c,d]=l.useState(""),[u,h]=l.useState(void 0),p=r!==void 0;let m;return o==="overview"?m=t==="connected"?e.jsx(Yf,{onBack:n,onRedeploy:()=>i("deploying")}):e.jsx(Hf,{onBack:n,onSetup:()=>i("connect")}):o==="connect"?m=e.jsx(qf,{onBack:()=>i("overview"),tokenMode:p,onContinue:f=>{p&&d(f??""),i("deploying")}}):o==="deploying"?m=p?e.jsx(Gf,{provider:r.provider,credential:c,onDone:f=>{h(f),i(t==="connected"?"overview":"live")},onRetry:()=>i("connect")}):e.jsx(Wf,{onDone:()=>i(t==="connected"?"overview":"live")}):m=e.jsx(Vf,{liveUrl:u,onFinish:()=>{s==null||s(),n()}}),e.jsxs("div",{className:"hosting-screen",children:[m,a&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[12px]",children:[e.jsx("button",{type:"button",className:"rounded px-3 py-1.5",style:{background:"var(--bg-card)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",cursor:"pointer"},onClick:a,children:"Open shared browser →"}),e.jsx("span",{style:{color:"var(--text-secondary)"},children:"Walk the hosting console together — you and the assistant both drive."})]})]})}const BL=Object.freeze(Object.defineProperty({__proto__:null,HostingScreen:Kf},Symbol.toStringTag,{value:"Module"}));function Jf({recipe:t,onBack:n,onMarkDone:s,status:r,onRevert:a,copyWriter:o}){return e.jsxs("div",{className:"learn-screen run-locally-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:n,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:n,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Run it locally"})]}),e.jsx("div",{className:"h",children:"Run it locally"}),e.jsx("div",{className:"hsub",children:"Right now your app runs inside this editor's Live Preview. Running it on your own machine lets you debug with your own tools, show it offline, or hand it to a teammate. Here's how, for this exact project."}),t===null?e.jsx("div",{className:"rl-loading","aria-hidden":"true",children:"Loading run instructions…"}):e.jsxs("div",{className:"rl-sections",children:[t.prereqs.length>0&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Prerequisites"}),e.jsx("ul",{className:"rl-prereqs",children:t.prereqs.map(i=>e.jsxs("li",{className:"rl-prereq",children:[e.jsx("span",{className:"rl-prereq-label",children:i.label}),e.jsx("span",{className:"rl-prereq-detail",children:i.detail})]},i.label))})]}),t.install&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Install"}),e.jsx(ms,{command:t.install,writer:o})]}),e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:t.runLabel||"Run"}),e.jsx(ms,{command:t.run,writer:o})]}),t.loadSteps&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:t.loadSteps.label}),e.jsx("ol",{className:"rl-load-steps",children:t.loadSteps.steps.map(i=>e.jsx("li",{className:"rl-load-step",children:i},i))}),t.loadTarget&&e.jsxs("div",{className:"rl-load-target",children:[e.jsx("div",{className:"rl-load-target-label",children:t.loadTarget.label}),e.jsx(ms,{command:t.loadTarget.path,writer:o})]})]}),t.reachableAt&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Open it"}),e.jsxs("div",{className:"rl-reachable",children:["Once it's running, open"," ",e.jsx("a",{className:"rl-url",href:t.reachableAt,target:"_blank",rel:"noreferrer",children:t.reachableAt}),"."]})]}),t.notes.length>0&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Notes"}),e.jsx("ul",{className:"rl-notes",children:t.notes.map(i=>e.jsx("li",{className:"rl-note",children:i},i))})]}),e.jsx(ye,{assistKey:"run-locally",topicName:"Run it locally"}),s&&e.jsx(we,{label:"Got it — mark as done",note:"You can revisit these steps anytime.",status:r,onComplete:()=>s(),onRevert:a,onBack:n})]})]})}const HL=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyScreen:Jf},Symbol.toStringTag,{value:"Module"}));function Xf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Ge,{size:26}),title:"Store accounts",meta:"Foundation · about 15 minutes",onBack:t,assistKey:"store-accounts"}),e.jsxs("p",{className:"lead",children:["To publish your extension, you first register as a developer with the"," ",e.jsx("b",{children:"Chrome Web Store"}),". This is a one-time setup that gives you a dashboard for uploading, updating, and managing your listing."]}),e.jsx("p",{className:"lead dim",children:"It's not the same as a regular Google account upgrade — there's a one-time registration fee and a short profile to fill in."}),e.jsx(Ct,{linkKey:"chrome.devConsole"}),e.jsx("div",{className:"seclabel",children:"What you'll do"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Pay the one-time developer fee.",children:["The Chrome Web Store charges a single"," ",e.jsx("b",{children:xe("chromeStore.fee").value})," registration fee per account — not per extension. There's no recurring cost. The registration guide walks through the exact steps."]}),e.jsx(A,{lead:"Complete your developer profile.",children:"A public display name and a contact email. The email is verified and used for store communications and review notices."}),e.jsx(A,{lead:"Verify your identity and payment profile.",children:"Paying the fee requires a verified Google payment profile, and you must verify your contact information (email, and sometimes a phone number) before you can publish. Do this early — an unverified account can't push a listing live."}),e.jsx(A,{lead:"Decide on a publisher identity.",children:"You can publish under your own name or a group publisher. Group publishers are worth it if a team will manage the listing."})]}),e.jsx(Ct,{linkKey:"chrome.register",label:"Read the Chrome Web Store registration guide"}),e.jsx(Fr,{}),e.jsx(ye,{assistKey:"store-accounts",topicName:"Store accounts"}),e.jsx(we,{label:"I've registered my developer account",note:"You only need to do this once. The next steps reuse the same account.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const qL=Object.freeze(Object.defineProperty({__proto__:null,StoreAccountsScreen:Xf},Symbol.toStringTag,{value:"Module"}));function Qf({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(mt,{size:26}),title:"Store assets",meta:"About 30 minutes · design time",onBack:t,assistKey:"extension-store-assets"}),e.jsxs("p",{className:"lead",children:["Your store listing needs a set of images at ",e.jsx("b",{children:"exact dimensions"}),". The store rejects assets that are the wrong size, so it's worth getting these right before you submit."]}),e.jsx("div",{className:"seclabel",children:"Required"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Store icon — 128×128 PNG.",children:"The icon shown in the store and in the user's toolbar. Use a transparent or solid background; avoid tiny text."}),e.jsx(A,{lead:"At least one screenshot — 1280×800 or 640×400.",children:"Show your extension in action. The first screenshot is the one most users actually look at, so lead with your strongest."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Recommended"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Small promo tile — 440×280.",children:"Shown in store listings and search results. A clean tile noticeably improves install rates."}),e.jsx(A,{lead:"Marquee promo tile — 1400×560.",children:"Only used if the store features your extension, but worth having ready."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"PNG or JPEG"}),e.jsx("span",{className:"chip",children:"No misleading imagery"}),e.jsx("span",{className:"chip",children:"Up to 5 screenshots"})]}),e.jsx(Ct,{linkKey:"chrome.devConsole",label:"Upload assets in the developer dashboard"}),e.jsx(ye,{assistKey:"extension-store-assets",topicName:"Store assets"}),e.jsx(we,{label:"My store assets are ready",note:"You can update assets later — a new upload doesn't restart the whole review.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const WL=Object.freeze(Object.defineProperty({__proto__:null,ExtensionAssetsScreen:Qf},Symbol.toStringTag,{value:"Module"})),Zf={storage:"Save the user's settings and data between sessions.",activeTab:"Act on the current tab only when the user clicks your extension — no broad access. Prefer this over a host permission whenever the work starts from a user click; it sidesteps the host-permission review entirely.",scripting:"Inject the scripts that make your extension work on a page.",tabs:"Read tab titles and URLs to coordinate behaviour across open tabs.",cookies:"Read or set cookies for the sites your extension supports.",notifications:"Show desktop notifications the user has opted into.",contextMenus:"Add your own items to the right-click menu.",alarms:"Schedule background work at set intervals.",bookmarks:"Read or organise the user's bookmarks.",history:"Read or clear the user's browsing history.",downloads:"Start or manage file downloads on the user's behalf.",clipboardWrite:"Copy text to the clipboard when the user asks.",webRequest:"Observe network requests to filter or modify them.",webRequestBlocking:"Block or redirect requests synchronously. MV2-only — in Manifest V3 use declarativeNetRequest instead; this permission alone can fail the review on a new submission.",declarativeNetRequest:"Block or modify network requests via static rules — the MV3 replacement for blocking webRequest.",identity:"Sign the user in with their existing Google account. Heads-up: requesting OAuth scopes triggers a separate Google security/verification review that can take weeks — start it early.",debugger:"Attach to the DevTools protocol. High-risk: reviewers scrutinise this closely and it's rejected unless the core feature genuinely needs it.",nativeMessaging:"Talk to a companion app installed on the user's machine. Near-automatic deep review — expect extra scrutiny and a longer timeline.",offscreen:"Run an offscreen document for DOM work a service worker can't do (audio, clipboard, parsing).",management:"Read or manage the user's other installed extensions. High-risk — justify narrowly or reviewers reject it.",proxy:"Control the browser's proxy settings. High-risk; expect close review.",tabCapture:"Capture the visible tab's audio/video — only after the user starts capture from your UI.",desktopCapture:"Capture the screen, a window, or a tab the user picks. Must be user-initiated each time."};function js(t){const n=t.trim();return n.includes("://")||n.startsWith("*")||n==="<all_urls>"}function q2(t){const n=t.trim();return n==="<all_urls>"?!0:js(n)?n.replace(/^\*?:\/\//,"").split("/")[0]==="*":!1}function W2(t){const n=t.trim();return n==="<all_urls>"?"Run on every site the user visits. Only request this if your extension truly needs it — reviewers scrutinise it closely.":q2(n)?`Run on a very broad set of sites (${n}). Reviewers treat broad host access like <all_urls> — narrow it to the exact origins you need, or use activeTab instead.`:js(n)?`Run only on the specific sites this pattern matches (${n}).`:Zf[n]??"Explain, in one plain sentence, exactly what this permission lets your extension do for the user."}function G2(t){const n=t.trim();return js(n)||n in Zf}const U2=["storage","activeTab","scripting","https://api.example.com/*"];function po({perm:t}){return e.jsxs("div",{className:"reason",children:[e.jsx(Qe,{}),e.jsxs("span",{children:[e.jsx("b",{children:e.jsx("code",{children:t})})," ",W2(t),G2(t)?null:e.jsx("span",{className:"bestfit",style:{marginLeft:8},children:"needs your wording"})]})]},t)}function eg({permissions:t=U2,onBack:n,onComplete:s,status:r,onRevert:a}){const o=t.filter(js),i=t.filter(c=>!js(c));return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Ge,{size:26}),title:"Permissions",meta:"About 20 minutes · often missed",onBack:n,assistKey:"permissions-justification"}),e.jsxs("p",{className:"lead",children:["The store asks you to justify ",e.jsx("b",{children:"every permission"})," your extension requests. A clear, honest reason for each one is the difference between a smooth review and a rejection."]}),e.jsxs("p",{className:"lead dim",children:["These are read from your ",e.jsx("code",{children:"manifest.json"}),". Review the suggested justification for each and tighten it to match what your extension actually does."]}),e.jsxs("div",{className:"asknote",style:{marginTop:4},children:[e.jsx("b",{children:"Single-purpose policy:"})," every permission must serve your extension's one stated purpose. Unrelated permissions get rejected even when each is individually justified — it's one of the top rejection causes."]}),e.jsx("div",{className:"seclabel",children:"API permissions you request"}),i.length===0?e.jsx("p",{className:"lead dim",children:"Your manifest requests no API permissions to justify here."}):e.jsx("div",{className:"reasons",children:i.map(c=>e.jsx(po,{perm:c},c))}),e.jsx("div",{className:"seclabel",children:"Host permissions"}),o.length===0?e.jsx("p",{className:"lead dim",children:"Your manifest requests no host permissions — the easiest possible review on this axis."}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"lead dim",children:["Host permissions are submitted in a ",e.jsx("b",{children:"separate field"})," on the dashboard and scrutinised the hardest — narrow them to the exact origins you need."]}),e.jsx("div",{className:"reasons",children:o.map(c=>e.jsx(po,{perm:c},c))})]}),t.length===0&&e.jsx("p",{className:"lead dim",children:"Your manifest requests no special permissions — there's nothing to justify. That's the easiest possible review."}),e.jsx("div",{className:"asknote",style:{marginTop:14},children:"Rule of thumb: if you can't explain why a permission helps the user, remove it. Fewer permissions means a faster review and more installs."}),e.jsx(Ct,{linkKey:"chrome.devConsole",label:"Submit justifications in the developer dashboard"}),e.jsx(ye,{assistKey:"permissions-justification",topicName:"Permissions"}),e.jsx(we,{label:"My permissions are justified",note:"Reviewers read these. Vague or copy-pasted reasons are the most common rejection.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const GL=Object.freeze(Object.defineProperty({__proto__:null,PermissionRow:po,PermissionsJustificationScreen:eg},Symbol.toStringTag,{value:"Module"}));function tg({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"Privacy policy",meta:"About 20 minutes · disclosure required for every extension",onBack:t,assistKey:"privacy-policy"}),e.jsxs("p",{className:"lead",children:["A privacy policy at a public URL is required for any extension that accesses user data. Separately, ",e.jsx("b",{children:"every"})," extension must complete the data-use disclosure in the dashboard — even one that collects nothing has to declare that. Mismatches between the policy and the disclosure get flagged."]}),e.jsx("p",{className:"lead dim",children:`Even if you collect almost nothing, you still declare that — "we don't collect personal data" is a valid, common policy.`}),e.jsx("div",{className:"seclabel",children:'The "Privacy practices" tab'}),e.jsxs("p",{className:"lead dim",children:["The disclosure lives on the dashboard's ",e.jsx("b",{children:"Privacy practices"})," tab. You can't submit until you check its three mandatory certifications:"]}),e.jsxs(he,{children:[e.jsx(A,{lead:"You don't sell or transfer data to third parties",children:"outside of approved use cases."}),e.jsx(A,{lead:"You don't use or transfer data for purposes unrelated",children:"to your extension's single purpose."}),e.jsx(A,{lead:"You don't use or transfer data to determine creditworthiness",children:"or for lending purposes."})]}),e.jsx("div",{className:"seclabel",children:"Your policy must cover"}),e.jsxs(he,{children:[e.jsx(A,{lead:"What you collect.",children:"List the categories of data — settings, content the user enters, usage analytics — in plain terms."}),e.jsx(A,{lead:"Why you collect it.",children:"Tie each category to a feature. The store cross-checks this against your permission justifications."}),e.jsx(A,{lead:"Where it goes.",children:"Whether data stays on the device, syncs to the user's account, or is sent to a server you run or a third party."}),e.jsx(A,{lead:"How users can reach you.",children:"A contact method for privacy questions or deletion requests."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Hosted at a public URL"}),e.jsx("span",{className:"chip",children:"Linked in the dashboard"}),e.jsx("span",{className:"chip",children:"Matches your data disclosure"})]}),e.jsx(ye,{assistKey:"privacy-policy",topicName:"Privacy policy"}),e.jsx(we,{label:"My privacy policy is published and linked",note:"Keep the policy URL live — a dead link can get the listing taken down later.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const UL=Object.freeze(Object.defineProperty({__proto__:null,ExtensionPrivacyPolicyScreen:tg},Symbol.toStringTag,{value:"Module"}));function ng({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Ge,{size:26}),title:"OAuth & sign-in verification",meta:"Days to weeks · a separate review from the store listing",onBack:t,assistKey:"oauth-verification"}),e.jsxs("p",{className:"lead",children:["If your extension signs users in with Google, the OAuth"," ",e.jsx("b",{children:"consent screen"})," goes through its own verification — separate from, and slower than, the Chrome Web Store listing review. Plan for it early; it's the step that surprises people the week they hoped to launch."]}),e.jsx("p",{className:"lead dim",children:"This only applies if you request Google account access. Sign-in handled entirely by your own backend, or no sign-in at all, skips this gate completely."}),e.jsxs("div",{className:"asknote",style:{marginTop:4},children:[e.jsx("b",{children:"Two reviews, two timelines:"})," the store reviews your extension listing; Google separately reviews the ",e.jsx("b",{children:"OAuth consent screen"})," tied to your Cloud project. Approval on one is not approval on the other."]}),e.jsx("div",{className:"seclabel",children:"How long depends on the scopes you ask for"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Non-sensitive scopes (email, profile).",children:"Basic sign-in. No verification wait — your consent screen works for everyone as soon as you publish it."}),e.jsx(A,{lead:"Sensitive scopes (Gmail, Drive, Calendar).",children:"Require app verification. Expect a multi-day to multi-week review and a justification for why you need each scope."}),e.jsx(A,{lead:"Restricted scopes (full mailbox, all files).",children:"Pull in an annual third-party security assessment that can run weeks and cost real money. Avoid unless your product truly needs them."})]}),e.jsx("div",{className:"seclabel",children:"Before you submit for verification"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Request the narrowest scope that works.",children:"Drop from a restricted scope to a sensitive one, or a sensitive one to a non-sensitive one, wherever your feature allows — it's the single biggest lever on review time."}),e.jsx(A,{lead:"Verify your domain and publish a privacy policy.",children:"Verified ownership of every domain on the consent screen and a live policy URL are prerequisites — the same policy your listing needs."}),e.jsx(A,{lead:"Match scopes to your permission justifications.",children:"Reviewers cross-check the OAuth scopes against the case you make on the Permissions topic. Inconsistencies stall both reviews."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Separate from the store review"}),e.jsx("span",{className:"chip",children:"Sensitive scopes = verification"}),e.jsx("span",{className:"chip",children:"Restricted scopes = security assessment"})]}),e.jsx(Ct,{linkKey:"google.oauthConsent"}),e.jsx(ye,{assistKey:"oauth-verification",topicName:"OAuth & sign-in verification"}),e.jsx(we,{label:"My OAuth scopes and consent screen are ready",note:"Start verification as early as you can — it runs in parallel with everything else and is the most common launch-day surprise.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const VL=Object.freeze(Object.defineProperty({__proto__:null,OAuthVerificationScreen:ng},Symbol.toStringTag,{value:"Module"}));function sg({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Be,{size:26}),title:"Single purpose & listing quality",meta:"About 30 minutes · two of the top rejection causes",onBack:t,assistKey:"single-purpose-listing"}),e.jsxs("p",{className:"lead",children:["Every extension must have a ",e.jsx("b",{children:"single, narrow purpose"}),", and your listing has to describe it clearly. Bundling unrelated features, or a vague/keyword-stuffed listing, are among the most common reasons a submission gets rejected — both before you ever reach a human reviewer and during manual review."]}),e.jsx("p",{className:"lead dim",children:"Write your one-sentence purpose first. Everything else — permissions, the description, the category — should follow from it."}),e.jsx("div",{className:"seclabel",children:"The single-purpose policy"}),e.jsxs(he,{children:[e.jsx(A,{lead:"One narrow purpose, stated in a sentence.",children:`"Save articles to read later," not "a toolkit for productivity." If you can't say it in one sentence, it's probably two extensions.`}),e.jsx(A,{lead:"No unrelated functionality.",children:"A second, tangential feature — even a useful one — gets the whole extension rejected. Ship it separately if it doesn't serve the one purpose."}),e.jsx(A,{lead:"Permissions trace back to that purpose.",children:"Every permission you request should obviously serve the stated purpose, which is exactly what the Permissions topic asks you to justify."})]}),e.jsx("div",{className:"seclabel",children:"Listing quality"}),e.jsxs(he,{children:[e.jsx(A,{lead:"A description that says what it does, not what it's like.",children:"Lead with the purpose and the concrete value. Reviewers and users both bounce off generic marketing copy."}),e.jsx(A,{lead:"The right category.",children:"Pick the category that matches the purpose. A mismatched category is a flag and hurts discovery."}),e.jsx(A,{lead:"No keyword stuffing or misleading claims.",children:`Repeated keywords in the title/description, fake "official" branding, or features you don't actually have are explicit policy violations.`})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"One sentence, one purpose"}),e.jsx("span",{className:"chip",children:"Description matches behavior"}),e.jsx("span",{className:"chip",children:"Honest title & category"})]}),e.jsx(Ct,{linkKey:"chrome.devConsole",label:"Edit the listing description in the developer dashboard"}),e.jsx(ye,{assistKey:"single-purpose-listing",topicName:"Single purpose & listing quality"}),e.jsx(we,{label:"My purpose is narrow and my listing reflects it",note:"Re-read your listing as a skeptical reviewer: does it promise exactly what the extension does, and nothing more?",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const YL=Object.freeze(Object.defineProperty({__proto__:null,SinglePurposeListingScreen:sg},Symbol.toStringTag,{value:"Module"}));function rg({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(mt,{size:26}),title:"Manifest & versioning",meta:"About 15 minutes · enforced before review even starts",onBack:t,assistKey:"manifest-versioning"}),e.jsxs("p",{className:"lead",children:["Your ",e.jsx("code",{children:"manifest.json"})," has to satisfy a few hard rules before the store will accept an upload at all — these checks run"," ",e.jsx("b",{children:"before"})," any human review. Getting them right means your Submit step goes through on the first try instead of bouncing."]}),e.jsx("p",{className:"lead dim",children:"These are mechanical, not judgment calls — but each one rejects the upload outright, with an error that isn't always obvious."}),e.jsx("div",{className:"seclabel",children:"The rules the store enforces"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Manifest V3 is required.",children:[e.jsx("code",{children:'"manifest_version": 3'}),". V2 is no longer accepted for new uploads — a service worker replaces the old background page, and blocking ",e.jsx("code",{children:"webRequest"})," is gone."]}),e.jsxs(A,{lead:"The version must strictly increase on every upload.",children:["Bump ",e.jsx("code",{children:"version"})," for each upload — the store rejects a re-used or lower number. This is the most common upload failure: forgetting to bump after a fix."]}),e.jsxs(A,{lead:"Use a valid version format.",children:["One to four dot-separated integers (e.g. ",e.jsx("code",{children:"1.2.0"}),"). Each part is compared numerically, so ",e.jsx("code",{children:"1.10"})," is newer than"," ",e.jsx("code",{children:"1.9"}),"."]})]}),e.jsx("div",{className:"seclabel",children:"Worth setting deliberately"}),e.jsxs(he,{children:[e.jsx(A,{lead:"minimum_chrome_version.",children:"Set it to the oldest Chrome you actually support. The store won't offer the extension to older browsers — sparing those users a version that would break for them."}),e.jsxs(A,{lead:"Keep name, description, and icons in sync.",children:["The manifest's ",e.jsx("code",{children:"name"}),"/",e.jsx("code",{children:"description"})," seed your listing, and the icon set here is what the store and toolbar render."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"manifest_version: 3"}),e.jsx("span",{className:"chip",children:"version strictly increases"}),e.jsx("span",{className:"chip",children:"minimum_chrome_version set"})]}),e.jsx(ye,{assistKey:"manifest-versioning",topicName:"Manifest & versioning"}),e.jsx(we,{label:"My manifest is MV3 and the version is bumped",note:"Bumping the version is the easiest step to forget — make it part of your build, not a manual afterthought.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const KL=Object.freeze(Object.defineProperty({__proto__:null,ManifestVersioningScreen:rg},Symbol.toStringTag,{value:"Module"}));function ag({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Xe,{size:26}),title:"Submit for review",meta:"About 15 minutes · then a review wait",onBack:t,assistKey:"submit-review"}),e.jsx("p",{className:"lead",children:"Last step: package your extension, upload it, and submit for review. Once you submit, the Chrome Web Store checks your listing against its policies before it goes public."}),e.jsx("div",{className:"seclabel",children:"Packaging & submitting"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Build and zip the extension.",children:"Produce your production build and zip its folder — the zip is what you upload, not the source repository."}),e.jsxs(A,{lead:"Put manifest.json at the zip root.",children:["The ",e.jsx("code",{children:"manifest.json"})," must sit at the top level of the zip, not inside a nested folder. Zipping the parent directory instead of its contents is a top first-upload failure."]}),e.jsx(A,{lead:"Upload and fill in the listing.",children:"Drop the zip into the dashboard, then complete the description, category, assets, and the data-use disclosure."}),e.jsx(A,{lead:"Choose visibility and rollout.",children:"At submit time you pick the distribution — public, unlisted, or private — and can stage a percentage rollout to release gradually."}),e.jsx(A,{lead:"Submit for review.",children:"Once everything validates, submit. You can't edit a submission while it's under review — but you can keep developing and submit a new version, and a rejection doesn't lose your draft."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"What to expect"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Timelines vary — hours to weeks.",children:"Many reviews clear in hours to a few days, but a new publisher account, broad host permissions, remote code, or OAuth scopes can push it to weeks. Plan for the longer end if any of those apply."}),e.jsx(A,{lead:"Rejections come with a reason.",children:"If it's rejected, the store says why. The usual culprits are permission justifications and the privacy policy — both covered in the earlier steps."})]}),e.jsx(Ct,{linkKey:"chrome.devConsole",label:"Upload and submit in the developer dashboard"}),e.jsx(Fr,{}),e.jsx(ye,{assistKey:"submit-review",topicName:"Submit for review"}),e.jsx(we,{label:"I've submitted for review",note:"Once approved, your store listing link is what you share to install the extension.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const JL=Object.freeze(Object.defineProperty({__proto__:null,SubmitReviewScreen:ag},Symbol.toStringTag,{value:"Module"})),V2=[{q:"Can my testers just double-click a file to install it?",a:"Not for the load-unpacked path — Chrome blocks installing extensions from a double-clicked file outside the Web Store. Each tester opens the browser's extensions page, turns on Developer mode, and chooses “Load unpacked” on the folder. If you want a one-click install link, use an unlisted Web Store listing instead."},{q:"Will the extension update itself for my testers?",a:"Only the unlisted Web Store listing auto-updates — you upload a new version and Chrome pushes it to everyone with the link. A load-unpacked build never auto-updates: you re-send the zip and each tester reloads it. A self-hosted .crx can auto-update via its update_url, but that path is really for managed/enterprise installs."},{q:`Do I need the ${xe("chromeStore.fee").value} developer account just to share with my team?`,a:`Not for the zip / load-unpacked handoff — that needs no account at all. You only need the one-time ${xe("chromeStore.fee").value} developer account if you want the unlisted-listing path (link-shareable, auto-updating, and trusted by Chrome).`}];function og({onBack:t,onComplete:n,status:s,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{icon:e.jsx(Xe,{size:26}),title:"Share with testers",meta:"About 10 minutes · no public listing",onBack:t,assistKey:"share-testing"}),e.jsx("p",{className:"lead",children:"Want a few people to try your extension before it's public? You don't have to go through the Chrome Web Store review. There are three ways to hand a build to testers — from a zip you email today, to a private store listing that auto-updates, to a self-hosted package for managed fleets. Pick by how many testers you have and whether they need updates."}),e.jsx("div",{className:"seclabel",children:"Load unpacked (zip handoff)"}),e.jsxs(he,{children:[e.jsx(A,{lead:"Build, zip, and send it.",children:"Produce your production build and zip the output folder. Each tester opens the browser's extensions page, enables Developer mode, and chooses “Load unpacked” on the unzipped folder. No account, no review — it works the moment they load it."}),e.jsxs(A,{lead:"Put manifest.json at the zip root.",children:["The ",e.jsx("code",{children:"manifest.json"})," must sit at the top level of the unzipped folder, not inside a nested directory — the same gotcha that trips up store uploads."]}),e.jsxs(A,{lead:"Know the trade-offs.",children:["There is ",e.jsx("b",{children:"no auto-update"})," — to ship a fix you re-send the zip and testers reload it. Chrome also shows a persistent “disable developer-mode extensions” warning, which can confuse non-technical testers. Best for a handful of trusted people on a short loop."]})]}),e.jsx(cn,{assistKey:"share-testing",topicName:"Share with testers",goalId:"zip-load-unpacked",buttonLabel:'Ask AI to help with the "Load Unpacked (Zip Handoff)" goal'}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Unlisted / private Web Store listing"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Upload to the store, but hide it.",children:["You still upload to the Chrome Web Store, but set visibility to"," ",e.jsx("b",{children:"Unlisted"})," (link-shareable, not discoverable in search) or"," ",e.jsx("b",{children:"Private"})," (restricted to named testers). Anyone with the link installs in one click — no Developer mode, no warning."]}),e.jsx(A,{lead:"It auto-updates and is trusted by Chrome.",children:"Push a new version and the store delivers it to every tester automatically. Because it's a real store install, Chrome trusts it — none of the unpacked-build friction."}),e.jsxs(A,{lead:"It still needs the one-time developer account.",children:["An unlisted listing requires the same"," ",e.jsx("b",{children:xe("chromeStore.fee").value})," developer registration as a public one (see the ",e.jsx("b",{children:"Store accounts"})," topic). An unlisted listing also still goes through review — it just isn't publicly discoverable once approved."]})]}),e.jsx(Ct,{linkKey:"chrome.devConsole",label:"Upload an unlisted build in the developer dashboard"}),e.jsx(cn,{assistKey:"share-testing",topicName:"Share with testers",goalId:"unlisted-listing",buttonLabel:'Ask AI to help with the "Unlisted / Private Web Store Listing" goal'}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Self-hosted .crx + update_url (advanced)"}),e.jsxs(he,{children:[e.jsxs(A,{lead:"Host the packed .crx and an update manifest.",children:["Pack the extension to a ",e.jsx("code",{children:".crx"}),", host it alongside an update manifest, and point the manifest's ",e.jsx("code",{children:"update_url"})," at it. This is the only path that needs no store account at all."]}),e.jsxs(A,{lead:"Chrome blocks off-store .crx for ordinary users.",children:["For a normal browser profile, Chrome refuses to install an off-store",e.jsx("code",{children:".crx"}),". This path really exists for"," ",e.jsx("b",{children:"managed / enterprise"})," force-install via admin policy (e.g. a company's device management) — not for casual beta testers."]})]}),e.jsx(cn,{assistKey:"share-testing",topicName:"Share with testers",goalId:"self-host-crx",buttonLabel:'Ask AI to help with the "Self-Hosted .crx + update_url (Advanced)" goal'}),e.jsx(ot,{items:V2}),e.jsx(Fr,{}),e.jsx(we,{label:"I've shared a build with testers",note:"When you're ready for the public store, the store-accounts → submit-for-review chain takes it the rest of the way.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:t})]})}const XL=Object.freeze(Object.defineProperty({__proto__:null,ExtensionDistributionScreen:og},Symbol.toStringTag,{value:"Module"}));function hn({tone:t="cost",title:n,children:s}){const r=t==="wait"?"⏳":t==="size"?"⬇":"$";return e.jsxs("div",{className:"sd-callout "+t,children:[e.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:r}),e.jsxs("div",{children:[e.jsx("div",{className:"sd-callout-t",children:n}),e.jsx("div",{className:"sd-callout-b",children:s})]})]})}function vt({store:t,badge:n,enrollUrl:s,enrollLabel:r,children:a}){const o=t==="ios"?"Apple App Store":"Google Play",i=t==="ios"?"":"▶";return e.jsxs("div",{className:"sd-store "+t,children:[e.jsx("div",{className:"sd-store-mark","aria-hidden":"true",children:i}),e.jsxs("div",{className:"sd-store-body",children:[e.jsxs("div",{className:"sd-store-top",children:[e.jsx("span",{className:"sd-store-name",children:o}),e.jsx("span",{className:"sd-store-badge",children:n})]}),e.jsx("div",{className:"sd-store-desc",children:a}),s&&e.jsx("a",{className:"sd-store-enroll",href:s,target:"_blank",rel:"noreferrer noopener",children:r??"Enrol →"})]})]})}function mn({items:t}){return e.jsx("div",{className:"sd-checks",children:t.map((n,s)=>e.jsxs("div",{className:"sd-check",children:[e.jsx(Qe,{}),e.jsx("span",{children:n})]},s))})}const QL=Object.freeze(Object.defineProperty({__proto__:null,CheckList:mn,CostCallout:hn,StoreCard:vt},Symbol.toStringTag,{value:"Module"}));function In(t){return t==="ios"||t==="both"}function Qn(t){return t==="android"||t==="both"}const Ic=["swift","swiftui","ios","uikit"],Lc=["kotlin","android","jetpack-compose"];function Dc(t,n){return t&&!n?"ios":n&&!t?"android":null}function Y2(t){if(!t)return"both";const n=t.platforms;if(Array.isArray(n)){const a=n.some(i=>String(i).toLowerCase().includes("ios")),o=n.some(i=>String(i).toLowerCase().includes("android"));if(a&&!o)return"ios";if(o&&!a)return"android";if(a||o)return"both"}const s=String(t.framework??"").toLowerCase();if(s){const a=Dc(Ic.some(o=>s.includes(o)),Lc.some(o=>s.includes(o)));if(a)return a}const r=String(t.id??"").toLowerCase().split("-");if(r.some(Boolean)){const a=Dc(Ic.some(o=>r.includes(o)),Lc.some(o=>r.includes(o)));if(a)return a}return"both"}function ig({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=In(t),i=Qn(t),c=[{q:"Do I really have to pay before I can ship?",a:"Yes — there's no free tier for publishing to the stores. Apple charges $99/year and Google a one-time $25. You can build and test for free; the fee is the gate to actually listing the app."},{q:"How long does verification take?",a:"Anywhere from a few hours to several days for identity checks. The slow part is organisation/business verification — and if you need a brand-new D-U-N-S number for Apple, that alone can take up to ~2 weeks. Start it well before your planned launch."},{q:"Why is my Play account stuck in closed testing?",a:"Personal Google Play accounts created after 2023-11-13 must run a closed test with at least 12 testers opted in for 14 continuous days before they can request production access. If your tester count drops below 12, the 14-day clock resets. Organisation accounts are generally not subject to this."},{q:"Do I need a Mac to ship an iOS app?",a:"Practically, yes — building, signing, and uploading an iOS build needs Xcode, which only runs on macOS. You can write the code anywhere, but the final build and submission step expects a Mac (or a cloud Mac/CI service)."},{q:"Can I publish to just one store first?",a:"Absolutely. Many teams ship to one platform to start. Enrol only in the account you need now — you can add the other later without redoing anything."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Ge,{size:26}),title:"Developer accounts",meta:"One-time setup · paid · about 20 minutes",assistKey:"dev-accounts"}),e.jsx("p",{className:"lead",children:"Before an app can reach the stores, you have to enrol as a developer with each company you ship to. This is the account that owns your app, signs your builds, and gets paid out — so it's worth doing carefully and once."}),e.jsxs(hn,{tone:"cost",title:"These accounts cost money up front",children:["Plan for this before you start — there's no free tier for publishing.",o&&i?" Together that's $99 the first year plus a one-time $25.":""]}),e.jsx("div",{className:"seclabel",children:"What to set up"}),o?e.jsxs(vt,{store:"ios",badge:xe("appleDeveloper.fee").value,enrollUrl:"https://developer.apple.com/programs/enroll/",enrollLabel:"Enrol in the Apple Developer Program →",children:["Enrol in the ",e.jsx("b",{children:"Apple Developer Program"})," at developer.apple.com. The membership renews yearly; let it lapse and your apps are pulled from sale. Enrolling as an organisation needs a D-U-N-S number — if you don't already have one, issuance can take ",e.jsx("b",{children:"up to ~2 weeks"}),", so start this well before your planned launch."]}):null,i?e.jsxs(vt,{store:"android",badge:xe("googlePlay.fee").value,enrollUrl:"https://play.google.com/console/signup",enrollLabel:"Open Google Play Console signup →",children:["Register for the ",e.jsx("b",{children:"Google Play Console"})," at play.google.com/console. The fee is one-time, not yearly. ",xe("playStore.closedTestGate").value," ","— and if your tester count drops below 12, the 14-day clock resets. Organisation accounts are generally not subject to this gate. Factor the closed-test window into your timeline."]}):null,e.jsx(hn,{tone:"wait",title:"Verification isn't instant",children:"Identity and (for organisations) business verification can take anywhere from a few hours to several days. Get this out of the way before you're ready to ship, not the night before."}),e.jsx(ot,{items:c}),e.jsx(ye,{assistKey:"dev-accounts",topicName:"Developer accounts"}),e.jsx(we,{label:"Mark developer accounts as set up",note:"Do this once you've enrolled and your account is verified.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const ZL=Object.freeze(Object.defineProperty({__proto__:null,DevAccountsScreen:ig},Symbol.toStringTag,{value:"Module"}));function lg({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=In(t),i=Qn(t),c=[{q:"Do my screenshots have to be the exact pixel sizes?",a:"For the required sets, yes — App Store Connect rejects the wrong dimensions. Capture on the 6.9″ iPhone simulator (1320×2868) and Apple scales that master down for the smaller phones; the older 6.7″/6.5″ sizes are still accepted if that's all you have."},{q:"Why does my Google Play listing keep getting rejected?",a:"The most common cause is a missing feature graphic (1024×500) — it's mandatory and easy to forget — or placeholder/lorem-ipsum screens. Make sure the 512×512 icon, the feature graphic, and at least two real phone screenshots are all uploaded."},{q:"Do I need separate icons for each store?",a:"Yes, at different sizes: a 1024×1024 master for the App Store and a 512×512 icon for Google Play. Both must be square PNGs with no transparency and no pre-rounded corners — the stores round them for you."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(mt,{size:26}),title:"Store assets",meta:"Design work · about 1–2 hours",assistKey:"store-assets"}),e.jsx("p",{className:"lead",children:"Every store listing needs artwork: a high-resolution app icon, a set of screenshots, and some promo imagery. The stores reject submissions with the wrong sizes or placeholder art, so it's worth getting these right before you submit."}),e.jsx("div",{className:"seclabel",children:"The essentials, everywhere"}),e.jsx(mn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"App icon"})," — a square PNG with no transparency and no rounded corners (the stores round them for you). Apple wants a 1024×1024 master; Google Play wants a 512×512 icon — export both, not one size everywhere."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Screenshots"})," — captured on the exact device sizes each store asks for, not scaled-up phone shots."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"No placeholder art"}),' — "lorem ipsum" screens and stock icons are the most common rejection reason.']})]}),e.jsx("div",{className:"seclabel",children:"Per store"}),o?e.jsxs(vt,{store:"ios",badge:xe("appleScreenshots.iphone").value,children:["The App Store's primary iPhone set is now the ",e.jsx("b",{children:"6.9″ (1320×2868)"})," ","size — capture on that simulator and Apple scales the master down for smaller phones. The older 6.7″/6.5″ sizes (1290×2796, 1242×2688) are still accepted as a fallback. If your app supports iPad, also provide the ",xe("appleScreenshots.ipad").value," master. App previews (short videos) are optional but help conversion."]}):null,i?e.jsxs(vt,{store:"android",badge:"512×512 icon + feature graphic",children:["Google Play needs a ",e.jsx("b",{children:"512×512"})," icon (not the 1024×1024 iOS master), a 1024×500 ",e.jsx("b",{children:"feature graphic"})," (the banner at the top of your listing — easy to forget), and at least two phone screenshots. The feature graphic is mandatory; the listing won't publish without it."]}):null,e.jsx(ot,{items:c}),e.jsx(ye,{assistKey:"store-assets",topicName:"Store assets"}),e.jsx(we,{label:"Mark store assets as ready",note:"Do this once your icon and screenshots are exported at the right sizes.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const eD=Object.freeze(Object.defineProperty({__proto__:null,StoreAssetsScreen:lg},Symbol.toStringTag,{value:"Module"}));function cg({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=In(t),i=Qn(t);return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Be,{size:26}),title:"Store listing",meta:"Writing + forms · about 45 minutes",assistKey:"store-listing"}),e.jsx("p",{className:"lead",children:"The listing is how people decide whether to install. It's your title and subtitle, the description, a category, and a keyword set — plus the privacy disclosures the stores now require. The writing sells; the privacy form is a hard gate."}),e.jsx("div",{className:"seclabel",children:"Write these"}),e.jsx(mn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Title & subtitle"})," — clear over clever. The first few words are what shows in search results."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Description"})," — lead with what the app does and who it's for; keep the keyword-stuffing out, both stores penalise it."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Category"})," — pick the one your app actually fits; it affects where you rank."]})]}),e.jsx("div",{className:"seclabel",children:"Privacy is required now"}),o?e.jsxs(vt,{store:"ios",badge:"Nutrition labels",children:["Apple's ",e.jsx("b",{children:'privacy "nutrition labels"'})," ask you to declare exactly what data your app collects and how it's used. You fill these in App Store Connect; they show on your listing. Misdeclaring is grounds for removal, so answer them honestly."]}):null,i?e.jsxs(vt,{store:"android",badge:"Data safety form",children:["Google Play's ",e.jsx("b",{children:"Data safety"})," form covers the same ground — collection, sharing, and security practices. It's mandatory; the listing can't go live until it's complete and consistent with what your app actually does."]}):null,e.jsx(ye,{assistKey:"store-listing",topicName:"Store listing"}),e.jsx(we,{label:"Mark store listing as drafted",note:"Do this once your copy is written and the privacy form is filled in.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const tD=Object.freeze(Object.defineProperty({__proto__:null,StoreListingScreen:cg},Symbol.toStringTag,{value:"Module"}));function dg({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=In(t),i=Qn(t),c=[{q:"How long does the first store review really take?",a:"Once you're set up, per-update reviews are fast — Apple usually within a day, Google often within hours. The slow one is a new Google Play account's first production-access approval, which can take ~7 days on top of the closed-testing gate. Plan your launch date around that first approval, not the steady-state speed."},{q:"Why is my Play app stuck before I can go to production?",a:xe("playStore.closedTestGate").value+" — and the 14-day clock resets if the tester count drops below 12. Organisation accounts are generally not subject to this gate."},{q:"How many testers can I have?",a:"On TestFlight, up to 100 internal testers (your team) and up to 10,000 external testers. On Google Play, internal testing is a small email list, while closed/open tracks scale much larger."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Xe,{size:26}),title:"Testing & distribution",meta:"Build + review · hours to days",assistKey:"testing-distribution"}),e.jsx("p",{className:"lead",children:"Before you release to everyone, you put a build in front of a small group of testers, then submit that build for the store's review. Both steps use the store's own tooling — you don't email APKs around."}),e.jsxs(hn,{tone:"size",title:"First native build pulls a large SDK",children:["Producing a real device build downloads the platform toolchain — often",e.jsx("b",{children:" 8–12 GB"})," and ",e.jsx("b",{children:"10–30 minutes"})," the first time. Run the iOS pre-flight checks in ",e.jsx("code",{children:"MOBILE_SETUP.md"})," before you kick it off so a missing platform SDK surfaces in seconds, not ten minutes in."]}),e.jsx("div",{className:"seclabel",children:"Get a build to testers"}),o?e.jsxs(e.Fragment,{children:[e.jsxs(vt,{store:"ios",badge:"TestFlight",children:["Upload to ",e.jsx("b",{children:"TestFlight"})," from Xcode or your CI. Internal testers (up to 100 on your team) get builds instantly; ",e.jsx("b",{children:"external testers go up to 10,000"}),` and go through a lighter "beta" review first. This is also how you sanity-check the exact binary you'll submit.`]}),e.jsx(cn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-testflight",buttonLabel:"Ask AI to help: Prep a TestFlight upload"})]}):null,i?e.jsxs(e.Fragment,{children:[e.jsxs(vt,{store:"android",badge:"Internal testing",children:["Use a Play Console ",e.jsx("b",{children:"internal testing"})," track for instant distribution to a list of tester emails. Promote the same build up through closed → open → production tracks as your confidence grows. Note the production gate: ",xe("playStore.closedTestGate").value," ","(the 14-day clock resets below 12). Organisation accounts are generally not subject to this."]}),e.jsx(cn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-play-internal",buttonLabel:"Ask AI to help: Set up Play internal testing"})]}):null,e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Get ready for store review"}),e.jsx("p",{className:"lead",children:"Before you submit, run a pre-review pass across the stores you target: your privacy / data-safety answers match what the code actually does, the required usage-description strings are present, no debug or placeholder content ships, and deep links and permissions really work. Submitting a clean build is the fastest way through review."}),e.jsxs(hn,{tone:"wait",title:"Review takes real time",children:["Store review is a human process. Once you're established, per-update reviews are quick — Apple typically within a day, Google often within hours. The slow one is a ",e.jsx("b",{children:"new Google Play account's first production-access approval (~7 days)"}),", separate from and on top of the closed-testing gate. Build that first approval into your launch date — you can't rush it."]}),e.jsx(cn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-store-review",buttonLabel:"Ask AI to help: Get ready for store review"}),e.jsx(ot,{items:c}),e.jsx(we,{label:"Mark testing & distribution as set up",note:"Do this once a build is on a test track and you know the review path.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const nD=Object.freeze(Object.defineProperty({__proto__:null,TestingDistributionScreen:dg},Symbol.toStringTag,{value:"Module"}));function ug({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=In(t),i=Qn(t),c=[{q:"Can I test push on the iOS simulator?",a:"Partly. Xcode 14+/macOS 13+ simulators can receive a payload you drag onto them, but real end-to-end APNs delivery is unreliable on the simulator. Verify real delivery on a physical device before you rely on it."},{q:"Why aren't my notifications showing up?",a:"The most common reason is that the user never granted permission — on iOS notifications are off until they explicitly opt in, and Android 13+ also needs a runtime permission prompt. Check the permission state first, then your APNs key / FCM token wiring."},{q:"Do I have to add push before I launch?",a:"No — push is optional. If your app doesn't need to reach people while it's closed, skip it. You can add APNs/FCM later without resubmitting the rest of your setup."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Li,{size:26}),title:"Push notifications",meta:"Optional · about 1 hour",assistKey:"push-notifications"}),e.jsx("p",{className:"lead",children:"Push lets your app reach people when it's closed. Each platform has its own delivery service you register with — you don't send notifications directly, you hand them to Apple or Google to deliver."}),e.jsx("div",{className:"seclabel",children:"The delivery services"}),o?e.jsxs(vt,{store:"ios",badge:"APNs",children:["Apple's ",e.jsx("b",{children:"Push Notification service (APNs)"}),". You create an APNs key or certificate in your developer account and register your app's capability in Xcode. On iOS the user must explicitly grant permission — notifications are off until they say yes."]}):null,i?e.jsxs(vt,{store:"android",badge:"FCM",children:["Google's ",e.jsx("b",{children:"Firebase Cloud Messaging (FCM)"}),". Add the Firebase config to your app and use the FCM token to target a device. Android 13+ also requires a runtime permission prompt, so don't assume delivery without it."]}):null,e.jsx("div",{className:"seclabel",children:"Get this right"}),e.jsx(mn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Ask at the right moment."})," Prompt for permission when the value is obvious, not on first launch — a denied prompt is hard to recover."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Make them opt-in and useful."})," Noisy notifications get your app muted or uninstalled."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Test on a real device."})," Push is unreliable on the iOS simulator — Xcode 14+/macOS 13+ can receive a dropped payload, but verify real delivery on a physical device."]})]}),e.jsx(ot,{items:c}),e.jsx(ye,{assistKey:"push-notifications",topicName:"Push notifications"}),e.jsx(we,{label:"Mark push notifications as set up",note:"Optional — skip it if your app doesn't need to reach people when closed.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const sD=Object.freeze(Object.defineProperty({__proto__:null,PushNotificationsScreen:ug},Symbol.toStringTag,{value:"Module"}));function hg({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Tt,{size:26}),title:"Crash reporting",meta:"Recommended · about 30 minutes",assistKey:"crash-reporting"}),e.jsx("p",{className:"lead",children:"Once real people run your app, some of them will hit crashes you never saw in testing — on devices and OS versions you don't own. Crash reporting captures those automatically so you find out before the one-star reviews do."}),e.jsx("div",{className:"seclabel",children:"What you'll get"}),e.jsx(mn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Stack traces"})," pointing at the exact line that failed, grouped so you see which crash hits the most people first."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Device context"})," — OS version, model, and steps — so you can reproduce instead of guessing."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Trends over time"})," so you can tell whether a release made things better or worse."]})]}),e.jsx("div",{className:"seclabel",children:"Common tools"}),e.jsxs("p",{className:"lead dim",children:[e.jsx("b",{children:"Firebase Crashlytics"})," (free, works on both platforms) and"," ",e.jsx("b",{children:"Sentry"})," (crashes plus broader error monitoring) are the usual starting points. Both drop in as an SDK; pick one and wire it once."]}),e.jsxs("div",{className:"sd-callout size",children:[e.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:"⬇"}),e.jsxs("div",{children:[e.jsx("div",{className:"sd-callout-t",children:"Upload your symbols, or reports are noise"}),e.jsx("div",{className:"sd-callout-b",children:"Release builds are stripped, so a raw crash is unreadable hex. Upload the debug symbols (dSYMs on iOS, mapping files on Android) on every release — most SDKs automate this in CI — or your stack traces won't point at real code."})]})]}),e.jsx(ye,{assistKey:"crash-reporting",topicName:"Crash reporting"}),e.jsx(we,{label:"Mark crash reporting as set up",note:"Do this once an SDK is wired in and symbol upload is part of your release.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const rD=Object.freeze(Object.defineProperty({__proto__:null,CrashReportingScreen:hg},Symbol.toStringTag,{value:"Module"}));function pg({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=In(t),i=Qn(t),c=[{q:"Can't I just use Stripe like on the web?",a:"Not for digital goods consumed in the app — unlocking features, virtual currency, subscriptions. Those must go through the store's billing, and shipping a side payment link for them is one of the most common rejections. Stripe is fine for real-world goods and services (a ride, a physical product, an in-person class)."},{q:"Why is the commission lower in some cases?",a:"Both stores drop to 15% for most small developers — Apple's Small Business Program (under ~$1M/year) and Google's first $1M/year — and for subscriptions (Apple after the subscriber's first year, Google from day one). Above those thresholds the standard rate is 30%."},{q:"How do I test a purchase without being charged?",a:"Both stores have sandbox testers: Apple uses Sandbox Apple IDs in App Store Connect, Google uses license-test accounts in the Play Console. Purchases run end-to-end against test billing so you can verify the unlock flow without real money."},{q:"Do I have to verify the purchase on a server?",a:"For anything worth protecting, yes. Validate the store receipt / purchase token server-side before granting entitlements — a client-only check is trivially bypassed. Both platforms publish server-side verification APIs."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Jt,{size:26}),title:"In-app purchases & subscriptions",meta:"When you sell inside the app · about 30 minutes",assistKey:"in-app-purchases"}),e.jsxs("p",{className:"lead",children:["Selling anything digital inside your app — a subscription, a feature unlock, in-app currency — doesn't work like web checkout. The stores require you to use ",e.jsx("i",{children:"their"})," billing, take a cut, and reject apps that route around it. Getting this right early saves a painful rewrite later."]}),e.jsx(hn,{tone:"cost",title:"The store takes a commission on every sale",children:"Budget for it in your pricing from the start — the cut comes off the top of every transaction, before you see a cent."}),e.jsx("div",{className:"seclabel",children:"What you'll wire up"}),o?e.jsxs(vt,{store:"ios",badge:xe("appStore.commission").value,children:["Use ",e.jsx("b",{children:"StoreKit"})," (StoreKit 2 is the current API) to define products in App Store Connect and present the native purchase sheet. Apple's cut is ",xe("appStore.commission").value,"."," ",e.jsx(un,{fact:xe("appStore.commission")})]}):null,i?e.jsxs(vt,{store:"android",badge:xe("googlePlay.commission").value,children:["Use the ",e.jsx("b",{children:"Google Play Billing Library"})," to define products in the Play Console and launch the billing flow. Google's service fee is"," ",xe("googlePlay.commission").value,"."," ",e.jsx(un,{fact:xe("googlePlay.commission")})]}):null,e.jsx("div",{className:"seclabel",children:"The rule that gets apps rejected"}),e.jsx(mn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Digital goods must use store billing."}),' Subscriptions, feature unlocks, virtual currency — all of it goes through StoreKit / Play Billing. A Stripe link or "pay on our website" prompt for these is a rejection.']}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Physical goods and real-world services don't."})," A ride, a shipped product, an in-person class — bill those however you like; the stores explicitly don't want their cut of those."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Verify entitlements server-side."})," Validate the receipt or purchase token on your backend before unlocking — never trust the client alone."]})]}),e.jsx(ot,{items:c}),e.jsx(ye,{assistKey:"in-app-purchases",topicName:"In-app purchases & subscriptions"}),e.jsx(we,{label:"Mark in-app purchases as set up",note:"Do this once your products are defined and a sandbox purchase unlocks the right entitlement.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const aD=Object.freeze(Object.defineProperty({__proto__:null,InAppPurchasesScreen:pg},Symbol.toStringTag,{value:"Module"}));function mg({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=In(t),i=[{q:"Do I need a privacy policy even if I collect almost nothing?",a:"Yes. Both stores require a reachable privacy policy URL for essentially every app — even a trivial one. It has to be live before you submit, and it must match what your app actually does. A dead link or a mismatch is a rejection."},{q:"Why do I have to let people delete their account in the app?",a:"Both Apple and Google require that apps which let you create an account also let you delete it — and the data tied to it — from inside the app (a web link is allowed alongside, but the in-app path must exist). It's a hard review gate, not a nicety."},{q:"What exactly counts as 'tracking' for the iOS prompt?",a:"Linking a user's data with data from other companies' apps or sites for advertising or sharing with data brokers. If you do that, you must show the App Tracking Transparency prompt and only track if they allow it. Plain first-party analytics usually isn't 'tracking' in Apple's sense — but the store privacy questionnaire still has to be answered honestly."},{q:"Is the privacy questionnaire the same as the privacy policy?",a:"No — they're two things. The store's privacy questionnaire (Apple's 'privacy nutrition label', Google's Data safety form) is a structured declaration you fill in at submission; the privacy policy is your own hosted page. Both have to agree with each other and with the app's real behavior."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Ge,{size:26}),title:"App privacy & tracking",meta:"Submission gate · about 30 minutes",assistKey:"app-privacy"}),e.jsx("p",{className:"lead",children:`A build that runs perfectly still gets held at review if its privacy story isn't in order. These gates are about what you tell users you do with their data — and the stores check them on every submission, so it's worth handling before you hit "submit," not after a rejection.`}),e.jsx("div",{className:"seclabel",children:"The gates that apply everywhere"}),e.jsx(mn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"A live privacy policy URL."})," Host a policy that matches what the app actually collects, and make sure the link resolves — a dead link is an instant rejection."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"In-app account deletion."})," If users can create an account, they must be able to delete it — and its data — from inside the app. Both stores require this path to exist."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"An honest privacy declaration."})," Fill in Apple's privacy label and Google's Data safety form to match reality; a mismatch with your policy or your code is a rejection."]})]}),o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:"iOS only — the tracking prompt"}),e.jsxs(hn,{tone:"wait",title:"App Tracking Transparency is its own gate",children:["If your app tracks users across other companies' apps and sites — for ads or to share with data brokers — iOS requires the"," ",e.jsx("b",{children:"App Tracking Transparency"}),' prompt before any of it, and you may only track users who tap "Allow." Declare your tracking honestly; tracking without the prompt is a rejection (and, if shipped, an enforcement risk).']})]}):null,e.jsx(ot,{items:i}),e.jsx(ye,{assistKey:"app-privacy",topicName:"App privacy & tracking"}),e.jsx(we,{label:"Mark app privacy as set up",note:"Do this once your policy URL is live, account deletion works in-app, and the store privacy forms are filled in.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const oD=Object.freeze(Object.defineProperty({__proto__:null,AppPrivacyScreen:mg},Symbol.toStringTag,{value:"Module"}));function fg({platform:t="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=[{q:"How long does review actually take?",a:"Apple is often a day or less now; Google can be a few hours to a few days, and longer for a brand-new account or a sensitive permission. The killer isn't the queue — it's the round-trips. Every rejection restarts the clock, so the way to ship fast is to not get rejected."},{q:"What's the most common avoidable rejection?",a:"Incomplete or inaccurate metadata and missing reviewer access. If a feature is behind a login, the reviewer needs a working demo account (or a documented way in) — otherwise they can't test it and they reject. Screenshots that don't match the app and broken support/privacy links are close behind."},{q:"What does 'minimum functionality' mean?",a:"Apple in particular rejects apps that are too thin — a repackaged website, a static brochure, or something that could just be a web page. The app needs to do something that justifies being an app. If it's borderline, add real native value before submitting."},{q:"I got rejected — now what?",a:"Read the exact guideline they cite, fix that specific thing, and reply in Resolution Center / the Play policy console with what you changed. Don't resubmit blind. If you genuinely disagree, you can respond or appeal — but a clean, targeted fix is almost always faster than arguing."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(pe,{onBack:n,icon:e.jsx(Be,{size:26}),title:"Getting through review",meta:"Before you submit · about 20 minutes",assistKey:"app-review"}),e.jsx("p",{className:"lead",children:"Every store submission goes through a human (and automated) review, and it's where launches slip by weeks. The good news: almost every rejection is avoidable and predictable. Knock these out before you submit and most apps clear review on the first try."}),e.jsx(hn,{tone:"wait",title:"Rejections cost round-trips, not just time",children:"Each rejection sends you back to the end of the queue. Front-loading the common reasons is the single biggest thing you can do to ship on schedule."}),e.jsx("div",{className:"seclabel",children:"Clear these before submitting"}),e.jsx(mn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Complete, accurate metadata."})," Real screenshots that match the current app, a truthful description, and working support and privacy URLs. Placeholder or mismatched assets get rejected."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"A demo account for the reviewer."})," Anything behind a login needs working credentials (or a documented bypass) in the review notes — otherwise the reviewer can't test it and rejects."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Enough functionality to be an app."})," Especially on iOS, a thin wrapper around a website or a static brochure gets rejected for minimum functionality. Make sure it does something app-worthy."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Honest permissions and data use."})," Every permission you request needs a clear in-context reason, and your store privacy declaration has to match what the app does."]})]}),e.jsx(ot,{items:o}),e.jsx(ye,{assistKey:"app-review",topicName:"Getting through review"}),e.jsx(we,{label:"Mark review readiness as set up",note:"Do this once your metadata is complete, a reviewer demo account is in the notes, and permissions are all justified.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const iD=Object.freeze(Object.defineProperty({__proto__:null,AppReviewScreen:fg},Symbol.toStringTag,{value:"Module"})),K2=5e3,Fc=50;function J2(){const[t,n]=l.useState([]),[s,r]=l.useState(0),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[h,p]=l.useState(null),m=l.useRef("idle"),f=l.useRef([]),g=l.useRef(null);l.useEffect(()=>{f.current=t},[t]),l.useEffect(()=>{g.current=a},[a]);const b=l.useCallback(async()=>{if(m.current==="idle"){m.current="initial",c(!0),p(null);try{const v=await fetch(`/api/history?limit=${Fc}`);if(!v.ok)throw new Error(`HTTP ${v.status}`);const _=await v.json();n(_.entries??[]),r(_.total??0),o(_.nextCursor??null),_.error&&p(_.error)}catch(v){p(v instanceof Error?v.message:"Failed to load history")}finally{c(!1),m.current="idle"}}},[]),x=l.useCallback(async()=>{var _;if(m.current!=="idle")return;const v=(_=f.current[0])==null?void 0:_.commit.sha;if(!v){await b();return}m.current="poll";try{const j=await fetch(`/api/history?since=${encodeURIComponent(v)}`);if(!j.ok)throw new Error(`HTTP ${j.status}`);const k=await j.json(),S=new Set(f.current.map(C=>C.commit.sha)),w=(k.entries??[]).filter(C=>!S.has(C.commit.sha));w.length>0&&(n(C=>[...w,...C]),r(C=>C+w.length))}catch(j){p(j instanceof Error?j.message:"Failed to poll history")}finally{m.current="idle"}},[b]),y=l.useCallback(async()=>{if(m.current!=="idle")return;const v=g.current;if(v){m.current="more",u(!0);try{const _=await fetch(`/api/history?limit=${Fc}&before=${encodeURIComponent(v)}`);if(!_.ok)throw new Error(`HTTP ${_.status}`);const j=await _.json();n(k=>[...k,...j.entries??[]]),o(j.nextCursor??null),typeof j.total=="number"&&r(j.total)}catch(_){p(_ instanceof Error?_.message:"Failed to load more commits")}finally{u(!1),m.current="idle"}}},[]);return l.useEffect(()=>{b();const v=setInterval(()=>{x()},K2);return()=>clearInterval(v)},[b,x]),{rows:t,total:s,hasMore:a!==null,loading:i,loadingMore:d,error:h,loadMore:y,reload:b}}const Oa={rows:[],total:0,truncated:!1,repo:null,screenshotsRepoRelDir:"",loading:!1,error:null};function X2(t){const[n,s]=l.useState(Oa),r=(t==null?void 0:t.from)??null,a=(t==null?void 0:t.to)??null;return l.useEffect(()=>{if(r===null||a===null){s(Oa);return}let o=!1;s(c=>({...c,loading:!0,error:null}));const i=new URLSearchParams({from:r,to:a});return fetch(`/api/history?${i.toString()}`).then(async c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return await c.json()}).then(c=>{o||s({rows:c.entries??[],total:c.total??0,truncated:!!c.truncated,repo:c.repo??null,screenshotsRepoRelDir:c.screenshotsRepoRelDir??"",loading:!1,error:c.error??null})}).catch(c=>{o||s({...Oa,error:c instanceof Error?c.message:"Failed to load range"})}),()=>{o=!0}},[r,a]),n}function gg(t){const n=new Map;return t.forEach((s,r)=>{var o;const a=((o=s.entry)==null?void 0:o.scenarioScreenshots)??[];for(const i of a)n.has(i.name)||n.set(i.name,r)}),n}const Q2=[/\.test\.[jt]sx?$/,/\.spec\.[jt]sx?$/,/__tests__\//,/tests?\//];function Yi(t){return t.filter(n=>Q2.some(s=>s.test(n.path)))}function Z2(t){const n={},s={total:0,passed:0,failed:0},r=new Set,a=new Set,o=new Set,i=[];let c=0,d=0;for(const u of t){if(!u.entry){d++;continue}c++;const h=u.entry.type||"other";n[h]=(n[h]??0)+1,u.commit.authorName&&r.add(u.commit.authorName),u.entry.testResults&&(s.total+=u.entry.testResults.total,s.passed+=u.entry.testResults.passed,s.failed+=u.entry.testResults.failed);for(const p of Yi(u.entry.modifiedFiles??[]))o.add(p.path);for(const p of u.entry.scenarioScreenshots??[])a.has(p.name)||(a.add(p.name),i.push(p))}return{totalChanges:c,byType:n,testFilesTouched:o.size,testTotals:s,screenshots:i,contributors:[...r],hiddenCommitOnlyCount:d}}const eC=[{key:"all-time",label:"All time"},{key:"last-24h",label:"Last 24 hours"},{key:"last-3d",label:"Last 3 days"},{key:"last-week",label:"Last week"},{key:"last-month",label:"Last month"}],Ks=864e5;function tC(t,n){const s=n.toISOString();switch(t){case"last-24h":return{from:new Date(n.getTime()-Ks).toISOString(),to:s};case"last-3d":return{from:new Date(n.getTime()-3*Ks).toISOString(),to:s};case"last-week":return{from:new Date(n.getTime()-7*Ks).toISOString(),to:s};case"last-month":return{from:new Date(n.getTime()-30*Ks).toISOString(),to:s};case"all-time":case"custom":return null}}function nC(t){const n=new Date(t.from),s=new Date(t.to);if(isNaN(n.getTime())||isNaN(s.getTime()))return`${t.from} – ${t.to}`;const r=h=>h.toLocaleDateString("en-US",{month:"short"}),a=r(n),o=n.getDate(),i=n.getFullYear(),c=r(s),d=s.getDate(),u=s.getFullYear();return i===u&&n.getMonth()===s.getMonth()?`${a} ${o} – ${d}, ${u}`:i===u?`${a} ${o} – ${c} ${d}, ${u}`:`${a} ${o}, ${i} – ${c} ${d}, ${u}`}function bg({commit:t}){return e.jsxs("div",{className:"rounded-lg border px-4 py-3",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"var(--text-dim)"},children:[e.jsx("span",{className:"font-mono uppercase tracking-wide",style:{color:"var(--text-muted)"},children:"commit"}),e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:t.shortSha}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:km(t.timestamp)}),t.authorName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:t.authorName})]})]}),e.jsx("p",{className:"mt-1 text-sm truncate",style:{color:"var(--text-primary)"},children:t.subject})]})}const lD=Object.freeze(Object.defineProperty({__proto__:null,CommitOnlyHistoryRow:bg},Symbol.toStringTag,{value:"Module"}));function na({entry:t,commit:n,onSelectScreenshot:s}){const r=Yi(t.modifiedFiles??[]);return e.jsxs("div",{className:"rounded-lg border",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3",style:{borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`text-xs font-medium uppercase tracking-wide ${Sm(t.type)}`,children:t.type}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:km(t.timestamp)}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:"·"}),e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:n.shortSha}),n.authorName&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["· ",n.authorName]})]})]}),e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:t.title})]}),e.jsxs("div",{className:"px-4 py-3 flex flex-col gap-3",children:[t.userRequest&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:"Prompt"}),e.jsx(Wr,{children:t.userRequest})]}),(t.scenarioScreenshots??[]).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:"Screenshots"}),e.jsx(Mi,{screenshots:t.scenarioScreenshots??[],onSelect:s})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Tests"}),t.testResults&&e.jsx(Ur,{total:t.testResults.total,passed:t.testResults.passed,failed:t.testResults.failed})]}),r.length>0?e.jsx("ul",{className:"flex flex-col gap-0.5",children:r.map(a=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx(Gr,{status:a.status}),e.jsx("span",{className:"font-mono text-xs truncate",style:{color:"var(--text-secondary)"},children:a.path})]},a.path))}):e.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No test files changed"})]})]})]})}const cD=Object.freeze(Object.defineProperty({__proto__:null,HistoryEntryCard:na},Symbol.toStringTag,{value:"Module"}));function xg({selection:t,onChange:n,now:s=new Date}){const[r,a]=l.useState(""),[o,i]=l.useState(""),c=u=>{n({preset:u,range:tC(u,s)})},d=(u,h)=>{a(u),i(h),u&&h&&n({preset:"custom",range:{from:new Date(`${u}T00:00:00Z`).toISOString(),to:new Date(`${h}T23:59:59Z`).toISOString()}})};return e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[eC.map(u=>{const h=t.preset===u.key;return e.jsx("button",{type:"button",onClick:()=>c(u.key),"aria-pressed":h,className:`rounded border px-2.5 py-1 text-xs transition ${h?"border-[var(--accent-primary)] text-[var(--text-primary)]":"border-[var(--border-default)] text-[var(--text-muted)] hover:bg-[var(--bg-subtle)]"}`,children:u.label},u.key)}),e.jsx("span",{className:"mx-1 text-xs text-[var(--text-dim)]",children:"or"}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-[var(--text-dim)]",children:["From",e.jsx("input",{type:"date","aria-label":"Custom range start",value:r,onChange:u=>d(u.target.value,o),className:"rounded border border-[var(--border-default)] bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]"})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-[var(--text-dim)]",children:["To",e.jsx("input",{type:"date","aria-label":"Custom range end",value:o,onChange:u=>d(r,u.target.value),className:"rounded border border-[var(--border-default)] bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]"})]})]})}const dD=Object.freeze(Object.defineProperty({__proto__:null,HistoryRangeSelector:xg},Symbol.toStringTag,{value:"Module"}));function sC(t){const{rangeLabel:n,summary:s,rows:r,repo:a,screenshotsRepoRelDir:o}=t,i=(a==null?void 0:a.rawUrlTemplate)??null,c=[];c.push(`# Change digest — ${n}`),c.push(""),c.push(rC(s)),s.hiddenCommitOnlyCount>0&&(c.push(""),c.push(`_${s.hiddenCommitOnlyCount} non-journaled commit${s.hiddenCommitOnlyCount===1?"":"s"} hidden._`));const d=r.filter(u=>u.entry!==null);for(const u of d){const h=u.entry;c.push(""),c.push(`## ${h.title}`),c.push(""),c.push(`- **Type:** ${h.type}`),c.push(`- **Commit:** \`${u.commit.shortSha}\``),h.description&&(c.push(""),c.push(h.description));const p=Yi(h.modifiedFiles??[]);if(p.length>0){c.push(""),c.push("**Test files:**");for(const f of p)c.push(`- \`${f.path}\``)}const m=h.scenarioScreenshots??[];if(m.length>0)if(c.push(""),i)for(const f of m){if(!f.screenshotPath)continue;const g=i.replace("{sha}",u.commit.sha).replace("{path}",aC(o,f.screenshotPath));c.push(``)}else{c.push("**Screenshots (local only):**");for(const f of m)c.push(`- ${f.name}`)}}return c.join(`
|
|
104
|
+
`)}function rC(t){const n=[];n.push(`**${t.totalChanges}** change${t.totalChanges===1?"":"s"}`);const s=Object.entries(t.byType).map(([r,a])=>`${a} ${r}`);return s.length>0&&n.push(s.join(", ")),n.push(`${t.testFilesTouched} test file${t.testFilesTouched===1?"":"s"}`),t.testTotals.total>0&&n.push(`${t.testTotals.passed}/${t.testTotals.total} tests passed`),n.push(`${t.screenshots.length} screenshot${t.screenshots.length===1?"":"s"}`),n.join(" · ")}function aC(t,n){const s=t.replace(/\/+$/,""),r=n.replace(/^\/+/,"");return s?`${s}/${r}`:r}function yg({summary:t}){return e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[e.jsxs("span",{className:"text-[var(--text-primary)]",children:[t.totalChanges," change",t.totalChanges===1?"":"s"]}),Object.entries(t.byType).map(([n,s])=>e.jsxs("span",{className:Sm(n),children:[s," ",n]},n)),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.testFilesTouched," test file",t.testFilesTouched===1?"":"s"]}),e.jsx(Ur,{total:t.testTotals.total,passed:t.testTotals.passed,failed:t.testTotals.failed}),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.screenshots.length," screenshot",t.screenshots.length===1?"":"s"]}),t.contributors.length>0&&e.jsx("span",{className:"text-[var(--text-dim)]",children:t.contributors.join(", ")})]})}const uD=Object.freeze(Object.defineProperty({__proto__:null,HistoryDigestStatRow:yg},Symbol.toStringTag,{value:"Module"}));function vg({rangeLabel:t,summary:n,rows:s,repo:r,screenshotsRepoRelDir:a,truncated:o,onPreviewScreenshot:i}){const[c,d]=l.useState(!1),u=gg(s),h=async()=>{const p=sC({rangeLabel:t,summary:n,rows:s,repo:r,screenshotsRepoRelDir:a});try{await navigator.clipboard.writeText(p),d(!0),setTimeout(()=>d(!1),2e3)}catch{}};return n.totalChanges===0?e.jsxs("div",{children:[e.jsx(mo,{rangeLabel:t,onCopy:h,copied:c}),e.jsxs("div",{className:"py-10 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No changes in this window."}),n.hiddenCommitOnlyCount>0&&e.jsxs("p",{className:"mt-2 text-xs",children:[n.hiddenCommitOnlyCount," non-journaled commit",n.hiddenCommitOnlyCount===1?"":"s"," hidden."]})]})]}):e.jsxs("div",{children:[e.jsx(mo,{rangeLabel:t,onCopy:h,copied:c}),e.jsx(yg,{summary:n}),n.hiddenCommitOnlyCount>0&&e.jsxs("p",{className:"mb-3 text-xs text-[var(--text-dim)]",children:[n.hiddenCommitOnlyCount," non-journaled commit",n.hiddenCommitOnlyCount===1?"":"s"," hidden from this digest."]}),o&&e.jsxs("p",{className:"mb-3 text-xs text-[var(--accent-yellow,#eab308)]",children:["Showing the ",s.length," most recent changes in this window — narrow the range to see the rest."]}),n.screenshots.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-[var(--text-muted)]",children:"Screenshots"}),e.jsx(Mi,{screenshots:n.screenshots,onSelect:i?p=>i({...p,isLatest:u.get(p.name)===oC(s,p.name)}):void 0})]}),e.jsx("div",{className:"flex flex-col gap-3",children:s.map((p,m)=>p.entry?e.jsx(na,{entry:p.entry,commit:p.commit,onSelectScreenshot:i?f=>i({...f,isLatest:u.get(f.name)===m}):void 0},p.commit.sha):null)})]})}function mo({rangeLabel:t,onCopy:n,copied:s}){return e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-primary)]",children:t}),e.jsx("button",{type:"button",onClick:n,className:"rounded border border-[var(--border-default)] px-2.5 py-1 text-xs text-[var(--text-muted)] hover:bg-[var(--bg-subtle)]",children:s?"Copied!":"Copy summary"})]})}function oC(t,n){return t.findIndex(s=>{var r;return(((r=s.entry)==null?void 0:r.scenarioScreenshots)??[]).some(a=>a.name===n)})}const hD=Object.freeze(Object.defineProperty({__proto__:null,DigestHeader:mo,HistoryDigest:vg},Symbol.toStringTag,{value:"Module"}));function jg({onPreviewScreenshot:t}={}){const[n,s]=l.useState({preset:"all-time",range:null});return e.jsxs(Dt,{children:[e.jsx(xg,{selection:n,onChange:s}),n.range?e.jsx(iC,{range:n.range,onPreviewScreenshot:t}):e.jsx(lC,{onPreviewScreenshot:t})]})}function iC({range:t,onPreviewScreenshot:n}){const{rows:s,truncated:r,repo:a,screenshotsRepoRelDir:o,loading:i,error:c}=X2(t);if(i)return e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading digest..."});if(c)return e.jsx("div",{className:"py-12",children:e.jsx(ft,{text:`Failed to load digest: ${c}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});const d=Z2(s);return e.jsx(vg,{rangeLabel:nC(t),summary:d,rows:s,repo:a,screenshotsRepoRelDir:o,truncated:r,onPreviewScreenshot:n})}function lC({onPreviewScreenshot:t}){const{rows:n,total:s,hasMore:r,loading:a,loadingMore:o,error:i,loadMore:c}=J2();if(a)return e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading history..."});if(i&&n.length===0)return e.jsx("div",{className:"py-12",children:e.jsx(ft,{text:`Failed to load history: ${i}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});if(n.length===0)return e.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No commits yet."}),e.jsx("p",{className:"mt-2 text-sm",children:"Commits and journal entries will appear here as you build features."})]});const d=Math.max(s,n.length),u=gg(n);return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mb-3 text-xs",style:{color:"var(--text-dim)"},children:[n.length," of ",d," commit",d===1?"":"s"]}),e.jsx("div",{className:"flex flex-col gap-3",children:n.map((h,p)=>h.entry?e.jsx(na,{entry:h.entry,commit:h.commit,onSelectScreenshot:t?m=>t({...m,isLatest:u.get(m.name)===p}):void 0},h.commit.sha):e.jsx(bg,{commit:h.commit},h.commit.sha))}),r?e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>void c(),disabled:o,className:"rounded border border-[var(--border)] px-3 py-1 text-sm text-[var(--text-muted)] hover:bg-[var(--bg-subtle)] disabled:opacity-50",children:o?"Loading...":"Load older commits"})}):null]})}const pD=Object.freeze(Object.defineProperty({__proto__:null,HistoryTab:jg},Symbol.toStringTag,{value:"Module"})),cC="I came to the Build tab to find the AI waiting for me but never saw any of the idle notifications — no sound, no orange dot on the Build tab, no idle banner. Please diagnose using the trace below.\n\nStart with the **UI idle trace** section: a single `debounce-cancelled` line with a `trigger` field identifies which silent path killed the 1500ms debounce before `debounce-resolved` could fire. Cross-reference with the **Rust idle trace** and **editor-server.log** sections to confirm the backend actually sent `agent-idle` and to see the timing.";function dC(){const t=typeof Notification<"u"?Notification.permission:"unknown",n=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!1,s=typeof document<"u"?document.hidden:!1;let r=null;try{r=typeof localStorage<"u"?localStorage.getItem("codeyam.idleDebug"):null}catch{}const a=typeof navigator<"u"?navigator.userAgent:"unknown";return{notificationPermission:t,hasFocus:n,hidden:s,idleDebug:r,userAgent:a}}function zc(t){return t.length===0?"_(no events in window)_":`\`\`\`jsonl
|
|
105
|
+
${t.map(s=>JSON.stringify(s)).join(`
|
|
106
|
+
`)}
|
|
107
|
+
\`\`\``}function Aa(t,n){return t.trim().length===0?`_(${n} empty)_`:`\`\`\`
|
|
108
|
+
${t}
|
|
109
|
+
\`\`\``}function uC(t){var x,y,v;const{bundle:n,browser:s,uiBufferText:r,prompt:a,agentName:o}=t,i=(n==null?void 0:n.now)??new Date().toISOString(),c=(n==null?void 0:n.session)??si(),d=(n==null?void 0:n.windowMinutes)??10,u=((x=n==null?void 0:n.environment)==null?void 0:x.editorVersion)??"unknown",h=((y=n==null?void 0:n.environment)==null?void 0:y.platform)??"unknown",p=((v=n==null?void 0:n.environment)==null?void 0:v.projectDir)??"unknown",m=(a??cC).trim(),f=[`- Notification.permission: ${s.notificationPermission}`,`- document.hasFocus(): ${s.hasFocus}`,`- document.hidden: ${s.hidden}`,`- localStorage.codeyam.idleDebug: ${s.idleDebug===null?"(unset)":JSON.stringify(s.idleDebug)}`,`- userAgent: ${s.userAgent}`].join(`
|
|
110
|
+
`),g=n&&n.truncations.length>0?`> **Truncations:** ${n.truncations.join("; ")}`:"";return["# CodeYam Notification Debug Bundle","",m,"","---","",`**Captured:** ${i}`,`**UI session:** ${c} (window: last ${d} minutes)`,`**Editor version:** ${u}`,`**Platform:** ${h}`,`**Project:** ${p}`,o?`**Agent:** ${o}`:null,"","**Browser state:**",f,"",g,"","## UI idle trace (persisted)","",zc((n==null?void 0:n.uiTrace)??[]),"","## UI idle trace (in-memory ring buffer — may be ahead of persisted)","",Aa(r,"in-memory buffer"),"","## Rust idle trace","",zc((n==null?void 0:n.rustTrace)??[]),"","## editor-server.log (filtered to idle= within window)","",Aa((n==null?void 0:n.editorServerLog)??"","editor-server.log"),"","## dev-server.log (last lines)","",Aa((n==null?void 0:n.devServerLog)??"","dev-server.log"),""].filter(_=>_!==null).join(`
|
|
111
|
+
`)}async function hC(t={}){const n=encodeURIComponent(si());let s=null,r=null;try{const c=await fetch(`/api/idle-trace/bundle?session=${n}&minutes=10`);c.ok?s=await c.json():r=`HTTP ${c.status}`}catch(c){r=c instanceof Error?c.message:String(c)}const a=dC(),o=wk({agentName:t.agentName});return{markdown:uC({bundle:s,browser:a,uiBufferText:o,prompt:t.prompt,agentName:t.agentName}),bundle:s,error:r}}const pC=1500;function mC(t=pC){const[n,s]=l.useState(null),r=l.useRef(null),a=l.useCallback((o,i)=>{r.current!==null&&clearTimeout(r.current),s(o),r.current=setTimeout(()=>{s(null),r.current=null},i??t)},[t]);return l.useEffect(()=>()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),{label:n,flash:a}}const fC=2500;function wg({agentName:t}){const[n,s]=l.useState(!1),{label:r,flash:a}=mC(fC),o=async()=>{s(!0);const{markdown:i,bundle:c,error:d}=await hC({agentName:t});try{await navigator.clipboard.writeText(i);const u=((c==null?void 0:c.uiTrace.length)??0)+((c==null?void 0:c.rustTrace.length)??0),h=Math.round(i.length/1024*10)/10,p=d?`Copied (offline — ${u} events, ${h} KB)`:`Copied ${u} events · ${h} KB`;a(p)}catch{a("Copy failed")}finally{s(!1)}};return e.jsx("button",{onClick:()=>void o(),disabled:n,className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors font-medium",style:{background:"transparent",color:"var(--text-secondary)"},"data-testid":"notification-debug-copy",children:r??(n?"Gathering bundle…":"Debug Notifications")})}const mD=Object.freeze(Object.defineProperty({__proto__:null,DebugNotificationsButton:wg},Symbol.toStringTag,{value:"Module"})),_g=1,Js={sound:"soft-double-tap",systemNotification:!0,idleOnStop:!0,idleOnNotification:!0,settingsVersion:_g},kg=[{id:"soft-double-tap",label:"Soft double tap"},{id:"gentle-chime",label:"Gentle chime"},{id:"warm-ding",label:"Warm ding"},{id:"mellow-two-tone",label:"Mellow two-tone"},{id:"triangle-bell",label:"Triangle bell"},{id:"off",label:"No sound"}],Sg="codeyam-editor-notifications";function Ng(){try{const t=localStorage.getItem(Sg);if(!t)return Js;const n=JSON.parse(t),s={...Js,...n};return typeof(n==null?void 0:n.settingsVersion)!="number"&&(s.idleOnStop=Js.idleOnStop,s.settingsVersion=_g),s}catch{return Js}}function Cg(t){localStorage.setItem(Sg,JSON.stringify(t))}const gC={"soft-double-tap":t=>([0,.12].forEach(n=>{const s=t.createOscillator(),r=t.createGain();s.connect(r),r.connect(t.destination),s.type="sine",s.frequency.value=392,r.gain.setValueAtTime(.25,t.currentTime+n),r.gain.exponentialRampToValueAtTime(.01,t.currentTime+n+.1),s.start(t.currentTime+n),s.stop(t.currentTime+n+.1)}),{count:2,longestStopSec:.22}),"gentle-chime":t=>{const n=t.createOscillator(),s=t.createGain();return n.connect(s),s.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(523,t.currentTime),n.frequency.setValueAtTime(659,t.currentTime+.15),s.gain.setValueAtTime(.3,t.currentTime),s.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),n.start(),n.stop(t.currentTime+.4),{count:1,longestStopSec:.4}},"warm-ding":t=>{const n=t.createOscillator(),s=t.createGain();return n.connect(s),s.connect(t.destination),n.type="sine",n.frequency.value=330,s.gain.setValueAtTime(.35,t.currentTime),s.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),n.start(),n.stop(t.currentTime+.6),{count:1,longestStopSec:.6}},"mellow-two-tone":t=>{const n=t.createOscillator(),s=t.createGain();return n.connect(s),s.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(294,t.currentTime),n.frequency.setValueAtTime(440,t.currentTime+.18),s.gain.setValueAtTime(.3,t.currentTime),s.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),n.start(),n.stop(t.currentTime+.5),{count:1,longestStopSec:.5}},"triangle-bell":t=>{const n=t.createOscillator(),s=t.createGain();return n.connect(s),s.connect(t.destination),n.type="triangle",n.frequency.value=523,s.gain.setValueAtTime(.4,t.currentTime),s.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),n.start(),n.stop(t.currentTime+.8),{count:1,longestStopSec:.8}}};function Ra(t,n){const s=n;re(t,{name:s==null?void 0:s.name,message:s==null?void 0:s.message})}function Ki(t){if(t==="off")return;re("audio-playsound-entered",{soundId:t});let n;try{n=new AudioContext}catch(r){Ra("audio-context-failed",r);return}re("audio-context-created",{state:n.state});const s=()=>{let r;try{r=gC[t](n)}catch(a){Ra("audio-context-failed",a),n.close().catch(()=>{});return}re("audio-oscillators-scheduled",{soundId:t,count:r.count,longestStopSec:r.longestStopSec}),setTimeout(()=>{n.close().then(()=>re("audio-context-closed")).catch(()=>{})},(r.longestStopSec+.1)*1e3)};n.state==="running"?s():n.state==="suspended"?(re("audio-context-resume-attempted"),n.resume().then(()=>{re("audio-context-resume-ok",{state:n.state}),s()},r=>{Ra("audio-context-resume-failed",r),n.close().catch(()=>{})})):(re("audio-context-failed",{name:"UnexpectedState",message:`AudioContext state "${n.state}"`}),n.close().catch(()=>{}))}function fo({label:t,checked:n,onChange:s,className:r}){return e.jsxs("label",{className:`flex items-center gap-2 cursor-pointer${r?` ${r}`:""}`,children:[e.jsx("input",{type:"checkbox",checked:n,onChange:a=>s(a.target.checked),className:"accent-green-500"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t})]})}const fD=Object.freeze(Object.defineProperty({__proto__:null,IdleTriggerCheckbox:fo},Symbol.toStringTag,{value:"Module"}));function Tg({settings:t,onChange:n,providerLabel:s}){const r=t.idleOnStop??!0,a=t.idleOnNotification??!0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Notification sound"}),e.jsx("div",{className:"flex flex-col gap-0.5",children:kg.map(o=>e.jsx("button",{onClick:()=>{n({...t,sound:o.id}),o.id!=="off"&&Ki(o.id)},className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors",style:{background:t.sound===o.id?"var(--bg-input)":"transparent",color:t.sound===o.id?"var(--text-primary)":"var(--text-secondary)"},children:o.label},o.id))})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Trigger idle on"}),e.jsx(fo,{label:`${s} stops`,checked:r,onChange:o=>n({...t,idleOnStop:o})}),e.jsx(fo,{label:`${s} sends a notification`,checked:a,onChange:o=>n({...t,idleOnNotification:o}),className:"mt-1"})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.systemNotification,onChange:o=>{const i=o.target.checked;n({...t,systemNotification:i}),i&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"System notification"})]}),e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--text-dim)"},children:"Shows when tab is not visible"}),typeof Notification<"u"&&Notification.permission==="denied"&&e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--accent-red, #ef4444)"},children:"Notifications are blocked. Click the lock icon in your address bar → Site settings → Notifications → Allow"})]})]})}const gD=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsControls:Tg},Symbol.toStringTag,{value:"Module"}));function Pg({settings:t,onChange:n,agentName:s,providerLabel:r}){const[a,o]=l.useState(!1),i=l.useRef(null),c=t.idleOnStop??!1,d=t.idleOnNotification??!0,u=t.sound!=="off"||t.systemNotification||c||d;return l.useEffect(()=>{if(!a)return;const h=p=>{i.current&&!i.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[a]),e.jsxs("div",{className:"h-7 flex items-center px-3 text-xs shrink-0",style:{background:"var(--bg-nav)",borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",ref:i,children:[e.jsx("button",{onClick:()=>{o(!a),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"cursor-pointer transition-colors",style:{color:u?"var(--accent-green)":"var(--text-dim)",fontSize:"11px"},children:u?"Notifications On":"Notifications Off"}),a&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx(Tg,{settings:t,onChange:n,providerLabel:r}),e.jsx("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:e.jsx(wg,{agentName:s})})]})]})]})}const bD=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsPopover:Pg},Symbol.toStringTag,{value:"Module"})),Og="codeyam-editor-notifications-prompted",bC="codeyam-editor-notifications";function Ag(){try{localStorage.setItem(Og,"1")}catch{}}function xC(){try{return localStorage.getItem(Og)!==null||localStorage.getItem(bC)!==null}catch{return!0}}function Rg({settings:t,onChange:n,providerLabel:s}){const[r,a]=l.useState(()=>!xC());if(!r)return null;const o=()=>{Ag(),a(!1)},i=()=>{n({...t,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission(),o()};return e.jsxs("div",{className:"rounded-lg px-4 py-2.5 mb-3 flex items-center gap-3",style:{background:"var(--surface-card)",border:"1px solid var(--lime-300)"},children:[e.jsx("span",{"aria-hidden":"true",style:{fontSize:15,lineHeight:1,color:"var(--lime-300)"},children:"🔔"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-strong)"},children:["Get notified when ",s," finishes"]}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-faint)",marginLeft:8},children:"We'll ping you when the agent stops or pauses."})]}),e.jsx("button",{onClick:i,className:"shrink-0 cursor-pointer transition-colors",style:{background:"var(--action-bg)",color:"var(--action-fg)",fontSize:"12.5px",fontWeight:600,borderRadius:9,padding:"7px 14px"},children:"Enable"}),e.jsx("button",{onClick:o,className:"shrink-0 cursor-pointer",style:{color:"var(--text-faint)",fontSize:"12px"},children:"Not now"})]})}const xD=Object.freeze(Object.defineProperty({__proto__:null,NotificationSetupBanner:Rg},Symbol.toStringTag,{value:"Module"}));function Eg(){const[t,n]=l.useState(null);return l.useEffect(()=>{fetch("/api/editor-setup-answers").then(s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}).then(s=>{n(s!==null)}).catch(()=>{n(!1)})},[]),{saved:t}}function Mg({appStatsLength:t,configLoading:n,scenariosLoading:s,setupAnswersSaved:r,hasStepState:a}){return t===0&&!n&&!s&&r===!1&&!a}function Ig({projectDescription:t}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Building your project…"}),e.jsx("blockquote",{className:"mt-4 border-l-2 border-[var(--accent-active)] pl-4 text-sm italic text-[var(--text-dim)]",children:t}),e.jsxs("p",{className:"mt-6 text-sm text-[var(--text-dim)]",children:["Your app will appear here as it’s built. The agent is scaffolding it now on the ",e.jsx("strong",{children:"Build"})," tab — open it to follow along."]})]})}const yD=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateBuildingPanel:Ig},Symbol.toStringTag,{value:"Module"}));function Lg(){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"No app scaffolded yet"}),e.jsxs("p",{className:"mt-4 text-sm text-[var(--text-dim)]",children:["Your project hasn’t been scaffolded yet. Open the"," ",e.jsx("strong",{children:"Build"})," tab to start building."]})]})}const vD=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateNoAppPanel:Lg},Symbol.toStringTag,{value:"Module"}));function Dg({onClick:t}){return e.jsx("button",{type:"button",onClick:t,"data-testid":"app-overview-empty-open-build",className:"mt-6 inline-flex items-center gap-2 rounded border border-[var(--accent-active)] bg-[var(--accent-active)] px-4 py-2 text-xs font-medium uppercase tracking-wide text-black transition-colors hover:bg-[var(--accent-active)]/90 cursor-pointer",children:"Open Build tab"})}const jD=Object.freeze(Object.defineProperty({__proto__:null,OpenBuildTabButton:Dg},Symbol.toStringTag,{value:"Module"}));function Fg({projectDescription:t,onOpenBuildTab:n}){const s=t!==null&&t.trim().length>0;return e.jsxs("div",{className:"mx-auto max-w-2xl px-5 py-12 text-[var(--text-primary)]",children:[s?e.jsx(Ig,{projectDescription:t}):e.jsx(Lg,{}),e.jsx(Dg,{onClick:n})]})}const wD=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyState:Fg},Symbol.toStringTag,{value:"Module"}));function zg({stats:t,onSelectApp:n,testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o}){return e.jsx("div",{className:"flex flex-col gap-4",children:t.map(i=>e.jsx(hm,{stats:i,onClick:()=>n(i.app.dir),testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o},i.app.dir))})}const _D=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewGrid:zg},Symbol.toStringTag,{value:"Module"}));function $g({projectTitle:t,coverage:n,onCoverageClick:s}){return e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t}),e.jsx(Ei,{coverage:n,testId:"app-overview-coverage",onClick:s})]})}const kD=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewHeader:$g},Symbol.toStringTag,{value:"Module"}));function Bg(){return e.jsxs("span",{className:"hbuild-dots","aria-hidden":"true",children:[e.jsx("span",{children:"."}),e.jsx("span",{children:"."}),e.jsx("span",{children:"."})]})}const SD=Object.freeze(Object.defineProperty({__proto__:null,AnimatedEllipsis:Bg},Symbol.toStringTag,{value:"Module"}));function Hg({screenshotPath:t}){return e.jsx("span",{className:"hbuild-thumb",children:t?e.jsx(At,{screenshotPath:t,alt:""}):e.jsx("span",{className:"hbuild-nothumb",children:"No preview yet"})})}const ND=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardThumbnail:Hg},Symbol.toStringTag,{value:"Module"})),yC=28,vC=21,jC=4,wC=5,_C={1:"Plan",2:"Explore",3:"Confirm",4:"Prepare",5:"Seed Data",6:"Live Preview Loop",7:"Verify Prototype",8:"Confirm Mode",9:"Prepare Demo",10:"Approve Demo",11:"Deconstruct",12:"Extract TDD",13:"Glossary",14:"Dependency Graph",15:"Isolation Routes",16:"Component Coverage",17:"Register Scenarios",18:"Capture Scenarios",19:"Curate Scenarios",20:"App Scenarios",21:"Present",22:"Reconcile",23:"Journal",24:"Pre-Commit Sync",25:"Finalize",26:"Commit",27:"Push",28:"Feature Complete"},kC={1:"Plan",2:"Explore",3:"Confirm Plan",4:"Prepare",5:"Prototype",6:"Confirm Mode",7:"Approve Demo",8:"Deconstruct",9:"Extract TDD",10:"Test Tooling",11:"Glossary",12:"Dependency Graph",13:"Present",14:"Review",15:"Reconcile",16:"Journal",17:"Pre-Commit Sync",18:"Finalize",19:"Commit",20:"Push",21:"Feature Complete"},SC={1:"Triage",2:"Route",3:"Wrap Up",4:"Complete"},NC={1:"Ground",2:"Generate",3:"Iterate",4:"Resolve",5:"Return"},CC={1:"Plan the feature and confirm the approach with the user before writing any code.",2:"Map out all the files you'll need to read or modify; check for reference implementations.",3:"Repeat the plan back to the user and gate on explicit approval before any code is written.",4:"Prepare the project environment and dependencies for prototyping.",5:"Wire up API routes and seed the database with realistic, demo-rich data.",6:"Iterate on the prototype with the live preview — navigate, edit, verify.",7:"Verify the prototype's routes, images, and client errors before presenting.",8:"Confirm or switch the workflow mode before the demo.",9:"Capture and show a verified live-preview demonstration of the change.",10:"Hand the live preview to the user for interactive testing and get approval.",11:"Read the code and plan all component and function extractions.",12:"Extract components and functions via TDD; cover library functions with multiple tests.",13:"Register every new test and glossary entry produced in the prior step.",14:"Rebuild the dependency graph after extraction.",15:"Create isolation routes for every extracted visual component.",16:"Decide per-component scenario coverage (multi-state or untestability) for every isolated component.",17:"Register component-level scenarios (one per state) for every visual component.",18:"Capture and verify component-level scenarios; gate on visual coverage before advancing.",19:"Curate the existing app-scenario set — review, consolidate, dedup, and edit in place — before registering new scenarios.",20:"Create app-level scenarios that show full pages with realistic data.",21:"Final approval gate — recapture screenshots and present a summary of all work to the user.",22:"Run the audit gate, reconcile any registry/glossary drift until clean.",23:"Create or update the journal entry documenting what was built.",24:"Sync local state with the remote so the next commit lands on a merged tree.",25:"Finalize the session — run the full suite once.",26:"Commit all changes to git.",27:"Push the branch to the remote repository.",28:"Fire the feature-complete modal — the cycle ends here."},TC={1:"Plan the feature and confirm the approach with the user before writing any code.",2:"Map out all the files you'll need to read or modify; check for reference implementations.",3:"Repeat the plan back to the user and gate on explicit approval before any code is written.",4:"Prepare the project environment.",5:"Build the feature. Tests come at the Deconstruct cluster.",6:"Confirm or switch the workflow mode before the demo.",7:"Show the prototype results and gate on the user's yes/iterate decision before any verification work.",8:"Read the code and plan all function/method/helper extractions.",9:"Extract functions/methods/helpers via TDD; every change must have a red-if-reverted test.",10:"Test-runner and tooling discipline for the backend extract-TDD loop.",11:"Register every new test and glossary entry produced in the prior step.",12:"Rebuild the dependency graph after extraction.",13:"Author the session narrative in full, then present the /results page with the behavior gallery, tests, and changed files.",14:"Review the results page with the user — summary, ways-to-test, weakened-test flag, audit status — and gate on the Save / Fast-Commit / change decision.",15:"Run the audit gate, reconcile any registry/glossary drift until clean.",16:"Re-validate the session narrative, reconciling only what changed since Present, then create the journal entry.",17:"Sync local state with the remote so the next commit lands on a merged tree.",18:"Finalize the session — run the full suite once.",19:"Commit all changes to git.",20:"Push the branch to the remote repository.",21:"Fire the feature-complete modal — the cycle ends here."},PC={1:"Read how legible the request is: a build, a clear non-build, or a request whose goal the user has not settled yet.",2:"Route the classified request: hand off to a build flow, work it directly, or orient a user who does not yet know what they want.",3:"Inventory what changed on disk and decide with the user what, if anything, to commit.",4:"Return the editor to the beginning state so a build or another assist request can start."},OC={1:"Establish what the surface being modified actually looks like today before generating any mockup.",2:"Generate the round's mockups as variations grounded in the current state.",3:"Dwell here: iterate with the user until they pick a direction or abandon the round.",4:"Resolve the round — attach the selected design to the work in flight, or archive and discard.",5:"Return control to the invoking context — the build session's prototype phase or the ad-hoc caller."},AC={1:"Understanding your idea",2:"Looking through your project",3:"Confirming the approach with you",4:"Preparing your workspace",5:"Adding sample data",6:"Building your app",7:"Checking the prototype",8:"Confirming the next step with you",9:"Showing you the result",10:"Trying it out together",11:"Reading the code carefully",12:"Adding tests",13:"Documenting the building blocks",14:"Mapping connections in your code",15:"Setting up isolation routes",16:"Checking component coverage",17:"Registering component snapshots",18:"Capturing component snapshots",19:"Curating existing snapshots",20:"Capturing whole-page snapshots",21:"Showing you the final review",22:"Reconciling everything",23:"Writing a journal entry",24:"Syncing with the latest",25:"Finalizing the build",26:"Saving your changes",27:"Pushing your work",28:"All done"},RC={1:"Understanding your idea",2:"Looking through your project",3:"Confirming the approach with you",4:"Preparing your workspace",5:"Building your app",6:"Confirming the next step with you",7:"Showing you the result",8:"Reading the code carefully",9:"Adding tests",10:"Setting up test tooling",11:"Documenting the building blocks",12:"Mapping connections in your code",13:"Putting together your results",14:"Showing you the final review",15:"Reconciling everything",16:"Writing a journal entry",17:"Syncing with the latest",18:"Finalizing the build",19:"Saving your changes",20:"Pushing your work",21:"All done"},EC={1:"Working out what you need",2:"Deciding how to help",3:"Checking this is what you wanted",4:"All done"},MC={1:"Learning what you like",2:"Sketching some options",3:"Refining the design with you",4:"Applying the design you picked",5:"Back to building"},IC=[{phaseId:"understand",phaseLabel:"Understanding your idea",phaseSteps:[1,2,3]},{phaseId:"setup",phaseLabel:"Setting things up",phaseSteps:[4]},{phaseId:"build",phaseLabel:"Building your app",phaseSteps:[5,6,7,8,9,10]},{phaseId:"tidy",phaseLabel:"Making the code maintainable",phaseSteps:[11,12,13,14,15,16,17,18,19,20]},{phaseId:"review",phaseLabel:"Final Review",phaseSteps:[21,22,23,24,25]},{phaseId:"save",phaseLabel:"Saving your work",phaseSteps:[26,27,28]}],LC=[{phaseId:"understand",phaseLabel:"Understanding your idea",phaseSteps:[1,2,3]},{phaseId:"setup",phaseLabel:"Setting things up",phaseSteps:[4]},{phaseId:"build",phaseLabel:"Building your app",phaseSteps:[5,6,7]},{phaseId:"tidy",phaseLabel:"Making the code maintainable",phaseSteps:[8,9,10,11,12]},{phaseId:"review",phaseLabel:"Final Review",phaseSteps:[13,14,15,16,17,18]},{phaseId:"save",phaseLabel:"Saving your work",phaseSteps:[19,20,21]}],DC=[{phaseId:"assist-understand",phaseLabel:"Working out what you need",phaseSteps:[1]},{phaseId:"assist-act",phaseLabel:"Getting it done",phaseSteps:[2]},{phaseId:"assist-finish",phaseLabel:"Wrapping up",phaseSteps:[3,4]}],FC=[{phaseId:"design-understand",phaseLabel:"Learning what you like",phaseSteps:[1]},{phaseId:"design-explore",phaseLabel:"Exploring some looks",phaseSteps:[2,3]},{phaseId:"design-finish",phaseLabel:"Settling on a direction",phaseSteps:[4,5]}],zC={ui:_C,backend:kC,assist:SC,design:NC},$C={ui:CC,backend:TC,assist:PC,design:OC},BC={ui:yC,backend:vC,assist:jC,design:wC},HC={ui:"UI Flow",backend:"Backend Flow",assist:"Assist Flow",design:"Design Round"},qC=["ui","backend","assist","design"];function _t(t){return qC.includes(t)?t:"ui"}function Ji(t,n){return zC[_t(n)][t]??"?"}function qg(t,n){return $C[_t(n)][t]??""}function Xi(t){return BC[_t(t)]}function Wg(t){return HC[_t(t)]}function WC(t,n){const s=_t(n);return{description:qg(t,s),label:Ji(t,s),prefix:Wg(s),totalSteps:Xi(s)}}const GC={ui:AC,backend:RC,assist:EC,design:MC},UC={ui:IC,backend:LC,assist:DC,design:FC};function Gg(t,n){return GC[_t(n)][t]??""}function Ug(t){return UC[_t(t)]}function VC(t,n){const s=Ug(n);return s.find(a=>a.phaseSteps.includes(t))??s[0]}function YC(t,n){var r;const s=_t(n);return{...Vg(t,s),phaseLabel:((r=VC(t,s))==null?void 0:r.phaseLabel)??"",description:qg(t,s)}}function Vg(t,n){const s=_t(n);return KC(Gg(t,s),Ji(t,s))}function KC(t,n){return t===""||t===n?{primary:t||n,secondary:null}:{primary:t,secondary:n}}function Yg({position:t,phase:n,mode:s}){return!s&&!t?null:e.jsxs("span",{className:"hbuild-step",children:[s?e.jsx("span",{className:"hbuild-flow",children:Wg(s)}):null,t?e.jsxs("span",{className:"hbuild-pos",children:[t,":"]}):null,n?e.jsx("span",{className:"hbuild-phase",children:n}):null]})}const CD=Object.freeze(Object.defineProperty({__proto__:null,BuildingStepLine:Yg},Symbol.toStringTag,{value:"Module"})),JC={building:{state:"Building",ellipsis:!0,attn:!1},"needs-input":{state:"Needs you",ellipsis:!1,attn:!0},waiting:{state:"Paused",ellipsis:!1,attn:!0}};function Kg({feature:t,stepLabel:n,stepPosition:s=null,status:r="building",progress:a=null,mode:o,thumbnailPath:i=null,onOpen:c}){const d=JC[r],u=r==="building";return e.jsxs("button",{type:"button",className:"hbuild-card active"+(d.attn?" attn":""),onClick:c,children:[e.jsx(Hg,{screenshotPath:i}),e.jsxs("span",{className:"hbuild-main",children:[e.jsxs("span",{className:"hbuild-title",children:[u?e.jsx("span",{className:"hbuild-spinner","aria-hidden":"true"}):null,t,e.jsxs("span",{className:"hbuild-state",children:[d.state,d.ellipsis?e.jsx(Bg,{}):null]})]}),e.jsx(Yg,{position:s,phase:n,mode:o}),u?e.jsx("span",{className:"hbuild-bar",children:e.jsx("span",{style:{width:a!=null?`${Math.round(a*100)}%`:"12%"}})}):null]}),e.jsxs("span",{className:"hbuild-cta",children:["Build ",e.jsx("span",{"aria-hidden":"true",children:"→"})]})]})}const TD=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardActive:Kg},Symbol.toStringTag,{value:"Module"}));function Jg({lastBuiltLabel:t,onStart:n}){return e.jsxs("button",{type:"button",className:"hbuild-card",onClick:n,children:[e.jsxs("span",{className:"hbuild-main",children:[e.jsx("span",{className:"hbuild-ready",children:"Ready to build?"}),t?e.jsxs("span",{className:"hbuild-last",children:["Your last build: ",e.jsx("b",{children:t})]}):null]}),e.jsxs("span",{className:"hbuild-cta",children:["Build ",e.jsx("span",{"aria-hidden":"true",children:"→"})]})]})}const PD=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardIdle:Jg},Symbol.toStringTag,{value:"Module"}));function Xg({onReset:t}){return e.jsxs("button",{type:"button","data-testid":"build-status-reset",onClick:t,className:"hbuild-reset",children:[e.jsx("span",{"aria-hidden":"true",children:"⊗"})," Reset build"]})}const OD=Object.freeze(Object.defineProperty({__proto__:null,BuildResetLink:Xg},Symbol.toStringTag,{value:"Module"}));function Qi({isBuilding:t,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,thumbnailPath:c=null,lastBuiltLabel:d,onOpenBuilding:u,onStartNewFeature:h,onResetBuild:p}){return t?e.jsxs(e.Fragment,{children:[e.jsx(Kg,{feature:n||"your latest change",stepLabel:s,stepPosition:r,status:a,progress:o,mode:i,thumbnailPath:c,onOpen:u}),p?e.jsx(Xg,{onReset:p}):null]}):e.jsx(Jg,{lastBuiltLabel:d,onStart:h??u})}const AD=Object.freeze(Object.defineProperty({__proto__:null,BuildingDoor:Qi},Symbol.toStringTag,{value:"Module"}));function Qg({isBuilding:t,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,onOpenBuilding:c,onResetBuild:d}){return t?e.jsx("section",{"data-testid":"home-build-status-section",className:"mt-6 mb-6",children:e.jsx(Qi,{isBuilding:t,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r,buildingStatus:a,buildingProgress:o,buildingMode:i,onOpenBuilding:c,onStartNewFeature:c,onResetBuild:d})}):null}const RD=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildStatusSection:Qg},Symbol.toStringTag,{value:"Module"}));async function XC(t){try{t.description&&await fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:t.description,allowOverwrite:!0})});const n={appFormats:t.appFormats,techStackId:t.techStackId,designApproach:t.designApproach};t.defaultDevice&&(n.defaultDevice=t.defaultDevice),await fetch("/api/editor-setup-answers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}const $c=["prompt","design-approach","notifications"];function Bc(t){return t==="files"||t==="chat"?[...$c,"design-details"]:$c}const Zg="codeyam.questionnaire.draft";function Zi(t){return`${Zg}:${t}`}function QC(t){if(t===null||typeof t!="object")return!1;const n=t;if(typeof n.step!="number"||!Number.isFinite(n.step)||typeof n.savedAt!="string"||n.designChatLaunched!==void 0&&typeof n.designChatLaunched!="boolean")return!1;const s=n.answers;if(s===null||typeof s!="object")return!1;const r=s;return!(!Array.isArray(r.appFormats)||!r.appFormats.every(a=>typeof a=="string")||typeof r.description!="string"||r.techStackId!==null&&typeof r.techStackId!="string"||r.designApproach!==null&&typeof r.designApproach!="string"||r.defaultDevice!==null&&typeof r.defaultDevice!="string")}function Ea(t){try{const n=localStorage.getItem(Zi(t));if(n===null)return null;const s=JSON.parse(n);return QC(s)?s:null}catch{return null}}function ZC(t,n){try{localStorage.setItem(Zi(t),JSON.stringify(n))}catch{}}function e5(t){try{localStorage.removeItem(Zi(t))}catch{}}function t5(){try{localStorage.removeItem(Zg)}catch{}}function n5(){const[t,n]=l.useState([]);return l.useEffect(()=>{fetch("/api/editor-stacks").then(s=>s.json()).then(n).catch(()=>{})},[]),{techStacks:t}}function s5(t){const n=t.toLowerCase();return/extension|chrome/.test(n)?"chrome-extension":/desktop|menu bar|mac app/.test(n)?"desktop":/\bapp\b|ios|android|phone|mobile/.test(n)?"mobile":"web"}function r5(t,n){const s=l.useRef(n);l.useEffect(()=>{s.current=n},[n]),l.useEffect(()=>{if(!t)return;let r=!1,a=null;const o=async()=>{try{const c=await(await fetch("/api/editor-design-state")).json();!r&&c.active&&s.current(c.active)}catch{}finally{r||(a=window.setTimeout(o,3e3))}};return o(),()=>{r=!0,a!==null&&window.clearTimeout(a)}},[t])}function eb({providerLabel:t,preparing:n,onLaunch:s,variant:r="chat"}){const a=r==="files"?e.jsxs(e.Fragment,{children:["Click the button below to start a design session with ",t,"."," ",t," will turn the assets you added above into HTML mockups you can compare and iterate on."]}):e.jsxs(e.Fragment,{children:["Click the button below to launch a chat window with ",t," so that ",t," can generate some design options for you to consider and iterate on."]}),o=r==="files"?e.jsxs(e.Fragment,{children:[t," reads the design assets you added in the"," ",e.jsx("strong",{children:"Add your design files"})," step above — keep adding more any time and ",t," will fold them in."]}):e.jsxs(e.Fragment,{children:[t," will ask whether you have any design assets — logos, screenshots, brand guides, or inspiration. You can add them any time from the ",e.jsx("strong",{children:"Add assets"})," panel on the right (drag-and-drop or browse)."]}),i=r==="files"?"Start a design session":`Launch ${t} Design Chat`;return e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 var(--spacing-md, 12px)",fontSize:"var(--text-md, 15px)",lineHeight:1.5,color:"var(--text-primary)"},children:a}),e.jsx("p",{style:{margin:"0 0 var(--spacing-lg, 16px)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5,color:"var(--text-secondary)"},children:o}),e.jsx("button",{onClick:s,disabled:n,style:{background:n?"var(--bg-surface)":"var(--accent-active)",border:"none",color:n?"var(--text-dim)":"#000",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:n?"not-allowed":"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:n?"Preparing design moodboards…":i})]})}const ED=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatLaunchPanel:eb},Symbol.toStringTag,{value:"Module"}));function tb({title:t,subtitle:n,children:s}){return e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"var(--text-xl, 22px)",fontWeight:700,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:t}),e.jsx("p",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-muted)",marginBottom:"var(--spacing-lg, 24px)"},children:n}),s]})}const MD=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireStepPanel:tb},Symbol.toStringTag,{value:"Module"}));function go({description:t,launched:n,onLaunched:s,onDesignSelected:r,onPreviewUrl:a,variant:o="chat"}){const[i,c]=l.useState({kind:"preparing"}),{config:d}=jt(),u=Ue(d==null?void 0:d.provider),h=l.useRef(n),p=o==="chat"||n;l.useEffect(()=>{if(p)return a==null||a("/design-exploration"),()=>{a==null||a(null)}},[a,p]),l.useEffect(()=>{let x=!1;return(async()=>{try{const y=!h.current,[v,_,j]=await Promise.all([fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:t,allowOverwrite:!0})}),fetch("/api/editor-design-systems-install",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}),y?fetch("/api/editor-design-reset",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}):Promise.resolve(null)]);if(!_.ok){const k=await _.text().catch(()=>`${_.status}`);throw new Error(k||`install failed: ${_.status}`)}if(j&&!j.ok){const k=await j.text().catch(()=>`${j.status}`);throw new Error(k||`design-reset failed: ${j.status}`)}v.ok||console.warn("[QuestionnaireDesignChatStep] editor-project-info failed; skill will prompt for description",v.status),x||c({kind:"ready"})}catch(y){x||c({kind:"error",message:y instanceof Error?y.message:String(y)})}})(),()=>{x=!0}},[t]),r5(n,r);const m=i.kind==="preparing",f=o==="files"?"Turn your assets into a mockup":"Explore design directions",g=o==="files"?"Start a design session and the agent will turn the assets you uploaded into HTML mockups — pick one from the panel on the right.":"Chat with the agent, share any design assets, then pick a mockup from the panel on the right.",b=o==="files"?"Try Skip instead, or keep uploading assets and try again.":"Try the Files or Skip approach instead.";return e.jsx(tb,{title:f,subtitle:g,children:n?e.jsx($t,{chatName:"initial-design",slashCommand:"/codeyam-design",height:420}):i.kind==="error"?e.jsxs("div",{style:{padding:"var(--spacing-md, 12px)",marginBottom:"var(--spacing-sm, 8px)",borderRadius:8,background:"var(--bg-danger-soft, rgba(248,113,113,0.12))",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:["Couldn't prepare design moodboards: ",i.message,". ",b]}):e.jsx(eb,{providerLabel:u,preparing:m,onLaunch:s,variant:o})})}const ID=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatStep:go},Symbol.toStringTag,{value:"Module"}));function nb(){return e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-subtle)",fontSize:"var(--text-sm, 14px)",color:"var(--text-muted)"},children:"Before we dive in, help us comprehend what you want to build better."})}const LD=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireIntroBanner:nb},Symbol.toStringTag,{value:"Module"}));function sb({step:t,canAdvance:n,isFinalStep:s,isAdvancing:r,onBack:a,onNext:o,onFinish:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",marginTop:"var(--spacing-lg, 24px)"},children:[t>1&&e.jsx("button",{onClick:a,style:{background:"none",border:"1px solid var(--border-default)",color:"var(--text-secondary)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:"pointer",fontSize:"var(--text-sm, 14px)"},children:"← Back"}),s?e.jsx("button",{onClick:i,disabled:!n,style:{background:n?"var(--accent-active)":"var(--bg-surface)",border:"none",color:n?"#000":"var(--text-dim)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:n?"pointer":"not-allowed",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:"FINISH →"}):e.jsx("button",{onClick:o,disabled:!n||r,style:{background:n?"var(--accent-active)":"var(--bg-surface)",border:"none",color:n?"#000":"var(--text-dim)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:n&&!r?"pointer":"not-allowed",fontSize:"var(--text-sm, 14px)",fontWeight:600,opacity:r?.7:1},children:r?"…":"NEXT →"})]})}const DD=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireNavButtons:sb},Symbol.toStringTag,{value:"Module"})),a5=e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M5.50742 6.94462H6.6669C6.89825 6.94462 7.12013 6.85463 7.28372 6.69444C7.44731 6.53426 7.53921 6.317 7.53921 6.09047C7.53921 5.86394 7.44731 5.64668 7.28372 5.4865C7.12013 5.32631 6.89825 5.23633 6.6669 5.23633H5.51133C5.27997 5.23633 5.05809 5.32631 4.8945 5.4865C4.73091 5.64668 4.639 5.86394 4.639 6.09047C4.639 6.20264 4.61644 6.31372 4.57261 6.41735C4.52877 6.52098 4.46451 6.61513 4.38351 6.69444C4.3025 6.77376 4.20634 6.83668 4.1005 6.8796C3.99467 6.92253 3.88124 6.94462 3.76668 6.94462H2.61111C2.38009 6.94462 2.15851 7.03435 1.99498 7.19412C1.83144 7.35389 1.7393 7.57066 1.73878 7.79687C1.73878 8.02307 1.64715 8.24003 1.48398 8.40016C1.32081 8.56029 1.09944 8.6505 0.868421 8.65101C0.637744 8.65202 0.416859 8.74245 0.25411 8.90253C0.0913609 9.0626 -2.30897e-06 9.27929 0 9.50516C-5.79344e-07 9.73086 0.0914247 9.94733 0.254229 10.1071C0.417033 10.2669 0.637923 10.3569 0.868421 10.3574C1.09944 10.3579 1.32081 10.4481 1.48398 10.6082C1.64715 10.7684 1.73878 10.9853 1.73878 11.2115C1.73878 11.4381 1.83069 11.6553 1.99429 11.8155C2.15788 11.9757 2.37976 12.0657 2.61111 12.0657H3.76668C3.9977 12.0657 4.21928 12.1554 4.38282 12.3152C4.54635 12.475 4.63848 12.6917 4.639 12.9179C4.639 13.1445 4.73091 13.3617 4.8945 13.5219C5.05809 13.6821 5.27997 13.7721 5.51133 13.7721H6.6669C6.78136 13.7721 6.8947 13.75 7.00043 13.707C7.10615 13.6641 7.20218 13.6011 7.28303 13.5218C7.36388 13.4424 7.42794 13.3483 7.47157 13.2447C7.51519 13.141 7.53753 13.03 7.53727 12.9179C7.53727 12.6919 7.44556 12.4751 7.28234 12.3153C7.11911 12.1555 6.89773 12.0657 6.6669 12.0657H5.50937C5.27836 12.0652 5.05698 11.975 4.89381 11.8148C4.73064 11.6547 4.639 11.4377 4.639 11.2115C4.639 10.985 4.5471 10.7678 4.38351 10.6076C4.21991 10.4474 3.99804 10.3574 3.76668 10.3574H2.59745C2.36929 10.3574 2.15025 10.2697 1.98746 10.1132C1.82468 9.95667 1.73117 9.74381 1.72707 9.52044C1.72707 9.52044 1.72707 9.52045 1.72707 9.50516C1.72707 9.50516 1.72707 9.49369 1.72707 9.48796C1.73117 9.26459 1.82468 9.05173 1.98746 8.89519C2.15025 8.73866 2.36929 8.65097 2.59745 8.65101H3.76668C3.99804 8.65101 4.21991 8.56102 4.38351 8.40084C4.5471 8.24065 4.639 8.0234 4.639 7.79687C4.639 7.57117 4.73043 7.35468 4.89324 7.19491C5.05604 7.03514 5.27692 6.94513 5.50742 6.94462Z",fill:"currentColor"}),e.jsx("path",{d:"M17.1351 5.27098C16.9037 5.27098 16.6818 5.36096 16.5183 5.52115C16.3547 5.68133 16.2628 5.89859 16.2628 6.12512V7.83152C16.2628 7.94368 16.2402 8.05475 16.1964 8.15838C16.1525 8.26201 16.0883 8.35618 16.0073 8.43549C15.9263 8.51481 15.8301 8.57771 15.7243 8.62064C15.6184 8.66356 15.505 8.68566 15.3904 8.68566C15.1594 8.68616 14.938 8.77637 14.7749 8.9365C14.6117 9.09663 14.5201 9.31361 14.5201 9.53981C14.5196 9.76602 14.4274 9.98278 14.2639 10.1426C14.1003 10.3023 13.8788 10.392 13.6477 10.392C13.4167 10.392 13.1951 10.3023 13.0316 10.1426C12.8681 9.98278 12.7759 9.76602 12.7754 9.53981C12.7754 9.31361 12.6838 9.09663 12.5206 8.9365C12.3574 8.77637 12.1361 8.68616 11.9051 8.68566C11.7905 8.68566 11.6771 8.66356 11.5712 8.62064C11.4654 8.57771 11.3692 8.51481 11.2882 8.43549C11.2072 8.35618 11.143 8.26201 11.0991 8.15838C11.0553 8.05475 11.0327 7.94368 11.0327 7.83152V6.13086C11.0383 6.01542 11.0199 5.90007 10.9786 5.7918C10.9374 5.68352 10.8741 5.58458 10.7926 5.50095C10.7112 5.41732 10.6132 5.35074 10.5047 5.30526C10.3962 5.25977 10.2794 5.23633 10.1614 5.23633C10.0434 5.23633 9.92656 5.25977 9.81805 5.30526C9.70955 5.35074 9.61161 5.41732 9.53015 5.50095C9.44869 5.58458 9.38541 5.68352 9.34414 5.7918C9.30287 5.90007 9.28446 6.01542 9.29004 6.13086V7.83724C9.29004 8.06345 9.38168 8.28041 9.54485 8.44054C9.70802 8.60067 9.9294 8.69089 10.1604 8.6914C10.3918 8.6914 10.6136 8.78138 10.7772 8.94157C10.9408 9.10175 11.0327 9.31901 11.0327 9.54554C11.0332 9.77174 11.1254 9.98851 11.2889 10.1483C11.4525 10.308 11.674 10.3978 11.9051 10.3978C12.1351 10.3983 12.3556 10.4877 12.5186 10.6466C12.6816 10.8055 12.7739 11.021 12.7754 11.2462V12.966C12.7754 13.1922 12.8671 13.4091 13.0302 13.5693C13.1934 13.7294 13.4148 13.8196 13.6458 13.8201C13.8771 13.8201 14.099 13.7301 14.2626 13.5699C14.4262 13.4097 14.5181 13.1925 14.5181 12.966V11.2596C14.5181 11.0334 14.6097 10.8164 14.7729 10.6563C14.9361 10.4961 15.1575 10.4059 15.3885 10.4054C15.6195 10.4054 15.8411 10.3157 16.0046 10.1559C16.1682 9.99616 16.2603 9.77938 16.2608 9.55318C16.2608 9.32664 16.3527 9.10939 16.5163 8.9492C16.6799 8.78902 16.9018 8.69904 17.1331 8.69904C17.3641 8.69853 17.5855 8.60832 17.7487 8.44819C17.9119 8.28806 18.0035 8.07109 18.0035 7.84488V6.13086C18.0043 6.01853 17.9824 5.90715 17.9392 5.80311C17.8959 5.69907 17.8321 5.6044 17.7515 5.52453C17.6708 5.44466 17.5748 5.38115 17.4691 5.33764C17.3633 5.29414 17.2498 5.27148 17.1351 5.27098Z",fill:"currentColor"})]}),o5=e.jsx("path",{d:"M28.609 14.209C27.883 14.209 27.2597 14.0807 26.739 13.824C26.2183 13.5673 25.793 13.2337 25.463 12.823C25.1403 12.4123 24.902 11.965 24.748 11.481C24.594 10.997 24.517 10.5313 24.517 10.084V9.842C24.517 9.34333 24.594 8.852 24.748 8.368C24.9093 7.884 25.155 7.444 25.485 7.048C25.815 6.652 26.233 6.33667 26.739 6.102C27.2523 5.86 27.8573 5.739 28.554 5.739C29.28 5.739 29.9107 5.871 30.446 6.135C30.9887 6.39167 31.4213 6.75833 31.744 7.235C32.0667 7.70433 32.261 8.25433 32.327 8.885H30.754C30.6953 8.51833 30.5633 8.21033 30.358 7.961C30.16 7.70433 29.907 7.51367 29.599 7.389C29.291 7.257 28.9427 7.191 28.554 7.191C28.158 7.191 27.806 7.26067 27.498 7.4C27.19 7.532 26.9333 7.72267 26.728 7.972C26.5227 8.22133 26.365 8.51467 26.255 8.852C26.1523 9.18933 26.101 9.56333 26.101 9.974C26.101 10.37 26.1523 10.7367 26.255 11.074C26.365 11.4113 26.5263 11.7083 26.739 11.965C26.9517 12.2143 27.212 12.4087 27.52 12.548C27.8353 12.6873 28.1983 12.757 28.609 12.757C29.2103 12.757 29.7163 12.6103 30.127 12.317C30.545 12.0163 30.798 11.5983 30.886 11.063H32.459C32.3857 11.635 32.1913 12.1593 31.876 12.636C31.5607 13.1127 31.128 13.494 30.578 13.78C30.028 14.066 29.3717 14.209 28.609 14.209ZM36.5271 14.209C35.9991 14.209 35.5334 14.1247 35.1301 13.956C34.7268 13.7873 34.3858 13.56 34.1071 13.274C33.8284 12.9807 33.6158 12.6507 33.4691 12.284C33.3298 11.9173 33.2601 11.536 33.2601 11.14V10.909C33.2601 10.4983 33.3334 10.1097 33.4801 9.743C33.6341 9.369 33.8504 9.039 34.1291 8.753C34.4151 8.45967 34.7598 8.23233 35.1631 8.071C35.5664 7.90233 36.0211 7.818 36.5271 7.818C37.0331 7.818 37.4878 7.90233 37.8911 8.071C38.2944 8.23233 38.6354 8.45967 38.9141 8.753C39.2001 9.039 39.4164 9.369 39.5631 9.743C39.7098 10.1097 39.7831 10.4983 39.7831 10.909V11.14C39.7831 11.536 39.7098 11.9173 39.5631 12.284C39.4238 12.6507 39.2148 12.9807 38.9361 13.274C38.6574 13.56 38.3164 13.7873 37.9131 13.956C37.5098 14.1247 37.0478 14.209 36.5271 14.209ZM36.5271 12.9C36.9011 12.9 37.2164 12.8193 37.4731 12.658C37.7298 12.4893 37.9241 12.2657 38.0561 11.987C38.1881 11.701 38.2541 11.3783 38.2541 11.019C38.2541 10.6523 38.1844 10.3297 38.0451 10.051C37.9131 9.765 37.7151 9.54133 37.4511 9.38C37.1944 9.21133 36.8864 9.127 36.5271 9.127C36.1678 9.127 35.8561 9.21133 35.5921 9.38C35.3354 9.54133 35.1374 9.765 34.9981 10.051C34.8588 10.3297 34.7891 10.6523 34.7891 11.019C34.7891 11.3783 34.8551 11.701 34.9871 11.987C35.1264 12.2657 35.3244 12.4893 35.5811 12.658C35.8378 12.8193 36.1531 12.9 36.5271 12.9ZM43.5969 14.198C43.1789 14.198 42.7939 14.121 42.4419 13.967C42.0899 13.813 41.7856 13.5967 41.5289 13.318C41.2723 13.0393 41.0743 12.7167 40.9349 12.35C40.7956 11.976 40.7259 11.5727 40.7259 11.14V10.909C40.7259 10.4837 40.7919 10.084 40.9239 9.71C41.0633 9.336 41.2539 9.00967 41.4959 8.731C41.7453 8.45233 42.0423 8.236 42.3869 8.082C42.7389 7.92067 43.1276 7.84 43.5529 7.84C44.0223 7.84 44.4329 7.94267 44.7849 8.148C45.1443 8.346 45.4303 8.64667 45.6429 9.05C45.8556 9.45333 45.9729 9.95933 45.9949 10.568L45.5439 10.04V5.97H47.0729V14H45.8629V11.459H46.1269C46.1049 12.0677 45.9803 12.5773 45.7529 12.988C45.5256 13.3913 45.2249 13.6957 44.8509 13.901C44.4843 14.099 44.0663 14.198 43.5969 14.198ZM43.9379 12.911C44.2386 12.911 44.5136 12.845 44.7629 12.713C45.0123 12.5737 45.2103 12.3757 45.3569 12.119C45.5109 11.855 45.5879 11.547 45.5879 11.195V10.755C45.5879 10.403 45.5109 10.1097 45.3569 9.875C45.2029 9.633 45.0013 9.44967 44.7519 9.325C44.5026 9.193 44.2313 9.127 43.9379 9.127C43.6079 9.127 43.3146 9.20767 43.0579 9.369C42.8086 9.523 42.6106 9.743 42.4639 10.029C42.3246 10.315 42.2549 10.6487 42.2549 11.03C42.2549 11.4113 42.3283 11.745 42.4749 12.031C42.6216 12.3097 42.8196 12.526 43.0689 12.68C43.3256 12.834 43.6153 12.911 43.9379 12.911ZM51.4863 14.209C50.973 14.209 50.522 14.121 50.1333 13.945C49.752 13.769 49.433 13.5343 49.1763 13.241C48.927 12.9403 48.7363 12.6067 48.6043 12.24C48.4797 11.8733 48.4173 11.4993 48.4173 11.118V10.909C48.4173 10.513 48.4797 10.1317 48.6043 9.765C48.7363 9.391 48.927 9.061 49.1763 8.775C49.433 8.48167 49.7483 8.25067 50.1223 8.082C50.4963 7.906 50.929 7.818 51.4203 7.818C52.0657 7.818 52.6047 7.961 53.0373 8.247C53.4773 8.52567 53.8073 8.896 54.0273 9.358C54.2473 9.81267 54.3573 10.304 54.3573 10.832V11.382H49.0663V10.447H53.4003L52.9273 10.909C52.9273 10.5277 52.8723 10.2013 52.7623 9.93C52.6523 9.65867 52.4837 9.44967 52.2563 9.303C52.0363 9.15633 51.7577 9.083 51.4203 9.083C51.083 9.083 50.797 9.16 50.5623 9.314C50.3277 9.468 50.148 9.69167 50.0233 9.985C49.906 10.271 49.8473 10.6157 49.8473 11.019C49.8473 11.393 49.906 11.7267 50.0233 12.02C50.1407 12.306 50.3203 12.5333 50.5623 12.702C50.8043 12.8633 51.1123 12.944 51.4863 12.944C51.8603 12.944 52.1647 12.8707 52.3993 12.724C52.634 12.57 52.7843 12.383 52.8503 12.163H54.2583C54.1703 12.5737 54.0017 12.933 53.7523 13.241C53.503 13.549 53.184 13.7873 52.7953 13.956C52.414 14.1247 51.9777 14.209 51.4863 14.209ZM57.2956 10.931L54.8756 5.97H56.4816L58.3296 9.853L57.9776 9.743H59.0226L58.6486 9.853L60.3316 5.97H61.8496L59.6166 10.931H57.2956ZM57.6916 14V10.689H59.2206V14H57.6916ZM66.0534 14V12.229H65.8004V10.26C65.8004 9.91533 65.7161 9.65867 65.5474 9.49C65.3788 9.32133 65.1184 9.237 64.7664 9.237C64.5831 9.237 64.3631 9.24067 64.1064 9.248C63.8498 9.25533 63.5894 9.26633 63.3254 9.281C63.0688 9.28833 62.8378 9.29933 62.6324 9.314V8.016C62.8011 8.00133 62.9918 7.98667 63.2044 7.972C63.4171 7.95733 63.6334 7.95 63.8534 7.95C64.0808 7.94267 64.2934 7.939 64.4914 7.939C65.1074 7.939 65.6171 8.01967 66.0204 8.181C66.4311 8.34233 66.7391 8.59533 66.9444 8.94C67.1571 9.28467 67.2634 9.73567 67.2634 10.293V14H66.0534ZM64.1284 14.154C63.6958 14.154 63.3144 14.077 62.9844 13.923C62.6618 13.769 62.4088 13.549 62.2254 13.263C62.0494 12.977 61.9614 12.6323 61.9614 12.229C61.9614 11.789 62.0678 11.4297 62.2804 11.151C62.5004 10.8723 62.8048 10.6633 63.1934 10.524C63.5894 10.3847 64.0514 10.315 64.5794 10.315H65.9654V11.228H64.5574C64.2054 11.228 63.9341 11.316 63.7434 11.492C63.5601 11.6607 63.4684 11.8807 63.4684 12.152C63.4684 12.4233 63.5601 12.6433 63.7434 12.812C63.9341 12.9807 64.2054 13.065 64.5574 13.065C64.7701 13.065 64.9644 13.0283 65.1404 12.955C65.3238 12.8743 65.4741 12.7423 65.5914 12.559C65.7161 12.3683 65.7858 12.1117 65.8004 11.789L66.1744 12.218C66.1378 12.636 66.0351 12.988 65.8664 13.274C65.7051 13.56 65.4778 13.78 65.1844 13.934C64.8984 14.0807 64.5464 14.154 64.1284 14.154ZM68.9012 14V8.027H70.1112V10.59H70.0012C70.0012 9.98867 70.0782 9.48633 70.2322 9.083C70.3862 8.67233 70.6136 8.36433 70.9142 8.159C71.2222 7.94633 71.6036 7.84 72.0582 7.84H72.1242C72.5862 7.84 72.9676 7.94633 73.2682 8.159C73.5762 8.36433 73.8036 8.67233 73.9502 9.083C74.1042 9.48633 74.1812 9.98867 74.1812 10.59H73.7962C73.7962 9.98867 73.8732 9.48633 74.0272 9.083C74.1886 8.67233 74.4196 8.36433 74.7202 8.159C75.0282 7.94633 75.4096 7.84 75.8642 7.84H75.9302C76.3922 7.84 76.7772 7.94633 77.0852 8.159C77.3932 8.36433 77.6242 8.67233 77.7782 9.083C77.9396 9.48633 78.0202 9.98867 78.0202 10.59V14H76.4912V10.447C76.4912 10.073 76.3959 9.776 76.2052 9.556C76.0146 9.32867 75.7432 9.215 75.3912 9.215C75.0392 9.215 74.7569 9.33233 74.5442 9.567C74.3316 9.79433 74.2252 10.1023 74.2252 10.491V14H72.6962V10.447C72.6962 10.073 72.6009 9.776 72.4102 9.556C72.2196 9.32867 71.9482 9.215 71.5962 9.215C71.2442 9.215 70.9619 9.33233 70.7492 9.567C70.5366 9.79433 70.4302 10.1023 70.4302 10.491V14H68.9012Z",fill:"currentColor"});function Kn({className:t="h-5",markOnly:n=!1}){return e.jsxs("svg",{className:t,viewBox:n?"0 0 19 20":"0 0 79 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":n?"CodeYam":"CodeYam Editor",children:[a5,!n&&o5]})}const FD=Object.freeze(Object.defineProperty({__proto__:null,CyLogo:Kn},Symbol.toStringTag,{value:"Module"}));function rb({progress:t,onBack:n,onNext:s,nextLabel:r="Next",nextEnabled:a=!0,hideFooter:o=!1,wide:i=!1,children:c}){return e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:60,background:"var(--bg-deep)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",padding:"14px 26px",flexShrink:0,zIndex:4},children:[e.jsx("span",{style:{color:"var(--text-primary)",display:"flex"},children:e.jsx(Kn,{className:"h-5"})}),e.jsx("a",{href:"https://codeyam.com/guides",target:"_blank",rel:"noopener noreferrer",style:{marginLeft:"auto",fontSize:13,color:"var(--text-muted)",textDecoration:"none",cursor:"pointer"},children:"Help"}),e.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:1.5,background:"rgba(255,255,255,.06)"},children:e.jsx("i",{"data-testid":"onboarding-progress-fill",style:{display:"block",height:"100%",width:`${Math.round(t*100)}%`,background:"var(--accent-active)",transition:"width .5s cubic-bezier(.2,.8,.2,1)"}})})]}),e.jsx("div",{style:{flex:1,minHeight:0,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"20px 26px 90px",overflowY:"auto",overscrollBehavior:"contain"},children:e.jsx("div",{style:{width:"100%",maxWidth:i?"none":940,textAlign:i?"left":"center",margin:i?0:"auto 0",flex:i?1:void 0,display:i?"flex":void 0,minHeight:0},children:c})}),!o&&e.jsxs("div",{style:{position:"absolute",left:0,right:0,bottom:0,display:"flex",alignItems:"center",padding:"34px 30px 22px",gap:14,pointerEvents:"none",background:"linear-gradient(to top, var(--bg-deep) 62%, rgba(30,30,30,0))"},children:[n&&e.jsx("button",{type:"button",onClick:n,style:{pointerEvents:"auto",background:"none",border:"none",padding:0,fontSize:13.5,color:"var(--text-dim)",cursor:"pointer"},children:"← Back"}),e.jsxs("button",{type:"button","data-testid":"onboarding-next",onClick:()=>{a&&s()},disabled:!a,style:{pointerEvents:"auto",marginLeft:"auto",background:a?"var(--accent-active)":"#2b2b2b",color:a?"var(--text-on-accent, #14170a)":"var(--text-dim)",border:"none",borderRadius:12,padding:"12px 20px",fontSize:14,fontWeight:700,cursor:a?"pointer":"not-allowed",transition:".18s"},children:[r," →"]})]})]})}const zD=Object.freeze(Object.defineProperty({__proto__:null,OnboardingShell:rb},Symbol.toStringTag,{value:"Module"}));function ab({selectedName:t,onOpen:n,onClear:s}){return t?e.jsxs("div",{style:{marginTop:8,fontSize:12.5},children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Tech stack: "}),e.jsx("span",{style:{color:"var(--text-secondary)"},children:t}),e.jsx("button",{type:"button",onClick:n,style:Hc,children:"Change"}),e.jsx("button",{type:"button",onClick:s,style:Hc,children:"Clear"})]}):e.jsx("div",{style:{marginTop:8},children:e.jsx("button",{type:"button",onClick:n,"aria-expanded":!1,style:{background:"none",border:"none",padding:0,fontSize:12.5,fontFamily:"inherit",color:"var(--text-dim)",textDecoration:"underline",textUnderlineOffset:3,cursor:"pointer"},children:"I want a specific tech stack"})})}const Hc={background:"none",border:"none",padding:0,marginLeft:10,fontSize:12.5,fontFamily:"inherit",color:"var(--text-dim)",textDecoration:"underline",textUnderlineOffset:3,cursor:"pointer"},$D=Object.freeze(Object.defineProperty({__proto__:null,StackPickerCollapsed:ab},Symbol.toStringTag,{value:"Module"}));function ob({matches:t,totalStacks:n,query:s,selectedStackId:r,onChoose:a}){return t.length===0?e.jsx("p",{style:{margin:"10px 2px 0",fontSize:12.5,color:"var(--text-dim)"},children:n===0?"No stacks available yet. CodeYam will pick one for you.":`No stack matches “${s.trim()}”. CodeYam will pick one for you.`}):e.jsx("ul",{role:"listbox","aria-label":"Tech stacks",style:{listStyle:"none",margin:"8px 0 0",padding:0,maxHeight:188,overflowY:"auto"},children:t.map(o=>e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":o.id===r,onClick:()=>a(o),style:{display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",borderRadius:8,padding:"8px 12px",fontSize:13,fontFamily:"inherit",color:"var(--text-secondary)",cursor:"pointer"},children:[o.name,e.jsx("span",{style:{marginLeft:8,fontSize:11.5,color:"var(--text-dim)"},children:o.description})]})},o.id))})}const BD=Object.freeze(Object.defineProperty({__proto__:null,StackPickerResults:ob},Symbol.toStringTag,{value:"Module"}));function ib({stacks:t,selectedStackId:n,onSelectStack:s}){const[r,a]=l.useState(!1),[o,i]=l.useState(""),c=l.useRef(null),d=t.find(p=>p.id===n)??null;l.useEffect(()=>{var p;r&&((p=c.current)==null||p.focus())},[r]);const u=l.useMemo(()=>{const p=o.trim().toLowerCase();return p?t.filter(m=>m.name.toLowerCase().includes(p)||m.description.toLowerCase().includes(p)):t},[t,o]),h=p=>{s(p.id),i(""),a(!1)};return r?e.jsxs("div",{style:{marginTop:8},children:[e.jsx("input",{ref:c,type:"text",value:o,onChange:p=>i(p.target.value),onKeyDown:p=>{if(p.key==="Escape"){p.stopPropagation(),i(""),a(!1);return}if(p.key==="Enter"){p.preventDefault(),p.stopPropagation();const m=u[0];m&&h(m)}},placeholder:"Search stacks…","aria-label":"Search tech stacks",style:{width:"100%",background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:10,padding:"10px 14px",fontSize:13.5,fontFamily:"inherit",color:"var(--text-primary)",outline:"none"}}),e.jsx(ob,{matches:u,totalStacks:t.length,query:o,selectedStackId:n,onChoose:h})]}):e.jsx(ab,{selectedName:(d==null?void 0:d.name)??null,onOpen:()=>a(!0),onClear:()=>s(null)})}const HD=Object.freeze(Object.defineProperty({__proto__:null,OnboardingStackPicker:ib},Symbol.toStringTag,{value:"Module"})),lb=[{id:"mobile",label:"Mobile app"},{id:"web",label:"Web app"},{id:"static",label:"Website"},{id:"chrome-extension",label:"Chrome extension"},{id:"game",label:"Game"},{id:"other",label:"Other"}];function cb({appFormats:t,onToggleFormat:n}){return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:8,marginBottom:16},children:lb.map(({id:s,label:r})=>{const a=t.includes(s);return e.jsx("button",{type:"button","aria-pressed":a,onClick:()=>n(s),style:{background:a?"var(--accent-active)":"rgba(255,255,255,.035)",border:"1px solid transparent",borderRadius:999,padding:"7px 14px",fontSize:12,fontWeight:a?600:400,color:a?"var(--text-on-accent, #14170a)":"var(--text-dim)",cursor:"pointer",transition:".16s"},children:r},s)})})}const qD=Object.freeze(Object.defineProperty({__proto__:null,OnboardingTypeChips:cb,PRODUCT_TYPES:lb},Symbol.toStringTag,{value:"Module"}));function db({value:t,onChange:n,onSubmit:s,stacks:r=[],selectedStackId:a=null,onSelectStack:o,appFormats:i=[],onToggleFormat:c}){const d=l.useRef(null);return l.useEffect(()=>{const u=d.current;u&&(u.focus(),u.setSelectionRange(u.value.length,u.value.length))},[]),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:34,fontWeight:600,letterSpacing:"-.02em",color:"var(--text-primary)",lineHeight:1.15,marginBottom:10},children:"What do you want to build?"}),e.jsxs("div",{style:{maxWidth:720,margin:"0 auto",textAlign:"left"},children:[e.jsx(cb,{appFormats:i,onToggleFormat:c??(()=>{})}),e.jsx("textarea",{ref:d,value:t,onChange:u=>n(u.target.value),onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||(u.preventDefault(),t.trim().length>2&&s(t))},placeholder:"Ask CodeYam to build...","aria-label":"Describe what you want to build",style:{width:"100%",height:132,resize:"none",background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:16,padding:"20px 22px",fontSize:17,lineHeight:1.5,fontFamily:"inherit",color:"var(--text-primary)",outline:"none"}}),e.jsx(ib,{stacks:r,selectedStackId:a,onSelectStack:o??(()=>{})})]})]})}const WD=Object.freeze(Object.defineProperty({__proto__:null,OnboardingPromptStep:db},Symbol.toStringTag,{value:"Module"}));function bo({badge:t,label:n,selected:s,dashed:r=!1,onClick:a,children:o}){return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:a,"aria-pressed":s,style:{width:"100%",display:"flex",alignItems:"center",gap:14,background:r?"transparent":s?"#2b2b2b":"var(--bg-input)",border:`1px ${r?"dashed":"solid"} ${s?"var(--accent-active)":"rgba(255,255,255,.09)"}`,borderRadius:14,padding:"16px 20px",fontSize:15.5,color:s?"var(--text-primary)":"var(--text-secondary)",textAlign:"left",cursor:"pointer",transition:".16s"},children:[e.jsx("span",{style:{flexShrink:0,width:22,height:22,display:"inline-flex",alignItems:"center",justifyContent:"center",fontFamily:"'IBM Plex Mono', monospace",fontSize:11,borderRadius:5,border:`1px solid ${s?"var(--accent-active)":"rgba(255,255,255,.09)"}`,background:s?"var(--accent-active)":"transparent",color:s?"var(--text-on-accent, #14170a)":"var(--text-dim)"},children:t}),n]}),o]})}const GD=Object.freeze(Object.defineProperty({__proto__:null,OnboardingListItem:bo},Symbol.toStringTag,{value:"Module"}));function ub({open:t,files:n,onAddFiles:s,onRemoveFile:r}){const a=l.useRef(null),[o,i]=l.useState(!1),c=o;return e.jsxs("div",{style:{maxHeight:t?320:0,opacity:t?1:0,overflow:"hidden",transition:"max-height .38s cubic-bezier(.2,.8,.2,1), opacity .28s"},children:[e.jsxs("div",{role:"button",tabIndex:t?0:-1,onClick:()=>{var d;return(d=a.current)==null?void 0:d.click()},onKeyDown:d=>{var u;(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),(u=a.current)==null||u.click())},onDragOver:d=>{d.preventDefault(),i(!0)},onDragLeave:()=>i(!1),onDrop:d=>{d.preventDefault(),i(!1),s(Array.from(d.dataTransfer.files))},style:{marginTop:9,border:`1px dashed ${c?"var(--accent-active)":"rgba(255,255,255,.16)"}`,borderRadius:14,padding:26,textAlign:"center",fontSize:14,color:c?"var(--text-primary)":"var(--text-muted)",background:c?"rgba(199,240,74,.05)":"transparent",cursor:"pointer",transition:".16s"},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--text-primary)"},children:"Drop files here"})," ","or"," ",e.jsx("span",{style:{color:"var(--accent-active)",textDecoration:"underline"},children:"browse"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",marginTop:7},children:"PNG, JPG, SVG, PDF, Figma links"})]}),e.jsx("input",{ref:a,type:"file",multiple:!0,"aria-label":"Add design files",onChange:d=>{s(Array.from(d.target.files??[])),d.target.value=""},style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0}}),n.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7,marginTop:9},children:n.map((d,u)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,background:"#2b2b2b",border:"1px solid rgba(255,255,255,.09)",borderRadius:8,padding:"6px 8px 6px 12px",fontSize:12.5,color:"var(--text-secondary)"},children:[d.name,e.jsx("button",{type:"button","aria-label":`Remove ${d.name}`,onClick:h=>{h.stopPropagation(),r(u)},style:{background:"none",border:"none",padding:0,color:"var(--text-dim)",cursor:"pointer",fontSize:13},children:"×"})]},`${d.name}-${u}`))})]})}const UD=Object.freeze(Object.defineProperty({__proto__:null,OnboardingDropzone:ub},Symbol.toStringTag,{value:"Module"}));function i5(t,n){l.useEffect(()=>{function s(r){if(r.metaKey||r.ctrlKey||r.altKey)return;const a=r.target;if(a){const i=a.tagName;if(i==="INPUT"||i==="TEXTAREA"||a.isContentEditable)return}const o=Number(r.key);!Number.isInteger(o)||o<1||o>t||(r.preventDefault(),n(o))}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t,n])}const Ma=[{id:"files",badge:"1",label:"Yes, I have some"},{id:"chat",badge:"2",label:"I'd like help with design"},{id:"skip",badge:"3",label:"I don't care, let's start building"}],hb=260;function pb({selected:t,files:n,onSelect:s,onAddFiles:r,onRemoveFile:a,onOpenChat:o}){return i5(Ma.length,i=>{s(Ma[i-1].id)}),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:34,fontWeight:600,letterSpacing:"-.02em",color:"var(--text-primary)",marginBottom:10},children:"Do you have any design assets?"}),e.jsxs("p",{style:{fontSize:14.5,color:"var(--text-muted)",marginBottom:34},children:["Logos, screenshots, brand guides."," ",e.jsx("a",{href:"https://docs.codeyam.com/design-assets",target:"_blank",rel:"noreferrer",style:{color:"var(--accent-active)"},children:"Learn about design assets"})]}),e.jsxs("div",{style:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:9,textAlign:"left"},children:[Ma.map(i=>e.jsx(bo,{badge:i.badge,label:i.label,selected:t===i.id,onClick:()=>s(i.id),children:i.id==="files"&&e.jsx(ub,{open:t==="files",files:n,onAddFiles:r,onRemoveFile:a})},i.id)),e.jsx(bo,{badge:"↩",label:"Chat about this instead",selected:!1,dashed:!0,onClick:o})]})]})}const VD=Object.freeze(Object.defineProperty({__proto__:null,ASSETS_AUTO_ADVANCE_MS:hb,OnboardingDesignAssetsStep:pb},Symbol.toStringTag,{value:"Module"}));function mb({sound:t,onChange:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:14,paddingLeft:25},children:[e.jsx("span",{style:{fontSize:12.5,color:"var(--text-dim)"},children:"Sound"}),e.jsx("select",{value:t,"aria-label":"Notification sound",onChange:s=>n(s.target.value),style:{background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:8,padding:"5px 9px",fontSize:12.5,fontFamily:"inherit",color:"var(--text-secondary)",outline:"none",cursor:"pointer"},children:kg.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))})]})}const YD=Object.freeze(Object.defineProperty({__proto__:null,NotificationSoundSelect:mb},Symbol.toStringTag,{value:"Module"}));function fb(){const[t,n]=l.useState(()=>Ng());l.useEffect(()=>{Ag()},[]);function s(i){n(i),Cg(i)}function r(){const i=t.sound==="off"?"soft-double-tap":t.sound;s({...t,systemNotification:!0,sound:i}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function a(){s({...t,systemNotification:!1,sound:"off"})}const o=t.systemNotification;return e.jsxs("div",{style:{maxWidth:460,margin:"0 auto",textAlign:"left"},children:[e.jsx("h1",{style:{fontFamily:"'IBM Plex Mono', monospace",fontSize:10.5,fontWeight:500,letterSpacing:".08em",textTransform:"uppercase",color:"var(--text-dim)",textAlign:"center",marginBottom:8},children:"Notifications"}),e.jsx("p",{style:{fontSize:13.5,lineHeight:1.55,color:"var(--text-muted)",textAlign:"center",marginBottom:16},children:"Building takes a few minutes. I'll let you know the moment I need you."}),e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:14,padding:"16px 18px"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontSize:14,color:"var(--text-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:o,onChange:i=>i.target.checked?r():a(),style:{width:15,height:15,accentColor:"var(--accent-active)",cursor:"pointer"}}),"Ping me when the build is done",e.jsx("span",{style:{fontSize:12,color:"var(--text-dim)"},children:"(recommended)"})]}),o&&e.jsx(mb,{sound:t.sound,onChange:i=>{s({...t,sound:i}),i!=="off"&&Ki(i)}})]})]})}const KD=Object.freeze(Object.defineProperty({__proto__:null,OnboardingNotificationsStep:fb},Symbol.toStringTag,{value:"Module"}));function gb(t){const{projectDir:n,loaded:s}=ai(),r=l.useRef(!1);return l.useEffect(()=>{s&&!r.current&&(r.current=!0,t5())},[s]),s?e.jsx(bb,{...t,projectDir:n}):e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:e.jsx(nb,{})})}function bb({onComplete:t,onPreviewUrl:n,projectDir:s}){const[r,a]=l.useState(()=>{const R=s?Ea(s):null;return R?R.step:1}),[o,i]=l.useState(()=>{const R=s?Ea(s):null;return(R==null?void 0:R.answers)??{appFormats:[],description:"",techStackId:null,designApproach:null,defaultDevice:"Desktop"}}),[c,d]=l.useState(null),[u,h]=l.useState([]),[p,m]=l.useState(()=>{const R=s?Ea(s):null;return(R==null?void 0:R.designChatLaunched)??!1}),f=l.useRef(p),{techStacks:g}=n5(),b=Bc(o.designApproach),x=b[r-1],y=r===b.length;l.useEffect(()=>{r>b.length&&a(b.length)},[r,b.length]);const v=l.useRef(!0);l.useEffect(()=>{if(v.current){v.current=!1;return}s!==null&&ZC(s,{step:r,answers:o,designChatLaunched:p,savedAt:new Date().toISOString()})},[r,o,p,s]);const _=l.useCallback(()=>{m(!0)},[]),[j,k]=l.useState(f.current?{state:"pending"}:{state:"ready",active:null});l.useEffect(()=>{if(!f.current)return;let R=!1;return(async()=>{try{const M=await(await fetch("/api/editor-design-state")).json();R||k({state:"ready",active:M.active??null})}catch{R||k({state:"ready",active:null})}})(),()=>{R=!0}},[]);const S=l.useCallback(R=>{i(L=>({...L,appFormats:L.appFormats.includes(R)?L.appFormats.filter(M=>M!==R):[...L.appFormats,R]}))},[]),w=l.useCallback(R=>{i(L=>({...L,techStackId:R}))},[]),C=l.useCallback(R=>{i(L=>({...L,designApproach:R}))},[]),P=l.useCallback(R=>{h(L=>[...L,...R])},[]),T=l.useCallback(R=>{h(L=>L.filter((M,K)=>K!==R))},[]),O=l.useCallback(async()=>{await XC(o),s!==null&&e5(s),t==null||t(o)},[o,t,s]),N=l.useRef(!1);l.useEffect(()=>{N.current||j.state==="ready"&&x==="design-details"&&(o.designApproach==="chat"||o.designApproach==="files")&&c!==null&&c!==j.active&&(N.current=!0,O())},[x,o.designApproach,c,O,j]);const E=l.useCallback(()=>{a(R=>R+1)},[]),I=l.useCallback(()=>{a(R=>R-1)},[]),ee=(()=>{switch(x){case"prompt":return o.description.trim().length>2;case"notifications":return!0;case"design-approach":return o.designApproach!==null;case"design-details":return o.designApproach==="chat"?c!==null:!0;default:return!0}})(),B=l.useCallback(R=>{i(L=>({...L,description:R,appFormats:L.appFormats.length>0?L.appFormats:[s5(R)]})),a(L=>L+1)},[]),z=l.useCallback(R=>{if(C(R),R==="files")return;const L=setTimeout(()=>a(M=>M+1),hb);Y.current=L},[C]),Y=l.useRef(null);l.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[r]);const te=l.useCallback(()=>{i(L=>({...L,designApproach:"chat"}));const R=Bc("chat");a(R.indexOf("design-details")+1)},[]);if(x){const R=x==="design-details";if(R)return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto",padding:"var(--spacing-xl, 28px)"},children:[e.jsx(go,{description:o.description,launched:p,onLaunched:_,onDesignSelected:d,onPreviewUrl:n,variant:o.designApproach==="files"?"files":"chat"}),e.jsx(sb,{step:r,canAdvance:ee,isFinalStep:y,onBack:I,onNext:E,onFinish:O})]});const L=x==="notifications"?o.designApproach==="chat"?"Start with design":"Start building":"Next";return e.jsx(rb,{progress:b.length>1?(r-1)/(b.length-1):0,onBack:r>1?I:void 0,onNext:y?O:E,nextLabel:L,nextEnabled:ee,children:e.jsxs("div",{style:{animation:"onboardingSlideIn .44s cubic-bezier(.2,.8,.2,1) both"},children:[x==="prompt"&&e.jsx(db,{value:o.description,onChange:M=>i(K=>({...K,description:M})),onSubmit:B,stacks:g,selectedStackId:o.techStackId,onSelectStack:w,appFormats:o.appFormats,onToggleFormat:S}),x==="design-approach"&&e.jsx(pb,{selected:o.designApproach,files:u,onSelect:z,onAddFiles:P,onRemoveFile:T,onOpenChat:te}),x==="notifications"&&e.jsx(fb,{}),R&&e.jsx(go,{description:o.description,launched:p,onLaunched:_,onDesignSelected:d,onPreviewUrl:n,variant:o.designApproach==="files"?"files":"chat"})]},x)})}return null}const JD=Object.freeze(Object.defineProperty({__proto__:null,NewProjectQuestionnaire:gb,NewProjectQuestionnaireInner:bb},Symbol.toStringTag,{value:"Module"}));function xb({projectTitle:t,projectDescription:n,stats:s,coverage:r,onSelectApp:a,configLoading:o,scenariosLoading:i,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:h,stepState:p,onPreviewUrl:m,onComplete:f,onOpenBuildTab:g,onCoverageClick:b,isBuilding:x=!1,buildingLabel:y,buildingStepLabel:v,buildingStepPosition:_,buildingStatus:j,buildingProgress:k,onResetBuild:S}){const{saved:w}=Eg();return s.length===0?o||i||w===null?null:Mg({appStatsLength:s.length,configLoading:!!o,scenariosLoading:!!i,setupAnswersSaved:w,hasStepState:!!p})?e.jsx(gb,{onPreviewUrl:m,onComplete:f}):e.jsx(Fg,{projectDescription:n??null,onOpenBuildTab:g??(()=>{})}):e.jsx("div",{className:"px-5 py-5",children:e.jsxs("div",{style:{width:"100%",maxWidth:1e3,marginInline:"auto"},children:[e.jsx($g,{projectTitle:t,coverage:r,onCoverageClick:b}),e.jsx(Qg,{isBuilding:x,buildingLabel:y,buildingStepLabel:v,buildingStepPosition:_,buildingStatus:j,buildingProgress:k,buildingMode:p==null?void 0:p.mode,onOpenBuilding:g??(()=>{}),onResetBuild:S??(()=>{})}),e.jsx(zg,{stats:s,onSelectApp:a,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:h})]})})}const XD=Object.freeze(Object.defineProperty({__proto__:null,AppOverview:xb},Symbol.toStringTag,{value:"Module"}));function yb({sessionContent:t,stepIndicator:n}){return e.jsxs("div",{className:"flex flex-col h-full",children:[n,t]})}const QD=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLayout:yb},Symbol.toStringTag,{value:"Module"}));function vb({activeTab:t,buildTab:n,footer:s,resultsPanel:r,minimizedResults:a,resultsMode:o}){return e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:t==="build"?"visible":"hidden",pointerEvents:t==="build"?"auto":"none"},children:[e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{style:{flex:o==="full"?"0 0 50%":"1 1 auto",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:n}),o==="full"?r:null,o==="minimized"?a:null]}),s]})}const ZD=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPaneLayout:vb},Symbol.toStringTag,{value:"Module"}));function l5(t=!1){return{title:"Session Ready to Resume",description:t?"CodeYam saved this build session while it was waiting on the next workflow action. Review the current feature and step below, then click resume when you're ready to continue.":"CodeYam found a saved build session for this feature. Review the current feature and step below, then click resume when you're ready to continue.",buttonLabel:"Resume Session",providersLabel:null}}function c5(t,n){const s=Ue(t),r=Ue(n);return{title:"Saved Handoff Ready",description:`A ${s} build session is still in progress for this feature. CodeYam saved the workflow state so ${r} can continue from the same step instead of starting over.`,buttonLabel:"Continue with Saved Handoff",providersLabel:`${s} to ${r}`}}function d5({resumeMode:t,previousProvider:n,currentProvider:s,awaitingUserInput:r=!1}){return t!=="handoff"||n==null||s==null||n===s?l5(r):c5(n,s)}function jb({label:t,onContinue:n}){return e.jsx("button",{onClick:n,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer font-medium",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)"},children:t})}const e9=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryActionButton:jb},Symbol.toStringTag,{value:"Module"}));function wb({children:t}){return e.jsx("div",{className:"flex items-center justify-center h-full",role:"dialog","aria-modal":"true",style:{background:"var(--bg-deep)",color:"var(--text-secondary)"},children:e.jsx("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:t})})}const t9=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryDialog:wb},Symbol.toStringTag,{value:"Module"}));function _b({description:t,title:n}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",style:{color:"var(--text-primary)"},children:n}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--text-muted)"},children:t})]})}const n9=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryHeader:_b},Symbol.toStringTag,{value:"Module"}));function ur({label:t,rowClassName:n,value:s}){return e.jsxs("div",{className:n,children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:[t,":"]})," ",e.jsx("span",{style:{color:"var(--text-primary)"},children:s})]})}const s9=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummaryRow:ur},Symbol.toStringTag,{value:"Module"}));function kb({featureName:t,editorStep:n,editorStepLabel:s,providersLabel:r}){return!t&&(n==null||!s)&&!r?null:e.jsxs("div",{className:"rounded p-3 mb-5 text-sm",style:{background:"var(--bg-deep)"},children:[t&&e.jsx(ur,{label:"Feature",value:t,rowClassName:"mb-1"}),n!=null&&s&&e.jsx(ur,{label:"Step",value:`${n} (${s})`}),r&&e.jsx(ur,{label:"Providers",value:r,rowClassName:"mt-1"})]})}const r9=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummary:kb},Symbol.toStringTag,{value:"Module"}));function u5(t){const n=l.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),t())},[t]);l.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n])}function Sb({featureName:t,editorStep:n,workflowMode:s,previousProvider:r,currentProvider:a,resumeMode:o,awaitingUserInput:i=!1,onContinue:c}){const d=d5({resumeMode:o,previousProvider:r,currentProvider:a,awaitingUserInput:i}),u=n==null?null:Ji(n,s);return u5(c),e.jsxs(wb,{children:[e.jsx(_b,{title:d.title,description:d.description}),e.jsx(kb,{featureName:t,editorStep:n,editorStepLabel:u,providersLabel:d.providersLabel}),e.jsx(jb,{label:d.buttonLabel,onContinue:c})]})}const a9=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecovery:Sb},Symbol.toStringTag,{value:"Module"}));function Nb({awaitingUserInput:t,currentProvider:n,editorStep:s,featureName:r,onContinue:a,previousProvider:o,resumeMode:i,workflowMode:c}){return e.jsx(Sb,{featureName:r,editorStep:s,workflowMode:c,previousProvider:o,currentProvider:n,resumeMode:i,awaitingUserInput:t,onContinue:a})}const o9=Object.freeze(Object.defineProperty({__proto__:null,BuildTabRecoveryPanel:Nb},Symbol.toStringTag,{value:"Module"}));function h5({sessionDecision:t,sessionInfo:n,buildLaunchGateArmed:s,stepState:r}){return{recoveryFeatureName:(r==null?void 0:r.feature)??(n==null?void 0:n.feature)??null,recoveryStep:(r==null?void 0:r.step)??(n==null?void 0:n.step)??null,recoveryMode:(r==null?void 0:r.mode)??(n==null?void 0:n.mode)??null,showTerminal:!s&&(t==="continue"||t==="fresh"||t==="no-session")&&(r!==null||n!==null),shouldResumeSameProvider:t==="continue"&&(n==null?void 0:n.resumeMode)==="resume"}}const hr=8e3,p5="agent-banner-ready",m5="agent-auth-required";let jr=!1,wr=!1,Kt=[],qc=!1,en=null,sn=null,pr=!1;function f5(){qc||typeof window>"u"||(qc=!0,window.addEventListener(p5,()=>{const t=!wr;if(t){wr=!0;const n=Kt;Kt=[];for(const s of n)s("banner")}if(pr&&(pr=!1,sn&&en===null)){re("dispatch-rename-after-auth",{label:sn.label,reason:"first-observed-frame-after-auth"}),en=sn,xs(sn.label,sn.send,void 0,"rename-coordinator-after-auth");return}en&&(re("dispatch-rename-reapply",{label:en.label,reason:t?"first-observed-frame":"second-observed-frame"}),xs(en.label,en.send,void 0,"rename-coordinator-reapply"))}),window.addEventListener(m5,()=>{pr=!0,re("agent-auth-required-observed",{});const t=Kt;Kt=[];for(const n of t)n("auth-required")}))}f5();function g5(){return wr?Promise.resolve("banner"):new Promise(t=>{let n=!1;const s=a=>{n||(n=!0,clearTimeout(r),t(a))};Kt.push(s);const r=setTimeout(()=>{if(n)return;n=!0;const a=Kt.indexOf(s);a>=0&&Kt.splice(a,1),t("fallback")},hr)})}async function Cb(t,n,s=0,r=M1,a=!1){if(jr){re("dispatch-rename-suppressed",{caller:n,label:t});return}jr=!0,sn={label:t,send:r},re("dispatch-rename",{phase:"queued",caller:n,label:t,fallbackMs:hr,postReadyDelayMs:s});const o=await g5();if(o==="auth-required"){re("dispatch-rename-deferred-for-auth",{caller:n,label:t});return}if(a&&o==="fallback"){re("dispatch-rename-skipped-no-banner",{caller:n,label:t,fallbackMs:hr});return}s>0&&await new Promise(i=>setTimeout(i,s)),o==="fallback"&&re("dispatch-rename-fallback",{caller:n,label:t,fallbackMs:hr}),re("dispatch-rename",{phase:"fired",caller:n,label:t,source:o,postReadyDelayMs:s}),en={label:t,send:r},xs(t,r,void 0,n)}function b5(){jr=!1,wr=!1,Kt=[],en=null,sn=null,pr=!1}function x5(){jr=!1,Kt=[],sn=null}const y5="Editor";function Tb(t){return t??y5}function v5({provider:t,agentStartMode:n,currentFeature:s}){const r=l.useRef(!1);l.useEffect(()=>{if(!(r.current||!Xd(t)||n!=="fresh")){if(s!==null){r.current=!0;return}r.current=!0,Cb(Tb(s),"build-session-seed",Qd,void 0,!0)}},[t,n,s])}function Pb(t,n){const[s,r]=l.useState(t),a=l.useRef(null);return l.useEffect(()=>{if(t!==!1){a.current!==null&&(window.clearTimeout(a.current),a.current=null),r(t);return}if(a.current===null)return a.current=window.setTimeout(()=>{a.current=null,r(!1)},n),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},[t,n]),s}function j5(t,n){const[s,r]=l.useState(!1),a=l.useRef(null);return l.useEffect(()=>{if(!t){a.current!==null&&(window.clearTimeout(a.current),a.current=null),r(!1);return}if(a.current===null)return a.current=window.setTimeout(()=>{a.current=null,r(!0)},n),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},[t,n]),s}const w5=120*1e3,_r=1500;class _5{constructor(n,s,r=re){Lt(this,"deferred",!1);Lt(this,"userActiveSinceLastOutput",!1);Lt(this,"lastActivitySource",null);Lt(this,"lastActivityAt",null);Lt(this,"lastNotificationTime",null);Lt(this,"actions");Lt(this,"env");Lt(this,"now");Lt(this,"log");this.actions=n,this.env=s,this.now=s.now??(()=>Date.now()),this.log=r}reportUserActivity(n){this.userActiveSinceLastOutput=!0,this.lastActivitySource=n,this.lastActivityAt=this.now()}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(n,s){this.deferred=!1;const r=this.env.hasBrowserFocus(),a=this.lastNotificationTime===null?null:this.now()-this.lastNotificationTime,o=this.lastActivityAt===null?null:this.now()-this.lastActivityAt,i={buildTabActive:s,hasBrowserFocus:r,msSinceLastNotification:a,userActiveSinceLastOutput:this.userActiveSinceLastOutput,lastActivitySource:this.lastActivitySource,msSinceLastActivity:o},c=o!==null&&o<_r;if(s&&r&&c)return this.userActiveSinceLastOutput=!1,this.log("suppressed-user-active",i),"suppressed";if(a!==null&&a<w5)return this.log("cooldown",i),"cooldown";const d=this.notify(n);return this.log(d==="played"?"notify-played":"notify-played-no-sound",i),d}onBuildTabChange(n,s){return!n&&this.deferred?(this.deferred=!1,this.notify(s),!0):!1}onActive(){const n=this.deferred;this.deferred=!1,this.log("on-active",{hadDeferred:n}),this.actions.closeSystemNotification(),this.log("system-notification-closed-on-active",{hadDeferred:n})}onUserEngagement(){const n=this.deferred;return this.deferred=!1,n}get isDeferred(){return this.deferred}notify(n){const s=!!(n!=null&&n.sound)&&n.sound!=="off";s?(this.actions.playSound(n.sound),this.log("sound-played",{soundId:n.sound})):this.log("sound-skipped-off",{});const r=this.env.hasBrowserFocus(),a=typeof Notification<"u"?Notification.permission:"unknown";return!r&&(n!=null&&n.systemNotification)?this.env.hasNotificationPermission()?(this.actions.showSystemNotification(),this.log("system-notification-shown",{notificationPermission:a})):this.log("system-notification-skipped-no-permission",{notificationPermission:a}):r&&this.log("system-notification-skipped-focus",{notificationPermission:a}),this.lastNotificationTime=this.now(),s?"played":"played-no-sound"}}function Ob({onDismiss:t,providerLabel:n}){return e.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:e.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FFB454]/60 bg-[#2a1f0d]",children:[e.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FFB454] shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-[#FFD199]",children:[n," needs"," ",e.jsx("span",{className:"font-medium",children:"your approval to continue"}),"."]}),e.jsx("p",{className:"text-xs text-[#FFD199]/70 mt-1",children:"The turn stopped on a prompt in the terminal below and won't continue until you answer it."})]}),e.jsx("button",{type:"button",onClick:t,className:"shrink-0 p-0.5 mt-1 text-[#FFD199]/60 hover:text-[#FFD199] transition-colors cursor-pointer",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const i9=Object.freeze(Object.defineProperty({__proto__:null,BlockedBanner:Ob},Symbol.toStringTag,{value:"Module"}));function Ab({snippet:t,onRetry:n,onDismiss:s,providerLabel:r}){return e.jsx("div",{"data-testid":"build-tab-startup-error",className:"border-b border-red-500/30 bg-red-950/40 text-red-100 px-4 py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm mb-1",children:[r," didn't start"]}),e.jsx("pre",{"data-testid":"build-tab-startup-error-snippet",className:"font-mono text-xs whitespace-pre-wrap break-words bg-black/40 text-red-50 px-2 py-1 rounded max-h-40 overflow-auto",children:t})]}),e.jsxs("div",{className:"flex items-start gap-2 shrink-0",children:[e.jsx(at,{variant:"subtle",text:t,label:"Copy",className:"shrink-0 px-3 py-1.5 rounded border border-red-500/50 text-red-100 text-sm font-medium hover:bg-red-900/40 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"}),e.jsx("button",{type:"button",onClick:n,"data-testid":"build-tab-startup-error-retry",className:"px-3 py-1.5 rounded bg-red-500 text-white text-sm font-medium cursor-pointer hover:bg-red-400",children:"Retry"}),e.jsx("button",{type:"button",onClick:s,"data-testid":"build-tab-startup-error-dismiss","aria-label":"Dismiss",title:"Dismiss",className:"px-2 py-1.5 rounded text-red-200 text-sm cursor-pointer hover:bg-red-900/40",children:"×"})]})]})})}const l9=Object.freeze(Object.defineProperty({__proto__:null,BuildTabStartupError:Ab},Symbol.toStringTag,{value:"Module"}));function Rb(t=768){const n=`(max-width: ${t-.02}px)`,[s,r]=l.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(n).matches);return l.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia(n);r(a.matches);const o=i=>r(i.matches);return a.addEventListener("change",o),()=>a.removeEventListener("change",o)},[n]),s}const Eb=[{label:"Remote Control",send:"/remote-control",submit:!0},{label:"Codeyam Editor",send:"/codeyam-editor",submit:!0},{label:"Clear",send:"/clear",submit:!0},{label:"Cancel (ESC)",send:"\x1B",submit:!1}];function Mb({defaultOpen:t=!1,currentFeature:n=null}){return Rb()?e.jsx(Ib,{defaultOpen:t,currentFeature:n}):null}function Ib({defaultOpen:t=!1,currentFeature:n=null}){const{config:s}=jt(),[r,a]=l.useState(t),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(()=>a(!1),[]);Mr(o,c,i);const d=s&&s.mobileTerminalCommands.length>0?s.mobileTerminalCommands:Eb,u=l.useCallback(m=>{m.submit?Va(m.send):I1(m.send),a(!1)},[]),h=l.useCallback(()=>{xs(Tb(n),void 0,void 0,"mobile-command-menu"),a(!1)},[n]),p=Xd(s==null?void 0:s.provider);return e.jsxs("div",{className:"absolute top-2 right-2 z-20 flex flex-col items-end",children:[e.jsx("button",{ref:i,type:"button","data-testid":"mobile-command-menu-toggle","aria-haspopup":"menu","aria-expanded":r,"aria-label":"Terminal commands",onClick:()=>a(m=>!m),className:"rounded-full bg-gray-800/90 px-3 py-1.5 text-xs font-medium text-gray-100 shadow-lg ring-1 ring-white/10 backdrop-blur active:bg-gray-700",children:"⌨ Commands"}),r&&e.jsxs("div",{ref:o,role:"menu","data-testid":"mobile-command-menu-popup",className:"mt-1 min-w-[10rem] overflow-hidden rounded-lg bg-gray-800 py-1 shadow-xl ring-1 ring-white/10",children:[d.map((m,f)=>e.jsx("button",{type:"button",role:"menuitem","data-testid":`mobile-command-${f}`,onClick:()=>u(m),className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:m.label},`${m.label}-${f}`)),p&&e.jsx("button",{type:"button",role:"menuitem","data-testid":"mobile-command-rename-session",onClick:h,className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:"Rename Session"})]})]})}const c9=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MOBILE_TERMINAL_COMMANDS:Eb,MobileTerminalCommandMenu:Mb,MobileTerminalCommandMenuPanel:Ib},Symbol.toStringTag,{value:"Module"}));function k5(t){const n=Math.floor(t/6e4);if(n<1)return"under a minute";if(n===1)return"1 minute";if(n<60)return`${n} minutes`;const s=Math.floor(n/60);return s===1?"over an hour":`over ${s} hours`}function Lb({silentMs:t,onDismiss:n,providerLabel:s}){const{sendToAgent:r,agentReady:a}=Ko();return e.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:e.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FF5A5A]/60 bg-[#2a0d0d]",children:[e.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FF5A5A] shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-[#FF8B8B]",children:[s," has been mid-turn with no output for"," ",e.jsx("span",{className:"font-medium",children:k5(t)}),"."]}),e.jsxs("p",{className:"text-xs text-[#FF8B8B]/70 mt-1",children:["There's no input box because ",s," still believes it's working. Interrupting returns the prompt so you can type again."]})]}),e.jsx("button",{type:"button",disabled:!a,onClick:()=>r(""),className:"shrink-0 px-3 py-1.5 rounded-md text-sm font-medium border border-[#FF5A5A]/60 text-[#FF8B8B] hover:bg-[#FF5A5A]/15 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer transition-colors",title:a?"Send Ctrl-C to interrupt the current turn":"No agent connected",children:"Interrupt (Ctrl-C)"}),e.jsx("button",{type:"button",onClick:n,className:"shrink-0 p-0.5 mt-1 text-[#FF8B8B]/60 hover:text-[#FF8B8B] transition-colors cursor-pointer",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const d9=Object.freeze(Object.defineProperty({__proto__:null,StuckTurnBanner:Lb},Symbol.toStringTag,{value:"Module"}));function el(t,n,s=50){const r=l.useRef(n);r.current=n,l.useEffect(()=>{const a=t.current;if(!a)return;let o=null;const i=new ResizeObserver(c=>{o&&clearTimeout(o);const d=c[0];d&&(o=setTimeout(()=>{r.current(d)},s))});return i.observe(a),()=>{o&&clearTimeout(o),i.disconnect()}},[t,s])}function Wc({viewportY:t,baseY:n}){return!Number.isFinite(t)||!Number.isFinite(n)?!1:t>=n}function S5({width:t,height:n,cellWidth:s,cellHeight:r}){return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(r)||s<=0||r<=0?!1:t>=s&&n>=r}function N5(t){var s,r,a,o;const n=(o=(a=(r=(s=t._core)==null?void 0:s._renderService)==null?void 0:r.dimensions)==null?void 0:a.css)==null?void 0:o.cell;return{cellWidth:(n==null?void 0:n.width)??NaN,cellHeight:(n==null?void 0:n.height)??NaN}}const C5="codeyam.terminalScrollDebug";function T5(){var t;try{return typeof window<"u"&&((t=window.localStorage)==null?void 0:t.getItem(C5))==="1"}catch{return!1}}function ls(t,n,s){if(T5())try{const r=n.buffer.active,a={trigger:t,ydisp:r.viewportY,ybase:r.baseY,rows:n.rows,cols:n.cols,containerHeight:(s==null?void 0:s.clientHeight)??null};console.log("[codeyam.terminalScroll]",a)}catch{}}function tl(t){const[n,s]=l.useState(0);l.useEffect(()=>{if(n===0)return;const a=window.setTimeout(()=>s(0),t);return()=>window.clearTimeout(a)},[n,t]);const r=l.useCallback(()=>{s(a=>a+1)},[]);return[n>0,r]}function P5(t=2e3){return new Promise(n=>{let s=!1,r=null;const a=i=>{if(!s){s=!0,clearTimeout(o);try{r==null||r.close()}catch{}n(i)}},o=setTimeout(()=>a(!1),t);try{const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/health`;r=new WebSocket(c),r.onmessage=()=>a(!0),r.onopen=()=>a(!0),r.onerror=()=>a(!1),r.onclose=()=>a(!1)}catch{a(!1)}})}function O5(t){return t>=200&&t<300?"valid":t===401?"stale":"unreachable"}async function Db(t=1500){try{const n=await fetch("/api/session-check",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(t)});return O5(n.status)}catch{return"unreachable"}}async function A5(){try{await fetch("/build",{credentials:"same-origin",cache:"no-store"})}catch{return!1}return await Db()==="valid"}function R5({session:t,attempts:n,max:s}){return t!=="stale"?"check-transport":n<s?"reacquire":"give-up"}async function Gc(t=1500){try{const n=await fetch("/api/session-info",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(t)});if(!n.ok)return null;const s=await n.json();return E5(s==null?void 0:s.buildSessionExit)}catch{return null}}function E5(t){if(typeof t!="object"||t===null)return null;const n=t;return typeof n.sessionId!="string"||typeof n.reason!="string"?null:{sessionId:n.sessionId,pid:typeof n.pid=="number"?n.pid:0,signal:typeof n.signal=="string"?n.signal:null,signalNumber:typeof n.signalNumber=="number"?n.signalNumber:null,exitCode:typeof n.exitCode=="number"?n.exitCode:null,atUnixSecs:typeof n.atUnixSecs=="number"?n.atUnixSecs:0,origin:n.origin==="broker-initiated"?"broker-initiated":"external",reason:n.reason,externalDeath:n.externalDeath===!0,oomSignature:n.oomSignature===!0}}function M5({baseline:t,current:n}){return n?t===void 0?{kind:"transport"}:t===null?{kind:"process-death",report:n}:n.atUnixSecs!==t.atUnixSecs||n.pid!==t.pid?{kind:"process-death",report:n}:{kind:"transport"}:{kind:"transport"}}function sa(){return e.jsx("div",{"data-testid":"terminal-copied-toast",style:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",background:"#1f3a23",color:"#94ff94",border:"1px solid #397a39",borderRadius:4,padding:"6px 12px",fontFamily:"'IBM Plex Mono', monospace",fontSize:12,zIndex:6,pointerEvents:"none"},children:"Copied"})}const u9=Object.freeze(Object.defineProperty({__proto__:null,TerminalCopiedToast:sa},Symbol.toStringTag,{value:"Module"})),Uc=15,I5=3,L5=2,D5=5e3;function Fb({provider:t,agentStartMode:n,sessionId:s,onAgentIdle:r,onAgentActive:a,onAgentBlocked:o,onAgentStuckTurn:i,onAgentTurnEndedOffGate:c,onUserInput:d,onStartupFailed:u,onStartupFailedCleared:h,suppressReconnectOnStopBuilding:p=!1,launchIntent:m=!1}){if(Ot())return null;const f=l.useRef(null),g=l.useRef(null),b=l.useRef(null),x=l.useRef(null),y=l.useRef(null),v=l.useRef(!1),_=l.useRef(n??"fresh"),j=l.useRef(s??null),k=l.useRef(m),[S,w]=l.useState({kind:"connecting"}),[C,P]=l.useState(0),[T,O]=tl(1200);l.useEffect(()=>{_.current=n??"fresh",j.current=s??null,k.current=m},[n,s,m]);const N=l.useRef(r);N.current=r;const E=l.useRef(a);E.current=a;const I=l.useRef(o);I.current=o;const ee=l.useRef(i);ee.current=i;const B=l.useRef(c);B.current=c;const z=l.useRef(d);z.current=d;const Y=l.useRef(u);Y.current=u;const te=l.useRef(h);te.current=h;const R=L1({wsRef:y,insertInput:$=>{var V,ae;((V=y.current)==null?void 0:V.readyState)===WebSocket.OPEN&&y.current.send(JSON.stringify({type:"input",data:$})),Us(),(ae=z.current)==null||ae.call(z)}}),L=l.useRef(R);L.current=R;const M=l.useCallback($=>{var V;return((V=y.current)==null?void 0:V.readyState)===WebSocket.OPEN?(y.current.send(JSON.stringify({type:"input",data:$})),!0):!1},[]);D1(M,S.kind==="open");const K=F1(y,L);z1(K,S.kind==="open");const ie=l.useCallback(()=>{x.current===null&&(x.current=requestAnimationFrame(()=>{var $;x.current=null,($=g.current)==null||$.scrollToBottom()}))},[]);return el(f,()=>{var le;const $=b.current,V=g.current,ae=f.current;if(!$||!V)return;const{cellWidth:ne,cellHeight:me}=N5(V);if(!S5({width:(ae==null?void 0:ae.clientWidth)??NaN,height:(ae==null?void 0:ae.clientHeight)??NaN,cellWidth:ne,cellHeight:me})){ls("resize-skipped-degenerate",V,ae);return}const q=Wc(V.buffer.active);ls("resize-before-fit",V,ae),$.fit(),((le=y.current)==null?void 0:le.readyState)===WebSocket.OPEN&&y.current.send(JSON.stringify({type:"resize",cols:V.cols,rows:V.rows})),ls("resize-after-fit",V,ae),q&&ie()}),l.useEffect(()=>{if(!f.current||v.current)return;v.current=!0;const $=new Jo.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",scrollback:D5,rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),V=new Xo.FitAddon;$.loadAddon(V),$.open(f.current),g.current=$,b.current=V;const ae=Qo($,f.current,{onError:H=>L.current.showError(H),onCopy:()=>O()}),ne=$.onScroll(()=>{ls("scroll",$,f.current)}),me=Zo($,{sendInput:H=>{var G,be;((G=y.current)==null?void 0:G.readyState)===WebSocket.OPEN&&y.current.send(JSON.stringify({type:"input",data:H})),Us(),(be=z.current)==null||be.call(z)}});requestAnimationFrame(()=>{V.fit(),$.focus()});let q=!1,le=0,Pe=!1,Ce=0,F=0,J,Z=null;function ue(){Pe=!1,J=void 0,Gc().then(H=>{J=H});try{const H=new WebSocket(W1({provider:t,mode:_.current,sessionId:j.current??void 0,launch:k.current,cols:$.cols,rows:$.rows}));y.current=H,H.binaryType="arraybuffer",H.onmessage=G=>{var be,de,je,Ne,Ee,Le,He;if(G.data instanceof ArrayBuffer){const X=Wc($.buffer.active);$.write(new Uint8Array(G.data)),X&&(ls("replay-write",$,f.current),ie())}else if(typeof G.data=="string")try{const X=JSON.parse(G.data);if(X.type==="error"){q=!0,w({kind:"server-error",message:G1(X)});return}if(X.type==="session-id")_.current="resume",j.current=X.sessionId??null;else if(X.type==="agent-idle"||X.type==="claude-idle"){const Oe=typeof X.source=="string"?X.source:void 0;re("ws-message-received",{type:X.type,source:Oe}),(be=N.current)==null||be.call(N,Oe),window.dispatchEvent(new CustomEvent("build-agent-idle",{detail:{source:Oe}}))}else if(X.type==="agent-blocked"){const Oe=typeof X.source=="string"?X.source:void 0;re("ws-message-received-blocked",{type:X.type,source:Oe}),(de=I.current)==null||de.call(I,Oe)}else if(X.type==="agent-active"||X.type==="claude-active")re("ws-message-received-active",{type:X.type}),(je=E.current)==null||je.call(E);else if(X.type==="agent-stuck-turn"){const Oe=typeof X.silentMs=="number"?X.silentMs:0;re("ws-message-received-stuck-turn",{silentMs:Oe,source:typeof X.source=="string"?X.source:void 0}),(Ne=ee.current)==null||Ne.call(ee,Oe)}else if(X.type==="agent-turn-ended-off-gate"){const Oe=typeof X.step=="number"?X.step:0,it=typeof X.label=="string"?X.label:"";re("ws-message-received-turn-ended-off-gate",{step:Oe,slug:typeof X.slug=="string"?X.slug:void 0}),(Ee=B.current)==null||Ee.call(B,{step:Oe,label:it})}else if(X.type==="idle-diag"){const{site:Oe,event:it,...tt}=X;re(`rust:${it??"unknown"}`,{site:Oe,...tt})}else X.type==="drop-complete"?L.current.resolveDrop(String(X.id??""),String(X.path??"")):X.type==="drop-error"?L.current.rejectDrop(String(X.id??""),String(X.message??"drop failed")):X.type==="startup-failed"?(Le=Y.current)==null||Le.call(Y,String(X.snippet??"")):X.type==="startup-failed-cleared"?(He=te.current)==null||He.call(te):X.type==="agent-banner-ready"?(re("agent-banner-ready",{}),window.dispatchEvent(new CustomEvent("agent-banner-ready"))):X.type==="agent-auth-required"?(re("agent-auth-required",{}),window.dispatchEvent(new CustomEvent("agent-auth-required"))):X.type==="agent-auth-resolved"&&(re("agent-auth-resolved",{}),window.dispatchEvent(new CustomEvent("agent-auth-resolved")))}catch{}},H.onopen=()=>{le=0,Pe=!0,Ce=0,F=0,w({kind:"open"}),re("ws-open"),H.send(JSON.stringify({type:"resize",cols:$.cols,rows:$.rows}));try{typeof localStorage<"u"&&localStorage.getItem("codeyam.idleDebug")==="1"&&(H.send(JSON.stringify({type:"enable-idle-diag",sessionId:si()})),re("idle-diag-enabled"))}catch{}},H.onerror=()=>{},H.onclose=async()=>{if(re("ws-close",{reconnectAttempts:le}),L.current.cancelAllDrops("Not connected"),q){w(je=>je.kind==="server-error"?je:{kind:"ended"}),$.writeln(`\r
|
|
112
|
+
\x1B[90m[Terminal session ended]\x1B[0m`);return}const G=await U1();if(q)return;if(!G){w({kind:"server-stopped"}),Z==null||Z(),Z=V1(2e3,()=>{q||window.location.reload()});return}const be=await Gc();if(q)return;const de=M5({baseline:J,current:be});if(de.kind==="process-death"){w({kind:"session-died",report:de.report});return}if(Pe)Ce=0;else{Ce++;const je=await Db();if(q)return;const Ne=R5({session:je,attempts:F,max:L5});if(Ne==="reacquire"){F++,w({kind:"session-stale"});const Le=await A5();if(q)return;if(Le){Ce=0,ue();return}w({kind:"session-stale",canRetry:!0});return}if(Ne==="give-up"){w({kind:"session-stale",canRetry:!0});return}const Ee=await P5();if(q)return;if(!Ee||Ce>=I5){w({kind:"edge-unreachable"});return}}if(le<Uc){const je=le<4?1e3*Math.pow(2,le):1e4;le++,w({kind:"reconnecting",attempt:le,maxAttempts:Uc}),setTimeout(()=>{q||ue()},je)}else w({kind:"failed"})}}catch{w({kind:"failed"})}}try{V.fit()}catch{}ue();let ve=0;const fe=1e3;function se(){var G;const H=Date.now();H-ve>=fe&&((G=y.current)==null?void 0:G.readyState)===WebSocket.OPEN&&(y.current.send(JSON.stringify({type:"browser-activity"})),ve=H)}document.addEventListener("mousemove",se),document.addEventListener("keydown",se),document.addEventListener("mousedown",se),$.onData(H=>{var G,be;((G=y.current)==null?void 0:G.readyState)===WebSocket.OPEN?y.current.send(JSON.stringify({type:"input",data:H})):P(de=>de+1),Us(),(be=z.current)==null||be.call(z)});const Q=f.current;function ze(H){var Ee,Le,He;const G=H,be=Y1(G.clipboardData);if(be.length>0){H.preventDefault(),H.stopPropagation(),L.current.handleImageFiles(be);return}const de=((Ee=G.clipboardData)==null?void 0:Ee.getData("text"))??"";if(!de)return;H.preventDefault(),H.stopPropagation();const je=de.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),Ne=$.modes.bracketedPasteMode?`\x1B[200~${je}\x1B[201~`:je;((Le=y.current)==null?void 0:Le.readyState)===WebSocket.OPEN?y.current.send(JSON.stringify({type:"input",data:Ne})):P(X=>X+1),Us(),(He=z.current)==null||He.call(z)}Q.addEventListener("paste",ze,!0);function ge(H){var de,je;const G=H.detail;if(!G)return;((de=y.current)==null?void 0:de.readyState)===WebSocket.OPEN?((je=y.current)==null||je.send(JSON.stringify({type:"input",data:G})),re("terminal-send-input",{len:G.length,firstChars:G.slice(0,16),wsOpen:!0,dropped:!1})):re("terminal-send-input",{len:G.length,firstChars:G.slice(0,16),wsOpen:!1,dropped:!0})}window.addEventListener("terminal-send-input",ge),$1();function Ae(){ei(),$.focus()}window.addEventListener("terminal-focus",Ae);function Te(){var H;q=!0,(H=y.current)==null||H.close(),w({kind:"ended"}),$.reset()}return p&&window.addEventListener("build-session-stopped",Te),()=>{var H;q=!0,Z==null||Z(),Z=null,document.removeEventListener("mousemove",se),document.removeEventListener("keydown",se),document.removeEventListener("mousedown",se),window.removeEventListener("terminal-send-input",ge),K1(),window.removeEventListener("terminal-focus",Ae),p&&window.removeEventListener("build-session-stopped",Te),Q.removeEventListener("paste",ze,!0),me(),ne.dispose(),x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),(H=y.current)==null||H.close(),ae(),$.dispose(),v.current=!1}},[t,ie]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},"data-terminal-emulator":!0,onDragEnter:R.dropHandlers.onDragEnter,onDragOver:R.dropHandlers.onDragOver,onDragLeave:R.dropHandlers.onDragLeave,onDrop:R.dropHandlers.onDrop,onPaste:R.pasteHandler,children:[e.jsx("div",{ref:f,className:"flex-1",tabIndex:-1,style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3,outline:"none"},onPointerDown:()=>{gc(f.current,()=>{var $;return($=g.current)==null?void 0:$.focus()})},onClick:()=>{gc(f.current,()=>{var $;return($=g.current)==null?void 0:$.focus()})}}),R.dragActive&&e.jsx(B1,{}),R.errorToast&&e.jsx(H1,{message:R.errorToast}),T&&e.jsx(sa,{}),e.jsx(q1,{status:S,pulseKey:C,onRefresh:()=>window.location.reload()})]})}const h9=Object.freeze(Object.defineProperty({__proto__:null,TerminalEmulator:Fb},Symbol.toStringTag,{value:"Module"}));function zb({step:t,label:n,onDismiss:s,providerLabel:r}){const{sendToAgent:a,agentReady:o}=Ko();return e.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:e.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FFC53D]/60 bg-[#2a2000]",children:[e.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FFC53D] shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-[#FFD778]",children:[r," stopped at"," ",e.jsxs("span",{className:"font-medium",children:["step ",t,", ",n]})," ","— a step that isn't a decision point."]}),e.jsxs("p",{className:"text-xs text-[#FFD778]/70 mt-1",children:["Nothing is waiting on you here — ",r," was meant to keep going. Continue picks the work back up without you having to type."]})]}),e.jsx("button",{type:"button",disabled:!o,onClick:()=>a("Continue.\r"),className:"shrink-0 px-3 py-1.5 rounded-md text-sm font-medium border border-[#FFC53D]/60 text-[#FFD778] hover:bg-[#FFC53D]/15 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer transition-colors",title:o?`Tell ${r} to resume the workflow`:"No agent connected",children:"Continue"}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 p-0.5 mt-1 text-[#FFD778]/60 hover:text-[#FFD778] transition-colors cursor-pointer",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const p9=Object.freeze(Object.defineProperty({__proto__:null,TurnEndedOffGateBanner:zb},Symbol.toStringTag,{value:"Module"}));function $b({onAgentActive:t,onAgentIdle:n,onAgentBlocked:s,onUserInput:r,provider:a,sessionId:o,shouldResumeSameProvider:i,currentFeature:c}){const[d,u]=l.useState(null),[h,p]=l.useState(0),[m,f]=l.useState(null),[g,b]=l.useState(!1),[x,y]=l.useState(!1),[v,_]=l.useState(null),j=Pb(g,_r),k=j5(v!==null,_r);v5({provider:a,agentStartMode:i?"resume":"fresh",currentFeature:c}),l.useEffect(()=>()=>{b5()},[]);const S=l.useCallback(I=>{u(I)},[]),w=l.useCallback(()=>{u(null)},[]),C=l.useCallback(()=>{u(null),p(I=>I+1)},[]),P=l.useCallback(I=>{f(null),b(!1),n(I)},[n]),T=l.useCallback(()=>{f(null),b(!1),_(null),t()},[t]),O=l.useCallback(I=>{f(null),b(!1),_(I)},[]),N=l.useCallback(I=>{f(null),_(null),g||y(!1),b(!0),s(I)},[s,g]),E=l.useCallback(()=>{f(null),_(null),b(!1),r()},[r]);return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d!==null&&e.jsx(Ab,{snippet:d,onRetry:C,onDismiss:w,providerLabel:Ue(a)}),j===!0&&!x&&e.jsx(Ob,{onDismiss:()=>y(!0),providerLabel:Ue(a)}),m!==null&&e.jsx(Lb,{silentMs:m,onDismiss:()=>f(null),providerLabel:Ue(a)}),k&&v!==null&&e.jsx(zb,{step:v.step,label:v.label,onDismiss:()=>_(null),providerLabel:Ue(a)}),e.jsxs("div",{className:"relative flex flex-col flex-1 min-h-0",children:[e.jsx(Fb,{provider:a,agentStartMode:i?"resume":"fresh",sessionId:i?o:null,onAgentIdle:P,onAgentActive:T,onAgentBlocked:N,onAgentStuckTurn:f,onAgentTurnEndedOffGate:O,onUserInput:E,onStartupFailed:S,onStartupFailedCleared:w,suppressReconnectOnStopBuilding:!0,launchIntent:!0},h),e.jsx(Mb,{currentFeature:c}),e.jsx("div",{className:"absolute top-2 left-2 z-20 md:left-auto md:right-2",children:e.jsx(J1,{className:"rounded-full bg-gray-800/90 px-3 py-1.5 shadow-lg ring-1 ring-white/10 backdrop-blur"})})]})]})}const m9=Object.freeze(Object.defineProperty({__proto__:null,BuildTabTerminalSession:$b},Symbol.toStringTag,{value:"Module"}));function yt(){const t=()=>{typeof window<"u"&&window.dispatchEvent(new Event("terminal-focus"))};t();const n=requestAnimationFrame(t),s=setTimeout(t,50);return()=>{cancelAnimationFrame(n),clearTimeout(s)}}function Bb({onClick:t,disabled:n=!1}){const s="mt-3 inline-flex items-center gap-3 rounded-lg px-4 py-2.5 text-sm font-medium transition-opacity",r=n?"border border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"bg-[var(--accent-active)] text-[var(--text-on-accent)] hover:opacity-90 cursor-pointer";return e.jsxs("button",{type:"button",onClick:n?void 0:t,disabled:n,"aria-disabled":n,"data-testid":"start-chat",className:`${s} ${r}`,children:["Start Chat",!n&&e.jsx("span",{"aria-hidden":"true",className:"text-base leading-none",children:"↓"})]})}const f9=Object.freeze(Object.defineProperty({__proto__:null,StartChatButton:Bb},Symbol.toStringTag,{value:"Module"}));function Hb({draft:t,onDraftChange:n,onStart:s,providerLabel:r}){return e.jsxs(e.Fragment,{children:[e.jsx(Lr,{value:t,onChange:n,testId:"chat-describe-input",placeholder:"Ask anything about the project or CodeYam"}),e.jsx(Bb,{onClick:s}),e.jsxs("p",{className:"mt-2 text-xs text-[var(--text-dim)]",children:[r," reads the project's description, deliverables and scenarios before answering."]})]})}const g9=Object.freeze(Object.defineProperty({__proto__:null,BuildChatLaunchPanel:Hb},Symbol.toStringTag,{value:"Module"})),qb="/codeyam-plan",Wb="/codeyam-prototype",Gb="/codeyam-chat";function ra(t,n){const s=Ub(n);return s?`${t} ${s}`:t}function Ub(t){return t.replace(/\s+/g," ").trim()}function nl(t,n=""){const[s,r]=l.useState(n),[a,o]=l.useState(null),[i,c]=l.useState(null);return{draft:s,setDraft:r,seededCommand:a,seedText:i,open:()=>{o(ra(t,s)),c(Ub(s)||null)},close:()=>{o(null),c(null)},clearDraft:()=>r("")}}function Vb({onClose:t,slashCommand:n,seedText:s}){return e.jsx($t,{chatName:"chat",slashCommand:n??Gb,seedText:s,height:480,onClose:t})}const b9=Object.freeze(Object.defineProperty({__proto__:null,BuildChatAgentChat:Vb},Symbol.toStringTag,{value:"Module"}));function Yb(t){return Zd("miniagent-output",t)}const Kb='The user has clicked "I\'m done". Stop the current activity now. Do NOT start anything new, do NOT write a plan file, do NOT commit, and do NOT run any `codeyam-editor editor advance`/`step` command. Leave any edits you made in the working tree exactly as they are. Summarize what happened in ONE line, then stop.';function sl({disabled:t=!1,onDone:n}={}){const[s,r]=l.useState(!1),a=l.useRef(!1),o=async()=>{if(!(t||a.current)){a.current=!0,r(!0);try{Gn(Kb),await Yb(ys),Gn("\r"),n==null||n()}finally{a.current=!1,r(!1)}}},i=t||s;return e.jsx("button",{type:"button",onClick:o,disabled:i,"data-testid":"activity-done",className:"mt-3 ml-2 inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors "+(i?"border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"border-[var(--border-default)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--text-primary)] cursor-pointer"),children:"I'm Done"})}const x9=Object.freeze(Object.defineProperty({__proto__:null,ACTIVITY_DONE_INSTRUCTION:Kb,ActivityDoneButton:sl},Symbol.toStringTag,{value:"Module"})),Jb='The user has clicked "Finish and Formalize in Build". Stop prototyping. Write the plan BODY describing what was prototyped to a scratch file, then create the plan with `codeyam-editor editor plan-create --title "<feature name>" --mode ui --step 11 --source prototype --body-file <path>` (backend mode: `--mode backend --step 8`). Do NOT write the plan file yourself and do NOT hand-author frontmatter — plan-create derives the slug and stamps `createdAt`, which you have no clock to guess. It prints the path it wrote; take the slug from there and run `codeyam-editor editor launch-plan <slug>` to switch the UI to the Build tab, then output "Done — opening Build to finalize." and stop.';function rl({disabled:t=!1,onClick:n}={}){const[s,r]=l.useState(!1),a=l.useRef(!1),o=async()=>{if(!(t||a.current)){a.current=!0,r(!0);try{Gn(Jb),await Yb(ys),Gn("\r"),n==null||n()}finally{a.current=!1,r(!1)}}},i=t||s;return e.jsx("button",{type:"button",onClick:o,disabled:i,"data-testid":"finish-and-formalize",className:"mt-3 inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors "+(i?"border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"border-[var(--accent-active)] text-[var(--accent-active)] hover:bg-[var(--accent-active)] hover:text-black cursor-pointer"),children:"Finish and Formalize in Build"})}const y9=Object.freeze(Object.defineProperty({__proto__:null,FINISH_AND_FORMALIZE_INSTRUCTION:Jb,FinishAndFormalizeButton:rl},Symbol.toStringTag,{value:"Module"}));function Xb({escalatedToPrototype:t=!1,onDone:n,initialDraft:s="",initiallyOpen:r=!0}){const[a,o]=l.useState(r),i=nl(Gb,s),{config:c}=jt(),d=Ue(c==null?void 0:c.provider),u=()=>{i.open(),yt(),o(!0)},h=()=>{i.close(),o(!1)};return e.jsxs("div",{"data-testid":"build-chat-pane",children:[!a&&e.jsx(Hb,{draft:i.draft,onDraftChange:i.setDraft,onStart:u,providerLabel:d}),a&&e.jsxs(e.Fragment,{children:[e.jsx(Vb,{onClose:h,slashCommand:i.seededCommand??void 0,seedText:i.seedText??void 0}),t&&e.jsx(rl,{}),e.jsx(sl,{onDone:n})]})]})}const v9=Object.freeze(Object.defineProperty({__proto__:null,BuildChatPane:Xb},Symbol.toStringTag,{value:"Module"}));function Qb(t,n){const s=l.useRef(n);s.current=n;const r=l.useRef(t);l.useEffect(()=>{t!==r.current&&(r.current=t,s.current())},[t])}function Zb({onClose:t,slashCommand:n,seedText:s}){return e.jsx($t,{chatName:"prototype",slashCommand:n??Wb,seedText:s,height:480,onClose:t})}const j9=Object.freeze(Object.defineProperty({__proto__:null,PrototypeAgentChat:Zb},Symbol.toStringTag,{value:"Module"})),ex="Building is in-process. Prototyping is only available when building is not ongoing. Please wait for the current building session to complete before prototyping.";function tx(){return e.jsxs("div",{"data-testid":"prototype-building-banner",className:"mt-3 rounded border px-4 py-3 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",color:"var(--text-muted)"},children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Build in progress."})," ",ex]})}const w9=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_BUILDING_IN_PROGRESS_MESSAGE:ex,PrototypeBuildingInProgressBanner:tx},Symbol.toStringTag,{value:"Module"}));function xo({open:t,disabled:n=!1,onToggle:s}){const r="mt-3 inline-flex items-center gap-3 rounded-lg px-4 py-2.5 text-sm font-medium transition-opacity",a=n?"border border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"bg-[var(--accent-active)] text-[var(--text-on-accent)] hover:opacity-90 cursor-pointer";return e.jsxs("button",{type:"button",onClick:n?void 0:s,disabled:n,"aria-disabled":n,title:n?"Building is in progress.":void 0,"data-testid":"start-prototyping",className:`${r} ${a}`,children:[t?"Close Prototype":"Start Prototyping",!t&&!n&&e.jsx("span",{"aria-hidden":"true",className:"text-base leading-none",children:"↓"})]})}const _9=Object.freeze(Object.defineProperty({__proto__:null,StartPrototypingButton:xo},Symbol.toStringTag,{value:"Module"}));function nx(t,n){return`Launches a chat window with ${t} to ${n==="describe"?"describe your plan":"start prototyping"}.`}function sx({providerLabel:t,kind:n}){return e.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":`plan-chat-launch-caption-${n}`,children:nx(t,n)})}const k9=Object.freeze(Object.defineProperty({__proto__:null,PlanChatLaunchCaption:sx,planChatLaunchCaptionText:nx},Symbol.toStringTag,{value:"Module"}));function rx({isAgentBuilding:t,onLaunched:n,onDone:s,initiallyOpen:r=!1,launchSignal:a=0,initialDraft:o=""}){const[i,c]=l.useState(r),d=nl(Wb,o),[u,h]=l.useState(!1),{config:p}=jt(),m=Ue(p==null?void 0:p.provider);Qb(a,()=>{h(!1),c(!1),d.clearDraft(),n==null||n()});const f=()=>{if(t)return;const b=!i;b&&(d.open(),yt()),c(b)},g=()=>{d.close(),c(!1)};return t?e.jsxs("div",{"data-testid":"prototype-pane",children:[e.jsx(tx,{}),e.jsx(xo,{open:!1,disabled:!0,onToggle:()=>{}})]}):e.jsxs("div",{"data-testid":"prototype-pane",children:[!i&&e.jsx(Lr,{value:d.draft,onChange:d.setDraft,testId:"prototype-describe-input",placeholder:"Describe what you want to prototype"}),e.jsx(xo,{open:i,onToggle:f}),!i&&e.jsx(sx,{providerLabel:m,kind:"prototype"}),i&&e.jsxs(e.Fragment,{children:[e.jsx(Zb,{onClose:g,slashCommand:d.seededCommand??void 0,seedText:d.seedText??void 0}),e.jsx(rl,{disabled:u,onClick:()=>h(!0)}),e.jsx(sl,{disabled:u,onDone:s}),u&&e.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":"prototype-awaiting-formalize",children:"Waiting for the agent to write the plan file…"})]})]})}const S9=Object.freeze(Object.defineProperty({__proto__:null,PrototypePane:rx},Symbol.toStringTag,{value:"Module"}));function F5(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return l.useMemo(()=>r=>{n.forEach(a=>a(r))},n)}const aa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Zn(t){const n=Object.prototype.toString.call(t);return n==="[object Window]"||n==="[object global]"}function al(t){return"nodeType"in t}function gt(t){var n,s;return t?Zn(t)?t:al(t)&&(n=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?n:window:window}function ol(t){const{Document:n}=gt(t);return t instanceof n}function Rs(t){return Zn(t)?!1:t instanceof gt(t).HTMLElement}function ax(t){return t instanceof gt(t).SVGElement}function es(t){return t?Zn(t)?t.document:al(t)?ol(t)?t:Rs(t)||ax(t)?t.ownerDocument:document:document:document}const zt=aa?l.useLayoutEffect:l.useEffect;function il(t){const n=l.useRef(t);return zt(()=>{n.current=t}),l.useCallback(function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return n.current==null?void 0:n.current(...r)},[])}function z5(){const t=l.useRef(null),n=l.useCallback((r,a)=>{t.current=setInterval(r,a)},[]),s=l.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[n,s]}function ws(t,n){n===void 0&&(n=[t]);const s=l.useRef(t);return zt(()=>{s.current!==t&&(s.current=t)},n),s}function Es(t,n){const s=l.useRef();return l.useMemo(()=>{const r=t(s.current);return s.current=r,r},[...n])}function kr(t){const n=il(t),s=l.useRef(null),r=l.useCallback(a=>{a!==s.current&&(n==null||n(a,s.current)),s.current=a},[]);return[s,r]}function yo(t){const n=l.useRef();return l.useEffect(()=>{n.current=t},[t]),n.current}let Ia={};function Ms(t,n){return l.useMemo(()=>{if(n)return n;const s=Ia[t]==null?0:Ia[t]+1;return Ia[t]=s,t+"-"+s},[t,n])}function ox(t){return function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return r.reduce((o,i)=>{const c=Object.entries(i);for(const[d,u]of c){const h=o[d];h!=null&&(o[d]=h+t*u)}return o},{...n})}}const qn=ox(1),_s=ox(-1);function $5(t){return"clientX"in t&&"clientY"in t}function ll(t){if(!t)return!1;const{KeyboardEvent:n}=gt(t.target);return n&&t instanceof n}function B5(t){if(!t)return!1;const{TouchEvent:n}=gt(t.target);return n&&t instanceof n}function vo(t){if(B5(t)){if(t.touches&&t.touches.length){const{clientX:n,clientY:s}=t.touches[0];return{x:n,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:n,clientY:s}=t.changedTouches[0];return{x:n,y:s}}}return $5(t)?{x:t.clientX,y:t.clientY}:null}const ks=Object.freeze({Translate:{toString(t){if(!t)return;const{x:n,y:s}=t;return"translate3d("+(n?Math.round(n):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:n,scaleY:s}=t;return"scaleX("+n+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[ks.Translate.toString(t),ks.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:n,duration:s,easing:r}=t;return n+" "+s+"ms "+r}}}),Vc="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function H5(t){return t.matches(Vc)?t:t.querySelector(Vc)}const q5={display:"none"};function W5(t){let{id:n,value:s}=t;return pt.createElement("div",{id:n,style:q5},s)}function G5(t){let{id:n,announcement:s,ariaLiveType:r="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return pt.createElement("div",{id:n,style:a,role:"status","aria-live":r,"aria-atomic":!0},s)}function U5(){const[t,n]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&n(r)},[]),announcement:t}}const ix=l.createContext(null);function V5(t){const n=l.useContext(ix);l.useEffect(()=>{if(!n)throw new Error("useDndMonitor must be used within a children of <DndContext>");return n(t)},[t,n])}function Y5(){const[t]=l.useState(()=>new Set),n=l.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[l.useCallback(r=>{let{type:a,event:o}=r;t.forEach(i=>{var c;return(c=i[a])==null?void 0:c.call(i,o)})},[t]),n]}const K5={draggable:`
|
|
113
|
+
To pick up a draggable item, press the space bar.
|
|
114
|
+
While dragging, use the arrow keys to move the item.
|
|
115
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
116
|
+
`},J5={onDragStart(t){let{active:n}=t;return"Picked up draggable item "+n.id+"."},onDragOver(t){let{active:n,over:s}=t;return s?"Draggable item "+n.id+" was moved over droppable area "+s.id+".":"Draggable item "+n.id+" is no longer over a droppable area."},onDragEnd(t){let{active:n,over:s}=t;return s?"Draggable item "+n.id+" was dropped over droppable area "+s.id:"Draggable item "+n.id+" was dropped."},onDragCancel(t){let{active:n}=t;return"Dragging was cancelled. Draggable item "+n.id+" was dropped."}};function X5(t){let{announcements:n=J5,container:s,hiddenTextDescribedById:r,screenReaderInstructions:a=K5}=t;const{announce:o,announcement:i}=U5(),c=Ms("DndLiveRegion"),[d,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),V5(l.useMemo(()=>({onDragStart(p){let{active:m}=p;o(n.onDragStart({active:m}))},onDragMove(p){let{active:m,over:f}=p;n.onDragMove&&o(n.onDragMove({active:m,over:f}))},onDragOver(p){let{active:m,over:f}=p;o(n.onDragOver({active:m,over:f}))},onDragEnd(p){let{active:m,over:f}=p;o(n.onDragEnd({active:m,over:f}))},onDragCancel(p){let{active:m,over:f}=p;o(n.onDragCancel({active:m,over:f}))}}),[o,n])),!d)return null;const h=pt.createElement(pt.Fragment,null,pt.createElement(W5,{id:r,value:a.draggable}),pt.createElement(G5,{id:c,announcement:i}));return s?Nn.createPortal(h,s):h}var Ye;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Ye||(Ye={}));function Sr(){}function Yc(t,n){return l.useMemo(()=>({sensor:t,options:n??{}}),[t,n])}function Q5(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return l.useMemo(()=>[...n].filter(r=>r!=null),[...n])}const Pt=Object.freeze({x:0,y:0});function lx(t,n){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))}function cx(t,n){let{data:{value:s}}=t,{data:{value:r}}=n;return s-r}function Z5(t,n){let{data:{value:s}}=t,{data:{value:r}}=n;return r-s}function Kc(t){let{left:n,top:s,height:r,width:a}=t;return[{x:n,y:s},{x:n+a,y:s},{x:n,y:s+r},{x:n+a,y:s+r}]}function dx(t,n){if(!t||t.length===0)return null;const[s]=t;return s[n]}function Jc(t,n,s){return n===void 0&&(n=t.left),s===void 0&&(s=t.top),{x:n+t.width*.5,y:s+t.height*.5}}const eT=t=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=t;const a=Jc(n,n.left,n.top),o=[];for(const i of r){const{id:c}=i,d=s.get(c);if(d){const u=lx(Jc(d),a);o.push({id:c,data:{droppableContainer:i,value:u}})}}return o.sort(cx)},tT=t=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=t;const a=Kc(n),o=[];for(const i of r){const{id:c}=i,d=s.get(c);if(d){const u=Kc(d),h=a.reduce((m,f,g)=>m+lx(u[g],f),0),p=Number((h/4).toFixed(4));o.push({id:c,data:{droppableContainer:i,value:p}})}}return o.sort(cx)};function nT(t,n){const s=Math.max(n.top,t.top),r=Math.max(n.left,t.left),a=Math.min(n.left+n.width,t.left+t.width),o=Math.min(n.top+n.height,t.top+t.height),i=a-r,c=o-s;if(r<a&&s<o){const d=n.width*n.height,u=t.width*t.height,h=i*c,p=h/(d+u-h);return Number(p.toFixed(4))}return 0}const sT=t=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=t;const a=[];for(const o of r){const{id:i}=o,c=s.get(i);if(c){const d=nT(c,n);d>0&&a.push({id:i,data:{droppableContainer:o,value:d}})}}return a.sort(Z5)};function rT(t,n,s){return{...t,scaleX:n&&s?n.width/s.width:1,scaleY:n&&s?n.height/s.height:1}}function ux(t,n){return t&&n?{x:t.left-n.left,y:t.top-n.top}:Pt}function aT(t){return function(s){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];return a.reduce((i,c)=>({...i,top:i.top+t*c.y,bottom:i.bottom+t*c.y,left:i.left+t*c.x,right:i.right+t*c.x}),{...s})}}const oT=aT(1);function iT(t){if(t.startsWith("matrix3d(")){const n=t.slice(9,-1).split(/, /);return{x:+n[12],y:+n[13],scaleX:+n[0],scaleY:+n[5]}}else if(t.startsWith("matrix(")){const n=t.slice(7,-1).split(/, /);return{x:+n[4],y:+n[5],scaleX:+n[0],scaleY:+n[3]}}return null}function lT(t,n,s){const r=iT(n);if(!r)return t;const{scaleX:a,scaleY:o,x:i,y:c}=r,d=t.left-i-(1-a)*parseFloat(s),u=t.top-c-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=a?t.width/a:t.width,p=o?t.height/o:t.height;return{width:h,height:p,top:u,right:d+h,bottom:u+p,left:d}}const cT={ignoreTransform:!1};function ts(t,n){n===void 0&&(n=cT);let s=t.getBoundingClientRect();if(n.ignoreTransform){const{transform:u,transformOrigin:h}=gt(t).getComputedStyle(t);u&&(s=lT(s,u,h))}const{top:r,left:a,width:o,height:i,bottom:c,right:d}=s;return{top:r,left:a,width:o,height:i,bottom:c,right:d}}function Xc(t){return ts(t,{ignoreTransform:!0})}function dT(t){const n=t.innerWidth,s=t.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}function uT(t,n){return n===void 0&&(n=gt(t).getComputedStyle(t)),n.position==="fixed"}function hT(t,n){n===void 0&&(n=gt(t).getComputedStyle(t));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=n[a];return typeof o=="string"?s.test(o):!1})}function oa(t,n){const s=[];function r(a){if(n!=null&&s.length>=n||!a)return s;if(ol(a)&&a.scrollingElement!=null&&!s.includes(a.scrollingElement))return s.push(a.scrollingElement),s;if(!Rs(a)||ax(a)||s.includes(a))return s;const o=gt(t).getComputedStyle(a);return a!==t&&hT(a,o)&&s.push(a),uT(a,o)?s:r(a.parentNode)}return t?r(t):s}function hx(t){const[n]=oa(t,1);return n??null}function La(t){return!aa||!t?null:Zn(t)?t:al(t)?ol(t)||t===es(t).scrollingElement?window:Rs(t)?t:null:null}function px(t){return Zn(t)?t.scrollX:t.scrollLeft}function mx(t){return Zn(t)?t.scrollY:t.scrollTop}function jo(t){return{x:px(t),y:mx(t)}}var Je;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Je||(Je={}));function fx(t){return!aa||!t?!1:t===document.scrollingElement}function gx(t){const n={x:0,y:0},s=fx(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-s.width,y:t.scrollHeight-s.height},a=t.scrollTop<=n.y,o=t.scrollLeft<=n.x,i=t.scrollTop>=r.y,c=t.scrollLeft>=r.x;return{isTop:a,isLeft:o,isBottom:i,isRight:c,maxScroll:r,minScroll:n}}const pT={x:.2,y:.2};function mT(t,n,s,r,a){let{top:o,left:i,right:c,bottom:d}=s;r===void 0&&(r=10),a===void 0&&(a=pT);const{isTop:u,isBottom:h,isLeft:p,isRight:m}=gx(t),f={x:0,y:0},g={x:0,y:0},b={height:n.height*a.y,width:n.width*a.x};return!u&&o<=n.top+b.height?(f.y=Je.Backward,g.y=r*Math.abs((n.top+b.height-o)/b.height)):!h&&d>=n.bottom-b.height&&(f.y=Je.Forward,g.y=r*Math.abs((n.bottom-b.height-d)/b.height)),!m&&c>=n.right-b.width?(f.x=Je.Forward,g.x=r*Math.abs((n.right-b.width-c)/b.width)):!p&&i<=n.left+b.width&&(f.x=Je.Backward,g.x=r*Math.abs((n.left+b.width-i)/b.width)),{direction:f,speed:g}}function fT(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:i}=window;return{top:0,left:0,right:o,bottom:i,width:o,height:i}}const{top:n,left:s,right:r,bottom:a}=t.getBoundingClientRect();return{top:n,left:s,right:r,bottom:a,width:t.clientWidth,height:t.clientHeight}}function bx(t){return t.reduce((n,s)=>qn(n,jo(s)),Pt)}function gT(t){return t.reduce((n,s)=>n+px(s),0)}function bT(t){return t.reduce((n,s)=>n+mx(s),0)}function xT(t,n){if(n===void 0&&(n=ts),!t)return;const{top:s,left:r,bottom:a,right:o}=n(t);hx(t)&&(a<=0||o<=0||s>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const yT=[["x",["left","right"],gT],["y",["top","bottom"],bT]];class cl{constructor(n,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=oa(s),a=bx(r);this.rect={...n},this.width=n.width,this.height=n.height;for(const[o,i,c]of yT)for(const d of i)Object.defineProperty(this,d,{get:()=>{const u=c(r),h=a[o]-u;return this.rect[d]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fs{constructor(n){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...s)})},this.target=n}add(n,s,r){var a;(a=this.target)==null||a.addEventListener(n,s,r),this.listeners.push([n,s,r])}}function vT(t){const{EventTarget:n}=gt(t);return t instanceof n?t:es(t)}function Da(t,n){const s=Math.abs(t.x),r=Math.abs(t.y);return typeof n=="number"?Math.sqrt(s**2+r**2)>n:"x"in n&&"y"in n?s>n.x&&r>n.y:"x"in n?s>n.x:"y"in n?r>n.y:!1}var wt;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(wt||(wt={}));function Qc(t){t.preventDefault()}function jT(t){t.stopPropagation()}var Se;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Se||(Se={}));const xx={start:[Se.Space,Se.Enter],cancel:[Se.Esc],end:[Se.Space,Se.Enter,Se.Tab]},wT=(t,n)=>{let{currentCoordinates:s}=n;switch(t.code){case Se.Right:return{...s,x:s.x+25};case Se.Left:return{...s,x:s.x-25};case Se.Down:return{...s,y:s.y+25};case Se.Up:return{...s,y:s.y-25}}};class dl{constructor(n){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=n;const{event:{target:s}}=n;this.props=n,this.listeners=new fs(es(s)),this.windowListeners=new fs(gt(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(wt.Resize,this.handleCancel),this.windowListeners.add(wt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(wt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:n,onStart:s}=this.props,r=n.node.current;r&&xT(r),s(Pt)}handleKeyDown(n){if(ll(n)){const{active:s,context:r,options:a}=this.props,{keyboardCodes:o=xx,coordinateGetter:i=wT,scrollBehavior:c="smooth"}=a,{code:d}=n;if(o.end.includes(d)){this.handleEnd(n);return}if(o.cancel.includes(d)){this.handleCancel(n);return}const{collisionRect:u}=r.current,h=u?{x:u.left,y:u.top}:Pt;this.referenceCoordinates||(this.referenceCoordinates=h);const p=i(n,{active:s,context:r.current,currentCoordinates:h});if(p){const m=_s(p,h),f={x:0,y:0},{scrollableAncestors:g}=r.current;for(const b of g){const x=n.code,{isTop:y,isRight:v,isLeft:_,isBottom:j,maxScroll:k,minScroll:S}=gx(b),w=fT(b),C={x:Math.min(x===Se.Right?w.right-w.width/2:w.right,Math.max(x===Se.Right?w.left:w.left+w.width/2,p.x)),y:Math.min(x===Se.Down?w.bottom-w.height/2:w.bottom,Math.max(x===Se.Down?w.top:w.top+w.height/2,p.y))},P=x===Se.Right&&!v||x===Se.Left&&!_,T=x===Se.Down&&!j||x===Se.Up&&!y;if(P&&C.x!==p.x){const O=b.scrollLeft+m.x,N=x===Se.Right&&O<=k.x||x===Se.Left&&O>=S.x;if(N&&!m.y){b.scrollTo({left:O,behavior:c});return}N?f.x=b.scrollLeft-O:f.x=x===Se.Right?b.scrollLeft-k.x:b.scrollLeft-S.x,f.x&&b.scrollBy({left:-f.x,behavior:c});break}else if(T&&C.y!==p.y){const O=b.scrollTop+m.y,N=x===Se.Down&&O<=k.y||x===Se.Up&&O>=S.y;if(N&&!m.x){b.scrollTo({top:O,behavior:c});return}N?f.y=b.scrollTop-O:f.y=x===Se.Down?b.scrollTop-k.y:b.scrollTop-S.y,f.y&&b.scrollBy({top:-f.y,behavior:c});break}}this.handleMove(n,qn(_s(p,this.referenceCoordinates),f))}}}handleMove(n,s){const{onMove:r}=this.props;n.preventDefault(),r(s)}handleEnd(n){const{onEnd:s}=this.props;n.preventDefault(),this.detach(),s()}handleCancel(n){const{onCancel:s}=this.props;n.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}dl.activators=[{eventName:"onKeyDown",handler:(t,n,s)=>{let{keyboardCodes:r=xx,onActivation:a}=n,{active:o}=s;const{code:i}=t.nativeEvent;if(r.start.includes(i)){const c=o.activatorNode.current;return c&&t.target!==c?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function Zc(t){return!!(t&&"distance"in t)}function ed(t){return!!(t&&"delay"in t)}class ul{constructor(n,s,r){var a;r===void 0&&(r=vT(n.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=n,this.events=s;const{event:o}=n,{target:i}=o;this.props=n,this.events=s,this.document=es(i),this.documentListeners=new fs(this.document),this.listeners=new fs(r),this.windowListeners=new fs(gt(i)),this.initialCoordinates=(a=vo(o))!=null?a:Pt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:n,props:{options:{activationConstraint:s,bypassActivationConstraint:r}}}=this;if(this.listeners.add(n.move.name,this.handleMove,{passive:!1}),this.listeners.add(n.end.name,this.handleEnd),n.cancel&&this.listeners.add(n.cancel.name,this.handleCancel),this.windowListeners.add(wt.Resize,this.handleCancel),this.windowListeners.add(wt.DragStart,Qc),this.windowListeners.add(wt.VisibilityChange,this.handleCancel),this.windowListeners.add(wt.ContextMenu,Qc),this.documentListeners.add(wt.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ed(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Zc(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(n,s){const{active:r,onPending:a}=this.props;a(r,n,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:n}=this,{onStart:s}=this.props;n&&(this.activated=!0,this.documentListeners.add(wt.Click,jT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(wt.SelectionChange,this.removeTextSelection),s(n))}handleMove(n){var s;const{activated:r,initialCoordinates:a,props:o}=this,{onMove:i,options:{activationConstraint:c}}=o;if(!a)return;const d=(s=vo(n))!=null?s:Pt,u=_s(a,d);if(!r&&c){if(Zc(c)){if(c.tolerance!=null&&Da(u,c.tolerance))return this.handleCancel();if(Da(u,c.distance))return this.handleStart()}if(ed(c)&&Da(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}n.cancelable&&n.preventDefault(),i(d)}handleEnd(){const{onAbort:n,onEnd:s}=this.props;this.detach(),this.activated||n(this.props.active),s()}handleCancel(){const{onAbort:n,onCancel:s}=this.props;this.detach(),this.activated||n(this.props.active),s()}handleKeydown(n){n.code===Se.Esc&&this.handleCancel()}removeTextSelection(){var n;(n=this.document.getSelection())==null||n.removeAllRanges()}}const _T={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class hl extends ul{constructor(n){const{event:s}=n,r=es(s.target);super(n,_T,r)}}hl.activators=[{eventName:"onPointerDown",handler:(t,n)=>{let{nativeEvent:s}=t,{onActivation:r}=n;return!s.isPrimary||s.button!==0?!1:(r==null||r({event:s}),!0)}}];const kT={move:{name:"mousemove"},end:{name:"mouseup"}};var wo;(function(t){t[t.RightClick=2]="RightClick"})(wo||(wo={}));class ST extends ul{constructor(n){super(n,kT,es(n.event.target))}}ST.activators=[{eventName:"onMouseDown",handler:(t,n)=>{let{nativeEvent:s}=t,{onActivation:r}=n;return s.button===wo.RightClick?!1:(r==null||r({event:s}),!0)}}];const Fa={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class NT extends ul{constructor(n){super(n,Fa)}static setup(){return window.addEventListener(Fa.move.name,n,{capture:!1,passive:!1}),function(){window.removeEventListener(Fa.move.name,n)};function n(){}}}NT.activators=[{eventName:"onTouchStart",handler:(t,n)=>{let{nativeEvent:s}=t,{onActivation:r}=n;const{touches:a}=s;return a.length>1?!1:(r==null||r({event:s}),!0)}}];var gs;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(gs||(gs={}));var Nr;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Nr||(Nr={}));function CT(t){let{acceleration:n,activator:s=gs.Pointer,canScroll:r,draggingRect:a,enabled:o,interval:i=5,order:c=Nr.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:h,delta:p,threshold:m}=t;const f=PT({delta:p,disabled:!o}),[g,b]=z5(),x=l.useRef({x:0,y:0}),y=l.useRef({x:0,y:0}),v=l.useMemo(()=>{switch(s){case gs.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case gs.DraggableRect:return a}},[s,a,d]),_=l.useRef(null),j=l.useCallback(()=>{const S=_.current;if(!S)return;const w=x.current.x*y.current.x,C=x.current.y*y.current.y;S.scrollBy(w,C)},[]),k=l.useMemo(()=>c===Nr.TreeOrder?[...u].reverse():u,[c,u]);l.useEffect(()=>{if(!o||!u.length||!v){b();return}for(const S of k){if((r==null?void 0:r(S))===!1)continue;const w=u.indexOf(S),C=h[w];if(!C)continue;const{direction:P,speed:T}=mT(S,C,v,n,m);for(const O of["x","y"])f[O][P[O]]||(T[O]=0,P[O]=0);if(T.x>0||T.y>0){b(),_.current=S,g(j,i),x.current=T,y.current=P;return}}x.current={x:0,y:0},y.current={x:0,y:0},b()},[n,j,r,b,o,i,JSON.stringify(v),JSON.stringify(f),g,u,k,h,JSON.stringify(m)])}const TT={x:{[Je.Backward]:!1,[Je.Forward]:!1},y:{[Je.Backward]:!1,[Je.Forward]:!1}};function PT(t){let{delta:n,disabled:s}=t;const r=yo(n);return Es(a=>{if(s||!r||!a)return TT;const o={x:Math.sign(n.x-r.x),y:Math.sign(n.y-r.y)};return{x:{[Je.Backward]:a.x[Je.Backward]||o.x===-1,[Je.Forward]:a.x[Je.Forward]||o.x===1},y:{[Je.Backward]:a.y[Je.Backward]||o.y===-1,[Je.Forward]:a.y[Je.Forward]||o.y===1}}},[s,n,r])}function OT(t,n){const s=n!=null?t.get(n):void 0,r=s?s.node.current:null;return Es(a=>{var o;return n==null?null:(o=r??a)!=null?o:null},[r,n])}function AT(t,n){return l.useMemo(()=>t.reduce((s,r)=>{const{sensor:a}=r,o=a.activators.map(i=>({eventName:i.eventName,handler:n(i.handler,r)}));return[...s,...o]},[]),[t,n])}var Ss;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Ss||(Ss={}));var _o;(function(t){t.Optimized="optimized"})(_o||(_o={}));const td=new Map;function RT(t,n){let{dragging:s,dependencies:r,config:a}=n;const[o,i]=l.useState(null),{frequency:c,measure:d,strategy:u}=a,h=l.useRef(t),p=x(),m=ws(p),f=l.useCallback(function(y){y===void 0&&(y=[]),!m.current&&i(v=>v===null?y:v.concat(y.filter(_=>!v.includes(_))))},[m]),g=l.useRef(null),b=Es(y=>{if(p&&!s)return td;if(!y||y===td||h.current!==t||o!=null){const v=new Map;for(let _ of t){if(!_)continue;if(o&&o.length>0&&!o.includes(_.id)&&_.rect.current){v.set(_.id,_.rect.current);continue}const j=_.node.current,k=j?new cl(d(j),j):null;_.rect.current=k,k&&v.set(_.id,k)}return v}return y},[t,o,s,p,d]);return l.useEffect(()=>{h.current=t},[t]),l.useEffect(()=>{p||f()},[s,p]),l.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),l.useEffect(()=>{p||typeof c!="number"||g.current!==null||(g.current=setTimeout(()=>{f(),g.current=null},c))},[c,p,f,...r]),{droppableRects:b,measureDroppableContainers:f,measuringScheduled:o!=null};function x(){switch(u){case Ss.Always:return!1;case Ss.BeforeDragging:return s;default:return!s}}}function yx(t,n){return Es(s=>t?s||(typeof n=="function"?n(t):t):null,[n,t])}function ET(t,n){return yx(t,n)}function MT(t){let{callback:n,disabled:s}=t;const r=il(n),a=l.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,s]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function ia(t){let{callback:n,disabled:s}=t;const r=il(n),a=l.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[s]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function IT(t){return new cl(ts(t),t)}function nd(t,n,s){n===void 0&&(n=IT);const[r,a]=l.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??s)!=null?u:null}const h=n(t);return JSON.stringify(d)===JSON.stringify(h)?d:h})}const i=MT({callback(d){if(t)for(const u of d){const{type:h,target:p}=u;if(h==="childList"&&p instanceof HTMLElement&&p.contains(t)){o();break}}}}),c=ia({callback:o});return zt(()=>{o(),t?(c==null||c.observe(t),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(c==null||c.disconnect(),i==null||i.disconnect())},[t]),r}function LT(t){const n=yx(t);return ux(t,n)}const sd=[];function DT(t){const n=l.useRef(t),s=Es(r=>t?r&&r!==sd&&t&&n.current&&t.parentNode===n.current.parentNode?r:oa(t):sd,[t]);return l.useEffect(()=>{n.current=t},[t]),s}function FT(t){const[n,s]=l.useState(null),r=l.useRef(t),a=l.useCallback(o=>{const i=La(o.target);i&&s(c=>c?(c.set(i,jo(i)),new Map(c)):null)},[]);return l.useEffect(()=>{const o=r.current;if(t!==o){i(o);const c=t.map(d=>{const u=La(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,jo(u)]):null}).filter(d=>d!=null);s(c.length?new Map(c):null),r.current=t}return()=>{i(t),i(o)};function i(c){c.forEach(d=>{const u=La(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),l.useMemo(()=>t.length?n?Array.from(n.values()).reduce((o,i)=>qn(o,i),Pt):bx(t):Pt,[t,n])}function rd(t,n){n===void 0&&(n=[]);const s=l.useRef(null);return l.useEffect(()=>{s.current=null},n),l.useEffect(()=>{const r=t!==Pt;r&&!s.current&&(s.current=t),!r&&s.current&&(s.current=null)},[t]),s.current?_s(t,s.current):Pt}function zT(t){l.useEffect(()=>{if(!aa)return;const n=t.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of n)s==null||s()}},t.map(n=>{let{sensor:s}=n;return s}))}function $T(t,n){return l.useMemo(()=>t.reduce((s,r)=>{let{eventName:a,handler:o}=r;return s[a]=i=>{o(i,n)},s},{}),[t,n])}function vx(t){return l.useMemo(()=>t?dT(t):null,[t])}const ad=[];function BT(t,n){n===void 0&&(n=ts);const[s]=t,r=vx(s?gt(s):null),[a,o]=l.useState(ad);function i(){o(()=>t.length?t.map(d=>fx(d)?r:new cl(n(d),d)):ad)}const c=ia({callback:i});return zt(()=>{c==null||c.disconnect(),i(),t.forEach(d=>c==null?void 0:c.observe(d))},[t]),a}function HT(t){if(!t)return null;if(t.children.length>1)return t;const n=t.children[0];return Rs(n)?n:t}function qT(t){let{measure:n}=t;const[s,r]=l.useState(null),a=l.useCallback(u=>{for(const{target:h}of u)if(Rs(h)){r(p=>{const m=n(h);return p?{...p,width:m.width,height:m.height}:m});break}},[n]),o=ia({callback:a}),i=l.useCallback(u=>{const h=HT(u);o==null||o.disconnect(),h&&(o==null||o.observe(h)),r(h?n(h):null)},[n,o]),[c,d]=kr(i);return l.useMemo(()=>({nodeRef:c,rect:s,setRef:d}),[s,c,d])}const WT=[{sensor:hl,options:{}},{sensor:dl,options:{}}],GT={current:{}},mr={draggable:{measure:Xc},droppable:{measure:Xc,strategy:Ss.WhileDragging,frequency:_o.Optimized},dragOverlay:{measure:ts}};class bs extends Map{get(n){var s;return n!=null&&(s=super.get(n))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(n=>{let{disabled:s}=n;return!s})}getNodeFor(n){var s,r;return(s=(r=this.get(n))==null?void 0:r.node.current)!=null?s:void 0}}const UT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new bs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Sr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:mr,measureDroppableContainers:Sr,windowRect:null,measuringScheduled:!1},VT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Sr,draggableNodes:new Map,over:null,measureDroppableContainers:Sr},la=l.createContext(VT),jx=l.createContext(UT);function YT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new bs}}}function KT(t,n){switch(n.type){case Ye.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:n.initialCoordinates,active:n.active}};case Ye.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:n.coordinates.x-t.draggable.initialCoordinates.x,y:n.coordinates.y-t.draggable.initialCoordinates.y}}};case Ye.DragEnd:case Ye.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ye.RegisterDroppable:{const{element:s}=n,{id:r}=s,a=new bs(t.droppable.containers);return a.set(r,s),{...t,droppable:{...t.droppable,containers:a}}}case Ye.SetDroppableDisabled:{const{id:s,key:r,disabled:a}=n,o=t.droppable.containers.get(s);if(!o||r!==o.key)return t;const i=new bs(t.droppable.containers);return i.set(s,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:i}}}case Ye.UnregisterDroppable:{const{id:s,key:r}=n,a=t.droppable.containers.get(s);if(!a||r!==a.key)return t;const o=new bs(t.droppable.containers);return o.delete(s),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function JT(t){let{disabled:n}=t;const{active:s,activatorEvent:r,draggableNodes:a}=l.useContext(la),o=yo(r),i=yo(s==null?void 0:s.id);return l.useEffect(()=>{if(!n&&!r&&o&&i!=null){if(!ll(o)||document.activeElement===o.target)return;const c=a.get(i);if(!c)return;const{activatorNode:d,node:u}=c;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const h of[d.current,u.current]){if(!h)continue;const p=H5(h);if(p){p.focus();break}}})}},[r,n,a,i,o]),null}function XT(t,n){let{transform:s,...r}=n;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...r}),s):s}function QT(t){return l.useMemo(()=>({draggable:{...mr.draggable,...t==null?void 0:t.draggable},droppable:{...mr.droppable,...t==null?void 0:t.droppable},dragOverlay:{...mr.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function ZT(t){let{activeNode:n,measure:s,initialRect:r,config:a=!0}=t;const o=l.useRef(!1),{x:i,y:c}=typeof a=="boolean"?{x:a,y:a}:a;zt(()=>{if(!i&&!c||!n){o.current=!1;return}if(o.current||!r)return;const u=n==null?void 0:n.node.current;if(!u||u.isConnected===!1)return;const h=s(u),p=ux(h,r);if(i||(p.x=0),c||(p.y=0),o.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const m=hx(u);m&&m.scrollBy({top:p.y,left:p.x})}},[n,i,c,r,s])}const wx=l.createContext({...Pt,scaleX:1,scaleY:1});var tn;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(tn||(tn={}));const eP=l.memo(function(n){var s,r,a,o;let{id:i,accessibility:c,autoScroll:d=!0,children:u,sensors:h=WT,collisionDetection:p=sT,measuring:m,modifiers:f,...g}=n;const b=l.useReducer(KT,void 0,YT),[x,y]=b,[v,_]=Y5(),[j,k]=l.useState(tn.Uninitialized),S=j===tn.Initialized,{draggable:{active:w,nodes:C,translate:P},droppable:{containers:T}}=x,O=w!=null?C.get(w):null,N=l.useRef({initial:null,translated:null}),E=l.useMemo(()=>{var _e;return w!=null?{id:w,data:(_e=O==null?void 0:O.data)!=null?_e:GT,rect:N}:null},[w,O]),I=l.useRef(null),[ee,B]=l.useState(null),[z,Y]=l.useState(null),te=ws(g,Object.values(g)),R=Ms("DndDescribedBy",i),L=l.useMemo(()=>T.getEnabled(),[T]),M=QT(m),{droppableRects:K,measureDroppableContainers:ie,measuringScheduled:$}=RT(L,{dragging:S,dependencies:[P.x,P.y],config:M.droppable}),V=OT(C,w),ae=l.useMemo(()=>z?vo(z):null,[z]),ne=kt(),me=ET(V,M.draggable.measure);ZT({activeNode:w!=null?C.get(w):null,config:ne.layoutShiftCompensation,initialRect:me,measure:M.draggable.measure});const q=nd(V,M.draggable.measure,me),le=nd(V?V.parentElement:null),Pe=l.useRef({activatorEvent:null,active:null,activeNode:V,collisionRect:null,collisions:null,droppableRects:K,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ce=T.getNodeFor((s=Pe.current.over)==null?void 0:s.id),F=qT({measure:M.dragOverlay.measure}),J=(r=F.nodeRef.current)!=null?r:V,Z=S?(a=F.rect)!=null?a:q:null,ue=!!(F.nodeRef.current&&F.rect),ve=LT(ue?null:q),fe=vx(J?gt(J):null),se=DT(S?Ce??V:null),Q=BT(se),ze=XT(f,{transform:{x:P.x-ve.x,y:P.y-ve.y,scaleX:1,scaleY:1},activatorEvent:z,active:E,activeNodeRect:q,containerNodeRect:le,draggingNodeRect:Z,over:Pe.current.over,overlayNodeRect:F.rect,scrollableAncestors:se,scrollableAncestorRects:Q,windowRect:fe}),ge=ae?qn(ae,P):null,Ae=FT(se),Te=rd(Ae),H=rd(Ae,[q]),G=qn(ze,Te),be=Z?oT(Z,ze):null,de=E&&be?p({active:E,collisionRect:be,droppableRects:K,droppableContainers:L,pointerCoordinates:ge}):null,je=dx(de,"id"),[Ne,Ee]=l.useState(null),Le=ue?ze:qn(ze,H),He=rT(Le,(o=Ne==null?void 0:Ne.rect)!=null?o:null,q),X=l.useRef(null),Oe=l.useCallback((_e,ce)=>{let{sensor:U,options:Re}=ce;if(I.current==null)return;const De=C.get(I.current);if(!De)return;const qe=_e.nativeEvent,nt=new U({active:I.current,activeNode:De,event:qe,options:Re,context:Pe,onAbort(Fe){if(!C.get(Fe))return;const{onDragAbort:Ie}=te.current,$e={id:Fe};Ie==null||Ie($e),v({type:"onDragAbort",event:$e})},onPending(Fe,ct,Ie,$e){if(!C.get(Fe))return;const{onDragPending:st}=te.current,Ve={id:Fe,constraint:ct,initialCoordinates:Ie,offset:$e};st==null||st(Ve),v({type:"onDragPending",event:Ve})},onStart(Fe){const ct=I.current;if(ct==null)return;const Ie=C.get(ct);if(!Ie)return;const{onDragStart:$e}=te.current,D={activatorEvent:qe,active:{id:ct,data:Ie.data,rect:N}};Nn.unstable_batchedUpdates(()=>{$e==null||$e(D),k(tn.Initializing),y({type:Ye.DragStart,initialCoordinates:Fe,active:ct}),v({type:"onDragStart",event:D}),B(X.current),Y(qe)})},onMove(Fe){y({type:Ye.DragMove,coordinates:Fe})},onEnd:lt(Ye.DragEnd),onCancel:lt(Ye.DragCancel)});X.current=nt;function lt(Fe){return async function(){const{active:Ie,collisions:$e,over:D,scrollAdjustedTranslate:st}=Pe.current;let Ve=null;if(Ie&&st){const{cancelDrop:St}=te.current;Ve={activatorEvent:qe,active:Ie,collisions:$e,delta:st,over:D},Fe===Ye.DragEnd&&typeof St=="function"&&await Promise.resolve(St(Ve))&&(Fe=Ye.DragCancel)}I.current=null,Nn.unstable_batchedUpdates(()=>{y({type:Fe}),k(tn.Uninitialized),Ee(null),B(null),Y(null),X.current=null;const St=Fe===Ye.DragEnd?"onDragEnd":"onDragCancel";if(Ve){const Wt=te.current[St];Wt==null||Wt(Ve),v({type:St,event:Ve})}})}}},[C]),it=l.useCallback((_e,ce)=>(U,Re)=>{const De=U.nativeEvent,qe=C.get(Re);if(I.current!==null||!qe||De.dndKit||De.defaultPrevented)return;const nt={active:qe};_e(U,ce.options,nt)===!0&&(De.dndKit={capturedBy:ce.sensor},I.current=Re,Oe(U,ce))},[C,Oe]),tt=AT(h,it);zT(h),zt(()=>{q&&j===tn.Initializing&&k(tn.Initialized)},[q,j]),l.useEffect(()=>{const{onDragMove:_e}=te.current,{active:ce,activatorEvent:U,collisions:Re,over:De}=Pe.current;if(!ce||!U)return;const qe={active:ce,activatorEvent:U,collisions:Re,delta:{x:G.x,y:G.y},over:De};Nn.unstable_batchedUpdates(()=>{_e==null||_e(qe),v({type:"onDragMove",event:qe})})},[G.x,G.y]),l.useEffect(()=>{const{active:_e,activatorEvent:ce,collisions:U,droppableContainers:Re,scrollAdjustedTranslate:De}=Pe.current;if(!_e||I.current==null||!ce||!De)return;const{onDragOver:qe}=te.current,nt=Re.get(je),lt=nt&&nt.rect.current?{id:nt.id,rect:nt.rect.current,data:nt.data,disabled:nt.disabled}:null,Fe={active:_e,activatorEvent:ce,collisions:U,delta:{x:De.x,y:De.y},over:lt};Nn.unstable_batchedUpdates(()=>{Ee(lt),qe==null||qe(Fe),v({type:"onDragOver",event:Fe})})},[je]),zt(()=>{Pe.current={activatorEvent:z,active:E,activeNode:V,collisionRect:be,collisions:de,droppableRects:K,draggableNodes:C,draggingNode:J,draggingNodeRect:Z,droppableContainers:T,over:Ne,scrollableAncestors:se,scrollAdjustedTranslate:G},N.current={initial:Z,translated:be}},[E,V,de,be,C,J,Z,K,T,Ne,se,G]),CT({...ne,delta:P,draggingRect:be,pointerCoordinates:ge,scrollableAncestors:se,scrollableAncestorRects:Q});const qt=l.useMemo(()=>({active:E,activeNode:V,activeNodeRect:q,activatorEvent:z,collisions:de,containerNodeRect:le,dragOverlay:F,draggableNodes:C,droppableContainers:T,droppableRects:K,over:Ne,measureDroppableContainers:ie,scrollableAncestors:se,scrollableAncestorRects:Q,measuringConfiguration:M,measuringScheduled:$,windowRect:fe}),[E,V,q,z,de,le,F,C,T,K,Ne,ie,se,Q,M,$,fe]),Ke=l.useMemo(()=>({activatorEvent:z,activators:tt,active:E,activeNodeRect:q,ariaDescribedById:{draggable:R},dispatch:y,draggableNodes:C,over:Ne,measureDroppableContainers:ie}),[z,tt,E,q,y,R,C,Ne,ie]);return pt.createElement(ix.Provider,{value:_},pt.createElement(la.Provider,{value:Ke},pt.createElement(jx.Provider,{value:qt},pt.createElement(wx.Provider,{value:He},u)),pt.createElement(JT,{disabled:(c==null?void 0:c.restoreFocus)===!1})),pt.createElement(X5,{...c,hiddenTextDescribedById:R}));function kt(){const _e=(ee==null?void 0:ee.autoScrollEnabled)===!1,ce=typeof d=="object"?d.enabled===!1:d===!1,U=S&&!_e&&!ce;return typeof d=="object"?{...d,enabled:U}:{enabled:U}}}),tP=l.createContext(null),od="button",nP="Draggable";function sP(t){let{id:n,data:s,disabled:r=!1,attributes:a}=t;const o=Ms(nP),{activators:i,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:h,draggableNodes:p,over:m}=l.useContext(la),{role:f=od,roleDescription:g="draggable",tabIndex:b=0}=a??{},x=(d==null?void 0:d.id)===n,y=l.useContext(x?wx:tP),[v,_]=kr(),[j,k]=kr(),S=$T(i,n),w=ws(s);zt(()=>(p.set(n,{id:n,key:o,node:v,activatorNode:j,data:w}),()=>{const P=p.get(n);P&&P.key===o&&p.delete(n)}),[p,n]);const C=l.useMemo(()=>({role:f,tabIndex:b,"aria-disabled":r,"aria-pressed":x&&f===od?!0:void 0,"aria-roledescription":g,"aria-describedby":h.draggable}),[r,f,b,x,g,h.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:C,isDragging:x,listeners:r?void 0:S,node:v,over:m,setNodeRef:_,setActivatorNodeRef:k,transform:y}}function rP(){return l.useContext(jx)}const aP="Droppable",oP={timeout:25};function iP(t){let{data:n,disabled:s=!1,id:r,resizeObserverConfig:a}=t;const o=Ms(aP),{active:i,dispatch:c,over:d,measureDroppableContainers:u}=l.useContext(la),h=l.useRef({disabled:s}),p=l.useRef(!1),m=l.useRef(null),f=l.useRef(null),{disabled:g,updateMeasurementsFor:b,timeout:x}={...oP,...a},y=ws(b??r),v=l.useCallback(()=>{if(!p.current){p.current=!0;return}f.current!=null&&clearTimeout(f.current),f.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),f.current=null},x)},[x]),_=ia({callback:v,disabled:g||!i}),j=l.useCallback((C,P)=>{_&&(P&&(_.unobserve(P),p.current=!1),C&&_.observe(C))},[_]),[k,S]=kr(j),w=ws(n);return l.useEffect(()=>{!_||!k.current||(_.disconnect(),p.current=!1,_.observe(k.current))},[k,_]),l.useEffect(()=>(c({type:Ye.RegisterDroppable,element:{id:r,key:o,disabled:s,node:k,rect:m,data:w}}),()=>c({type:Ye.UnregisterDroppable,key:o,id:r})),[r]),l.useEffect(()=>{s!==h.current.disabled&&(c({type:Ye.SetDroppableDisabled,id:r,key:o,disabled:s}),h.current.disabled=s)},[r,o,s,c]),{active:i,rect:m,isOver:(d==null?void 0:d.id)===r,node:k,over:d,setNodeRef:S}}function Ns(t,n,s){const r=t.slice();return r.splice(s<0?r.length+s:s,0,r.splice(n,1)[0]),r}function lP(t,n){return t.reduce((s,r,a)=>{const o=n.get(r);return o&&(s[a]=o),s},Array(t.length))}function Xs(t){return t!==null&&t>=0}function cP(t,n){if(t===n)return!0;if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function dP(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const _x=t=>{let{rects:n,activeIndex:s,overIndex:r,index:a}=t;const o=Ns(n,r,s),i=n[a],c=o[a];return!c||!i?null:{x:c.left-i.left,y:c.top-i.top,scaleX:c.width/i.width,scaleY:c.height/i.height}},Qs={scaleX:1,scaleY:1},uP=t=>{var n;let{activeIndex:s,activeNodeRect:r,index:a,rects:o,overIndex:i}=t;const c=(n=o[s])!=null?n:r;if(!c)return null;if(a===s){const u=o[i];return u?{x:0,y:s<i?u.top+u.height-(c.top+c.height):u.top-c.top,...Qs}:null}const d=hP(o,a,s);return a>s&&a<=i?{x:0,y:-c.height-d,...Qs}:a<s&&a>=i?{x:0,y:c.height+d,...Qs}:{x:0,y:0,...Qs}};function hP(t,n,s){const r=t[n],a=t[n-1],o=t[n+1];return r?s<n?a?r.top-(a.top+a.height):o?o.top-(r.top+r.height):0:o?o.top-(r.top+r.height):a?r.top-(a.top+a.height):0:0}const kx="Sortable",Sx=pt.createContext({activeIndex:-1,containerId:kx,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:_x,disabled:{draggable:!1,droppable:!1}});function pP(t){let{children:n,id:s,items:r,strategy:a=_x,disabled:o=!1}=t;const{active:i,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:h}=rP(),p=Ms(kx,s),m=c.rect!==null,f=l.useMemo(()=>r.map(S=>typeof S=="object"&&"id"in S?S.id:S),[r]),g=i!=null,b=i?f.indexOf(i.id):-1,x=u?f.indexOf(u.id):-1,y=l.useRef(f),v=!cP(f,y.current),_=x!==-1&&b===-1||v,j=dP(o);zt(()=>{v&&g&&h(f)},[v,f,g,h]),l.useEffect(()=>{y.current=f},[f]);const k=l.useMemo(()=>({activeIndex:b,containerId:p,disabled:j,disableTransforms:_,items:f,overIndex:x,useDragOverlay:m,sortedRects:lP(f,d),strategy:a}),[b,p,j.draggable,j.droppable,_,f,x,d,m,a]);return pt.createElement(Sx.Provider,{value:k},n)}const mP=t=>{let{id:n,items:s,activeIndex:r,overIndex:a}=t;return Ns(s,r,a).indexOf(n)},fP=t=>{let{containerId:n,isSorting:s,wasDragging:r,index:a,items:o,newIndex:i,previousItems:c,previousContainerId:d,transition:u}=t;return!u||!r||c!==o&&a===i?!1:s?!0:i!==a&&n===d},gP={duration:200,easing:"ease"},Nx="transform",bP=ks.Transition.toString({property:Nx,duration:0,easing:"linear"}),xP={roleDescription:"sortable"};function yP(t){let{disabled:n,index:s,node:r,rect:a}=t;const[o,i]=l.useState(null),c=l.useRef(s);return zt(()=>{if(!n&&s!==c.current&&r.current){const d=a.current;if(d){const u=ts(r.current,{ignoreTransform:!0}),h={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(h.x||h.y)&&i(h)}}s!==c.current&&(c.current=s)},[n,s,r,a]),l.useEffect(()=>{o&&i(null)},[o]),o}function vP(t){let{animateLayoutChanges:n=fP,attributes:s,disabled:r,data:a,getNewIndex:o=mP,id:i,strategy:c,resizeObserverConfig:d,transition:u=gP}=t;const{items:h,containerId:p,activeIndex:m,disabled:f,disableTransforms:g,sortedRects:b,overIndex:x,useDragOverlay:y,strategy:v}=l.useContext(Sx),_=jP(r,f),j=h.indexOf(i),k=l.useMemo(()=>({sortable:{containerId:p,index:j,items:h},...a}),[p,a,j,h]),S=l.useMemo(()=>h.slice(h.indexOf(i)),[h,i]),{rect:w,node:C,isOver:P,setNodeRef:T}=iP({id:i,data:k,disabled:_.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...d}}),{active:O,activatorEvent:N,activeNodeRect:E,attributes:I,setNodeRef:ee,listeners:B,isDragging:z,over:Y,setActivatorNodeRef:te,transform:R}=sP({id:i,data:k,attributes:{...xP,...s},disabled:_.draggable}),L=F5(T,ee),M=!!O,K=M&&!g&&Xs(m)&&Xs(x),ie=!y&&z,$=ie&&K?R:null,ae=K?$??(c??v)({rects:b,activeNodeRect:E,activeIndex:m,overIndex:x,index:j}):null,ne=Xs(m)&&Xs(x)?o({id:i,items:h,activeIndex:m,overIndex:x}):j,me=O==null?void 0:O.id,q=l.useRef({activeId:me,items:h,newIndex:ne,containerId:p}),le=h!==q.current.items,Pe=n({active:O,containerId:p,isDragging:z,isSorting:M,id:i,index:j,items:h,newIndex:q.current.newIndex,previousItems:q.current.items,previousContainerId:q.current.containerId,transition:u,wasDragging:q.current.activeId!=null}),Ce=yP({disabled:!Pe,index:j,node:C,rect:w});return l.useEffect(()=>{M&&q.current.newIndex!==ne&&(q.current.newIndex=ne),p!==q.current.containerId&&(q.current.containerId=p),h!==q.current.items&&(q.current.items=h)},[M,ne,p,h]),l.useEffect(()=>{if(me===q.current.activeId)return;if(me!=null&&q.current.activeId==null){q.current.activeId=me;return}const J=setTimeout(()=>{q.current.activeId=me},50);return()=>clearTimeout(J)},[me]),{active:O,activeIndex:m,attributes:I,data:k,rect:w,index:j,newIndex:ne,items:h,isOver:P,isSorting:M,isDragging:z,listeners:B,node:C,overIndex:x,over:Y,setNodeRef:L,setActivatorNodeRef:te,setDroppableNodeRef:T,setDraggableNodeRef:ee,transform:Ce??ae,transition:F()};function F(){if(Ce||le&&q.current.newIndex===j)return bP;if(!(ie&&!ll(N)||!u)&&(M||Pe))return ks.Transition.toString({...u,property:Nx})}}function jP(t,n){var s,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(s=t==null?void 0:t.draggable)!=null?s:n.draggable,droppable:(r=t==null?void 0:t.droppable)!=null?r:n.droppable}}function Cr(t){if(!t)return!1;const n=t.data.current;return!!(n&&"sortable"in n&&typeof n.sortable=="object"&&"containerId"in n.sortable&&"items"in n.sortable&&"index"in n.sortable)}const wP=[Se.Down,Se.Right,Se.Up,Se.Left],_P=(t,n)=>{let{context:{active:s,collisionRect:r,droppableRects:a,droppableContainers:o,over:i,scrollableAncestors:c}}=n;if(wP.includes(t.code)){if(t.preventDefault(),!s||!r)return;const d=[];o.getEnabled().forEach(p=>{if(!p||p!=null&&p.disabled)return;const m=a.get(p.id);if(m)switch(t.code){case Se.Down:r.top<m.top&&d.push(p);break;case Se.Up:r.top>m.top&&d.push(p);break;case Se.Left:r.left>m.left&&d.push(p);break;case Se.Right:r.left<m.left&&d.push(p);break}});const u=tT({collisionRect:r,droppableRects:a,droppableContainers:d});let h=dx(u,"id");if(h===(i==null?void 0:i.id)&&u.length>1&&(h=u[1].id),h!=null){const p=o.get(s.id),m=o.get(h),f=m?a.get(m.id):null,g=m==null?void 0:m.node.current;if(g&&f&&p&&m){const x=oa(g).some((S,w)=>c[w]!==S),y=Cx(p,m),v=kP(p,m),_=x||!y?{x:0,y:0}:{x:v?r.width-f.width:0,y:v?r.height-f.height:0},j={x:f.left,y:f.top};return _.x&&_.y?j:_s(j,_)}}}};function Cx(t,n){return!Cr(t)||!Cr(n)?!1:t.data.current.sortable.containerId===n.data.current.sortable.containerId}function kP(t,n){return!Cr(t)||!Cr(n)||!Cx(t,n)?!1:t.data.current.sortable.index<n.data.current.sortable.index}function pl({title:t,filePath:n}){return e.jsxs("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:[e.jsx("div",{className:"text-xs text-[var(--text-dim)] break-words",children:t}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[e.jsx("span",{"data-testid":"plan-expanded-header-file-path",className:"text-xs font-mono text-[var(--text-dim)] break-all",children:n}),e.jsx(th,{value:n})]})]})}const N9=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedHeader:pl},Symbol.toStringTag,{value:"Module"}));function ml(){const[t,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i}=pn(),c=l.useRef(!1),d=l.useCallback(async()=>{c.current||r(!0),o(null);try{const u=await fetch("/api/plans");if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=await u.json();n(Array.isArray(h)?h.map(p=>({...p,dependsOn:Array.isArray(p.dependsOn)?p.dependsOn:[]})):[]),c.current=!0}catch(u){o(u instanceof Error?u.message:"Failed to load plans")}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d,i]),{plans:t,loading:s,error:a,refetch:d}}function SP(){const[t,n]=l.useState(!1),[s,r]=l.useState(null);return{deletePlan:l.useCallback(async o=>{n(!0),r(null);try{const i=await fetch(`/api/plans/${encodeURIComponent(o)}`,{method:"DELETE"});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.error??`HTTP ${i.status}`)}}catch(i){const c=i instanceof Error?i.message:"Failed to delete plan";throw r(c),i instanceof Error?i:new Error(c)}finally{n(!1)}},[]),deleting:t,error:s}}function NP(){const[t,n]=l.useState(!1),[s,r]=l.useState(null);return{updatePlan:l.useCallback(async(o,i)=>{n(!0),r(null);try{const c=await fetch(`/api/plans/${o}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(!c.ok){const d=await c.json().catch(()=>({}));throw new Error(d.error??`HTTP ${c.status}`)}}catch(c){const d=c instanceof Error?c.message:"Failed to save plan";throw r(d),c instanceof Error?c:new Error(d)}finally{n(!1)}},[]),saving:t,error:s}}function CP(t,n){return n.filter(s=>s.slug!==t&&(s.dependsOn??[]).includes(t)).map(s=>({slug:s.slug,title:s.title}))}function Tx({slug:t,onClose:n}){return e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:e.jsx($t,{chatName:`edit-plan-${t}`,slashCommand:`/codeyam-edit-plan ${t}`,height:360,onClose:n})})}const C9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedChat:Tx},Symbol.toStringTag,{value:"Module"}));function Px({titleDraft:t,bodyDraft:n,saving:s,error:r,onTitleChange:a,onBodyChange:o,onSave:i,onCancel:c}){const d=Math.min(20,Math.max(8,n.split(`
|
|
117
|
+
`).length));return e.jsxs("div",{className:"border-t border-[var(--border-subtle)] px-3 py-2 flex flex-col gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:u=>a(u.target.value),"aria-label":"Plan title",className:"w-full px-2 py-1 text-sm rounded border border-[var(--border-subtle)] bg-[var(--bg-input,transparent)] text-[var(--text-primary)]"}),e.jsx("textarea",{value:n,onChange:u=>o(u.target.value),"aria-label":"Plan body",rows:d,className:"w-full px-2 py-1 text-xs rounded border border-[var(--border-subtle)] bg-[var(--bg-input,transparent)] text-[var(--text-primary)] font-mono resize-y"}),r&&e.jsx(ft,{text:r,className:"text-xs text-[var(--accent-red)]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:c,disabled:s,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer disabled:opacity-60",children:"Cancel"}),e.jsx("button",{type:"button",onClick:i,disabled:s,className:"px-2.5 py-1 text-xs rounded border border-[var(--accent-active)] bg-[var(--accent-active)] text-black hover:bg-[var(--accent-active)]/90 cursor-pointer disabled:opacity-60",children:s?"Saving…":"Save"})]})]})}const T9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedEdit:Px},Symbol.toStringTag,{value:"Module"}));function Ox({onClick:t}){return e.jsx("button",{type:"button",onClick:t,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"Edit"})}const P9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditButton:Ox},Symbol.toStringTag,{value:"Module"}));function Ax({providerLabel:t,onClick:n}){return e.jsxs("button",{type:"button",onClick:n,className:"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",title:`Open a chat with ${t} seeded with this plan's contents`,children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.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 O9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditChatButton:Ax},Symbol.toStringTag,{value:"Module"}));function Rx({dep:t}){const n=!t.satisfied&&t.title===null,s=t.satisfied?"completed":n?"missing":"blocked",r=t.satisfied?{borderColor:"var(--border-subtle)",color:"var(--text-dim)"}:{borderColor:"var(--accent-warn, #c08a2c)",color:"var(--accent-warn, #c08a2c)"};return e.jsxs("li",{"data-testid":`plan-row-dep-${t.slug}`,className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border whitespace-nowrap",style:r,children:s}),e.jsx("span",{className:t.satisfied?"text-[var(--text-dim)] truncate":"text-[var(--text-primary)] truncate",children:n?`missing: ${t.slug}`:t.title??t.slug})]})}const A9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDependencyEntry:Rx},Symbol.toStringTag,{value:"Module"}));function fl({dependencies:t}){return e.jsxs("div",{"data-testid":"plan-row-deps",className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mb-1.5",children:"Depends on"}),e.jsx("ul",{className:"flex flex-col gap-1",children:t.map(n=>e.jsx(Rx,{dep:n},n.slug))})]})}const R9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedDependencies:fl},Symbol.toStringTag,{value:"Module"}));function Ex({title:t,filePath:n,body:s,providerLabel:r,onEdit:a,onChat:o,onDelete:i,dependencies:c}){return e.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[c&&c.length>0&&e.jsx(fl,{dependencies:c}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx(Bt,{variant:"compact",children:s})}),e.jsx(pl,{title:t,filePath:n}),e.jsxs("div",{className:"flex gap-2 justify-between px-3 py-2 border-t border-[var(--border-subtle)]",children:[e.jsx(Vu,{onClick:i}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ox,{onClick:a}),e.jsx(Ax,{providerLabel:r,onClick:o})]})]})]})}const E9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedView:Ex},Symbol.toStringTag,{value:"Module"}));function Mx({plan:t,dependencies:n}){const[s,r]=l.useState("view"),[a,o]=l.useState(!1),[i,c]=l.useState(t.title),[d,u]=l.useState(t.body),{updatePlan:h,saving:p,error:m}=NP(),{deletePlan:f,deleting:g,error:b}=SP(),{plans:x}=ml(),{config:y}=jt(),v=Ue(y==null?void 0:y.provider);return l.useEffect(()=>{c(t.title),u(t.body),r("view"),o(!1)},[t.slug]),s==="chat"?e.jsx(Tx,{slug:t.slug,onClose:()=>r("view")}):s==="edit"?e.jsx(Px,{titleDraft:i,bodyDraft:d,saving:p,error:m,onTitleChange:c,onBodyChange:u,onSave:async()=>{try{await h(t.slug,{title:i,body:d}),r("view")}catch{}},onCancel:()=>{c(t.title),u(t.body),r("view")}}):e.jsxs(e.Fragment,{children:[e.jsx(Ex,{title:t.title,filePath:t.filePath,body:t.body,providerLabel:v,onEdit:()=>r("edit"),onChat:()=>r("chat"),onDelete:()=>o(!0),dependencies:n}),a&&e.jsx(Uu,{title:t.title,slug:t.slug,filePath:t.filePath,dependents:CP(t.slug,x),busy:g,error:b,onCancel:()=>o(!1),onConfirm:async()=>{try{await f(t.slug)}catch{}}})]})}const M9=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedBody:Mx},Symbol.toStringTag,{value:"Module"}));function gl({plan:t,expanded:n,onToggle:s,onRun:r,launching:a=!1,blocked:o=!1,position:i,dragHandleRef:c,dragHandleAttributes:d,dragHandleListeners:u,sortableRef:h,sortableStyle:p,isDragging:m=!1,unsatisfiedDepCount:f=0,unsatisfiedDepTooltip:g,dependencies:b,claim:x,staleFetch:y=!1,expandedBodyVariant:v="full",author:_}){const j=k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),s())};return e.jsxs("li",{ref:h,style:p,className:`border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)] transition-colors hover:border-[var(--text-dim)] hover:bg-[var(--bg-card)] ${m?"opacity-60 shadow-lg":""}`,children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:j,className:"w-full text-left px-3 py-2 flex items-center justify-between gap-3 bg-transparent cursor-pointer",children:[e.jsx(ah,{slug:t.slug,title:t.title,timestamp:t.createdAt,position:i,author:_,dragHandleRef:c,dragHandleAttributes:d,dragHandleListeners:u}),e.jsx(uh,{slug:t.slug,mode:t.mode,expanded:n,onRun:r,launching:a,blocked:o,unsatisfiedDepCount:f,unsatisfiedDepTooltip:g,claim:x,staleFetch:y})]}),n&&(v==="view"?e.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[b&&b.length>0&&e.jsx(fl,{dependencies:b}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx(Bt,{variant:"compact",children:t.body})}),e.jsx(pl,{title:t.title,filePath:t.filePath})]}):e.jsx(Mx,{plan:t,dependencies:b}))]})}const I9=Object.freeze(Object.defineProperty({__proto__:null,PlanRow:gl},Symbol.toStringTag,{value:"Module"}));function Ix({plan:t,position:n,expanded:s,onToggle:r,onRun:a,launching:o,blocked:i,draggable:c,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:h,claim:p,staleFetch:m,author:f}){const{attributes:g,listeners:b,setNodeRef:x,setActivatorNodeRef:y,transform:v,transition:_,isDragging:j}=vP({id:t.slug,disabled:!c}),k={transform:ks.Transform.toString(v),transition:_};return e.jsx(gl,{plan:t,expanded:s,onToggle:r,onRun:a,launching:o,blocked:i,position:n,sortableRef:x,sortableStyle:k,isDragging:j,dragHandleRef:c?y:void 0,dragHandleAttributes:c?g:void 0,dragHandleListeners:c?b:void 0,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:h,claim:p,staleFetch:m,author:f})}const L9=Object.freeze(Object.defineProperty({__proto__:null,SortablePlanRow:Ix},Symbol.toStringTag,{value:"Module"}));function TP(t,n){const[s,r]=l.useState(null),[a,o]=l.useState(null);return l.useEffect(()=>{r(null)},[t]),{items:s??t,error:a,reorder:n?i=>{r(i),o(null),n(i).catch(c=>{r(null),o(c instanceof Error?c.message:"Unknown error")})}:null}}function ca({plans:t,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i=!1,onReorder:c,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:h,staleFetch:p,showAuthors:m=!1,skeletonCount:f=3}){const[g,b]=l.useState(null),{items:x,error:y,reorder:v}=TP(t,c?w=>c(w.map(C=>C.slug)):void 0),j=n&&x.length===0?f:x.length,[k,S]=l.useState(!0);return e.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5",children:[e.jsx(Ts,{title:"Queued Plans",count:j,expanded:k,onToggle:()=>S(w=>!w),testId:"queued-plans-header"}),o&&e.jsxs(Qa,{tone:"error",spacing:"tight",children:["Failed to launch plan: ",o]}),y&&e.jsxs(Qa,{tone:"error",spacing:"tight",children:["Failed to reorder plans: ",y]}),k&&e.jsx(bl,{plans:x,loading:n,error:s,expandedSlug:g,onToggle:w=>b(C=>C===w?null:w),onRun:r,launchingSlug:a??null,blocked:i,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:h,staleFetch:p,onReorder:v??void 0,showAuthors:m,skeletonCount:f})]})}function bl({plans:t,loading:n,error:s,expandedSlug:r,onToggle:a,onRun:o,launchingSlug:i,blocked:c,onReorder:d,depAnnotationsBySlug:u,dependenciesBySlug:h,claimsBySlug:p,staleFetch:m,showAuthors:f=!1,skeletonCount:g=3}){const b=Q5(Yc(hl,{activationConstraint:{distance:4}}),Yc(dl,{coordinateGetter:_P})),x=l.useMemo(()=>t.map(j=>j.slug),[t]),y=s?e.jsx(ft,{text:`Failed to load plans: ${s}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):null;if(n&&t.length===0)return e.jsx(pi,{count:g});if(t.length===0)return y;const v=j=>{const{active:k,over:S}=j;if(!S||k.id===S.id||!d)return;const w=t.findIndex(P=>P.slug===k.id),C=t.findIndex(P=>P.slug===S.id);w===-1||C===-1||d(Ns(t,w,C))},_=e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"plan-list",children:t.map((j,k)=>{const S=u==null?void 0:u[j.slug],w=p==null?void 0:p.get(j.slug);return e.jsx(Ix,{plan:j,position:k+1,expanded:r===j.slug,onToggle:()=>a(j.slug),onRun:o,launching:i===j.slug,blocked:c,draggable:!!d,unsatisfiedDepCount:S==null?void 0:S.count,unsatisfiedDepTooltip:S==null?void 0:S.tooltip,dependencies:h==null?void 0:h[j.slug],claim:w,staleFetch:m,author:f?j.author:void 0},j.slug)})});return d?e.jsxs(e.Fragment,{children:[y,e.jsx(eP,{sensors:b,collisionDetection:eT,onDragEnd:v,children:e.jsx(pP,{items:x,strategy:uP,children:_})})]}):e.jsxs(e.Fragment,{children:[y,_]})}const D9=Object.freeze(Object.defineProperty({__proto__:null,QueuedChangesBody:bl,QueuedChangesSection:ca},Symbol.toStringTag,{value:"Module"}));function Lx({awaitingPlanLaunchChoice:t,configLoading:n,sessionLoading:s,sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i,provider:c,onContinueSession:d,onAgentIdle:u,onAgentBlocked:h,onAgentActive:p,onUserInput:m,pendingPlans:f,pendingPlansLoading:g,pendingPlansError:b,onLaunchPlan:x,launchingSlug:y,launchError:v,onReorderPlans:_,isAgentBuilding:j,featureCompleteActive:k=!1,buildActivity:S="menu",chatEscalatedToPrototype:w=!1,onActivityDone:C,onPrototypeLaunched:P,prototypeLaunchSignal:T=0}){const{recoveryFeatureName:O,recoveryStep:N,recoveryMode:E,showTerminal:I,shouldResumeSameProvider:ee}=h5({sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i}),B=r==="completed"&&!(a!=null&&a.cycleClosed);return r==="pending"||B?e.jsx(Nb,{featureName:O,editorStep:N,workflowMode:E,currentProvider:c,previousProvider:(a==null?void 0:a.provider)??null,resumeMode:(a==null?void 0:a.resumeMode)??"fresh",awaitingUserInput:(a==null?void 0:a.awaitingUserInput)??!1,onContinue:d}):S==="prototype"?e.jsx(Dt,{testId:"build-activity-prototype",children:e.jsx(rx,{isAgentBuilding:j&&!k,initiallyOpen:!0,onDone:C,onLaunched:P,launchSignal:T})}):S==="chat"?e.jsx(Dt,{testId:"build-activity-chat",children:e.jsx(Xb,{escalatedToPrototype:w,onDone:C})}):t&&f.length>0&&a===null&&i===null?e.jsx(Dt,{children:e.jsx(ca,{plans:f,loading:g,error:b,onRun:z=>{var te;const Y=((te=f.find(R=>R.slug===z))==null?void 0:te.title)??z;x(z,Y)},launchingSlug:y,launchError:v,blocked:j,onReorder:_})}):I?e.jsx($b,{provider:c,shouldResumeSameProvider:ee,sessionId:(a==null?void 0:a.sessionId)??null,onAgentIdle:u,onAgentBlocked:h,onAgentActive:p,onUserInput:m,currentFeature:(i==null?void 0:i.feature)??null}):v?e.jsx(nu,{message:v}):r==="no-session"&&i===null?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-slate-500 space-y-4 px-10 text-center",children:[e.jsx("div",{className:"text-lg font-medium text-slate-400",children:"Ready to build"}),e.jsx("p",{className:"max-w-md",children:"Your first session will start automatically. You can queue changes or wait for the project to initialize."})]}):null}const F9=Object.freeze(Object.defineProperty({__proto__:null,BuildTabSessionContent:Lx},Symbol.toStringTag,{value:"Module"}));function PP(t){return t?{step:t.step??0,feature:t.feature??null,startedAt:t.startedAt??"",mode:_t(t.mode),slug:t.slug??null,slugVisits:t.slugVisits??{}}:null}const OP=3e3;function Is(){const[t,n]=l.useState(null),[s,r]=l.useState(!0),a=l.useRef(null),o=l.useRef(null),i=l.useCallback(()=>{fetch("/api/step").then(c=>c.json()).then(c=>{const d=PP(c),u=JSON.stringify(d);u!==o.current&&(o.current=u,n(d)),r(!1)}).catch(()=>{r(!1)})},[]);return l.useEffect(()=>(i(),a.current=setInterval(i,OP),()=>{a.current&&clearInterval(a.current)}),[i]),{stepState:t,loading:s,refetch:i}}const dt={hasSession:!1,resumeMode:"fresh",provider:null,feature:null,step:null,mode:null,label:null,sessionId:null,awaitingUserInput:!1,reopenResults:!1,preview:null,agentBrokerLive:!1,resultsShown:!1,cycleClosed:null};function AP(t){return{hasSession:(t==null?void 0:t.hasSession)??dt.hasSession,resumeMode:(t==null?void 0:t.resumeMode)??dt.resumeMode,provider:(t==null?void 0:t.provider)??dt.provider,feature:(t==null?void 0:t.feature)??dt.feature,step:(t==null?void 0:t.step)??dt.step,mode:(t==null?void 0:t.mode)==null?dt.mode:_t(t.mode),label:(t==null?void 0:t.label)??dt.label,sessionId:(t==null?void 0:t.sessionId)??dt.sessionId,awaitingUserInput:(t==null?void 0:t.awaitingUserInput)??dt.awaitingUserInput,reopenResults:(t==null?void 0:t.reopenResults)??dt.reopenResults,preview:(t==null?void 0:t.preview)??dt.preview,agentBrokerLive:(t==null?void 0:t.agentBrokerLive)??dt.agentBrokerLive,resultsShown:(t==null?void 0:t.resultsShown)??dt.resultsShown,cycleClosed:(t==null?void 0:t.cycleClosed)??dt.cycleClosed}}function xl(t){const n=t==null?void 0:t.pollIntervalMs,[s,r]=l.useState(null),[a,o]=l.useState(!0),i=l.useCallback(async()=>{o(!0);try{const d=await(await fetch("/api/session-info")).json();r(AP(d))}catch{r(c=>c??dt)}finally{o(!1)}},[]);return l.useEffect(()=>{i()},[i]),l.useEffect(()=>{if(n==null||n<=0)return;const c=setInterval(()=>{i()},n);return()=>clearInterval(c)},[n,i]),{sessionInfo:s,loading:a,refetch:i}}const RP=5e3;function EP(){const[t,n]=l.useState(null),[s,r]=l.useState(!0),a=l.useRef(null);return l.useEffect(()=>{const o=()=>{fetch("/api/prompt").then(i=>i.json()).then(i=>{n(i.prompt??null),r(!1)}).catch(()=>r(!1))};return o(),a.current=setInterval(o,RP),()=>{a.current&&clearInterval(a.current)}},[]),{prompt:t,loading:s}}function MP({currentDecision:t,sessionInfo:n,sessionLoading:s,attachedSessionId:r=null}){return s||!n?t:t==="continue"&&n.hasSession?"continue":t==="fresh"&&n.hasSession&&(n.resumeMode==="resume"||n.resumeMode==="completed")?"fresh":n.resumeMode==="completed"?"completed":n.resumeMode==="resume"&&n.hasSession&&r!=null&&n.sessionId===r?"continue":n.resumeMode==="resume"||n.resumeMode==="handoff"?"pending":"fresh"}let fr=null;const IP=1e4,ko=new Set;function Dx(){fr=Date.now();for(const t of[...ko])t()}function LP(t){return ko.add(t),()=>{ko.delete(t)}}function id(){if(fr==null)return!1;const t=Date.now()-fr;return fr=null,t<=IP}const yl="codeyam.buildTab.attachedSessionId";function DP(t){try{window.sessionStorage.setItem(yl,t)}catch{}}function FP(){try{return window.sessionStorage.getItem(yl)}catch{return null}}function zP(){try{window.sessionStorage.removeItem(yl)}catch{}}function $P({sessionLoading:t,sessionInfo:n}){const s=l.useRef(void 0);s.current===void 0&&(s.current=FP());const[r,a]=l.useState(()=>id()?"fresh":"no-session");l.useEffect(()=>LP(()=>{id(),a("fresh")}),[]),l.useEffect(()=>{a(i=>MP({currentDecision:i,sessionInfo:n,sessionLoading:t,attachedSessionId:s.current??null}))},[t,n]),l.useEffect(()=>{if(n){if(!n.hasSession){zP(),s.current=null;return}n.sessionId&&(r==="continue"||r==="fresh")&&(DP(n.sessionId),s.current=n.sessionId)}},[r,n]);const o=l.useCallback(()=>{a("continue")},[]);return{sessionDecision:r,handleContinueSession:o}}function ld(){const t=document.activeElement;return t===null||t===document.body||t===document.documentElement||t instanceof HTMLElement&&t.dataset.navTab==="true"}function cd(t,n,s,r=0){return t>=s.left-r&&t<=s.right+r&&n>=s.top-r&&n<=s.bottom+r}function dd(t){ud(t,!0);let n=!1;const s=()=>{n||(n=!0,ud(t,!1))};typeof requestAnimationFrame=="function"?(requestAnimationFrame(s),setTimeout(s,100)):queueMicrotask(s)}function ud(t,n){const s=t;if(typeof s.inert=="boolean"){s.inert=n;return}n?t.setAttribute("inert",""):t.removeAttribute("inert")}function za(t){ei(),dd(t),t.blur(),yt(),queueMicrotask(()=>{document.activeElement===t&&(dd(t),t.blur(),yt())})}function BP(t){const n=l.useRef(!1),s=l.useRef(null);l.useEffect(()=>{if(!t)return;function r(){if(!n.current&&ld()){n.current=!0;try{ei(),window.dispatchEvent(new Event("terminal-focus"))}finally{n.current=!1}}}function a(){queueMicrotask(r)}function o(){const u=document.activeElement;u instanceof HTMLIFrameElement&&(s.current=u)}function i(u){const h=document.activeElement;if(h instanceof HTMLIFrameElement){if(u.target===h)return;za(h),d(h);return}const p=s.current;if(!p||u.target===p)return;const m=u;if(typeof m.clientX=="number"&&typeof m.clientY=="number"){const f=p.getBoundingClientRect();if(cd(m.clientX,m.clientY,f,1))return}za(p),d(p)}function c(u){const h=document.activeElement;if(!(h instanceof HTMLIFrameElement))return;s.current=h;const p=h.getBoundingClientRect();cd(u.clientX,u.clientY,p,1)||(za(h),d(h))}function d(u){requestAnimationFrame(()=>{document.activeElement!==u&&(ld()||(s.current=null))})}return document.addEventListener("focusin",o),document.addEventListener("focusout",a),window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),document.addEventListener("mouseup",a),document.addEventListener("pointerdown",i,!0),document.addEventListener("mousedown",i,!0),document.addEventListener("click",i,!0),document.addEventListener("pointermove",c,{capture:!0,passive:!0}),()=>{document.removeEventListener("focusin",o),document.removeEventListener("focusout",a),window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a),document.removeEventListener("mouseup",a),document.removeEventListener("pointerdown",i,!0),document.removeEventListener("mousedown",i,!0),document.removeEventListener("click",i,!0),document.removeEventListener("pointermove",c,{capture:!0})}},[t])}function HP({sessionLoading:t,sessionInfo:n,onRestorePreview:s}){const r=l.useRef(!1);l.useEffect(()=>{t||!(n!=null&&n.preview)||n.resumeMode!=="resume"&&n.resumeMode!=="handoff"||r.current||(r.current=!0,s==null||s(n.preview))},[s,n,t])}function qP(t){const n=l.useRef(t),s=l.useRef(null);l.useEffect(()=>{t&&t!==n.current&&(n.current=t,s.current??(s.current=new AbortController),xs(t,void 0,void 0,"session-feature-rename",s.current.signal))},[t]),l.useEffect(()=>()=>{var r;(r=s.current)==null||r.abort()},[])}function WP(t,n){if(!t||!n)return null;const s=n[t]??0;return s<=1?null:s===2?"2nd pass":s===3?"3rd pass":`${s}th pass`}function GP(t,n,s){l.useEffect(()=>{if(!n)return;const r=a=>{t.current&&!t.current.contains(a.target)&&s()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,n,s])}function Fx({displayName:t,hasPrompt:n,expanded:s,onToggle:r}){return n?e.jsxs("button",{onClick:r,className:"flex items-center gap-1 cursor-pointer transition-colors min-w-0",style:{color:"var(--text-secondary)"},children:[e.jsx("span",{className:"font-medium truncate",children:t}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`shrink-0 transition-transform ${s?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}):e.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-secondary)"},children:t})}const z9=Object.freeze(Object.defineProperty({__proto__:null,FeatureNameButton:Fx},Symbol.toStringTag,{value:"Module"}));function zx({prompt:t}){return e.jsx("div",{style:{background:"var(--bg-input)",borderBottom:"1px solid var(--border-default)",maxHeight:"16rem",overflowY:"auto",padding:"0 0.75rem 0.75rem"},children:e.jsx(Bt,{variant:"compact",children:t})})}const $9=Object.freeze(Object.defineProperty({__proto__:null,PromptDropdownPanel:zx},Symbol.toStringTag,{value:"Module"}));function $x({label:t}){return t?e.jsx("span",{className:"rounded px-1.5 py-0.5",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",color:"var(--text-dim)"},children:t}):null}const B9=Object.freeze(Object.defineProperty({__proto__:null,RepeatPassMarker:$x},Symbol.toStringTag,{value:"Module"}));function Bx({currentStep:t,isExpanded:n,mode:s,onToggle:r=()=>{},stepNum:a}){const o=a===t,i=a<t,{primary:c,secondary:d,phaseLabel:u,description:h}=YC(a,s);return e.jsxs("div",{onClick:r,className:"cursor-pointer",children:[e.jsxs("div",{className:"w-full px-3 py-0.5 flex items-center gap-2 text-left transition-colors",style:{color:o?"var(--accent-active)":i?"var(--text-secondary)":"var(--text-muted)",fontWeight:o?500:void 0},onMouseEnter:p=>p.currentTarget.style.background="var(--bg-input)",onMouseLeave:p=>p.currentTarget.style.background="transparent",children:[e.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[a,"."]}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:c}),d&&e.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-dim)",opacity:.7},children:d}),h&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`shrink-0 opacity-40 transition-transform ${n?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),n&&h&&e.jsxs("div",{className:"px-3 pb-1.5 pl-10",children:[u&&e.jsx("p",{className:"text-[9px] m-0 mb-0.5 uppercase tracking-wide",style:{color:"var(--text-dim)",opacity:.7},children:u}),e.jsx("p",{className:"text-[10px] m-0 leading-relaxed",style:{color:"var(--text-dim)"},children:h})]})]},a)}const H9=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorDropdownItem:Bx},Symbol.toStringTag,{value:"Module"}));function Hx({step:t,feature:n,mode:s,projectTitle:r,userPrompt:a,slug:o=null,slugVisits:i}){const[c,d]=l.useState(!1),[u,h]=l.useState(null),[p,m]=l.useState(!1),[f,g]=l.useState(null),b=l.useRef(null),x=l.useRef(null),y=l.useRef(null),v=l.useRef(null);l.useLayoutEffect(()=>{if(!c)return;const E=()=>{var ee;const I=(ee=x.current)==null?void 0:ee.getBoundingClientRect();I&&g({top:I.bottom+4,right:window.innerWidth-I.right})};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[c]),l.useEffect(()=>{if(!c)return;const E=I=>{var B,z;const ee=I.target;(B=b.current)!=null&&B.contains(ee)||(z=y.current)!=null&&z.contains(ee)||d(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[c]),GP(v,p,l.useCallback(()=>m(!1),[]));const _=n&&t>0,j=n||"New Working Session",k=_t(s),S=WC(t,k),w=S.totalSteps,C=S.prefix,P=Vg(t,k),T=_?P.primary:null,O=_?P.secondary:null,N=WP(o,i);return t===0?e.jsxs("div",{className:"h-8 flex items-center justify-between px-3 text-xs shrink-0 select-none",style:{background:"var(--bg-input)",borderBottom:"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"truncate",style:{color:"var(--text-dim)"},children:r||"New Project"}),e.jsx("span",{style:{color:"var(--text-dim)",opacity:.5},children:">"}),e.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-muted)"},children:j})]}),e.jsx("span",{style:{color:"var(--text-dim)"},children:n?"Starting…":"Waiting for session"})]}):e.jsxs("div",{className:"shrink-0",ref:v,children:[e.jsxs("div",{className:"h-8 flex items-center justify-between px-3 text-xs select-none",style:{background:"var(--bg-input)",borderBottom:p?"none":"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"truncate",style:{color:"var(--text-dim)"},children:r||"New Project"}),e.jsx("span",{style:{color:"var(--text-dim)",opacity:.5},children:">"}),e.jsx(Fx,{displayName:j,hasPrompt:!!a,expanded:p,onToggle:()=>m(E=>!E)})]}),_&&e.jsxs("div",{className:"relative",ref:b,children:[e.jsxs("button",{ref:x,onClick:()=>d(E=>!E),className:"flex items-center gap-1.5 cursor-pointer transition-colors",style:{color:"var(--text-secondary)"},children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:"::"}),e.jsxs("span",{children:[C," ",t,e.jsxs("span",{style:{color:"var(--text-dim)"},children:[" / ",w]}),": ",T,O&&e.jsxs("span",{style:{color:"var(--text-dim)",opacity:.7},children:[" ","(",O,")"]})]}),e.jsx($x,{label:N}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`transition-transform ${c?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),c&&f&&Nn.createPortal(e.jsx("div",{ref:y,className:"w-96 rounded-lg shadow-lg py-1 text-xs max-h-[70vh] overflow-y-auto",style:{position:"fixed",top:f.top,right:f.right,zIndex:60,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:Array.from({length:w},(E,I)=>I+1).map(E=>{const I=u===E;return e.jsx(Bx,{currentStep:t,isExpanded:I,mode:k,onToggle:()=>h(I?null:E),stepNum:E},E)})}),document.body)]})]}),p&&a&&e.jsx(zx,{prompt:a})]})}const q9=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorBar:Hx},Symbol.toStringTag,{value:"Module"}));function qx({awaitingPlanLaunchChoice:t,buildLaunchGateArmed:n,isActive:s,onAgentIdle:r,onAgentBlocked:a,onAgentActive:o,onUserInput:i,provider:c,onRestorePreview:d,pendingPlans:u,pendingPlansLoading:h,pendingPlansError:p,onLaunchPlan:m,launchingSlug:f,launchError:g,onReorderPlans:b,isAgentBuilding:x,featureCompleteActive:y,buildActivity:v,chatEscalatedToPrototype:_,onActivityDone:j,onPrototypeLaunched:k,prototypeLaunchSignal:S}){const{stepState:w}=Is(),{config:C,loading:P}=jt(),{prompt:T}=EP(),{sessionInfo:O,loading:N}=xl(),{sessionDecision:E,handleContinueSession:I}=$P({sessionLoading:N,sessionInfo:O});return BP(s),HP({sessionLoading:N,sessionInfo:O,onRestorePreview:d}),qP((w==null?void 0:w.feature)??null),e.jsx(yb,{stepIndicator:e.jsx(Hx,{step:(w==null?void 0:w.step)??0,feature:(w==null?void 0:w.feature)??null,mode:(w==null?void 0:w.mode)??"ui",projectTitle:(C==null?void 0:C.projectTitle)??null,userPrompt:T,slug:(w==null?void 0:w.slug)??null,slugVisits:w==null?void 0:w.slugVisits}),sessionContent:e.jsx(Lx,{awaitingPlanLaunchChoice:t,buildLaunchGateArmed:n,configLoading:P,sessionLoading:N,sessionDecision:E,sessionInfo:O,stepState:w,provider:c,onContinueSession:I,onAgentIdle:r,onAgentBlocked:a,onAgentActive:o,onUserInput:i,pendingPlans:u,pendingPlansLoading:h,pendingPlansError:p,onLaunchPlan:m,launchingSlug:f,launchError:g,onReorderPlans:b,isAgentBuilding:x,featureCompleteActive:y,buildActivity:v,chatEscalatedToPrototype:_,onActivityDone:j,onPrototypeLaunched:k,prototypeLaunchSignal:S})})}const W9=Object.freeze(Object.defineProperty({__proto__:null,BuildTab:qx},Symbol.toStringTag,{value:"Module"}));function Wx({refreshing:t,onRefresh:n,onClose:s,minimizeMode:r=!1}){return e.jsxs("div",{className:"shrink-0 px-4 py-2 bg-[var(--bg-card)] border-b border-[var(--border-default)] flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Working Session Results"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:n,disabled:t,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-xs leading-none px-2 py-1 border border-[var(--border-default)] rounded disabled:opacity-50",title:"Refresh session data",children:t?"…":"↻"}),e.jsx("button",{onClick:s,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-lg leading-none px-1",title:r?"Minimize results panel":"Close results panel",children:r?"▾":"✕"})]})]})}const G9=Object.freeze(Object.defineProperty({__proto__:null,SessionResultsPanelHeader:Wx},Symbol.toStringTag,{value:"Module"}));function hs(t,n){if(t.length===0)return{selectedIndex:-1,scenario:null};if("direction"in n){const r=n.direction==="next"?1:-1,a=(n.selectedIndex+r+t.length)%t.length;return{selectedIndex:a,scenario:t[a]}}if("slug"in n){const r=t.findIndex(a=>a.slug===n.slug);return r>=0?{selectedIndex:r,scenario:t[r]}:hs(t,{defaultSelection:!0,selectedIndex:n.selectedIndex})}const s=Math.min(n.selectedIndex??0,t.length-1);return{selectedIndex:s,scenario:t[s]}}function Tr(t,n){if(!n)return{headline:t,collapsed:[]};const s=[],r=[];for(const a of t)a.demonstratesNew?s.push(a):r.push(a);return{headline:s,collapsed:r}}function vl(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&typeof t.name=="string"?t.name:String(t)}function UP(t){if(t!=null&&typeof t=="object"){const{description:n}=t;if(typeof n=="string"&&n.trim()!=="")return n}}function jl({fn:t,testid:n}){return e.jsxs("div",{className:"flex items-start gap-2","data-testid":n,children:[e.jsx("span",{className:"text-[10px] text-[var(--text-muted)] mt-0.5 shrink-0",children:"fn"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium text-[var(--text-primary)]",children:t.name}),t.description&&e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:t.description}),e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] font-mono mt-0.5",children:t.filePath})]})]})}const U9=Object.freeze(Object.defineProperty({__proto__:null,FunctionChangeRow:jl},Symbol.toStringTag,{value:"Module"})),VP="no-isolation-harness";function Gx(t){var n;return t.coverageStatus==="reason"&&((n=t.untestabilityReason)==null?void 0:n.kind)===VP}const YP="/api/editor-session-summary",KP=3e3;function Ux(t=KP){const[n,s]=l.useState(null),[r,a]=l.useState(!0),[o,i]=l.useState(!1),c=l.useCallback(async()=>{i(!0);try{const d=await fetch(YP);d.ok&&s(await d.json())}catch{}i(!1),a(!1)},[]);return l.useEffect(()=>{c()},[c]),l.useEffect(()=>{if(t<=0)return;const d=window.setInterval(c,t);return()=>window.clearInterval(d)},[c,t]),{summary:n,loading:r,refreshing:o,refresh:c}}function Vx({onClose:t,onSelectScenario:n,previewSlug:s=null,minimizeMode:r=!1}){var j;const{summary:a,loading:o,refreshing:i,refresh:c}=Ux(),[d,u]=l.useState(0),h=l.useMemo(()=>a?[...a.application,...a.components]:[],[a]),p=l.useMemo(()=>s&&h.some(k=>k.slug===s)?s:null,[h,s]),m=p??((j=h[d])==null?void 0:j.slug);l.useEffect(()=>{if(!p)return;const k=h.findIndex(S=>S.slug===p);k>=0&&k!==d&&u(k)},[h,p,d]);const f=l.useCallback(k=>{h.length!==0&&(document.activeElement instanceof HTMLIFrameElement||X1()||(k.key==="ArrowRight"?(k.preventDefault(),u(S=>{const w=hs(h,{direction:"next",selectedIndex:S});return w.scenario&&(n==null||n(w.scenario.slug,w.scenario.url)),w.selectedIndex})):k.key==="ArrowLeft"&&(k.preventDefault(),u(S=>{const w=hs(h,{direction:"previous",selectedIndex:S});return w.scenario&&(n==null||n(w.scenario.slug,w.scenario.url)),w.selectedIndex}))))},[h,n]);l.useEffect(()=>(window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)),[f]);const g=l.useRef(!1);if(l.useEffect(()=>{if(g.current||h.length===0)return;g.current=!0;const k=hs(h,{defaultSelection:!0,selectedIndex:d});k.scenario&&(n==null||n(k.scenario.slug,k.scenario.url))},[h,n,d]),o)return e.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:e.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:e.jsx("div",{className:"text-sm text-[var(--text-muted)]",children:"No session data available."})});const b=a.application.length+a.components.length,x=a.hubDominated??!1,y=Tr(a.application,x),v=Tr(a.components,x),_=(k,S)=>{var C,P;const w=hs(h,{slug:k,selectedIndex:d});w.selectedIndex>=0&&u(w.selectedIndex),n==null||n(((C=w.scenario)==null?void 0:C.slug)??k,((P=w.scenario)==null?void 0:P.url)??S)};return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-[var(--bg-deep)]",style:{borderTop:"2px solid #005c75"},children:[e.jsx(Wx,{refreshing:i,onRefresh:c,onClose:t,minimizeMode:r}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[a.userPrompt&&e.jsx(Yx,{text:a.userPrompt}),e.jsxs(ps,{title:"Application",icon:"🌐",count:y.headline.length,impactedCount:y.collapsed.length,empty:b===0?"No scenarios in this session":void 0,children:[y.headline.length>0&&e.jsx(Jx,{scenarios:y.headline,selectedSlug:m,onSelect:_}),e.jsx(So,{scenarios:y.collapsed,selectedSlug:m,onSelect:_})]}),e.jsxs(ps,{title:"Components",icon:"🧩",count:v.headline.length,impactedCount:v.collapsed.length,children:[v.headline.length>0&&e.jsx(Kx,{scenarios:v.headline,selectedSlug:m,onSelect:_}),e.jsx(So,{scenarios:v.collapsed,selectedSlug:m,onSelect:_})]}),e.jsx(ps,{title:"Functions",icon:"⚙️",count:a.functions.length,children:a.functions.length>0&&e.jsx(Qx,{functions:a.functions})}),e.jsx(ps,{title:"Modified Files",icon:"📄",count:a.modifiedFiles.length,children:a.modifiedFiles.length>0&&e.jsx(Zx,{files:a.modifiedFiles})})]})]})}function Yx({text:t}){const[n,s]=l.useState(!1),r=t.split(`
|
|
118
|
+
`)[0],a=t.includes(`
|
|
119
|
+
`)||t.length>120;return e.jsxs("div",{className:"px-1 pb-2",children:[e.jsx("div",{className:"text-[10px] font-semibold text-[var(--text-muted)] uppercase tracking-wide mb-1",children:"User Request"}),n?e.jsxs("div",{children:[e.jsx(Bt,{variant:"compact",children:t}),a&&e.jsx("button",{onClick:()=>s(!1),className:"text-[#D7FF63] hover:underline text-xs mt-1",children:"Show less"})]}):e.jsxs("div",{className:"text-xs text-[var(--text-secondary)] leading-relaxed",children:[r.slice(0,120),a&&e.jsx("button",{onClick:()=>s(!0),className:"text-[#D7FF63] hover:underline ml-1 text-xs",children:"Read more..."})]})]})}function ps({title:t,icon:n,count:s,impactedCount:r=0,empty:a,children:o}){const i=s+r;return e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-input)] flex items-center gap-2",children:[e.jsx("span",{className:"text-xs",children:n}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-primary)]",children:t}),e.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",s,r>0?` +${r} impacted`:"",")"]})]}),e.jsx("div",{className:"p-3",children:i===0?e.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:a||`No ${t.toLowerCase()} in this session`}):o})]})}function Cs({scenarios:t,selectedSlug:n,onSelect:s}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("div",{className:"flex gap-2",style:{minWidth:"min-content"},children:t.map(r=>e.jsx(Xx,{scenario:r,isSelected:r.slug===n,onSelect:s},r.slug))})})}function So({scenarios:t,selectedSlug:n,onSelect:s}){const[r,a]=l.useState(!1);return t.length===0?null:e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]",children:[e.jsxs("button",{onClick:()=>a(o=>!o),className:"text-[11px] text-[var(--text-muted)] hover:text-[var(--text-secondary)] flex items-center gap-1",children:[e.jsx("span",{children:r?"▾":"▸"}),e.jsxs("span",{children:[t.length," more impacted by hub-file changes (not recaptured this session)"]})]}),r&&e.jsx("div",{className:"mt-2",children:e.jsx(Cs,{scenarios:t,selectedSlug:n,onSelect:s})})]})}function Kx({scenarios:t,selectedSlug:n,onSelect:s}){const r={};for(const i of t){const c=i.componentName||"Unknown";r[c]||(r[c]=[]),r[c].push(i)}const a=Object.keys(r).sort(),o=t.some(Gx);return e.jsxs("div",{className:"space-y-3",children:[o&&e.jsx("div",{className:"text-[10px] leading-snug text-[var(--text-muted)] bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded px-2 py-1.5",children:"This stack has no component isolation harness, so leaf components are verified inside the full app scenarios rather than in isolation."}),a.map(i=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] mb-1",children:i}),e.jsx(Cs,{scenarios:r[i],selectedSlug:n,onSelect:s})]},i))]})}function Jx({scenarios:t,selectedSlug:n,onSelect:s}){if(!t.some(i=>i.routeName))return e.jsx(Cs,{scenarios:t,selectedSlug:n,onSelect:s});const a={};for(const i of t){const c=i.routeName||"Other";a[c]||(a[c]=[]),a[c].push(i)}const o=Object.keys(a).sort();return e.jsx("div",{className:"space-y-3",children:o.map(i=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] mb-1",children:i}),e.jsx(Cs,{scenarios:a[i],selectedSlug:n,onSelect:s})]},i))})}function Xx({scenario:t,isSelected:n,onSelect:s}){var o;const r=t.name.replace(/\s*\[.*\]\s*$/,"").trim(),a=Gx(t);return e.jsxs("div",{className:"shrink-0 cursor-pointer group",onClick:()=>s==null?void 0:s(t.slug,t.url),title:t.name,children:[e.jsx("div",{className:`w-24 h-24 rounded overflow-hidden flex items-center justify-center bg-[var(--bg-surface)] transition-colors ${n?"border-2 border-[#005c75] shadow-md":"border border-[var(--border-default)] group-hover:border-[#005c75]"}`,children:t.screenshotPaths.length>0?e.jsx(At,{screenshotPath:t.screenshotPaths[0],cacheBuster:t.screenshotCapturedAtMs??void 0,alt:t.name}):t.coverageStatus==="needs-isolated-scenario"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:"Backed only by a unit test — capture an isolated scenario so this component is viewable in the editor.",children:[e.jsx("span",{className:"text-amber-500 text-lg leading-none",children:"⚠"}),e.jsx("span",{className:"text-[8px] leading-tight text-amber-700",children:"needs isolated scenario"})]}):t.coverageStatus==="reason"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:t.untestabilityReason?`${t.untestabilityReason.kind}: ${t.untestabilityReason.justification}`:"Covered by a recorded untestability reason.",children:[e.jsx("span",{className:"text-[var(--text-muted)] text-lg leading-none",children:"🧪"}),e.jsx("span",{className:"text-[8px] leading-tight text-[var(--text-muted)]",children:((o=t.untestabilityReason)==null?void 0:o.kind)??"test-backed"})]}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-[var(--text-muted)] text-lg",children:"📷"})}),e.jsx("div",{className:`mt-1 text-[10px] truncate w-24 ${n?"text-[#005c75] font-medium":"text-[var(--text-secondary)] group-hover:text-[#005c75]"}`,children:r}),a&&e.jsx("div",{className:"mt-0.5 w-24 text-[9px] leading-tight text-[var(--text-muted)]",children:"Covered via app scenarios — no isolation harness"})]})}function Qx({functions:t}){return e.jsx("div",{className:"divide-y divide-gray-100 -mx-3 -mb-3",children:t.map(n=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx(jl,{fn:n}),n.tests.length>0&&e.jsx("div",{className:"ml-5 mt-1.5 space-y-0.5",children:n.tests.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-green-500 text-[10px]",children:"✓"}),e.jsx("span",{className:"text-[10px] text-[var(--text-secondary)]",children:vl(s)})]},r))}),n.testFile&&n.tests.length===0&&e.jsx("div",{className:"ml-5 mt-1 text-[10px] text-[var(--text-muted)] font-mono",children:n.testFile})]},`${n.filePath}::${n.name}`))})}function Zx({files:t}){return e.jsx("div",{className:"divide-y divide-gray-100 -mx-3 -mb-3",children:t.map(n=>e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[e.jsx(Gr,{status:n.status}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono truncate",children:n.path})]},n.path))})}const V9=Object.freeze(Object.defineProperty({__proto__:null,ApplicationGroups:Jx,CollapsedImpactedScenarios:So,ComponentGroups:Kx,FilesList:Zx,FunctionsList:Qx,ScenarioThumbnail:Xx,ScenarioThumbnailStrip:Cs,Section:ps,SessionResultsPanel:Vx,UserPrompt:Yx},Symbol.toStringTag,{value:"Module"}));function ey({onExpand:t}){const{summary:n}=Ux(),s=(n==null?void 0:n.hubDominated)??!1,r=Tr((n==null?void 0:n.application)??[],s),a=Tr((n==null?void 0:n.components)??[],s),o=r.headline.length+a.headline.length,i=r.collapsed.length+a.collapsed.length;return e.jsxs("button",{type:"button",onClick:t,title:"Expand working session results",className:"shrink-0 w-full flex items-center gap-2 px-4 py-1.5 text-left bg-[var(--bg-card)] hover:bg-[var(--bg-input)] transition-colors",style:{borderTop:"2px solid #005c75"},children:[e.jsx("span",{className:"text-[var(--text-muted)] text-xs leading-none",children:"▴"}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-primary)]",children:"Working Session Results"}),e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:[o," new",i>0?` · ${i} impacted`:""]})]})}const Y9=Object.freeze(Object.defineProperty({__proto__:null,MinimizedSessionResults:ey},Symbol.toStringTag,{value:"Module"}));function JP(t,n){return(t==null?void 0:t.mode)!=="ui"?!1:(t==null?void 0:t.slug)==="feature-complete"||!!n}const XP=new Set(["ui-present","backend-present"]);function ty(t){return!!(t!=null&&t.slug)&&XP.has(t.slug)}function QP({stepState:t,resultsShown:n,featureCompleteActive:s,userExpanded:r}){return s?"hidden":ty(t)?(t==null?void 0:t.mode)==="ui"?"full":"hidden":JP(t,n)?r?"full":"minimized":"hidden"}function ny({awaitingPlanLaunchChoice:t,buildLaunchGateArmed:n,buildActivated:s,activeTab:r,onSelectScenario:a,previewSlug:o=null,showResultsCommandKey:i,hideResultsCommandKey:c,onAgentIdle:d,onAgentBlocked:u,onAgentActive:h,onUserInput:p,notifSettings:m,onSettingsChange:f,provider:g,onRestorePreview:b,pendingPlans:x,pendingPlansLoading:y,pendingPlansError:v,onLaunchPlan:_,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:w,featureCompleteActive:C,buildActivity:P,chatEscalatedToPrototype:T,onActivityDone:O,onPrototypeLaunched:N,prototypeLaunchSignal:E}){const{stepState:I}=Is(),{sessionInfo:ee}=xl({pollIntervalMs:15e3}),[B,z]=l.useState(!1),[Y,te]=l.useState(!1),[R,L]=l.useState(0),M=(ee==null?void 0:ee.resultsShown)??!1;l.useEffect(()=>{M||(te(!1),z(!1))},[M]),l.useEffect(()=>{i&&(te(!1),z(!0),L(ne=>ne+1))},[i]),l.useEffect(()=>{c&&z(!1)},[c]);const K=ty(I),ie=QP({stepState:I,resultsShown:M,featureCompleteActive:C,userExpanded:B}),$=K&&Y?"hidden":ie,V=l.useCallback(()=>{K?te(!0):z(!1)},[K]),ae=l.useCallback(()=>{z(!0),L(ne=>ne+1)},[]);return s?e.jsx(vb,{activeTab:r,resultsMode:$,buildTab:e.jsx(qx,{awaitingPlanLaunchChoice:t,buildLaunchGateArmed:n,isActive:r==="build",onAgentIdle:d,onAgentBlocked:u,onAgentActive:h,onUserInput:p,provider:g,onRestorePreview:b,pendingPlans:x,pendingPlansLoading:y,pendingPlansError:v,onLaunchPlan:_,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:w,featureCompleteActive:C,buildActivity:P,chatEscalatedToPrototype:T,onActivityDone:O,onPrototypeLaunched:N,prototypeLaunchSignal:E}),resultsPanel:e.jsx(Vx,{onClose:V,onSelectScenario:a,previewSlug:o,minimizeMode:!K},R),minimizedResults:e.jsx(ey,{onExpand:ae}),footer:e.jsx(Pg,{settings:m,onChange:f,agentName:g,providerLabel:Ue(g)})}):null}const K9=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPane:ny},Symbol.toStringTag,{value:"Module"}));function sy({name:t}){const n={width:13,height:13,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},s=t.toLowerCase(),r=s.includes("landscape"),a=s.includes("iphone"),o=s.includes("ipad");return s.includes("laptop")?e.jsxs("svg",{...n,children:[e.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),e.jsx("path",{d:"M2 18h20"})]}):s.includes("desktop")||s.includes("monitor")?e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}):s.includes("tablet")||s.includes("ipad")?r?e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),o?e.jsx("path",{d:"M5 12h.01"}):e.jsx("path",{d:"M18 12h.01"})]}):e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),o?e.jsx("path",{d:"M12 5h.01"}):e.jsx("path",{d:"M12 18h.01"})]}):s.includes("phone")||s.includes("iphone")||s.includes("mobile")?r?e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"2",y:"7",width:"20",height:"10",rx:a?3:2}),a?e.jsx("path",{d:"M5 9.5v5"}):e.jsx("path",{d:"M18 12h.01"})]}):e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:a?3:2}),a?e.jsx("path",{d:"M10 4.5h4"}):e.jsx("path",{d:"M12 18h.01"})]}):e.jsx("span",{className:"text-xs",children:t})}const J9=Object.freeze(Object.defineProperty({__proto__:null,DeviceIcon:sy},Symbol.toStringTag,{value:"Module"})),hd=["·","✢","✳","✶","✻","✽"],ZP=160;function Pr({testId:t="nav-build-dot-active",ariaLabel:n="Build in progress"}={}){const[s,r]=l.useState(0);return l.useEffect(()=>{const a=window.setInterval(()=>r(o=>(o+1)%hd.length),ZP);return()=>window.clearInterval(a)},[]),e.jsx("span",{"data-testid":t,"aria-label":n,className:"mr-1 inline-block w-3 text-center text-[#D7FF63] leading-none text-[11px] tabular-nums",children:hd[s]})}const X9=Object.freeze(Object.defineProperty({__proto__:null,BuildSpinner:Pr},Symbol.toStringTag,{value:"Module"}));function ry({size:t=16}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}const Q9=Object.freeze(Object.defineProperty({__proto__:null,EnvelopeIcon:ry},Symbol.toStringTag,{value:"Module"}));function ay({size:t=16}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}const Z9=Object.freeze(Object.defineProperty({__proto__:null,GearIcon:ay},Symbol.toStringTag,{value:"Module"}));function oy({onNavigateToBuild:t,onDismiss:n,providerLabel:s}){return l.useEffect(()=>(re("banner-mounted",{}),()=>{re("banner-unmounted",{})}),[]),e.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-1.5 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg border border-[#FF8B43]/60 bg-[#2a1500] shrink-0",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#FF8B43] shrink-0"}),e.jsxs("span",{className:"text-sm text-[#FF8B43]",children:[s," is waiting for you."," ",e.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]}),e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),n()},className:"p-0.5 text-[#FF8B43]/60 hover:text-[#FF8B43] transition-colors cursor-pointer",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const eF=Object.freeze(Object.defineProperty({__proto__:null,IdleBanner:oy},Symbol.toStringTag,{value:"Module"})),pd="#FF8B43",e3="#FFC773",t3=[{key:"home",label:"Home"},{key:"plan",label:"Plan"},{key:"build",label:"Build"},{key:"history",label:"History"}];function $a(){if(typeof document>"u")return;const t=document.activeElement;t instanceof HTMLElement&&t.blur()}function iy({activeTab:t,onTabChange:n,onSendTranscript:s,buildIdle:r=!1,agentBlocked:a=!1,isAgentBuilding:o=!1,planIdle:i=!1,planActive:c=!1,bannerVisible:d=!1,onDismissIdleBanner:u,buildDisabled:h=!1,showLogo:p=!0,providerLabel:m}){const f=d&&t!=="build",g=r&&a,b=r&&!a,x=o&&!r,y=x?"green":g?"amber-pulse":b?"orange":"none",v=l.useRef(y);l.useEffect(()=>{v.current!==y&&(re("build-tab-dot-change",{from:v.current,to:y}),v.current=y)},[y]);const _=i,j=c&&!i,k=j?"green":_?"orange":"none",S=l.useRef(k);return l.useEffect(()=>{S.current!==k&&(re("plan-tab-dot-change",{from:S.current,to:k}),S.current=k)},[k]),e.jsxs("div",{className:"shrink-0",children:[e.jsxs("div",{className:"@container bg-black h-10 flex items-center px-4 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(Kn,{className:"h-5 text-white shrink-0 @max-[440px]:hidden"}),e.jsx(Kn,{markOnly:!0,className:"h-5 text-white shrink-0 hidden @max-[440px]:block"})]}),e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"})]}),e.jsx("div",{className:"flex items-center gap-1",children:t3.map(w=>w.key==="build"&&h?e.jsx("button",{type:"button","data-nav-tab":"true","data-testid":"nav-build-disabled",title:"Connect your provider account on the Home tab to enable Build",onClick:()=>{n("home"),$a()},className:"px-2.5 py-2.5 text-sm text-[#5A5A5A] cursor-not-allowed font-light whitespace-nowrap",children:w.label},w.key):e.jsxs(yr,{href:rn(w.key),"data-nav-tab":"true",onNavigate:()=>{n(w.key),$a(),w.key==="build"&&yt()},className:`px-2.5 py-2.5 text-sm transition-colors cursor-pointer inline-flex items-center whitespace-nowrap ${t===w.key?"text-[#D7FF63] font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[w.key==="build"&&x&&e.jsx(Pr,{}),w.key==="build"&&g&&e.jsx(rr,{variant:"ring",color:e3,testId:"nav-build-dot-blocked",title:"Waiting on you — the turn stopped on a prompt and won't continue until you answer",pulse:!0}),w.key==="build"&&b&&e.jsx(rr,{variant:"solid",color:pd,testId:"nav-build-dot-idle"}),w.key==="plan"&&j&&e.jsx(Pr,{testId:"nav-plan-dot-active",ariaLabel:"Planning in progress"}),w.key==="plan"&&_&&e.jsx(rr,{variant:"solid",color:pd,testId:"nav-plan-dot-idle"}),w.label]},w.key))})]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white",title:"Send Session Feedback",children:e.jsx(ry,{})}),e.jsx(yr,{href:rn("settings"),"data-nav-tab":"true",onNavigate:()=>{n("settings"),$a()},className:`p-1.5 rounded-md transition-colors cursor-pointer inline-flex items-center ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white"}`,title:"Settings",children:e.jsx(ay,{})})]}),f&&e.jsx(oy,{onNavigateToBuild:()=>n("build"),onDismiss:u??(()=>{}),providerLabel:m})]})}const tF=Object.freeze(Object.defineProperty({__proto__:null,EditorNavBar:iy},Symbol.toStringTag,{value:"Module"}));function ly({projectTitle:t}){const n=typeof t=="string"&&t.trim().length>0;return e.jsxs("div",{"data-tauri-drag-region":!0,"data-testid":"desktop-title-bar",className:"shrink-0 bg-black h-9 flex items-center justify-center gap-2 px-4 select-none",children:[e.jsx(Kn,{className:"h-5 text-white shrink-0"}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),e.jsx("span",{className:"text-white text-sm truncate max-w-[60%]",children:t})]})]})}const nF=Object.freeze(Object.defineProperty({__proto__:null,DesktopTitleBar:ly},Symbol.toStringTag,{value:"Module"}));function n3(){const[t,n]=l.useState(!1),[s,r]=l.useState(""),[a,o]=l.useState(null),i=l.useCallback(()=>n(u=>!u),[]),c=l.useCallback(()=>n(!1),[]),d=l.useCallback(u=>(o(u.adHoc?u.label:null),n(!1),r(u.range),u.range),[]);return{open:t,seed:s,lastAdHocRange:a,toggle:i,close:c,accept:d}}function s3(t,n=25){const[s,r]=l.useState([]);return l.useEffect(()=>{if(!t||s.length>0)return;let a=!1;return(async()=>{try{const o=await fetch(`/api/history?limit=${n}`);if(!o.ok)return;const i=await o.json();if(a)return;r((i.entries??[]).map(c=>c.commit).filter(Boolean))}catch{}})(),()=>{a=!0}},[t,s.length,n]),s}function r3(t,n){for(const s of t.filesByDirectory)for(const r of s.files)if(r.filePath===n)return r;return null}function cy(t){return t>=80?"#16a34a":t>=50?"#eab308":"#dc2626"}function Ls({coverage:t}){const n=Math.max(0,Math.min(100,t.percent)),s=cy(n);return e.jsxs("div",{className:"flex items-center gap-2 min-w-[140px]","data-testid":"coverage-bar",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:e.jsx("div",{"data-testid":"coverage-bar-fill",className:"h-full rounded-full",style:{width:`${n}%`,backgroundColor:s}})}),e.jsxs("span",{className:"text-xs font-mono tabular-nums",style:{color:s},children:[Math.round(n),"%"]})]})}const sF=Object.freeze(Object.defineProperty({__proto__:null,CoverageBar:Ls},Symbol.toStringTag,{value:"Module"}));function dy({file:t,onSelectFile:n}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-directory-file-row",children:[e.jsx("button",{type:"button",onClick:()=>n(t),className:"flex-1 min-w-0 text-left text-xs text-gray-700 truncate hover:underline cursor-pointer",children:t.filePath}),e.jsx(Ls,{coverage:t.coverage})]})}const rF=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryFileRow:dy},Symbol.toStringTag,{value:"Module"}));function uy({group:t,onSelectFile:n}){return e.jsxs("details",{"data-testid":"coverage-details-directory-group",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-gray-800",children:[t.directory||"(root)"," ·"," ",e.jsxs("span",{className:"text-gray-500",children:[t.files.length," file",t.files.length===1?"":"s"]})]}),e.jsx("ul",{className:"divide-y divide-gray-100 mt-2",children:t.files.map(s=>e.jsx(dy,{file:s,onSelectFile:n},s.filePath))})]})}const aF=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryGroup:uy},Symbol.toStringTag,{value:"Module"}));function hy({directories:t,onSelectFile:n}){return t.length===0?null:e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-directories-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By directory"}),e.jsx("div",{className:"flex flex-col gap-3",children:t.map(s=>e.jsx(uy,{group:s,onSelectFile:n},s.directory||"(root)"))})]})}const oF=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoriesSection:hy},Symbol.toStringTag,{value:"Module"}));function py({entry:t,onSelectFile:n}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-entry-row",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{type:"button",onClick:()=>n(t.filePath),className:"text-sm font-medium text-gray-900 truncate text-left hover:underline cursor-pointer",children:t.name}),e.jsx("div",{className:"text-xs text-gray-500 truncate",children:t.filePath}),t.linkedTests.length>0&&e.jsxs("div",{className:"text-xs text-gray-400 truncate",children:[t.linkedTests.length," linked test",t.linkedTests.length===1?"":"s"]})]}),e.jsx(Ls,{coverage:{percent:t.percent,hitLines:t.hitLines,totalLines:t.totalLines}})]})}const iF=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntryRow:py},Symbol.toStringTag,{value:"Module"}));function my({entries:t,onSelectFile:n}){return e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-entries-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By glossary entry"}),t.length===0?e.jsx("p",{className:"text-xs text-gray-500","data-testid":"coverage-details-entries-empty",children:"No glossary entries have coverage data yet."}):e.jsx("ul",{className:"divide-y divide-gray-100",children:t.map(s=>e.jsx(py,{entry:s,onSelectFile:n},`${s.filePath}::${s.name}`))})]})}const lF=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntriesSection:my},Symbol.toStringTag,{value:"Module"}));function fy({file:t}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"orphaned-file-row",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"text-xs text-gray-500 truncate",children:t.filePath})}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-400",title:"Coverage at file level — no glossary entry maps to this file.",children:"file-level"}),e.jsx(Ls,{coverage:t.coverage})]})}const cF=Object.freeze(Object.defineProperty({__proto__:null,OrphanedFileRow:fy},Symbol.toStringTag,{value:"Module"}));function gy({files:t,onSelectFile:n}){return t.length===0?null:e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-orphaned-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"Orphaned files"}),e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:[t.length," file",t.length===1?"":"s"," with coverage but no glossary entry."]}),e.jsx("ul",{className:"divide-y divide-gray-100",children:t.map(s=>e.jsx("div",{onClick:()=>n(s.filePath),role:"button",tabIndex:0,className:"cursor-pointer",onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n(s.filePath))},children:e.jsx(fy,{file:s})},s.filePath))})]})}const dF=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsOrphanedSection:gy},Symbol.toStringTag,{value:"Module"}));function by({line:t,hits:n}){const s=n>0;return e.jsxs("li",{className:"flex items-center gap-3 py-1 font-mono text-xs","data-testid":s?"coverage-line-hit":"coverage-line-miss",children:[e.jsx("span",{className:"w-12 text-right text-gray-400",children:t}),e.jsx("span",{className:s?"px-2 py-0.5 rounded bg-green-100 text-green-800":"px-2 py-0.5 rounded bg-red-100 text-red-800",children:s?`×${n}`:"miss"})]})}const uF=Object.freeze(Object.defineProperty({__proto__:null,CoverageLineRow:by},Symbol.toStringTag,{value:"Module"}));function xy({file:t,onBack:n}){const s=Object.entries(t.lines).map(([r,a])=>({line:Number(r),hits:a})).sort((r,a)=>r.line-a.line);return e.jsxs("div",{"data-testid":"coverage-file-drilldown",className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:n,className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":"coverage-file-drilldown-back",children:"← Back"}),e.jsx("div",{className:"text-sm font-medium text-gray-900 truncate mt-1",children:t.filePath})]}),e.jsx(Ls,{coverage:t.coverage})]}),s.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:"No instrumented lines in this file."}):e.jsx("ul",{className:"divide-y divide-gray-100 max-h-[50vh] overflow-y-auto","data-testid":"coverage-file-drilldown-lines",children:s.map(({line:r,hits:a})=>e.jsx(by,{line:r,hits:a},r))})]})}const hF=Object.freeze(Object.defineProperty({__proto__:null,CoverageFileDrilldown:xy},Symbol.toStringTag,{value:"Module"}));function yy({title:t,aggregate:n,aggregateTestId:s}){return e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900 m-0",children:t}),n&&n.totalLines>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[n.hitLines,"/",n.totalLines," lines"]}),e.jsxs("span",{className:"text-xs font-semibold",style:{color:cy(n.percent)},"data-testid":s,children:[Math.round(n.percent),"% overall"]})]})]})}const pF=Object.freeze(Object.defineProperty({__proto__:null,CoverageSectionHeader:yy},Symbol.toStringTag,{value:"Module"}));function vy({warnings:t}){return t.length===0?null:e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"coverage-warnings-banner",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-amber-800 m-0",children:"Coverage Warnings"}),e.jsx(at,{variant:"subtle",text:t.join(`
|
|
120
|
+
`),label:"Copy",className:"shrink-0 px-2 py-1 text-xs font-medium rounded border border-amber-300 text-amber-800 hover:bg-amber-100 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"})]}),e.jsx("ul",{className:"mt-1 space-y-1 text-sm text-amber-700 list-none p-0 m-0",children:t.map((n,s)=>e.jsx("li",{className:"break-words",children:n},s))})]})]})})}const mF=Object.freeze(Object.defineProperty({__proto__:null,CoverageWarningsBanner:vy},Symbol.toStringTag,{value:"Module"}));function jy({onClose:t,fetchDetails:n=a3,initialData:s}){const[r,a]=l.useState(s??null),[o,i]=l.useState(null),[c,d]=l.useState(null);l.useEffect(()=>{if(s)return;let p=!1;return n().then(m=>{p||a(m)}).catch(m=>{p||i(m instanceof Error?m.message:String(m))}),()=>{p=!0}},[n,s]);const u=l.useCallback(p=>{p.key==="Escape"&&(p.preventDefault(),c?d(null):t())},[t,c]);l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]);const h=p=>{if(!r)return;const m=r3(r,p);m&&d(m)};return e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"coverage-details-modal",onClick:t,children:e.jsxs("div",{className:"max-w-3xl w-full mx-4 p-6 rounded-lg bg-[var(--bg-card)] max-h-[90vh] overflow-y-auto",onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:"Project coverage"}),e.jsx("button",{type:"button",onClick:t,className:"text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer","data-testid":"coverage-details-modal-close","aria-label":"Close",children:"✕"})]}),o&&e.jsx(ft,{testId:"coverage-details-modal-error",text:`Failed to load coverage details: ${o}`,className:"text-sm text-red-700"}),!r&&!o&&e.jsx("p",{className:"text-sm text-[var(--text-muted)]","data-testid":"coverage-details-modal-loading",children:"Loading coverage details…"}),r&&c&&e.jsx(xy,{file:c,onBack:()=>d(null)}),r&&!c&&e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(yy,{title:"Overall",aggregate:r.projectWide,aggregateTestId:"coverage-details-modal-aggregate"}),r.coverageWarnings.length>0&&e.jsx(vy,{warnings:r.coverageWarnings}),e.jsx(my,{entries:r.entries,onSelectFile:h}),e.jsx(gy,{files:r.orphanedFiles,onSelectFile:h}),e.jsx(hy,{directories:r.filesByDirectory,onSelectFile:d})]})]})})}function a3(){return fetch("/api/coverage/details").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()})}const fF=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsModal:jy},Symbol.toStringTag,{value:"Module"}));function o3({launcherUrl:t,projectCount:n=0,fallback:s}){const[r,a]=l.useState(!1),o=l.useCallback(async()=>{if(t){window.location.href=t;return}if(!r){a(!0);try{const c=await fetch("/api/launcher/ensure",{method:"POST"}),d=await c.json().catch(()=>({}));if(c.ok&&typeof d.url=="string"){window.location.href=d.url;return}a(!1)}catch{a(!1)}}},[t,r]);return{goBack:!!t||n>=2?()=>{o()}:s,busy:r}}function wy({title:t,onBack:n,backBusy:s=!1}){return e.jsxs("div",{className:"home-head",children:[n?e.jsx("button",{type:"button",className:"hback",onClick:n,disabled:s,"aria-label":"All projects",title:"All projects",children:"←"}):null,e.jsx("span",{className:"hmark","aria-hidden":"true",children:e.jsx(Kn,{className:"h-4",markOnly:!0})}),e.jsx("h1",{className:"htitle",children:t})]})}const gF=Object.freeze(Object.defineProperty({__proto__:null,HomeHeader:wy},Symbol.toStringTag,{value:"Module"}));function da({title:t,emptyTitle:n,count:s,live:r=!1,attention:a=!1,onAdd:o,addLabel:i,children:c}){const d=s===0;return e.jsxs("div",{className:"home-sechead",children:[e.jsxs("h2",{className:"home-sectitle"+(d?" empty":""),children:[d?n??`No ${t}`:t,s!=null&&s>0?e.jsxs("span",{className:"count",children:[" (",s,")"]}):null]}),r?e.jsx("span",{className:"home-livedot"+(a?" warn":""),"data-testid":"home-section-live-dot"}):null,c,o?e.jsx("button",{type:"button",className:"home-secadd"+(d?"":" spacer"),onClick:o,"aria-label":i,title:i,children:"+"}):null]})}const bF=Object.freeze(Object.defineProperty({__proto__:null,HomeSectionHeading:da},Symbol.toStringTag,{value:"Module"}));function _y({isBuilding:t,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,thumbnailPath:i=null,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u,onResetBuild:h}){return e.jsxs("section",{"data-testid":"home-building-section",children:[e.jsx(da,{title:"What's Building",live:t,attention:t&&a!=="building"}),e.jsx(Qi,{isBuilding:t,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r,buildingStatus:a,buildingProgress:o,thumbnailPath:i,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u,onResetBuild:h})]})}const xF=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildingSection:_y},Symbol.toStringTag,{value:"Module"})),ky=3;function Sy({plans:t,loading:n,error:s,onRun:r,launchingSlug:a=null,blocked:o=!1,depAnnotationsBySlug:i,dependenciesBySlug:c,claimsBySlug:d,staleFetch:u,showAuthors:h=!1,onOpenPlans:p}){const[m,f]=l.useState(null),g=t.slice(0,ky),b=t.length>g.length;return e.jsxs("section",{className:"home-sec","data-testid":"home-queued-plans-section",children:[e.jsx(da,{title:"Queued Plans",count:t.length,onAdd:p,addLabel:"Plan a new change"}),e.jsx(bl,{plans:g,loading:n,error:s,expandedSlug:m,onToggle:x=>f(y=>y===x?null:x),onRun:r,launchingSlug:a,blocked:o,depAnnotationsBySlug:i,dependenciesBySlug:c,claimsBySlug:d,staleFetch:u,showAuthors:h}),b?e.jsxs("button",{type:"button",className:"home-viewall",onClick:p,children:["View all ",e.jsx("span",{"aria-hidden":"true",children:"→"})]}):null]})}const yF=Object.freeze(Object.defineProperty({__proto__:null,HOME_QUEUED_PLAN_LIMIT:ky,HomeQueuedPlansSection:Sy},Symbol.toStringTag,{value:"Module"})),i3=550;function l3(t,n,s=i3){const r=t.filter(p=>p.status!=="completed"),[a,o]=l.useState([]),i=l.useRef(r),c=l.useRef(new Map),d=r.map(p=>p.id).join(" ");if(l.useEffect(()=>{const p=i.current;i.current=r;const m=new Set(r.map(x=>x.id)),f=c.current,g=new Set;f.forEach((x,y)=>{m.has(y)&&(clearTimeout(x),f.delete(y),g.add(y))});const b=p.map((x,y)=>{var v;return{test:x,before:((v=p[y+1])==null?void 0:v.id)??null}}).filter(({test:x})=>!m.has(x.id)&&!f.has(x.id));b.length===0&&g.size===0||(b.forEach(({test:x})=>{f.set(x.id,setTimeout(()=>{f.delete(x.id),o(y=>y.filter(v=>v.test.id!==x.id))},s))}),o(x=>[...x.filter(y=>!g.has(y.test.id)),...b]))},[d,s,r]),l.useEffect(()=>{const p=c.current;return()=>{p.forEach(m=>clearTimeout(m)),p.clear()}},[]),n){const p=new Set(n);return{pending:r.filter(m=>!p.has(m.id)),rows:t.filter(m=>m.status!=="completed"||p.has(m.id)),departingIds:n,pinned:!0}}if(a.length===0)return{pending:r,rows:r,departingIds:[],pinned:!1};const u=new Map(t.map(p=>[p.id,p])),h=[...r];return[...a].reverse().forEach(({test:p,before:m})=>{const f=m===null?-1:h.findIndex(g=>g.id===m);h.splice(f===-1?h.length:f,0,u.get(p.id)??p)}),{pending:r,rows:h,departingIds:a.map(p=>p.test.id),pinned:!1}}function Ny(t){return!t||t.neverGenerated||t.lastGeneratedShaUnreachable||t.commitsSince==null?!0:t.commitsSince>0}function Cy({status:t,onGenerate:n,onAskForMore:s,disabled:r=!1,openChat:a=null,lastAdHocRange:o=null}){return e.jsxs("div",{className:"mtest-controls","data-testid":"home-testing-controls",children:[e.jsx(vu,{status:t}),e.jsx(Tu,{range:o}),e.jsxs("div",{className:"mtest-buttons",children:[e.jsx("button",{type:"button",className:"mtest-btn"+(Ny(t)?" primary":"")+(a==="generate"?" open":""),onClick:n,disabled:r||!n,"aria-expanded":a==="generate",children:"Generate tests"}),e.jsx("button",{type:"button",className:"mtest-btn"+(a==="ask"?" open":""),onClick:s,disabled:r||!s,"aria-expanded":a==="ask",children:"Ask for more tests"})]})]})}const vF=Object.freeze(Object.defineProperty({__proto__:null,HomeTestingSectionControls:Cy,shouldEmphasizeGenerate:Ny},Symbol.toStringTag,{value:"Module"})),md=2;function Ty({tests:t,status:n,loading:s=!1,error:r=null,busyIds:a=[],onToggle:o,onOpenUncovered:i,onGenerate:c,onAskForMore:d,blocked:u=!1,chatSlot:h,openChat:p=null,onAskAboutTest:m,onDeleteTest:f,askProviderLabel:g,openTestChatId:b=null,testChatSlot:x,departingIds:y,rangeSlot:v,lastAdHocRange:_=null}){const j=t.filter(I=>I.status==="completed"),k=new Set(a),[S,w]=l.useState(!1),{pending:C,rows:P,departingIds:T,pinned:O}=l3(t,y),N=new Set(T),E=S?P:P.slice(0,md);return e.jsxs("section",{className:"home-sec","data-testid":"home-testing-section",children:[e.jsx(da,{title:"Testing",emptyTitle:"Nothing to Verify",count:t.length===0?void 0:C.length}),e.jsx(Cy,{status:n,onGenerate:c,onAskForMore:d,disabled:u,openChat:p,lastAdHocRange:_}),v||null,h?e.jsx("div",{className:"mtest-chat",children:h}):null,s?e.jsx("div",{className:"mtest-placeholder","data-testid":"home-testing-loading",children:"Loading tests…"}):r?e.jsx("div",{className:"mtest-placeholder error","data-testid":"home-testing-error",children:r}):e.jsxs(e.Fragment,{children:[P.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mtest-list",children:E.map(I=>e.jsx(ii,{test:I,onToggle:o,onOpenUncovered:i,onAskAbout:m,onDelete:f,askProviderLabel:g,chatOpen:b===I.id,chatSlot:b===I.id?x:null,busy:k.has(I.id),departing:N.has(I.id)&&(O?"pinned":!0)},I.id))}),C.length>md?e.jsx("button",{type:"button",className:"mtest-disclose",onClick:()=>w(I=>!I),"aria-expanded":S,"data-testid":"home-testing-show-all",children:S?"Show less":`Show all ${C.length} tests`}):null]}):e.jsx("div",{className:"mtest-placeholder","data-testid":"home-testing-empty",children:t.length>0?"Nothing left to verify.":"No manual tests yet."}),e.jsx(yu,{tests:j,busyIds:a,onToggle:o,onOpenUncovered:i,onAskAboutTest:m,onDeleteTest:f,askProviderLabel:g,openTestChatId:b,testChatSlot:x})]})]})}const jF=Object.freeze(Object.defineProperty({__proto__:null,HomeTestingSection:Ty},Symbol.toStringTag,{value:"Module"}));function Py({projectTitle:t,app:n,isBuilding:s,buildingLabel:r,buildingStepLabel:a,buildingStepPosition:o,buildingStatus:i,buildingProgress:c,buildingThumbnailPath:d,lastBuiltLabel:u,plans:h,plansLoading:p=!1,plansError:m=null,onRunPlan:f,launchingSlug:g,planDepAnnotationsBySlug:b,planDependenciesBySlug:x,planClaimsBySlug:y,planStaleFetch:v,showPlanAuthors:_,manualTests:j=[],manualTestsStatus:k=null,manualTestsLoading:S=!1,manualTestsError:w=null,manualTestsBusyIds:C,onCompleteManualTest:P,onOpenUncoveredSurface:T,onGenerateTests:O,onAskForTests:N,manualTestsChatSlot:E,manualTestsChatOpen:I=null,manualTestsRangeSlot:ee,manualTestsLastAdHocRange:B=null,onAskAboutTest:z,onDeleteManualTest:Y,manualTestAgentLabel:te,manualTestChatId:R=null,manualTestChatSlot:L,onOpenBuilding:M,onStartNewFeature:K,onResetBuild:ie,onOpenPlans:$,onBackToProjects:V,launcherUrl:ae,projectCount:ne=0}){const{goBack:me,busy:q}=o3({launcherUrl:ae,projectCount:ne,fallback:V}),le=(t==null?void 0:t.trim())||n.name||"Your project";return e.jsxs("div",{className:"home-landing",children:[e.jsx(wy,{title:le,onBack:me,backBusy:q}),e.jsx("div",{className:"home-sec",children:e.jsx(_y,{isBuilding:s,buildingLabel:r,buildingStepLabel:a,buildingStepPosition:o,buildingStatus:i,buildingProgress:c,thumbnailPath:d,lastBuiltLabel:u,onOpenBuilding:M,onStartNewFeature:K,onResetBuild:ie})}),e.jsx(Sy,{plans:h,loading:p,error:m,onRun:f,launchingSlug:g,blocked:s,depAnnotationsBySlug:b,dependenciesBySlug:x,claimsBySlug:y,staleFetch:v,showAuthors:_,onOpenPlans:$}),e.jsx(Ty,{tests:j,status:k,loading:S,error:w,busyIds:C,onToggle:P??(()=>{}),onOpenUncovered:T,onGenerate:O,onAskForMore:N,blocked:s,chatSlot:E,openChat:I,rangeSlot:ee,lastAdHocRange:B,onAskAboutTest:z,onDeleteTest:Y,askProviderLabel:te,openTestChatId:R,testChatSlot:L})]})}const wF=Object.freeze(Object.defineProperty({__proto__:null,HomeLanding:Py},Symbol.toStringTag,{value:"Module"})),Oy="/codeyam-manual-tests";function c3(t){return ra(Oy,"")}function d3(t,n){const s=t.trim();if(!s)return c3();const r="".trim();return ra(Oy,r?`range:${s} ${r}`:`range:${s}`)}function u3(t){const n=t==null?void 0:t.lastGeneratedSha;return n?`${n.slice(0,7)}..HEAD`:null}const h3="/codeyam-manual-test-help";function p3(t){return ra(h3,t)}function Ay({id:t,onClose:n}){const s=l.useRef(null);return l.useEffect(()=>{const r=s.current;r&&typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"nearest",behavior:"smooth"})},[]),e.jsx("div",{ref:s,children:e.jsx($t,{chatName:`manual-test-${t}`,slashCommand:p3(t),height:360,onClose:n})})}const _F=Object.freeze(Object.defineProperty({__proto__:null,ManualTestHelpChat:Ay},Symbol.toStringTag,{value:"Module"}));function m3(){const[t,n]=l.useState([]),[s,r]=l.useState(null),[a,o]=l.useState(!0),[i,c]=l.useState(null),{manualTestsVersion:d}=pn(),u=l.useRef(!1),h=l.useCallback(async()=>{u.current||o(!0),c(null);try{const[p,m]=await Promise.all([fetch("/api/manual-tests"),fetch("/api/manual-tests/status")]);if(!p.ok)throw new Error(`HTTP ${p.status}`);if(!m.ok)throw new Error(`HTTP ${m.status}`);const f=await p.json(),g=await m.json();n(Array.isArray(f)?f:[]),r(g),u.current=!0}catch(p){c(p instanceof Error?p.message:"Failed to load manual tests")}finally{o(!1)}},[]);return l.useEffect(()=>{h()},[h,d]),{tests:t,status:s,loading:a,error:i,refetch:h}}function f3(t){const[n,s]=l.useState({}),[r,a]=l.useState({}),[o,i]=l.useState(null);return{setCompleted:l.useCallback(async(d,u)=>{const h=u?"completed":"pending";i(null),s(p=>({...p,[d]:h})),a(p=>({...p,[d]:!0}));try{const p=u?"complete":"uncomplete",m=await fetch(`/api/manual-tests/${encodeURIComponent(d)}/${p}`,{method:"POST"});if(!m.ok)throw new Error(`HTTP ${m.status}`);await t(),s(f=>{const g={...f};return delete g[d],g})}catch(p){s(m=>{const f={...m};return delete f[d],f}),i(p instanceof Error?p.message:"Failed to update test")}finally{a(p=>{const m={...p};return delete m[d],m})}},[t]),overrides:n,inFlightIds:Object.keys(r),error:o}}function g3(){const[t,n]=l.useState(!1),[s,r]=l.useState(null);return{deleteTest:l.useCallback(async o=>{n(!0),r(null);try{const i=await fetch(`/api/manual-tests/${encodeURIComponent(o)}`,{method:"DELETE"});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.error??`HTTP ${i.status}`)}}catch(i){const c=i instanceof Error?i.message:"Failed to delete test";throw r(c),i instanceof Error?i:new Error(c)}finally{n(!1)}},[]),deleting:t,error:s}}function Ry({title:t,id:n,completed:s,busy:r,error:a,onCancel:o,onConfirm:i}){return l.useEffect(()=>{const c=d=>{d.key==="Escape"&&!r&&o()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[r,o]),e.jsx("div",{role:"presentation",onClick:()=>{r||o()},style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:24},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Delete manual test?","data-test-id":n,onClick:c=>c.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(460px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(cu,{title:t}),e.jsx(lu,{completed:s})]}),a&&e.jsx(On,{severity:"error",testId:"manual-test-delete-error",headline:"The test wasn't deleted",explanation:"CodeYam asked the editor to remove this test and the request came back with an error. The test is still in the list and nothing on disk was changed.",nextAction:"Try Delete test again. If it keeps failing, copy this report — the test file may have been moved or removed outside the editor.",diagnostics:a}),e.jsx(iu,{busy:r,onCancel:o,onConfirm:i})]})})}const kF=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmModal:Ry},Symbol.toStringTag,{value:"Module"}));function b3(t,n){return Object.keys(n).length===0?t:t.map(s=>n[s.id]&&n[s.id]!==s.status?{...s,status:n[s.id]}:s)}const x3={provider:"vercel"},Ey={"dev-accounts":ig,"store-assets":lg,"store-listing":cg,"testing-distribution":dg,"push-notifications":ug,"crash-reporting":hg,"in-app-purchases":pg,"app-privacy":mg,"app-review":fg};function fd(t){return t in Ey}function y3(){const[t,n]=l.useState(null),s=l.useCallback(async()=>{try{const o=await fetch("/api/setup-topics");if(!o.ok)throw new Error(`HTTP ${o.status}`);const i=await o.json();n(Array.isArray(i)?i:[])}catch{n([])}},[]);l.useEffect(()=>{s()},[s]);const r=l.useCallback((o,i)=>{n(c=>c&&c.map(d=>d.key===o?{...d,status:i}:d)),fetch("/api/setup-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:o,status:i})}).catch(()=>{s()})},[s]),a=l.useCallback(async o=>{const i=await fetch("/api/setup-topics",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o.name,desc:o.desc??"",icon:o.icon??""})});if(!i.ok){const d=await i.json().catch(()=>null);throw new Error(d&&typeof d.error=="string"&&d.error||`HTTP ${i.status}`)}const c=await i.json();return await s(),{key:c.key,existed:!!c.existed}},[s]);return{topics:t,setStatus:r,addTopic:a}}function v3(){const[t,n]=l.useState(null);return l.useEffect(()=>{let s=!1;return(async()=>{try{const r=await fetch("/api/setup-libraries");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();s||n(Array.isArray(a)?a:[])}catch{s||n([])}})(),()=>{s=!0}},[]),{groups:t}}function j3(){const[t,n]=l.useState(null);return l.useEffect(()=>{let s=!1;return(async()=>{try{const r=await fetch("/api/local-run-recipe");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();s||n(a)}catch{s||n(null)}})(),()=>{s=!0}},[]),{recipe:t}}function w3(t,n){if(n(),Z1()){Va(t);return}Q1(bc).then(s=>{s?Va(t):console.warn(`[setup-chat] Build terminal did not attach within ${bc}ms; prompt not sent`)})}const _3=new Set(["share-testing","store-accounts","store-assets","permissions-justification","oauth-verification","privacy-policy","single-purpose-listing","manifest-versioning","submit-review"]);function My({appDetailProps:t,appOverviewProps:n,selectedApp:s,projectTitle:r,admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepPosition:d,buildingStatus:u,buildingProgress:h,buildingThumbnailPath:p,lastBuiltLabel:m,plans:f,plansLoading:g,plansError:b,onRunPlan:x,launchingSlug:y,planDepAnnotationsBySlug:v,planDependenciesBySlug:_,planClaimsBySlug:j,planStaleFetch:k,showPlanAuthors:S,onNavigateToPlan:w,onNavigateToBuild:C,onResetBuild:P,onBackToProjects:T,launcherUrl:O,projectCount:N,onOpenSetupBrowser:E}){const[I,ee]=l.useState(!1),B=()=>ee(!0),z=()=>ee(!1),{tests:Y,status:te,loading:R,error:L,refetch:M}=m3(),{setCompleted:K,overrides:ie,inFlightIds:$}=f3(M),{deleteTest:V,deleting:ae,error:ne}=g3(),[me,q]=l.useState(null),le=Y.find(U=>U.id===me)??null,[Pe,Ce]=l.useState(null),F=n3(),J=s3(F.open),[Z,ue]=l.useState(null),{config:ve}=jt(),fe=Ue(ve==null?void 0:ve.provider),[se,Q]=l.useState("landing"),[ze,ge]=l.useState(null),[Ae,Te]=l.useState(null),{topics:H,setStatus:G,addTopic:be}=y3();H==null||H.filter(U=>U.status==="done").length;const de=U=>{var Re;return((Re=H==null?void 0:H.find(De=>De.key===U))==null?void 0:Re.status)??"available"},{services:je,dismiss:Ne,refetch:Ee}=Ci(),[Le,He]=l.useState(null),X=l.useCallback(U=>{var De;const Re=(De=U.envVars)==null?void 0:De[0];Re&&He({serviceName:U.name,envVar:Re,topic:U.topic,docsUrl:U.docsUrl})},[]),{recipe:Oe}=j3(),it=Y2(vm()),{groups:tt}=v3(),qt=(H==null?void 0:H.some(U=>U.key==="dev-accounts"))??!1,Ke=(H==null?void 0:H.some(U=>U.key==="deploy-target"))??!1,kt=U=>{U==="run-locally"?Q("run-locally"):qt&&fd(U)?(Te(U),Q("mobile-setup")):_3.has(U)?Q(U):fd(U)?(Te(U),Q("mobile-setup")):(ge(U),Q("topic"))},_e=!!(t.selectedRouteEntity||t.selectedEntityHash);let ce;if(!s)ce=e.jsx(xb,{...n,onCoverageClick:B},"app-overview");else if(_e||se==="detail"){const U=se==="detail"&&!_e;ce=e.jsxs(e.Fragment,{children:[U?e.jsx("div",{className:"home-landing",style:{padding:"20px 28px 0"},children:e.jsxs("div",{className:"crumbs",style:{marginBottom:0},children:[e.jsx("button",{type:"button",className:"back",onClick:()=>Q("landing"),"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:()=>Q("landing"),children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Explore your app"})]})}):null,e.jsx(_m,{app:s,...t,onCoverageClick:B})]})}else if(se==="learn")ce=e.jsx(dr,{topics:H,detectedServices:je,onBack:()=>Q("landing"),onOpenHosting:()=>Q("hosting"),onOpenTopic:kt,onOpenLibraries:()=>Q("libraries"),onDismissService:Ne,onAddCredential:X,onCreateTopic:be,onOpenConcepts:()=>Q("concepts")});else if(se==="libraries")ce=e.jsx(Lm,{groups:tt,onBack:()=>Q("learn")});else if(se==="concepts")ce=e.jsx(Bf,{onBack:()=>Q("learn")});else if(se==="hosting")ce=e.jsx(Kf,{connector:x3,onBack:()=>Q("learn"),onComplete:()=>G("hosting","done"),onOpenSharedBrowser:E});else if(se==="run-locally")ce=e.jsx(Jf,{recipe:Oe,onBack:()=>Q("learn"),status:de("run-locally"),onMarkDone:()=>G("run-locally","done"),onRevert:()=>G("run-locally","available")});else if(se==="share-testing")ce=e.jsx(og,{onBack:()=>Q("learn"),status:de("share-testing"),onComplete:()=>G("share-testing","done"),onRevert:()=>G("share-testing","available")});else if(se==="store-accounts")ce=e.jsx(Xf,{onBack:()=>Q("learn"),status:de("store-accounts"),onComplete:()=>G("store-accounts","done"),onRevert:()=>G("store-accounts","available")});else if(se==="store-assets")ce=e.jsx(Qf,{onBack:()=>Q("learn"),status:de("store-assets"),onComplete:()=>G("store-assets","done"),onRevert:()=>G("store-assets","available")});else if(se==="permissions-justification")ce=e.jsx(eg,{onBack:()=>Q("learn"),status:de("permissions-justification"),onComplete:()=>G("permissions-justification","done"),onRevert:()=>G("permissions-justification","available")});else if(se==="oauth-verification")ce=e.jsx(ng,{onBack:()=>Q("learn"),status:de("oauth-verification"),onComplete:()=>G("oauth-verification","done"),onRevert:()=>G("oauth-verification","available")});else if(se==="privacy-policy")ce=e.jsx(tg,{onBack:()=>Q("learn"),status:de("privacy-policy"),onComplete:()=>G("privacy-policy","done"),onRevert:()=>G("privacy-policy","available")});else if(se==="single-purpose-listing")ce=e.jsx(sg,{onBack:()=>Q("learn"),status:de("single-purpose-listing"),onComplete:()=>G("single-purpose-listing","done"),onRevert:()=>G("single-purpose-listing","available")});else if(se==="manifest-versioning")ce=e.jsx(rg,{onBack:()=>Q("learn"),status:de("manifest-versioning"),onComplete:()=>G("manifest-versioning","done"),onRevert:()=>G("manifest-versioning","available")});else if(se==="submit-review")ce=e.jsx(ag,{onBack:()=>Q("learn"),status:de("submit-review"),onComplete:()=>G("submit-review","done"),onRevert:()=>G("submit-review","available")});else if(se==="topic"&&ze){const U=(H==null?void 0:H.find(Re=>Re.key===ze))??null;ce=e.jsx($f,{topicKey:ze,topicName:U==null?void 0:U.name,topicDesc:U==null?void 0:U.desc,isBackend:Ke,onBack:()=>Q("learn"),onComplete:Re=>G(Re,"done"),onChatWithAI:Re=>w3(Re,C)})}else if(se==="mobile-setup"&&Ae){const U=Ey[Ae];ce=U?e.jsx(U,{platform:it,onBack:()=>Q("learn"),status:de(Ae),onComplete:()=>G(Ae,"done"),onRevert:()=>G(Ae,"available")}):e.jsx(dr,{topics:H,detectedServices:je,onBack:()=>Q("landing"),onOpenHosting:()=>Q("hosting"),onOpenTopic:kt,onDismissService:Ne,onAddCredential:X})}else ce=e.jsxs(e.Fragment,{children:[e.jsx(Py,{app:s,projectTitle:r,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepPosition:d,buildingStatus:u,buildingProgress:h,buildingThumbnailPath:p,lastBuiltLabel:m,plans:f,plansLoading:g,plansError:b,onRunPlan:x,launchingSlug:y,planDepAnnotationsBySlug:v,planDependenciesBySlug:_,planClaimsBySlug:j,planStaleFetch:k,showPlanAuthors:S,manualTests:b3(Y,ie),manualTestsStatus:te,manualTestsLoading:R,manualTestsError:L,manualTestsBusyIds:$,onCompleteManualTest:(U,Re)=>{K(U,Re)},onGenerateTests:()=>{ue(null),Ce(null),F.toggle()},onAskForTests:()=>{ue(null),F.close(),Ce(U=>U==="ask"?null:"ask")},manualTestsChatOpen:F.open?"generate":Pe,manualTestsLastAdHocRange:F.lastAdHocRange,manualTestsRangeSlot:F.open?e.jsx(Cu,{defaultRange:u3(te),commitCount:(te==null?void 0:te.commitsSince)??null,recentCommits:J,onCancel:F.close,onGenerate:U=>{F.accept(U),Ce("generate")}}):null,manualTestsChatSlot:Pe?e.jsx(gu,{slashCommand:Pe==="generate"?d3(F.seed):void 0,onClose:()=>Ce(null)}):null,onAskAboutTest:U=>{Ce(null),ue(Re=>Re===U?null:U)},onDeleteManualTest:U=>q(U),manualTestAgentLabel:fe,manualTestChatId:Z,manualTestChatSlot:Z?e.jsx(Ay,{id:Z,onClose:()=>ue(null)}):null,onOpenBuilding:C,onStartNewFeature:C,onResetBuild:P,onOpenPlans:w,onBackToProjects:T,launcherUrl:O,projectCount:N}),e.jsx(Yp,{appDetailProps:t,selectedApp:s,setupSlot:a?e.jsx(dr,{topics:H,detectedServices:je,onBack:()=>Q("landing"),onOpenHosting:()=>Q("hosting"),onOpenTopic:kt,onOpenLibraries:()=>Q("libraries"),onDismissService:Ne,onAddCredential:X,onCreateTopic:be,onOpenConcepts:()=>Q("concepts")}):void 0})]});return e.jsxs(Pm,{children:[ce,I&&e.jsx(jy,{onClose:z}),Le?e.jsx(Br,{target:Le,onStored:()=>{He(null),Ee()},onClose:()=>He(null)}):null,le?e.jsx(Ry,{title:le.title,id:le.id,completed:le.status==="completed",busy:ae,error:ne,onCancel:()=>q(null),onConfirm:()=>{V(le.id).then(()=>{q(null),M()}).catch(()=>{})}}):null]})}const SF=Object.freeze(Object.defineProperty({__proto__:null,EditorShellHomeTabContent:My},Symbol.toStringTag,{value:"Module"}));function Iy({activeTab:t,awaitingPlanLaunchChoice:n,buildLaunchGateArmed:s,buildActivated:r,hideResultsCommandKey:a,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,onAgentIdle:d,onAgentBlocked:u,onAgentActive:h,onUserInput:p,notifSettings:m,onSettingsChange:f,provider:g,onRestorePreview:b,pendingPlans:x,pendingPlansLoading:y,pendingPlansError:v,onLaunchPlan:_,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:w,featureCompleteActive:C,buildActivity:P,chatEscalatedToPrototype:T,onActivityDone:O,onPrototypeLaunched:N,prototypeLaunchSignal:E}){return r?e.jsx(ny,{awaitingPlanLaunchChoice:n,buildLaunchGateArmed:s,buildActivated:r,activeTab:t,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,hideResultsCommandKey:a,onAgentIdle:d,onAgentBlocked:u,onAgentActive:h,onUserInput:p,notifSettings:m,onSettingsChange:f,provider:g,onRestorePreview:b,pendingPlans:x,pendingPlansLoading:y,pendingPlansError:v,onLaunchPlan:_,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:w,featureCompleteActive:C,buildActivity:P,chatEscalatedToPrototype:T,onActivityDone:O,onPrototypeLaunched:N,prototypeLaunchSignal:E}):null}const NF=Object.freeze(Object.defineProperty({__proto__:null,EditorShellBuildLayer:Iy},Symbol.toStringTag,{value:"Module"}));function Ly({onMouseDown:t}){return e.jsx("div",{onMouseDown:t,className:"shrink-0 flex items-center justify-center group",style:{width:12,cursor:"col-resize",background:"var(--bg-surface)",borderLeft:"1px solid var(--border-default)",borderRight:"1px solid var(--border-default)"},children:e.jsx("div",{className:"w-0.5 h-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"var(--text-dim)"}})})}const CF=Object.freeze(Object.defineProperty({__proto__:null,PanelDivider:Ly},Symbol.toStringTag,{value:"Module"})),k3=[{key:"editor",label:"Editor"},{key:"preview",label:"Preview"}];function Dy({active:t,onChange:n,isAgentBuilding:s=!1,buildIdle:r=!1}){const a=s&&!r,o=r;return e.jsx("div",{"data-testid":"mobile-pane-switcher",className:"shrink-0 flex w-full",style:{background:"var(--bg-nav)",borderTop:"1px solid var(--border-default)",paddingBottom:"env(safe-area-inset-bottom)"},children:k3.map(i=>{const c=t===i.key;return e.jsxs("button",{"data-testid":`mobile-pane-switcher-${i.key}`,onClick:()=>n(i.key),"aria-pressed":c,className:`flex-1 flex items-center justify-center gap-1 h-12 text-sm border-t-2 transition-colors cursor-pointer ${c?"text-[#D7FF63] border-[#D7FF63] font-medium":"text-[#8E8E8E] border-transparent font-light"}`,children:[i.key==="editor"&&a&&e.jsx(Pr,{}),i.key==="editor"&&o&&e.jsx("span",{"data-testid":"mobile-pane-switcher-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),i.label]},i.key)})})}const TF=Object.freeze(Object.defineProperty({__proto__:null,MobilePaneSwitcher:Dy},Symbol.toStringTag,{value:"Module"}));function Fy({isCollapsed:t,leftPane:n,onResizeStart:s,previewPane:r,splitRef:a,isNarrow:o,mobilePane:i,onMobilePaneChange:c,isAgentBuilding:d=!1,buildIdle:u=!1,hidePreview:h=!1,onHomeLivePageBack:p}){return o?e.jsxs("div",{ref:a,className:"fixed inset-0 flex flex-col",style:{background:"var(--bg-surface)"},children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:`absolute inset-0 flex ${i==="editor"?"":"hidden"}`,children:n}),e.jsx("div",{className:`absolute inset-0 flex ${i==="preview"?"":"hidden"}`,children:r})]}),e.jsx(Dy,{active:i,onChange:c,isAgentBuilding:d,buildIdle:u})]}):p?e.jsx("div",{ref:a,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:r}):h?e.jsx("div",{ref:a,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:n}):e.jsxs("div",{ref:a,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:[!t&&e.jsxs(e.Fragment,{children:[n,e.jsx(Ly,{onMouseDown:s})]}),r]})}const PF=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLayout:Fy},Symbol.toStringTag,{value:"Module"}));function wl(){const[t,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i,claimsVersion:c}=pn(),d=l.useCallback(async()=>{r(!0),o(null);try{const u=await fetch("/api/plan-claims");if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=await u.json();n(Array.isArray(h)?h:[])}catch(u){o(u instanceof Error?u.message:"Failed to load plan claims")}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d,i,c]),{claims:t,loading:s,error:a,refetch:d}}function _l(){const[t,n]=l.useState(null),{claimsVersion:s}=pn(),r=l.useCallback(async()=>{try{const a=await fetch("/api/plan-claims/sync-status");if(!a.ok)return;const o=await a.json();n(o)}catch{}},[]);return l.useEffect(()=>{r()},[r,s]),l.useEffect(()=>{const a=setInterval(()=>void r(),1e4);return()=>clearInterval(a)},[r]),{status:t}}function S3(){const[t,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/server/staleness");if(!r.ok)return;const a=await r.json();n(a)}catch{}},[]);return l.useEffect(()=>{s()},[s]),l.useEffect(()=>{const r=setInterval(()=>void s(),6e4);return()=>clearInterval(r)},[s]),{staleness:t}}const Ba="codeyam-editor editor plan-claims-status",N3="git push origin HEAD";function zy(t,n){switch(t){case"credential":return{message:"Plan tracking isn't reaching the remote — git credentials need refreshing. Run the command below from a shell to wake the credential helper.",command:N3};case"network":return{message:"Plan tracking can't reach the remote (network failure). Check connectivity, then run the command below for details.",command:Ba};case"git-spawn":return{message:"Plan tracking can't launch git. Run the command below for the failing invocation.",command:Ba};default:return{message:`Plan tracking is failing (${n} failed ticks). Teammates' in-flight plans may not appear. Run the command below for details.`,command:Ba}}}function $y({status:t}){const n=(t==null?void 0:t.consecutiveFailures)??0;if((t==null?void 0:t.enabled)===!1||n<3)return null;const{message:s,command:r}=zy(t==null?void 0:t.lastErrorCategory,n);return e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3","data-testid":"plan-claim-sync-banner",role:"alert",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm text-amber-800",children:[s," ",e.jsx("code",{className:"text-xs",children:r})," ",e.jsx(at,{text:r,label:"Copy command",copiedLabel:"Copied",ariaLabel:"Copy the plan-tracking diagnostic command",className:"underline text-amber-700 hover:text-amber-900 disabled:opacity-50"})]})]})})}const OF=Object.freeze(Object.defineProperty({__proto__:null,PlanClaimSyncBanner:$y,planClaimSyncBannerContent:zy},Symbol.toStringTag,{value:"Module"})),gd="codeyam-editor editor restart-server";function kl({staleness:t,backendOutOfDate:n=!1}){var a;const s=!!(t!=null&&t.stale);if(!s&&!n)return null;const r=((a=t==null?void 0:t.info)==null?void 0:a.minutesStale)??0;return e.jsx("div",{className:"rounded-lg p-3","data-testid":"server-staleness-banner",role:"alert",style:{background:"rgba(239, 111, 111, 0.08)",border:"0.5px solid rgba(239, 111, 111, 0.3)"},children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--red-300)"},children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[s?e.jsxs(e.Fragment,{children:["The editor is running an older version of itself (rebuilt"," ",r," min ago) and needs restarting to pick up the latest plan tracking fixes."]}):e.jsx(e.Fragment,{children:"The editor is running an older version of itself, which can’t drive the Build tab. Restarting it reconnects everything."})," ","Run"," ",e.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:gd}),"."," ",e.jsx(at,{text:gd,label:"Copy command",copiedLabel:"Copied",ariaLabel:"Copy the editor restart command",className:"underline disabled:opacity-50"})]})]})})}const AF=Object.freeze(Object.defineProperty({__proto__:null,ServerStalenessBanner:kl},Symbol.toStringTag,{value:"Module"}));function Sl(t){const n=new Map;for(const s of t){const r=n.get(s.slug);(!r||r.source!=="local"&&s.source==="local")&&n.set(s.slug,s)}return n}function C3(t){var s;const n=new Set;for(const r of t){const a=(s=r==null?void 0:r.email)==null?void 0:s.trim().toLowerCase();a&&n.add(a)}return n.size}function By(t){return C3(t)>=2}function T3(t,n){return t.filter(s=>s.source==="local"||!n.has(s.slug))}function Hy(t=10){const[n,s]=l.useState([]),[r,a]=l.useState(!0),[o,i]=l.useState(null),c=l.useRef(!1),d=l.useCallback(async()=>{c.current||a(!0),i(null);try{const u=await fetch(`/api/plans/completed?limit=${t}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=await u.json();s(Array.isArray(h)?h:[]),c.current=!0}catch(u){i(u instanceof Error?u.message:"Failed to load completed plans")}finally{a(!1)}},[t]);return l.useEffect(()=>{d()},[d]),{plans:n,loading:r,error:o,refetch:d}}function qy(){const[t,n]=l.useState(()=>new Set),[s,r]=l.useState(!0),[a,o]=l.useState(null),i=l.useCallback(async()=>{r(!0),o(null);try{const c=await fetch("/api/plans/completed/slugs");if(!c.ok)throw new Error(`HTTP ${c.status}`);const d=await c.json(),u=Array.isArray(d==null?void 0:d.slugs)?d.slugs:[];n(new Set(u.filter(h=>typeof h=="string")))}catch(c){o(c instanceof Error?c.message:"Failed to load completed plan slugs")}finally{r(!1)}},[]);return l.useEffect(()=>{i()},[i]),{slugs:t,loading:s,error:a,refetch:i}}function P3(t,n,s){const r=new Map(n.map(a=>[a.slug,a]));return t.dependsOn.map(a=>{var o;return{slug:a,title:((o=r.get(a))==null?void 0:o.title)??null,satisfied:s.has(a)}})}function Wy(t){return t.filter(n=>!n.satisfied)}function Nl(t){const{slugs:n}=qy();return l.useMemo(()=>{const s={},r={};for(const a of t){const o=a.dependsOn??[];if(o.length===0)continue;const i=P3({...a,dependsOn:o},t,n);r[a.slug]=i;const c=Wy(i);c.length!==0&&(s[a.slug]={count:c.length,tooltip:c.map(d=>d.title??`missing: ${d.slug}`).join(", ")})}return{annotationsBySlug:s,dependenciesBySlug:r}},[t,n])}async function Gy({send:t,waitForIdle:n,ceilingMs:s,payload:r}){const a=t("\x1B"),o=n(s);await a,await o,await t(r)}let Wn={hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null};function ua(t){Wn={...Wn,...t}}function O3(){return Wn}function A3(){return Wn.hasActiveSession||Wn.isAgentBuilding||!!Wn.stepStateFeature}function R3(t){return Zd("build-agent-idle",t)}const E3=500,M3=ys,I3="The session could not be started because the Build terminal never opened, so the launch commands had nowhere to go.";async function Uy(){let t=!1,n;try{const s=await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})});n=s.status,s.ok&&(t=!0)}catch{}t&&ua({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),re("clear-editor-session",{ok:t,...n!==void 0?{status:n}:{},snapshotReset:t})}async function L3(){let t=!1,n;try{const s=await fetch("/api/stop-building",{method:"POST",headers:{"Content-Type":"application/json"}});n=s.status,s.ok&&(t=!0)}catch{}t&&ua({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),re("stop-building",{ok:t,...n!==void 0?{status:n}:{},snapshotReset:t})}async function D3(){let t=!1,n;try{const s=await fetch("/api/reset-everything",{method:"POST",headers:{"Content-Type":"application/json"}});n=s.status,s.ok&&(t=!0)}catch{}t&&ua({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),re("reset-everything",{ok:t,...n!==void 0?{status:n}:{},snapshotReset:t})}async function Vy(t={}){const n=O3(),s=t.caller??"unknown",r=t.bypassLiveGuard===!0;if(A3()&&!r){re("launch-editor-skill",{caller:s,suppressed:!0,snapshot:n,bypassLiveGuard:!1});return}if(x5(),re("launch-editor-skill",{caller:s,suppressed:!1,snapshot:n,bypassLiveGuard:r}),!(t.provider==="gemini"||t.provider==="opencode")){Cb(t.renameLabel??"Editor",s,Qd);try{await Gy({send:xc,waitForIdle:R3,ceilingMs:M3,payload:"/clear\r"}),await new Promise((a,o)=>setTimeout(()=>{xc("/codeyam-editor\r").then(a,o)},E3))}catch(a){throw a instanceof ek?(re("launch-editor-skill",{caller:s,suppressed:!1,droppedNoTerminal:!0}),new Error(I3)):a}}}function Cl(t,n=!1,s=n){const r=_k(t),a=n&&r==="build"?"home":r,[o,i]=l.useState(a==="build"),[c,d]=l.useState(a==="plan");l.useEffect(()=>{a==="build"&&i(!0),a==="plan"&&d(!0)},[a]),l.useEffect(()=>{s&&r==="build"&&window.history.replaceState(null,"",rn("home"))},[s,r]);const u=l.useCallback(m=>{if(n&&m==="build"){window.history.pushState(null,"",rn("home"));return}window.history.pushState(null,"",rn(m)),m==="build"&&i(!0),m==="plan"&&d(!0)},[n]),h=l.useCallback(()=>{n||(window.history.pushState(null,"",rn("build")),i(!0))},[n]),p=l.useCallback(()=>{i(!1)},[]);return{activeTab:a,buildActivated:o,planActivated:c,navigateToTab:u,showBuildTab:h,deactivateBuild:p}}const F3=15e3;function Yy(t={}){const{launchAnchored:n=!1}=t,{showBuildTab:s}=Cl(typeof window>"u"?"/":window.location.pathname),{config:r}=jt(),[a,o]=l.useState(null),[i,c]=l.useState(null),d=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},[]),h=l.useCallback(()=>{u(),o(null)},[u]);l.useEffect(()=>{a!==null&&n&&h()},[a,n,h]),l.useEffect(()=>u,[u]);const p=l.useCallback(async(m,f)=>{if(a)return!1;c(null),o(m);try{try{await Uy(),Dx()}catch{}const g=await fetch(`/api/plans/${encodeURIComponent(m)}/select`,{method:"POST"});if(!g.ok){let b=`HTTP ${g.status}`;try{const x=await g.json();x!=null&&x.error&&(b=x.error)}catch{}throw new Error(b)}s()}catch(g){return c(g instanceof Error?g.message:"Failed to launch plan"),h(),!1}return u(),d.current=setTimeout(()=>{d.current=null,o(null)},F3),Vy({caller:"plan-launcher",renameLabel:f,provider:r==null?void 0:r.provider,bypassLiveGuard:!0}).catch(g=>{c(g instanceof Error?g.message:"Failed to launch plan")}),!0},[a,s,r==null?void 0:r.provider,h,u]);return{launchingSlug:a,error:i,launchPlan:p}}function Ky({onClose:t}){const n=s=>{s.target===s.currentTarget&&t()};return e.jsx("div",{"data-testid":"plan-run-blocked-modal",onClick:n,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Build in progress"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:lh}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsx("button",{onClick:t,"data-testid":"plan-run-blocked-ok",className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"OK"})})]})})}const RF=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedModal:Ky},Symbol.toStringTag,{value:"Module"}));function Jy({deps:t,onClose:n}){const s=r=>{r.target===r.currentTarget&&n()};return e.jsx("div",{"data-testid":"plan-run-dependencies-modal",onClick:s,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Prerequisite plans not yet built"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"This plan depends on the following changes that have not yet been built. Run them first, then come back to this one."}),e.jsx("ul",{className:"flex flex-col gap-1.5 mb-4",children:t.map(r=>e.jsx("li",{"data-testid":`plan-dep-${r.slug}`,className:"text-sm text-[var(--text-primary)]",children:r.title===null?e.jsxs("span",{className:"text-[var(--text-muted)]",children:["missing: ",r.slug," — was the prerequisite plan deleted?"]}):r.title},r.slug))}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsx("button",{onClick:n,"data-testid":"plan-run-dependencies-ok",className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"OK"})})]})})}const EF=Object.freeze(Object.defineProperty({__proto__:null,PlanRunDependenciesModal:Jy},Symbol.toStringTag,{value:"Module"}));function Xy({claim:t,onCancel:n,onConfirm:s}){const r=An(),a=t.claimedBy.agentProvider??"agent",o=t.claimedBy.currentStep??"unknown",i=t.sessionAlive===!1,c=i?"Previous session (no longer running)":"Another session is working on this plan",d=i?"Reclaim and run":"Run anyway";l.useEffect(()=>{const h=p=>{p.key==="Escape"&&n()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[n]);const u=h=>{h.target===h.currentTarget&&n()};return e.jsx("div",{"data-testid":"plan-run-foreign-claim-modal",onClick:u,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{"data-testid":"plan-foreign-claim-heading",className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:c}),e.jsxs("div",{className:"text-sm text-[var(--text-muted)] mb-4 flex flex-col gap-1",children:[e.jsxs("span",{"data-testid":"plan-foreign-claim-identity",children:["claimed by ",a,"@",t.claimedBy.machine]}),e.jsxs("span",{children:["started ",dn(t.claimedBy.startedAt,r)]}),e.jsxs("span",{"data-testid":"plan-foreign-claim-step",children:["on step ",o," (",dn(t.currentStepEnteredAt,r)," on step)"]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:n,"data-testid":"plan-run-foreign-claim-cancel",className:"flex-1 px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--bg-elevated, transparent)",border:"1px solid var(--border-default)",color:"var(--text-primary)"},type:"button",children:"Cancel"}),e.jsx("button",{onClick:s,"data-testid":"plan-run-foreign-claim-confirm",className:"flex-1 px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-warn, #c08a2c)",color:"var(--bg-deep)"},type:"button",children:d})]})]})})}const MF=Object.freeze(Object.defineProperty({__proto__:null,PlanRunForeignClaimModal:Xy},Symbol.toStringTag,{value:"Module"}));function ha({dependenciesBySlug:t,claimsBySlug:n,isAgentBuilding:s=!1,onLaunch:r}){const[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),h=f=>{if(s){o(!0);return}const g=Wy(t[f]??[]);if(g.length>0){c(g);return}const b=n.get(f);if(b&&b.source!=="local"){u(b);return}r(f)},p=()=>{const f=d;if(f){if(u(null),f.sessionAlive===!1){fetch(`/api/plan-claims/${encodeURIComponent(f.slug)}/reclaim`,{method:"POST"}).catch(()=>{}).finally(()=>r(f.slug));return}r(f.slug)}},m=e.jsxs(e.Fragment,{children:[a&&e.jsx(Ky,{onClose:()=>o(!1)}),i&&e.jsx(Jy,{deps:i,onClose:()=>c(null)}),d&&e.jsx(Xy,{claim:d,onCancel:()=>u(null),onConfirm:p})]});return{requestRun:h,gateModals:m}}const Qy="codeyam.";function z3(t){try{const n=window.sessionStorage.getItem(Qy+t);if(n===null)return null;const s=Number.parseInt(n,10);return Number.isInteger(s)&&s>=0?s:null}catch{return null}}function $3(t,n){try{window.sessionStorage.setItem(Qy+t,String(n))}catch{}}function bd(t,n,s=3){const r=l.useRef(void 0);return r.current===void 0&&(r.current=z3(t)),l.useEffect(()=>{n!==null&&$3(t,n)},[t,n]),r.current??s}function Zy(t){return{reorderPlans:l.useCallback(async s=>{const r=await fetch("/api/plans/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slugs:s})});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error??`HTTP ${r.status}`)}t==null||t()},[t])}}function B3(t){return`${t} will remember your plans and suggest them once the current building session is over.`}function ev({providerLabel:t}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:"Plan your next move"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--text-dim)]",children:B3(t)})]})}const IF=Object.freeze(Object.defineProperty({__proto__:null,PlanTabHeader:ev},Symbol.toStringTag,{value:"Module"}));function tv({open:t,onToggle:n}){return e.jsxs("button",{type:"button",onClick:n,className:"mt-3 inline-flex items-center gap-3 rounded-lg bg-[var(--accent-active)] px-4 py-2.5 text-sm font-medium text-[var(--text-on-accent)] transition-opacity hover:opacity-90 cursor-pointer","data-testid":"plan-next-change",children:[t?"Close Planner":"Plan Next Change",!t&&e.jsx("span",{"aria-hidden":"true",className:"text-base leading-none",children:"↓"})]})}const LF=Object.freeze(Object.defineProperty({__proto__:null,PlanNextChangeButton:tv},Symbol.toStringTag,{value:"Module"}));function nv({onClose:t,slashCommand:n=qb,seedText:s}){return e.jsx($t,{chatName:"plan",slashCommand:n,seedText:s,height:360,onClose:t})}const DF=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthoringChat:nv},Symbol.toStringTag,{value:"Module"}));function sv({chatOpen:t,onChatToggle:n,onChatClose:s,initialDraft:r="",planCompleteSignal:a=0}){const o=nl(qb,r);Qb(a,o.clearDraft);const i=()=>{t||o.open(),n()},c=()=>{o.close(),s()};return e.jsxs("div",{"data-testid":"describe-pane",children:[!t&&e.jsx(Lr,{value:o.draft,onChange:o.setDraft,testId:"plan-describe-input"}),e.jsx(tv,{open:t,onToggle:i}),t&&e.jsx(nv,{onClose:c,slashCommand:o.seededCommand??void 0,seedText:o.seedText??void 0})]})}const FF=Object.freeze(Object.defineProperty({__proto__:null,DescribePane:sv},Symbol.toStringTag,{value:"Module"}));function rv({claim:t}){const n=An(),s=t.claimedBy.agentProvider??"agent",r=t.claimedBy.machine,a=t.claimedBy.currentStep??null,o=dn(t.currentStepEnteredAt,n),i=dn(t.claimedBy.startedAt,n),{dead:c}=oh(t);return e.jsxs("li",{className:"flex flex-col gap-1 rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-surface,transparent)] px-3 py-2","data-testid":`in-flight-row-${t.slug}`,"data-session-alive":c?"false":void 0,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm text-[var(--text-default)]",children:t.title}),e.jsx(mi,{testId:`in-flight-source-${t.slug}`,children:t.source})]}),e.jsx(rh,{slug:t.slug,identity:`${s}@${r}`,step:a?`step ${a} · ${o} on step`:null,age:i,dead:c})]})}const zF=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRow:rv},Symbol.toStringTag,{value:"Module"}));function av({claims:t}){const[n,s]=l.useState(!1);return t.length===0?null:e.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5","data-testid":"in-flight-section",children:[e.jsx(Ts,{title:"In Flight",count:t.length,expanded:n,onToggle:()=>s(r=>!r),testId:"in-flight-header"}),n&&e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"in-flight-list",children:t.map(r=>e.jsx(rv,{claim:r},`${r.slug}:${r.claimedBy.machine}:${r.claimedBy.sessionId}:${r.claimedBy.pid}:${r.claimedBy.startedAt}`))})]})}const $F=Object.freeze(Object.defineProperty({__proto__:null,InFlightSection:av},Symbol.toStringTag,{value:"Module"})),H3=5e3;function q3(){const[t,n]=l.useState([]),[s,r]=l.useState(null),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(null),h=l.useRef(!1),p=l.useCallback(async()=>{c(!0),u(null);try{const g=await fetch("/api/branch-queue/status");if(!g.ok)throw new Error(`HTTP ${g.status}`);const b=await g.json();if(h.current)return;n(Array.isArray(b.entries)?b.entries:[]),r(b.branch??null),o(b.remote??null)}catch(g){if(h.current)return;u(g instanceof Error?g.message:"Failed to load branch queue"),n([])}finally{h.current||c(!1)}},[]);l.useEffect(()=>{h.current=!1,p();const g=setInterval(()=>{p()},H3);return()=>{h.current=!0,clearInterval(g)}},[p]);const m=l.useCallback(async(g,b,x)=>{const y={uuid:g,priority:b};typeof x=="number"&&(y.expectedPriority=x);const v=await fetch("/api/branch-queue/set-priority",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y)});if(!v.ok){const _=await v.text().catch(()=>"");throw new Error(`set-priority ${v.status}: ${_}`)}await p()},[p]),f=l.useCallback(async g=>{const b=await fetch("/api/branch-queue/release",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({uuid:g})});if(!b.ok){const x=await b.text().catch(()=>"");throw new Error(`release ${b.status}: ${x}`)}await p()},[p]);return{entries:t,branch:s,remote:a,loading:i,error:d,setPriority:m,release:f,refetch:p}}function W3(){const[t,n]=l.useState(null),[s,r]=l.useState(null),a=l.useCallback(c=>{n(c)},[]),o=l.useCallback(c=>{r(c)},[]),i=l.useCallback(()=>{n(null),r(null)},[]);return{dragSourceUuid:t,dragOverUuid:s,beginDrag:a,hoverOver:o,reset:i}}function G3(t,n){const s=new Map(n.map(i=>[i.uuid,i])),r=[],a=new Set;for(const i of t.order){const c=s.get(i.uuid);c&&(r.push(c),a.add(i.uuid))}for(const i of n)a.has(i.uuid)||(r.push(i),a.add(i.uuid));const o=new Set;for(const i of t.releasedUuids)s.has(i)&&o.add(i);return{order:r,releasedUuids:o}}const U3=new Set;function Ha(t,n){return t??{order:[...n],releasedUuids:new Set}}function V3(){const[t,n]=l.useState(null),s=l.useCallback(h=>t?t.order:h,[t]),r=l.useCallback((h,p,m)=>{n(f=>{const g=Ha(f,m),b=g.order.findIndex(y=>y.uuid===h),x=g.order.findIndex(y=>y.uuid===p);return b===-1||x===-1||b===x?g:{...g,order:Ns(g.order,b,x)}})},[]),a=l.useCallback((h,p,m)=>{n(f=>{const g=Ha(f,m),b=g.order.findIndex(y=>y.uuid===h);if(b===-1)return g;const x=b-p;return x<0||x>=g.order.length?g:{...g,order:Ns(g.order,b,x)}})},[]),o=l.useCallback((h,p)=>{n(m=>{const f=Ha(m,p),g=new Set(f.releasedUuids);return g.has(h)?g.delete(h):g.add(h),{...f,releasedUuids:g}})},[]),i=l.useCallback(h=>{n(p=>p?G3(p,h):null)},[]),c=l.useCallback(()=>n(null),[]),d=l.useCallback(h=>t?t.releasedUuids.size>0||t.order.length!==h.length?!0:t.order.some((p,m)=>{var f;return p.uuid!==((f=h[m])==null?void 0:f.uuid)}):!1,[t]),u=l.useCallback(h=>{var b,x;if(!t)return 0;const p=t.releasedUuids,m=h.filter(y=>!p.has(y.uuid)),f=t.order.filter(y=>!p.has(y.uuid));let g=0;for(let y=0;y<f.length;y++)((b=f[y])==null?void 0:b.uuid)!==((x=m[y])==null?void 0:x.uuid)&&g++;return g},[t]);return{isActive:t!==null,displayEntries:s,releasedUuids:(t==null?void 0:t.releasedUuids)??U3,isDirty:d,reorderedCount:u,releasedCount:(t==null?void 0:t.releasedUuids.size)??0,moveByDrag:r,nudge:a,toggleRelease:o,reconcile:i,reset:c}}const Y3=10;function K3(t,n,s){const r=new Map(s.map(d=>[d.uuid,d])),a=s.filter(d=>n.has(d.uuid)).map(d=>d.uuid),o=t.filter(d=>!n.has(d.uuid)),i=o.length,c=[];return o.forEach((d,u)=>{const h=r.get(d.uuid);if(!h)return;const p=(i-u)*Y3;h.meta.priority!==p&&c.push({uuid:d.uuid,priority:p,expectedPriority:h.meta.priority})}),{releases:a,priorities:c}}function ov({priority:t,uuid:n,onNudge:s}){const r=t===0?"priority 0":t>0?`priority +${t}`:`priority ${t}`;return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] rounded border border-[var(--border-subtle)] px-2 py-1 text-[var(--text-muted)]","data-testid":`commit-queue-priority-chip-${n}`,children:[e.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-down-${n}`,onClick:()=>void s(-1),"aria-label":"Lower priority",children:"−"}),e.jsx("span",{"data-testid":`commit-queue-priority-value-${n}`,children:r}),e.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-up-${n}`,onClick:()=>void s(1),"aria-label":"Raise priority",children:"+"})]})}const BF=Object.freeze(Object.defineProperty({__proto__:null,CommitQueuePriorityChip:ov},Symbol.toStringTag,{value:"Module"}));function iv({entry:t,isHead:n}){const s=An(),r=t.meta.agentProvider??"agent",a=t.meta.machine,o=t.meta.currentStep??null,i=dn(t.meta.startedAt??t.committerDate,s);return e.jsxs("div",{className:"flex-1 flex flex-col gap-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-default)] truncate",title:a,"data-testid":`commit-queue-machine-${t.uuid}`,children:a}),n&&e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-strong)]","data-testid":`commit-queue-head-marker-${t.uuid}`,children:"← head"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[e.jsx("span",{"data-testid":`commit-queue-agent-${t.uuid}`,children:r}),o&&e.jsxs("span",{"data-testid":`commit-queue-step-${t.uuid}`,children:["step ",o]}),e.jsxs("span",{"data-testid":`commit-queue-started-${t.uuid}`,children:["started ",i]}),e.jsxs("span",{"data-testid":`commit-queue-pid-${t.uuid}`,children:["pid ",t.meta.pid]})]})]})}const HF=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowIdentity:iv},Symbol.toStringTag,{value:"Module"}));function lv({entry:t,position:n,isHead:s,markedForRelease:r,expanded:a,onToggleExpanded:o,onPriorityNudge:i,onToggleRelease:c,onDragStart:d,onDragOver:u,onDrop:h,isDragging:p,isDragOver:m}){return e.jsxs("li",{"data-testid":`commit-queue-row-${t.uuid}`,draggable:!0,onDragStart:f=>{f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",t.uuid),d()},onDragOver:f=>{f.preventDefault(),f.dataTransfer.dropEffect="move",u()},onDrop:f=>{f.preventDefault(),h()},"data-marked-for-release":r||void 0,className:`group flex flex-wrap items-center gap-y-2 rounded border px-3 py-2 ${s?"border-[var(--accent-strong)]":"border-[var(--border-subtle)]"} ${p?"opacity-40":""} ${m?"ring-2 ring-[var(--accent-strong)]":""} ${r?"opacity-50 line-through":""}`,children:[e.jsxs("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-3",children:[e.jsx("span",{"aria-hidden":!0,className:"cursor-grab select-none text-[var(--text-dim)] hover:text-[var(--text-default)]",title:"Drag to reorder","data-testid":`commit-queue-drag-${t.uuid}`,children:"⋮⋮"}),e.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)] w-6 text-right","data-testid":`commit-queue-position-${t.uuid}`,children:[n,"."]}),e.jsxs("button",{type:"button",onClick:o,"aria-expanded":a,"data-testid":`commit-queue-toggle-${t.uuid}`,className:"flex min-w-0 flex-1 basis-48 items-center gap-2 bg-transparent text-left cursor-pointer",children:[e.jsx(iv,{entry:t,isHead:s}),e.jsx(Ir,{expanded:a,testId:`commit-queue-chevron-${t.uuid}`})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[e.jsx(ov,{priority:t.meta.priority,uuid:t.uuid,onNudge:i}),e.jsx(oi,{uuid:t.uuid,markedForRelease:r,onToggle:c})]})]}),a&&e.jsx("div",{className:"w-full border-t border-[var(--border-subtle)] pt-2",children:e.jsx(du,{entry:t,markedForRelease:r,onToggleRelease:c})})]})}const qF=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRow:lv},Symbol.toStringTag,{value:"Module"}));function cv({reorderedCount:t,releasedCount:n,saving:s,onSave:r,onCancel:a}){const o=[];t>0&&o.push(`${t} reordered`),n>0&&o.push(`${n} to remove`);const i=o.join(" · ")||"Unsaved changes";return e.jsxs("div",{"data-testid":"commit-queue-save-bar",className:"mt-3 flex items-center justify-between gap-3 border-t border-[var(--accent-strong)] pt-3",children:[e.jsx("span",{className:"text-xs text-[var(--text-muted)]","data-testid":"commit-queue-save-summary",children:i}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button","data-testid":"commit-queue-cancel",onClick:a,disabled:s,className:"text-xs px-3 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:text-[var(--text-default)] disabled:opacity-50 cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"commit-queue-save",onClick:r,disabled:s,className:"text-xs px-3 py-1 rounded bg-[var(--accent-strong)] font-medium text-white hover:opacity-90 disabled:opacity-50 cursor-pointer",children:s?"Saving…":"Save"})]})]})}const WF=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSaveBar:cv},Symbol.toStringTag,{value:"Module"}));function dv({entriesOverride:t,branchOverride:n}={}){const s=q3(),r=t!==void 0,a=t??s.entries,o=n??s.branch,i=W3(),c=V3(),{reconcile:d}=c,[u,h]=l.useState(null),[p,m]=l.useState(!0),[f,g]=l.useState(!1),[b,x]=l.useState(null);if(l.useEffect(()=>{r||d(a)},[a,d,r]),!r&&s.loading&&a.length===0||a.length===0)return null;const y=c.displayEntries(a),v=c.isDirty(a),_=C=>{var O;const P=i.dragSourceUuid,T=(O=y[C])==null?void 0:O.uuid;i.reset(),!(P===null||!T||P===T)&&c.moveByDrag(P,T,a)},j=(C,P)=>{c.nudge(C.uuid,P,a)},k=C=>{c.toggleRelease(C.uuid,a)},S=()=>{h(null),c.reset()},w=async()=>{const{releases:C,priorities:P}=K3(y,new Set(c.releasedUuids),a);h(null),g(!0);try{if(!r){for(const T of C)await s.release(T);for(const T of P)await s.setPriority(T.uuid,T.priority,T.expectedPriority);await s.refetch()}c.reset()}catch(T){h(T instanceof Error?T.message:"Failed to save changes")}finally{g(!1)}};return e.jsxs("div",{className:"mt-6 border-t border-[var(--border-subtle)] pt-4","data-testid":"commit-queue-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Ts,{title:"Commit Queue",count:y.length,expanded:p,onToggle:()=>m(C=>!C),testId:"commit-queue-header"}),o&&e.jsx("span",{className:"text-[11px] text-[var(--text-dim)]","data-testid":"commit-queue-branch",children:o})]}),u&&e.jsx("div",{className:"mt-2","data-testid":"commit-queue-error",children:e.jsx(ft,{text:u,className:"text-xs text-[var(--accent-danger)]"})}),p&&e.jsx("ol",{className:"mt-3 flex flex-col gap-2","data-testid":"commit-queue-list",children:y.map((C,P)=>e.jsx(lv,{entry:C,position:P+1,isHead:P===0,markedForRelease:c.releasedUuids.has(C.uuid),expanded:b===C.uuid,onToggleExpanded:()=>x(T=>T===C.uuid?null:C.uuid),onPriorityNudge:T=>j(C,T),onToggleRelease:()=>k(C),onDragStart:()=>i.beginDrag(C.uuid),onDragOver:()=>i.hoverOver(C.uuid),onDrop:()=>_(P),isDragging:i.dragSourceUuid===C.uuid,isDragOver:i.dragOverUuid===C.uuid&&i.dragSourceUuid!==C.uuid},C.uuid))}),v&&e.jsx(cv,{reorderedCount:c.reorderedCount(a),releasedCount:c.releasedCount,saving:f,onSave:w,onCancel:S})]})}const GF=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSection:dv},Symbol.toStringTag,{value:"Module"}));function J3(t){const[n,s]=l.useState(null),[r,a]=l.useState(!0),[o,i]=l.useState(null);return l.useEffect(()=>{let c=!1;return(async()=>{a(!0),i(null);try{const d=new Date(new Date(t).getTime()-1).toISOString(),u=await fetch(`/api/journal?since=${encodeURIComponent(d)}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const p=((await u.json()).entries??[]).find(m=>m.timestamp===t)??null;c||s(p)}catch(d){c||(s(null),i(d instanceof Error?d.message:"Failed to load journal entry"))}finally{c||a(!1)}})(),()=>{c=!0}},[t]),{entry:n,loading:r,error:o}}function uv({journalTimestamp:t}){const{entry:n,loading:s,error:r}=J3(t);return s?e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Loading journal entry…"}):r?e.jsx(ft,{text:`Failed to load journal entry: ${r}`,className:"text-sm text-[var(--accent-red)]"}):n?e.jsx(na,{entry:n}):e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No journal entry found for this plan yet."})}const UF=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanExpandedBody:uv},Symbol.toStringTag,{value:"Module"})),xd=160;function X3(t){if(!t)return"";let n=!1;for(const s of t.split(`
|
|
121
|
+
`)){const r=s.trim();if(r.startsWith("```")){n=!n;continue}if(n||!r||/^(#{1,6}\s|[-*+]\s|>\s|\||---$)/.test(r))continue;const a=r.replace(/`([^`]*)`/g,"$1").replace(/\*\*([^*]*)\*\*/g,"$1").replace(/\*([^*]*)\*/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").trim();if(a)return a.length>xd?`${a.slice(0,xd).trimEnd()}…`:a}return""}function hv({plan:t,expanded:n,onToggle:s,author:r}){const a=X3(t.body);return e.jsxs("li",{className:"border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)]",children:[e.jsxs("button",{type:"button",onClick:s,className:"w-full text-left px-3 py-2 flex items-center justify-between gap-3 bg-transparent cursor-pointer","data-testid":"completed-plan-row",children:[r&&e.jsx(Rr,{author:r}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx(gi,{title:t.title,timestamp:t.completedAt,tone:"muted"}),a&&e.jsx("span",{className:"mt-0.5 block truncate text-xs text-[var(--text-dim)]","data-testid":`completed-plan-excerpt-${t.slug}`,children:a})]}),e.jsx(fi,{mode:t.mode}),e.jsx(Ir,{expanded:n,testId:"completed-plan-row-chevron"})]}),n&&e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]","data-testid":"completed-plan-row-body",children:e.jsx(uv,{journalTimestamp:t.journalTimestamp})})]})}const VF=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanRow:hv},Symbol.toStringTag,{value:"Module"}));function pv({plans:t,loading:n,error:s,showAuthors:r=!1,skeletonCount:a=3}){const[o,i]=l.useState(null),[c,d]=l.useState(!1),h=n&&t.length===0?a:t.length;return e.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5",children:[e.jsx(Ts,{title:"Completed Plans",count:h,expanded:c,onToggle:()=>d(p=>!p),testId:"completed-plans-header"}),c&&e.jsx(mv,{plans:t,loading:n,error:s,expandedSlug:o,onToggle:p=>i(m=>m===p?null:p),showAuthors:r,skeletonCount:a})]})}function mv({plans:t,loading:n,error:s,expandedSlug:r,onToggle:a,showAuthors:o=!1,skeletonCount:i=3}){const c=s?e.jsx(ft,{text:`Failed to load completed plans: ${s}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):null;return n&&t.length===0?e.jsx(pi,{count:i,testId:"recent-plans-skeleton-list",label:"Loading completed plans"}):t.length===0?c:e.jsxs(e.Fragment,{children:[c,e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"recent-plans-list",children:t.map(d=>e.jsx(hv,{plan:d,expanded:r===d.slug,onToggle:()=>a(d.slug),author:o?d.author:void 0},d.slug))})]})}const YF=Object.freeze(Object.defineProperty({__proto__:null,RecentPlansBody:mv,RecentPlansSection:pv},Symbol.toStringTag,{value:"Module"}));function fv({chatOpen:t,onChatOpenChange:n,isActive:s=!0,isAgentBuilding:r=!1,launchingSlug:a,launchError:o,onLaunchPlan:i,planCompleteSignal:c=0}={}){const{plans:d,loading:u,error:h,refetch:p}=ml(),{claims:m}=wl(),{slugs:f}=qy(),{status:g}=_l(),{staleness:b}=S3(),x=((g==null?void 0:g.consecutiveFailures)??0)>=3,{plans:y,loading:v,error:_}=Hy(),j=bd("plan-tab.queued-count",u?null:d.length),k=bd("plan-tab.completed-count",v?null:y.length),{config:S}=jt(),w=Ue(S==null?void 0:S.provider),C=i!==void 0,P=Yy(),T=C?a??null:P.launchingSlug,O=C?o??null:P.error,[N,E]=l.useState(!1),I=l.useMemo(()=>Sl(m),[m]),ee=l.useMemo(()=>T3(m,f),[m,f]),B=l.useMemo(()=>By([...d.map(ne=>ne.author),...y.map(ne=>ne.author)]),[d,y]),z=t!==void 0,Y=z?t:N,te=ne=>{z||E(ne),n==null||n(ne)},R=()=>{te(!1),p()},L=()=>{const ne=!Y;ne&&yt(),te(ne)};l.useEffect(()=>{if(!(!s||!Y))return yt()},[s,Y]);const{annotationsBySlug:M,dependenciesBySlug:K}=Nl(d),ie=ne=>{var q;const me=((q=d.find(le=>le.slug===ne))==null?void 0:q.title)??ne;if(i){i(ne,me);return}P.launchPlan(ne,me)},{requestRun:$,gateModals:V}=ha({dependenciesBySlug:K,claimsBySlug:I,isAgentBuilding:r,onLaunch:ie}),{reorderPlans:ae}=Zy(p);return e.jsxs(Dt,{testId:"plan-tab",children:[e.jsx(ev,{providerLabel:w}),e.jsx(sv,{chatOpen:Y,onChatToggle:L,onChatClose:R,planCompleteSignal:c}),e.jsx(kl,{staleness:b}),e.jsx($y,{status:g}),e.jsx(ca,{plans:d,loading:u,error:h,onRun:$,launchingSlug:T,launchError:O,blocked:r,onReorder:ae,depAnnotationsBySlug:M,dependenciesBySlug:K,claimsBySlug:I,staleFetch:x,skeletonCount:j,showAuthors:B}),e.jsx(av,{claims:ee}),e.jsx(dv,{}),e.jsx(pv,{plans:y,loading:v,error:_,skeletonCount:k,showAuthors:B}),V]})}const KF=Object.freeze(Object.defineProperty({__proto__:null,PlanTab:fv},Symbol.toStringTag,{value:"Module"}));function gv({activeTab:t,planActivated:n,chatOpen:s,onChatOpenChange:r,isAgentBuilding:a=!1,launchingPlanSlug:o,planLaunchError:i,onLaunchPlan:c,planCompleteSignal:d=0}){return n?e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:t==="plan"?"visible":"hidden",pointerEvents:t==="plan"?"auto":"none"},children:e.jsx(fv,{chatOpen:s,onChatOpenChange:r,isActive:t==="plan",isAgentBuilding:a,launchingSlug:o,launchError:i,onLaunchPlan:c,planCompleteSignal:d})}):null}const JF=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPlanLayer:gv},Symbol.toStringTag,{value:"Module"})),Q3="desktop",yd="codeyam:isDesktopApp";function Z3(t=typeof window<"u"?window:void 0){var o,i,c;if(!t)return!1;try{if(((o=t.sessionStorage)==null?void 0:o.getItem(yd))==="1")return!0}catch{}const s=new URLSearchParams(((i=t.location)==null?void 0:i.search)??"").get(Q3)==="1",r=typeof t.__TAURI__<"u",a=s||r;if(a)try{(c=t.sessionStorage)==null||c.setItem(yd,"1")}catch{}return a}function bv({visible:t,children:n}){return e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-auto",style:{visibility:t?"visible":"hidden"},children:n})}const XF=Object.freeze(Object.defineProperty({__proto__:null,TabPane:bv},Symbol.toStringTag,{value:"Module"}));function xv({activeTab:t,children:n}){const s=["home","build","plan","history","reviews","settings"];return e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:s.map(r=>e.jsx(bv,{visible:t===r,children:n[r]},r))})}const QF=Object.freeze(Object.defineProperty({__proto__:null,LeftPanel:xv},Symbol.toStringTag,{value:"Module"}));function yv({label:t,description:n,checked:s,disabled:r=!1,onChange:a,children:o}){return e.jsxs("div",{className:"py-3",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:r,onChange:i=>a(i.target.checked),className:"accent-green-500 mt-0.5"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"text-[12px] block",style:{color:"var(--text-primary)"},children:t}),e.jsx("span",{className:"text-[11px] block mt-0.5",style:{color:"var(--text-dim)"},children:n})]})]}),o]})}const ZF=Object.freeze(Object.defineProperty({__proto__:null,CheckInToggleRow:yv},Symbol.toStringTag,{value:"Module"}));function Tl({options:t,value:n,onChange:s,disabled:r=!1,ariaLabel:a}){return e.jsx("div",{className:"flex gap-1",role:a?"radiogroup":void 0,"aria-label":a,children:t.map(o=>{const i=o.value===n;return e.jsx("button",{type:"button",role:a?"radio":void 0,"aria-checked":a?i:void 0,title:o.hint,disabled:r,onClick:()=>s(o.value),className:"text-[11px] px-2 py-1 rounded cursor-pointer transition-colors",style:{background:i?"var(--bg-input)":"transparent",color:i?"var(--text-primary)":"var(--text-secondary)"},children:o.label},o.value)})})}const ez=Object.freeze(Object.defineProperty({__proto__:null,SegmentedPicker:Tl},Symbol.toStringTag,{value:"Module"})),e4=[{value:"commit",label:"Commit",hint:"Run the full finalize, then commit."},{value:"fastCommit",label:"Fast commit",hint:"Defer the heavy finalize work; owed before merge."}];function vv({autoAction:t,branchState:n,disabled:s=!1,onChange:r}){return n.onPrimaryBranch?e.jsx("div",{className:"mt-2 ml-6",children:e.jsxs("p",{className:"text-[11px]",style:{color:"var(--text-dim)"},children:["Fast commit is disabled on"," ",n.primaryBranch??"the primary branch"," — this check-in will commit normally."]})}):e.jsxs("div",{className:"mt-2 ml-6",children:[e.jsx("div",{className:"text-[11px] mb-1",style:{color:"var(--text-muted)"},children:"When it runs on its own"}),e.jsx(Tl,{options:e4,value:t,onChange:r,disabled:s,ariaLabel:"Autonomous commit action"})]})}const tz=Object.freeze(Object.defineProperty({__proto__:null,HardeningAutoAction:vv},Symbol.toStringTag,{value:"Module"})),jv={checkIns:{planAccepted:{pause:!0},prototypeCompleted:{pause:!0},hardeningCompleted:{pause:!0,autoAction:"commit"},push:{pause:!0}}};function vd(t){const n=(t==null?void 0:t.checkIns)??{},s=jv.checkIns;return{checkIns:{planAccepted:n.planAccepted??s.planAccepted,prototypeCompleted:n.prototypeCompleted??s.prototypeCompleted,hardeningCompleted:n.hardeningCompleted??s.hardeningCompleted,push:n.push??s.push}}}function t4(){const[t,n]=l.useState(jv),[s,r]=l.useState({currentBranch:null,primaryBranch:null,onPrimaryBranch:!1}),[a,o]=l.useState(!0),[i,c]=l.useState(!1),[d,u]=l.useState(null);l.useEffect(()=>{let p=!1;return(async()=>{var m;try{const f=await fetch("/api/config");if(!f.ok)throw new Error(`config request failed (${f.status})`);const g=await f.json();if(p)return;const b=(g==null?void 0:g.currentBranch)??null,x=((m=g==null?void 0:g.audit)==null?void 0:m.branchBaseRef)??null;n(vd(g==null?void 0:g.workflow)),r({currentBranch:b,primaryBranch:x,onPrimaryBranch:b!==null&&b===x})}catch(f){p||u(f instanceof Error?f.message:String(f))}finally{p||o(!1)}})(),()=>{p=!0}},[]);const h=l.useCallback(async(p,m)=>{const f=t;n(p),c(!0),u(null);try{const g=await fetch("/api/workflow-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:m,workflow:p})}),b=await g.json().catch(()=>({}));if(!g.ok||(b==null?void 0:b.success)===!1)throw new Error((b==null?void 0:b.message)??(b==null?void 0:b.error)??`save failed (${g.status})`);b!=null&&b.workflow&&n(vd(b.workflow))}catch(g){n(f),u(g instanceof Error?g.message:String(g))}finally{c(!1)}},[t]);return{settings:t,branchState:s,loading:a,saving:i,error:d,save:h}}const n4=[{key:"planAccepted",label:"Plan accepted",description:"Pause after the plan is written, before any code is built."},{key:"prototypeCompleted",label:"Prototype completed",description:"Pause once the prototype is demoable in the Live Preview."},{key:"hardeningCompleted",label:"Hardening completed",description:"Pause after tests, scenarios, and the audit are green."},{key:"push",label:"Push",description:"Pause before the branch is pushed to the remote."}],s4=[{value:"local",label:"This machine only"},{value:"project",label:"Whole project"}];function wv(){const[t,n]=l.useState("local"),{settings:s,branchState:r,loading:a,saving:o,error:i,save:c}=t4(),d=s.checkIns.hardeningCompleted;return e.jsxs("section",{className:"mt-4",children:[e.jsx("h3",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:"Workflow"}),e.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-dim)"},children:"Checked means the workflow pauses and asks you at that point. Unchecked means it keeps going on its own."}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Apply to"}),e.jsx(Tl,{options:s4,value:t,onChange:n})]}),e.jsx("div",{className:"mt-3",children:n4.map(u=>{const h=s.checkIns[u.key];return e.jsx(yv,{label:u.label,description:u.description,checked:h.pause,disabled:a||o,onChange:p=>void c({checkIns:{...s.checkIns,[u.key]:{...h,pause:p}}},t),children:u.key==="hardeningCompleted"&&!d.pause&&e.jsx(vv,{autoAction:d.autoAction,branchState:r,disabled:o,onChange:p=>void c({checkIns:{...s.checkIns,hardeningCompleted:{...d,autoAction:p}}},t)})},u.key)})}),i&&e.jsxs("p",{className:"text-[11px] mt-3",role:"alert",style:{color:"var(--accent-red, #ef4444)"},children:["Could not save: ",i]})]})}const nz=Object.freeze(Object.defineProperty({__proto__:null,WorkflowSettingsSection:wv},Symbol.toStringTag,{value:"Module"}));function _v(){return e.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4",children:[e.jsx("h2",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:"Settings"}),e.jsx(wv,{})]})}const sz=Object.freeze(Object.defineProperty({__proto__:null,SettingsTab:_v},Symbol.toStringTag,{value:"Module"}));function kv({activeTab:t,appTabContent:n,leftWidth:s,onPreviewScreenshot:r}){const a=t!=="build"&&t!=="plan",[o,i]=l.useState(!1),[c,d]=l.useState(!1),[u,h]=l.useState(!1);return l.useEffect(()=>{t==="history"&&i(!0),t==="reviews"&&d(!0),t==="settings"&&h(!0)},[t]),e.jsx("div",{className:"absolute inset-0 flex flex-col",style:{visibility:a?"visible":"hidden",pointerEvents:a?"auto":"none"},children:e.jsx(xv,{activeTab:t,width:s,children:{home:n,build:null,plan:null,history:o?e.jsx(jg,{onPreviewScreenshot:r}):null,reviews:c?e.jsx(Nm,{}):null,settings:u?e.jsx(_v,{}):null}})})}const rz=Object.freeze(Object.defineProperty({__proto__:null,EditorShellTabLayer:kv},Symbol.toStringTag,{value:"Module"}));function Sv(t){const{annotationsBySlug:n,dependenciesBySlug:s}=Nl(t),{claims:r}=wl(),{status:a}=_l(),o=l.useMemo(()=>Sl(r),[r]),i=((a==null?void 0:a.consecutiveFailures)??0)>=3;return{annotationsBySlug:n,dependenciesBySlug:s,claimsBySlug:o,staleFetch:i}}function r4(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-terminal-emulator], .xterm")}function a4(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-post-push-modal]")}function o4(t,n=!0){const s=l.useCallback(r=>{if(r.key!=="Enter"||!n||r4(r.target))return;const a=r.target===document.body||r.target===document.documentElement||r.target===document;!a4(r.target)&&!a||(r.preventDefault(),t())},[n,t]);l.useEffect(()=>(window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)),[s])}function i4(t){return[{id:"prototype",title:"Prototype",caption:`Work quickly with ${t} to prototype something before hardening the code changes in the full workflow`},{id:"plan",title:"Plan",caption:"Plan out a change in the code you want to make (e.g. a bug fix or feature request)"},{id:"chat",title:"Chat",caption:`Ask ${t} anything about the project or CodeYam`}]}function Nv({title:t,caption:n,testId:s,onClick:r,disabled:a=!1}){return e.jsxs("button",{type:"button",disabled:a,onClick:r,"data-testid":s,className:"group w-full rounded-md border border-[var(--accent-active)] bg-transparent px-4 py-3 text-left transition "+(a?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-[var(--accent-active)]"),children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--text-primary)] "+(a?"":"group-hover:text-[var(--bg-deep)]"),children:t}),e.jsx("span",{className:"mt-0.5 block text-xs text-[var(--text-dim)] "+(a?"":"group-hover:text-[var(--bg-deep)]"),children:n})]})}const az=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityCard:Nv},Symbol.toStringTag,{value:"Module"}));function Cv({providerLabel:t,onChoose:n,disabled:s=!1}){const r=i4(t);return e.jsx("div",{className:"flex flex-col gap-2","data-testid":"build-activity-menu",children:r.map(a=>e.jsx(Nv,{title:a.title,caption:a.caption,testId:`build-activity-${a.id}`,onClick:()=>n(a.id),disabled:s},a.id))})}const oz=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityMenu:Cv},Symbol.toStringTag,{value:"Module"}));function l4({mode:t,hasPlans:n}){return t==="feature-complete"?{heading:"Feature Complete!",subtitle:"Your changes have been committed and pushed. Pick what to do next."}:{heading:"What do you want to do?",subtitle:n?"Run a queued plan, or pick one of the options below.":"Pick one of the options below to get started."}}function Tv({mode:t,hasPlans:n,featureSummary:s}){if(t==="feature-complete"&&(s!=null&&s.title))return e.jsx(Eu,{summary:s});const{heading:r,subtitle:a}=l4({mode:t,hasPlans:n});return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:r}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:a})]})}const iz=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityModalHeading:Tv},Symbol.toStringTag,{value:"Module"}));function Pv({plans:t,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i,depAnnotationsBySlug:c,dependenciesBySlug:d,claimsBySlug:u,staleFetch:h}){return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-3","data-testid":"build-activity-modal-plan-list",children:e.jsx(ca,{plans:t,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i,depAnnotationsBySlug:c,dependenciesBySlug:d,claimsBySlug:u,staleFetch:h})}),e.jsxs("div",{className:"flex items-center gap-3 my-4 text-xs text-[var(--text-dim)]","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"}),e.jsx("span",{children:"or"}),e.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"})]})]})}const lz=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityPlanList:Pv},Symbol.toStringTag,{value:"Module"}));function Ov({onContinueInSession:t,onStopBuilding:n,onSendTranscript:s}){return!t&&!n&&!s?null:e.jsxs("div",{className:"mt-4 pt-3 border-t border-[var(--border-subtle)] flex flex-col gap-2","data-testid":"feature-complete-actions",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"w-full px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Continue in Current Session"}),n&&e.jsx("button",{type:"button",onClick:n,className:"w-full px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--accent-danger, #f87171)",border:"1px solid var(--accent-danger, #f87171)"},"data-testid":"post-push-stop-building",children:"Stop Building"}),s&&e.jsx("button",{type:"button",onClick:s,className:"w-full px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-dim)",border:"1px solid var(--border-default)"},children:"Send Session Feedback"})]})}const cz=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteActions:Ov},Symbol.toStringTag,{value:"Module"})),c4=300;function Av({mode:t,providerLabel:n,plans:s,onPickPlan:r,launchingSlug:a,planError:o,pendingPlansLoading:i,pendingPlansError:c,isAgentBuilding:d,featureCycleComplete:u=!1,onChooseActivity:h,onSubmitPrompt:p,submittingPrompt:m=!1,featureSummary:f,onContinueInSession:g,onStopBuilding:b,onSendTranscript:x,onMinimize:y}){const{annotationsBySlug:v,dependenciesBySlug:_,claimsBySlug:j,staleFetch:k}=Sv(s),S=t==="feature-complete",w=d&&!u,{requestRun:C,gateModals:P}=ha({dependenciesBySlug:_,claimsBySlug:j,isAgentBuilding:w,onLaunch:O=>{var E;const N=((E=s.find(I=>I.slug===O))==null?void 0:E.title)??O;r(O,N)}}),T=m||a!==null;return o4(l.useCallback(()=>h("prototype"),[h]),!T),e.jsxs("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"build-activity-modal","data-post-push-modal":!0,children:[e.jsxs("div",{className:"max-w-lg w-full mx-4 p-6 rounded-lg max-h-[85vh] overflow-y-auto",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"mb-4",children:e.jsx(su,{maxHeight:c4,testId:"build-activity-narrative",children:e.jsx(Tv,{mode:t,hasPlans:s.length>0,featureSummary:f})})}),e.jsx("div",{children:e.jsx(Pv,{plans:s,loading:i,error:c,onRun:C,launchingSlug:a,launchError:o,blocked:w,depAnnotationsBySlug:v,dependenciesBySlug:_,claimsBySlug:j,staleFetch:k})}),e.jsxs("div",{className:"border-t border-[var(--border-subtle)] pt-4 mt-1",children:[e.jsx(Cv,{providerLabel:n,onChoose:h,disabled:T}),p&&e.jsx(Au,{onSubmitPrompt:p,disabled:T}),S&&e.jsx(Ov,{onContinueInSession:g,onStopBuilding:b,onSendTranscript:x}),y&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx("button",{type:"button",onClick:y,className:"text-xs underline underline-offset-2 text-[var(--text-muted)] hover:text-[var(--text-primary)] transition cursor-pointer","data-testid":"build-activity-minimize",children:"Back to what I was doing"})})]})]}),P]})}const dz=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityModal:Av},Symbol.toStringTag,{value:"Module"}));function Rv({onReopen:t,pendingPlanCount:n=0}){return e.jsxs("button",{type:"button",onClick:t,"data-testid":"build-activity-reopen-bar",className:"absolute bottom-0 left-0 right-0 z-[55] flex items-center justify-between px-4 py-2.5 text-sm transition cursor-pointer hover:opacity-90",style:{background:"var(--bg-surface)",borderTop:"1px solid var(--border-default)",color:"var(--text-secondary)"},children:[e.jsx("span",{children:"What do you want to do?"}),e.jsxs("span",{className:"flex items-center gap-2 text-xs text-[var(--text-dim)]",children:[n>0&&e.jsxs("span",{"data-testid":"build-activity-reopen-bar-count",children:[n," queued"]}),e.jsx("span",{"aria-hidden":"true",children:"↑"})]})]})}const uz=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityReopenBar:Rv},Symbol.toStringTag,{value:"Module"}));function Ev({onCreateNewPlan:t,onContinueSession:n,onViewPlans:s}){return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},"data-testid":"plan-complete-dialog",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Plan Saved!"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Your plan has been committed. Start a fresh plan, continue this session to write a related follow-up with the current context, or head back to see the list."}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("button",{onClick:t,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"Create New Plan"}),e.jsx("button",{onClick:n,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},type:"button",children:"Continue with this planning session"}),e.jsx("button",{onClick:s,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},type:"button",children:"View Plans"})]})]})}const hz=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteDialog:Ev},Symbol.toStringTag,{value:"Module"}));function Mv({onCreateNewPlan:t,onContinueSession:n,onViewPlans:s}){return e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsx(Ev,{onCreateNewPlan:t,onContinueSession:n,onViewPlans:s})})}const pz=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteTransition:Mv},Symbol.toStringTag,{value:"Module"}));function Iv({plans:t,onSelect:n,onCancel:s,launchingSlug:r,error:a}){const[o,i]=l.useState(null),c=l.useMemo(()=>{const b={};for(const x of t)b[x.slug]=x;return b},[t]),{annotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:h,staleFetch:p}=Sv(t),{requestRun:m,gateModals:f}=ha({dependenciesBySlug:u,claimsBySlug:h,onLaunch:l.useCallback(b=>{const x=c[b];x&&n(x.slug,x.title)},[n,c])}),g=l.useCallback(b=>{if(b.key==="Escape"){b.preventDefault(),s();return}b.key==="Enter"&&t.length>0&&!r&&(b.preventDefault(),m(t[0].slug))},[r,s,m,t]);return l.useEffect(()=>(window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)),[g]),t.length===0?null:e.jsxs("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"select-plan-modal",children:[e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Select A Plan"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Pick a queued plan to run next. Its body primes the editor workflow in a fresh session."}),e.jsx("ul",{className:"flex flex-col gap-2 max-h-[50vh] overflow-y-auto mb-2",children:t.map((b,x)=>{var y,v;return e.jsx(gl,{plan:b,position:x+1,expanded:o===b.slug,onToggle:()=>i(_=>_===b.slug?null:b.slug),onRun:m,launching:r===b.slug,unsatisfiedDepCount:(y=d[b.slug])==null?void 0:y.count,unsatisfiedDepTooltip:(v=d[b.slug])==null?void 0:v.tooltip,dependencies:u[b.slug],claim:h.get(b.slug),staleFetch:p,expandedBodyVariant:"view"},b.slug)})}),a&&e.jsx(ft,{testId:"select-plan-error",text:a,className:"text-xs text-[var(--text-danger)]",rowClassName:"mb-3"}),e.jsx("button",{type:"button",onClick:s,className:"w-full px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Cancel"}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Press Enter to launch the first plan, Escape to cancel"})]}),f]})}const mz=Object.freeze(Object.defineProperty({__proto__:null,SelectPlanModal:Iv},Symbol.toStringTag,{value:"Module"}));function Lv({activeTab:t,onSendTranscript:n,appTabContent:s,awaitingPlanLaunchChoice:r,buildActivated:a,planActivated:o,buildIdle:i=!1,agentBlocked:c=!1,isAgentBuilding:d=!1,planActive:u=!1,planIdle:h=!1,bannerVisible:p=!1,onDismissIdleBanner:m,hideResultsCommandKey:f,leftWidth:g,fullWidth:b=!1,navigateToTab:x,onAgentActive:y,onAgentIdle:v,onAgentBlocked:_,onUserInput:j,notifSettings:k,onSettingsChange:S,provider:w,onContinueInSession:C,onRestorePreview:P,onResultsScenarioSelect:T,previewSlug:O=null,onStopBuilding:N,featureSummary:E,featureCycleComplete:I,showResultsCommandKey:ee,planChatOpen:B,onPlanChatOpenChange:z,showPlanCompleteModal:Y,onCreateNewPlan:te,onContinueSession:R,onViewPlans:L,pendingPlans:M,onSelectPlan:K,selectPlanOpen:ie,onPickPlan:$,onCancelSelectPlan:V,launchingPlanSlug:ae,planLaunchError:ne,prototypeLaunchSignal:me=0,planCompleteSignal:q=0,showBuildLaunchModal:le=!1,buildLaunchGateArmed:Pe=!1,buildActivity:Ce="menu",buildActivityMinimized:F=!1,chatEscalatedToPrototype:J=!1,onChooseActivity:Z,onNavigateToPlanTab:ue,onActivityDone:ve,onPrototypeLaunched:fe,onMinimizeActivityModal:se,onReopenActivityModal:Q,onSubmitBuildPrompt:ze,submittingBuildPrompt:ge=!1,buildPromptError:Ae=null,pendingPlansLoading:Te,pendingPlansError:H,onReorderPlans:G,buildDisabled:be=!1,onPreviewScreenshot:de,projectTitle:je=null}){const Ne=Z3(),Ee=I,Le=t==="build"&&!ie&&!F&&(Ee||le),He=X=>{if(X==="plan"){ue==null||ue();return}Z==null||Z(X)};return e.jsxs("div",{className:`${b?"flex-1 w-full min-w-0":"shrink-0"} flex flex-col overflow-hidden`,style:b?{background:"var(--bg-deep)"}:{width:g,background:"var(--bg-deep)"},children:[Ne&&e.jsx(ly,{projectTitle:je}),e.jsx(iy,{activeTab:t,onTabChange:x,onSendTranscript:n,buildIdle:i,agentBlocked:c,isAgentBuilding:d,planActive:u,planIdle:h,bannerVisible:p,onDismissIdleBanner:m,buildDisabled:be,showLogo:!Ne,providerLabel:Ue(w)}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.jsx(Iy,{awaitingPlanLaunchChoice:r,buildLaunchGateArmed:Pe,buildActivated:a,activeTab:t,onSelectScenario:T,previewSlug:O,showResultsCommandKey:ee,hideResultsCommandKey:f,onAgentIdle:v,onAgentBlocked:_,onAgentActive:y,onUserInput:j,notifSettings:k,onSettingsChange:S,provider:w,onRestorePreview:P,pendingPlans:M,pendingPlansLoading:Te,pendingPlansError:H,onLaunchPlan:$,launchingSlug:ae,launchError:ne,onReorderPlans:G,isAgentBuilding:d,featureCompleteActive:I,buildActivity:Ce,chatEscalatedToPrototype:J,onActivityDone:ve,onPrototypeLaunched:fe,prototypeLaunchSignal:me}),e.jsx(gv,{activeTab:t,planActivated:o,chatOpen:B,onChatOpenChange:z,isAgentBuilding:d,launchingPlanSlug:ae,planLaunchError:ne,onLaunchPlan:$,planCompleteSignal:q}),e.jsx(kv,{activeTab:t,appTabContent:s,leftWidth:g,onPreviewScreenshot:de}),ie&&t==="build"?e.jsx(Iv,{plans:M,onSelect:$,onCancel:V,launchingSlug:ae,error:ne}):null,Le?e.jsx(Av,{mode:Ee?"feature-complete":"cold",providerLabel:Ue(w),plans:M,onPickPlan:$,launchingSlug:ae,planError:ne,pendingPlansLoading:Te,pendingPlansError:H,isAgentBuilding:d,featureCycleComplete:I,onChooseActivity:He,onSubmitPrompt:ze,submittingPrompt:ge,featureSummary:E,onContinueInSession:Ee?C:void 0,onStopBuilding:Ee?N:void 0,onSendTranscript:Ee?n:void 0,onMinimize:se}):null,F&&t==="build"&&Q?e.jsx(Rv,{onReopen:Q,pendingPlanCount:M.length}):null,Y&&t==="plan"?e.jsx(Mv,{onCreateNewPlan:te,onContinueSession:R,onViewPlans:L}):null]})]})}const fz=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLeftPane:Lv},Symbol.toStringTag,{value:"Module"}));async function jd(t,n=null){try{const s={pid:t};n&&(s.url=n),await fetch("/api/editor-iframe-loaded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch{}}async function d4(t){try{await fetch("/api/editor-iframe-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({error:t})})}catch{}}async function u4(t){try{await fetch("/api/editor-iframe-banner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seedError:t})})}catch{}}async function h4(t){try{await fetch("/api/editor-iframe-auth-needed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({previewOrigin:t})})}catch{}}async function p4(t){try{await fetch("/api/editor-preview-escape",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({escapedPath:t})})}catch{}}function m4(t,n,s,r,a){const o=t-a*2,i=n-a*2;return o<=0||i<=0?1:Math.min(1,o/s,i/r)}const f4=32;function g4({currentHeight:t,currentWidth:n,isFilled:s}){const[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(h=>{const p=h.getBoundingClientRect();a({width:p.width,height:p.height})},[]),d=l.useCallback(h=>{if(o.current&&(o.current.disconnect(),o.current=null),i.current=h,!h){a(null);return}c(h);const p=new ResizeObserver(()=>{const m=i.current;m&&c(m)});p.observe(h),o.current=p},[c]),u=s||!r?1:m4(r.width,r.height,n,t,f4);return{containerRef:d,containerSize:r,scale:u}}const b4={kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!1},wd=[400,800,1500,3e3];function Dv(){const[t,n]=l.useState({kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!0});return l.useEffect(()=>{let s=!1,r,a=0;const o=()=>{const d=wd[Math.min(a,wd.length-1)];a+=1,r=setTimeout(c,d)},i=()=>{n(d=>d.loading?b4:d),o()},c=()=>{fetch("/api/project-stack").then(d=>d.ok?d.json():{}).then(d=>{s||(x4(d)?n(y4(d)):i())}).catch(()=>{s||i()})};return c(),()=>{s=!0,r&&clearTimeout(r)}},[]),t}function x4(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length>0}function y4(t){const n=t&&typeof t=="object"&&"preview"in t?t.preview:null;if(!n||typeof n!="object")return{kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!1};const s=n;return{kind:v4(s.kind),fallbackKind:j4(s.fallbackKind),fallbackPort:typeof s.fallbackPort=="number"?s.fallbackPort:null,loading:!1}}function v4(t){return t==="simulator-ios"?"simulator-ios":t==="simulator-android"?"simulator-android":"iframe"}function j4(t){return t==="iframe"||t==="simulator-ios"||t==="simulator-android"?t:null}const w4="codeyam:client-routing-detected";function _4(t){const[n,s]=l.useState(!1);return l.useEffect(()=>{if(!t)return;function r(a){var o;a.origin===window.location.origin&&((o=a.data)==null?void 0:o.type)===w4&&s(!0)}return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[t]),n}const k4=700;function Fv({pollMs:t=k4,paused:n=!1,onError:s}={}){const[r,a]=l.useState(0),[o,i]=l.useState({kind:"loading"}),c=l.useRef(s);return c.current=s,l.useEffect(()=>{if(n)return;let d=!1;const u=window.setInterval(()=>{d||a(h=>h+1)},t);return()=>{d=!0,window.clearInterval(u)}},[t,n]),l.useEffect(()=>{if(n)return;let d=!1;return fetch(`/api/simulator-frame?t=${r}`,{method:"HEAD"}).then(async u=>{var p;if(d)return;if(u.ok){i({kind:"ok"});return}if(u.status===503){const m=await S4(u);if(d)return;(typeof(m==null?void 0:m.error)=="string"?m.error:"").includes("xcode")?i({kind:"xcode-missing"}):i({kind:"no-device"});return}const h=`simulator frame request failed (${u.status})`;i({kind:"capture-failed",message:h}),(p=c.current)==null||p.call(c,h)}).catch(u=>{var p;if(d)return;const h=u instanceof Error?u.message:"simulator frame request errored";i({kind:"capture-failed",message:h}),(p=c.current)==null||p.call(c,h)}),()=>{d=!0}},[r,n]),{state:o,isBooted:o.kind==="ok",frameToken:r}}async function S4(t){try{return await t.json()}catch{return null}}function N4(t,n){const s=(t==null?void 0:t.screenshotPaths)??[];if(s.length===0)return null;if(n){const r=`--${n.toLowerCase()}.png`,a=s.find(o=>o.toLowerCase().endsWith(r));if(a)return a}return s[0]??null}function C4(t,n,s){switch(t){case 1:case 2:return"Setting up...";case 3:return`Building — ${n} files modified, ${s} tests modified`;case 4:return"Verifying — running tests...";case 5:return"Ready for review";case 6:return"Refactoring...";case 7:case 8:return"Finalizing...";case 9:return"Ready for approval";case 10:return"Complete";default:return""}}async function No(){const t=Date.now();try{const n=await fetch("/api/editor-session-summary"),s=Date.now()-t;return n.ok?{ok:!0,data:await n.json(),statusCode:n.status,durationMs:s,error:null}:{ok:!1,data:null,statusCode:n.status,durationMs:s,error:`HTTP ${n.status}`}}catch(n){return{ok:!1,data:null,statusCode:null,durationMs:Date.now()-t,error:n instanceof Error?n.message:String(n)}}}const T4=50,P4={status:"loading",lastSuccessAt:null,lastErrorAt:null,lastErrorMessage:null,fetchCount:0,errorCount:0};function O4(t,n,s){return{status:n.ok?"connected":"disconnected",lastSuccessAt:n.ok?s:t.lastSuccessAt,lastErrorAt:n.ok?t.lastErrorAt:s,lastErrorMessage:n.ok?t.lastErrorMessage:n.error,fetchCount:t.fetchCount+1,errorCount:t.errorCount+(n.ok?0:1)}}function A4(t,n){return{timestamp:n,success:t.ok,statusCode:t.statusCode,durationMs:t.durationMs,error:t.error}}function R4(t,n){return[n,...t].slice(0,T4)}function E4(){const[t,n]=l.useState(P4),[s,r]=l.useState([]),a=l.useCallback(i=>{const c=Date.now();r(d=>R4(d,A4(i,c))),n(d=>O4(d,i,c))},[]),o=l.useCallback(()=>{n(i=>({...i,status:"polling"}))},[]);return{connectionState:t,fetchLog:s,recordFetch:a,markPolling:o}}async function M4(t){try{const r=await fetch("/api/test-results");if(r.ok&&(await r.json()).running)return{kind:"busy"}}catch{}const n={tests:[t.name]};t.file&&(n.changedFiles=[t.file]);let s;try{s=await fetch("/api/test-results/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch(r){return{kind:"error",message:r instanceof Error?r.message:String(r)}}if(s.ok)return{kind:"accepted"};try{const r=await s.json();if(typeof r.message=="string"&&r.message.trim())return{kind:"error",message:r.message}}catch{}return{kind:"error",message:`Couldn't start the run (HTTP ${s.status}).`}}function I4(t,n){if(!t.narrative)return null;for(const s of t.narrative.changes)for(const r of s.tests)if(r.name===n)return{lastRunAt:r.lastRunAt,status:r.status??"unknown"};return null}async function L4(t,n,s){const r=s.intervalMs??2e3,a=s.nowMs??(()=>Date.now()),o=s.sleep??(c=>new Promise(d=>setTimeout(d,c))),i=a()+s.timeoutMs;for(;;){const c=await No();if(c.ok&&c.data){const d=I4(c.data,t.name);if(d!=null&&d.lastRunAt&&Date.parse(d.lastRunAt)>n)return{kind:"completed",status:d.status,summary:c.data}}if(a()>=i)return{kind:"timeout"};await o(r)}}function D4(t){return!t||t<=0?3e4:Math.max(3e4,t*2)}function F4({onSummaryUpdate:t,getLastDurationMs:n}){const[s,r]=l.useState(null),a=l.useCallback(o=>{const i=o.name;r({name:i,state:{phase:"verifying"}});const c=Date.now();(async()=>{const d=await M4(o);if(d.kind==="busy"){r({name:i,state:{phase:"busy"}});return}if(d.kind==="error"){r({name:i,state:{phase:"error",message:d.message}});return}const u=D4(n()),h=await L4(o,c,{timeoutMs:u});h.kind==="completed"?(t(h.summary),r(null)):r({name:i,state:{phase:"timeout"}})})()},[t,n]);return{active:s,onRerun:a}}function z4(t){switch(t.status){case"connected":return{dotClass:"bg-green-500",label:"Connected",labelClass:"text-green-400"};case"polling":return{dotClass:"bg-yellow-400 animate-pulse",label:"Polling...",labelClass:"text-yellow-400"};case"disconnected":return{dotClass:"bg-red-500",label:"Disconnected",labelClass:"text-red-400"};case"loading":default:return{dotClass:"bg-[var(--text-muted)]",label:"Connecting...",labelClass:"text-[var(--text-muted)]"}}}function zv({state:t}){const n=An(),{dotClass:s,label:r,labelClass:a}=z4(t);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium","data-testid":"connection-status-badge",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s}`,"data-testid":"connection-status-dot"}),e.jsx("span",{className:a,"data-testid":"connection-status-label",children:r}),t.lastSuccessAt!=null&&e.jsxs("span",{className:"text-[var(--text-muted)]","data-testid":"connection-status-updated",children:["Updated ",Ya(t.lastSuccessAt,n)]})]})}const gz=Object.freeze(Object.defineProperty({__proto__:null,BackendConnectionStatusBadge:zv},Symbol.toStringTag,{value:"Module"}));function $v({feature:t,connectionState:n,statusChip:s,userPrompt:r}){return e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:[e.jsx("h1",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:t||"Working Session Results"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx(zv,{state:n}),s&&e.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)] rounded-full","data-testid":"status-chip",children:s})]}),r&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]","data-testid":"user-prompt-section",children:[e.jsx("div",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wide",children:"Your request"}),e.jsx("div",{className:"mt-2 bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded-md p-3",children:e.jsx(Wr,{maxHeight:90,moreLabel:"View More",lessLabel:"View Less",fadeColor:"var(--bg-input)",children:r})})]})]})}const bz=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsHeader:$v},Symbol.toStringTag,{value:"Module"}));function $4(t,n,s=[]){var r;return{headline:(r=t.description)!=null&&r.trim()?t.description:t.name,name:t.name,file:t.file,status:t.status??"unknown",failureMessage:t.failureMessage,change:n.title,lastRunAt:t.lastRunAt,lastRunKind:t.lastRunKind,recentStatuses:t.recentStatuses,exercises:s.filter(a=>a.tests.some(o=>vl(o)===t.name)),example:t.example}}function Bv(t,n=[]){const s=[],r=[];let a=0;for(const o of t.tests){if(o.verified===!1){a+=1;continue}const i=$4(o,t,n);i.status==="passing"?s.push(i):r.push(i)}return{worksNow:s,inProgress:r,unverifiedCount:a}}function B4(t,n=[]){const s=[],r=[];let a=0;for(const o of t.changes){const i=Bv(o,n);s.push(...i.worksNow),r.push(...i.inProgress),a+=i.unverifiedCount}return{worksNow:s,inProgress:r,unverifiedCount:a}}function H4(t){if(!t||t.length<2)return!1;const n=t.some(r=>r.status==="pass"),s=t.some(r=>r.status==="fail");return n&&s}function q4(t){if(t==null||t===0)return"";const n=Math.abs(t),s=t>0?"slower":"faster";return`${n}s ${s} than the previous run`}function Hv({status:t}){switch(t){case"passing":return e.jsx("span",{className:"text-green-500 text-xs mt-0.5 shrink-0",children:"✓"});case"failing":return e.jsx("span",{className:"text-red-500 text-xs mt-0.5 shrink-0",children:"✗"});case"running":return e.jsx("span",{className:"text-[#D7FF63] text-xs mt-0.5 shrink-0 animate-spin",children:"◠"});default:return e.jsx("span",{className:"text-gray-400 text-xs mt-0.5 shrink-0",children:"●"})}}const xz=Object.freeze(Object.defineProperty({__proto__:null,NarrativeTestStatusIcon:Hv},Symbol.toStringTag,{value:"Module"})),_d="font-mono text-[11px] text-[var(--text-primary)] whitespace-pre-wrap break-words min-w-0",kd="w-0 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] align-top pr-3 py-1 whitespace-nowrap";function qv({example:t}){return e.jsxs("div",{"data-testid":"behavior-example",children:[e.jsx("table",{className:"w-full border-collapse",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{className:kd,children:"Input"}),e.jsx("td",{className:`${_d} py-1`,"data-testid":"example-input",children:t.input})]}),e.jsxs("tr",{children:[e.jsx("td",{className:kd,children:"Output"}),e.jsx("td",{className:`${_d} py-1`,"data-testid":"example-output",children:t.output})]})]})}),t.note&&e.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1 mb-0 italic","data-testid":"example-note",children:t.note})]})}const yz=Object.freeze(Object.defineProperty({__proto__:null,BehaviorExampleTable:qv},Symbol.toStringTag,{value:"Module"})),W4="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function G4(t){switch(t.phase){case"busy":return"Tests are already running — try again once they finish.";case"error":return t.message;case"timeout":return"Couldn't confirm — check test results.";default:return null}}function Wv({rerun:t={phase:"idle"},onRerun:n,disabled:s=!1,disabledReason:r}){const a=t.phase==="verifying",o=t.phase==="error",i=s||a,c=s&&r||G4(t);return e.jsxs("div",{"data-testid":"evidence-rerun",children:[e.jsx("div",{className:W4,children:"Re-run"}),e.jsxs("button",{type:"button",onClick:n,disabled:i,title:s?r:void 0,"aria-busy":a,"data-testid":"rerun-button",className:"inline-flex items-center gap-1.5 text-[11px] px-2 py-1 rounded border border-[var(--border-default)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--text-muted)] disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:[a&&e.jsx("span",{className:"inline-block w-3 h-3 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full animate-spin"}),a?"Verifying…":"Re-run this test"]}),c&&e.jsx("p",{className:`text-[11px] mt-1 m-0 ${o?"text-red-600":"text-[var(--text-muted)]"}`,"data-testid":"rerun-note",children:c})]})}const vz=Object.freeze(Object.defineProperty({__proto__:null,RerunSection:Wv},Symbol.toStringTag,{value:"Module"}));function U4(t){return t==="passing"?"passed":t==="failing"?"failed":"ran"}function V4(t){switch(t){case"full":return"full run";case"changed":return"changed-files run";case"targeted":return"targeted run"}}function Gv(t){var r;const n=t.status==="failing"&&!!t.failureMessage,s=(((r=t.recentStatuses)==null?void 0:r.length)??0)>0;return!!t.lastRunAt||t.exercises.length>0||n||!!t.example||s}const cs="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function Uv({behavior:t,rerun:n={phase:"idle"},onRerun:s,disabled:r=!1,disabledReason:a}){const o=An(),i=t.status==="failing"&&!!t.failureMessage;return e.jsxs("div",{className:"mt-2 ml-5 space-y-3","data-testid":"behavior-evidence-drawer",children:[t.lastRunAt&&e.jsxs("div",{"data-testid":"evidence-verified",children:[e.jsx("div",{className:cs,children:"Verified"}),e.jsxs("p",{className:"text-[11px] text-[var(--text-secondary)] m-0",children:[U4(t.status)," ",Ya(Date.parse(t.lastRunAt),o),t.lastRunKind&&e.jsxs("span",{className:"text-[var(--text-muted)]",children:[" (",V4(t.lastRunKind),")"]})]})]}),t.example&&e.jsxs("div",{"data-testid":"evidence-example",children:[e.jsx("div",{className:cs,children:"Example"}),e.jsx(qv,{example:t.example})]}),t.recentStatuses&&t.recentStatuses.length>0&&e.jsxs("div",{"data-testid":"evidence-recent-runs",children:[e.jsx("div",{className:cs,children:"Recent runs"}),e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:[...t.recentStatuses].reverse().map((c,d)=>e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${c.status==="pass"?"bg-green-500":c.status==="fail"?"bg-red-500":"bg-[var(--text-dim)]"}`,title:`${c.status} · ${Ya(Date.parse(c.at),o)}`,"data-testid":`recent-run-dot-${c.status}`},`${c.at}-${d}`))})]}),t.exercises.length>0&&e.jsxs("div",{"data-testid":"evidence-exercises",children:[e.jsx("div",{className:cs,children:"Exercises"}),e.jsx("ul",{className:"list-none p-0 m-0 space-y-1",children:t.exercises.map(c=>e.jsxs("li",{className:"text-[11px] text-[var(--text-secondary)] flex items-center gap-x-1.5",children:[e.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:c.name}),e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsx("span",{className:"font-mono text-[var(--text-dim)] min-w-0 truncate",children:c.filePath}),c.coverage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[Math.round(c.coverage.percent),"% covered"]})]})]},c.name))})]}),i&&e.jsxs("div",{"data-testid":"evidence-failure",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:cs,children:"Failure"}),e.jsx(at,{variant:"subtle",text:t.failureMessage??"",label:"Copy",className:"shrink-0 px-2 py-0.5 text-[11px] font-medium rounded border border-red-200 text-red-700 hover:bg-red-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"})]}),e.jsx("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-[11px] font-mono text-red-700 whitespace-pre-wrap overflow-x-auto","data-testid":"failure-message",children:t.failureMessage})]}),e.jsx(Wv,{rerun:n,onRerun:s,disabled:r,disabledReason:a})]})}const jz=Object.freeze(Object.defineProperty({__proto__:null,BehaviorEvidenceDrawer:Uv,hasDrawerContent:Gv},Symbol.toStringTag,{value:"Module"}));function Vv({behavior:t,rerun:n}){var h,p;const[s,r]=l.useState(!1),a=Gv(t),o=H4(t.recentStatuses),i=((h=n==null?void 0:n.active)==null?void 0:h.name)===t.name,c=i?n.active.state:{phase:"idle"},d=c.phase==="verifying",u=((p=n==null?void 0:n.active)==null?void 0:p.state.phase)==="verifying"&&!i;return e.jsx("div",{"data-testid":"behavior-item",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Hv,{status:d?"running":t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-[var(--text-primary)] leading-relaxed",children:[t.headline,o&&e.jsx("span",{className:"ml-1.5 align-middle inline-block px-1.5 py-0.5 rounded text-[10px] font-medium text-[var(--text-muted)] bg-[var(--bg-surface)] border border-[var(--border-default)]",title:"Recent runs mix passes and failures — this behavior is intermittently failing","data-testid":"flaky-chip",children:"flaky?"})]}),e.jsxs("div",{className:"flex items-center gap-x-1.5 mt-1 text-[11px]",children:[e.jsx("span",{className:"text-[var(--text-muted)] font-mono min-w-0 truncate",children:t.name}),t.file&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),e.jsx("span",{className:"text-[var(--text-dim)] font-mono min-w-0 truncate",children:t.file})]}),t.change&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),e.jsx("span",{className:"text-[var(--text-muted)] opacity-70 shrink-0",children:t.change})]})]})]}),a&&e.jsx("button",{className:"shrink-0 text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer text-[10px] leading-none mt-1 px-1",onClick:()=>r(!s),"aria-expanded":s,"aria-label":s?"Hide evidence":"Show evidence","data-testid":"toggle-evidence-drawer",children:s?"▾":"▸"})]}),a&&s&&e.jsx(Uv,{behavior:t,rerun:c,onRerun:n?()=>n.onRerun(t):void 0,disabled:u,disabledReason:"Verifying another behavior…"})]})]})})}const wz=Object.freeze(Object.defineProperty({__proto__:null,BehaviorItem:Vv},Symbol.toStringTag,{value:"Module"}));function Co({label:t,behaviors:n,tone:s,rerun:r}){if(n.length===0)return null;const a=s==="positive"?"text-green-500":"text-[var(--text-secondary)]";return e.jsxs("section",{className:"space-y-3","data-testid":"behavior-group",children:[e.jsxs("h2",{className:`text-xs font-semibold uppercase tracking-wide m-0 ${a}`,"data-testid":"behavior-group-heading",children:[t," (",n.length,")"]}),e.jsx("div",{className:"space-y-4",children:n.map(o=>e.jsx(Vv,{behavior:o,rerun:r},`${o.change}:${o.name}`))})]})}const _z=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGroup:Co},Symbol.toStringTag,{value:"Module"}));function Pl({ways:t}){return t.length===0?null:e.jsxs("div",{className:"space-y-1.5","data-testid":"ways-to-test",children:[e.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0",children:"Ways to test"}),e.jsx("ul",{className:"list-disc pl-4 space-y-1 m-0",children:t.map((n,s)=>e.jsx("li",{className:"text-sm leading-relaxed","data-testid":"way-to-test",children:Y4(n)},s))})]})}function Y4(t){return t.kind==="run-scenario"&&t.scenarioUrl?e.jsxs("a",{href:t.scenarioUrl,target:"_blank",rel:"noopener",className:"text-[var(--accent-blue)] hover:underline inline-flex items-center gap-1","data-testid":"way-to-test-scenario-link",children:[t.text,e.jsx("span",{"aria-hidden":"true",className:"text-[10px] opacity-70",children:"↗ open in dev app"})]}):t.kind==="staging-only"?e.jsx("span",{className:"text-[var(--text-muted)] italic","data-testid":"way-to-test-staging-only",children:t.text}):e.jsx("span",{className:"text-[var(--text-primary)]",children:t.text})}const kz=Object.freeze(Object.defineProperty({__proto__:null,WaysToTestList:Pl},Symbol.toStringTag,{value:"Module"}));function Yv({change:t,functions:n=[],rerun:s}){const{worksNow:r,inProgress:a}=Bv(t,n);return e.jsxs("section",{className:"space-y-3 pt-4 border-t border-[var(--border-subtle)]","data-testid":"change-card",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] leading-relaxed m-0",children:t.description}),e.jsx(Pl,{ways:t.waysToTest??[]}),e.jsx(Co,{label:"Works now",behaviors:r,tone:"positive",rerun:s}),e.jsx(Co,{label:"In progress",behaviors:a,tone:"pending",rerun:s})]})}const Sz=Object.freeze(Object.defineProperty({__proto__:null,ChangeCard:Yv},Symbol.toStringTag,{value:"Module"}));function Kv({narrative:t,functions:n=[],rerun:s}){const{unverifiedCount:r}=B4(t,n);return e.jsxs("div",{className:"space-y-6","data-testid":"behavior-gallery",children:[t.summary&&e.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-relaxed m-0",children:t.summary}),t.changes.map((a,o)=>e.jsx(Yv,{change:a,functions:n,rerun:s},`${a.title}:${o}`)),r>0&&e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)] m-0","data-testid":"unverified-footnote",children:[r," test",r===1?"":"s"," not yet found in source."]})]})}const Nz=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGallery:Kv},Symbol.toStringTag,{value:"Module"}));function Jv({step:t}){return e.jsx("div",{className:"text-sm text-[var(--text-muted)]","data-testid":"behavior-gallery-empty",children:e.jsx("span",{"data-testid":"behavior-gallery-prebuild",children:"The build will describe what it’s creating here as it works."})})}const Cz=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGalleryEmptyState:Jv},Symbol.toStringTag,{value:"Module"}));function K4(t){const n=t.trim();if(n==="??")return"New";switch(n.replace(/\s/g,"").charAt(0)){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"R":return"Renamed";case"C":return"Copied";case"U":return"Unmerged";case"T":return"Type changed";default:return n||t}}function Xv({path:t,status:n,testid:s}){return e.jsxs("li",{className:"flex items-center gap-2","data-testid":s,children:[e.jsx("span",{className:"font-mono text-[var(--text-primary)] truncate",children:t}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)] shrink-0",children:K4(n)})]})}const Tz=Object.freeze(Object.defineProperty({__proto__:null,BuildFileRow:Xv},Symbol.toStringTag,{value:"Module"}));function Qv({feature:t,modifiedFiles:n,functions:s,waysToTestBaseline:r,step:a}){const o=new Set(s.map(u=>u.filePath)),i=n.filter(u=>!o.has(u.path)),c=(()=>{const u=new Map;for(const h of s.flatMap(p=>p.tests)){const p=vl(h);if(!p)continue;const m=UP(h),f=u.get(p);f?f.description===void 0&&m!==void 0&&(f.description=m):u.set(p,{name:p,description:m})}return Array.from(u.values())})(),d=a>=4;return e.jsxs("div",{className:"text-sm space-y-5","data-testid":"build-progress-detail",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-[var(--accent-blue)] animate-pulse","aria-hidden":"true"}),e.jsx("span",{className:"text-[var(--text-primary)] font-medium",children:t?`Building ${t}…`:"Building…"})]}),e.jsxs("section",{"data-testid":"build-areas-changed",children:[e.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0 mb-1.5",children:"Areas being changed"}),s.length===0&&n.length===0?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Gathering changes…"}):e.jsxs("div",{className:"space-y-3",children:[s.length>0&&e.jsx("ul",{className:"list-none pl-0 m-0 space-y-2",children:s.map(u=>e.jsx("li",{children:e.jsx(jl,{fn:u,testid:"build-area-function"})},`${u.filePath}::${u.name}`))}),i.length>0&&e.jsxs("div",{children:[s.length>0&&e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-muted)] mb-1",children:"Other files"}),e.jsx("ul",{className:"list-none pl-0 m-0 space-y-0.5",children:i.map(u=>e.jsx(Xv,{path:u.path,status:u.status,testid:"build-area-file"},u.path))})]})]})]}),e.jsxs("section",{"data-testid":"build-tests",children:[e.jsxs("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0 mb-1.5",children:["Tests validating the change",c.length>0&&e.jsxs("span",{className:"ml-1 text-[var(--text-muted)] font-normal normal-case tracking-normal",children:["(",c.length,")"]})]}),c.length===0?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Tests will appear here as they’re written."}):e.jsx("ul",{className:"list-none pl-0 m-0 space-y-1",children:c.map(u=>e.jsxs("li",{"data-testid":"build-test-name",children:[e.jsx("div",{className:"font-mono text-xs text-[var(--text-primary)]",children:u.name}),u.description&&e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:u.description})]},u.name))})]}),e.jsxs("section",{"data-testid":"build-ways-to-test",children:[e.jsx(Pl,{ways:r??[]}),e.jsx("div",{className:"mt-1.5 text-xs text-[var(--text-muted)] italic",children:d?"Detailed ways to test appear once the build finishes verifying.":"Detailed ways to test appear once the build finishes."})]})]})}const Pz=Object.freeze(Object.defineProperty({__proto__:null,BuildProgressDetail:Qv},Symbol.toStringTag,{value:"Module"}));function J4(t){return t.filter(Boolean).join(" · ")}function X4(t){if(!t)return"";const n=Math.round(t.global.percent);if(t.previousGlobal==null)return`coverage ${n}%`;const s=Math.round(t.global.percent-t.previousGlobal);if(s===0)return`coverage ${n}% (±0)`;const r=s>0?"+":"−";return`coverage ${n}% (${r}${Math.abs(s)})`}function Zv({stats:t,thresholds:n,trendDeltaSecs:s}){if(!t)return null;const r=t.runners.length||t.per_runner.length,a=t.per_runner.filter(i=>i.duration_ms!=null).map(i=>`${i.name} ${Math.round(i.duration_ms/1e3)}s`),o=J4([`${r} runner${r===1?"":"s"}`,`${t.passed} passed`,t.failed>0?`${t.failed} failed`:"",...a,X4(n),q4(s)]);return e.jsx("p",{className:"text-[11px] text-[var(--text-muted)] font-mono m-0","data-testid":"run-evidence-line",children:o})}const Oz=Object.freeze(Object.defineProperty({__proto__:null,RunEvidenceLine:Zv},Symbol.toStringTag,{value:"Module"})),Q4=5e3;function ej(){const[t,n]=l.useState(null),[s,r]=l.useState(!0),{connectionState:a,recordFetch:o,markPolling:i}=E4(),c=l.useRef(null),d=l.useRef(null);d.current=t;const u=F4({onSummaryUpdate:n,getLastDurationMs:l.useCallback(()=>{var f,g;return(g=(f=d.current)==null?void 0:f.testRunnerStats)==null?void 0:g.duration_ms},[])});if(l.useEffect(()=>{async function f(){const g=await No();o(g),g.ok&&g.data&&n(g.data),r(!1)}return f(),()=>{c.current&&clearInterval(c.current)}},[o]),l.useEffect(()=>(c.current&&(clearInterval(c.current),c.current=null),(t==null?void 0:t.live)===!0&&(c.current=setInterval(async()=>{i();const f=await No();o(f),f.ok&&f.data&&n(f.data)},Q4)),()=>{c.current&&clearInterval(c.current)}),[t==null?void 0:t.live,o,i]),s)return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center",children:e.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!t)return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center text-[var(--text-muted)] text-sm",children:"No session data available."});const h=t.step??0,p=t.functions.reduce((f,g)=>f+g.tests.length,0),m=C4(h,t.modifiedFiles.length,p);return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] p-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsx($v,{feature:t.feature,connectionState:a,statusChip:m,userPrompt:t.userPrompt}),e.jsx(Zv,{stats:t.testRunnerStats,thresholds:t.coverageThresholds,trendDeltaSecs:t.suiteTrendDeltaSecs}),e.jsx("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:t.narrative?e.jsx(Kv,{narrative:t.narrative,functions:t.functions,rerun:u}):h>=3?e.jsx(Qv,{feature:t.feature,modifiedFiles:t.modifiedFiles,functions:t.functions,waysToTestBaseline:t.waysToTestBaseline,step:h}):e.jsx(Jv,{step:h})})]})})}const Az=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPage:ej},Symbol.toStringTag,{value:"Module"}));function tj(){return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx(ej,{})})}const Rz=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPanelView:tj},Symbol.toStringTag,{value:"Module"}));function nj({onClose:t,providerLabel:n}){const[s,r]=l.useState(""),a=l.useRef(null);return l.useEffect(()=>{var o;(o=a.current)==null||o.focus()},[]),l.useEffect(()=>{const o=i=>{i.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onMouseDown:o=>{o.target===o.currentTarget&&t()},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-1",children:"Create New State"}),e.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Describe the state you want ",n," to build."]}),e.jsx("textarea",{ref:a,value:s,onChange:o=>r(o.target.value),placeholder:"e.g. Empty inbox with a friendly empty-state illustration",rows:5,className:"w-full px-3 py-2 text-sm rounded mb-4 resize-none focus:outline-none",style:{background:"var(--bg-input)",border:"1px solid var(--border-default)",color:"var(--text-primary)"}}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-md text-sm transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Cancel"}),e.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"px-4 py-2 rounded-md text-sm font-medium opacity-50 cursor-not-allowed",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},children:["Send to ",n]})]})]})})}const Ez=Object.freeze(Object.defineProperty({__proto__:null,CreateStatePlaceholderModal:nj},Symbol.toStringTag,{value:"Module"}));function sj({dragActive:t,inputRef:n,folderInputRef:s,onDragOver:r,onDragLeave:a,onDrop:o,onFilePick:i,onFolderPick:c}){return e.jsxs(e.Fragment,{children:[e.jsxs("label",{onDragOver:r,onDragLeave:a,onDrop:o,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"var(--spacing-xl, 32px)",border:`2px dashed ${t?"var(--accent-active)":"var(--border-default)"}`,borderRadius:12,background:t?"var(--bg-elevated, rgba(255,255,255,0.03))":"var(--bg-input)",cursor:"pointer",textAlign:"center",gap:"var(--spacing-xs, 4px)"},children:[e.jsx("input",{ref:n,type:"file",multiple:!0,onChange:i,style:{display:"none"}}),e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500},children:"Drop files or a folder here, or click to choose files"}),e.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"PNG, JPG, PDF, Markdown — anything that describes your design"})]}),e.jsx(eh,{fileInputRef:n,folderInputRef:s,onFolderPick:c})]})}const Mz=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropLabel:sj},Symbol.toStringTag,{value:"Module"}));function rj({pending:t,onDescriptionChange:n,onRemove:s}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px)",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-input)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500,overflowWrap:"anywhere"},children:t.relativePath}),e.jsx("button",{type:"button",onClick:()=>s(t.id),style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:"Remove"})]}),e.jsx("textarea",{value:t.description,onChange:r=>n(t.id,r.target.value),placeholder:"What does this file show? (optional)",rows:2,style:{width:"100%",padding:"var(--spacing-sm, 8px)",background:"var(--bg-default)",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-primary)",fontSize:"var(--text-xs, 12px)",resize:"vertical",outline:"none",fontFamily:"inherit"}})]})}const Iz=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCard:rj},Symbol.toStringTag,{value:"Module"}));function aj({pending:t,onDescriptionChange:n,onRemove:s}){return t.length===0?null:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)",marginTop:"var(--spacing-md, 12px)"},children:[e.jsx(Qu,{count:t.length}),t.map(r=>e.jsx(rj,{pending:r,onDescriptionChange:n,onRemove:s},r.id))]})}const Lz=Object.freeze(Object.defineProperty({__proto__:null,PendingFileList:aj},Symbol.toStringTag,{value:"Module"}));function Z4(t){return new Promise(n=>{t.file(s=>n(s),()=>n(null))})}function eO(t){return new Promise(n=>{const s=[],r=()=>{t.readEntries(a=>{if(a.length===0){n(s);return}s.push(...a),r()},()=>n(s))};r()})}function tO(t){return t.split("/").some(n=>n.startsWith("."))}async function oj(t,n,s){if(t.name.startsWith("."))return 0;const r=n?`${n}/${t.name}`:t.name;if(t.isFile){const a=await Z4(t);return a?(s.push({file:a,relativePath:r}),0):1}if(t.isDirectory){const a=await eO(t.createReader());let o=0;for(const i of a)o+=await oj(i,r,s);return o}return 0}async function nO(t){const n=t.items;if(!(!!n&&n.length>0&&typeof n[0].webkitGetAsEntry=="function"))return{files:Array.from(t.files).map(i=>({file:i,relativePath:i.name})),skipped:0,expandedViaEntryApi:!1};const r=[];for(const i of Array.from(n)){const c=i.webkitGetAsEntry();c&&r.push(c)}const a=[];let o=0;for(const i of r)o+=await oj(i,"",a);return{files:a,skipped:o,expandedViaEntryApi:!0}}function sO(t){return Array.from(t).map(n=>({file:n,relativePath:n.webkitRelativePath||n.name})).filter(({relativePath:n})=>!tO(n))}function rO(t){return t.size===0&&t.type===""}const aO="Folders can't be read in this browser — open the folder and drop the files inside it.";function oO(t,n,s){const r=[];let a=null;for(const o of t){if(!n&&rO(o.file)){a=aO;continue}if(o.file.size>s){a=`${o.relativePath} is larger than the ${s/(1024*1024*1024)}GB safety ceiling`;continue}r.push(o)}return{valid:r,rejection:a}}function iO(t){const{files:n,skipped:s,expandedViaEntryApi:r}=t;return s>0&&n.length===0?"Couldn't read any of the files in that folder.":n.length===0&&r?"No files found in that folder.":s>0?`${s} item(s) couldn't be read and were skipped.`:null}async function lO(t){const n=new FormData;for(const a of t)n.append("path",a.relativePath),n.append("description",a.description),n.append("file",a.file,a.file.name);const s=await fetch("/api/editor-design-assets",{method:"POST",body:n});if(!s.ok)throw new Error(s.status===413?"That file is too large to add.":`Could not save assets (status ${s.status}).`);return(await s.json()).written??t.map(a=>a.relativePath)}function ij({message:t}){return t?e.jsx("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-xs, 12px)"},children:t}):null}const Dz=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveErrorMessage:ij},Symbol.toStringTag,{value:"Module"}));function lj({filenames:t}){return!t||t.length===0?null:e.jsxs("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--text-secondary)",fontSize:"var(--text-xs, 12px)"},children:["Added ",t.length," file",t.length===1?"":"s","."]})}const Fz=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveSuccessMessage:lj},Symbol.toStringTag,{value:"Module"}));function cj({disabled:t,submitting:n,onClick:s}){return e.jsx("button",{type:"button",onClick:s,disabled:t,style:{marginTop:"var(--spacing-md, 12px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",background:t?"var(--bg-input)":"var(--accent-active)",color:t?"var(--text-muted)":"var(--text-on-accent, white)",border:t?"1px solid var(--border-default)":"1px solid var(--accent-active)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontWeight:500,cursor:t?"not-allowed":"pointer"},children:n?"Saving…":"Save assets"})}const zz=Object.freeze(Object.defineProperty({__proto__:null,SaveAssetsButton:cj},Symbol.toStringTag,{value:"Module"})),cO=1024*1024*1024;function dj({onAssetsSaved:t}){const[n,s]=l.useState([]),[r,a]=l.useState(!1),[o,i]=l.useState(null),[c,d]=l.useState(null),[u,h]=l.useState(!1),p=l.useRef(null),m=l.useRef(null),f=l.useCallback((j,k)=>{const{valid:S,rejection:w}=oO(j,k,cO);return d(w),s(C=>[...C,...S.map(({file:P,relativePath:T})=>({id:`${T}-${P.size}-${Math.random().toString(36).slice(2)}`,file:P,relativePath:T,description:""}))]),w!==null},[]),g=l.useCallback(async j=>{const k=await nO(j);if(f(k.files,k.expandedViaEntryApi))return;const S=iO(k);S&&d(S)},[f]),b=l.useCallback(j=>{j.target.files&&f(Array.from(j.target.files).map(k=>({file:k,relativePath:k.name})),!1),j.target.value=""},[f]),x=l.useCallback(j=>{if(j.target.files){const k=sO(j.target.files);f(k,!0),k.length===0&&d("No files found in that folder.")}j.target.value=""},[f]),y=l.useCallback((j,k)=>{s(S=>S.map(w=>w.id===j?{...w,description:k}:w))},[]),v=l.useCallback(j=>{s(k=>k.filter(S=>S.id!==j))},[]),_=l.useCallback(async()=>{if(n.length!==0){a(!0),d(null);try{const j=await lO(n);i(j),s([]),t==null||t(j)}catch(j){d(j instanceof Error?j.message:String(j))}finally{a(!1)}}},[n,t]);return e.jsxs(e.Fragment,{children:[e.jsx(sj,{dragActive:u,inputRef:p,onDragOver:j=>{j.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:j=>{j.preventDefault(),h(!1),g(j.dataTransfer)},onFilePick:b,onFolderPick:x,folderInputRef:m}),e.jsx(aj,{pending:n,onDescriptionChange:y,onRemove:v}),e.jsx(ij,{message:c}),e.jsx(lj,{filenames:o}),e.jsx(cj,{disabled:n.length===0||r,submitting:r,onClick:_})]})}const $z=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropZone:dj},Symbol.toStringTag,{value:"Module"}));function uj(){const[t,n]=l.useState(null),s=l.useRef(!0),r=l.useCallback(async()=>{try{const a=await fetch("/api/editor-design-assets");if(!a.ok)return;const o=await a.json();s.current&&n(Array.isArray(o.assets)?o.assets:[])}catch{}},[]);return l.useEffect(()=>(s.current=!0,r(),()=>{s.current=!1}),[r]),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{padding:"var(--spacing-lg, 16px)",gap:"var(--spacing-md, 12px)",overflow:"auto"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"var(--text-md, 15px)",fontWeight:600,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:"Add design assets"}),e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)",lineHeight:1.5},children:"Drag design assets onto codeyam-editor, or browse to add them — logos, screenshots, brand guides, inspiration. The agent reads whatever you add and folds it into the mockups."})]}),e.jsx(dj,{onAssetsSaved:r}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:[e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Added assets"}),t===null?e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"Loading…"}):t.length===0?e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"No assets added yet."}):t.map(a=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px)",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-input)"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:500,color:"var(--text-primary)"},children:a.filename}),a.description.trim().length>0&&e.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:a.description})]},a.filename))]})]})}const Bz=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetsView:uj},Symbol.toStringTag,{value:"Module"}));function dO(t,n){var c;const s=[],r=Object.entries(n.vars).filter(([,d])=>d&&d.trim());if(r.length>0){const d=r.map(([u,h])=>` ${u}: ${h};`).join(`
|
|
122
|
+
`);s.push(`:root {
|
|
123
|
+
${d}
|
|
124
|
+
}`)}if(n.primaryFont){const d=Sd(n.primaryFont,n.primaryFontStack);s.push(`body, p, li, span, button, input, textarea, select, label { font-family: ${d} !important; }`)}if(n.secondaryFont){const d=Sd(n.secondaryFont,n.secondaryFontStack);s.push(`h1, h2, h3, h4, h5, h6, .heading, [class*="title"], [class*="headline"] { font-family: ${d} !important; }`)}const a=s.length>0?`<style data-codeyam-overrides="1">
|
|
125
|
+
${s.join(`
|
|
126
|
+
|
|
127
|
+
`)}
|
|
128
|
+
</style>`:"",o=n.fontsHref?`<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
129
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
130
|
+
<link rel="stylesheet" href="${n.fontsHref}" data-codeyam-fonts="1">`:"";if(!a&&!o)return t;const i=t.search(/<\/head\s*>/i);if(i===-1){const d=t.search(/<body[^>]*>/i);if(d===-1)return`${o}
|
|
131
|
+
${a}
|
|
132
|
+
${t}`;const u=d+(((c=t.match(/<body[^>]*>/i))==null?void 0:c[0].length)??0);return`${t.slice(0,u)}
|
|
133
|
+
${o}
|
|
134
|
+
${a}
|
|
135
|
+
${t.slice(u)}`}return`${t.slice(0,i)}
|
|
136
|
+
${o}
|
|
137
|
+
${a}
|
|
138
|
+
${t.slice(i)}`}function Sd(t,n){const s=/\s/.test(t)?`"${t}"`:t,r=(n==null?void 0:n.trim())||"system-ui, sans-serif";return`${s}, ${r}`}const uO={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function pa(t){return t.replace(/^\d{1,2}-/,"").replace(/-mockup\.html$/i,"").replace(/\.html$/i,"")}function hO(t,n){if(t===null||t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(t[s].filename!==n[s].filename||t[s].url!==n[s].url||t[s].name!==n[s].name)return!1;return!0}const pO="\x1B[200~",mO="\x1B[201~";function To(t,n=fO){const s=t.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),r=`${pO}${s}${mO}`;return n(r),new Promise(a=>{setTimeout(()=>{n("\r"),a()},tk)})}function fO(t){window.dispatchEvent(new CustomEvent("miniagent-send-input",{detail:t}))}function gO({feedbackByFilename:t,mockupFilenames:n}){const s={};for(const o of n){const i=t[o];if(!i)continue;const c=typeof i.rating=="number",d=i.comment.trim().length>0;!c&&!d||(s[o]={rating:c?i.rating:null,comment:i.comment.trim()})}return Object.keys(s).length===0?"Iterate: before regenerating anything, first ask the user in the chat which of these designs (if any) are close enough to keep and just tweak — and let them know that every other design will be discarded and redesigned fresh. Wait for their reply before writing any mockup. No per-card feedback was provided, so let their answer guide what to keep vs. redesign from scratch.":`Iterate: before regenerating anything, first ask the user in the chat which of these designs (if any) are close enough to keep and just tweak — and let them know that every other design will be discarded and redesigned fresh from the feedback below. Wait for their reply before writing any mockup.
|
|
139
|
+
|
|
140
|
+
Once they answer: for designs they choose to keep, refine them in place using their specific feedback, keeping the same numeric prefix and design system. For every other design, redesign it fresh from the feedback — each redesign must directly address the specific comment and rating for that card (a pointed comment is a concrete instruction the redesign must visibly resolve; a low rating means change direction further). For fresh redesigns, weigh the rating and comment to decide whether to keep the same design system with a new layout, or swap in a different system from .codeyam/design/design_systems/ — avoid duplicating a system already used by a kept card. When you change a slot's design system, delete the old NN-*.html file before writing the new NN-<newsystem>-mockup.html so each slot has exactly one file. Keep numeric filename prefixes stable so slots don't move.
|
|
141
|
+
|
|
142
|
+
Per-card feedback (rating is 1-100 or null; comment may be empty):
|
|
143
|
+
|
|
144
|
+
\`\`\`json
|
|
145
|
+
`+JSON.stringify(s,null,2)+"\n```"}const bO=9e4;function xO(t){return!!(t.agentRespondedAfterDispatch||yO(t.snapshotFilenames,t.latestFilenames))}function yO(t,n){if(t.length!==n.length)return!0;const s=[...t].sort(),r=[...n].sort();for(let a=0;a<s.length;a++)if(s[a]!==r[a])return!0;return!1}function vO(t){const n={},s={},r=t.split(`
|
|
146
|
+
`);let a=!1,o=[];for(const i of r){const c=i.trim();if(/^```/.test(c)){a=!a;continue}if(a)continue;const d=/^(#{1,6})\s+(.+)$/.exec(c);if(d){const g=d[1].length;o=o.slice(0,g-1),o[g-1]=d[2].trim();continue}if(!c.startsWith("|"))continue;const u=c.split("|").map(g=>g.trim());if(u.length<3)continue;const h=u[1].replace(/`/g,"").trim(),p=u[2].replace(/`/g,"").trim();if(!/^--[A-Za-z0-9_-]+$/.test(h)||!jO(p))continue;const m=o.filter(Boolean).join(" / "),f=hj(m)?s:n;h in f||(f[h]=p)}return{light:n,dark:s}}function hj(t){return/\bdark[\s-]?mode\b|\bdark\b\s*(palette|variant|theme)?/i.test(t)}function jO(t){return!!(/^#[0-9a-fA-F]{3,8}$/.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)||/^oklch\(/i.test(t))}const wO=["Background","Surface","Text","Primary","Secondary","Accent"],_O={Background:[/^--bg(-default|-page|-canvas|-base)?$/,/^--page(-bg)?$/,/^--canvas$/,/^--background$/,/^--light-linen$/,/^--paper$/,/^--body-bg$/,/-canvas$/,/-page-bg$/],Surface:[/^--bg-surface$/,/^--surface(-1|-elevated)?$/,/^--card(-bg)?$/,/^--bg-elevated$/,/^--marketplace-gray$/,/^--panel(-bg)?$/,/^--cream$/,/-surface$/,/-porcelain-surface$/],Text:[/^--text(-primary|-default)?$/,/^--fg(-default)?$/,/^--foreground$/,/^--ink$/,/^--pitch-black$/,/^--body-text$/,/^--ink-text$/,/-ink-text$/,/-graphite-text$/],Primary:[/^--primary$/,/^--accent(-primary)?$/,/^--brand(-primary)?$/,/^--creator-pink$/,/^--palette-1$/,/^--lime$/,/^--burgundy$/,/-amethyst-accent$/,/-accent$/],Secondary:[/^--secondary$/,/^--accent-secondary$/,/^--brand-secondary$/,/^--sunshine-yellow$/,/^--palette-2$/,/^--sage$/,/^--sky-blue$/,/-sky-blue-highlight$/,/-highlight$/],Accent:[/^--accent(-tertiary|-highlight)?$/,/^--highlight$/,/^--lime-glow$/,/^--lime-deep$/,/^--firecracker-orange$/,/^--sky-blue$/,/^--gold$/,/^--palette-3$/,/-detail$/]};function kO(t){const n=[],s=t.split(`
|
|
147
|
+
`);let r=!1,a="",o=0,i=null,c=[];for(let d=0;d<s.length;d++){const h=s[d].trim();if(!r){const p=/^(#{1,6})\s+(.+)$/.exec(h);if(p){const f=p[1].length;c=c.slice(0,f-1),c[f-1]=p[2].trim(),i=p[2].trim();continue}const m=/^```(\w*)/.exec(h);m&&(r=!0,a=m[1].toLowerCase(),o=d+1);continue}if(h==="```"){if(a==="css"||a===""){const p=s.slice(o,d).join(`
|
|
148
|
+
`);for(const m of NO(p)){const f=c.filter(Boolean).join(" / "),g=SO(m.selector)||hj(f);n.push({selector:m.selector,heading:i,isDark:g,vars:m.vars})}}r=!1,a=""}}return n}function SO(t){return/\[data-theme[~|*$^]?="?dark"?\]/.test(t)}function NO(t){const n=[],s=/(:root[^\{]*?)\{([\s\S]*?)\}/g;let r;for(;(r=s.exec(t))!==null;){const a=r[1].trim(),o=r[2],i={},c=/(--[A-Za-z0-9_-]+)\s*:\s*([^;\n]+?)\s*(?:;|$)/g;let d;for(;(d=c.exec(o))!==null;){const u=d[1],h=d[2].replace(/\/\*.*?\*\//g,"").trim();h&&(i[u]=h)}Object.keys(i).length>0&&n.push({selector:a,vars:i})}return n}function CO(t,n){const s=_O[n];for(const r of Object.keys(t))for(const a of s)if(a.test(r))return{cssVar:r,value:t[r]};return{cssVar:null,value:null}}function TO(t){const n=/\[data-palette[~|*$^]?="?([^"\]]+)"?\]/.exec(t);return n?n[1].split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null}function PO(t){if(!t)return"Default";let n=t.replace(/\(.+?\)/g,"");return n=n.replace(/\bpalette\b/i,"").replace(/\bmode\b/i,""),/\bdark\b/i.test(n)?"Default":(n=n.replace(/\bdark\b/i,""),n=n.replace(/\blight\b/i,""),n=n.trim().replace(/\s+/g," "),n||"Default")}function Nd(t){const n=wO.map(s=>{const{cssVar:r,value:a}=CO(t,s);return{label:s,cssVar:r,value:a}});return{vars:t,slots:n}}function Ol(t){const n=kO(t),s=new Map,r=new Map,a=[];for(const o of n){const c=TO(o.selector)??PO(o.heading);a.includes(c)||a.push(c),o.isDark?r.has(c)||r.set(c,o.vars):s.has(c)||s.set(c,o.vars)}if(s.size===0){const o=vO(t);o.light&&Object.keys(o.light).length>0&&(a.unshift("Default"),s.set("Default",o.light),o.dark&&Object.keys(o.dark).length>0&&r.set("Default",o.dark))}return a.map(o=>{const i=s.get(o);if(!i)return null;const c=r.get(o)??null;return{name:o,light:Nd(i),dark:c?Nd(c):null}}).filter(o=>o!==null)}function OO(t){const n=Object.keys(t);if(n.length===0)return{};const s=fj(t),r={};for(const a of n){const o=t[a];if(!o||!o.trim())continue;const i=s.get(a)??null;r[a]=EO(o,i)}return r}const pj="#0f1115",AO="#181b21",mj="#e8eaed";function RO(t){const n=fj(t);let s=null,r=null;for(const[a,o]of n){const i=t[a];!i||!i.trim()||(o==="Background"&&s===null&&(s=i),o==="Text"&&r===null&&(r=i))}return{bg:s??pj,text:r??mj}}function fj(t){var i;const s=["```css",":root {",Object.entries(t).map(([c,d])=>` ${c}: ${d};`).join(`
|
|
149
|
+
`),"}","```"].join(`
|
|
150
|
+
`),r=Ol(s),a=new Map,o=((i=r[0])==null?void 0:i.light.slots)??[];for(const c of o)c.cssVar&&a.set(c.cssVar,c.label);return a}function EO(t,n){switch(n){case"Background":return pj;case"Surface":return AO;case"Text":return mj;case"Primary":case"Secondary":case"Accent":return Cd(t);default:return Cd(t)}}function Cd(t){const n=MO(t.trim());if(!n)return t;const{h:s,s:r,l:a}=IO(n.r,n.g,n.b),{r:o,g:i,b:c}=LO(s,r,1-a),d=u=>u.toString(16).padStart(2,"0");return n.a!=null&&n.a<1?`rgba(${o}, ${i}, ${c}, ${n.a})`:`#${d(o)}${d(i)}${d(c)}`}function MO(t){const n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(n){let r=n[1];return r.length===3&&(r=r.split("").map(a=>a+a).join("")),{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}const s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(t);return s?{r:qa(parseInt(s[1],10)),g:qa(parseInt(s[2],10)),b:qa(parseInt(s[3],10)),a:s[4]!=null?parseFloat(s[4]):void 0}:null}function qa(t){return Math.max(0,Math.min(255,t))}function IO(t,n,s){const r=t/255,a=n/255,o=s/255,i=Math.max(r,a,o),c=Math.min(r,a,o),d=(i+c)/2;let u=0,h=0;if(i!==c){const p=i-c;switch(h=d>.5?p/(2-i-c):p/(i+c),i){case r:u=(a-o)/p+(a<o?6:0);break;case a:u=(o-r)/p+2;break;default:u=(r-a)/p+4;break}u/=6}return{h:u,s:h,l:d}}function LO(t,n,s){if(n===0){const i=Math.round(s*255);return{r:i,g:i,b:i}}const r=(i,c,d)=>{let u=d;return u<0&&(u+=1),u>1&&(u-=1),u<1/6?i+(c-i)*6*u:u<1/2?c:u<2/3?i+(c-i)*(2/3-u)*6:i},a=s<.5?s*(1+n):s+n-s*n,o=2*s-a;return{r:Math.round(r(o,a,t+1/3)*255),g:Math.round(r(o,a,t)*255),b:Math.round(r(o,a,t-1/3)*255)}}function DO(t){const[n,s]=l.useState({}),r=l.useRef(!0);return l.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),l.useEffect(()=>{if(!t)return;const a=new Set,o=t.map(i=>pa(i.filename)).filter(i=>a.has(i)?!1:(a.add(i),!(i in n)));o.length!==0&&(async()=>{var i,c,d;for(const u of o)try{const h=await fetch(`/api/editor-design-systems/${u}`);if(!h.ok)continue;const p=await h.json().catch(()=>null);if(!(p!=null&&p.content)){r.current&&s(x=>({...x,[u]:null}));continue}const m=Ol(p.content),f=((c=(i=m[0])==null?void 0:i.dark)==null?void 0:c.vars)??null,g=((d=m[0])==null?void 0:d.light.vars)??null,b=f&&Object.keys(f).length>0?f:g&&Object.keys(g).length>0?OO(g):null;r.current&&s(x=>({...x,[u]:b}))}catch{r.current&&s(h=>({...h,[u]:null}))}})()},[t,n]),n}function FO(){const[t,n]=l.useState([]);return l.useEffect(()=>{let s=!1;async function r(){try{const o=await fetch("/api/editor-mockups-history");if(!o.ok)return;const i=await o.json();s||n(Array.isArray(i)?i:[])}catch{}}r();const a=window.setInterval(r,4e3);return()=>{s=!0,window.clearInterval(a)}},[]),t}function gj({round:t,onRestore:n,restoring:s=!1}){if(!t||!t.mockups||t.mockups.length===0)return e.jsx(Oi,{});const r=t.feedback??{};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-md, 14px)"},children:[n&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",onClick:n,disabled:s,style:{padding:"6px 14px",background:"transparent",color:"var(--accent-active, #D7FF63)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:6,fontSize:"var(--text-sm, 13px)",fontWeight:500,cursor:s?"default":"pointer",opacity:s?.6:1},children:s?"Bringing back…":"Bring back this round"})}),e.jsx("div",{"data-mockup-archived-round":!0,style:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:t.mockups.map((a,o)=>{const i=r[a.filename],c=o+1,d=a.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsxs("div",{style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)"},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(c).padStart(2,"0")}),e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{textTransform:"capitalize",fontWeight:500,color:"var(--text-primary)",textDecoration:"none"},children:d})]}),e.jsx("iframe",{src:a.url,title:a.name,sandbox:"",style:{width:"100%",aspectRatio:"1 / 1",border:"none",pointerEvents:"none",background:"var(--bg-card, #1a1a1a)"}}),i&&(typeof i.rating=="number"||i.comment.trim().length>0)&&e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",borderTop:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:4,fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[typeof i.rating=="number"&&e.jsxs("div",{children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Rating ·"," "]}),e.jsxs("span",{style:{color:"var(--text-primary)"},children:[i.rating,"/100"]})]}),i.comment.trim().length>0&&e.jsxs("div",{style:{lineHeight:1.4},children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Note ·"," "]}),e.jsx("span",{style:{color:"var(--text-primary)"},children:i.comment})]})]})]},a.filename)})})]})}const Hz=Object.freeze(Object.defineProperty({__proto__:null,MockupArchivedRoundView:gj},Symbol.toStringTag,{value:"Module"}));function bj({columns:t,onChange:n}){return e.jsxs("div",{role:"group","aria-label":"Mockup columns",style:{display:"flex",gap:2,padding:2,borderRadius:8,background:"rgba(255,255,255,.04)",flexShrink:0},children:[e.jsx(Po,{count:1,active:t===1,onClick:()=>n(1)}),e.jsx(Po,{count:2,active:t===2,onClick:()=>n(2)})]})}function Po({count:t,active:n,onClick:s}){return e.jsx("button",{type:"button",onClick:s,"aria-pressed":n,"aria-label":t===1?"One column":"Two columns",title:t===1?"One column":"Two columns",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:22,border:"none",borderRadius:6,background:n?"var(--accent-active)":"transparent",color:n?"var(--text-on-accent, #14170a)":"var(--text-dim)",cursor:"pointer",transition:".16s"},children:e.jsx("svg",{width:"13",height:"11",viewBox:"0 0 13 11","aria-hidden":"true",children:t===1?e.jsx("rect",{x:"1",y:"1",width:"11",height:"9",rx:"1.5",fill:"currentColor"}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"1",y:"1",width:"4.5",height:"9",rx:"1.5",fill:"currentColor"}),e.jsx("rect",{x:"7.5",y:"1",width:"4.5",height:"9",rx:"1.5",fill:"currentColor"})]})})})}const qz=Object.freeze(Object.defineProperty({__proto__:null,ColumnsButton:Po,MockupColumnsToggle:bj},Symbol.toStringTag,{value:"Module"})),Al=[{family:"Archivo",category:"sans",weights:[400,500,600,700]},{family:"DM Sans",category:"sans",weights:[400,500,700]},{family:"Inter",category:"sans",weights:[400,500,600,700]},{family:"Karla",category:"sans",weights:[400,500,700]},{family:"Manrope",category:"sans",weights:[400,500,700]},{family:"Nunito",category:"sans",weights:[400,600,700]},{family:"Plus Jakarta Sans",category:"sans",weights:[400,500,700]},{family:"Public Sans",category:"sans",weights:[400,500,700]},{family:"Roboto",category:"sans",weights:[400,500,700]},{family:"Work Sans",category:"sans",weights:[400,500,700]},{family:"Cormorant Garamond",category:"serif",weights:[400,500,700]},{family:"Crimson Pro",category:"serif",weights:[400,600,700]},{family:"Fraunces",category:"serif",weights:[400,600,700]},{family:"Lora",category:"serif",weights:[400,500,700]},{family:"Merriweather",category:"serif",weights:[400,700]},{family:"Playfair Display",category:"serif",weights:[400,600,700]},{family:"Source Serif 4",category:"serif",weights:[400,600,700]},{family:"Abril Fatface",category:"display",weights:[400]},{family:"Bebas Neue",category:"display",weights:[400]},{family:"Bricolage Grotesque",category:"display",weights:[400,600,800]},{family:"Chakra Petch",category:"display",weights:[400,600,700]},{family:"Lexend",category:"display",weights:[400,500,700]},{family:"Outfit",category:"display",weights:[400,600,800]},{family:"Rubik",category:"display",weights:[400,500,700]},{family:"Space Grotesk",category:"display",weights:[400,500,700]},{family:"Syne",category:"display",weights:[400,600,800]},{family:"Unbounded",category:"display",weights:[400,600,800]},{family:"Fira Code",category:"mono",weights:[400,500,700]},{family:"IBM Plex Mono",category:"mono",weights:[400,500,600]},{family:"JetBrains Mono",category:"mono",weights:[400,500,700]},{family:"Space Mono",category:"mono",weights:[400,700]}],zO={sans:"Sans-serif",serif:"Serif",display:"Display",mono:"Monospace"};function xj(t){const n=new Set,s=[];for(const r of t){if(!r||n.has(r))continue;n.add(r);const a=Al.find(c=>c.family===r),o=(a==null?void 0:a.weights)??[400,700],i=r.replace(/ /g,"+");s.push(`family=${i}:wght@${o.join(";")}`)}return s.length===0?"":`https://fonts.googleapis.com/css2?${s.join("&")}&display=swap`}function $O(t,n,s){const r={},a=Td(t,s),o=Td(n,s),i=new Map;for(const c of a)c.cssVar&&i.set(c.label,c.cssVar);for(const c of o){if(!c.value)continue;const d=i.get(c.label)??c.cssVar;d&&(r[d]=c.value)}return r}function Td(t,n){return t?n==="dark"&&t.dark?t.dark.slots:t.light.slots:[]}function BO(t,n,s){var a,o;return n!=="dark"?s:{...((o=(a=t[0])==null?void 0:a.dark)==null?void 0:o.vars)??{},...s}}function HO(t,n){const[s,r]=l.useState({kind:"loading"});return l.useEffect(()=>{let a=!1;return r({kind:"loading"}),(async()=>{try{const[o,i]=await Promise.all([fetch(t),fetch(`/api/editor-design-systems/${n}`)]),c=await o.text();let d="";if(i.ok){const u=await i.json().catch(()=>null);d=(u==null?void 0:u.content)??""}if(a)return;r({kind:"ready",html:c,palettes:Ol(d)})}catch(o){a||r({kind:"error",message:o instanceof Error?o.message:String(o)})}})(),()=>{a=!0}},[t,n]),s}function yj(t,n,s){l.useEffect(()=>{if(!t)return;const r=o=>{var c;const i=o.target;(c=n.current)!=null&&c.contains(i)||s()},a=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",a)}},[t,n,s])}function Zs(t,n,s){return{name:t,light:Pd(n),dark:s?Pd(s):null}}function Pd(t){const n=[{label:"Background",cssVar:"--bg-default",value:t.bg},{label:"Surface",cssVar:"--bg-surface",value:t.surface},{label:"Text",cssVar:"--text-primary",value:t.text},{label:"Primary",cssVar:"--accent-primary",value:t.primary},{label:"Secondary",cssVar:"--accent-secondary",value:t.secondary},{label:"Accent",cssVar:"--accent-highlight",value:t.accent}],s={};for(const r of n)r.cssVar&&r.value&&(s[r.cssVar]=r.value);return{vars:s,slots:n}}function qO(){return[Zs("Lime Bright",{bg:"#F4F4EE",surface:"#FFFFFF",text:"#0F0F0F",primary:"#D7FF63",secondary:"#9DA48F",accent:"#FF6B5C"},{bg:"#14160F",surface:"#25251F",text:"#F1EFEA",primary:"#D7FF63",secondary:"#4D5247",accent:"#FF6B5C"}),Zs("Warm Cream",{bg:"#EFE9DA",surface:"#F8F3E7",text:"#3B2F1C",primary:"#C44536",secondary:"#7A9E7E",accent:"#EAA64A"},{bg:"#1F1A11",surface:"#2A2418",text:"#EFE9DA",primary:"#E07767",secondary:"#A9CBA9",accent:"#EAA64A"}),Zs("Cool Mono",{bg:"#F5F6F8",surface:"#FFFFFF",text:"#101218",primary:"#2B2D3A",secondary:"#8B8FA3",accent:"#5C8DFF"},{bg:"#0E1016",surface:"#181B23",text:"#E9EBF2",primary:"#E9EBF2",secondary:"#8B8FA3",accent:"#7CA0FF"}),Zs("Bold Pop",{bg:"#FFF8F0",surface:"#FFFFFF",text:"#181818",primary:"#FF3D7F",secondary:"#3DD2FF",accent:"#FFD60A"},{bg:"#161113",surface:"#1F1A1D",text:"#FFF8F0",primary:"#FF3D7F",secondary:"#3DD2FF",accent:"#FFD60A"})]}function vj({palettes:t,activeName:n,theme:s,onApply:r}){const a=(()=>{const o=new Set(t.map(c=>c.name.toLowerCase())),i=qO().filter(c=>!o.has(c.name.toLowerCase()));return[...t,...i]})();return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:a.map(o=>{const i=s==="dark"&&o.dark?o.dark:o.light,c=o.name===n;return e.jsx("button",{type:"button",onClick:()=>r(o),"aria-pressed":c,"aria-label":`Apply ${o.name} palette`,title:o.name,style:{padding:4,border:c?"2px solid var(--accent-active, #D7FF63)":"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-elevated)",cursor:"pointer"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 18px)",gridTemplateRows:"repeat(2, 18px)",gap:2},children:i.slots.map(d=>e.jsx("span",{title:d.label,style:{width:18,height:18,borderRadius:4,border:"1px solid var(--border-default)",background:d.value??"transparent"}},d.label))})},o.name)})})}const Wz=Object.freeze(Object.defineProperty({__proto__:null,ColorPalettePicker:vj},Symbol.toStringTag,{value:"Module"}));function jj({slots:t,values:n,onChange:s}){return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:"8px 16px"},children:t.map(r=>{const a=!r.cssVar,o=r.cssVar?n[r.cssVar]??r.value??"":"",i=WO(o);return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"70px 1fr 80px",alignItems:"center",gap:6,opacity:a?.4:1,minWidth:0},children:[e.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-primary)",fontWeight:500},children:r.label}),e.jsx("input",{type:"color","aria-label":`${r.label} color`,disabled:a,value:i,onChange:c=>{r.cssVar&&s(r.cssVar,c.target.value)},style:{width:"100%",height:28,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-elevated)",cursor:a?"not-allowed":"pointer"}}),e.jsx("input",{type:"text","aria-label":`${r.label} hex`,disabled:a,value:o,onChange:c=>{r.cssVar&&s(r.cssVar,c.target.value)},spellCheck:!1,style:{padding:"4px 6px",fontSize:"var(--text-xs, 12px)",fontFamily:"var(--font-mono, monospace)",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-elevated)",color:"var(--text-primary)"}})]},r.label)})})}function WO(t){const n=t.trim();return/^#[0-9a-fA-F]{6}$/.test(n)?n.toLowerCase():/^#[0-9a-fA-F]{3}$/.test(n)?`#${n[1]}${n[1]}${n[2]}${n[2]}${n[3]}${n[3]}`.toLowerCase():"#000000"}const Gz=Object.freeze(Object.defineProperty({__proto__:null,ColorSwatchEditor:jj},Symbol.toStringTag,{value:"Module"}));function Oo({children:t}){return e.jsx("h4",{style:{margin:"0 0 8px",fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.08em"},children:t})}const Uz=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePanelSectionHeading:Oo},Symbol.toStringTag,{value:"Module"}));function wj({palettes:t,activeName:n,theme:s,slots:r,vars:a,onApplyPalette:o,onColorChange:i}){return e.jsxs("div",{role:"menu",style:{padding:"var(--spacing-md, 12px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{children:[e.jsx(Oo,{children:"Palettes"}),e.jsx(vj,{palettes:t,activeName:n,theme:s,onApply:o})]}),e.jsxs("div",{children:[e.jsx(Oo,{children:"Individual colors"}),e.jsx(jj,{slots:r,values:a,onChange:i})]})]})}const Vz=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeColorsPanel:wj},Symbol.toStringTag,{value:"Module"}));function _j({message:t}){return e.jsx("div",{style:{padding:"var(--spacing-md, 12px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:t})}const Yz=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeErrorBanner:_j},Symbol.toStringTag,{value:"Module"}));let Od=!1;function GO(){if(Od||typeof document>"u")return;Od=!0;const t=xj(Al.map(s=>s.family));if(!t)return;const n=document.createElement("link");n.rel="stylesheet",n.href=t,n.dataset.codeyamFontPreviews="1",document.head.appendChild(n)}function Ao({label:t,value:n,onChange:s,hint:r}){const[a,o]=l.useState(!1),i=l.useRef(null),c=l.useRef(null),d=l.useRef(null);l.useEffect(()=>{GO()},[]);const u=l.useCallback(()=>o(!1),[]);yj(a,d,u);const h={sans:[],serif:[],display:[],mono:[]};for(const p of Al)h[p.category].push(p);return e.jsxs("div",{ref:d,style:{display:"flex",flexDirection:"column",gap:4,fontSize:"var(--text-xs, 12px)",color:"var(--text-primary)",position:"relative"},children:[e.jsx("span",{style:{fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontSize:11,fontWeight:500,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)"},children:t}),r&&e.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},children:r}),e.jsxs("button",{ref:i,type:"button","aria-haspopup":"listbox","aria-expanded":a,onClick:()=>o(p=>!p),style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,padding:"6px 10px",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontFamily:n?`"${n}", system-ui, sans-serif`:"inherit",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{children:n??"System default"}),e.jsx("span",{"aria-hidden":!0,style:{opacity:.6},children:"▾"})]}),a&&e.jsxs("div",{ref:c,role:"listbox",style:{position:"absolute",top:"100%",left:0,right:0,marginTop:4,zIndex:20,background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",maxHeight:320,overflowY:"auto",padding:4},children:[e.jsx(Ro,{family:null,label:"System default",isActive:n===null,onPick:()=>{s(null),o(!1)}}),Object.keys(h).map(p=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"6px 10px 2px",fontSize:"var(--text-xs, 11px)",color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:700},children:zO[p]}),h[p].map(m=>e.jsx(Ro,{family:m.family,label:m.family,isActive:n===m.family,onPick:()=>{s(m.family),o(!1)}},m.family))]},p))]})]})}function Ro({family:t,label:n,isActive:s,onPick:r}){return e.jsx("button",{type:"button",role:"option","aria-selected":s,onClick:r,style:{display:"block",width:"100%",padding:"8px 10px",background:s?"var(--bg-elevated)":"transparent",color:"var(--text-primary)",border:"none",borderRadius:4,fontSize:16,fontFamily:t?`"${t}", system-ui, sans-serif`:"inherit",textAlign:"left",cursor:"pointer"},children:n})}const Kz=Object.freeze(Object.defineProperty({__proto__:null,FontOptionRow:Ro,FontPicker:Ao},Symbol.toStringTag,{value:"Module"}));function kj({primaryFont:t,secondaryFont:n,onPrimaryChange:s,onSecondaryChange:r}){return e.jsxs("div",{role:"menu",style:{padding:"var(--spacing-md, 12px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-default)",display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsx(Ao,{label:"Headings",value:n,onChange:r}),e.jsx(Ao,{label:"Body text",value:t,onChange:s})]})}const Jz=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeFontsPanel:kj},Symbol.toStringTag,{value:"Module"}));function Rl(t){const n=/<meta\b[^>]*>/gi;let s;for(;(s=n.exec(t))!==null;){const r=s[0];if(!/name=["']codeyam-viewport["']/i.test(r))continue;const a=/content=["']([^"']+)["']/i.exec(r);if(!a)continue;const o=a[1].toLowerCase().trim();return o==="desktop"||o==="tablet"||o==="mobile"?o:null}return null}function UO(t,n){const{vars:s,bg:r,text:a}=VO(n),o=Object.entries(s).filter(([,p])=>p&&p.trim());if(o.length===0)return t;const i=[`:root {
|
|
151
|
+
`+o.map(([p,m])=>` ${p}: ${m};`).join(`
|
|
152
|
+
`)+`
|
|
153
|
+
}`,":root { color-scheme: dark; }"];r&&r.trim()&&a&&a.trim()&&i.push(`html, body { background: ${r}; color: ${a}; }`);const c=`<style data-codeyam-dark="1">${i.join(`
|
|
154
|
+
`)}</style>`;if(t.search(/<\/head\s*>/i)===-1)return`${c}
|
|
155
|
+
${t}`;const u=YO(t),h=u.search(/<\/head\s*>/i);return`${u.slice(0,h)}
|
|
156
|
+
${c}
|
|
157
|
+
${u.slice(h)}`}function VO(t){return t&&typeof t=="object"&&"vars"in t&&typeof t.vars=="object"?t:{vars:t}}function YO(t){const n=/<html\b([^>]*)>/i,s=n.exec(t);if(!s)return t;let r=s[1];/\bdata-theme\s*=/.test(r)||(r+=' data-theme="dark"');const a=/\bclass\s*=\s*("|')([\s\S]*?)\1/,o=a.exec(r);if(o){const i=o[2].split(/\s+/).filter(Boolean);if(!i.includes("dark")){const c=[...i,"dark"].join(" ");r=r.replace(a,`class=${o[1]}${c}${o[1]}`)}}else r+=' class="dark"';return t.replace(n,`<html${r}>`)}function Sj({html:t,srcDoc:n,theme:s,mockupUrl:r,mockupName:a}){const o=Rl(t)??"desktop",i=o==="mobile"||o==="tablet",c=o==="mobile"?390:o==="tablet"?834:null;return e.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:i?"#1a1a1a":"white",backgroundImage:i?"radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px)":void 0,backgroundSize:i?"12px 12px":void 0,display:"flex",justifyContent:"center"},children:e.jsx("iframe",{title:`Customize preview: ${a}`,srcDoc:n,sandbox:"",style:{width:i&&c?`${c}px`:"100%",height:"100%",minHeight:800,border:"none",background:"white",flexShrink:0}},`${r}-${s}`)})}const Xz=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePreviewArea:Sj},Symbol.toStringTag,{value:"Module"}));function El({theme:t,onToggle:n,size:s=28}){return e.jsx("button",{type:"button",onClick:n,"aria-label":t==="light"?"Switch to dark mode":"Switch to light mode","aria-pressed":t==="dark",title:t==="light"?"Dark mode":"Light mode",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:s,height:s,background:"var(--bg-card, #1a1a1a)",border:"1px solid var(--border-default)",borderRadius:6,cursor:"pointer",color:"var(--text-primary)",padding:0,fontSize:14,lineHeight:1},children:t==="light"?"☾":"☀"})}const Qz=Object.freeze(Object.defineProperty({__proto__:null,MockupCardThemeToggleButton:El},Symbol.toStringTag,{value:"Module"}));function er(t){return{height:28,padding:"0 8px",background:t?"#555":"#3a3a3a",color:t?"#ffffff":"#d1d5db",border:"none",borderRadius:4,fontSize:11,fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontWeight:400,letterSpacing:"0.04em",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4}}function Nj({systemName:t,openMenu:n,theme:s,hasDark:r,saving:a,toolbarRef:o,onBack:i,onToggleMenu:c,onToggleTheme:d,onReset:u,onSave:h}){return e.jsxs("div",{ref:o,style:{display:"flex",alignItems:"center",gap:8,padding:"0 8px",height:40,borderBottom:"1px solid #3d3d3d",background:"#2d2d2d",flexWrap:"nowrap"},children:[e.jsx("button",{type:"button",onClick:i,"aria-label":"Back to mockups",style:{...er(!1),background:"transparent"},children:"← Back"}),e.jsxs("span",{style:{color:"#9ca3af",fontSize:13,fontFamily:"'IBM Plex Sans', system-ui, sans-serif",fontWeight:400,marginRight:4},children:["Customize: ",t]}),e.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":n==="fonts",onClick:()=>c("fonts"),style:er(n==="fonts"),children:["Fonts ",e.jsx("span",{"aria-hidden":!0,style:{opacity:.7},children:"▾"})]}),e.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":n==="colors",onClick:()=>c("colors"),style:er(n==="colors"),children:["Colors ",e.jsx("span",{"aria-hidden":!0,style:{opacity:.7},children:"▾"})]}),e.jsx("button",{type:"button",onClick:u,style:{...er(!1),background:"transparent",color:"#9ca3af"},children:"Reset"}),e.jsx("div",{style:{flex:1}}),r&&e.jsx(El,{theme:s,onToggle:d,size:28}),e.jsx("button",{type:"button",onClick:h,disabled:a,style:{height:28,padding:"0 10px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"none",borderRadius:4,fontSize:11,fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontWeight:500,letterSpacing:"0.04em",cursor:a?"wait":"pointer",opacity:a?.7:1},children:a?"SAVING…":"SAVE"})]})}const Zz=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeToolbar:Nj},Symbol.toStringTag,{value:"Module"}));function Cj({mockup:t,systemName:n,initial:s,onBack:r,onSave:a,saving:o=!1}){var P;const i=HO(t.url,n),[c,d]=l.useState(s),[u,h]=l.useState(null),[p,m]=l.useState("light"),[f,g]=l.useState(null),b=l.useRef(null),x=l.useCallback(()=>g(null),[]);yj(f!==null,b,x);const y=l.useMemo(()=>{const T=[];return c.primaryFont&&T.push(c.primaryFont),c.secondaryFont&&T.push(c.secondaryFont),T.length===0?null:xj(T)},[c.primaryFont,c.secondaryFont]),v=l.useMemo(()=>i.kind!=="ready"?c.vars:BO(i.palettes,p,c.vars),[i,c.vars,p]),_=l.useMemo(()=>i.kind!=="ready"?"":dO(i.html,{...c,vars:v,fontsHref:y}),[i,c,v,y]),j=l.useCallback(T=>{h(T.name);const O=i.kind==="ready"?i.palettes[0]:void 0,N=$O(O,T,p);d(E=>({...E,vars:{...E.vars,...N}}))},[i,p]),k=l.useCallback((T,O)=>{h(null),d(N=>({...N,vars:{...N.vars,[T]:O}}))},[]),S=l.useCallback(()=>{d({vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null}),h(null)},[]),w=l.useMemo(()=>{if(i.kind!=="ready"||i.palettes.length===0)return[{label:"Background",cssVar:"--bg-default",value:null},{label:"Surface",cssVar:"--bg-surface",value:null},{label:"Text",cssVar:"--text-primary",value:null},{label:"Primary",cssVar:"--accent-primary",value:null},{label:"Secondary",cssVar:"--accent-secondary",value:null},{label:"Accent",cssVar:"--accent-highlight",value:null}];const T=i.palettes[0];return p==="dark"&&T.dark?T.dark.slots:T.light.slots},[i,p]),C=i.kind==="ready"&&!!((P=i.palettes[0])!=null&&P.dark);return e.jsxs("div",{"data-testid":"mockup-customize-view",className:"flex-1 flex flex-col min-w-0",style:{overflow:"hidden",position:"relative"},children:[e.jsxs("div",{ref:b,children:[e.jsx(Nj,{systemName:n,openMenu:f,theme:p,hasDark:C,saving:o,toolbarRef:{current:null},onBack:()=>r(c),onToggleMenu:T=>g(O=>O===T?null:T),onToggleTheme:()=>m(T=>T==="light"?"dark":"light"),onReset:S,onSave:()=>a(c)}),f==="fonts"&&e.jsx(kj,{primaryFont:c.primaryFont,secondaryFont:c.secondaryFont,onPrimaryChange:T=>d(O=>({...O,primaryFont:T})),onSecondaryChange:T=>d(O=>({...O,secondaryFont:T}))}),f==="colors"&&e.jsx(wj,{palettes:i.kind==="ready"?i.palettes:[],activeName:u,theme:p,slots:w,vars:c.vars,onApplyPalette:j,onColorChange:k})]}),i.kind==="error"&&e.jsx(_j,{message:i.message}),i.kind==="loading"?e.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"white",padding:"var(--spacing-lg, 16px)",color:"var(--text-secondary)"},children:"Loading mockup…"}):i.kind==="ready"?e.jsx(Sj,{html:i.html,srcDoc:_,theme:p,mockupUrl:t.url,mockupName:t.name}):null]})}const e$=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeView:Cj},Symbol.toStringTag,{value:"Module"})),Tj={desktop:{w:1440,h:900},tablet:{w:834,h:1112},mobile:{w:390,h:844}},Ad="desktop",Eo=1280,Mo=1280;function KO(t){const[n,...s]=t;return n?s.some(r=>r!==n)?{w:Eo,h:Mo}:Tj[n]:{w:Eo,h:Mo}}const JO="#1a1a1a",XO="radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px)",QO="12px 12px";function ZO(t,n,s,r){if(t<=0||n<=0||s<=0||r<=0)return{scale:0,offsetX:0,offsetY:0};const a=Math.min(t/s,n/r),o=s*a,i=r*a;return{scale:a,offsetX:Math.max(0,(t-o)/2),offsetY:Math.max(0,(n-i)/2)}}function Pj(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M4.5 2.5h-2v7h7v-2"}),e.jsx("path",{d:"M7 2.5h2.5V5"}),e.jsx("path",{d:"M9.5 2.5L5.5 6.5"})]})}function Oj({displayNumber:t,formattedName:n,theme:s,showThemeToggle:r,busy:a,openInNewTabUrl:o,onToggleTheme:i,onChoose:c,onCustomize:d}){return e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(t).padStart(2,"0")}),o?e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${n} in new tab`,title:"Open in new tab",onClick:u=>u.stopPropagation(),style:{display:"inline-flex",alignItems:"center",gap:4,minWidth:0,color:"var(--text-primary)",textDecoration:"none"},children:[e.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:"var(--text-muted)",lineHeight:1,flexShrink:0},children:e.jsx(Pj,{})})]}):e.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-xs, 8px)",flexShrink:0},children:[r&&e.jsx(El,{theme:s,onToggle:i}),e.jsx("button",{type:"button",onClick:d,disabled:a,style:{padding:"6px 14px",background:"var(--bg-card, #1a1a1a)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:"var(--text-xs, 12px)",fontWeight:500,cursor:a?"wait":"pointer",opacity:a?.6:1},children:"Customize"}),e.jsx("button",{type:"button",onClick:c,disabled:a,style:{padding:"6px 14px",background:"var(--accent-active, #7c3aed)",color:"var(--text-on-accent, #fff)",border:"1px solid transparent",borderRadius:6,fontSize:"var(--text-xs, 12px)",fontWeight:600,cursor:a?"wait":"pointer",opacity:a?.6:1,boxShadow:a?"none":"0 0 0 3px color-mix(in srgb, var(--accent-active, #7c3aed) 30%, transparent), 0 2px 6px color-mix(in srgb, var(--accent-active, #7c3aed) 40%, transparent)"},children:"Select"})]})]})}const t$=Object.freeze(Object.defineProperty({__proto__:null,MockupCardFooter:Oj,OpenInNewTabIcon:Pj},Symbol.toStringTag,{value:"Module"})),eA=700;function tA({srcDoc:t,url:n,theme:s,scale:r,hasContent:a}){const[o,i]=l.useState(!1),[c,d]=l.useState(!1),u=l.useRef([]);l.useEffect(()=>{i(!1),d(!1);const f=window.setTimeout(()=>d(!0),eA);return()=>window.clearTimeout(f)},[t,n,s]);const h=()=>{const f=window.requestAnimationFrame(()=>{const g=window.requestAnimationFrame(()=>i(!0));u.current.push(g)});u.current.push(f)};l.useEffect(()=>()=>{u.current.forEach(f=>window.cancelAnimationFrame(f)),u.current=[]},[]);const p=o&&r>0;return{handleIframeLoad:h,visible:p,showSkeleton:!a||!p||!c}}function Aj(){return e.jsxs("div",{"aria-label":"Loading mockup",style:{position:"absolute",inset:0,padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[e.jsx(Er,{}),e.jsx(et,{widthPct:45,heightPx:14,variant:"overlay"}),e.jsx(et,{widthPct:70,heightPx:10,variant:"overlay"}),e.jsx("div",{style:{height:"6%"}}),e.jsx(et,{widthPct:100,heightPx:32,variant:"overlay"}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(et,{widthPct:48,heightPx:48,variant:"overlay"}),e.jsx(et,{widthPct:48,heightPx:48,variant:"overlay"})]}),e.jsx(et,{widthPct:88,heightPx:10,variant:"overlay"}),e.jsx(et,{widthPct:60,heightPx:10,variant:"overlay"})]})}const n$=Object.freeze(Object.defineProperty({__proto__:null,MockupSkeletonOverlay:Aj},Symbol.toStringTag,{value:"Module"}));function Ml({html:t,url:n,title:s,viewport:r,theme:a,darkVars:o,slotAspect:i={w:Eo,h:Mo}}){const c=l.useRef(null),[d,u]=l.useState(0),[h,p]=l.useState(0),m=Tj[r];l.useEffect(()=>{const k=c.current;if(!k)return;const S=()=>{const C=k.clientWidth,P=k.clientHeight;C>0&&u(C),P>0&&p(P)};if(S(),typeof ResizeObserver>"u")return;const w=new ResizeObserver(S);return w.observe(k),()=>w.disconnect()},[]);const{scale:f,offsetX:g,offsetY:b}=ZO(d,h,m.w,m.h),x=t&&a==="dark"&&o?UO(t,{vars:o,...RO(o)}):t,{handleIframeLoad:y,visible:v,showSkeleton:_}=tA({srcDoc:x,url:n,theme:a,scale:f,hasContent:t!==null}),j=()=>window.open(n,"_blank","noopener,noreferrer");return e.jsxs("div",{ref:c,onClick:j,style:{position:"relative",width:"100%",aspectRatio:`${i.w} / ${i.h}`,overflow:"hidden",cursor:"pointer",backgroundColor:JO,backgroundImage:XO,backgroundSize:QO},children:[t!==null&&e.jsx("iframe",{src:x?void 0:n,srcDoc:x??void 0,title:s,sandbox:"",onLoad:y,style:{width:m.w,height:m.h,border:"none",background:"white",transform:f>0?`scale(${f})`:"scale(0)",transformOrigin:"top left",pointerEvents:"none",position:"absolute",top:b,left:g,visibility:v?"visible":"hidden"}},a),_&&e.jsx(Aj,{})]})}const s$=Object.freeze(Object.defineProperty({__proto__:null,MockupCardPreviewSlot:Ml},Symbol.toStringTag,{value:"Module"})),nA=`
|
|
158
|
+
.mockup-feedback-slider {
|
|
159
|
+
-webkit-appearance: none;
|
|
160
|
+
appearance: none;
|
|
161
|
+
background: transparent;
|
|
162
|
+
height: 18px;
|
|
163
|
+
padding: 0;
|
|
164
|
+
margin: 0;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
}
|
|
167
|
+
.mockup-feedback-slider:focus { outline: none; }
|
|
168
|
+
.mockup-feedback-slider::-webkit-slider-runnable-track {
|
|
169
|
+
height: 4px;
|
|
170
|
+
background: #4a4a4a;
|
|
171
|
+
border-radius: 2px;
|
|
172
|
+
}
|
|
173
|
+
.mockup-feedback-slider::-moz-range-track {
|
|
174
|
+
height: 4px;
|
|
175
|
+
background: #4a4a4a;
|
|
176
|
+
border-radius: 2px;
|
|
177
|
+
border: none;
|
|
178
|
+
}
|
|
179
|
+
.mockup-feedback-slider::-moz-range-progress {
|
|
180
|
+
background: #4a4a4a;
|
|
181
|
+
height: 4px;
|
|
182
|
+
border-radius: 2px;
|
|
183
|
+
}
|
|
184
|
+
.mockup-feedback-slider::-webkit-slider-thumb {
|
|
185
|
+
-webkit-appearance: none;
|
|
186
|
+
appearance: none;
|
|
187
|
+
width: 14px;
|
|
188
|
+
height: 14px;
|
|
189
|
+
border-radius: 50%;
|
|
190
|
+
background: #5a5a5a;
|
|
191
|
+
border: none;
|
|
192
|
+
margin-top: -5px;
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
transition: background 120ms ease;
|
|
195
|
+
}
|
|
196
|
+
.mockup-feedback-slider::-moz-range-thumb {
|
|
197
|
+
width: 14px;
|
|
198
|
+
height: 14px;
|
|
199
|
+
border-radius: 50%;
|
|
200
|
+
background: #5a5a5a;
|
|
201
|
+
border: none;
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
transition: background 120ms ease;
|
|
204
|
+
}
|
|
205
|
+
.mockup-feedback-slider[data-rated="true"]::-webkit-slider-runnable-track {
|
|
206
|
+
/* Two stacked layers: a grey overlay that masks the right portion of
|
|
207
|
+
* the track from progress% onward, and a full-width red-amber-keylime
|
|
208
|
+
* rainbow underneath. The visible filled portion is the slice of the
|
|
209
|
+
* rainbow up to the thumb position. */
|
|
210
|
+
background:
|
|
211
|
+
linear-gradient(
|
|
212
|
+
to right,
|
|
213
|
+
transparent 0%,
|
|
214
|
+
transparent var(--mockup-feedback-progress, 0%),
|
|
215
|
+
#4a4a4a var(--mockup-feedback-progress, 0%),
|
|
216
|
+
#4a4a4a 100%
|
|
217
|
+
),
|
|
218
|
+
linear-gradient(
|
|
219
|
+
to right,
|
|
220
|
+
rgb(239, 68, 68) 0%,
|
|
221
|
+
rgb(251, 191, 36) 50%,
|
|
222
|
+
rgb(215, 255, 99) 100%
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
.mockup-feedback-slider[data-rated="true"]::-moz-range-track {
|
|
226
|
+
background: linear-gradient(
|
|
227
|
+
to right,
|
|
228
|
+
rgb(239, 68, 68) 0%,
|
|
229
|
+
rgb(251, 191, 36) 50%,
|
|
230
|
+
rgb(215, 255, 99) 100%
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
.mockup-feedback-slider[data-rated="true"]::-moz-range-progress {
|
|
234
|
+
/* Firefox draws ::-moz-range-progress on top of ::-moz-range-track,
|
|
235
|
+
* so the progress layer would otherwise hide the rainbow below it.
|
|
236
|
+
* Leave it transparent so the rainbow shows through up to the value. */
|
|
237
|
+
background: transparent;
|
|
238
|
+
}
|
|
239
|
+
.mockup-feedback-slider[data-rated="true"]::-webkit-slider-thumb {
|
|
240
|
+
background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
|
|
241
|
+
}
|
|
242
|
+
.mockup-feedback-slider[data-rated="true"]::-moz-range-thumb {
|
|
243
|
+
background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
|
|
244
|
+
}
|
|
245
|
+
`,sA=`
|
|
246
|
+
.mockup-feedback-comment {
|
|
247
|
+
width: 100%;
|
|
248
|
+
padding: var(--spacing-sm, 8px) var(--spacing-sm, 10px);
|
|
249
|
+
background: var(--bg-card, #1a1a1a);
|
|
250
|
+
color: var(--text-primary);
|
|
251
|
+
border: 1px solid var(--border-default);
|
|
252
|
+
border-radius: 6px;
|
|
253
|
+
font-size: var(--text-xs, 12px);
|
|
254
|
+
line-height: 1.4;
|
|
255
|
+
resize: vertical;
|
|
256
|
+
box-sizing: border-box;
|
|
257
|
+
min-height: 56px;
|
|
258
|
+
outline: none;
|
|
259
|
+
}
|
|
260
|
+
.mockup-feedback-comment:focus,
|
|
261
|
+
.mockup-feedback-comment:focus-visible {
|
|
262
|
+
border-color: var(--text-primary, #ffffff);
|
|
263
|
+
outline: none;
|
|
264
|
+
box-shadow: 0 0 0 1px var(--text-primary, #ffffff);
|
|
265
|
+
}
|
|
266
|
+
`;function Rj({comment:t,onCommentChange:n}){return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:sA}),e.jsx("textarea",{value:t,onChange:s=>n(s.target.value),placeholder:"What do you like or would like to change? (optional)",rows:3,className:"mockup-feedback-comment"})]})}const r$=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackCommentBox:Rj},Symbol.toStringTag,{value:"Module"})),Ej=[239,68,68],Io=[251,191,36],Mj=[215,255,99];function rA(t){const n=Math.max(1,Math.min(100,t));let s,r,a;n<=50?(s=Ej,r=Io,a=(n-1)/49):(s=Io,r=Mj,a=(n-50)/50);const o=Math.round(s[0]+(r[0]-s[0])*a),i=Math.round(s[1]+(r[1]-s[1])*a),c=Math.round(s[2]+(r[2]-s[2])*a);return`rgb(${o}, ${i}, ${c})`}`${Ej.join(", ")}${Io.join(", ")}${Mj.join(", ")}`;function Ij(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3z"}),e.jsx("path",{d:"M17 2h2.5a2.5 2.5 0 0 1 2.5 2.5v6A2.5 2.5 0 0 1 19.5 13H17"})]})}function Lj(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3z"}),e.jsx("path",{d:"M7 22H4.5a2.5 2.5 0 0 1-2.5-2.5v-6A2.5 2.5 0 0 1 4.5 11H7"})]})}const a$=Object.freeze(Object.defineProperty({__proto__:null,ThumbDownIcon:Ij,ThumbUpIcon:Lj},Symbol.toStringTag,{value:"Module"}));function Dj({rating:t,onRatingChange:n}){const s=t!=null,r=s&&t<=33,a=s&&t>=67;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-sm, 10px)"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:r?"var(--text-primary)":"var(--text-muted)",display:"inline-flex",alignItems:"center"},children:e.jsx(Ij,{})}),e.jsx("input",{type:"range",min:1,max:100,step:1,value:t??50,onPointerDown:()=>{s||n(50)},onChange:o=>n(Number(o.target.value)),"aria-label":"Rate this mockup from 1 to 100",className:"mockup-feedback-slider","data-rated":s?"true":"false",style:{flex:1,"--mockup-feedback-progress":`${t??0}%`,"--mockup-feedback-color":s?rA(t):"var(--accent-active, #D7FF63)"}}),e.jsx("span",{"aria-hidden":"true",style:{color:a?"var(--text-primary)":"var(--text-muted)",display:"inline-flex",alignItems:"center"},children:e.jsx(Lj,{})})]})}const o$=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackRatingSlider:Dj},Symbol.toStringTag,{value:"Module"})),Fj={rating:null,comment:""};function zj({value:t,onChange:n}){return e.jsxs("div",{"data-mockup-feedback":!0,style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",borderTop:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 10px)",background:"var(--bg-surface)"},children:[e.jsx("style",{children:nA}),e.jsx(Dj,{rating:t.rating,onRatingChange:s=>n({...t,rating:s})}),e.jsx(Rj,{comment:t.comment,onCommentChange:s=>n({...t,comment:s})})]})}const i$=Object.freeze(Object.defineProperty({__proto__:null,EMPTY_FEEDBACK:Fj,MockupCardFeedback:zj},Symbol.toStringTag,{value:"Module"}));function $j({mockup:t,displayNumber:n,onChoose:s,onCustomize:r,busy:a=!1,darkVars:o=null,feedback:i,onFeedbackChange:c,slotAspect:d,onViewportResolved:u}){const[h,p]=l.useState(null),[m,f]=l.useState(Ad),[g,b]=l.useState("light");if(l.useEffect(()=>{if(!t)return;let y=!1;return(async()=>{try{const v=await fetch(t.url);if(!v.ok)return;const _=await v.text();if(y)return;const j=Rl(_)??Ad;p(_),f(j),u==null||u(j)}catch{}})(),()=>{y=!0}},[t==null?void 0:t.url]),!t)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:160,border:"1px dashed var(--border-default)",borderRadius:12,background:"var(--bg-surface)",color:"var(--text-muted)",fontSize:"var(--text-sm, 14px)"},children:"No mockup to preview"});const x=t.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsx(Oj,{displayNumber:n,formattedName:x,theme:g,showThemeToggle:!!o,busy:a,openInNewTabUrl:t.url,onToggleTheme:()=>b(y=>y==="light"?"dark":"light"),onChoose:()=>s==null?void 0:s(t),onCustomize:()=>r==null?void 0:r(t)}),e.jsx(Ml,{html:h,url:t.url,title:t.name,viewport:m,theme:g,darkVars:o,slotAspect:d}),c&&e.jsx(zj,{value:i??Fj,onChange:c})]})}const l$=Object.freeze(Object.defineProperty({__proto__:null,MockupCard:$j},Symbol.toStringTag,{value:"Module"}));function Bj({displayNumber:t,slotAspect:n}){return e.jsxs("div",{"data-mockup-placeholder":!0,"aria-label":"The AI is designing this mockup",style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsx(Er,{}),e.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:n?`${n.w} / ${n.h}`:"1 / 1",overflow:"hidden",background:"var(--bg-elevated, #141414)",padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[e.jsx(et,{widthPct:45,heightPx:14}),e.jsx(et,{widthPct:70,heightPx:10}),e.jsx("div",{style:{height:"6%"}}),e.jsx(et,{widthPct:100,heightPx:32}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(et,{widthPct:48,heightPx:48}),e.jsx(et,{widthPct:48,heightPx:48})]}),e.jsx(et,{widthPct:88,heightPx:10}),e.jsx(et,{widthPct:60,heightPx:10})]}),e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",display:"flex",alignItems:"center",gap:"var(--spacing-sm, 8px)"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(t).padStart(2,"0")}),e.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},"data-testid":"mockup-placeholder-label",children:"The AI is designing this mockup…"})]})})]})}const c$=Object.freeze(Object.defineProperty({__proto__:null,MockupPlaceholderCard:Bj},Symbol.toStringTag,{value:"Module"}));function Hj({slots:t,darkVarsBySystem:n,busyFilename:s,feedbackByFilename:r,onFeedbackChange:a,onChoose:o,onCustomize:i,columns:c=2}){const[d,u]=l.useState({}),h=l.useCallback((m,f)=>{u(g=>g[m]===f?g:{...g,[m]:f})},[]),p=l.useMemo(()=>KO(Object.values(d)),[d]);return e.jsx("div",{style:{display:"grid",gridTemplateColumns:c===1?"1fr":"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:t.map(m=>m.mockup?e.jsx($j,{mockup:m.mockup,displayNumber:m.number,onChoose:o,onCustomize:i,busy:s===m.mockup.filename,darkVars:n[pa(m.mockup.filename)]??null,feedback:r==null?void 0:r[m.mockup.filename],onFeedbackChange:a?f=>a(m.mockup.filename,f):void 0,slotAspect:p,onViewportResolved:f=>h(m.mockup.filename,f)},`mockup-${m.mockup.filename}`):e.jsx(Bj,{displayNumber:m.number,slotAspect:p},`placeholder-${m.number}`))})}const d$=Object.freeze(Object.defineProperty({__proto__:null,MockupGrid:Hj},Symbol.toStringTag,{value:"Module"}));function qj(){return e.jsxs("div",{"data-mockup-generating-overlay":!0,style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"var(--spacing-md, 14px)",zIndex:5,background:"var(--bg-overlay, rgba(15,17,21,0.45))",backdropFilter:"blur(1px)",borderRadius:12,pointerEvents:"auto"},children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}),e.jsx("div",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:500},children:"Generating new designs…"})]})}const u$=Object.freeze(Object.defineProperty({__proto__:null,MockupGridGeneratingOverlay:qj},Symbol.toStringTag,{value:"Module"}));function Wj(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M9 18h6"}),e.jsx("path",{d:"M10 22h4"}),e.jsx("path",{d:"M12 2a7 7 0 0 0-4 12.74V17a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.26A7 7 0 0 0 12 2z"})]})}function Gj(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}function Uj({onDismiss:t}){return e.jsxs("div",{role:"note","data-mockup-info-banner":!0,style:{display:"flex",alignItems:"flex-start",gap:"var(--spacing-md, 14px)",padding:"var(--spacing-md, 14px) var(--spacing-md, 16px)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:12,background:"rgba(215, 255, 99, 0.04)"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0,paddingTop:1},children:e.jsx(Wj,{})}),e.jsxs("p",{style:{flex:1,margin:0,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5},children:[e.jsx("strong",{style:{fontWeight:700},children:"Not sure which to pick?"})," ","Rate these designs and jot a quick note. We'll refine them into a fresh round — no need to choose yet."]}),e.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss tip",title:"Dismiss",style:{flexShrink:0,padding:4,background:"transparent",color:"var(--text-muted)",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Gj,{})})]})}const h$=Object.freeze(Object.defineProperty({__proto__:null,CloseIcon:Gj,LightbulbIcon:Wj,MockupGridInfoBanner:Uj},Symbol.toStringTag,{value:"Module"}));function Vj(){return e.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-3.36-7"}),e.jsx("polyline",{points:"21 4 21 10 15 10"})]})}function Yj({feedbackCount:t,busy:n,onIterate:s}){const r=t===0?"Add a rating or note above, then iterate.":t===1?"1 card has feedback — iterate to refresh the round.":`${t} cards have feedback — iterate to refresh the round.`;return e.jsxs("div",{style:{marginTop:"var(--spacing-md, 12px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-md, 16px)",padding:"var(--spacing-md, 16px) var(--spacing-lg, 20px)",border:"1px solid var(--border-default)",borderRadius:12,background:"var(--bg-card, #1a1a1a)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 14px)",minWidth:0},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0},children:e.jsx(Vj,{})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.jsx("span",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:600,lineHeight:1.3},children:"Ready for the next round?"}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"var(--text-xs, 12px)",lineHeight:1.4,marginTop:2},children:r})]})]}),e.jsx("button",{type:"button",onClick:s,disabled:n,"data-mockup-iterate":!0,style:{flexShrink:0,padding:"10px 22px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:8,fontSize:"var(--text-sm, 14px)",fontWeight:600,cursor:n?"wait":"pointer",opacity:n?.6:1},children:n?"Sending…":"Iterate"})]})}const p$=Object.freeze(Object.defineProperty({__proto__:null,MockupGridIterateButton:Yj,RefreshCycleIcon:Vj},Symbol.toStringTag,{value:"Module"}));function Kj(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}function Jj(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Xj({archivedRoundsNewestFirst:t,selected:n,onSelect:s}){if(!t||t.length===0)return null;const a=[...[...t].reverse(),"current"],o=a.length,i=a.indexOf(n),c=i===-1?o-1:i,d=n==="current",u=c>0,h=c<o-1,p=d?`Round ${o} of ${o} · Current`:`Round ${c+1} of ${o} · Archived`;return e.jsxs("div",{"data-mockup-round-pager":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-sm, 10px)",padding:"var(--spacing-xs, 6px) var(--spacing-md, 14px)",border:"1px solid var(--border-default)",borderRadius:10,background:"var(--bg-card, #1a1a1a)"},children:[e.jsx(Lo,{ariaLabel:"Previous round",disabled:!u,onClick:()=>u&&s(a[c-1]),icon:e.jsx(Kj,{})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)"},children:p}),!d&&e.jsx("button",{type:"button",onClick:()=>s("current"),style:{padding:"4px 10px",background:"transparent",color:"var(--accent-active, #D7FF63)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:6,fontSize:"var(--text-xs, 11px)",fontWeight:500,cursor:"pointer"},children:"Return to current"})]}),e.jsx(Lo,{ariaLabel:"Next round",disabled:!h,onClick:()=>h&&s(a[c+1]),icon:e.jsx(Jj,{})})]})}function Lo({ariaLabel:t,disabled:n,onClick:s,icon:r}){return e.jsx("button",{type:"button",onClick:s,disabled:n,"aria-label":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,background:"transparent",color:n?"var(--text-dim, #666)":"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,cursor:n?"default":"pointer",opacity:n?.5:1,padding:0},children:r})}const m$=Object.freeze(Object.defineProperty({__proto__:null,ChevronLeftIcon:Kj,ChevronRightIcon:Jj,MockupRoundPager:Xj,PagerArrowButton:Lo},Symbol.toStringTag,{value:"Module"}));function Qj({mockup:t,busy:n,onCancel:s,onConfirm:r}){l.useEffect(()=>{const o=i=>{i.key==="Escape"&&!n&&s()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n,s]);const a=t.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsx("div",{role:"presentation",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:24},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Ready to start building?",onClick:o=>o.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(440px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"hidden",aspectRatio:"16 / 9",background:"#1a1a1a",position:"relative"},children:e.jsx("iframe",{src:t.url,title:`${a} thumbnail`,sandbox:"",style:{width:1440,height:900,border:"none",background:"white",transform:"scale(0.305)",transformOrigin:"top left",pointerEvents:"none",position:"absolute",top:0,left:0}})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Ready to start building?"}),e.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13,textTransform:"capitalize"},children:["Using ",e.jsx("strong",{style:{color:"var(--text-primary)"},children:a})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:s,disabled:n,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:n?"wait":"pointer",opacity:n?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:r,disabled:n,style:{padding:"8px 18px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:6,fontSize:13,fontWeight:600,cursor:n?"wait":"pointer",opacity:n?.7:1,fontFamily:"inherit"},children:n?"Starting…":"Start building"})]})]})})}const f$=Object.freeze(Object.defineProperty({__proto__:null,StartBuildingConfirmModal:Qj},Symbol.toStringTag,{value:"Module"}));function aA(t){return t===void 0?"/api/editor-design-select":`/api/editor-mockup-customize?round=${encodeURIComponent(t)}`}function Hn(t,n){if(!n)return t;const s=t.includes("?")?"&":"?";return`${t}${s}round=${encodeURIComponent(n)}`}function Il({onDesignConfirmed:t,round:n}={}){const[s,r]=l.useState(null),[a,o]=l.useState(null),[i,c]=l.useState(null),[d,u]=l.useState(null),[h,p]=l.useState(null),[m,f]=l.useState(null),[g,b]=l.useState({}),[x,y]=l.useState({}),[v,_]=l.useState(!1),[j,k]=l.useState(!1),S=l.useRef([]),w=l.useRef(!1),C=l.useRef(!1),[P,T]=l.useState(null),[O,N]=l.useState(()=>typeof window>"u"?!1:window.sessionStorage.getItem("mockup-grid-tip-dismissed")==="1"),[E,I]=l.useState(()=>typeof window>"u"?2:window.localStorage.getItem("mockup-grid-columns")==="1"?1:2),ee=F=>{I(F),typeof window<"u"&&window.localStorage.setItem("mockup-grid-columns",String(F))},[B,z]=l.useState("current"),Y=FO(),te=l.useRef(null),R=DO(s),L=l.useRef(!0),M=l.useCallback(async()=>{try{const[F,J]=await Promise.all([fetch(Hn("/api/editor-mockups",n)),fetch(Hn("/api/editor-mockups-target",n))]),Z=await F.json(),ue=await J.json();L.current&&(r(ve=>hO(ve,Z)||w.current&&Z.length<S.current.length?ve:Z),o(ve=>ve===ue.count?ve:ue.count))}catch(F){L.current&&c(F instanceof Error?F.message:String(F))}},[n]);l.useEffect(()=>{L.current=!0,M();const F=window.setInterval(M,4e3);return()=>{L.current=!1,window.clearInterval(F)}},[M]),l.useEffect(()=>{let F=!1;return(async()=>{try{const J=await fetch(Hn("/api/editor-mockups-feedback",n));if(!J.ok)return;const Z=await J.json();if(F||!Z||typeof Z!="object"||Array.isArray(Z))return;const ue={};for(const[ve,fe]of Object.entries(Z)){if(!fe||typeof fe!="object")continue;const se=fe;se.rating!=null&&typeof se.rating!="number"||se.comment!=null&&typeof se.comment!="string"||(ue[ve]={rating:typeof se.rating=="number"?se.rating:null,comment:typeof se.comment=="string"?se.comment:""})}y(ue)}catch{}})(),()=>{F=!0}},[]);const K=l.useCallback((F,J)=>{y(Z=>{const ue={...Z,[F]:J};return te.current!=null&&window.clearTimeout(te.current),te.current=window.setTimeout(()=>{fetch(Hn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)}).catch(()=>{})},400),ue})},[n]);l.useEffect(()=>()=>{te.current!=null&&window.clearTimeout(te.current)},[]);const ie=l.useCallback(()=>{if(!s)return;const F=s.map(Z=>Z.filename);S.current=F,C.current=!1,k(!1),_(!0),z("current");const J=gO({feedbackByFilename:x,mockupFilenames:F});(async()=>{try{await fetch("/api/editor-mockups-archive",{method:"POST"})}catch{}await To(J),L.current&&(C.current=!0,y({}),fetch(Hn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).catch(()=>{}))})()},[x,s,n]);l.useEffect(()=>{w.current=v},[v]),l.useEffect(()=>{if(!v)return;const F=()=>{C.current&&k(!0)};return window.addEventListener("miniagent-output",F),()=>window.removeEventListener("miniagent-output",F)},[v]),l.useEffect(()=>{if(!v)return;const F=window.setTimeout(()=>{L.current&&_(!1)},bO);return()=>window.clearTimeout(F)},[v]),l.useEffect(()=>{v&&xO({snapshotFilenames:S.current,latestFilenames:(s??[]).map(F=>F.filename),agentRespondedAfterDispatch:j})&&_(!1)},[v,s,j]);const $=l.useCallback(async F=>{T(F);try{const J=await fetch("/api/editor-mockups-restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({round:F})});if(!J.ok){const Z=await J.text().catch(()=>`${J.status}`);throw new Error(Z||`restore failed: ${J.status}`)}L.current&&(z("current"),M())}catch(J){L.current&&c(J instanceof Error?J.message:String(J))}finally{L.current&&T(null)}},[M]),V=l.useCallback(F=>{f(F)},[]),ae=l.useCallback(async()=>{if(!m)return;const F=m;u(F.filename);try{if(n===void 0){const J=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:F.filename})});if(!J.ok){const Z=await J.text().catch(()=>`${J.status}`);throw new Error(Z||`select failed: ${J.status}`)}}L.current&&(f(null),t==null||t({kind:"use",filename:F.filename}))}catch(J){c(J instanceof Error?J.message:String(J))}finally{L.current&&u(null)}},[m,t,n]),ne=l.useCallback(F=>{const J=pa(F.filename);p({mockup:F,systemName:J})},[]),me=l.useCallback(F=>{h&&b(J=>({...J,[h.mockup.filename]:F})),p(null)},[h]),q=l.useCallback(async F=>{if(h){u(h.mockup.filename);try{const J=JSON.stringify({filename:h.mockup.filename,overrides:{vars:F.vars,primaryFont:F.primaryFont,secondaryFont:F.secondaryFont}}),Z=await fetch(aA(n),{method:"POST",headers:{"Content-Type":"application/json"},body:J});if(!Z.ok){const ue=await Z.text().catch(()=>`${Z.status}`);throw new Error(ue||`select failed: ${Z.status}`)}b(ue=>({...ue,[h.mockup.filename]:F})),p(null),t==null||t({kind:"use",filename:h.mockup.filename})}catch(J){c(J instanceof Error?J.message:String(J))}finally{L.current&&u(null)}}},[h,t,n]);if(h)return e.jsx(Cj,{mockup:h.mockup,systemName:h.systemName,initial:g[h.mockup.filename]??uO,onBack:me,onSave:q,saving:d===h.mockup.filename});if(!s)return e.jsx("div",{style:{padding:"var(--spacing-lg, 16px)"},children:e.jsx("div",{style:{color:"var(--text-secondary)"},children:"Loading design mockups…"})});const le=s.reduce((F,J)=>{const Z=/^(\d{1,2})-/.exec(J.filename);return Z?Math.max(F,parseInt(Z[1],10)):F},0),Pe=Math.max(a??0,le);if(Pe===0)return e.jsx(Oi,{});const Ce=Array.from({length:Pe},(F,J)=>{const Z=J+1,ue=String(Z).padStart(2,"0"),ve=s.find(fe=>fe.filename.startsWith(`${ue}-`))??null;return{number:Z,mockup:ve}});return e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{padding:"var(--spacing-lg, 16px)",gap:"var(--spacing-md, 12px)",overflow:"auto"},children:[!O&&e.jsx(Uj,{onDismiss:()=>{N(!0),typeof window<"u"&&window.sessionStorage.setItem("mockup-grid-tip-dismissed","1")}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)"},children:[e.jsx(Xj,{archivedRoundsNewestFirst:Y.map(F=>F.round),selected:B,onSelect:z}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(bj,{columns:E,onChange:ee})})]}),i&&e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderRadius:8,background:"var(--bg-danger-soft, rgba(248,113,113,0.12))",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:i}),B==="current"?e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[e.jsxs("div",{style:v?{opacity:.4,pointerEvents:"none"}:void 0,children:[e.jsx(Hj,{slots:Ce,darkVarsBySystem:R,busyFilename:d,feedbackByFilename:x,onFeedbackChange:K,onChoose:V,onCustomize:ne,columns:E}),s.length>0&&e.jsx("div",{style:{marginTop:"var(--spacing-md, 12px)"},children:e.jsx(Yj,{feedbackCount:Object.values(x).filter(F=>typeof F.rating=="number"||F.comment.trim().length>0).length,busy:v,onIterate:ie})})]}),v&&e.jsx(qj,{})]}):(()=>{const F=Y.find(J=>J.round===B);return F?e.jsx(gj,{round:F,onRestore:()=>$(F.round),restoring:P===F.round}):e.jsx("div",{style:{padding:"var(--spacing-md, 14px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:"Loading archived round…"})})(),m&&e.jsx(Qj,{mockup:m,busy:d===m.filename,onCancel:()=>f(null),onConfirm:ae})]})}const g$=Object.freeze(Object.defineProperty({__proto__:null,DesignExplorationView:Il,systemNameFromFilename:pa,withRoundParam:Hn},Symbol.toStringTag,{value:"Module"}));function Zj({onDesignConfirmed:t}){const[n,s]=l.useState("assets"),r=l.useRef(!0),a=l.useRef(0);return l.useEffect(()=>{r.current=!0;const o=async()=>{try{const d=await(await fetch("/api/editor-design-active-tab")).json();if(!r.current)return;d.tab!==null&&d.nonce!==null&&d.nonce>a.current&&(a.current=d.nonce,s(d.tab))}catch{}};o();const i=window.setInterval(o,4e3);return()=>{r.current=!1,window.clearInterval(i)}},[]),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderBottom:"1px solid var(--border-default)"},children:[{id:"assets",label:"Add assets"},{id:"mockups",label:"Mockups"}].map(({id:o,label:i})=>{const c=n===o;return e.jsx("button",{type:"button",role:"tab","aria-selected":c,onClick:()=>s(o),style:{padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,border:"none",cursor:"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:500,background:c?"var(--accent-active)":"transparent",color:c?"var(--text-on-accent, white)":"var(--text-secondary)"},children:i},o)})}),n==="assets"?e.jsx(uj,{}):e.jsx(Il,{onDesignConfirmed:t})]})}const b$=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPreviewPane:Zj},Symbol.toStringTag,{value:"Module"}));function oA(t=!0){const[n,s]=l.useState(void 0),r=l.useRef(!0);return l.useEffect(()=>{if(!t)return;r.current=!0;const a=async()=>{try{const i=await fetch("/api/editor-design-round");if(!i.ok)return;const c=await i.json();if(!r.current)return;s(c.roundId??null)}catch{}};a();const o=window.setInterval(a,4e3);return()=>{r.current=!1,window.clearInterval(o)}},[t]),n}function e0({roundId:t,onUse:n,onDiscard:s}={}){const[r,a]=l.useState(null),o=oA(t===void 0),i=t??o,c=l.useCallback(u=>{u.kind==="use"&&(a("use"),n?n(u.filename):To(`I've picked the design "${u.filename}" for this round. Please record the selection (branch-outcome design-iterate use), apply it, and return to the build.`))},[n]),d=l.useCallback(()=>{a("discard"),s?s():To("Let's discard this design round — none of these directions. Please record the discard (branch-outcome design-iterate discard), archive the round, and return to the build with the design unchanged.")},[s]);return e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-md, 12px)",padding:"var(--spacing-md, 12px) var(--spacing-lg, 16px)",borderBottom:"1px solid var(--border-default)"},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Design round"}),e.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"The first card reads as the app today, changed. Pick a direction to carry into the build, or discard the round."})]}),e.jsx("button",{type:"button",onClick:d,disabled:r!=null,style:{flexShrink:0,padding:"var(--spacing-xs, 6px) var(--spacing-md, 12px)",borderRadius:8,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)",cursor:r!=null?"default":"pointer",opacity:r!=null?.6:1},children:r==="discard"?"Discarding…":"Discard round"})]}),typeof i=="string"?e.jsx(Il,{round:i,onDesignConfirmed:c}):e.jsx(uu,{state:i===void 0?"resolving":"none"})]})}const x$=Object.freeze(Object.defineProperty({__proto__:null,DesignRoundPreviewPane:e0},Symbol.toStringTag,{value:"Module"}));function t0({deviceLabel:t,actions:n}){return e.jsxs("div",{role:"note",className:"flex items-center gap-2 border-b border-l-4 px-3 py-2 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("rect",{x:"3",y:"4",width:"7",height:"16",rx:"1"}),e.jsx("rect",{x:"14",y:"4",width:"7",height:"16",rx:"1"}),e.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22",strokeDasharray:"2 2"})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"font-semibold",children:"Live mirror — not interactive."})," ",e.jsxs("span",{style:{color:"var(--text-dim)"},children:["Tap and type directly in the ",t," window."]})]}),n?e.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:n}):null]})}const y$=Object.freeze(Object.defineProperty({__proto__:null,NativeMirrorNotice:t0},Symbol.toStringTag,{value:"Module"}));function n0({isCollapsed:t,onToggle:n}){return e.jsx("button",{onClick:n,className:`p-1.5 rounded transition-colors cursor-pointer ${t?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:t?"Show editor":"Hide editor",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 17l5-5-5-5"}),e.jsx("path",{d:"M6 17l5-5-5-5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 17l-5-5 5-5"}),e.jsx("path",{d:"M18 17l-5-5 5-5"})]})})})}const v$=Object.freeze(Object.defineProperty({__proto__:null,CollapseToggleButton:n0},Symbol.toStringTag,{value:"Module"}));function Do({label:t,value:n,disabled:s,onCommit:r}){const[a,o]=l.useState(String(n));l.useEffect(()=>{o(String(n))},[n]);const i=()=>{const c=Number.parseInt(a,10);if(!Number.isFinite(c)||c<=0){o(String(n));return}c!==n&&r(c)};return e.jsxs("label",{className:`flex items-center gap-0.5 px-1 py-0.5 rounded bg-[#2A2929] text-xs ${s?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 select-none",children:t}),e.jsx("input",{type:"text",inputMode:"numeric",value:a,disabled:s,"aria-label":t==="H"?"Height":"Width",onChange:c=>o(c.target.value.replace(/[^0-9]/g,"")),onBlur:i,onKeyDown:c=>{c.key==="Enter"?(i(),c.target.blur()):c.key==="Escape"&&(o(String(n)),c.target.blur())},className:"w-8 bg-transparent text-gray-200 text-center text-[11px] font-mono focus:outline-none disabled:cursor-not-allowed [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})]})}const j$=Object.freeze(Object.defineProperty({__proto__:null,DimensionInput:Do},Symbol.toStringTag,{value:"Module"}));function s0({isFilled:t,onToggle:n}){return e.jsx("button",{onClick:n,className:`p-1.5 rounded transition-colors cursor-pointer ${t?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:t?"Exit fullscreen":"Fill page with preview",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t?e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})}const w$=Object.freeze(Object.defineProperty({__proto__:null,FillPreviewButton:s0},Symbol.toStringTag,{value:"Module"}));function r0({previewUrl:t}){return e.jsx("button",{onClick:()=>{t&&window.open(t,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})}const _$=Object.freeze(Object.defineProperty({__proto__:null,OpenInNewTabButton:r0},Symbol.toStringTag,{value:"Module"})),Fo=new Set;function iA(t){return Fo.add(t),()=>{Fo.delete(t)}}function lA(){for(const t of Fo)t()}function a0(){return e.jsx("button",{onClick:()=>lA(),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Refresh preview","aria-label":"Refresh preview",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("polyline",{points:"1 20 1 14 7 14"}),e.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})})}const k$=Object.freeze(Object.defineProperty({__proto__:null,RefreshPreviewButton:a0},Symbol.toStringTag,{value:"Module"}));function Rd(t){var s;return t.route==="Uncategorized"?2:t.route.startsWith("/isolated-components/")||((s=t.scenarios[0])==null?void 0:s.scenarioType)==="component"?1:0}function o0(t){const n=new Map;for(const s of t){const r=s.url??"Uncategorized",a=n.get(r)??[];a.push(s),n.set(r,a)}return Array.from(n.entries()).map(([s,r])=>({route:s,scenarios:r})).sort((s,r)=>{const a=Rd(s)-Rd(r);return a!==0?a:s.route.localeCompare(r.route)})}function cA(t,n){const s=n.trim().toLowerCase();return s?t.filter(r=>{const a=(r.url??"").toLowerCase(),o=r.name.toLowerCase(),i=(r.componentName??"").toLowerCase();return a.includes(s)||o.includes(s)||i.includes(s)}):t}function i0({tab:t,hasQuery:n}){return n?e.jsx("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:"No matches for your search."}):e.jsxs("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:["No ",t==="pages"?"pages":"components"," yet."]})}const S$=Object.freeze(Object.defineProperty({__proto__:null,PagePickerEmptyMessage:i0},Symbol.toStringTag,{value:"Module"}));function l0({scenario:t,active:n,onClick:s}){const r=t.screenshotPaths[0],a=zr(t);return e.jsxs("button",{onClick:s,className:`w-32 text-left rounded border transition-colors cursor-pointer ${n?"border-[#007a99] bg-[#1a2a30]":"border-[#3d3d3d] bg-[#1a1a1a] hover:border-[#555]"}`,title:t.name,children:[e.jsx("div",{className:"aspect-[4/3] w-full overflow-hidden rounded-t border-b border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:r?e.jsx("img",{src:Rn(r),alt:t.name,className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-[10px] text-gray-600",children:"No screenshot"})}),e.jsx("div",{className:"px-2 py-1 text-[11px] text-gray-200 truncate",children:a})]})}const N$=Object.freeze(Object.defineProperty({__proto__:null,PagePickerScenarioThumbnail:l0},Symbol.toStringTag,{value:"Module"}));function c0({group:t,currentSlug:n,onSelect:s}){const r=t.scenarios[0]?Vh(t.scenarios[0]):null;return e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 mb-1.5 px-1",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-200 truncate",children:r??t.route}),r?e.jsx("span",{className:"text-[10px] text-gray-500 font-mono truncate",children:t.route}):null]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.scenarios.map(a=>e.jsx(l0,{scenario:a,active:a.slug===n,onClick:()=>s(a.slug)},a.slug))})]})}const C$=Object.freeze(Object.defineProperty({__proto__:null,PagePickerRouteSection:c0},Symbol.toStringTag,{value:"Module"}));function zo({label:t,active:n,count:s,onClick:r}){return e.jsxs("button",{onClick:r,className:`flex items-center gap-1.5 px-2 py-1 rounded text-[10px] font-semibold tracking-wider cursor-pointer transition-colors ${n?"text-white bg-[#3a3a3a]":"text-gray-500 hover:text-gray-300"}`,children:[t,e.jsx("span",{className:`text-[10px] font-mono px-1 rounded ${n?"bg-[#555] text-gray-200":"bg-[#2a2a2a] text-gray-500"}`,children:s})]})}const T$=Object.freeze(Object.defineProperty({__proto__:null,PagePickerTabButton:zo},Symbol.toStringTag,{value:"Module"}));function d0({scenarioGroups:t,currentSlug:n,onSelect:s,onClose:r,triggerRef:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(""),u=l.useRef(null),h=l.useRef(null);l.useEffect(()=>{var y;(y=h.current)==null||y.focus()},[]),Mr(u,r,a);const p=l.useMemo(()=>t.flatMap(y=>y.scenarios),[t]),m=l.useMemo(()=>cA(p,c),[p,c]),f=l.useMemo(()=>m.filter(Ar),[m]),g=l.useMemo(()=>m.filter(Vo),[m]),b=o==="pages"?f:g,x=l.useMemo(()=>o0(b),[b]);return e.jsxs("div",{ref:u,className:"absolute top-full left-0 mt-1 bg-[#222] border border-[#3d3d3d] rounded-lg shadow-2xl z-50 w-[560px] max-h-[480px] flex flex-col",role:"dialog",children:[e.jsxs("div",{className:"flex items-center border-b border-[#3d3d3d] px-2 py-1.5 gap-2",children:[e.jsx(zo,{label:"PAGES",active:o==="pages",count:f.length,onClick:()=>i("pages")}),e.jsx(zo,{label:"COMPONENTS",active:o==="components",count:g.length,onClick:()=>i("components")}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{ref:h,value:c,onChange:y=>d(y.target.value),placeholder:"Search…",className:"w-48 px-2 py-1 text-xs bg-[#1a1a1a] border border-[#3d3d3d] rounded text-gray-200 focus:outline-none focus:border-[#007a99]"}),e.jsx("button",{onClick:r,"aria-label":"Close",className:"p-1 text-gray-500 hover:text-gray-200 cursor-pointer",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"overflow-y-auto p-3 flex-1 min-h-0",children:x.length===0?e.jsx(i0,{tab:o,hasQuery:c.trim().length>0}):x.map(y=>e.jsx(c0,{group:y,currentSlug:n,onSelect:v=>{s(v),r()}},y.route))})]})}const P$=Object.freeze(Object.defineProperty({__proto__:null,PagePickerDropdown:d0},Symbol.toStringTag,{value:"Module"}));function u0(){return e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.jsx("path",{d:"M14 3v6h6"})]})}function h0(){return e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]})}function Ll({className:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:t??"opacity-70 shrink-0 text-gray-400",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}const O$=Object.freeze(Object.defineProperty({__proto__:null,ComponentGlyph:h0,DropdownChevron:Ll,PageGlyph:u0},Symbol.toStringTag,{value:"Module"}));function p0({currentScenario:t,isOpen:n,onClick:s,buttonRef:r}){const a=t?Vo(t):!1,o=(t==null?void 0:t.screenshotPaths[0])??null,i=t?a?t.componentName??t.name:Vh(t)??t.url??t.name:"Select a page";return e.jsxs("button",{ref:r,onClick:s,className:`flex items-center gap-1.5 max-w-[260px] pl-0.5 pr-1.5 py-0.5 rounded transition-colors cursor-pointer text-xs ${t?"text-gray-200":"text-gray-500"} ${n?"bg-[#555]":"hover:bg-[#4a4a4a]"}`,title:i,"aria-haspopup":"menu","aria-expanded":n,children:[e.jsxs("span",{className:"flex items-center gap-0.5 bg-[#1f1f1f] border border-[#3d3d3d] rounded p-0.5",children:[e.jsx("span",{className:"w-6 h-4 overflow-hidden rounded-sm bg-[#0f0f0f] flex items-center justify-center text-gray-500",children:o?e.jsx("img",{src:Rn(o),alt:"",className:"w-full h-full object-cover"}):a?e.jsx(h0,{}):e.jsx(u0,{})}),e.jsx(Ll,{})]}),e.jsx("span",{className:"truncate",children:i})]})}const A$=Object.freeze(Object.defineProperty({__proto__:null,PagePill:p0},Symbol.toStringTag,{value:"Module"}));function m0({scenario:t,active:n,onClick:s}){const r=t.screenshotPaths[0];return e.jsxs("button",{onClick:s,className:`flex items-center gap-2 w-full px-2 py-1.5 text-left transition-colors cursor-pointer ${n?"bg-[#1a2a30]":"hover:bg-[#2a2a2a]"}`,children:[e.jsx("div",{className:"w-10 h-7 shrink-0 rounded overflow-hidden border border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:r?e.jsx("img",{src:Rn(r),alt:"",className:"w-full h-full object-cover"}):null}),e.jsx("div",{className:`text-xs truncate flex-1 min-w-0 ${n?"text-white":"text-gray-200"}`,children:zr(t)})]})}const R$=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdownRow:m0},Symbol.toStringTag,{value:"Module"}));function f0({currentScenario:t,scenarioGroups:n,onSelect:s,onCreateNew:r,onClose:a,triggerRef:o}){const i=l.useRef(null);Mr(i,a,o);const c=l.useMemo(()=>_i(t,n),[t,n]);return e.jsxs("div",{ref:i,className:"absolute top-full right-0 mt-1 bg-[#222] border border-[#3d3d3d] rounded-lg shadow-2xl z-50 w-72 max-h-[400px] flex flex-col",role:"menu",children:[e.jsx("div",{className:"overflow-y-auto py-1 flex-1 min-h-0",children:c.map(d=>e.jsx(m0,{scenario:d,active:d.slug===t.slug,onClick:()=>{s(d.slug),a()}},d.slug))}),e.jsx("button",{onClick:()=>{r(),a()},className:"border-t border-[#3d3d3d] px-3 py-2 text-left text-[11px] font-mono tracking-wide text-[var(--accent-active)] hover:bg-[var(--accent-active)]/10 cursor-pointer",children:"+ CREATE NEW STATE"})]})}const E$=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdown:f0},Symbol.toStringTag,{value:"Module"}));function g0({label:t,disabled:n,isOpen:s,onClick:r,buttonRef:a}){return e.jsxs("button",{ref:a,onClick:()=>{n||r()},disabled:n,className:`flex items-center gap-1.5 max-w-[200px] h-7 px-2.5 rounded transition-colors text-xs ${n?"bg-[#3a3a3a] text-gray-600 cursor-not-allowed":s?"bg-[#444] text-gray-200 cursor-pointer":"bg-[#3a3a3a] text-gray-200 hover:bg-[#444] cursor-pointer"}`,title:n?"No active state":t,"aria-haspopup":"menu","aria-expanded":s,children:[e.jsx("span",{className:"truncate",children:t}),e.jsx(Ll,{className:"opacity-70 shrink-0"})]})}const M$=Object.freeze(Object.defineProperty({__proto__:null,StatesPillButton:g0},Symbol.toStringTag,{value:"Module"}));function b0({viewport:t,isActive:n,onSelect:s}){return e.jsx("button",{onClick:s,className:`p-1 rounded transition-colors cursor-pointer ${n?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${t.name} (${t.width}×${t.height})`,children:e.jsx(sy,{name:t.name})})}const I$=Object.freeze(Object.defineProperty({__proto__:null,ViewportPresetButton:b0},Symbol.toStringTag,{value:"Module"}));function x0({viewports:t,active:n,onChange:s,currentWidth:r,currentHeight:a,previewUrl:o,isCollapsed:i,onToggleCollapsed:c,isFilled:d,onToggleFilled:u,containerWidth:h,containerHeight:p,onCustomSizeChange:m,currentScenario:f,scenarioGroups:g,onShowScenarioPreview:b,onCreateStateRequest:x,isNarrow:y=!1,onBack:v,onPlanChange:_,onToggleStatesModal:j,statesModalOpen:k=!1}){const[S,w]=l.useState(!1),[C,P]=l.useState(!1),T=l.useRef(null),O=l.useRef(null),N=d&&h?Math.round(h):r,E=d&&p?Math.round(p):a,I=f?zr(f):"No state",ee=!f;return e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 h-10 grid grid-cols-[1fr_auto_1fr] items-center px-2",children:[e.jsx("div",{className:"justify-self-start",children:v?e.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 h-7 px-2 rounded text-sm text-[#ddd] hover:bg-[#3a3a3a]",children:[e.jsx("span",{"aria-hidden":"true",children:"←"})," Home"]}):y?null:e.jsx(n0,{isCollapsed:i,onToggle:c})}),e.jsxs("div",{className:`flex items-center gap-2 justify-self-center ${y?"min-w-0 overflow-x-auto":""}`,children:[e.jsxs("div",{className:"relative flex items-center bg-[#3a3a3a] rounded h-7 px-1 gap-1",children:[e.jsx(p0,{currentScenario:f,isOpen:S,onClick:()=>{w(B=>!B),P(!1)},buttonRef:T}),S&&e.jsx(d0,{scenarioGroups:g,currentSlug:(f==null?void 0:f.slug)??null,onSelect:b,onClose:()=>w(!1),triggerRef:T}),e.jsx("span",{className:"w-px h-5 bg-[#555] mx-1 shrink-0","aria-hidden":"true"}),t.map(B=>e.jsx(b0,{viewport:B,isActive:!d&&n===B.name,onSelect:()=>{d&&u(),s(B.name)}},B.name)),e.jsx(s0,{isFilled:d,onToggle:u}),e.jsx(Do,{label:"H",value:E,disabled:d,onCommit:B=>m(r,B)}),e.jsx(Do,{label:"W",value:N,disabled:d,onCommit:B=>m(B,a)}),e.jsx(a0,{}),e.jsx(r0,{previewUrl:o})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.jsx("div",{className:"relative",children:j?k?null:e.jsx("button",{type:"button",onClick:j,className:"font-mono text-[10px] leading-none uppercase tracking-widest underline underline-offset-2 whitespace-nowrap hover:opacity-80",style:{color:"var(--lime-300)"},children:"Scenarios"}):e.jsxs(e.Fragment,{children:[e.jsx(g0,{label:I,disabled:ee,isOpen:C,onClick:()=>{P(B=>!B),w(!1)},buttonRef:O}),C&&f&&e.jsx(f0,{currentScenario:f,scenarioGroups:g,onSelect:b,onCreateNew:x,onClose:()=>P(!1),triggerRef:O})]})})})]}),e.jsx("div",{className:"justify-self-end",children:_?e.jsx("button",{type:"button",onClick:_,className:"h-7 px-3 rounded text-xs font-medium uppercase tracking-wide whitespace-nowrap text-black hover:opacity-90",style:{background:"var(--lime-300)"},children:"Plan a change to this screen"}):null})]})}const L$=Object.freeze(Object.defineProperty({__proto__:null,NavigationBar:x0},Symbol.toStringTag,{value:"Module"}));function y0(){return e.jsxs("div",{style:{padding:"3rem 1rem",textAlign:"center",color:"var(--text-muted)"},children:[e.jsx("h2",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-secondary)",margin:"0 0 0.5rem 0"},children:"No plan loaded"}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem"},children:"Ask the AI to draft a plan, or pick one from the Plan tab."})]})}const D$=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewEmptyState:y0},Symbol.toStringTag,{value:"Module"}));function v0({title:t}){return e.jsx("h1",{style:{fontSize:"1.5rem",fontWeight:600,color:"var(--text-primary)",margin:"0 0 1rem 0",paddingBottom:"0.75rem",borderBottom:"1px solid var(--border-subtle)"},children:t})}const F$=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewHeader:v0},Symbol.toStringTag,{value:"Module"})),Ed={prompt:null,title:null};function j0(){const[t,n]=l.useState(Ed),[s,r]=l.useState(!0);return l.useEffect(()=>{let a=!1;return(async()=>{try{const i=await(await fetch("/api/prompt")).json();a||n({prompt:i.prompt??null,title:i.title??null})}catch{a||n(Ed)}finally{a||r(!1)}})(),()=>{a=!0}},[]),{...t,loading:s}}function w0(){const{prompt:t,title:n,loading:s}=j0();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:s?null:t?e.jsxs(e.Fragment,{children:[n?e.jsx(v0,{title:n}):null,e.jsx(Bt,{children:t})]}):e.jsx(y0,{})})})}const z$=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewPanelView:w0},Symbol.toStringTag,{value:"Module"}));function _0({message:t}){return e.jsx("span",{style:{color:"var(--text-dim)"},children:t})}const $$=Object.freeze(Object.defineProperty({__proto__:null,PreviewEmptyState:_0},Symbol.toStringTag,{value:"Module"}));function k0({hasDevServerConfigured:t}){const n=t?"Starting your app…":"Your app will display here once set up";return e.jsx("div",{"data-testid":"preview-waiting-placeholder",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",color:"var(--text-dim)"},children:e.jsx("span",{children:n})})}const B$=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingPlaceholder:k0},Symbol.toStringTag,{value:"Module"}));function S0(t,n,s){const r=[t];return n&&r.push(`reload:${n}`),s&&r.push(`command:${s}`),r.join("::")}function N0({currentWidth:t,currentHeight:n,isFilled:s,scale:r}){const a=e.jsx("div",{className:"w-full h-full border border-dashed rounded flex items-center justify-center text-center px-6",style:{borderColor:"var(--border-default)",background:"var(--bg-surface)",color:"var(--text-dim)"},children:e.jsxs("div",{className:"text-sm leading-relaxed",children:[e.jsx("div",{className:"font-medium",children:"Live Preview unavailable"}),e.jsxs("div",{className:"opacity-70 mt-1",children:[t,"×",n]})]})});return s?a:e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:t,height:n,transform:r<1?`scale(${r})`:void 0,transformOrigin:"center center",flexShrink:0},children:a})}const C0=l.forwardRef(function({currentHeight:n,currentWidth:s,isFilled:r,previewUrl:a,scale:o,reloadNonce:i,commandNonce:c,iframeKey:d,onLoad:u,onError:h},p){if(Ot())return e.jsx(N0,{currentWidth:s,currentHeight:n,isFilled:r,scale:o});const m=d??S0(a,i,c),f=()=>{h&&h("iframe error event")};return e.jsx("div",{className:r?"w-full h-full":"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:r?void 0:{width:s,height:n,transform:o<1?`scale(${o})`:void 0,transformOrigin:"center center",flexShrink:0},children:e.jsx("iframe",{ref:p,src:a,title:"Live Preview",style:{width:"100%",height:"100%",border:"none",background:"var(--bg-deep)"},onLoad:u,onError:f},m)})}),H$=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedPreviewPlaceholder:N0,PreviewFrame:C0},Symbol.toStringTag,{value:"Module"}));function T0({label:t="Loading preview..."}={}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-3 bg-[var(--bg-deep)]/80 backdrop-blur-sm text-[var(--text-muted)]",children:[e.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:t})]})}const q$=Object.freeze(Object.defineProperty({__proto__:null,PreviewLoadingSpinner:T0},Symbol.toStringTag,{value:"Module"}));function dA(t){var n,s;try{const r=(s=(n=t==null?void 0:t.contentWindow)==null?void 0:n.location)==null?void 0:s.href;return typeof r=="string"?r:null}catch{return null}}function uA(t,n){if(!n||!t||t==="about:blank")return null;let s;try{s=new URL(t,window.location.origin).pathname}catch{return null}return s===Cn||s.startsWith(`${Cn}/`)?null:s}function hA(t){return{type:"error",message:`The app navigated to "${t}", which is outside the Live Preview (everything the preview serves lives under ${Cn}). That path is served by the editor, so the frame would have rendered codeyam-editor instead of your app. The preview was stopped rather than showing you the wrong application.`,filename:t,lineno:null,colno:null,stack:[`Frame navigated to: ${t}`,`Expected to stay under: ${Cn}`,"",`Why this happens: the Live Preview is served from the same-origin ${Cn} subpath. A root-absolute navigation (an <a href="/…">, a form action, a location.href assignment, or an upstream redirect) leaves that subpath, so the request is answered by the editor rather than your app.`,"","Fix: if this app routes on the client, set `sameOriginSafe: false` in .codeyam/stack.json so the preview runs on its own dedicated origin."].join(`
|
|
267
|
+
`),timestampMs:Date.now(),dedupeKey:`preview-escape:${t}`,count:1}}function pA({previewUrl:t,resetKey:n,capturedErrors:s}){const[r,a]=l.useState(null),o=t.startsWith(Cn);l.useEffect(()=>{a(null)},[n,t]);const i=l.useCallback(u=>{const h=dA(u),p=uA(h,o);return a(p),p!==null&&p4(p),h},[o]),c=l.useCallback(()=>a(null),[]),d=l.useMemo(()=>r?[...s,hA(r)]:s,[s,r]);return{escaped:r!==null,overlayErrors:d,noteFrameLoad:i,clearEscape:c}}function mA(t,n){const s=l.useRef(!1);l.useEffect(()=>{s.current||t&&t.startCommand&&(t.intendedRunning||t.status==="stopped"&&(s.current=!0,n()))},[t,n])}function fA(t,n){const[s,r]=l.useState(!1),a=l.useCallback(()=>{s?(r(!1),t.deactivate(),t.clearSelection()):(r(!0),t.activate())},[s,t]);return l.useEffect(()=>{s&&(r(!1),t.clearSelection())},[n]),{isActive:s,toggle:a}}function gA(t,n=!0,s="running"){const r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(0),c=l.useRef(null);l.useEffect(()=>{t!=null&&(r.current!=null&&t!==r.current?(a.current=!1,i(h=>h+1)):r.current==null&&(a.current?n&&jd(t,c.current):i(h=>h+1)),r.current=t)},[t,n]);const d=l.useCallback(h=>{a.current=!0,h&&(c.current=h),n&&t!=null&&jd(t,h??c.current)},[t,n]),u=l.useCallback(h=>{n&&d4(h)},[n]);return{reloadNonce:o,handleIframeLoad:d,handleIframeError:u}}const bA=1500,xA=2e3,yA=3e3,vA=2;function jA(){return typeof window>"u"?!1:window.location.pathname.startsWith("/scenario/")?!0:Ot()}function wA(t,n=!1){const s=jA(),[r,a]=l.useState(s?!0:null),[o,i]=l.useState(null),[c,d]=l.useState(0),[u,h]=l.useState(0),p=l.useRef(null),m=l.useRef(null),f=l.useRef(null),g=l.useRef(!1),b=l.useRef(t),x=l.useRef(n);l.useEffect(()=>{b.current=t},[t]),l.useEffect(()=>{x.current=n},[n]);const y=l.useCallback(()=>{m.current!=null&&(clearTimeout(m.current),m.current=null)},[]),v=l.useCallback(async()=>{if(g.current||x.current)return;const S=b.current;if(!S)return;f.current&&f.current.abort();const w=new AbortController;f.current=w;const C=setTimeout(()=>w.abort(),yA);let P=!1;try{await fetch(S,{mode:"no-cors",cache:"no-store",signal:w.signal}),P=!0}catch{P=!1}finally{clearTimeout(C)}if(!g.current){if(i(Date.now()),P){if(d(0),p.current!==!0){const T=p.current===!1;p.current=!0,a(!0),T&&h(O=>O+1)}}else d(T=>{const O=T+1;return O>=vA&&p.current!==!1&&(p.current=!1,a(!1)),O});_()}},[]),_=l.useCallback(()=>{if(g.current)return;y();const S=p.current===!0?xA:bA;m.current=setTimeout(()=>{m.current=null,v()},S)},[y,v]),j=l.useCallback(()=>{y(),v()},[y,v]);l.useEffect(()=>{if(!s)return g.current=!1,v(),()=>{g.current=!0,y(),f.current&&(f.current.abort(),f.current=null)}},[v,y,s]),l.useEffect(()=>{s||v()},[t,v,s]);const k=l.useRef(n);return l.useEffect(()=>{if(s)return;const S=k.current;k.current=n,S&&!n&&v()},[n,v,s]),{healthy:r,lastProbeAt:o,failedProbeCount:c,reloadNonce:u,invalidate:j}}const Md={loaded:!1,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:null};function _A(t){const{active:n,trigger:s}=t,[r,a]=l.useState(Md),o=l.useRef(null),i=l.useCallback(()=>{var d;(d=o.current)==null||d.abort();const c=new AbortController;o.current=c,fetch("/api/dev-server-recent-requests",{signal:c.signal}).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.json()}).then(u=>{if(c.signal.aborted)return;const p=(u.stalls??[]).reduce((m,f)=>Math.max(m,f.durationMs??0),0);a({loaded:!0,stalledRequests:u.stalledRequests??0,fastRequests:u.fastRequests??0,longestStallMs:p,tailReadFailedReason:u.tailReadFailedReason??null})}).catch(u=>{c.signal.aborted||a({loaded:!0,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:u instanceof Error?u.message:"fetch failed"})})},[]);return l.useEffect(()=>{var c;if(!n){a(Md),(c=o.current)==null||c.abort();return}return i(),()=>{var d;(d=o.current)==null||d.abort()}},[n,s,i]),r}function kA(t){return!t||!t.loaded||t.tailReadFailedReason?null:t.stalledRequests>0?`Recent requests took up to ${Math.max(1,Math.round(t.longestStallMs/1e3))}s — the dev server is responding, just slowly. Check the dev-server log for what's blocking the render.`:t.fastRequests===0?"No recent activity in the dev-server log — the dev server may have stopped accepting connections. Restart it if this persists.":null}function SA({liveIframeHealthy:t,previewReachable:n}){return t===!0||n===!0}function NA({hasDevServerConfigured:t,hasServed:n}){return!t||n}const CA=2e3;function TA(t,n){const[s,r]=l.useState(0),a=l.useRef(t),o=l.useRef(n),i=l.useRef(0);return l.useEffect(()=>{const c=a.current,d=o.current;if(a.current=t,o.current=n,!(n===!1)||!(t===!0)||!(c===!1&&t===!0)&&!(d===!0&&n===!1))return;const f=Date.now();f-i.current<CA||(i.current=f,r(g=>g+1))},[t,n]),s}const tr={windowMs:1e4,threshold:4,ringBufferSize:16};function PA({pidNonce:t,probeNonce:n,draftNonce:s,windowMs:r=tr.windowMs,threshold:a=tr.threshold}){const[o,i]=l.useState(!1),[c,d]=l.useState([]),[u,h]=l.useState(0),p=l.useRef(!1),m=l.useRef(t),f=l.useRef(n),g=l.useRef(s),b=l.useCallback(y=>{const v=Date.now(),_=v-r;let j=[];d(S=>{const w=S.filter(C=>C.timestampMs>=_);return w.push({reason:y,timestampMs:v}),w.length>tr.ringBufferSize&&w.splice(0,w.length-tr.ringBufferSize),j=w,w});const k=j.filter(S=>S.timestampMs>=_).length;if(!p.current&&k>=a){p.current=!0,i(!0);return}p.current||h(S=>S+1)},[r,a]);l.useEffect(()=>{t!==m.current&&(m.current=t,b("pid"))},[t,b]),l.useEffect(()=>{n!==f.current&&(f.current=n,b("probe"))},[n,b]),l.useEffect(()=>{s!==g.current&&(g.current=s,b("draft"))},[s,b]);const x=l.useCallback(()=>{p.current=!1,i(!1),d([]),h(y=>y+1)},[]);return{tripped:o,recentReloads:c,gatedNonce:u,reset:x}}function OA(t,n,s=ti){const r=l.useRef(void 0);l.useEffect(()=>{if(!n){r.current=t;return}if(typeof t=="number"){if(r.current===void 0){r.current=t;return}t>r.current&&(r.current=t,s())}},[t,n,s])}const Id=20,AA="codeyam-error-capture";function RA(t,n=0){const[s,r]=l.useState([]),a=l.useCallback(()=>r([]),[]);return l.useEffect(()=>{r([])},[n]),l.useEffect(()=>{function o(i){const c=i.data;if(!c||c.source!==AA)return;const d=t.current;if(d&&i.source!==d.contentWindow)return;const u=c.payload;!u||typeof u!="object"||!u.dedupeKey||r(h=>{const p=h.findIndex(f=>f.dedupeKey===u.dedupeKey);if(p>=0){const f=h.slice();return f[p]={...f[p],count:f[p].count+1,timestampMs:u.timestampMs},f}const m=[...h,{...u,count:1}];return m.length>Id?m.slice(m.length-Id):m})}return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[t]),{errors:s,clear:a}}const Wa=[500,1e3,2e3];async function EA(t){try{const s=await(await fetch(`/api/probe-url?url=${encodeURIComponent(t)}`)).json();return{status:typeof(s==null?void 0:s.status)=="number"?s.status:null}}catch{return{status:null}}}async function MA(){try{const n=await(await fetch("/api/dev-server-log/slice?lines=40")).json();return Array.isArray(n==null?void 0:n.lines)?n.lines:[]}catch{return[]}}function IA(t,n){const[s,r]=l.useState({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return l.useEffect(()=>{if(!t){r({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return}let a=!1;return r({status:null,clickThroughBroken:!1,logLines:[],loading:!0}),(async()=>{const o=1+Wa.length;let i=null;for(let d=0;d<o;d++){if(a)return;const{status:u}=await EA(t);if(a)return;if(i=u,u===null||u<500){r({status:u,clickThroughBroken:!1,logLines:[],loading:!1});return}d<Wa.length&&await new Promise(h=>setTimeout(h,Wa[d]))}const c=await MA();a||r({status:i,clickThroughBroken:!0,logLines:c,loading:!1})})(),()=>{a=!0}},[t,n]),s}function P0({url:t,status:n,logLines:s,onRetry:r}){return e.jsx("div",{role:"alert","data-testid":"iframe-click-through-error-card",className:"absolute inset-0 z-20 flex items-center justify-center bg-zinc-950/85 p-6",children:e.jsxs("div",{className:"max-w-2xl w-full rounded-md border border-red-700 bg-zinc-900 text-zinc-100 shadow-xl",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-red-800 flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[e.jsxs("div",{className:"text-sm font-semibold text-red-300",children:["Scenario render failed (HTTP ",n,")"]}),e.jsx("div",{className:"mt-1 text-xs text-zinc-400 break-all",children:t}),e.jsx("div",{className:"mt-2 text-xs text-zinc-300",children:"The preview URL returned a server error. This is a bug — capture and click should always agree. Check the log below, and refresh once the underlying error is fixed."})]}),e.jsxs("div",{className:"flex-shrink-0 flex items-start gap-2",children:[e.jsx(at,{variant:"subtle",text:`Scenario render failed (HTTP ${n})
|
|
268
|
+
${t}
|
|
269
|
+
|
|
270
|
+
${s.join(`
|
|
271
|
+
`)}`,label:"Copy",className:"px-2.5 py-1 text-xs rounded border border-gray-600 bg-gray-800 text-gray-200 hover:bg-gray-700 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:r,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"})]})]}),e.jsx("div",{className:"px-5 py-4 max-h-72 overflow-auto font-mono text-[11px] leading-snug text-zinc-300 whitespace-pre-wrap",children:s.length>0?s.join(`
|
|
272
|
+
`):e.jsxs("span",{className:"text-zinc-500 italic",children:["No dev-server log lines available — see"," ",e.jsx("code",{children:".codeyam/logs/dev-server.log"}),"."]})})]})})}const W$=Object.freeze(Object.defineProperty({__proto__:null,IframeClickThroughErrorCard:P0},Symbol.toStringTag,{value:"Module"}));function LA(t){if(t===null||!t.startCommand)return{isRestarting:!1,isFailed:!1,isStarting:!1,isStopped:!1};const n=t.status==="failed",s=!n&&t.status!=="running"&&t.intendedRunning&&(t.restartCount??0)>0,r=!n&&t.intendedRunning&&t.status!=="running"&&(t.restartCount??0)===0,a=t.status==="stopped"&&!t.intendedRunning;return{isRestarting:s,isFailed:n,isStarting:r,isStopped:a}}const DA=20;function FA(t){const{hasDevServerConfigured:n,probeHealthy:s,backendIframeHealthy:r,isStarting:a,isRestarting:o,isFailed:i,isStopped:c,isPrePrototype:d,withinStartupGrace:u,previewReachable:h,hasEverServed:p}=t;return n?i?"crashed":r===!0||h===!0||s===!0&&r!==!1?null:d?"scaffolding":c?p?"stopped":null:o?"restarting":a||u||!p?null:s===!1?"reconnecting":r===!1&&s===!0?"disconnected":s===null?"probing":"reconnecting":null}function zA(t){return t===null||t.status!=="running"?!1:t.liveIframeHealthy!==!1}const $A=5,BA=3;function HA(t,n){return t===null||t<=0?!1:t<=(n==="backend"?BA:$A)}const Ld="Setting up your project",Dd="Preparing your project — the preview will appear once it's ready.",qA={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Aligning on the plan with you.",4:"Preparing the project environment.",5:"Wiring routes and seeding sample data."},WA={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Preparing the project environment."};function GA(t,n){return t===null?{title:Ld,body:Dd}:{title:Ld,body:(n==="backend"?WA:qA)[t]??Dd}}const UA={probing:{title:"Checking the Live Preview",body:"Making sure your app is responding before showing it.",spinner:!0,nextAction:"Use Retry now. If the check keeps failing, copy this report — your app's own startup output will say why it isn't answering."},starting:{title:"Starting your app",body:"Waiting for your app's server to come up…",spinner:!0,nextAction:"Use Retry now. If it never starts, copy this report and check your app's startup output for the reason."},restarting:{title:"Restarting your app",body:"Your app's server stopped unexpectedly. CodeYam is bringing it back automatically…",spinner:!0,nextAction:"Use Retry now. If it keeps stopping, copy this report — the cause is in your app's own startup output."},reconnecting:{title:"Reconnecting to your app",body:"Waiting for your app's server to respond…",spinner:!0,nextAction:"Use Retry now. If it stays unreachable, copy this report and check whether your app's server is still running."},disconnected:{title:"The preview lost its connection",body:"Your app's server is running fine. This preview just came unstuck from it after a restart, so it's showing nothing rather than something stale.",spinner:!1,nextAction:"Use Reload preview. There's no need to restart your app — it never stopped."},stopped:{title:"Your app isn't running",body:"Starting it automatically…",spinner:!1,nextAction:"Use Retry now. If it doesn't come up, copy this report and check your app's startup output."},crashed:{title:"Your app keeps stopping",body:"CodeYam has restarted it several times and it isn't staying up. This is something in the app itself rather than in the editor.",spinner:!1,nextAction:"Use Retry now to try once more. If it stops again, copy this report — the reason will be in your app's own startup output."},scaffolding:{title:"Setting up your project",body:"Preparing your project — the preview appears once it's ready.",spinner:!0,nextAction:"Nothing yet — setup finishes on its own. If it hasn't after a few minutes, copy this report."}};function O0({variant:t,restartCount:n=0,showRetry:s=!1,onRetry:r,bodyOverride:a}){const{title:o,body:i,spinner:c,nextAction:d}=UA[t],u=a??i,h=t==="disconnected",p=h||t==="crashed"||s,m=h?"Reload preview":"Retry now",{phase:f,attempts:g,retry:b}=eu(r??(()=>{}));return p?e.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":t,className:"absolute inset-0 z-50 flex items-center justify-center bg-white/90 p-6 backdrop-blur-sm dark:bg-gray-900/90",children:e.jsx(On,{severity:t==="crashed"?"error":"warning",testId:"preview-unhealthy-notice",headline:o,explanation:u,nextAction:d,actions:r?[{label:m,onClick:b,pending:f==="pending",pendingLabel:"Checking…",testId:"preview-unhealthy-overlay-retry"}]:[],actionFeedback:f==="unchanged"?e.jsxs("span",{"data-testid":"preview-unhealthy-overlay-unchanged",children:["Checked just now — the preview still isn’t back",g>1?` (${g} tries)`:"","."]}):null})}):e.jsx(Ju,{title:o,body:u,spinner:c,restartCount:n,variant:t})}const G$=Object.freeze(Object.defineProperty({__proto__:null,PreviewUnhealthyOverlay:O0},Symbol.toStringTag,{value:"Module"}));function VA(t){return t.slice().reverse().map(n=>{const s=n.filename!=null?`
|
|
273
|
+
at ${n.filename}${n.lineno!=null?`:${n.lineno}`:""}${n.colno!=null?`:${n.colno}`:""}`:"",r=n.stack?`
|
|
274
|
+
${n.stack}`:"",a=n.count>1?` (×${n.count})`:"";return`[${n.type}]${a} ${n.message}${s}${r}`}).join(`
|
|
275
|
+
|
|
276
|
+
`)}function YA(t){if(t.length===0)return"no reloads recorded";const n={};for(const s of t)n[s.reason]=(n[s.reason]??0)+1;return Object.entries(n).map(([s,r])=>`${s}×${r}`).join(", ")}function A0({count:t,onExpand:n,onClear:s}){const r=`${t} ${t===1?"Error":"Errors"}`;return e.jsx("div",{"data-testid":"preview-error-badge",className:"absolute bottom-3 right-3 z-50 pointer-events-auto",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-full shadow-lg border border-red-300 dark:border-red-800 bg-white dark:bg-gray-900",style:{background:"var(--bg-surface, rgba(255,255,255,0.97))"},children:[e.jsxs("button",{type:"button",onClick:n,"aria-label":`Expand ${r}`,className:"cursor-pointer flex items-center gap-1.5 pl-2.5 pr-2 py-1 text-xs font-medium text-red-700 dark:text-red-300 hover:bg-red-50 dark:hover:bg-red-950/40 rounded-l-full",children:[e.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full bg-red-600"}),e.jsx("span",{children:r}),e.jsx("span",{"aria-hidden":"true",className:"text-gray-400",children:"›"})]}),e.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss errors",className:"cursor-pointer px-2 py-1 text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 rounded-r-full",children:"✕"})]})})}const U$=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorBadge:A0},Symbol.toStringTag,{value:"Module"}));function R0({headline:t,tripped:n,onClear:s,closeAriaLabel:r="Dismiss errors",providerLabel:a}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3 border-b border-red-200 dark:border-red-900",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:t}),e.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:n?"Iframe frozen on its last load attempt. Copy the errors below, fix the code, then click Retry.":`Errors recorded from the running app. Copy them below to share with ${a}.`})]}),e.jsx("button",{type:"button",onClick:s,className:"cursor-pointer text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":r,children:"✕"})]})}const V$=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayHeader:R0},Symbol.toStringTag,{value:"Module"}));function KA(t){const n=t.filename?`${t.filename}${t.lineno!=null?`:${t.lineno}`:""}${t.colno!=null?`:${t.colno}`:""}`:"";return[`${t.type}: ${t.message}`,n,t.stack??""].filter(Boolean).join(`
|
|
277
|
+
`)}function E0({error:t,expanded:n,onToggle:s}){return e.jsxs("li",{className:"rounded border border-red-200 dark:border-red-900 bg-red-50/60 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsxs("button",{type:"button",onClick:s,className:"flex-1 min-w-0 flex items-start gap-2 text-left px-2 py-1.5 hover:bg-red-100/60 dark:hover:bg-red-900/30",children:[e.jsx("span",{className:"mt-0.5 text-red-500","aria-hidden":"true",children:n?"▾":"▸"}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-red-500 dark:text-red-400 mr-2",children:t.type}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 break-words",children:t.message}),t.count>1&&e.jsxs("span",{className:"ml-2 text-gray-500",children:["×",t.count]}),t.filename&&e.jsxs("span",{className:"block text-[11px] text-gray-500 mt-0.5 truncate",children:[t.filename,t.lineno!=null?`:${t.lineno}`:"",t.colno!=null?`:${t.colno}`:""]})]})]}),e.jsx("div",{className:"shrink-0 px-1.5 py-1.5",children:e.jsx(at,{variant:"icon",text:KA(t)})})]}),n&&t.stack&&e.jsx("pre",{className:"px-3 pb-2 text-[11px] font-mono text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",children:t.stack})]})}const Y$=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorRow:E0},Symbol.toStringTag,{value:"Module"}));function M0({errors:t,emptyHint:n}){const[s,r]=l.useState(null);return t.length===0?e.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:e.jsx("li",{className:"text-gray-500 px-2 py-3",children:n??"No runtime errors captured yet."})}):e.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:t.slice().reverse().map(a=>e.jsx(E0,{error:a,expanded:s===a.dedupeKey,onToggle:()=>r(s===a.dedupeKey?null:a.dedupeKey)},a.dedupeKey))})}const K$=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorList:M0},Symbol.toStringTag,{value:"Module"}));function I0({canCopy:t,reasonsSummary:n,copyState:s,onCopy:r,onCopyForAgent:a,onRetry:o,providerLabel:i}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 border-t border-red-200 dark:border-red-900 bg-gray-50 dark:bg-gray-900/40",children:[e.jsx("button",{type:"button",onClick:r,disabled:!t,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:"Copy errors"}),e.jsxs("button",{type:"button",onClick:a,disabled:!t,className:"px-2.5 py-1 text-xs rounded bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:["Copy and ask ",i]}),e.jsx("button",{type:"button",onClick:o,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"}),e.jsxs("span",{className:"ml-auto text-[11px] text-gray-500",children:["Reloads in last 10s: ",n,s==="copied"&&e.jsx("span",{className:"ml-2 text-emerald-600",children:"copied ✓"}),s==="failed"&&e.jsx("span",{className:"ml-2 text-red-500",children:"copy blocked"})]})]})}const J$=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayFooter:I0},Symbol.toStringTag,{value:"Module"})),JA=`Fix this error in the live preview. Here is what the captured runtime error reported:
|
|
278
|
+
|
|
279
|
+
`;function L0({tripped:t,errors:n,recentReloads:s,serverHealthy:r,onRetry:a,onClear:o,providerLabel:i}){const[c,d]=l.useState("idle"),[u,h]=l.useState(!0),p=l.useMemo(()=>VA(n),[n]),m=l.useMemo(()=>YA(s),[s]);if(l.useEffect(()=>{n.length===0&&h(!0)},[n.length]),!t&&n.length===0)return null;const f=r&&!t,g=f&&u&&n.length>0,b=t?`Live Preview paused — ${n.length} error${n.length===1?"":"s"} captured`:`${n.length} runtime error${n.length===1?"":"s"} captured`;async function x(y){const v=await Ck(y+p);d(v?"copied":"failed"),setTimeout(()=>d("idle"),1500)}return g?e.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":"false","data-collapsed":"true",className:"absolute inset-0 z-50 pointer-events-none",children:e.jsx(A0,{count:n.length,onExpand:()=>h(!1),onClear:o})}):e.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":t?"true":"false","data-collapsed":"false",className:"absolute inset-0 z-50 flex flex-col items-stretch p-4 pointer-events-none",children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl rounded-lg shadow-lg pointer-events-auto flex flex-col",style:{background:"var(--bg-surface, rgba(255,255,255,0.97))",border:"1px solid var(--border-default, #ef4444)",maxHeight:"100%"},children:[e.jsx(R0,{headline:b,tripped:t,onClear:f?()=>h(!0):o,closeAriaLabel:f?"Minimize errors":"Dismiss errors",providerLabel:i}),e.jsx(M0,{errors:n,emptyHint:t?`Breaker tripped before any runtime error was reported. Reasons in window: ${m}.`:null}),e.jsx(I0,{canCopy:n.length>0,reasonsSummary:m,copyState:c,onCopy:()=>x(""),onCopyForAgent:()=>x(JA),onRetry:a,providerLabel:i})]})})}const X$=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlay:L0},Symbol.toStringTag,{value:"Module"}));function XA(t){if(!t)return null;const n=Object.entries(t).map(([s,r])=>`${s}=${typeof r=="string"?r:JSON.stringify(r)}`);return n.length>0?n.join(", "):null}function D0({previewUrl:t,description:n,demonstratesState:s}){const r=l.useMemo(()=>{try{return new URL(t,window.location.origin).searchParams.get("_codeyam_scenario")}catch{return null}},[t]),a=l.useMemo(()=>XA(s),[s]);if(!r)return null;const o=n!=null&&n.trim()?n.trim():null;return e.jsxs("div",{className:"absolute top-2 left-2 z-30 flex flex-col gap-0.5 max-w-[16rem] px-2 py-1 rounded bg-black/60 backdrop-blur-sm border border-white/10 shadow-lg pointer-events-none select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),e.jsxs("span",{className:"text-[10px] font-medium text-white/90 tracking-wide uppercase",children:["Scenario: ",r]})]}),o?e.jsx("span",{className:"text-[10px] text-white/70 leading-snug whitespace-pre-line",children:o}):null,a?e.jsx("span",{className:"text-[9px] font-mono text-white/50 tracking-wide",children:a}):null]})}const Q$=Object.freeze(Object.defineProperty({__proto__:null,ActiveScenarioOverlay:D0},Symbol.toStringTag,{value:"Module"}));function F0(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx("h3",{className:"text-sm font-bold text-gray-900 dark:text-gray-100 uppercase tracking-tight",children:"Dev Server Crash Recovery Failed"})]}),e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 font-medium",children:"LAST 50 LOG LINES"})]})}const Z$=Object.freeze(Object.defineProperty({__proto__:null,CrashLogHeader:F0},Symbol.toStringTag,{value:"Module"}));function z0({logs:t}){return e.jsx("div",{className:"flex-1 bg-black p-4 font-mono text-[11px] leading-relaxed overflow-y-auto text-gray-300",children:t.length>0?t.map((n,s)=>e.jsx("div",{className:"whitespace-pre-wrap break-all border-l-2 border-gray-800 pl-3 mb-1",children:n},s)):e.jsx("div",{className:"italic text-gray-600",children:"No logs captured..."})})}const eB=Object.freeze(Object.defineProperty({__proto__:null,CrashLogViewer:z0},Symbol.toStringTag,{value:"Module"}));function $0({providerLabel:t}){return e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-red-800 dark:text-red-300 font-medium mb-1",children:"CodeYam was unable to restart the dev server after several attempts."}),e.jsxs("p",{className:"text-xs text-red-700/80 dark:text-red-400/80",children:["Copy the logs and share them with ",t," to investigate the underlying bug."]})]})}const tB=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooterMessage:$0},Symbol.toStringTag,{value:"Module"}));function B0({logs:t,copyWriter:n,providerLabel:s}){return e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-950/30 border-t border-red-100 dark:border-red-900/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx($0,{providerLabel:s}),e.jsx(at,{text:t.join(`
|
|
280
|
+
`),label:"Copy logs",writer:n})]})})}const nB=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooter:B0},Symbol.toStringTag,{value:"Module"}));function H0({logs:t,providerLabel:n}){return e.jsxs("div",{className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[e.jsx(F0,{}),e.jsx(z0,{logs:t}),e.jsx(B0,{logs:t,providerLabel:n})]})}const sB=Object.freeze(Object.defineProperty({__proto__:null,DevServerCrashLog:H0},Symbol.toStringTag,{value:"Module"})),Fd=20;function QA(t){if(!t)return null;try{return new Date(t).toLocaleTimeString()}catch{return null}}function q0({lastError:t,failureCount:n,failedAtMs:s,holder:r,onRetry:a,onReap:o}){const[i,c]=l.useState(!1),d=t.split(`
|
|
281
|
+
`),u=d.length>Fd,h=i||!u?d:d.slice(d.length-Fd),p=QA(s);return e.jsxs("div",{"data-testid":"dev-server-failed-panel",className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[e.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:["Dev server failed to start after ",n," ",n===1?"attempt":"attempts"]}),p&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["Last attempt: ",p]}),r&&e.jsxs("div",{"data-testid":"dev-server-failed-holder",className:"mt-3 rounded border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/30 px-3 py-2 text-xs text-amber-900 dark:text-amber-100",children:[e.jsxs("div",{children:["Port ",e.jsx("span",{className:"font-semibold",children:r.port})," is held by:"]}),e.jsxs("div",{className:"mt-1 font-mono",children:["PID ",r.pid," — ",r.command]})]})]}),e.jsx("pre",{"data-testid":"dev-server-failed-error",className:"flex-1 overflow-auto px-6 py-4 m-0 font-mono text-xs leading-relaxed text-gray-800 dark:text-gray-200 whitespace-pre",children:h.join(`
|
|
282
|
+
`)}),e.jsxs("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between gap-3",children:[u?e.jsx("button",{type:"button",onClick:()=>c(m=>!m),className:"text-xs text-gray-600 dark:text-gray-300 underline hover:text-gray-900 dark:hover:text-gray-100",children:i?"Show less":`Show all ${d.length} lines`}):e.jsx("span",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(at,{variant:"subtle",text:t,label:"Copy error",className:"shrink-0 px-3 py-1.5 text-sm font-medium rounded border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"}),r&&o&&e.jsx("button",{type:"button","data-testid":"dev-server-failed-reap",onClick:o,className:"px-4 py-1.5 text-sm font-medium rounded border border-amber-500 text-amber-700 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-900/50",children:"Kill orphan and retry"}),e.jsx("button",{type:"button","data-testid":"dev-server-failed-retry",onClick:a,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})]})]})]})}const rB=Object.freeze(Object.defineProperty({__proto__:null,DevServerFailedPanel:q0},Symbol.toStringTag,{value:"Module"}));function W0({diagnostic:t,onRetry:n}){const{expectedPort:s,actualPort:r,appName:a,currentStartCommand:o,remediation:i}=t;return e.jsxs("div",{"data-testid":"preview-port-mismatch-card",className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-auto",children:[e.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Dev server port conflict"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[a," bound port"," ",e.jsx("span",{className:"font-semibold",children:r}),", but the editor needs the app on port"," ",e.jsx("span",{className:"font-semibold",children:s})," so its reverse proxy (mocking, capture) can sit in front."]})]}),e.jsxs("div",{className:"flex-1 px-6 py-4 text-sm text-gray-800 dark:text-gray-200 space-y-3",children:[e.jsx("p",{children:i}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Current start command"}),e.jsx("pre",{className:"m-0 font-mono text-xs leading-relaxed whitespace-pre-wrap rounded bg-gray-100 dark:bg-gray-800 px-3 py-2",children:o||"(none configured)"})]})]}),e.jsx("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-end",children:e.jsx("button",{type:"button","data-testid":"preview-port-mismatch-retry",onClick:n,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})})]})}const aB=Object.freeze(Object.defineProperty({__proto__:null,PreviewPortMismatchCard:W0},Symbol.toStringTag,{value:"Module"})),zd=48,ZA=100,eR=320,tR=192;function nR({containerHeight:t,containerWidth:n,viewportHeight:s,viewportWidth:r}){if(!(r!=null&&s!=null&&n!=null&&t!=null&&r>0&&s>0&&n>0&&t>0))return{width:eR,height:tR,hasViewport:!1};const o=n-zd*2,i=t-zd*2-ZA,c=Math.min(1,o/r,i/s);return{width:Math.round(r*c),height:Math.round(s*c),hasViewport:!0}}function $o({containerHeight:t,containerWidth:n,heading:s="The app is being edited",onDismiss:r,scenarioName:a,screenshotPath:o,subtext:i="Live preview will load when the build agent is idle",viewportHeight:c,viewportWidth:d}){const{width:u,height:h,hasViewport:p}=nR({containerWidth:n,containerHeight:t,viewportWidth:d,viewportHeight:c}),m={width:u,height:h,...p?{overflowY:"auto"}:{}};return e.jsx("div",{className:"absolute inset-0 bg-white/90 dark:bg-gray-900/90 backdrop-blur-sm flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4 text-center p-6",children:[e.jsx("div",{className:"rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700 shadow-md",style:m,children:e.jsx(At,{screenshotPath:o??void 0,alt:a??"Scenario preview",className:p?"w-full h-auto":"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:s}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:i})]}),e.jsx("button",{onClick:r,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:"Dismiss"})]})})}const oB=Object.freeze(Object.defineProperty({__proto__:null,BuildingPreviewOverlay:$o},Symbol.toStringTag,{value:"Module"}));function G0({isActive:t,onToggle:n,interactionAvailable:s=!0}){return e.jsx("button",{onClick:s?n:void 0,disabled:!s,title:s?t?"Exit Debug Mode":"Debug Mode":"Click-to-select is unavailable for this stack's preview (served from a separate origin)",className:"absolute z-50",style:{bottom:16,right:16,width:40,height:40,borderRadius:"50%",border:t?"2px solid var(--accent-blue)":"1px solid var(--border-default)",background:t?"var(--accent-blue)":"var(--bg-surface)",color:t?"#000":"var(--text-secondary)",cursor:s?"pointer":"not-allowed",display:"none",alignItems:"center",justifyContent:"center",opacity:s?t?1:.6:.35,transition:"all 0.15s ease",fontSize:18},onMouseEnter:r=>{s&&(r.currentTarget.style.opacity="1")},onMouseLeave:r=>{s&&(t||(r.currentTarget.style.opacity="0.6"))},children:t?"✕":"🔍"})}const iB=Object.freeze(Object.defineProperty({__proto__:null,DebugModeButton:G0},Symbol.toStringTag,{value:"Module"}));function sR(){const[t,n]=l.useState(null),s=l.useCallback(async(a,o)=>{try{const i=await fetch("/api/open-in-editor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:a,line:o})}),c=await i.json().catch(()=>({}));if(!i.ok||(c==null?void 0:c.success)!==!0){n({message:(c==null?void 0:c.error)??`HTTP ${i.status}`,command:(c==null?void 0:c.command)??null});return}n(null)}catch(i){n({message:i instanceof Error?i.message:String(i),command:null})}},[]),r=l.useCallback(()=>n(null),[]);return{openInEditor:s,lastError:t,clearError:r}}function U0({tag:t,id:n,className:s,text:r,detectionMethod:a,previewUrl:o}){return e.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[e.jsx("div",{className:"rounded overflow-hidden flex-1",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",minHeight:200,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{style:{color:"var(--text-secondary)",fontSize:12},children:[e.jsxs("div",{className:"text-center",style:{color:"var(--text-secondary)"},children:["Preview: ",o.split("/").pop()]}),e.jsxs("div",{className:"mt-2 p-3 rounded",style:{background:"var(--bg-surface)",border:"1px dashed var(--border-default)",fontSize:11,fontFamily:"monospace"},children:["<",t,n?` id="${n}"`:"",s?` class="${s.slice(0,40)}"`:"",">",e.jsx("br",{}),r.slice(0,60),r.length>60?"...":""]})]})}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)"},children:["Detected via: ",a]})]})}const lB=Object.freeze(Object.defineProperty({__proto__:null,DebugModalElementPreview:U0},Symbol.toStringTag,{value:"Module"}));function V0({ancestors:t,onOpenInEditor:n}){return t.length===0?e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:12,fontStyle:"italic"},children:"No component ancestry available."}):e.jsx("ul",{className:"flex flex-col gap-1",style:{listStyle:"none",padding:0,margin:0},children:t.map((s,r)=>{const a=s.sourceFile&&s.lineNumber?`${s.sourceFile}:${s.lineNumber}`:s.sourceFile??"(unknown source)",o=!!s.sourceFile;return e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{background:"var(--bg-deep)"},children:[e.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontSize:12},children:s.componentName??"<anonymous>"}),e.jsx("span",{style:{color:"var(--text-secondary)",fontFamily:"monospace",fontSize:11,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),o&&e.jsx("button",{onClick:()=>n(s.sourceFile,s.lineNumber),className:"px-2 py-0.5 rounded text-xs",style:{background:"transparent",border:"1px solid var(--border-default)",color:"var(--accent-blue)",cursor:"pointer",fontSize:11},children:"Open in editor"})]},`${s.componentName??"anon"}-${r}`)})})}const cB=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestryList:V0},Symbol.toStringTag,{value:"Module"}));function Y0({ancestors:t,onOpenInEditor:n}){const[s,r]=l.useState(t.length>1);return t.length===0?null:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("button",{onClick:()=>r(a=>!a),className:"text-left",style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,cursor:"pointer",padding:0},children:[s?"▾":"▸"," Component ancestry (",t.length,")"]}),s&&e.jsx(V0,{ancestors:t,onOpenInEditor:n})]})}const dB=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestrySection:Y0},Symbol.toStringTag,{value:"Module"}));function K0({propsNames:t}){if(t.length===0)return null;const n=()=>{var s;(s=navigator.clipboard)==null||s.writeText(t.join(", "))};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontSize:12},children:"props:"}),t.map(s=>e.jsx("span",{onClick:n,className:"px-1.5 py-0.5 rounded",style:{background:"var(--bg-deep)",color:"var(--text-primary)",fontFamily:"monospace",fontSize:11,cursor:"pointer"},title:"Click to copy prop names",children:s},s))]})}const uB=Object.freeze(Object.defineProperty({__proto__:null,DebugPropsChips:K0},Symbol.toStringTag,{value:"Module"}));function J0({componentDisplay:t,sourceDisplay:n,tag:s,id:r,boundingBox:a,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:d,ancestors:u,propsNames:h,onOpenInEditor:p,onGoToIsolated:m,onCreatePlan:f,onClose:g}){const b=c||!o.trim();return e.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[e.jsx("h3",{style:{color:"var(--text-primary)",fontSize:16,fontWeight:600,margin:0},children:t}),n&&e.jsx("div",{className:"px-2 py-1 rounded",style:{background:"var(--bg-deep)",fontSize:12,fontFamily:"monospace",color:"var(--accent-blue)"},children:n}),e.jsxs("div",{className:"flex flex-col gap-1",style:{color:"var(--text-secondary)",fontSize:12},children:[e.jsxs("div",{children:["Element: <",s,">",r?` #${r}`:""]}),e.jsxs("div",{children:["Position: ",Math.round(a.x),", ",Math.round(a.y)," (",Math.round(a.width),"x",Math.round(a.height),")"]})]}),e.jsx(K0,{propsNames:h}),e.jsx(Y0,{ancestors:u,onOpenInEditor:p}),e.jsx("textarea",{value:o,onChange:x=>i(x.target.value),placeholder:"Describe the issue or desired change...",className:"flex-1 p-2 rounded resize-none",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",color:"var(--text-primary)",fontSize:13,minHeight:80,outline:"none"}}),e.jsxs("div",{className:"flex gap-2",children:[d&&e.jsx("button",{onClick:m,className:"px-3 py-1.5 rounded text-sm",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",color:"var(--text-primary)",cursor:"pointer"},children:"Go to Isolated Component"}),e.jsx("button",{onClick:f,disabled:b,className:"px-3 py-1.5 rounded text-sm flex-1",style:{background:b?"var(--bg-deep)":"var(--accent-blue)",border:"none",color:b?"var(--text-secondary)":"#000",cursor:b?"not-allowed":"pointer",fontWeight:600},children:c?"Creating...":"Create Fix Plan"}),e.jsx("button",{onClick:g,className:"px-3 py-1.5 rounded text-sm",style:{background:"transparent",border:"1px solid var(--border-default)",color:"var(--text-secondary)",cursor:"pointer"},children:"Cancel"})]})]})}const hB=Object.freeze(Object.defineProperty({__proto__:null,DebugModalInfoPanel:J0},Symbol.toStringTag,{value:"Module"}));function X0({error:t,onDismiss:n}){return e.jsxs("div",{onClick:s=>s.stopPropagation(),className:"fixed bottom-4 left-1/2 px-3 py-2 rounded",style:{transform:"translateX(-50%)",background:"var(--bg-surface)",border:"1px solid var(--accent-red, #f85149)",color:"var(--text-primary)",fontSize:12,zIndex:60,maxWidth:520},children:[e.jsxs("div",{children:["Open in editor failed: ",t.message]}),t.command&&e.jsx("div",{style:{fontFamily:"monospace",fontSize:11,marginTop:4},children:t.command}),e.jsx("button",{onClick:n,className:"mt-1",style:{background:"transparent",border:"none",color:"var(--accent-blue)",cursor:"pointer",fontSize:11,padding:0},children:"Dismiss"})]})}const pB=Object.freeze(Object.defineProperty({__proto__:null,OpenInEditorErrorToast:X0},Symbol.toStringTag,{value:"Module"}));function Q0({element:t,previewUrl:n,onClose:s,onGoToIsolated:r,onCreatePlan:a}){const[o,i]=l.useState(""),[c,d]=l.useState(!1),{openInEditor:u,lastError:h,clearError:p}=sR(),m=async()=>{d(!0);try{await a(o,t)}finally{d(!1)}},f=t.componentName??`<${t.element.tag}>`,g=t.sourceFile?`${t.sourceFile}${t.lineNumber?`:${t.lineNumber}`:""}`:null;return e.jsxs("div",{className:"absolute inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.7)"},onClick:s,children:[e.jsxs("div",{className:"flex gap-4 p-6 rounded-lg max-w-3xl w-full mx-4",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",maxHeight:"80vh"},onClick:b=>b.stopPropagation(),children:[e.jsx(U0,{tag:t.element.tag,id:t.element.id,className:t.element.className,text:t.element.text,detectionMethod:t.detectionMethod,previewUrl:n}),e.jsx(J0,{componentDisplay:f,sourceDisplay:g,tag:t.element.tag,id:t.element.id,boundingBox:t.element.boundingBox,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:!!t.componentName,ancestors:t.ancestors,propsNames:t.propsNames,onOpenInEditor:u,onGoToIsolated:()=>r(t.componentName),onCreatePlan:m,onClose:s})]}),h&&e.jsx(X0,{error:h,onDismiss:p})]})}const mB=Object.freeze(Object.defineProperty({__proto__:null,DebugModal:Q0},Symbol.toStringTag,{value:"Module"}));function Z0(){return e.jsx("div",{className:"absolute z-40 px-2 py-1 rounded",style:{bottom:8,right:8,background:"var(--bg-surface)",border:"1px solid var(--accent-blue)",color:"var(--accent-blue)",fontSize:11,fontWeight:600,pointerEvents:"none",fontFamily:"system-ui"},"data-testid":"debug-freeze-pill",children:"Debug — frozen"})}const fB=Object.freeze(Object.defineProperty({__proto__:null,DebugFreezePill:Z0},Symbol.toStringTag,{value:"Module"}));function ew({hoveredElement:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 z-40",style:{border:"3px solid var(--accent-blue)",cursor:"crosshair",pointerEvents:"none"}}),t&&e.jsx("div",{className:"absolute z-40 px-2 py-1 rounded",style:{top:8,left:8,background:"var(--accent-blue)",color:"#000",fontSize:12,fontWeight:600,pointerEvents:"none"},children:t.componentName??`<${t.element.tag}>`}),e.jsx(Z0,{})]})}const gB=Object.freeze(Object.defineProperty({__proto__:null,DebugOverlay:ew},Symbol.toStringTag,{value:"Module"}));function tw(){return e.jsx("div",{className:"absolute z-40 pointer-events-none",style:{top:0,left:0,right:0,bottom:0,border:"2px solid var(--accent-blue, #D7FF63)",borderRadius:4,boxSizing:"border-box"},children:e.jsx("div",{style:{position:"absolute",top:0,left:16,padding:"2px 8px",background:"var(--accent-blue, #D7FF63)",color:"#000",fontSize:10,fontWeight:700,fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:"0 0 4px 4px",letterSpacing:.5},children:"INSPECT MODE"})})}const bB=Object.freeze(Object.defineProperty({__proto__:null,InspectModeRibbon:tw},Symbol.toStringTag,{value:"Module"}));function rR(t,n,s){const{width:r,maxHeight:a,gap:o}=s,i=t.y+t.height+o,c=i+a>n.height,d=c?Math.max(o,t.y-a-o):i,u=Math.max(o,Math.min(t.x,n.width-r-o));return{top:d,left:u,placedAbove:c}}function nw({onDismiss:t}){return e.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:999998,background:"transparent"}})}const xB=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBackdrop:nw},Symbol.toStringTag,{value:"Module"}));function sw({match:t,onOpen:n}){return e.jsxs("button",{onClick:()=>n(t),style:{width:"100%",textAlign:"left",padding:"6px 8px",background:"rgba(88, 166, 255, 0.12)",color:"inherit",border:"1px solid rgba(88, 166, 255, 0.4)",borderRadius:4,cursor:"pointer",fontFamily:"monospace",fontSize:11},children:[e.jsx("div",{style:{fontWeight:600},children:t.endpoint}),e.jsx("div",{style:{opacity:.85},children:t.jsonPath})]})}const yB=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchButton:sw},Symbol.toStringTag,{value:"Module"}));function rw({matches:t,onOpen:n}){return e.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},children:t.map((s,r)=>e.jsx("li",{children:e.jsx(sw,{match:s,onOpen:n})},`${s.endpoint}${s.jsonPath}${r}`))})}const vB=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchList:rw},Symbol.toStringTag,{value:"Module"}));function aw({clickedText:t,matches:n,corpusEmpty:s,onOpenInPanel:r}){return e.jsxs("div",{style:{padding:"8px 12px"},children:[e.jsxs("div",{style:{opacity:.7,marginBottom:6,wordBreak:"break-all"},children:["Clicked: ",e.jsx("code",{children:ow(t,120)||"(empty)"})]}),s?e.jsx("div",{style:{opacity:.85},children:"No mocks were consumed on this page load yet."}):n.length===0?e.jsx("div",{style:{opacity:.85},children:"No direct mock value matches — this value may be computed or concatenated."}):e.jsx(rw,{matches:n,onOpen:r})]})}function ow(t,n){return t.length<=n?t:t.slice(0,n-1)+"…"}const jB=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBody:aw,truncate:ow},Symbol.toStringTag,{value:"Module"}));function iw({onDismiss:t}){return e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--border-muted, #374151)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontWeight:600},children:"Data source"}),e.jsx("button",{onClick:t,"aria-label":"Dismiss",style:{background:"transparent",color:"inherit",border:"none",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}const wB=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardHeader:iw},Symbol.toStringTag,{value:"Module"})),$d=320,Bd=320,aR=8;function lw({clickedText:t,matches:n,anchor:s,onOpenInPanel:r,onDismiss:a,corpusEmpty:o}){l.useEffect(()=>{function h(p){p.key==="Escape"&&a()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[a]);const i=typeof window<"u"?window.innerHeight:800,c=typeof window<"u"?window.innerWidth:1200,{top:d,left:u}=rR(s,{width:c,height:i},{width:$d,maxHeight:Bd,gap:aR});return e.jsxs(e.Fragment,{children:[e.jsx(nw,{onDismiss:a}),e.jsxs("div",{style:{position:"fixed",top:d,left:u,width:$d,maxHeight:Bd,zIndex:999999,background:"var(--bg-surface, #1f2937)",color:"var(--text-primary, #f3f4f6)",border:"1px solid var(--border-muted, #374151)",borderRadius:8,boxShadow:"0 10px 30px rgba(0,0,0,0.5)",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:12,overflow:"auto"},role:"dialog","aria-label":"Mock data source inspector",children:[e.jsx(iw,{onDismiss:a}),e.jsx(aw,{clickedText:t,matches:n,corpusEmpty:o,onOpenInPanel:r})]})]})}const _B=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCard:lw},Symbol.toStringTag,{value:"Module"}));function cw({healthy:t,reason:n,authNeeded:s}){const r=s?"auth-needed":t===!0?"healthy":t===!1?"unhealthy":"unknown",o={healthy:{bg:"#1f3a24",border:"#2f6b3a",dot:"#4ade80",label:"Live"},unhealthy:{bg:"#3a1f1f",border:"#6b2f2f",dot:"#f87171",label:"Stale"},unknown:{bg:"#2a2a2a",border:"#444",dot:"#9ca3af",label:"—"},"auth-needed":{bg:"#3a2f1f",border:"#6b552f",dot:"#fbbf24",label:"Sign in"}}[r];return e.jsxs("div",{role:"status","aria-label":`Live preview iframe: ${r}`,title:r==="auth-needed"?"Live Preview runs on a separate secured host that needs sign-in. Open it top-level to sign in, then reload.":r==="healthy"?"Live Preview iframe is healthy and matches the running dev server.":r==="unhealthy"?n?`Live Preview iframe is stale: ${n}`:"Live Preview iframe is stale and out of sync with the dev server.":"Live Preview iframe health unknown.",style:{position:"absolute",top:8,right:8,display:"inline-flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:999,backgroundColor:o.bg,border:`1px solid ${o.border}`,color:"#fff",fontSize:11,fontFamily:"monospace",zIndex:30,pointerEvents:"auto"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:o.dot,boxShadow:r==="healthy"?`0 0 6px ${o.dot}`:void 0}}),e.jsx("span",{children:o.label})]})}const kB=Object.freeze(Object.defineProperty({__proto__:null,LiveIframeHealthPill:cw},Symbol.toStringTag,{value:"Module"})),oR=new Set(["localhost","127.0.0.1","[::1]","::1"]);function Hd(t){if(!t)return!1;try{return!oR.has(new URL(t).hostname)}catch{return!1}}function dw(t,n,s){if(t===!1)return"local";const r=typeof window<"u"?window.location.origin:null;return Hd(n)||Hd(r)?"hosted":"tunnel"}function iR(t,n,s,r){return/^https?:\/\//i.test(s??"")?!0:dw(t,n)==="local"}function uw(t,n){switch(t){case"local":return{heading:`Nothing is answering on port ${n}`,ariaLabel:"Preview port not answering",showForwardFlag:!1};case"hosted":return{heading:"This preview needs a dedicated preview host",ariaLabel:"Preview host not provisioned",showForwardFlag:!1};case"tunnel":return{heading:`Forward port ${n} to see the Live Preview`,ariaLabel:"Preview port forward required",showForwardFlag:!0}}}function hw({hint:t,onRecheck:n}){const{inContainer:s,reachableUrl:r}=ai(),a=dw(s,r),{heading:o,showForwardFlag:i}=uw(a,t.port),{phase:c,attempts:d,retry:u}=eu(n),h=a==="local"?`This app does its own page routing, so its preview is served on its own address — port ${t.port} on this machine. The editor is running here too, so that address is already the right one. Nothing is answering on it.`:a==="hosted"?`This app does its own page routing, so its preview is served on its own address — port ${t.port}. But that address points at YOUR machine, not the one running the app. You reach this editor over a hosted address rather than a port forward, so there is no forward that could resolve it.`:`This app does its own page routing, so its preview is served on its own address — port ${t.port}. Your connection to this machine only carries the editor's port, so your browser can't reach that one.`,p=hi(r,a==="hosted"),m=p?`A preview address for this machine already exists and is answering: ${p}. Point the preview at it with: ${xr(p)} — it takes effect immediately, no restart needed.`:"This one isn't yours to fix from here — a dedicated preview host has to be provisioned for this machine, alongside the editor's own address. Copy this report and send it to whoever set the machine up.",f=a==="local"?"Start your app's server, then reload the preview.":a==="hosted"?m:`Add ${t.flag} to the connection you use to reach this machine, then reload the preview. Copy this report to get the flag with its context.`;return e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center p-8",style:{background:"var(--bg-surface)"},children:e.jsx(On,{severity:"blocked",testId:"preview-forward-port-notice",headline:o,explanation:h,nextAction:f,diagnostics:i?t.flag:void 0,actions:[{label:i?"I've added it — reload preview":"Reload preview",onClick:u,pending:c==="pending",pendingLabel:"Rechecking…",testId:"preview-forward-port-notice-recheck"}],actionFeedback:c==="unchanged"?e.jsxs("span",{"data-testid":"preview-forward-port-notice-unchanged",children:["Checked just now — port ",t.port," still isn’t reachable",d>1?` (${d} tries)`:"","."]}):null})})}const SB=Object.freeze(Object.defineProperty({__proto__:null,PreviewForwardPortNotice:hw,forwardPortNoticeCopy:uw},Symbol.toStringTag,{value:"Module"}));function pw(t){if(!t)return null;let n;try{n=new URL(t)}catch{return null}if(!(n.hostname==="localhost"||n.hostname==="127.0.0.1"||n.hostname==="[::1]"||n.hostname==="::1"))return null;const r=Number(n.port);return!Number.isInteger(r)||r<=0||r>65535?null:{port:r,flag:`-L ${r}:localhost:${r}`}}function qd(t,n){return(n==null?void 0:n.previewOrigin)??(t==null?void 0:t.previewOrigin)??null}function mw(t,n){if(!t||!/^https?:\/\//i.test(t))return!0;const s=typeof window<"u"?window.location.origin:null;if(!s)return!1;try{return new URL(t).origin===s}catch{return!0}}async function lR(t,n){if(mw(t))return"unknown";const s=t;try{await fetch(s,{credentials:"include",mode:"no-cors",redirect:"follow"})}catch{return pw(s)?"unreachable":"unknown"}try{return(await fetch(s,{credentials:"include",mode:"cors",redirect:"manual"})).type==="opaqueredirect"?"needs-signin":"authed"}catch{return"unknown"}}function cR(t,n){const[s,r]=l.useState("unknown"),[a,o]=l.useState(0),[i,c]=l.useState("idle"),[d,u]=l.useState(0),h=l.useCallback(async()=>{const m=await lR(t);r(f=>(f==="needs-signin"&&m==="authed"&&o(g=>g+1),m)),m!=="unknown"&&!Ot()&&h4(m==="needs-signin"?t??null:null)},[t]);l.useEffect(()=>{h()},[h,n]);const p=l.useCallback(()=>{c("pending"),u(m=>m+1),h().finally(()=>c("unchanged"))},[h]);return{authState:s,recheck:p,remountNonce:a,recheckPhase:i,recheckAttempts:d}}function Wd(t){if(!t||typeof t!="object")return null;const n=t;return{componentName:n.componentName??null,sourceFile:n.sourceFile??null,lineNumber:n.lineNumber??null,detectionMethod:n.detectionMethod??"dom-heuristics",ancestors:Array.isArray(n.ancestors)?n.ancestors:[],propsNames:Array.isArray(n.propsNames)?n.propsNames:[],element:n.element}}function dR(t){const[n,s]=l.useState(!1),[r,a]=l.useState(null),[o,i]=l.useState(null),c=l.useRef(!1),d=l.useCallback(m=>{const f=t.current;f!=null&&f.contentWindow&&f.contentWindow.postMessage({type:m},"*")},[t]),u=l.useCallback(()=>{s(!0),a(null),i(null),d("codeyam:debug:activate")},[d]),h=l.useCallback(()=>{s(!1),a(null),i(null),d("codeyam:debug:deactivate")},[d]),p=l.useCallback(()=>{i(null)},[]);return l.useEffect(()=>{function m(f){!f.data||typeof f.data.type!="string"||(f.data.type==="codeyam:debug:hover"?a(Wd(f.data.payload)):f.data.type==="codeyam:debug:selected"&&i(Wd(f.data.payload)))}return window.addEventListener("message",m),()=>window.removeEventListener("message",m)},[]),l.useEffect(()=>{c.current&&!n&&(c.current=!1),n&&(c.current=!0)},[n]),{isActive:n,hoveredElement:r,selectedElement:o,activate:u,deactivate:h,clearSelection:p}}const uR=/^\/api\/mock-panel(\/.*)?$/;function hR(t,n){return t.toUpperCase()!=="GET"?!1:uR.test(n)}function pR(t){return Array.isArray(t)?t.filter(n=>n.consumedThisPageLoad&&!hR(n.method,n.pathPattern)).map(n=>({endpoint:`${n.method} ${n.pathPattern}`,body:n.body})):[]}async function mR(t,n,s){return(await fetch("/api/debug/create-plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:t,componentName:n.componentName,sourceFile:n.sourceFile,lineNumber:n.lineNumber,detectionMethod:n.detectionMethod,element:n.element,previewUrl:s})})).json()}const fR=12;function gR(t,n,s){if(n.length===0)return[];const r=[];return Bo(t,n,s,"$",0,new Set,r),r}function bR(t,n){const s=[];for(const o of t)for(const i of gR(o.body,n,o.endpoint))s.push(i);const r=new Set,a=[];for(const o of s){const i=`${o.endpoint}\0${o.jsonPath}`;r.has(i)||(r.add(i),a.push(o))}return a.sort((o,i)=>{const c=i.matchedValue.length-o.matchedValue.length;return c!==0?c:i.pathDepth-o.pathDepth}),a}function Bo(t,n,s,r,a,o,i){if(t==null)return;const c=typeof t;if(c==="string"||c==="number"||c==="boolean"){String(t)===n&&i.push({endpoint:s,jsonPath:r,matchedValue:String(t),pathDepth:a});return}if(!(a>=fR)&&!o.has(t)){if(o.add(t),Array.isArray(t))for(let d=0;d<t.length;d++)Bo(t[d],n,s,`${r}[${d}]`,a+1,o,i);else if(c==="object")for(const[d,u]of Object.entries(t))Bo(u,n,s,`${r}.${d}`,a+1,o,i);o.delete(t)}}const xR={backgroundColor:"#1e1e1e",backgroundImage:"conic-gradient(#262626 25%, #1e1e1e 0 50%, #262626 0 75%, #1e1e1e 0)",backgroundSize:"16px 16px"};function fw({providerLabel:t,buildingScenarioName:n,buildingScenarioSlug:s,buildingScenarioDescription:r,buildingScreenshotPath:a,containerHeight:o,containerRef:i,containerWidth:c,currentHeight:d,currentWidth:u,emptyStateMessage:h,isFilled:p,onDismissBuildingOverlay:m,historicalScreenshotPath:f,historicalScenarioName:g,historicalHeading:b,historicalSubtext:x,onDismissHistoricalPreview:y,previewSlug:v,previewUrl:_,previewOrigin:j,scale:k,commandNonce:S}){var bt,Ds;const w=!!g&&!s,C=!!s||w,P=l.useRef(null),T=i??P,O=l.useRef(null),{status:N,restart:E}=nk();mA(N,E);const{isRestarting:I,isFailed:ee,isStarting:B,isStopped:z}=LA(N),{stepState:Y}=Is(),te=HA((Y==null?void 0:Y.step)??null,(Y==null?void 0:Y.mode)??"ui"),R=(N==null?void 0:N.liveIframeHealthy)!==void 0,{reloadNonce:L,handleIframeLoad:M,handleIframeError:K}=gA((N==null?void 0:N.pid)??null,R,N==null?void 0:N.status),ie=(N==null?void 0:N.status)==="failed",{healthy:$,failedProbeCount:V,reloadNonce:ae,invalidate:ne}=wA(_,ie),me=Pb(N==null?void 0:N.liveIframeHealthy,750),q=TA($,me),[le,Pe]=l.useState(0);l.useEffect(()=>sk(()=>{Pe(Ze=>Ze+1)}),[]),OA(N==null?void 0:N.sourceVersion,N==null?void 0:N.liveReloadEnabled);const{authState:Ce,recheck:F,remountNonce:J}=cR(j,_),Z=l.useMemo(()=>pw(j),[j]),ue=PA({pidNonce:L,probeNonce:ae+q,draftNonce:le+J}),ve=ue.gatedNonce,{errors:fe,clear:se}=RA(O,ve),{escaped:Q,overlayErrors:ze,noteFrameLoad:ge,clearEscape:Ae}=pA({previewUrl:_,resetKey:ve,capturedErrors:fe}),Te=IA(_,ve),H=l.useCallback(()=>{ue.reset(),se(),Ae(),ne()},[ue,se,Ae,ne]),G=l.useCallback(()=>{se(),Ae()},[se,Ae]),be=l.useCallback(()=>ti(),[]),de=(N==null?void 0:N.devServerStartedSecsAgo)??null,je=de!==null&&de<DA,Ne=!!(N!=null&&N.startCommand),Ee=SA({liveIframeHealthy:me,previewReachable:(bt=N==null?void 0:N.previewProbe)==null?void 0:bt.reachable}),[Le,He]=l.useState(!1);l.useEffect(()=>{Ee&&!Le&&He(!0)},[Ee,Le]);const X=Ee||Le,Oe=NA({hasDevServerConfigured:Ne,hasServed:X}),it=Oe?_:"about:blank",tt=S0(it,ve,S),[qt,Ke]=l.useState(null),kt=Oe&&qt!==tt,_e=FA({hasDevServerConfigured:Ne,probeHealthy:$,backendRunning:(N==null?void 0:N.status)==="running",backendIframeHealthy:me,isStarting:B,isRestarting:I,isFailed:ee,isStopped:z,isPrePrototype:te,withinStartupGrace:je,previewReachable:((Ds=N==null?void 0:N.previewProbe)==null?void 0:Ds.reachable)===!0,hasEverServed:X}),ce=l.useRef(void 0);l.useEffect(()=>{var Xt;if(ce.current===_e)return;const Ze=ce.current;ce.current=_e,console.debug(`[preview-overlay] ${Ze===void 0?"(init)":Ze??"none"} → ${_e??"none"}`,{status:N==null?void 0:N.status,intendedRunning:N==null?void 0:N.intendedRunning,restartCount:N==null?void 0:N.restartCount,pid:N==null?void 0:N.pid,liveIframeHealthy:N==null?void 0:N.liveIframeHealthy,previewProbeReachable:(Xt=N==null?void 0:N.previewProbe)==null?void 0:Xt.reachable,devServerStartedSecsAgo:de,withinStartupGrace:je,probeHealthy:$,isStarting:B,isRestarting:I,isFailed:ee,isStopped:z})},[_e,N,de,je,$,B,I,ee,z]);const U=N==null?void 0:N.portDiagnostic,Re=(U==null?void 0:U.conflict)===!0,De=_e==="scaffolding"?GA((Y==null?void 0:Y.step)??null,(Y==null?void 0:Y.mode)??"ui").body:void 0,qe=_A({active:_e==="reconnecting",trigger:V}),nt=_e==="reconnecting"?kA(qe):null,lt=De??nt??void 0,Fe=V>=10,{isActive:ct,hoveredElement:Ie,selectedElement:$e,activate:D,deactivate:st,clearSelection:Ve}=dR(O),St=l.useCallback(()=>{ct?st():D()},[ct,D,st]),{entries:Wt}=rk(v??null),{isActive:Rt,toggle:fn}=fA({activate:D,deactivate:st,clearSelection:Ve},L);l.useEffect(()=>(yc({isActive:Rt,previewSlug:v??null}),()=>{yc({isActive:!1,previewSlug:null})}),[Rt,v]),l.useEffect(()=>ak(()=>{fn()}),[fn]);const Ln=Rt&&$e?$e.element.text.trim():"",ns=l.useMemo(()=>pR(Wt),[Wt]),ma=l.useMemo(()=>!Rt||!Ln?[]:bR(ns,Ln),[Rt,Ln,ns]),Et=l.useCallback(async Ze=>{Ve(),st();try{const bn=await(await fetch("/api/scenarios")).json(),xn=Array.isArray(bn)?bn.find(Dn=>Dn.componentName===Ze):null;if(xn!=null&&xn.slug){const Dn=ci(window.location),Fs=Du(xn.slug,Dn,null,0,j);window.history.pushState(null,"",Fs);return}}catch{}window.history.pushState(null,"",`${ni()}/entities`)},[Ve,st,j]),gn=l.useCallback(async(Ze,Xt)=>{try{await mR(Ze,Xt,_),Ve(),st()}catch(bn){console.error("Failed to create debug plan:",bn)}},[_,Ve,st]);return e.jsx("div",{ref:T,className:`relative flex-1 flex overflow-hidden ${p?"":"items-center justify-center p-8"}`,style:p?{backgroundColor:"#fff"}:xR,children:_?e.jsxs(e.Fragment,{children:[e.jsx(C0,{ref:O,currentHeight:d,currentWidth:u,isFilled:p,previewUrl:it,scale:k,iframeKey:tt,onLoad:()=>{if(Oe){const Ze=ge(O.current);M(Ze??_),Ke(tt)}},onError:K}),!Oe&&e.jsx(k0,{hasDevServerConfigured:Ne}),kt&&e.jsx(T0,{}),!p&&e.jsx(D0,{previewUrl:_,description:r}),!p&&e.jsx(cw,{healthy:me,reason:(N==null?void 0:N.iframeLastError)??null,authNeeded:Ce==="needs-signin"}),Ce==="needs-signin"&&j&&e.jsx(om,{previewOrigin:j,onRecheck:F}),Ce==="unreachable"&&Z&&e.jsx(hw,{hint:Z,onRecheck:F}),ct&&e.jsx(ew,{hoveredElement:Ie}),Rt&&e.jsx(tw,{}),$e&&!Rt&&e.jsx(Q0,{element:$e,previewUrl:_,onClose:Ve,onGoToIsolated:Et,onCreatePlan:gn}),$e&&Rt&&e.jsx(lw,{clickedText:Ln,matches:ma,anchor:$e.element.boundingBox,corpusEmpty:ns.length===0,onOpenInPanel:Ze=>{ok({routeKey:Ze.endpoint,jsonPath:Ze.jsonPath}),Ve()},onDismiss:Ve}),!C&&e.jsx(G0,{isActive:ct,onToggle:St,interactionAvailable:mw(j)}),ie?e.jsx(q0,{lastError:(N==null?void 0:N.lastError)??(N==null?void 0:N.lastExit)??"(no error message captured)",failureCount:(N==null?void 0:N.failureCount)??0,failedAtMs:N==null?void 0:N.failedAtMs,holder:N==null?void 0:N.holder,onRetry:E,onReap:async()=>{await fetch("/api/editor-dev-server/reap",{method:"POST",headers:{"Content-Type":"application/json"}})}}):Re&&U?e.jsx(W0,{diagnostic:U,onRetry:E}):_e&&(_e==="crashed"?e.jsx(H0,{logs:(N==null?void 0:N.logs)??[],providerLabel:t}):e.jsx(O0,{variant:_e,restartCount:(N==null?void 0:N.restartCount)??0,showRetry:Fe,onRetry:_e==="disconnected"?be:ne,bodyOverride:lt})),e.jsx(L0,{tripped:ue.tripped||Q,errors:ze,recentReloads:ue.recentReloads,serverHealthy:zA(N),onRetry:H,onClear:G,providerLabel:t}),Te.clickThroughBroken&&Te.status!==null&&e.jsx(P0,{url:_,status:Te.status,logLines:Te.logLines,onRetry:H}),s&&m&&e.jsx($o,{containerHeight:o,containerWidth:c,onDismiss:m,scenarioName:n??null,screenshotPath:a??null,viewportHeight:d,viewportWidth:u}),w&&y&&e.jsx($o,{containerHeight:o,containerWidth:c,heading:b??void 0,subtext:x??void 0,onDismiss:y,scenarioName:g??null,screenshotPath:f??null,viewportHeight:d,viewportWidth:u})]}):e.jsx(_0,{message:h})})}const NB=Object.freeze(Object.defineProperty({__proto__:null,PreviewCanvas:fw},Symbol.toStringTag,{value:"Module"}));function gw({prompt:t}){const[n,s]=l.useState(!0);return e.jsxs("section",{"aria-label":"What you asked for",style:{border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"0.875rem 1rem",marginBottom:"1.5rem",background:"var(--bg-elevated)",fontFamily:"'IBM Plex Mono', monospace"},children:[e.jsxs("button",{type:"button",onClick:()=>s(r=>!r),"aria-expanded":n,style:{width:"100%",background:"transparent",border:"none",padding:0,margin:0,color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"inherit"},children:[e.jsx("span",{children:"What you asked for"}),e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",transition:"transform 150ms ease",transform:n?"rotate(0deg)":"rotate(-90deg)",color:"var(--text-muted)",fontSize:"0.75rem"},children:"▾"})]}),n?e.jsx("div",{style:{marginTop:"0.625rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",color:"var(--text-secondary)",fontSize:"0.8125rem",lineHeight:1.55},children:e.jsx(Bt,{children:t})}):null]})}const CB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDescriptionCard:gw},Symbol.toStringTag,{value:"Module"}));function bw({html:t,viewport:n}){return e.jsxs("div",{children:[e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Your chosen design"}),e.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:"6px",overflow:"hidden"},children:e.jsx(Ml,{html:t,url:"",title:"Chosen design",viewport:n,theme:"light",darkVars:null})})]})}const TB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupChosenMockup:bw},Symbol.toStringTag,{value:"Module"}));function xw({assets:t}){return e.jsxs("div",{children:[e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Design assets you added"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},children:t.map(n=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",padding:"0.5rem 0.625rem",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-input)"},children:[e.jsx("span",{style:{fontSize:"0.8125rem",fontWeight:500,color:"var(--text-primary)"},children:n.filename}),n.description.trim().length>0&&e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:n.description})]},n.filename))})]})}const PB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignAssetList:xw},Symbol.toStringTag,{value:"Module"}));function yw({mockupHtml:t,mockupViewport:n,assets:s}){const r=t!==null,a=s.length>0;return!r&&!a?null:e.jsxs("section",{"aria-label":"Your chosen design",style:{border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"0.875rem 1rem",marginBottom:"1.5rem",background:"var(--bg-elevated)",fontFamily:"'IBM Plex Mono', monospace"},children:[r&&e.jsx("div",{style:{marginBottom:a?"1rem":0},children:e.jsx(bw,{html:t,viewport:n})}),a&&e.jsx(xw,{assets:s})]})}const OB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignCard:yw},Symbol.toStringTag,{value:"Module"}));function vw(){return e.jsxs("header",{style:{marginBottom:"1.5rem",fontFamily:"'IBM Plex Mono', monospace"},children:[e.jsxs("h1",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-primary)",margin:"0 0 0.5rem 0",display:"flex",alignItems:"baseline",gap:"0.5rem"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-muted)",letterSpacing:"-0.1em"},children:"::"}),"Setting up your project…"]}),e.jsx("p",{style:{margin:0,color:"var(--text-muted)",fontSize:"0.8125rem"},children:"This usually takes a few minutes."})]})}const AB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupHeader:vw},Symbol.toStringTag,{value:"Module"}));function yR(t,n){if(t.phaseSteps.length===0)return"pending";const s=t.phaseSteps[0],r=t.phaseSteps[t.phaseSteps.length-1];return n>r?"complete":n>=s?"active":"pending"}const Ho="#D7FF63",vR="var(--text-muted)";function jw({status:t}){return t==="complete"?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:[e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:"#FFFFFF",strokeWidth:"1.5"}),e.jsx("path",{d:"M5.5 9.2 L8 11.5 L12.5 6.5",fill:"none",stroke:"#FFFFFF",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]}):t==="active"?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",role:"img","aria-label":"In progress",style:{flexShrink:0,display:"block",animation:"codeyam-setup-spin 1.1s linear infinite"},children:[e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:Ho,strokeWidth:"1.5",opacity:"0.25"}),e.jsx("path",{d:"M9 1.5 A 7.5 7.5 0 0 1 16.5 9",fill:"none",stroke:Ho,strokeWidth:"1.75",strokeLinecap:"round"})]}):e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:vR,strokeWidth:"1.5"})})}function ww({phase:t,status:n}){const s=n==="active"?Ho:n==="complete"?"var(--text-primary)":"var(--text-muted)";return e.jsxs("li",{"data-phase-id":t.phaseId,"data-phase-status":n,style:{display:"flex",alignItems:"center",gap:"0.625rem"},children:[e.jsx(jw,{status:n}),e.jsx("span",{style:{color:s,fontSize:"0.8125rem",fontFamily:"'IBM Plex Mono', monospace",fontWeight:n==="active"?600:400,letterSpacing:"0.01em"},children:t.phaseLabel})]})}const RB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressRow:ww,StatusIndicator:jw},Symbol.toStringTag,{value:"Module"}));function _w({currentStep:t,mode:n}){const s=Ug(n);return e.jsx("section",{"aria-label":"Progress",style:{marginBottom:"0.5rem"},children:e.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:"0.875rem"},children:s.map(r=>{const a=yR(r,t);return e.jsx(ww,{phase:r,status:a},r.phaseId)})})})}const EB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressList:_w},Symbol.toStringTag,{value:"Module"}));function jR(t){let n=t;const s=n.match(/^Feature: [^\n]*\n\nProject context: /);return s?n=n.slice(s[0].length):n.startsWith("Project context: ")&&(n=n.slice(17)),n.endsWith(`
|
|
283
|
+
`)&&(n=n.slice(0,-1)),n}function kw({prompt:t,currentStep:n,mode:s,mockupHtml:r=null,mockupViewport:a="desktop",assets:o=[]}){return e.jsxs("div",{style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"1.5rem 1.75rem",maxWidth:"520px"},children:[e.jsx(vw,{}),e.jsx(gw,{prompt:jR(t)}),e.jsx(yw,{mockupHtml:r,mockupViewport:a,assets:o}),e.jsx(_w,{currentStep:n,mode:s})]})}const MB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewView:kw},Symbol.toStringTag,{value:"Module"}));function wR(){const[t,n]=l.useState(null),[s,r]=l.useState("desktop"),[a,o]=l.useState([]);return l.useEffect(()=>{let i=!1;async function c(){try{const u=await fetch("/api/editor-design-selection");if(!u.ok)return;const h=await u.json();if(!h||typeof h.filename!="string"||!h.filename)return;const p=await fetch("/api/editor-design-selected-mockup");if(!p.ok)return;const m=await p.text();if(i||!m)return;n(m),r(Rl(m)??"desktop")}catch{}}async function d(){try{const u=await fetch("/api/editor-design-assets");if(!u.ok)return;const h=await u.json();!i&&Array.isArray(h.assets)&&o(h.assets)}catch{}}return c(),d(),()=>{i=!0}},[]),{mockupHtml:t,mockupViewport:s,assets:a}}function Sw(){const{prompt:t}=j0(),{stepState:n}=Is(),{mockupHtml:s,mockupViewport:r,assets:a}=wR();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:e.jsx(kw,{prompt:t??"",currentStep:(n==null?void 0:n.step)??1,mode:(n==null?void 0:n.mode)??"ui",mockupHtml:s,mockupViewport:r,assets:a})})})}const IB=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewPane:Sw},Symbol.toStringTag,{value:"Module"}));function _R(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-terminal`}function kR(t,n,s=1500){if(t<=0)return!1;const r=n-t;return r>=0&&r<=s}function Nw({assistantTyping:t}){return e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{children:"Shared setup terminal — you and the assistant both drive this shell."}),t&&e.jsx("span",{className:"rounded px-2 py-0.5",style:{background:"rgba(215, 255, 99, 0.15)",color:"#8fae00",border:"1px solid rgba(215, 255, 99, 0.4)"},children:"Assistant is typing…"})]})}const LB=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalHeader:Nw},Symbol.toStringTag,{value:"Module"})),SR=1200,NR=1e3,CR=["\x1B[90mproject/my-app\x1B[0m $ dig codeyam.com +short","\x1B[36m76.76.21.21\x1B[0m","\x1B[90mproject/my-app\x1B[0m $ \x1B[2m# assistant ran:\x1B[0m vercel --version","\x1B[36mVercel CLI 39.1.3\x1B[0m","\x1B[90mproject/my-app\x1B[0m $ "].join(`\r
|
|
284
|
+
`);function Cw(){const t=Ot(),n=l.useRef(null),s=l.useRef(null),r=l.useRef(null),a=l.useRef(null),o=l.useRef(!1),i=l.useRef(!1),c=l.useRef(null),[d,u]=l.useState(!1),[h,p]=tl(1200);function m(f){const g=a.current;(g==null?void 0:g.readyState)===WebSocket.OPEN&&g.send(new TextEncoder().encode(f))}return el(n,()=>{if(r.current&&s.current){r.current.fit();const f=a.current;(f==null?void 0:f.readyState)===WebSocket.OPEN&&f.send(JSON.stringify({type:"resize",cols:s.current.cols,rows:s.current.rows}))}}),l.useEffect(()=>{if(t)return;let f=!1;const g=async()=>{try{const x=await fetch("/api/setup-terminal/activity");if(!x.ok)return;const y=await x.json();if(f)return;u(kR(y.lastInjectMs??0,Date.now()))}catch{}};g();const b=window.setInterval(g,NR);return()=>{f=!0,window.clearInterval(b)}},[t]),l.useEffect(()=>{if(!n.current||o.current)return;o.current=!0,i.current=!1;const f=new Jo.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),g=new Xo.FitAddon;f.loadAddon(g),f.open(n.current),s.current=f,r.current=g;const b=Qo(f,n.current,{onCopy:()=>p()}),x=Zo(f,{sendInput:m});if(requestAnimationFrame(()=>{g.fit(),f.focus()}),t)return f.write(CR),u(!0),()=>{x(),b(),f.dispose(),o.current=!1};const y=()=>{if(i.current)return;const v=new WebSocket(_R());a.current=v,v.binaryType="arraybuffer",v.onmessage=_=>{_.data instanceof ArrayBuffer&&f.write(new Uint8Array(_.data))},v.onopen=()=>{v.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))},v.onclose=()=>{i.current||(c.current=window.setTimeout(y,SR))}};return y(),f.onData(m),()=>{var v;i.current=!0,c.current!==null&&window.clearTimeout(c.current),(v=a.current)==null||v.close(),x(),b(),f.dispose(),o.current=!1}},[t]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[e.jsx(Nw,{assistantTyping:d}),e.jsx("div",{ref:n,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var f;return(f=s.current)==null?void 0:f.focus()}}),h&&e.jsx(sa,{})]})}const DB=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalPane:Cw},Symbol.toStringTag,{value:"Module"}));function TR(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-browser`}function PR(t){let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null)return null;const s=n;if(s.type!=="frame"||typeof s.data!="string")return null;const r=typeof s.w=="number"?s.w:0,a=typeof s.h=="number"?s.h:0;return{src:`data:image/jpeg;base64,${s.data}`,width:r,height:a}}function OR(t){const n=t.paneWidth>0&&t.frameWidth>0?t.frameWidth/t.paneWidth:1,s=t.paneHeight>0&&t.frameHeight>0?t.frameHeight/t.paneHeight:1;return JSON.stringify({kind:"mouse",event:t.event,x:Math.round(t.paneX*n),y:Math.round(t.paneY*s),button:"left",clickCount:1})}function AR(t,n,s=1500){if(t<=0)return!1;const r=n-t;return r>=0&&r<=s}function ds(t,n){const s=`<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800" viewBox="0 0 1280 800">
|
|
285
|
+
<rect width="1280" height="800" fill="#0b0d12"/>
|
|
286
|
+
<rect width="1280" height="56" fill="#11141b"/>
|
|
287
|
+
<text x="28" y="35" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="20" font-weight="700">${n}</text>
|
|
288
|
+
${t}
|
|
289
|
+
</svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(s)}`}function Nt(t,n,s,r,a){return`
|
|
290
|
+
<text x="${t}" y="${n}" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">${r}</text>
|
|
291
|
+
<rect x="${t}" y="${n+10}" width="${s}" height="40" rx="6" fill="#171b24" stroke="#2a303c"/>
|
|
292
|
+
<text x="${t+14}" y="${n+36}" fill="#e7e9ee" font-family="ui-monospace, monospace" font-size="15">${a}</text>`}const RR={hosting:ds(`
|
|
293
|
+
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="28" font-weight="700">Production Deployment</text>
|
|
294
|
+
<rect x="28" y="160" width="1224" height="120" rx="10" fill="#12161f" stroke="#232a36"/>
|
|
295
|
+
<circle cx="60" cy="220" r="8" fill="#3ecf8e"/>
|
|
296
|
+
<text x="82" y="212" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="17">my-app.vercel.app</text>
|
|
297
|
+
<text x="82" y="238" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">Ready · deployed 2m ago · main@a1b2c3d</text>
|
|
298
|
+
<rect x="28" y="320" width="360" height="44" rx="8" fill="#D7FF63"/>
|
|
299
|
+
<text x="70" y="348" fill="#0b0d12" font-family="system-ui, sans-serif" font-size="16" font-weight="600">Add a custom domain →</text>`,"▲ Vercel — Project Settings"),dns:ds(`
|
|
300
|
+
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">DNS Records — codeyam.com</text>
|
|
301
|
+
${Nt(28,180,300,"Type","CNAME")}
|
|
302
|
+
${Nt(360,180,420,"Name","www")}
|
|
303
|
+
${Nt(812,180,440,"Value","cname.vercel-dns.com")}
|
|
304
|
+
${Nt(28,280,300,"Type","A")}
|
|
305
|
+
${Nt(360,280,420,"Name","@")}
|
|
306
|
+
${Nt(812,280,440,"Value","76.76.21.21")}
|
|
307
|
+
<rect x="28" y="380" width="220" height="44" rx="8" fill="#D7FF63"/>
|
|
308
|
+
<text x="70" y="408" fill="#0b0d12" font-family="system-ui, sans-serif" font-size="16" font-weight="600">Save Records</text>`,"☁ Cloudflare — DNS"),signin:ds(`
|
|
309
|
+
<rect x="440" y="200" width="400" height="380" rx="14" fill="#12161f" stroke="#232a36"/>
|
|
310
|
+
<text x="640" y="260" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="22" font-weight="700" text-anchor="middle">Sign in to continue</text>
|
|
311
|
+
${Nt(472,300,336,"Email","you@example.com")}
|
|
312
|
+
${Nt(472,380,336,"Password","••••••••••")}
|
|
313
|
+
<rect x="472" y="470" width="336" height="44" rx="8" fill="#4c7fff"/>
|
|
314
|
+
<text x="640" y="498" fill="#ffffff" font-family="system-ui, sans-serif" font-size="16" font-weight="600" text-anchor="middle">Sign in</text>`,"App Store Connect — Sign In"),appstore:ds(`
|
|
315
|
+
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">App Information</text>
|
|
316
|
+
${Nt(28,180,560,"Name","CodeYam")}
|
|
317
|
+
${Nt(620,180,632,"Subtitle","Build code and data scenarios together")}
|
|
318
|
+
${Nt(28,280,1224,"Promotional Text","See your app in every state, before you ship it.")}
|
|
319
|
+
<rect x="28" y="400" width="200" height="44" rx="8" fill="#4c7fff"/>
|
|
320
|
+
<text x="128" y="428" fill="#ffffff" font-family="system-ui, sans-serif" font-size="16" font-weight="600" text-anchor="middle">Submit for Review</text>`," App Store Connect — 1.0"),navigating:ds(`
|
|
321
|
+
<rect x="0" y="56" width="1280" height="3" fill="#D7FF63"/>
|
|
322
|
+
<text x="28" y="420" fill="#5b6472" font-family="system-ui, sans-serif" font-size="20" text-anchor="start">Loading DNS records…</text>`,"☁ Cloudflare — DNS")},ER={hosting:"https://vercel.com/acme/my-app",dns:"https://dash.cloudflare.com/dns/codeyam.com",signin:"https://appstoreconnect.apple.com/login",appstore:"https://appstoreconnect.apple.com/apps/1234/appstore",navigating:"https://dash.cloudflare.com/dns/codeyam.com"};function MR(t){return RR[t]}function IR(t){return ER[t]}function Tw({address:t,assistantNavigating:n,onBack:s,onForward:r,onReload:a,onStop:o}){const i={background:"var(--bg-input, #2a2a2a)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",borderRadius:4,width:24,height:22,cursor:"pointer",fontSize:12};return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Shared setup browser — you and the assistant both control this window."}),n&&e.jsx("span",{className:"rounded px-2 py-0.5",style:{background:"rgba(215, 255, 99, 0.15)",color:"#8fae00",border:"1px solid rgba(215, 255, 99, 0.4)"},children:"Assistant is navigating…"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",style:i,onClick:s,title:"Back","aria-label":"Back",children:"‹"}),e.jsx("button",{type:"button",style:i,onClick:r,title:"Forward","aria-label":"Forward",children:"›"}),e.jsx("button",{type:"button",style:i,onClick:a,title:"Reload","aria-label":"Reload",children:"↻"}),e.jsx("div",{className:"flex-1 truncate rounded px-2 py-0.5",style:{background:"var(--bg-input, #1e1e1e)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",fontFamily:"'IBM Plex Mono', monospace"},title:t,children:t||"about:blank"}),e.jsx("button",{type:"button",style:i,onClick:o,title:"Stop","aria-label":"Stop",children:"✕"})]})]})}const FB=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserHeader:Tw},Symbol.toStringTag,{value:"Module"})),LR=1200,DR=1e3;function Pw({demo:t="hosting",address:n,assistantNavigating:s,disconnected:r=!1}={}){const o=Ot()||s!==void 0||r,i=l.useRef(null),c=l.useRef(null),d=l.useRef(!1),u=l.useRef(null),h=l.useRef({width:0,height:0}),[p,m]=l.useState(o?MR(t):null),[f,g]=l.useState(n??(o?IR(t):"")),[b,x]=l.useState(s??!1),[y,v]=l.useState(!1);l.useEffect(()=>{if(o)return;let j=!1;const k=async()=>{try{const w=await fetch("/api/setup-browser/activity");if(!w.ok)return;const C=await w.json();if(j)return;x(AR(C.lastActMs??0,Date.now()))}catch{}};k();const S=window.setInterval(k,DR);return()=>{j=!0,window.clearInterval(S)}},[o]),l.useEffect(()=>{if(o)return;d.current=!1;const j=()=>{if(d.current)return;const k=new WebSocket(TR());c.current=k,k.onopen=()=>v(!0),k.onmessage=S=>{if(typeof S.data!="string")return;const w=PR(S.data);w&&(h.current={width:w.width,height:w.height},m(w.src))},k.onclose=()=>{v(!1),!d.current&&(u.current=window.setTimeout(j,LR))}};return j(),()=>{var k;d.current=!0,u.current!==null&&window.clearTimeout(u.current),(k=c.current)==null||k.close()}},[o]);function _(j,k){const S=c.current;if(!S||S.readyState!==WebSocket.OPEN)return;const w=k.currentTarget.getBoundingClientRect();S.send(OR({event:j,paneX:k.clientX-w.left,paneY:k.clientY-w.top,paneWidth:w.width,paneHeight:w.height,frameWidth:h.current.width,frameHeight:h.current.height}))}return e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[e.jsx(Tw,{address:f,assistantNavigating:b,onReload:()=>g(f)}),e.jsx("div",{ref:i,className:"flex-1 flex items-center justify-center overflow-hidden",style:{background:"#0b0d12",minHeight:0},children:r?e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center px-6",children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:"The shared browser session was stopped."}),e.jsx("button",{type:"button",className:"rounded px-3 py-1.5",style:{background:"#D7FF63",color:"#0b0d12",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Relaunch shared browser"})]}):p?e.jsx("img",{src:p,alt:"Shared setup browser viewport",className:"max-w-full max-h-full",style:{objectFit:"contain"},draggable:!1,onMouseDown:j=>_("mousePressed",j),onMouseUp:j=>_("mouseReleased",j)}):e.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:y?"Waiting for the first frame…":"Connecting to the shared browser…"})})]})}const zB=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserPane:Pw},Symbol.toStringTag,{value:"Module"}));function Ow({onDismiss:t,previewOrigin:n}){const{inContainer:s,reachableUrl:r}=ai(),a=iR(s,r,n),o=hi(r,!a),i=o?`A preview address for this machine already exists and is answering: ${o}. Point the preview at it with: ${xr(o)} — it takes effect immediately, no restart needed.`:null;return e.jsx(On,{severity:"warning",testId:"client-routing-advisory",className:"flex w-full flex-col gap-3 border-b border-l-4 px-4 py-3 text-sm",headline:"Reloading the preview may land on the wrong page",explanation:"This app uses client-side routing, so it handles its own page navigation. The Live Preview is served from the /__codeyam_preview sub-path, which a client-side router cannot serve correctly on a reload or a deep link. Clicking around inside the app works, but reloading may land on the wrong route.",nextAction:a?e.jsxs(e.Fragment,{children:["Set ",e.jsx("code",{children:"sameOriginSafe: false"})," in"," ",e.jsx("code",{children:".codeyam/stack.json"}),", then reload. The preview moves to its own address and the problem goes away. Copy this report if you want to hand the change to an agent."]}):i?e.jsx(e.Fragment,{children:i}):e.jsx(e.Fragment,{children:"Nothing you can change here. This editor is reached remotely and has no dedicated preview address provisioned, so there is nowhere to move the preview to yet — one has to be provisioned for this machine, alongside the editor’s own address, and the preview will use it automatically. Until then the sub-path is the only route that reaches you. Copy this report and send it to whoever set the machine up."}),nextActionText:a?'Set "sameOriginSafe": false in .codeyam/stack.json, then reload. The preview moves to its own address and the problem goes away.':i??"Nothing you can change here. This editor is reached remotely and has no dedicated preview address provisioned, so there is nowhere to move the preview to yet — one has to be provisioned for this machine, alongside the editor's own address. Until then the sub-path is the only route that reaches you. Copy this report and send it to whoever set the machine up.",actions:[{label:"Dismiss",onClick:t,variant:"secondary",ariaLabel:"Dismiss client-routing advisory",testId:"client-routing-advisory-dismiss"}]})}const $B=Object.freeze(Object.defineProperty({__proto__:null,ClientRoutingAdvisory:Ow},Symbol.toStringTag,{value:"Module"})),FR="Seed failed — DB state is unknown",zR="Preview capture failed — the app's data was seeded";function Aw({error:t,kind:n,onRetry:s}){const r=n==="device"?zR:FR;return e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 border-b border-[var(--accent-red)] bg-[var(--accent-red)]/10 px-4 py-2 text-sm text-[var(--accent-red)]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold",children:r}),e.jsx("div",{className:"truncate text-xs opacity-90",children:t})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(at,{variant:"subtle",text:`${r}
|
|
323
|
+
${t}`,label:"Copy",className:"shrink-0 rounded border border-[var(--accent-red)] px-2 py-1 text-xs hover:bg-[var(--accent-red)] hover:text-white disabled:opacity-50 disabled:cursor-not-allowed"}),s?e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded border border-[var(--accent-red)] px-2 py-1 text-xs hover:bg-[var(--accent-red)] hover:text-white",children:"Retry"}):null]})]})}const BB=Object.freeze(Object.defineProperty({__proto__:null,SeedErrorBanner:Aw},Symbol.toStringTag,{value:"Module"}));function Rw({label:t="Loading scenario..."}={}){return e.jsx("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-[var(--bg-deep)]/90 backdrop-blur-sm text-[var(--text-muted)]",children:t})}const HB=Object.freeze(Object.defineProperty({__proto__:null,SeedLoadingOverlay:Rw},Symbol.toStringTag,{value:"Module"}));function Ew(t){return t.state==="preflight-running"||t.state==="booting-simulator"||t.state==="simulator-booted"||t.state==="building-app"}const $R=1500;function Mw({stackId:t,pollMs:n=$R,onStateChange:s}={}){const[r,a]=l.useState({state:"idle"}),[o,i]=l.useState(!1),c=l.useRef(s);c.current=s,l.useEffect(()=>{let h=!1,p=!0;const m=async()=>{var g;try{const b=await fetch("/api/simulator-status");if(!b.ok)return;const x=await b.json();if(h||!p)return;const{history:y,...v}=x;a(v),(g=c.current)==null||g.call(c,v)}catch{}};m();const f=window.setInterval(m,n);return()=>{h=!0,p=!1,window.clearInterval(f)}},[n]);const d=l.useCallback(async()=>{if(!o){i(!0);try{const h=t?JSON.stringify({stack_id:t}):"{}";await fetch("/api/start-simulator",{method:"POST",headers:{"content-type":"application/json"},body:h})}finally{i(!1)}}},[t,o]),u=o||Ew(r);return{status:r,posting:o,buttonDisabled:u,start:d}}function Iw({stderrTail:t,onClose:n}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},onClick:n,children:e.jsxs("div",{className:"max-w-2xl w-full max-h-[80vh] overflow-auto rounded p-4 font-mono text-xs",style:{background:"var(--bg-elevated)",color:"var(--text-primary)"},onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("strong",{children:"Build logs (stderr tail)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(at,{variant:"subtle",text:t,label:"Copy"}),e.jsx("button",{type:"button",onClick:n,className:"opacity-70 hover:opacity-100",children:"✕"})]})]}),e.jsx("pre",{className:"whitespace-pre-wrap",children:t||"(no stderr captured)"})]})})}const qB=Object.freeze(Object.defineProperty({__proto__:null,BuildLogsModal:Iw},Symbol.toStringTag,{value:"Module"}));function qo({stackId:t,pollMs:n,onStateChange:s}){const[r,a]=l.useState(!1),{status:o,start:i,buttonDisabled:c}=Mw({stackId:t,pollMs:n,onStateChange:s}),d=o.state==="app-launched";return e.jsxs("div",{className:"flex items-center gap-3 text-sm",style:{color:"var(--text-primary)"},children:[e.jsx("button",{type:"button",onClick:i,disabled:c,className:"px-3 py-1 rounded font-medium disabled:opacity-40 disabled:cursor-not-allowed",style:d?{background:"var(--surface-raised)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",opacity:.7}:{background:"var(--accent-primary)",color:"var(--bg-deep)"},children:d?"Restart simulator":"Start simulator"}),e.jsx(Lw,{status:o}),o.state==="build-failed"?e.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-xs underline opacity-80 hover:opacity-100",children:"see logs"}):null,r&&o.state==="build-failed"?e.jsx(Iw,{stderrTail:o.stderrTail,onClose:()=>a(!1)}):null]})}function Lw({status:t}){const n=Dl(t);return e.jsx("span",{className:"text-xs opacity-80","data-testid":"simulator-status-pill",children:n})}function Dl(t){switch(t.state){case"idle":return"No simulator running";case"preflight-running":return"Pre-flight checks…";case"preflight-failed":return`Pre-flight failed: ${t.check} — ${t.message}`;case"booting-simulator":return`Booting ${t.device}…`;case"simulator-booted":return`Simulator booted (${t.name})`;case"building-app":return`Building (${Dw(t.elapsedSec)})…`;case"build-failed":return"Build failed";case"app-launched":return`App running ▸${t.appBundleId!=="com.codeyam.android"?" (host proxy active)":""}`;case"stopped":return t.reason.kind==="user-requested"?"Stopped":t.reason.kind==="editor-server-shutdown"?"Editor server shut down":t.reason.code!=null?`Stopped (exit ${t.reason.code})`:"Stopped"}}function Dw(t){if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s.toString().padStart(2,"0")}s`}const WB=Object.freeze(Object.defineProperty({__proto__:null,SimulatorLauncherControls:qo,StatusPill:Lw,formatElapsed:Dw,pillText:Dl},Symbol.toStringTag,{value:"Module"}));function Fw({stackId:t,pollMs:n,onStateChange:s}){const{status:r,start:a,buttonDisabled:o}=Mw({stackId:t,pollMs:n,onStateChange:s}),i=Ew(r);return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full px-6 text-center",style:{color:"var(--text-primary)"},children:[e.jsx("div",{className:"text-3xl","aria-hidden":"true",children:"📱"}),e.jsx("div",{className:"text-sm font-medium",children:"No simulator running yet"}),e.jsx("div",{className:"text-xs opacity-70",children:i?Dl(r):"Start it to preview this scenario on device."}),e.jsx("button",{type:"button",onClick:a,disabled:o,className:"px-3 py-1 rounded font-medium disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent-primary)",color:"var(--bg-deep)"},children:"Start simulator"})]})}const GB=Object.freeze(Object.defineProperty({__proto__:null,SimulatorNotBootedPrompt:Fw},Symbol.toStringTag,{value:"Module"}));function gr({src:t,currentHeight:n,currentWidth:s,isFilled:r,scale:a}){return r?e.jsx("img",{src:t,alt:"Simulator / Emulator preview",className:"w-full h-full object-contain",style:{background:"var(--bg-deep)"}}):e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:s,height:n,transform:a<1?`scale(${a})`:void 0,transformOrigin:"center center",flexShrink:0},children:e.jsx("img",{src:t,alt:"Simulator / Emulator preview",style:{width:"100%",height:"100%",background:"var(--bg-deep)",objectFit:"contain"}})})}const UB=Object.freeze(Object.defineProperty({__proto__:null,DeviceFrameImage:gr},Symbol.toStringTag,{value:"Module"}));function Or({currentWidth:t,currentHeight:n,isFilled:s,scale:r,title:a,hint:o}){const i=e.jsx("div",{className:"w-full h-full border border-dashed rounded flex items-center justify-center text-center px-6",style:{borderColor:"var(--border-default)",background:"var(--bg-surface)",color:"var(--text-dim)"},children:e.jsxs("div",{className:"text-sm leading-relaxed",children:[e.jsx("div",{className:"font-medium",children:a}),e.jsx("div",{className:"opacity-70 mt-1",children:o})]})});return s?i:e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:t,height:n,transform:r<1?`scale(${r})`:void 0,transformOrigin:"center center",flexShrink:0},children:i})}const VB=Object.freeze(Object.defineProperty({__proto__:null,SimulatorFrameNotice:Or},Symbol.toStringTag,{value:"Module"}));function zw({currentWidth:t,currentHeight:n,isFilled:s,scale:r,variant:a}){const o=a==="xcode-missing"?"Xcode/Android tooling not detected":"No simulator / emulator running",i=a==="xcode-missing"?"Install Xcode or Android SDK + command line tools, then boot a device.":"Boot a simulator or emulator to see the live preview.";return e.jsx(Or,{currentWidth:t,currentHeight:n,isFilled:s,scale:r,title:o,hint:i})}const YB=Object.freeze(Object.defineProperty({__proto__:null,NoBootedSimulatorPlaceholder:zw},Symbol.toStringTag,{value:"Module"})),BR=1500;function $w(t=BR){const[n,s]=l.useState({available:!1,loading:!0,capturedAtMs:null});return l.useEffect(()=>{let r=!1;const a=()=>{fetch("/api/preview-capture-status").then(i=>i.ok?i.json():{available:!1}).then(i=>{r||s({available:(i==null?void 0:i.available)===!0,loading:!1,capturedAtMs:typeof(i==null?void 0:i.capturedAtMs)=="number"?i.capturedAtMs:null})}).catch(()=>{r||s(i=>({available:i.available,loading:!1,capturedAtMs:i.capturedAtMs}))})};a();const o=window.setInterval(a,t);return()=>{r=!0,window.clearInterval(o)}},[t]),n}const HR=700;function Bw({currentHeight:t,currentWidth:n,isFilled:s,scale:r,pollMs:a=HR,onError:o,deviceLabel:i="iOS Simulator",scenarioScreenshotSrc:c=null,bootState:d}){const u=Fv({pollMs:a,paused:!!c||!!d,onError:o}),{state:h,frameToken:p}=d??u,m=$w();if(c)return e.jsx(gr,{src:c,currentWidth:n,currentHeight:t,isFilled:s,scale:r});if(h.kind==="no-device"||h.kind==="xcode-missing"){if(!m.loading&&m.available){const g=m.capturedAtMs!=null?`/api/preview-capture?cb=${m.capturedAtMs}`:"/api/preview-capture";return e.jsx(gr,{src:g,currentWidth:n,currentHeight:t,isFilled:s,scale:r})}return e.jsx(zw,{currentWidth:n,currentHeight:t,isFilled:s,scale:r,variant:h.kind})}if(h.kind==="loading")return e.jsx(Or,{currentWidth:n,currentHeight:t,isFilled:s,scale:r,title:`Connecting to the ${i}…`,hint:"Waiting for the first live frame."});if(h.kind==="capture-failed")return e.jsx(Or,{currentWidth:n,currentHeight:t,isFilled:s,scale:r,title:"Live preview frame unavailable",hint:`Your app is still running — interact with it directly in the ${i} window.`});const f=`/api/simulator-frame?t=${p}`;return e.jsx(gr,{src:f,currentWidth:n,currentHeight:t,isFilled:s,scale:r})}const KB=Object.freeze(Object.defineProperty({__proto__:null,SimulatorPreviewFrame:Bw},Symbol.toStringTag,{value:"Module"}));function Hw({emptyStateMessage:t,projectSetupInProgress:n,previewSlug:s,previewUrl:r,viewports:a,activeViewport:o,onViewportChange:i,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:h,currentWidth:p,currentHeight:m,onCustomSizeChange:f,buildingScenarioSlug:g,buildingScreenshotPath:b,buildingScenarioName:x,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:_,historicalScenarioName:j,historicalHeading:k,historicalSubtext:S,onDismissHistoricalPreview:w,previewSeeding:C,previewSeedError:P,previewSeedErrorKind:T,onRetrySeed:O,currentScenario:N,scenarioGroups:E,onShowScenarioPreview:I,commandNonce:ee,previewOrigin:B,isNarrow:z=!1,onBack:Y,onPlanChange:te,onDesignConfirmed:R}){const{config:L}=jt(),M=Ue(L==null?void 0:L.provider),[K,ie]=l.useState(!1),$=!!Y,ae=(N?_i(N,E??[]):[]).length>1,[ne,me]=l.useState(!0),[q,le]=l.useState(!1),Pe=$?ne:q,Ce=$?me:le,F=$||ae,J=Pe&&!!N&&($||ae),[Z,ue]=l.useState({state:"idle"}),{containerRef:ve,containerSize:fe,scale:se}=g4({currentHeight:m,currentWidth:p,isFilled:u}),Q=Dv(),ge=_4(B===Cn),[Ae,Te]=l.useState(!1),H=!!(L!=null&&L.previewDedicatedOriginUnavailable),[G,be]=l.useState(!1);l.useEffect(()=>{Ot()||u4(P??null)},[P]);const de=N4(N,o),je=de?Rn(de,N==null?void 0:N.screenshotCapturedAtMs):null,Ne=Na(Q.kind),Ee=!!je,Le=Fv({paused:!Ne||Ee}),He=Le.state.kind==="no-device"||Le.state.kind==="xcode-missing",X=Q.fallbackKind==="iframe"&&Q.fallbackPort!==null,Oe=Ne&&!Ee&&X&&He,it=Q.fallbackPort??0,qt=(N?zu(N,it,B):"")||di("/",{appPort:it,currentPort:typeof window<"u"?ci(window.location):0,previewOrigin:B}),Ke=r?li(r):"",kt=Ke==="/results"||Ke.startsWith("/results/"),_e=Ke==="/plan-preview",ce=Ke==="/design-exploration",U=Ke==="/design-round",Re=Ke==="/setup-terminal",De=Ke==="/setup-browser",qe=ui(Ke);if(Re)return e.jsx(Cw,{});if(De)return e.jsx(Pw,{});if(_e)return e.jsx(w0,{});if(kt)return e.jsx(tj,{});if(ce)return e.jsx(Zj,{onDesignConfirmed:R});if(U)return e.jsx(e0,{});if(qe)return e.jsx(Hu,{previewPath:Ke,commandNonce:ee});if(n&&!r&&!Q.loading&&!Na(Q.kind))return e.jsx(Sw,{});const nt=Z.state==="app-launched";return e.jsxs("div",{"data-preview-pane":"true",className:"flex-1 flex flex-col min-w-0",children:[e.jsx(x0,{viewports:a,active:o,onChange:i,currentWidth:p,currentHeight:m,previewUrl:r,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:h,containerWidth:(fe==null?void 0:fe.width)??null,containerHeight:(fe==null?void 0:fe.height)??null,onCustomSizeChange:f,currentScenario:N??null,scenarioGroups:E??[],onShowScenarioPreview:I??(()=>{}),onCreateStateRequest:()=>ie(!0),isNarrow:z,onBack:Y,onPlanChange:te,onToggleStatesModal:F?()=>Ce(lt=>!lt):void 0,statesModalOpen:Pe}),P?e.jsx(Aw,{error:P,kind:T,onRetry:O}):null,H&&!G?e.jsx(Yu,{onDismiss:()=>be(!0),hint:(L==null?void 0:L.previewDedicatedOriginHint)??null,onManagedFleetVm:!!(L!=null&&L.onManagedFleetVm)}):ge&&!Ae?e.jsx(Ow,{previewOrigin:B,onDismiss:()=>Te(!0)}):null,J&&N?e.jsx(Yh,{currentScenario:N,scenarioGroups:E??[],onSelect:lt=>(I??(()=>{}))(lt),onCreateNew:()=>ie(!0),onClose:()=>Ce(!1)}):null,e.jsxs("div",{className:"relative flex-1 flex flex-col min-h-0",children:[Ne&&!Oe?e.jsxs(e.Fragment,{children:[e.jsx(t0,{deviceLabel:Ca(Q.kind),actions:e.jsx(qo,{onStateChange:ue})}),e.jsx("div",{ref:ve,className:"relative flex-1 flex overflow-hidden items-center justify-center p-8",style:{backgroundColor:"#1e1e1e"},children:nt?e.jsx(Bw,{currentHeight:m,currentWidth:p,isFilled:u,scale:se,deviceLabel:Ca(Q.kind),scenarioScreenshotSrc:je,bootState:Le}):e.jsx(Fw,{onStateChange:ue})})]}):e.jsxs(e.Fragment,{children:[Oe?e.jsx(am,{deviceLabel:Ca(Q.kind),actions:e.jsx(qo,{})}):null,e.jsx(fw,{providerLabel:M,containerRef:ve,containerHeight:fe==null?void 0:fe.height,containerWidth:fe==null?void 0:fe.width,currentHeight:m,currentWidth:p,emptyStateMessage:t??"Select a scenario to preview",isFilled:u,previewSlug:Oe?(N==null?void 0:N.slug)??s:s,previewUrl:Oe?qt:r,previewOrigin:B,scale:se,buildingScenarioSlug:g,buildingScreenshotPath:b,buildingScenarioName:x,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:_,historicalScenarioName:j,historicalHeading:k,historicalSubtext:S,onDismissHistoricalPreview:w,commandNonce:ee})]}),C?e.jsx(Rw,{label:Na(Q.kind)?"Loading scenario on device…":void 0}):null]}),K?e.jsx(nj,{onClose:()=>ie(!1),providerLabel:M}):null]})}const JB=Object.freeze(Object.defineProperty({__proto__:null,PreviewPanel:Hw},Symbol.toStringTag,{value:"Module"})),Wo="reset";function qw({busy:t,onCancel:n,onConfirm:s,planSessionActive:r=!1}){const[a,o]=l.useState(""),i=a.trim().toLowerCase()===Wo;return l.useEffect(()=>{const c=d=>{d.key==="Escape"&&!t&&n()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[t,n]),e.jsx("div",{role:"presentation",onClick:()=>{t||n()},style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:24},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Cancel build and reset everything?",onClick:c=>c.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(440px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Cancel build & reset everything?"}),e.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:["This stops the current build, clears the editor session, and"," ",e.jsx("strong",{style:{color:"var(--accent-red)"},children:"permanently discards uncommitted code changes"})," ","(back to the current commit). This cannot be undone."]}),e.jsx("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"Plans in the Plan tab are kept."}),r?e.jsx("p",{"data-testid":"reset-plan-kept-notice",style:{margin:0,padding:"8px 10px",borderRadius:6,border:"1px solid var(--accent-green, #3ecf8e)",color:"var(--text-primary)",fontSize:12},children:"A plan is being written in the Plan tab — it will be kept."}):null]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:6,color:"var(--text-secondary)",fontSize:12},children:["Type ",e.jsx("strong",{style:{color:"var(--text-primary)"},children:Wo})," to confirm",e.jsx("input",{type:"text",value:a,disabled:t,autoFocus:!0,"data-testid":"reset-confirm-input",onChange:c=>o(c.target.value),style:{padding:"8px 10px",background:"var(--bg-input, #0f0f0f)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontFamily:"inherit"}})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:n,disabled:t,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:t?"wait":"pointer",opacity:t?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:s,disabled:t||!i,"data-testid":"reset-confirm-button",style:{padding:"8px 18px",background:"var(--accent-red, #ff5c5c)",color:"#fff",border:"1px solid var(--accent-red, #ff5c5c)",borderRadius:6,fontSize:13,fontWeight:600,cursor:t?"wait":i?"pointer":"not-allowed",opacity:t||!i?.5:1,fontFamily:"inherit"},children:t?"Resetting…":"Reset everything"})]})]})})}const XB=Object.freeze(Object.defineProperty({__proto__:null,RESET_CONFIRM_WORD:Wo,ResetBuildConfirmModal:qw},Symbol.toStringTag,{value:"Module"}));function qR(){const[t,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=l.useRef(!1),{scenariosVersion:u}=pn(),h=l.useCallback(async()=>{o(!0),d.current||r(!0),c(null);try{const m=await fetch("/api/scenarios");if(!m.ok)throw new Error(`HTTP ${m.status}`);const f=(await m.json()).map(Yo);n(o0(f))}catch(m){c(m instanceof Error?m.message:"Failed to load scenarios")}finally{d.current=!0,o(!1),r(!1)}},[]);l.useEffect(()=>{h()},[h,u]);const p=t.reduce((m,f)=>m+f.scenarios.length,0);return{groups:t,loading:s,refreshing:a,error:i,totalScenarios:p,reload:h}}function WR(t){if(Array.isArray(t))return{entities:t,unsurfacedPages:[],componentSurfaceReason:null};if(t&&typeof t=="object"){const n=t;return{entities:Array.isArray(n.entities)?n.entities:[],unsurfacedPages:Array.isArray(n.unsurfacedPages)?n.unsurfacedPages:[],componentSurfaceReason:GR(n.componentSurfaceReason)}}return{entities:[],unsurfacedPages:[],componentSurfaceReason:null}}function GR(t){if(!t||typeof t!="object")return null;const n=t.kind;return n==="no-component-scenarios"||n==="missing-from-glossary"||n==="not-visual-components"?t:null}function UR(){const[t,n]=l.useState([]),[s,r]=l.useState([]),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[h,p]=l.useState(null),m=l.useRef(!1),{scenariosVersion:f}=pn(),g=l.useCallback(async()=>{u(!0),m.current||c(!0),p(null);try{const b=await fetch("/api/app-route-entities");if(!b.ok)throw new Error(`HTTP ${b.status}`);const x=WR(await b.json());n(x.entities.map(y=>({...y,scenarios:Array.isArray(y==null?void 0:y.scenarios)?y.scenarios.map(Yo):[]}))),r(x.unsurfacedPages),o(x.componentSurfaceReason)}catch(b){p(b instanceof Error?b.message:"Failed to load app routes"),n([]),r([]),o(null)}finally{m.current=!0,u(!1),c(!1)}},[]);return l.useEffect(()=>{g()},[g,f]),{routeEntities:t,unsurfacedPages:s,componentSurfaceReason:a,loading:i,refreshing:d,error:h,reload:g}}function Gd(t){const n=new Map;for(const s of t){const r=VR(s.path);let a=n.get(r);a||(a=[],n.set(r,a));for(const o of s.tests)a.push({...o,file:s.path})}return Array.from(n.entries()).map(([s,r])=>({feature:s,tests:r})).filter(s=>s.tests.length>0).sort((s,r)=>s.feature.localeCompare(r.feature))}function VR(t){const s=t.replace(/\\/g,"/").replace(/^\.\//,"").split("/").filter(r=>r.length>0);return s.length===0?"Other":s[0]==="crates"&&s.length>=2?`crates/${s[1]}`:t==="(no-file)"?"(no-file)":s[0]}function Ww(t,n){if(n===".")return t;const s=n.endsWith("/")?n:`${n}/`;return t.map(r=>({feature:r.feature,tests:r.tests.filter(a=>a.file.startsWith(s))})).filter(r=>r.tests.length>0)}function Gw(t,n,s){return s==="backend"?[]:t.map(r=>({...r,scenarios:r.scenarios.filter(Ar)})).filter(r=>r.scenarios.length>0)}function Uw(t){let n=0,s=0,r=0,a=0,o=0;for(const i of t)for(const c of i.tests)o+=1,n+=1,c.status==="passed"?s+=1:c.status==="skipped"?a+=1:c.status==="failed"&&(r+=1);return{total:n,passed:s,failed:r,ignored:a,discovered:o}}function YR(t){return t.reduce((n,s)=>n+s.scenarios.length,0)}const KR=3e3;function JR(){const[t,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(!1),[h,p]=l.useState(null),[m,f]=l.useState(null),[g,b]=l.useState(null),x=l.useRef(null),y=l.useRef(null),v=l.useRef(!1),_=l.useRef(null),{testsVersion:j}=pn(),k=l.useCallback(async(N=!1)=>{var B;(B=x.current)==null||B.abort();const E=new AbortController;x.current=E;const{signal:I}=E;N&&(v.current=!0,o(!0));const ee=!N&&_.current!==null;ee||(r(!0),c(null));try{if(!N&&!ee)try{const R=await fetch("/api/test-results/summary",{signal:I});if(R.ok){const L=await R.json();L.running?p(L.currentRunner??null):L.stats&&(f(L.stats),b(L.coverage??null))}}catch{}let z,Y;if(ee){z=_.current;const R=await fetch("/api/test-results",{signal:I});if(!R.ok)throw new Error(`test-results: HTTP ${R.status}`);Y=await R.json()}else if(N){const R=await fetch("/api/test-results/refresh",{method:"POST",signal:I});if(!R.ok)throw new Error(`test-results: HTTP ${R.status}`);Y=await R.json(),z=_.current??[]}else{const[R,L]=await Promise.all([fetch("/api/tests",{signal:I}),fetch("/api/test-results",{signal:I})]);if(!R.ok)throw new Error(`tests: HTTP ${R.status}`);if(!L.ok)throw new Error(`test-results: HTTP ${L.status}`);z=Gd(await R.json()),Y=await L.json(),_.current=z}if(p(Y.currentRunner??null),Y.running&&v.current){y.current=setTimeout(()=>k(!1),KR);return}const te=v.current;if(v.current=!1,te){const R=await fetch("/api/tests",{signal:I});R.ok&&(z=Gd(await R.json()),_.current=z)}n(z),u(Y.cached??!1),b(Y.coverage??null),f(null),r(!1),o(!1)}catch(z){if(z instanceof DOMException&&z.name==="AbortError")return;v.current=!1,c(z instanceof Error?z.message:"Failed to load tests"),r(!1),o(!1)}},[]);l.useEffect(()=>(_.current=null,k(),()=>{var N;(N=x.current)==null||N.abort(),y.current&&clearTimeout(y.current)}),[k,j]);const{total:S,passed:w,failed:C,ignored:P,discovered:T}=l.useMemo(()=>Uw(t),[t]),O=l.useCallback(()=>{v.current||k(!0)},[k]);return{groups:t,loading:s,refreshing:a,error:i,cached:d,currentRunner:h,summaryStats:m,coverage:g,totalTests:S,passedTests:w,failedTests:C,ignoredTests:P,discoveredTests:T,reload:k,refresh:O}}function Fl(t,n){return t.filter(s=>s.appDir===n)}function Vw(t,n){return n?t.find(s=>s.route===n)??null:null}function Yw(t,n,s,r=null){const a=Gw(t,n,s);return ZR(a,r)}function XR(t){const n=t.filter(o=>o.defaultScenarioSlug);if(n.length===0)return null;const s=n.find(o=>o.route==="/"&&o.defaultScenarioSlug);if(s!=null&&s.defaultScenarioSlug)return s.defaultScenarioSlug;const r=n.find(o=>o.defaultScenarioSlug&&o.scenarios.some(i=>Go(i)));if(r!=null&&r.defaultScenarioSlug)return r.defaultScenarioSlug;const a=[...n].sort((o,i)=>o.route.length-i.route.length||o.route.localeCompare(i.route))[0];return(a==null?void 0:a.defaultScenarioSlug)??null}function QR(t){return(t==null?void 0:t.defaultScenarioSlug)??null}function Kw(t,n,s=null){const r=t.find(a=>a.type==="web");return r?Yw(n,r.dir,r.type,s):null}function ZR(t,n){const s=t.flatMap(d=>d.scenarios.filter(u=>Ar(u)).map(u=>({route:d.route,scenario:u})));if(s.length===0)return null;const r=nr(s.filter(({route:d,scenario:u})=>d==="/"&&Go(u)),n);if(r)return r.scenario.slug;const a=nr(s.filter(({route:d})=>d==="/"),n);if(a)return a.scenario.slug;const o=nr(s.filter(({scenario:d})=>Go(d)),n);if(o)return o.scenario.slug;const i=Math.min(...s.map(({route:d})=>d.length)),c=nr(s.filter(({route:d})=>d.length===i),n);return(c==null?void 0:c.scenario.slug)??null}function nr(t,n){return t.find(({scenario:s})=>e6(s,n))??t[0]??null}function e6(t,n){return n?t.dimensions.length===0||t.dimensions.includes(n):!0}function Go(t){return/\bhome\b/i.test(t.name)}function Ud(t){return new Set(t.flatMap(n=>n.scenarios.map(s=>s.slug)))}function Ga({selectedApp:t,appRouteEntities:n,scenarioGroups:s,defaultScreenSize:r=null}){return t?XR(n)??Yw(s,t.dir,t.type,r):null}function t6({apps:t,hasExplicitAppSelection:n,scenarioGroups:s,defaultScreenSize:r=null}){return n||t.length===0||s.length===0?null:Kw(t,s,r)}function Vd(t){return QR(t)}function n6({apps:t,routeEntities:n,selectedApp:s,appRouteEntities:r}){if(s)return r;const a=t.find(o=>o.type==="web");return a?Fl(n,a.dir):[]}function s6({previewRouteEntities:t,selectedRouteEntity:n}){var r;if(n!=null&&n.route)return n.route;if(t.length===0)return null;const s=t.find(a=>a.route==="/");return s?s.route:((r=[...t].sort((a,o)=>a.route.length-o.route.length||a.route.localeCompare(o.route))[0])==null?void 0:r.route)??null}function r6({previewRouteEntities:t,path:n}){var r;const s=li(n);return((r=Vw(t,s))==null?void 0:r.defaultScenarioSlug)??null}function a6(t){return t.startsWith("/scenario/")||tu(t)}function o6(t){const n=kk(t);return a6(n)?!1:n==="/"||n==="/apps"||n==="/apps/"}function i6(t,n,s=""){const r=Ta(s),[a,o]=l.useState(r.selectedAppDir),[i,c]=l.useState(r.selectedEntityHash);l.useEffect(()=>{const v=Ta(s);o(_=>_===v.selectedAppDir?_:v.selectedAppDir),c(_=>_===v.selectedEntityHash?_:v.selectedEntityHash)},[s]),l.useEffect(()=>{if(typeof window>"u"||t.length!==1)return;const v=Ta(s);if(v.selectedAppDir||v.selectedEntityHash||!o6(s))return;const _=`${Pa(t[0].dir)}${window.location.search}`;`${window.location.pathname}${window.location.search}`!==_&&(window.history.replaceState({},"",_),o(t[0].dir))},[t,s]);const d=l.useMemo(()=>i?n.find(v=>Za(v)===i)??null:null,[n,i]),u=l.useMemo(()=>a?t.find(v=>v.dir===a)??null:d?t.find(v=>v.dir===d.appDir)??null:i?t.find(v=>v.type==="web")??t[0]??null:null,[t,a,d,i]),h=l.useMemo(()=>u?Fl(n,u.dir):[],[n,u]),p=l.useMemo(()=>i?d:null,[i,d]);function m(v){if(typeof window>"u")return;const _=`${window.location.pathname}${window.location.search}`;v!==_&&window.history.pushState({},"",v)}function f(v){o(v),c(null),m(Pa(v))}function g(){o(null),c(null),m(rn("home"))}function b(v){const _=h.find(S=>S.route===v);if(!_)return;const j=Za(_),k=Lh(_);!j||!k||(c(j),m(k))}function x(v){c(v),m(Ih(v))}function y(){c(null),m(a?Pa(a):rn("home"))}return{selectedApp:u,appRouteEntities:h,selectedEntityHash:i,selectedRouteEntity:p,selectApp:f,deselectApp:g,selectRoute:b,selectEntity:x,deselectRoute:y}}function l6(t,n,s,r,a="",o=null,i=!0,c){const[d,u]=l.useState(null),h=l.useRef(!1),p=l.useRef(!1),{selectedApp:m,appRouteEntities:f,selectedEntityHash:g,selectedRouteEntity:b,selectApp:x,deselectApp:y,selectRoute:v,selectEntity:_,deselectRoute:j}=i6(t,n,a),k=l.useMemo(()=>Ud(f),[f]),S=l.useMemo(()=>Ud(b?[b]:[]),[b]),w=l.useMemo(()=>Ga({selectedApp:m,appRouteEntities:f,scenarioGroups:s,defaultScreenSize:o}),[f,o,s,m]),C=l.useMemo(()=>Vd(b),[b]),P=l.useMemo(()=>m?Ww(r,m.dir):[],[r,m]);l.useEffect(()=>{if(h.current)return;if(c!=null&&c.current){h.current=!0;return}if(!i)return;const B=t6({apps:t,scenarioGroups:s,hasExplicitAppSelection:!!m,defaultScreenSize:o});B&&(u(B),h.current=!0)},[t,o,s,m,i,c]),l.useEffect(()=>{if(m){if(p.current){p.current=!1;return}if(b){if(!C||d&&S.has(d))return;u(C);return}w&&(d&&k.has(d)||u(w))}},[w,C,d,m,k,b,S]);function T(B){x(B);const z=t.find(te=>te.dir===B);if(!z)return;const Y=Ga({selectedApp:z,appRouteEntities:Fl(n,z.dir),scenarioGroups:s,defaultScreenSize:o});u(Y)}function O(){y(),u(Kw(t,s,o))}function N(B){v(B);const z=Vd(Vw(f,B));u(z)}const E=l.useCallback(B=>{p.current=!0,u(B)},[]);function I(){if(j(),!m)return;const B=Ga({selectedApp:m,appRouteEntities:f,scenarioGroups:s,defaultScreenSize:o});B&&u(B)}function ee(B){_(B)}return{selectedApp:m,appRouteEntities:f,appTestGroups:P,selectedEntityHash:g,selectedRouteEntity:b,previewSlug:d,setPreviewSlug:u,setPreviewSlugExplicit:E,selectApp:T,deselectApp:O,selectRoute:N,selectEntity:ee,deselectRoute:I}}const c6=1e3;function d6(t,n){const s=l.useRef(t);s.current=t;const r=l.useRef(n);r.current=n;const a=l.useRef(null),o=l.useRef(null);l.useEffect(()=>{let i=!0;async function c(){var d;if(i){try{const u=a.current,h=u===null?"/api/editor-commands":`/api/editor-commands?since=${u}`,p=await fetch(h);if(p.ok){const m=await p.json();typeof m.seq=="number"&&(a.current=m.seq),m.bootId&&(o.current===null?o.current=m.bootId:o.current!==m.bootId&&(o.current=m.bootId,(d=r.current)==null||d.call(r)));for(const f of m.commands??[])s.current(f)}}catch{}i&&setTimeout(c,c6)}}return c(),()=>{i=!1}},[])}function u6(){const[t,n]=l.useState({}),[s,r]=l.useState(!0),[a,o]=l.useState(null);l.useEffect(()=>{let c=!1;return fetch("/api/dependency-graph").then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{if(c)return;const u="files"in d?d.files:d;n(u),r(!1)}).catch(d=>{c||(o(d.message),r(!1))}),()=>{c=!0}},[]);const i=l.useMemo(()=>DS(t),[t]);return{graph:t,entityLookup:i,loading:s,error:a}}function Uo(t,n){if(!t)return null;for(const s of n)for(const r of s.scenarios)if(r.slug===t)return r;return null}function h6({apps:t,appRouteEntities:n,directPreviewPath:s,fallbackPort:r,previewKind:a,previewOrigin:o,previewSlug:i,routeEntities:c,scenarioGroups:d,selectedApp:u,selectedRouteEntity:h}){const p=Bu(d,i),m=n6({apps:t,routeEntities:c,selectedApp:u,appRouteEntities:n}),f=s6({previewRouteEntities:m,selectedRouteEntity:h});let g="blank";a==="plan-preview"&&s?g="plan-preview":a==="results"&&s?g="results":a==="application"&&s?g="application":p?g=Ar(p)?"application":"component":f&&(g="application");const b=Hk({directPreviewPath:s,fallbackPreviewPath:f,previewKind:g,selectedScenario:p,port:r,previewOrigin:o});return{selectedScenario:p,previewRouteEntities:m,fallbackPreviewPath:f,resolvedPreviewKind:g,basePreviewUrl:b}}function p6({allowEditorRoutePreview:t,command:n,configLoaded:s,previewRouteEntities:r,scenarioGroups:a,scenarioDeferAvailable:o=!1}){const i=n.dimension??null,c=!!n.dimension,d=n.commandNonce;if(n.scenarioSlug??n.scenarioId){const b=n.scenarioSlug??n.scenarioId,x=Bu(a,b);return x?{clearCustomSize:c,scenarioSlug:x.slug,type:"show-scenario",viewportName:i,commandNonce:d}:o?{clearCustomSize:c,type:"defer",viewportName:i,commandNonce:d}:n.path?{clearCustomSize:c,path:n.path,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d}:{clearCustomSize:c,scenarioSlug:b,type:"show-scenario",viewportName:i,commandNonce:d}}if(!n.path)return{clearCustomSize:c,type:"refresh",viewportName:i,commandNonce:d};const u=n.path,h=u.startsWith("http")?new URL(u).pathname:u.split("?")[0]??u,p=h==="/results"||h.startsWith("/results/"),m=h==="/plan-preview",f=Fu(u);if(ui(h))return{clearCustomSize:c,path:u,previewKind:"agent-html",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(m)return{clearCustomSize:c,path:u,previewKind:"plan-preview",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(p)return{clearCustomSize:c,path:u,previewKind:"results",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(f&&!t)return{clearCustomSize:c,type:s?"ignore":"defer",viewportName:i,commandNonce:d};if(f&&t)return{clearCustomSize:c,path:u,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d};const g=r6({previewRouteEntities:r,path:u});return g?{clearCustomSize:c,scenarioSlug:g,type:"show-scenario",viewportName:i,commandNonce:d}:{clearCustomSize:c,path:u,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d}}function m6(t,n,s,r,a){const o=r.dimensions;return o.length===0||o.includes(t)&&n===null&&s===null?null:o.find(i=>a.some(c=>c.name===i))??o[0]}const f6=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}];function g6(t,n){const s=Object.entries(t);if(s.length===0)return f6;const r=s.map(([a,o])=>({name:a,width:o.width,height:o.height}));if(n){const a=r.findIndex(o=>o.name===n);if(a>0){const[o]=r.splice(a,1);r.unshift(o)}}return r}const b6=1500;function x6({enabled:t,pollMs:n=b6}){const[s,r]=l.useState(0),a=l.useRef(void 0);return l.useEffect(()=>{if(!t)return;let o=!1;const i=async()=>{try{const d=await fetch("/api/simulator-status");if(!d.ok)return;const u=await d.json();if(o)return;const h=u.state,p=a.current;a.current=h,h==="app-launched"&&p!==void 0&&p!=="app-launched"&&r(m=>m+1)}catch{}};i();const c=window.setInterval(i,n);return()=>{o=!0,window.clearInterval(c)}},[t,n]),s}function y6({isInIframe:t,hydrated:n=!0,persistedPath:s,previewKind:r,resolvedViewport:a,selectedScenario:o}){l.useEffect(()=>{t||!n||fetch("/api/editor-preview-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:r==="blank"?null:r,path:s,scenarioSlug:(o==null?void 0:o.slug)??null,scenarioId:(o==null?void 0:o.id)??null,dimension:a.name,width:a.width,height:a.height})}).catch(()=>{})},[n,t,s,r,a.height,a.name,a.width,o==null?void 0:o.id,o==null?void 0:o.slug])}function v6({deviceLaunchGeneration:t=0,isInIframe:n,onActivated:s,previewKind:r,previewMedium:a,scenariosLoaded:o,selectedScenario:i,seedRetryToken:c=0}){const[d,u]=l.useState(!1),[h,p]=l.useState(null),[m,f]=l.useState(null);return l.useEffect(()=>{if(!o||n)return;if(O1({isInIframe:n,previewKind:r,previewMedium:a,selectedScenario:i})){fetch("/api/editor-deactivate-scenario",{method:"POST"}).catch(()=>{});return}if(!i||i.scenarioType!=="application")return;let g=!1;return u(!0),p(null),f(null),fetch("/api/editor-activate-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:i.slug})}).then(async b=>{const x=await b.json().catch(()=>null);if(!g){if(!x||x.success===!1||x.seedError||x.deviceSeedError){p(x&&(x.seedError||x.deviceSeedError||x.error)||"scenario activation failed"),x!=null&&x.seedError?f("seed"):x!=null&&x.deviceSeedError||x!=null&&x.error?f("device"):f(null);return}s()}}).catch(b=>{g||(p(b instanceof Error?b.message:String(b)),f(null))}).finally(()=>{g||u(!1)}),()=>{g=!0}},[t,c,n,s,r,a,o,i==null?void 0:i.componentName,i==null?void 0:i.scenarioType,i==null?void 0:i.slug]),{seeding:d,seedError:h,seedErrorKind:m}}const j6=3;function w6({apps:t,appRouteEntities:n,configLoaded:s,defaultScreenSize:r,hydrated:a=!0,port:o,previewMedium:i,previewOrigin:c,projectTitle:d,previewSlug:u,routeEntities:h,scenarioGroups:p,scenariosLoaded:m,screenSizes:f,selectedApp:g,selectedRouteEntity:b,setPreviewSlug:x}){const[y,v]=l.useState(r??"Desktop"),_=l.useRef(!1),[j,k]=l.useState(null),[S,w]=l.useState(null),[C,P]=l.useState(null),[T,O]=l.useState(null),[N,E]=l.useState(()=>Date.now()),[I,ee]=l.useState(0),B=l.useRef(null),z=l.useRef(!1),Y=l.useMemo(()=>g6(f,r),[r,f]);l.useEffect(()=>{_.current||r&&(v(r),_.current=!0)},[r]);const te=l.useMemo(()=>j!==null&&S!==null?{name:"Custom",width:j,height:S}:Y.find(ge=>ge.name===y)??Y[0]??{name:"Desktop",width:1440,height:900},[y,S,j,Y]),R=Ot(),L=d==="CodeYam Editor",{basePreviewUrl:M,fallbackPreviewPath:K,previewRouteEntities:ie,resolvedPreviewKind:$,selectedScenario:V}=l.useMemo(()=>h6({apps:t,appRouteEntities:n,directPreviewPath:C,fallbackPort:o,previewKind:T,previewOrigin:c,previewSlug:u,routeEntities:h,scenarioGroups:p,selectedApp:g,selectedRouteEntity:b}),[t,n,C,o,T,c,u,h,p,g,b]),ae=l.useMemo(()=>M?qk(M,N):"",[M,N]),ne=l.useCallback(ge=>{v(ge),k(null),w(null)},[]),me=l.useCallback((ge,Ae)=>{k(ge),w(Ae)},[]),q=l.useCallback(ge=>{x(ge),P(null),O(null),E(Date.now());const Ae=Uo(ge,p);if(!Ae)return;const Te=m6(y,j,S,Ae,Y);Te!==null&&(v(Te),k(null),w(null))},[y,S,j,p,x,Y]),le=l.useCallback((ge,Ae)=>{const Te=(Ae==null?void 0:Ae.retriesLeft)??j6,H=p6({allowEditorRoutePreview:L,command:ge,configLoaded:s,previewRouteEntities:ie,scenarioGroups:p,scenarioDeferAvailable:Te>0});if(H.viewportName&&v(H.viewportName),H.clearCustomSize&&(k(null),w(null)),H.type==="show-scenario"){q(H.scenarioSlug),ee(G=>G+1);return}if(H.type==="defer"){B.current={command:ge,retriesLeft:Te};return}if(H.type==="refresh"){E(Date.now()),ee(G=>G+1);return}H.type!=="ignore"&&(H.type==="show-path"&&(O(H.previewKind),P(H.path),z.current=H.preserveDirectPreviewPathOnSlugChange,typeof H.previewSlug=="string"?x(H.previewSlug):H.previewSlug===null&&x(null)),E(Date.now()),ee(G=>G+1))},[s,L,ie,p,x,q]);l.useEffect(()=>{if(!s)return;const ge=B.current;ge&&(B.current=null,le(ge.command,{retriesLeft:ge.retriesLeft-1}))},[s,p,le]),l.useEffect(()=>{if(!(!u||C===null)){if(z.current){z.current=!1;return}P(null),O(null),E(Date.now())}},[C,u]);const Pe=l.useMemo(()=>$==="results"||$==="plan-preview"?C:$==="application"?C??(V==null?void 0:V.url)??K:null,[C,K,$,V==null?void 0:V.url]),Ce=l.useCallback(()=>{E(Date.now())},[]),[F,J]=l.useState(0),Z=l.useCallback(()=>{J(ge=>ge+1)},[]);y6({isInIframe:R,hydrated:a,persistedPath:Pe,previewKind:$,resolvedViewport:te,selectedScenario:V?{id:V.id??null,slug:V.slug}:null});const ve=x6({enabled:i==="simulator-ios"||i==="simulator-android"}),{seeding:fe,seedError:se,seedErrorKind:Q}=v6({deviceLaunchGeneration:ve,seedRetryToken:F,isInIframe:R,onActivated:Ce,previewKind:$,previewMedium:i,scenariosLoaded:m,selectedScenario:V?{slug:V.slug,scenarioType:V.scenarioType,componentName:V.componentName??null}:null}),ze=l.useCallback(ge=>{P(ge),O(ge?"application":null),E(Date.now())},[]);return{viewports:Y,resolvedViewport:te,previewUrl:ae,handleViewportChange:ne,handleCustomSizeChange:me,showScenarioPreview:q,handlePreviewCommand:le,setPreviewPath:ze,previewSeeding:fe,previewSeedError:se,previewSeedErrorKind:Q,retrySeed:Z,commandNonce:I}}function _6({isInIframe:t,scenariosLoaded:n,restoredRef:s,onAdopt:r,onHydrated:a,onSettledEmpty:o}){const i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(null),u=l.useRef(n);u.current=n;const h=l.useRef(r),p=l.useRef(a),m=l.useRef(o);h.current=r,p.current=a,m.current=o;const f=l.useCallback(()=>{if(c.current||!u.current||s.current)return;const g=d.current;g&&(c.current=!0,s.current=!0,h.current(g))},[s]);l.useEffect(()=>{t||i.current||(i.current=!0,fetch("/api/editor-preview-state").then(g=>g.json()).then(g=>{g&&(g.scenarioSlug||g.path)&&(d.current=g,f())}).catch(()=>{}).finally(()=>{var g;p.current(),!c.current&&!d.current&&((g=m.current)==null||g.call(m))}))},[t,f]),l.useEffect(()=>{f()},[n,f])}function k6({isInIframe:t,onConverge:n}){const s=l.useRef(n);s.current=n,l.useEffect(()=>{if(!t)return iA(()=>{fetch("/api/editor-preview-state").then(r=>r.json()).then(r=>{r&&(r.scenarioSlug||r.path)&&s.current(r)}).catch(()=>{}).finally(()=>{ti()})})},[t])}function S6({restoredRef:t,initiallySettled:n=!1,apply:s}){const r=l.useRef(n),a=l.useRef(null),o=l.useRef(s);o.current=s;const i=l.useCallback(u=>{t.current||(u.scenarioSlug||u.path)&&(t.current=!0,o.current(u))},[t]),c=l.useCallback(u=>{if(!t.current){if(!r.current){a.current=u;return}i(u)}},[i,t]),d=l.useCallback(()=>{r.current=!0;const u=a.current;a.current=null,u&&i(u)},[i]);return{requestRestore:c,onAdoptSettledEmpty:d}}function N6({scenariosLoaded:t,restoredRef:n,apply:s,onSettled:r}){const a=l.useRef(typeof window>"u"?null:Sk(window.location.search)),o=l.useRef(!1),i=l.useRef(!1),c=l.useRef(s),d=l.useRef(r);c.current=s,d.current=r,l.useEffect(()=>{i.current||!a.current||(i.current=!0,n.current=!0,d.current())},[n]),l.useEffect(()=>{if(o.current||!t)return;const u=a.current;u&&(o.current=!0,c.current(u))},[t])}function C6(t,{handlePreviewCommand:n,handleCustomSizeChange:s}){!t.scenarioSlug&&!t.path||(n({...t.scenarioSlug?{scenarioSlug:t.scenarioSlug}:{},...t.path?{path:t.path}:{},...t.dimension?{dimension:t.dimension}:{}}),t.dimension==="Custom"&&typeof t.width=="number"&&typeof t.height=="number"&&s(t.width,t.height))}function T6(){const[t,n]=l.useState(!1),[s,r]=l.useState(void 0),a=l.useCallback(d=>{r(d),n(!0)},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(()=>{},[]),c=l.useCallback(()=>{n(!1),r(void 0)},[]);return{showPostPushModal:t,featureSummary:s,onFeatureCompleteCommand:a,onAgentIdle:o,onAgentActive:i,dismissModal:c}}function zl(t){return t===null||t.slug===null||t.slug==="feature-complete"}function P6({showPostPushModal:t,stepState:n,dismissModal:s}){const r=l.useRef(!1);l.useEffect(()=>{if(!t){r.current=!1;return}if(zl(n)){r.current=!0;return}r.current&&(n==null?void 0:n.slug)!=null&&(s(),r.current=!1)},[t,n,s])}function O6({sessionInfo:t,stepState:n,showPostPushModal:s,onFeatureCompleteCommand:r}){const a=l.useRef(null);l.useEffect(()=>{const o=(t==null?void 0:t.cycleClosed)??null;if(!o)return;const i=o.closedAt??"unknown";if(a.current!==i){if(s){a.current=i;return}zl(n)&&(a.current=i,r(o.summary??void 0))}},[t,n,s,r])}function A6(t,n){return t&&zl(n)}function R6(){const[t,n]=l.useState(!1),s=l.useCallback(()=>{n(!0)},[]),r=l.useCallback(()=>{n(!1)},[]);return{showPlanCompleteModal:t,onPlanCompleteCommand:s,dismissPlanCompleteModal:r}}function E6({plans:t,completedPlans:n,isAgentBuilding:s,onLaunch:r}){const{claims:a}=wl(),{status:o}=_l(),i=((o==null?void 0:o.consecutiveFailures)??0)>=3,c=l.useMemo(()=>Sl(a),[a]),{annotationsBySlug:d,dependenciesBySlug:u}=Nl(t),h=l.useMemo(()=>By([...t.map(f=>f.author),...n.map(f=>f.author)]),[t,n]),{requestRun:p,gateModals:m}=ha({dependenciesBySlug:u,claimsBySlug:c,isAgentBuilding:s,onLaunch:r});return{claimsBySlug:c,staleFetch:i,annotationsBySlug:d,dependenciesBySlug:u,showAuthors:h,requestRun:p,gateModals:m}}function M6(){const{showBuildTab:t}=Cl(typeof window>"u"?"/":window.location.pathname),{config:n}=jt(),[s,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useCallback(async c=>{if(s)return!1;o(null),r(!0);try{try{await Uy(),Dx()}catch{}const d=await fetch("/api/build/start-from-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:c})});if(!d.ok){let u=`HTTP ${d.status}`;try{const h=await d.json();h!=null&&h.error&&(u=h.error)}catch{}throw new Error(u)}return t(),await Vy({provider:n==null?void 0:n.provider}),!0}catch(d){return o(d instanceof Error?d.message:"Failed to launch build"),!1}finally{r(!1)}},[s,t,n==null?void 0:n.provider]);return{launching:s,error:a,launchPrompt:i}}function I6({onTransitionToLive:t}){const[n,s]=l.useState(!1),[r,a]=l.useState(null),o=l.useRef(!1),i=l.useRef(null),c=l.useRef(t);c.current=t;const d=l.useCallback(()=>{o.current=!0,s(!0)},[]),u=l.useCallback(()=>{o.current=!1,s(!1);const f=i.current;f&&(i.current=null,a(null),c.current(f))},[]),h=l.useCallback(f=>o.current?(i.current=f,a(f),!0):!1,[]),p=l.useCallback(()=>{i.current=null,a(null)},[]),m=l.useCallback(()=>{o.current=!1,s(!1),i.current=null,a(null)},[]);return{isAgentBuilding:n,isAgentBuildingRef:o,buildingScenarioSlug:r,onAgentIdle:u,onAgentActive:d,guardScenarioSelect:h,clearBuildingOverlay:p,forceIdle:m}}function L6({chatOpen:t}){const[n,s]=l.useState(!1),[r,a]=l.useState(!1);return l.useEffect(()=>{function o(d){const u=d.detail;return(u==null?void 0:u.chatName)==="plan"}function i(d){o(d)&&(s(!0),a(!1))}function c(d){o(d)&&(s(!1),a(!0))}return window.addEventListener("miniagent-agent-active",i),window.addEventListener("miniagent-agent-idle",c),()=>{window.removeEventListener("miniagent-agent-active",i),window.removeEventListener("miniagent-agent-idle",c)}},[]),l.useEffect(()=>{t||(s(!1),a(!1))},[t]),{planActive:n,planIdle:r}}function D6(t,n,s){return t.map(r=>{const a=Ww(n,r.dir),o=Gw(s,r.dir,r.type),{total:i,passed:c,failed:d,ignored:u,discovered:h}=Uw(a),p=YR(o);return{app:r,tests:{total:i,passed:c,failed:d,ignored:u,discovered:h},scenarios:{total:p,thumbnails:F6(o)}}})}function F6(t){const n=[];for(const s of t)for(const r of s.scenarios)if(r.screenshotPaths.length>0&&n.push({path:r.screenshotPaths[0],cacheBuster:r.screenshotCapturedAtMs}),n.length>=6)return n;return n}function z6(t,n){return t==null?null:Math.min(1,Math.max(.04,t/Xi(n)))}function $6(t,n){return t==null||t===0?null:`${t}/${Xi(n)}`}function B6(t,n){var r;if(n==null||!Number.isFinite(n))return null;let s=null;for(const a of t??[]){const o=(r=a.screenshotPaths)==null?void 0:r[0];if(!o)continue;const i=a.screenshotCapturedAtMs;i==null||i<n||(!s||i>s.at)&&(s={path:o,at:i})}return(s==null?void 0:s.path)??null}const H6="Your app will display here once set up.",q6="Loading your app…",W6="Setting up your project…",G6="Select a scenario to preview",U6="No preview is available for this project.";function V6({configLoading:t,hasNoApps:n,hasStepState:s,hasPreviewableApp:r,setupInProgress:a,hasCaptureFrame:o}){return t?q6:a&&!o?W6:n&&!s?H6:r?G6:U6}const Y6=["web","mobile"];function K6(t){return Y6.includes(t)}function J6(t,n){return n?{scenarioSlug:t,path:n}:{scenarioSlug:t}}function X6(t,n){return t==="needs-login"&&!n}function Q6(t,n){if(!t)return null;for(const s of n)for(const r of s.scenarios)if(r.name===t)return r;return null}const Z6="The app is being edited",eE="Live preview will load when the build agent is idle",tE="Showing a saved version",nE="This is a past version of this scenario";function sE({shot:t,isLatest:n,liveScenario:s,isAgentBuilding:r}){if(n&&s&&!r)return{kind:"live",slug:s.slug};const[a,o]=r?[Z6,eE]:[tE,nE];return{kind:"historical",screenshotPath:t.screenshotPath??null,scenarioName:t.name,heading:a,subtext:o}}function Jw(t){return!t.hasActiveSession&&!t.isAgentBuilding&&!t.showPostPushModal&&t.launchingPlanSlug===null&&!t.submittingBuildPrompt&&!t.stepStateFeature&&!t.buildLaunchModalDismissed}function rE(t){return t.activeTab==="build"&&!t.buildActivityInFlight&&!t.buildActivityMinimized&&!t.buildHandoffPending&&Jw(t)}function aE(t){const[n,s]=l.useState("menu"),[r,a]=l.useState(!1),o=l.useCallback(p=>{s(p),a(!0)},[]),i=l.useCallback(()=>{s("session"),a(!1)},[]),c=l.useCallback(()=>{s("menu"),a(!1)},[]),d=l.useCallback(()=>a(!0),[]),u=l.useCallback(()=>a(!1),[]),h=l.useCallback(p=>{if(p==="plan"){t==null||t();return}s(m=>p==="prototype"&&m==="chat"?m:p),a(p!=="menu")},[t]);return{activity:n,minimized:r,hasLiveActivity:n==="prototype"||n==="chat",chooseActivity:o,startSession:i,finishActivity:c,minimize:d,reopen:u,applyCommand:h}}const oE=900*1e3;function iE(){const[t,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/server/update-check");if(!r.ok)return;const a=await r.json();n(a)}catch{}},[]);return l.useEffect(()=>{s()},[s]),l.useEffect(()=>{const r=setInterval(()=>void s(),oE);return()=>clearInterval(r)},[s]),{update:t}}function lE(t,n,s){const[r,a]=l.useState(!1),o=l.useCallback(()=>{a(!0)},[]),i=l.useCallback(c=>{a(!1),n(c)},[n]);return l.useEffect(()=>{r&&(t||(a(!1),s==null||s(),n("build")))},[r,t,n,s]),{arm:o,navigateToTabUser:i,pendingBuildNav:r}}const cE=4e3,dE=2;function Xw({state:t,provider:n,credsPresent:s=!0,cliInstalled:r=!0,scannedDirs:a=[],reason:o=null,expiresAt:i=null,probeInFlight:c=!1,probeAttempts:d=0,backendOutOfDate:u=!1,sessionOngoing:h=!1,onAuthenticated:p,onAuthorized:m}){const[f,g]=l.useState(!1),[b,x]=l.useState(!1),y=Ue(n),[v,_]=l.useState(!1);l.useEffect(()=>{if(t!=="unknown"){_(!1);return}const w=window.setTimeout(()=>_(!0),cE);return()=>window.clearTimeout(w)},[t]);const j=l.useCallback(()=>{g(!1),p(),m==null||m()},[p,m]),k=l.useCallback(async()=>{x(!0);try{await fetch("/api/auth/refresh-cache",{method:"POST"}),p()}catch{}finally{x(!1)}},[p]);if(t==="authenticated")return null;const S=f?e.jsx(lk,{provider:n,onAuthenticated:j,onClose:()=>g(!1)}):null;if(t==="unknown"){const w=o==="probe-timeout"&&d>=dE,C=r===!1||o==="cli-not-found";return!w&&!C&&(c||!v)||u?null:C?e.jsxs("div",{"data-testid":"provider-auth-cli-not-found","data-auth-card":!0,className:"m-4 rounded-lg border border-[#3A3A3A] bg-[#1E1E1E] p-5 space-y-3",children:[e.jsxs("p",{className:"text-sm text-white font-medium",children:[y," CLI not found"]}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["We couldn't find the ",y," CLI on this machine — we searched your PATH and the standard install locations",a.length>0?e.jsxs(e.Fragment,{children:[" (",a.join(", "),")"]}):e.jsx(e.Fragment,{children:" (~/.local/bin, ~/.cargo/bin, /opt/homebrew/bin, /usr/local/bin)"}),". Install the ",y," CLI, or add the directory it lives in to your PATH, then recheck. This is a PATH/install problem — re-authenticating won't fix it."]}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("button",{onClick:()=>void k(),"data-testid":"provider-auth-cli-not-found-recheck",disabled:b,className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:b?"Rechecking…":"Recheck after installing"})})]}):e.jsxs("div",{"data-testid":"provider-auth-checking","data-auth-card":!0,className:"m-4 rounded-lg border border-[#3A3A3A] bg-[#1E1E1E] p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{"data-testid":"provider-auth-checking-spinner","aria-hidden":"true",className:"h-4 w-4 rounded-full border-2 border-[#8E8E8E] border-t-transparent animate-spin"}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["Checking your ",y," account… If this takes more than a few seconds, your token may need refresh."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>g(!0),"data-testid":"provider-auth-checking-retry",className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Authenticate"}),e.jsx("button",{onClick:()=>void k(),"data-testid":"provider-auth-checking-recheck",disabled:b,className:"px-3 py-2 text-sm rounded-md border border-[#3A3A3A] text-white cursor-pointer disabled:opacity-50",children:b?"Rechecking…":"Already logged in? Recheck"})]}),S]})}return e.jsx(ik,{provider:n,credsPresent:s,reason:o,expiresAt:i,sessionOngoing:h,onAuthenticated:p,onAuthorized:m})}const QB=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthGate:Xw},Symbol.toStringTag,{value:"Module"}));function Qw({update:t}){const{copied:n,copy:s}=ri();if(!t||!t.available)return null;const r=t.channel==="desktop";return e.jsx("div",{className:"rounded-lg p-4","data-testid":"update-available-banner",role:"status",style:{background:"rgba(91, 155, 213, 0.16)",border:"1px solid rgba(91, 155, 213, 0.55)",borderLeft:"4px solid var(--blue-300)",boxShadow:"0 2px 10px rgba(91, 155, 213, 0.18)"},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-xl leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--blue-300)"},children:"↑"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[e.jsx("div",{className:"font-semibold mb-1",style:{color:"var(--blue-300)"},children:r?"Update ready":"Update available"}),r?e.jsx(e.Fragment,{children:"It will install automatically after your current session ends. To install now, use the Check for Updates menu."}):e.jsxs(e.Fragment,{children:["A new version of CodeYam Editor is available (",e.jsxs("span",{style:{color:"var(--text-strong)",fontWeight:600},children:[t.currentVersion," → ",t.latestVersion]}),"). Run"," ",e.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:t.upgradeCommand})," ","to upgrade."," ",e.jsx("button",{type:"button",className:"mt-2 inline-block rounded px-2.5 py-1 text-xs font-medium",style:{background:"var(--blue-300)",color:"#0b1220"},onClick:()=>void s(t.upgradeCommand??""),children:n?"Copied":"Copy command"})]})]})]})})}const ZB=Object.freeze(Object.defineProperty({__proto__:null,UpdateAvailableBanner:Qw},Symbol.toStringTag,{value:"Module"})),uE=300,Yd=150;function hE(t){const[n,s]=l.useState(null),r=l.useRef(!1),[a,o]=l.useState(!1),i=l.useCallback(()=>{var u;return((u=t.current)==null?void 0:u.clientWidth)??1200},[t]),c=n??Math.floor(i()/2),d=l.useCallback(u=>{u.preventDefault(),r.current=!0,o(!0)},[]);return l.useEffect(()=>{const u=p=>{var b;if(!r.current)return;const m=((b=t.current)==null?void 0:b.getBoundingClientRect().left)??0,f=p.clientX-m,g=i();f<Yd?s(0):f>g-Yd?s(g):s(Math.max(uE,f))},h=()=>{r.current&&(r.current=!1,o(!1))};return document.addEventListener("mousemove",u),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h)}},[t,i]),{leftWidth:c,isDragging:a,handleMouseDown:d}}const pE=3e3;function mE({hot:t,isInIframe:n,reload:s=()=>window.location.reload(),sustainedDisconnectMs:r=pE}){return()=>{}}function fE(){l.useEffect(()=>mE({hot:void 0,isInIframe:Ot()}),[])}async function Kd(){await ck(dk),await Gy({send:Gn,waitForIdle:vc,ceilingMs:ys,payload:"/clear\r"}),await vc(ys),Gn("/codeyam-plan\r")}function gE(){fetch("/api/clear-build-agent-session",{method:"POST"}).catch(()=>{})}function bE(t){const n=l.useRef(null),s=l.useRef(null);l.useEffect(()=>{if(typeof document>"u")return;s.current||(s.current=document.createElement("canvas"),s.current.width=64,s.current.height=64);const r=document.querySelector('link[rel="icon"]');if(!r){re("favicon-redraw",{idle:t,hasIcon:!1});return}if(n.current||(n.current=r.href),!t){r.href=n.current,re("favicon-restore",{});return}re("favicon-redraw",{idle:!0,hasIcon:!0});const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{const o=s.current,i=o.getContext("2d");i.clearRect(0,0,64,64);const c=56,d=(64-c)/2;i.drawImage(a,d,d,c,c);const u=12,h=64-u-1,p=u+1;i.beginPath(),i.arc(h,p,u,0,2*Math.PI),i.fillStyle="#ef4444",i.fill(),r.href=o.toDataURL("image/png")},a.src=n.current},[t]),l.useEffect(()=>()=>{if(typeof document>"u")return;const r=document.querySelector('link[rel="icon"]');r&&n.current&&(r.href=n.current)},[])}function xE(t,n){return new _5({playSound:Ki,showSystemNotification:()=>{if(typeof Notification>"u"||Notification.permission!=="granted")return;n.current&&n.current.close();const s=t.current,r=new Notification(`${s} is ready for you`,{body:`${s} has finished and is waiting for your input.`,tag:"build-agent-idle"});r.onclick=()=>{window.focus(),r.close(),n.current=null},n.current=r},closeSystemNotification:()=>{typeof Notification>"u"||n.current&&(n.current.close(),n.current=null)}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"})}function yE(t,n){return t==="hook-stop"?n.idleOnStop:n.idleOnNotification}const vE=600*1e3,jE=3e3;function wE({agentName:t,isBuildTabActive:n,isAgentBuilding:s,buildSessionLive:r,featureCompleteKey:a,navigateToTab:o,onAgentIdleImmediate:i,onAgentActiveImmediate:c}){const d=l.useRef(t);d.current=t;const u=l.useRef(n);u.current=n;const h=l.useRef(i);h.current=i;const p=l.useRef(c);p.current=c;const[m,f]=l.useState(Ng),[g,b]=l.useState(!1),x=l.useRef(!1);x.current=g;const[y,v]=l.useState(!1),_=l.useRef(!1),j=l.useRef(null),k=l.useRef(null),S=l.useRef(null),w=l.useRef(typeof document<"u"&&document.hidden?Date.now():null),C=l.useRef(null),P=l.useRef(r??!1);P.current=r??!1,bE(g),S.current||(S.current=xE(d,k));const T=l.useCallback(M=>{f(M),Cg(M)},[]),O=l.useCallback(M=>{j.current!==null&&(clearTimeout(j.current),j.current=null,re("debounce-cancelled",{trigger:M}))},[]),N=l.useCallback(M=>{x.current&&re("idle-cleared",{trigger:M}),b(!1),x.current=!1,v(!1),C.current=null,k.current&&(k.current.close(),k.current=null)},[]),E=l.useCallback((M,K)=>{var ie;if(!yE(M,m)){re("idle-suppressed-by-pref",{source:M,blocked:K});return}re("ws-idle-received",{buildTabActive:u.current,source:M,blocked:K}),(ie=h.current)==null||ie.call(h),O("re-arm-on-idle"),j.current=setTimeout(()=>{var ne;j.current=null;const $=w.current,V=$===null?null:Date.now()-$,ae=$!==null&&Date.now()-$>vE;re("debounce-resolved",{suppressedForOvernight:ae,msHidden:V,buildTabActive:u.current}),ae||(ne=S.current)==null||ne.onIdle(m,u.current),b(!0),x.current=!0,v(K),C.current=Date.now(),_.current=!1,re("agent-currently-idle-set",{suppressedForOvernight:ae,blocked:K}),u.current&&yt()},_r)},[m,O]),I=l.useCallback(M=>E(M,!1),[E]),ee=l.useCallback(M=>E(M,!0),[E]),B=l.useCallback(()=>{var M,K,ie;(M=p.current)==null||M.call(p),O("agent-active"),(K=S.current)==null||K.onActive(),(ie=S.current)==null||ie.resetActivityFlag(),x.current&&P.current&&C.current!==null&&Date.now()-C.current>jE&&N("remote-resume")},[O,N]),z=l.useCallback(()=>{var M,K;O("user-input"),x.current&&((M=S.current)==null||M.onUserEngagement(),(K=S.current)==null||K.reportUserActivity("terminal-input"),_.current=!0,N("user-input"))},[O,N]),Y=l.useCallback(M=>{var K;M==="build"&&(O("navigate-build"),x.current&&((K=S.current)==null||K.onUserEngagement(),_.current=!0,N("navigate-build"))),o(M)},[o,O,N]),te=l.useCallback(()=>{var M;O("dismiss-banner"),(M=S.current)==null||M.onUserEngagement(),_.current=!0,N("dismiss-banner")},[O,N]),R=l.useCallback(()=>{var M;O("stop-building"),(M=S.current)==null||M.onUserEngagement(),_.current=!0,N("stop-building")},[O,N]);l.useEffect(()=>{function M(){var q;x.current&&(_.current||(O("ack-notification"),(q=S.current)==null||q.onUserEngagement(),_.current=!0,re("notification-acknowledged",{trigger:"user-return"})))}function K(q){var le;x.current&&u.current&&document.hasFocus()&&(document.hidden||((le=S.current)==null||le.onUserEngagement(),_.current=!0,N(q)))}function ie(q){var le;document.hasFocus()&&M(),(le=S.current)==null||le.reportUserActivity(q)}const $=()=>ie("mousemove"),V=()=>ie("mousedown"),ae=()=>ie("keydown");function ne(){document.hidden?w.current===null&&(w.current=Date.now()):(w.current=null,M(),K("tab-visible-on-build"))}function me(){var q;M(),K("window-focus-on-build"),(q=S.current)==null||q.reportUserActivity("focus")}return window.addEventListener("focus",me),document.addEventListener("visibilitychange",ne),document.addEventListener("mousemove",$),document.addEventListener("mousedown",V),document.addEventListener("keydown",ae),()=>{O("unmount"),window.removeEventListener("focus",me),document.removeEventListener("visibilitychange",ne),document.removeEventListener("mousemove",$),document.removeEventListener("mousedown",V),document.removeEventListener("keydown",ae)}},[O,N]);const L=l.useRef(a??0);return l.useEffect(()=>{var ie;const M=a??0;if(M===L.current)return;L.current=M;const K=u.current&&document.hasFocus();re("feature-complete-fast-path",{skipBecauseWatching:K}),!K&&((ie=S.current)==null||ie.onIdle(m,!1),b(!0),x.current=!0,C.current=Date.now(),_.current=!1)},[a,m]),l.useEffect(()=>{var M,K;if((M=S.current)==null||M.onBuildTabChange(n,m),n)return x.current&&typeof document<"u"&&document.hasFocus()&&!document.hidden&&((K=S.current)==null||K.onUserEngagement(),_.current=!0,N("build-tab-active-on-focus")),yt()},[n,m,N]),{buildIdle:g,agentBlocked:y,bannerVisible:g,notifSettings:m,handleSettingsChange:T,handleAgentIdle:I,handleAgentBlocked:ee,handleAgentActive:B,handleUserInput:z,handleNavigateToTab:Y,dismissIdleBanner:te,clearIdleForStopBuilding:R}}const _E=1e4;function kE(t){const{isAgentBuilding:n,submittingBuildPrompt:s,launchingPlanSlug:r,sessionInfo:a,stepFeature:o,refetchSessionInfo:i}=t,[c,d]=l.useState(!1),u=l.useRef(!1),h=l.useCallback((m,f)=>{u.current!==m&&(re("build-session-live-change",{from:u.current,to:m,trigger:f}),u.current=m,d(m))},[]);return l.useEffect(()=>{n&&h(!0,"agent-active")},[n,h]),l.useEffect(()=>{s&&h(!0,"launch-prompt")},[s,h]),l.useEffect(()=>{r!==null&&h(!0,"launch-plan")},[r,h]),l.useEffect(()=>{((a==null?void 0:a.resumeMode)==="resume"||(a==null?void 0:a.resumeMode)==="handoff")&&h(!0,"resumable-session-detected")},[a,h]),l.useEffect(()=>{(a==null?void 0:a.agentBrokerLive)===!0&&h(!0,"broker-live-detected")},[a,h]),l.useEffect(()=>{a&&!a.hasSession&&!a.agentBrokerLive&&h(!1,"session-ended")},[a,h]),l.useEffect(()=>{if(!c)return;const m=setInterval(()=>{i()},_E);return()=>clearInterval(m)},[c,i]),{buildSessionLive:c,agentActivelyBuilding:c&&(!!o||n||s||r!==null),transitionBuildSessionLive:h}}function Jd(t){const{isAgentBuilding:n,trigger:s,transitionBuildSessionLive:r}=t;if(n){re("build-session-live-suppress-clear",{trigger:s,reason:"agent-still-active"});return}r(!1,s)}const SE=new Set(["ui-confirm-plan","backend-confirm-plan","present-live","backend-confirm","ui-present","backend-review"]);function NE(t,n){return t&&SE.has(t)?"needs-input":n?"waiting":"building"}function CE(){const[t,n]=l.useState({loading:!1,error:null,downloaded:!1}),s=l.useCallback(async a=>{n({loading:!0,error:null,downloaded:!1});try{const i=await(await fetch("/api/editor-transcript-package")).json();if(!i.success){n({loading:!1,error:i.error||"Failed to package transcript",downloaded:!1});return}let c=i.content;a!=null&&a.trim()&&(c=`## User Notes
|
|
324
|
+
|
|
325
|
+
${a.trim()}
|
|
326
|
+
|
|
327
|
+
${c}`);const d=new Blob([c],{type:"text/markdown"}),u=URL.createObjectURL(d),h=document.createElement("a");h.href=u,h.download=i.filename,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(u),n({loading:!1,error:null,downloaded:!0})}catch(o){n({loading:!1,error:o instanceof Error?o.message:"Network error",downloaded:!1})}},[]),r=l.useCallback(()=>{n({loading:!1,error:null,downloaded:!1})},[]);return{...t,sendTranscript:s,reset:r}}function TE(t,n){var o;const s="feedback@codeyam.com",r=encodeURIComponent(`CodeYam Session Feedback: ${t||"Session"}`+(n!=null&&n.category?` [${n.category}]`:"")),a=encodeURIComponent([((o=n==null?void 0:n.note)==null?void 0:o.trim())||"(no note)","","(Please attach the downloaded transcript file.)"].join(`
|
|
328
|
+
|
|
329
|
+
`));return`mailto:${s}?subject=${r}&body=${a}`}const PE=["bug","suggestion","question","praise"];function Zw({featureName:t,onClose:n}){const[s,r]=l.useState(""),[a,o]=l.useState(null),[i,c]=l.useState(!1),{loading:d,error:u,downloaded:h,sendTranscript:p}=CE(),m=l.useCallback(()=>{p(s)},[p,s]),f=l.useCallback(()=>{navigator.clipboard.writeText("feedback@codeyam.com").then(()=>{c(!0),setTimeout(()=>c(!1),2e3)})},[]),g=l.useCallback(b=>{o(x=>x===b?null:b)},[]);return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Send Session Transcript"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Download your session transcript and send it to the CodeYam team for feedback or debugging."}),e.jsxs("div",{className:"mb-3",children:[e.jsx("span",{className:"block text-xs text-[var(--text-muted)] mb-1.5",children:"Tag (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:PE.map(b=>{const x=a===b;return e.jsx("button",{type:"button","aria-pressed":x,onClick:()=>g(b),className:"px-2.5 py-1 rounded-full text-xs transition cursor-pointer",style:{background:x?"var(--accent-active)":"transparent",color:x?"var(--bg-deep)":"var(--text-secondary)",border:"1px solid var(--border-default)"},children:b},b)})})]}),e.jsx("textarea",{value:s,onChange:b=>r(b.target.value),placeholder:"What's on your mind? (optional)",className:"w-full h-20 px-3 py-2 text-sm rounded-md mb-4 resize-none",style:{background:"var(--bg-input, var(--bg-deep))",color:"var(--text-primary)",border:"1px solid var(--border-default)"}}),u&&e.jsx(ft,{text:u,className:"text-sm text-red-400",rowClassName:"mb-3"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-green-400 text-center",children:"Transcript downloaded!"}),e.jsx("a",{href:TE(t,{note:s,category:a}),className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition text-center block",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},children:"Open Email Client"}),e.jsx("button",{onClick:f,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},type:"button",children:i?"Copied!":"Copy Email Address"}),e.jsx("p",{className:"text-xs text-[var(--text-dim)] text-center",children:"Attach the downloaded file to your email"})]}):e.jsx("button",{onClick:m,disabled:d,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-active)",color:"var(--bg-deep)",opacity:d?.6:1},type:"button",children:d?"Packaging transcript...":"Download Transcript"}),e.jsx("button",{onClick:n,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"transparent",color:"var(--text-secondary)",border:h?"none":"1px solid var(--border-default)"},type:"button",children:h?"Done":"Cancel"})]})]})}const eH=Object.freeze(Object.defineProperty({__proto__:null,SendTranscriptModal:Zw},Symbol.toStringTag,{value:"Module"}));function e_({sha:t,onClick:n}){if(!t)return null;const s=t.slice(0,6),r="font-mono text-[11px] leading-none px-1.5 py-0.5 rounded border border-white/5 bg-black/55 backdrop-blur-sm hover:bg-black/75";return e.jsx("div",{className:`fixed bottom-1 left-1 z-30 ${n?"":"pointer-events-none"}`,style:{paddingBottom:"env(safe-area-inset-bottom)"},children:n?e.jsx("button",{type:"button",onClick:n,"data-testid":"build-sha-badge",title:t,"aria-label":`Build commit ${t}`,className:`cursor-pointer ${r}`,style:{color:"var(--text-secondary)"},children:s}):e.jsx("span",{"data-testid":"build-sha-badge",title:t,"aria-label":`Build commit ${t}`,className:r,style:{color:"var(--text-secondary)"},children:s})})}const tH=Object.freeze(Object.defineProperty({__proto__:null,BuildShaBadge:e_},Symbol.toStringTag,{value:"Module"}));function OE(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/raw-terminal`}function t_(){if(Ot())return null;const t=l.useRef(null),n=l.useRef(null),s=l.useRef(null),r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(!1),[c,d]=tl(1200);function u(h){const p=r.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&p.send(new TextEncoder().encode(h))}return el(t,()=>{if(s.current&&n.current){s.current.fit();const h=r.current;(h==null?void 0:h.readyState)===WebSocket.OPEN&&h.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))}}),l.useEffect(()=>{if(!t.current||a.current)return;a.current=!0;const h=new Jo.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),p=new Xo.FitAddon;h.loadAddon(p),h.open(t.current),n.current=h,s.current=p;const m=Qo(h,t.current,{onCopy:()=>d()}),f=Zo(h,{sendInput:u});requestAnimationFrame(()=>{p.fit(),h.focus()});const g=new WebSocket(OE());return r.current=g,g.binaryType="arraybuffer",g.onmessage=b=>{b.data instanceof ArrayBuffer&&h.write(new Uint8Array(b.data))},g.onopen=()=>{g.send(JSON.stringify({type:"resize",cols:h.cols,rows:h.rows}))},g.onclose=()=>{i(!0),h.writeln(`\r
|
|
330
|
+
\x1B[90m[Shell session ended]\x1B[0m`)},h.onData(u),()=>{var b;(b=r.current)==null||b.close(),f(),m(),h.dispose(),a.current=!1}},[]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[e.jsx("div",{ref:t,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var h;return(h=n.current)==null?void 0:h.focus()}}),o&&e.jsx("div",{role:"alert",className:"absolute bottom-2 left-2 rounded px-2 py-1 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:"Shell disconnected — close and reopen for a fresh shell."}),c&&e.jsx(sa,{})]})}const nH=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalEmulator:t_},Symbol.toStringTag,{value:"Module"}));function n_({isOpen:t,onClose:n}){return l.useEffect(()=>{if(!t)return;const s=r=>{r.key==="Escape"&&n()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),t?e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"raw-terminal-modal-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onMouseDown:s=>{s.target===s.currentTarget&&n()},children:e.jsxs("div",{className:"flex flex-col rounded-lg shadow-xl",style:{width:"80vw",height:"80vh",maxWidth:1200,maxHeight:800,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border-default)]",children:[e.jsx("h2",{id:"raw-terminal-modal-title",className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Terminal"}),e.jsx("button",{type:"button",onClick:n,"data-testid":"raw-terminal-modal-close","aria-label":"Close terminal",className:"text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"✕"})]}),e.jsx("div",{className:"flex-1 flex flex-col",style:{minHeight:0},children:e.jsx(t_,{})})]})}):null}const sH=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalModal:n_},Symbol.toStringTag,{value:"Module"}));function AE(){const[t,n]=l.useState(!1),[s,r]=l.useState(null),[a,o]=l.useState(null),i=l.useRef(0);l.useEffect(()=>{if(a===null)return;const u=window.setTimeout(()=>o(null),uk);return()=>window.clearTimeout(u)},[a]);const c=l.useCallback(()=>r(null),[]),d=l.useCallback(async u=>{if(u.length!==0){for(const h of u)if(h.size>jc){o(`${h.name} is larger than the ${jc/(1024*1024)} MB cap`);return}try{const h=await Promise.all(u.map(async g=>({filename:g.name||"unnamed",contentBase64:await hk(g)}))),p=await fetch("/api/editor-upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:h})});if(!p.ok){const g=await p.json().then(b=>b.error).catch(()=>null);throw new Error(g??`Upload failed: ${p.status}`)}const f=(await p.json()).written??[];if(f.length===0)throw new Error("Upload returned no saved files");r(f)}catch(h){o(h instanceof Error?h.message:String(h))}}},[]);return l.useEffect(()=>{const u=g=>{var b,x;return!!((x=(b=g.dataTransfer)==null?void 0:b.types)!=null&&x.includes("Files"))},h=g=>{u(g)&&(g.preventDefault(),i.current+=1,n(!0))},p=g=>{u(g)&&g.preventDefault()},m=g=>{u(g)&&(i.current=Math.max(0,i.current-1),i.current===0&&n(!1))},f=g=>{var x;if(!u(g))return;if(g.defaultPrevented){i.current=0,n(!1);return}if(g.preventDefault(),i.current=0,n(!1),g.dataTransfer&&pk(g.dataTransfer)){o("Folder drops are not supported — drag individual files instead");return}const b=Array.from(((x=g.dataTransfer)==null?void 0:x.files)??[]).filter(y=>y.size>0);d(b)};return window.addEventListener("dragenter",h),window.addEventListener("dragover",p),window.addEventListener("dragleave",m),window.addEventListener("drop",f),()=>{window.removeEventListener("dragenter",h),window.removeEventListener("dragover",p),window.removeEventListener("dragleave",m),window.removeEventListener("drop",f)}},[d]),{dragActive:t,pendingPaths:s,error:a,clearPending:c,uploadFiles:d}}function s_({visible:t}){return t?e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)",pointerEvents:"none"},"data-testid":"global-file-drop-overlay","aria-hidden":"true",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 px-10 py-8 rounded-xl text-center",style:{border:"2px dashed var(--accent-active, #D7FF63)",background:"rgba(0, 0, 0, 0.30)"},children:[e.jsx("span",{className:"text-2xl font-semibold text-[var(--text-primary)]",children:"Drop files to add them to this session"}),e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:"Saved to .codeyam/uploads/ — then hand them to the agent"})]})}):null}const rH=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropOverlay:s_},Symbol.toStringTag,{value:"Module"}));function r_({message:t}){return e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-[80] px-4 py-2 rounded-md text-sm",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",color:"var(--text-danger, #ff6b6b)"},"data-testid":"global-file-drop-error",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:t}),e.jsx(at,{variant:"icon",text:t})]})})}const aH=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropToast:r_},Symbol.toStringTag,{value:"Module"}));function a_({paths:t,onClose:n}){const{sendToAgent:s,agentReady:r}=Ko(),[a,o]=l.useState(!1),i=l.useCallback(h=>{h.key==="Escape"&&(h.preventDefault(),n())},[n]);l.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]);const c=t.map(mk).join(" "),d=l.useCallback(()=>{s(c+" ")&&n()},[s,c,n]),u=l.useCallback(()=>{var h;(h=navigator.clipboard)==null||h.writeText(c).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{})},[c]);return e.jsx("div",{className:"fixed inset-0 z-[75] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"file-drop-confirm-modal",children:e.jsxs("div",{className:"max-w-lg w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t.length===1?"File added":`${t.length} files added`}),e.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Saved to your project, but the agent hasn't been told about"," ",t.length===1?"it":"them"," yet. Hand the path",t.length===1?"":"s"," over so it can read"," ",t.length===1?"it":"them","."]}),e.jsx("ul",{className:"mb-4 max-h-48 overflow-y-auto rounded-md p-3 text-xs font-mono",style:{background:"var(--bg-deep, #0e0e0e)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"},"data-testid":"file-drop-confirm-paths",children:t.map(h=>e.jsx("li",{className:"truncate py-0.5",children:h},h))}),!r&&e.jsx("p",{className:"mb-3 text-xs",style:{color:"var(--text-dim)"},"data-testid":"file-drop-confirm-no-agent-hint",children:"Start or focus a session to hand the file to the agent."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},"data-testid":"file-drop-confirm-copy",children:a?"Copied":"Copy path"}),e.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},"data-testid":"file-drop-confirm-done",children:"Not now"}),e.jsx("button",{type:"button",onClick:d,disabled:!r,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #fff)",border:"1px solid transparent"},"data-testid":"file-drop-confirm-tell-agent",children:"Tell the agent"})]}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Escape closes · files stay in .codeyam/uploads/"})]})})}const oH=Object.freeze(Object.defineProperty({__proto__:null,FileDropConfirmModal:a_},Symbol.toStringTag,{value:"Module"}));let Ua=null;function RE(t){if(typeof t!="object"||t===null)return null;const n=t.buildCommitSha;return typeof n!="string"||n===""||n==="unknown"?null:n}async function EE(){try{const t=await fetch("/api/health");return t.ok?RE(await t.json()):null}catch{return null}}function ME(){const[t,n]=l.useState(null);return l.useEffect(()=>{let s=!0;return Ua||(Ua=EE()),Ua.then(r=>{s&&n(r)}),()=>{s=!1}},[]),{sha:t}}function IE(){var pc,mc,fc;fE();const{sha:t}=ME(),n=Nk(),{state:s,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,probeInFlight:u,probeAttempts:h,backendFieldAbsent:p,refresh:m}=fk(),{update:f}=iE(),{sessionInfo:g,refetch:b}=xl({pollIntervalMs:15e3}),x=(g==null?void 0:g.agentBrokerLive)??!1,y=X6(s,x),{activeTab:v,buildActivated:_,planActivated:j,navigateToTab:k,deactivateBuild:S}=Cl(n,y,s==="needs-login"&&!x),[w,C]=l.useState(!1),[P,T]=l.useState(!1),O=l.useCallback(()=>{C(!0),T(!1)},[]),{arm:N,navigateToTabUser:E}=lE(y,k,O),I=l.useCallback(()=>{T(!0),k("build")},[k]);l.useEffect(()=>{if(!P)return;const W=setTimeout(()=>T(!1),6e4);return()=>clearTimeout(W)},[P]);const ee=l.useCallback(()=>E("build"),[E]),[B,z]=l.useState(!1),[Y,te]=l.useState(!1),R=Ot(),[L,M]=l.useState(R),K=l.useRef(!1),ie=l.useCallback(()=>M(!0),[]),[$,V]=l.useState(R),[ae,ne]=l.useState(0),[me,q]=l.useState(0),[le,Pe]=l.useState(0),[Ce,F]=l.useState(0),[J,Z]=l.useState(0),[ue,ve]=l.useState(null),{showPostPushModal:fe,featureSummary:se,onFeatureCompleteCommand:Q,onAgentIdle:ze,onAgentActive:ge,dismissModal:Ae}=T6(),Te=l.useCallback(()=>{Ae(),fetch("/api/cycle-closed-ack",{method:"POST"}).catch(()=>{})},[Ae]),{showPlanCompleteModal:H,onPlanCompleteCommand:G,dismissPlanCompleteModal:be}=R6(),[de,je]=l.useState(!1),[Ne,Ee]=l.useState(!1),[Le,He]=l.useState(!1),[X,Oe]=l.useState(!1),[it,tt]=l.useState(!1),[qt,Ke]=l.useState(!1),kt=l.useCallback(()=>{He(!0)},[]),_e=l.useCallback(()=>{He(!1)},[]),{plans:ce,loading:U,error:Re,refetch:De}=ml(),{plans:qe}=Hy(),{reorderPlans:nt}=Zy(De),{launchPrompt:lt,launching:Fe,error:ct}=M6(),[Ie,$e]=l.useState(null),{stepState:D,refetch:st}=Is();P6({showPostPushModal:fe,stepState:D,dismissModal:Te}),O6({sessionInfo:g,stepState:D,showPostPushModal:fe,onFeatureCompleteCommand:Q});const Ve=l.useMemo(()=>A6(fe,D),[fe,D]),St=l.useRef(null),{leftWidth:Wt,handleMouseDown:Rt}=hE(St),fn=Rb(768),[Ln,ns]=l.useState("editor"),ma=l.useCallback(W=>{ns(W),W==="editor"&&(yt(),typeof window<"u"&&window.dispatchEvent(new Event("resize")))},[]),[Et,gn]=l.useState(!1),bt=v==="home";l.useEffect(()=>{!bt&&Et&&gn(!1)},[bt,Et]);const{entityLookup:Ds}=u6(),{groups:Ze,loading:Xt,refreshing:bn,currentRunner:xn,coverage:Dn,refresh:Fs}=JR(),{groups:ht,loading:Fn,reload:zs}=qR(),{routeEntities:$l,unsurfacedPages:o_,componentSurfaceReason:i_,loading:l_,refreshing:c_,error:d_}=UR(),{config:oe,apps:Gt,loading:$s,refetch:zn}=jt(),u_=Dv(),yn=l.useMemo(()=>D6(Gt,Ze,ht),[Gt,ht,Ze]),{saved:h_}=Eg(),p_=Mg({appStatsLength:yn.length,configLoading:$s,scenariosLoading:Fn,setupAnswersSaved:h_,hasStepState:!!D}),fa=bt&&!Et&&!p_,m_=fn||fa?((pc=St.current)==null?void 0:pc.clientWidth)??(typeof window<"u"?window.innerWidth:Wt):Wt,f_=l.useCallback(()=>{z(W=>!W)},[]),g_=l.useCallback(()=>{te(W=>!W)},[]),{selectedApp:vn,appRouteEntities:Bl,appTestGroups:b_,selectedEntityHash:x_,selectedRouteEntity:Hl,previewSlug:ss,setPreviewSlugExplicit:y_,selectApp:ga,deselectApp:ba,selectRoute:xa,selectEntity:v_,deselectRoute:j_}=l6(Gt,$l,ht,Ze,n,(oe==null?void 0:oe.defaultScreenSize)??null,$,K),{viewports:w_,resolvedViewport:rs,previewUrl:__,handleViewportChange:k_,handleCustomSizeChange:ya,showScenarioPreview:as,handlePreviewCommand:rt,setPreviewPath:va,previewSeeding:S_,previewSeedError:N_,previewSeedErrorKind:C_,retrySeed:T_,commandNonce:P_}=w6({apps:Gt,appRouteEntities:Bl,configLoaded:!$s,hydrated:L,port:(oe==null?void 0:oe.port)??5173,previewMedium:u_.kind,previewOrigin:qd(oe,vn),projectTitle:(oe==null?void 0:oe.projectTitle)??null,routeEntities:$l,screenSizes:(oe==null?void 0:oe.screenSizes)??{},defaultScreenSize:(oe==null?void 0:oe.defaultScreenSize)??null,scenarioGroups:ht,scenariosLoaded:!Fn,selectedApp:vn,selectedRouteEntity:Hl,previewSlug:ss,setPreviewSlug:y_});l.useEffect(()=>{bt&&Et&&rs.name==="Desktop"&&te(!0)},[bt,Et,rs.name]);const{isAgentBuilding:Ut,isAgentBuildingRef:ja,buildingScenarioSlug:wa,onAgentIdle:ql,onAgentActive:Wl,guardScenarioSelect:Gl,clearBuildingOverlay:Mt,forceIdle:Ul}=I6({onTransitionToLive:as}),{planActive:Vl,planIdle:Yl}=L6({chatOpen:de}),Bs=(g==null?void 0:g.resumeMode)==="resume"||(g==null?void 0:g.resumeMode)==="handoff",{launchPlan:os,launchingSlug:Hs,error:O_}=Yy({launchAnchored:Bs||!!(D!=null&&D.feature)}),{buildSessionLive:A_,agentActivelyBuilding:is,transitionBuildSessionLive:jn}=kE({isAgentBuilding:Ut,submittingBuildPrompt:Fe,launchingPlanSlug:Hs,sessionInfo:g,stepFeature:(D==null?void 0:D.feature)??null,refetchSessionInfo:b});l.useEffect(()=>{Ut&&g&&!g.hasSession&&!g.agentBrokerLive&&Ul()},[Ut,g,Ul]),l.useEffect(()=>{ua({hasActiveSession:Bs,isAgentBuilding:Ut,stepStateFeature:(D==null?void 0:D.feature)??null})},[Bs,Ut,D==null?void 0:D.feature]),l.useEffect(()=>{const W=oe==null?void 0:oe.projectTitle;document.title=typeof W=="string"&&W.length>0?`CodeYam: ${W}`:"CodeYam"},[oe==null?void 0:oe.projectTitle]);const R_=l.useCallback(()=>{ze(),ql()},[ze,ql]),E_=l.useCallback(()=>{ge(),Wl()},[ge,Wl]),Kl=(oe==null?void 0:oe.provider)??gk,Jl=Ue(Kl),{buildIdle:qs,agentBlocked:M_,bannerVisible:I_,notifSettings:Xl,handleSettingsChange:Ql,handleAgentIdle:L_,handleAgentBlocked:D_,handleAgentActive:F_,handleUserInput:z_,handleNavigateToTab:Zl,dismissIdleBanner:$_,clearIdleForStopBuilding:Ws}=wE({agentName:Jl,isBuildTabActive:v==="build",isAgentBuilding:Ut,buildSessionLive:A_,featureCompleteKey:le,navigateToTab:E,onAgentIdleImmediate:R_,onAgentActiveImmediate:E_}),ec=l.useMemo(()=>NE(D==null?void 0:D.slug,qs),[D==null?void 0:D.slug,qs]),tc=D?Gg(D.step,D.mode):null,nc=l.useMemo(()=>z6(D==null?void 0:D.step,D==null?void 0:D.mode),[D==null?void 0:D.step,D==null?void 0:D.mode]),sc=D?$6(D.step,D.mode):null,B_=((mc=qe[0])==null?void 0:mc.title)??null,rc=l.useMemo(()=>{const W=Date.parse((D==null?void 0:D.startedAt)??"");return Number.isNaN(W)?null:W},[D==null?void 0:D.startedAt]),H_=l.useMemo(()=>B6(ht.flatMap(W=>W.scenarios),rc),[ht,rc]),{claimsBySlug:q_,staleFetch:W_,annotationsBySlug:G_,dependenciesBySlug:U_,showAuthors:V_,requestRun:Y_,gateModals:K_}=E6({plans:ce,completedPlans:qe,isAgentBuilding:is,onLaunch:W=>{var It;const We=((It=ce.find(N1=>N1.slug===W))==null?void 0:It.title)??W;os(W,We)}}),ac=l.useCallback(W=>{$e(null),!Gl(W)&&(as(W),bt&&gn(!0))},[Gl,as,bt]),J_=l.useCallback(W=>{const We=Q6(W.name,ht),It=sE({shot:{name:W.name,screenshotPath:W.screenshotPath},isLatest:W.isLatest,liveScenario:We,isAgentBuilding:Ut});if(It.kind==="live"){$e(null),as(It.slug);return}$e({screenshotPath:It.screenshotPath,scenarioName:It.scenarioName,heading:It.heading,subtext:It.subtext})},[Ut,ht,as]),X_=l.useCallback(()=>{$e(null)},[]),Vt=l.useMemo(()=>Uo(wa,ht),[wa,ht]),Q_=((fc=Vt==null?void 0:Vt.screenshotPaths)==null?void 0:fc[0])??null,Z_=(Vt==null?void 0:Vt.name)??null,e1=(Vt==null?void 0:Vt.description)??null,oc=l.useCallback(()=>k("plan"),[k]),xt=aE(oc),[t1,ic]=l.useState(!1),n1=l.useCallback(W=>{switch(W.type){case"preview":("scenarioSlug"in W||"scenarioId"in W)&&zs(),rt(W);break;case"showResults":Mt(),zs(),ne(We=>We+1),(D==null?void 0:D.mode)==="backend"&&rt({path:"/results",dimension:"Desktop"});break;case"hideResults":q(We=>We+1);break;case"featureComplete":Mt(),Q({title:W.title,summary:W.summary,followUps:W.followUps,severeWarnings:W.severeWarnings,minorWarnings:W.minorWarnings}),Pe(We=>We+1),zn(),st(),Jd({isAgentBuilding:ja.current,trigger:"feature-complete",transitionBuildSessionLive:jn});break;case"planComplete":G(),Z(We=>We+1),zn(),Jd({isAgentBuilding:ja.current,trigger:"plan-complete",transitionBuildSessionLive:jn});break;case"launchPlan":os(W.slug,W.title),F(We=>We+1);break;case"buildActivity":W.activity==="prototype"?ic(!0):W.activity==="menu"&&ic(!1),xt.applyCommand(W.activity);break;case"requestCredential":ve({serviceName:W.serviceName,envVar:W.envVar,topic:W.topic,docsUrl:W.docsUrl});break}},[Mt,rt,ja,os,Q,G,zn,st,zs,D,jn]);d6(n1,l.useCallback(()=>{window.location.reload()},[]));const Gs=(D==null?void 0:D.slug)==="ui-confirm-plan"||(D==null?void 0:D.slug)==="backend-confirm-plan",_a=l.useRef(null);l.useEffect(()=>{if(!D||!Gs){_a.current=null;return}_a.current!==D.step&&(_a.current=D.step,rt({path:"/plan-preview",dimension:"Desktop"}))},[D,Gs,rt]);const ka=l.useRef(null);l.useEffect(()=>{if(!D||D.mode!=="backend"||D.step<2||Gs){ka.current=null;return}ka.current!==D.step&&(ka.current=D.step,rt({path:"/results",dimension:"Desktop"}))},[D,Gs,rt]);const Sa=l.useRef(!1);l.useEffect(()=>{(D==null?void 0:D.slug)==="ui-confirm-plan"?Sa.current=!0:Sa.current&&(Sa.current=!1,va(null))},[D,va]);const s1=l.useCallback(()=>{Te(),yt()},[Te]),r1=l.useCallback(async()=>{window.dispatchEvent(new CustomEvent("build-session-stopped")),await L3(),Te(),k("home"),S(),jn(!1,"stop-building"),Mt(),Ws(),C(!1),b()},[Te,k,S,jn,Mt,Ws,b]),a1=l.useCallback(async()=>{Ke(!0),window.dispatchEvent(new CustomEvent("build-session-stopped")),await D3(),Ke(!1),tt(!1),k("home"),S(),jn(!1,"reset-everything"),Mt(),Ws(),C(!1),b()},[k,S,jn,Mt,Ws,b]),o1=l.useCallback(()=>{je(!0),Kd(),be(),yt()},[be]),i1=l.useCallback(()=>{je(!0),be(),yt()},[be]),l1=l.useCallback(()=>{be(),Kd().finally(()=>{je(!1),gE()})},[be]),c1=l.useCallback(()=>{Ee(!0)},[]),d1=l.useCallback(()=>{Ee(!1)},[]),u1=l.useCallback(async(W,We)=>{await os(W,We)&&(Ee(!1),C(!0),xt.startSession(),Te(),b())},[os,Te,b,xt]),h1=l.useCallback(async W=>{await lt(W)&&(C(!0),Te(),b())},[lt,b,Te]),lc={hasActiveSession:Bs,isAgentBuilding:Ut,showPostPushModal:fe,launchingPlanSlug:Hs,submittingBuildPrompt:Fe,stepStateFeature:(D==null?void 0:D.feature)??null,buildLaunchModalDismissed:w,buildActivityInFlight:xt.activity!=="menu",buildActivityMinimized:xt.minimized,buildHandoffPending:P},p1=Jw(lc),cc=rE({activeTab:v,...lc}),m1=cc||Ne;l.useEffect(()=>{v==="build"&&b()},[v,b]),l.useEffect(()=>{v==="home"&&(zn(),m())},[v,zn,m]);const f1=l.useCallback(async(W,We)=>{Mt(),rt(J6(W,We))},[Mt,rt]),g1=l.useCallback(W=>{rt({...W.scenarioSlug?{scenarioSlug:W.scenarioSlug}:{},...W.path?{path:W.path}:{},...W.dimension?{dimension:W.dimension}:{}})},[rt]),{requestRestore:b1,onAdoptSettledEmpty:dc}=S6({restoredRef:K,initiallySettled:R,apply:g1}),uc=l.useCallback(W=>{C6(W,{handlePreviewCommand:rt,handleCustomSizeChange:ya})},[ya,rt]),x1=l.useCallback(()=>{dc(),V(!0)},[dc]);_6({isInIframe:R,scenariosLoaded:!Fn,restoredRef:K,onAdopt:uc,onHydrated:ie,onSettledEmpty:x1});const y1=l.useCallback(W=>{rt({scenarioSlug:W}),gn(!0)},[rt]);N6({scenariosLoaded:!Fn,restoredRef:K,apply:y1,onSettled:()=>V(!0)}),k6({isInIframe:R,onConverge:uc});const v1=l.useMemo(()=>({apps:Gt,isSingleApp:Gt.length===1,onSelectApps:ba,onSelectApp:ga,onSelectRoute:xa}),[Gt,ba,ga,xa]),j1=l.useMemo(()=>vn?yn.find(W=>W.app.dir===vn.dir)??null:null,[yn,vn]),w1=e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"12px 28px 0"},children:e.jsx(kl,{staleness:null,backendOutOfDate:p})}),e.jsx("div",{style:{padding:"12px 28px 0"},children:e.jsx(Qw,{update:f})}),e.jsx(Xw,{state:s,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,probeInFlight:u,probeAttempts:h,backendOutOfDate:p,sessionOngoing:x,onAuthenticated:m,onAuthorized:ee}),yn.length>0&&e.jsx("div",{style:{padding:"10px 28px 0"},children:e.jsx("div",{style:{width:"100%",maxWidth:1e3,marginInline:"auto"},children:e.jsx(Rg,{settings:Xl,onChange:Ql,providerLabel:Jl})})}),e.jsx(My,{selectedApp:vn,projectTitle:(oe==null?void 0:oe.projectTitle)??null,admin:(oe==null?void 0:oe.admin)??!1,isBuilding:is,buildingLabel:(D==null?void 0:D.feature)??null,buildingStepLabel:tc,buildingStepPosition:sc,buildingStatus:ec,buildingProgress:nc,lastBuiltLabel:B_,buildingThumbnailPath:H_,plans:ce,plansLoading:U,plansError:Re,onRunPlan:Y_,launchingSlug:Hs,planDepAnnotationsBySlug:G_,planDependenciesBySlug:U_,planClaimsBySlug:q_,planStaleFetch:W_,showPlanAuthors:V_,onNavigateToPlan:()=>k("plan"),onNavigateToBuild:()=>E("build"),onResetBuild:()=>tt(!0),onBackToProjects:Gt.length>1?ba:void 0,launcherUrl:(oe==null?void 0:oe.launcherUrl)??null,projectCount:(oe==null?void 0:oe.projectCount)??0,onOpenSetupBrowser:oe!=null&&oe.setupBrowserEnabled?()=>rt({path:"/setup-browser",dimension:"Desktop"}):void 0,appDetailProps:{navContext:v1,routeEntities:Bl,unsurfacedPages:o_,componentSurfaceReason:i_,routesLoading:l_,routesRefreshing:c_,routesError:d_,selectedEntityHash:x_,selectedRouteEntity:Hl,testGroups:b_,selectedSlug:ss,entityLookup:Ds,allScenarios:ht.flatMap(W=>W.scenarios),onSelectScenario:ac,onSelectRoute:xa,onSelectEntity:v_,onBackToRoutes:j_,onScenariosChanged:zs,coverage:Dn,showProjectBand:Gt.length===1,stats:j1,testsLoading:Xt,testsRefreshing:bn,onRunTests:Fs,currentRunner:xn},appOverviewProps:{projectTitle:(oe==null?void 0:oe.projectTitle)??"Project",projectDescription:(oe==null?void 0:oe.projectDescription)??null,stats:yn,coverage:Dn,onSelectApp:ga,configLoading:$s,scenariosLoading:Fn,testsLoading:Xt,testsRefreshing:bn,onRunTests:Fs,currentRunner:xn,stepState:D,onPreviewUrl:va,onComplete:async()=>{await zn(),console.info("[EditorShell] questionnaire complete; arming pending build-nav",{providerAuthState:s,buildBlocked:y}),N()},onOpenBuildTab:()=>E("build"),isBuilding:is,buildingLabel:(D==null?void 0:D.feature)??null,buildingStepLabel:tc,buildingStepPosition:sc,buildingStatus:ec,buildingProgress:nc,onResetBuild:()=>tt(!0)}})]}),_1=yn.some(W=>K6(W.app.type)),k1=ht.reduce((W,We)=>W+We.scenarios.length,0),hc=!!D&&!Fn&&k1===0,S1=$w(),wn=AE();return e.jsx(bk,{children:e.jsxs(xk,{fallbackUpload:wn.uploadFiles,children:[e.jsx(Fy,{splitRef:St,isCollapsed:B,hidePreview:fa,onHomeLivePageBack:bt&&Et?()=>gn(!1):void 0,onResizeStart:Rt,isNarrow:fn,mobilePane:Ln,onMobilePaneChange:ma,isAgentBuilding:is,buildIdle:qs,leftPane:e.jsx(Lv,{activeTab:v,onSendTranscript:kt,appTabContent:w1,awaitingPlanLaunchChoice:m1,buildActivated:_,planActivated:j,buildIdle:qs,agentBlocked:M_,isAgentBuilding:is,planActive:Vl,planIdle:Yl,bannerVisible:I_,onDismissIdleBanner:$_,hideResultsCommandKey:me,leftWidth:m_,fullWidth:fn||fa,navigateToTab:Zl,onAgentActive:F_,onAgentIdle:L_,onAgentBlocked:D_,onUserInput:z_,notifSettings:Xl,onSettingsChange:Ql,provider:Kl,onRestorePreview:b1,onResultsScenarioSelect:f1,previewSlug:ss,featureCycleComplete:Ve,featureSummary:se,onContinueInSession:s1,onStopBuilding:r1,showResultsCommandKey:ae,planChatOpen:de,onPlanChatOpenChange:je,showPlanCompleteModal:H,onCreateNewPlan:o1,onContinueSession:i1,onViewPlans:l1,pendingPlans:ce,onSelectPlan:c1,selectPlanOpen:Ne,onPickPlan:u1,onCancelSelectPlan:d1,launchingPlanSlug:Hs,planLaunchError:O_,prototypeLaunchSignal:Ce,planCompleteSignal:J,showBuildLaunchModal:cc,buildLaunchGateArmed:p1,buildActivity:xt.activity,buildActivityMinimized:xt.minimized,chatEscalatedToPrototype:t1,onChooseActivity:xt.chooseActivity,onNavigateToPlanTab:oc,onActivityDone:xt.finishActivity,onPrototypeLaunched:xt.startSession,onMinimizeActivityModal:xt.hasLiveActivity?xt.minimize:void 0,onReopenActivityModal:xt.reopen,onSubmitBuildPrompt:h1,submittingBuildPrompt:Fe,buildPromptError:ct,pendingPlansLoading:U,pendingPlansError:Re,onReorderPlans:nt,buildDisabled:y,onPreviewScreenshot:J_,projectTitle:(oe==null?void 0:oe.projectTitle)??null}),previewPane:e.jsx(Hw,{emptyStateMessage:V6({configLoading:$s,hasNoApps:yn.length===0,hasStepState:!!D,hasPreviewableApp:_1,setupInProgress:hc,hasCaptureFrame:S1.available}),projectSetupInProgress:hc,previewSlug:ss,previewUrl:__,viewports:w_,activeViewport:rs.name,onViewportChange:k_,isCollapsed:B,onToggleCollapsed:f_,isNarrow:fn,onBack:bt&&Et?()=>gn(!1):void 0,onPlanChange:bt&&Et?()=>Zl("plan"):void 0,isFilled:Y,onToggleFilled:g_,currentWidth:rs.width,currentHeight:rs.height,onCustomSizeChange:ya,buildingScenarioSlug:wa,buildingScreenshotPath:Q_,buildingScenarioName:Z_,buildingScenarioDescription:e1,onDismissBuildingOverlay:Mt,historicalScreenshotPath:(Ie==null?void 0:Ie.screenshotPath)??null,historicalScenarioName:(Ie==null?void 0:Ie.scenarioName)??null,historicalHeading:(Ie==null?void 0:Ie.heading)??null,historicalSubtext:(Ie==null?void 0:Ie.subtext)??null,onDismissHistoricalPreview:X_,previewSeeding:S_,previewSeedError:N_,previewSeedErrorKind:C_,onRetrySeed:T_,currentScenario:Uo(ss,ht),scenarioGroups:ht,onShowScenarioPreview:ac,commandNonce:P_,previewOrigin:qd(oe,vn),onDesignConfirmed:I})}),Le?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsx(Zw,{featureName:(D==null?void 0:D.feature)??null,onClose:_e})}):null,e.jsx(n_,{isOpen:X,onClose:()=>Oe(!1)}),e.jsx(e_,{sha:t,onClick:()=>Oe(!0)}),e.jsx(s_,{visible:wn.dragActive}),wn.error?e.jsx(r_,{message:wn.error}):null,wn.pendingPaths?e.jsx(a_,{paths:wn.pendingPaths,onClose:wn.clearPending}):null,it?e.jsx(qw,{busy:qt,onCancel:()=>tt(!1),onConfirm:()=>void a1(),planSessionActive:Vl||Yl}):null,ue?e.jsx(Br,{target:ue,onStored:()=>ve(null),onClose:()=>ve(null)}):null,K_]})})}const iH=Object.freeze(Object.defineProperty({__proto__:null,EditorShell:IE},Symbol.toStringTag,{value:"Module"}));export{iu as $,Ge as A,Bi as B,Wr as C,dj as D,SN as E,a_ as F,Vn as G,xe as H,qN as I,zm as J,zi as K,nn as L,Zp as M,yr as N,$i as O,om as P,tb as Q,Ku as R,Mi as S,Ur as T,Jp as U,ye as V,nu as W,VN as X,su as Y,au as Z,ou as _,Vr as a,Nh as a$,lu as a0,cu as a1,du as a2,uu as a3,hu as a4,Ka as a5,fu as a6,Pu as a7,gu as a8,yu as a9,Xa as aA,Ju as aB,Yu as aC,th as aD,nh as aE,fi as aF,Ir as aG,gi as aH,sh as aI,Rr as aJ,Ts as aK,rh as aL,ah as aM,uh as aN,Qa as aO,mi as aP,Lr as aQ,xh as aR,wh as aS,vi as aT,kh as aU,pi as aV,Xu as aW,Qu as aX,Zu as aY,eh as aZ,Sh as a_,vu as aa,bu as ab,Tu as ac,Nu as ad,Su as ae,ku as af,_u as ag,wu as ah,ju as ai,sr as aj,Cu as ak,Ja as al,br as am,Au as an,Ru as ao,Eu as ap,Mu as aq,Iu as ar,Lu as as,Hu as at,rr as au,qu as av,Wu as aw,Gu as ax,Uu as ay,Vu as az,dr as b,Zj as b$,Ch as b0,Uh as b1,Yh as b2,Yp as b3,Wh as b4,qh as b5,Pi as b6,ro as b7,Qt as b8,lr as b9,ps as bA,Cs as bB,Xx as bC,ms as bD,A as bE,mv as bF,bl as bG,W0 as bH,$y as bI,Lo as bJ,Hj as bK,Po as bL,bj as bM,Cj as bN,Nj as bO,Sj as bP,kj as bQ,wj as bR,El as bS,Oj as bT,Py as bU,Qx as bV,Ao as bW,Ro as bX,Yn as bY,Zx as bZ,q0 as b_,Sn as ba,kn as bb,_n as bc,Zt as bd,Ct as be,rm as bf,nm as bg,no as bh,hp as bi,am as bj,Oi as bk,Yx as bl,vt as bm,Lw as bn,jw as bo,af as bp,rf as bq,sf as br,zf as bs,an as bt,Yt as bu,pe as bv,we as bw,cn as bx,Qw as by,kl as bz,v8 as c,iw as c$,uj as c0,hn as c1,Kx as c2,jj as c3,vj as c4,So as c5,mn as c6,Jx as c7,ji as c8,ot as c9,Yf as cA,Vf as cB,Gf as cC,Wf as cD,qf as cE,Vi as cF,ln as cG,Eh as cH,us as cI,N0 as cJ,Be as cK,Tn as cL,Gj as cM,Ah as cN,Jj as cO,Kj as cP,Qe as cQ,Tt as cR,Jt as cS,mt as cT,Li as cU,Mh as cV,Rh as cW,k0 as cX,et as cY,rw as cZ,sw as c_,Ti as ca,un as cb,Kp as cc,D0 as cd,Dr as ce,Lj as cf,Ij as cg,Un as ch,sa as ci,ut as cj,Fr as ck,As as cl,nf as cm,Ii as cn,Xe as co,he as cp,a0 as cq,Vj as cr,Oh as cs,qr as ct,NN as cu,Pj as cv,Jn as cw,Wj as cx,Ph as cy,Hf as cz,Bf as d,Qg as d$,aw as d0,nw as d1,lw as d2,P0 as d3,tw as d4,T0 as d5,Rw as d6,Aw as d7,ry as d8,ep as d9,Yg as dA,Hg as dB,Jg as dC,Kg as dD,Bg as dE,ch as dF,Qi as dG,sp as dH,Ap as dI,so as dJ,Op as dK,wi as dL,e_ as dM,Pr as dN,A0 as dO,E0 as dP,M0 as dQ,I0 as dR,R0 as dS,L0 as dT,Ow as dU,O0 as dV,H0 as dW,z0 as dX,F0 as dY,$0 as dZ,B0 as d_,tp as da,Zh as db,Jh as dc,Qh as dd,At as de,Vp as df,Ry as dg,ii as dh,Cy as di,Ty as dj,Sy as dk,_y as dl,da as dm,wy as dn,Bh as dp,_h as dq,$p as dr,Bp as ds,zh as dt,Fh as du,Gh as dv,Hh as dw,$h as dx,Up as dy,Xg as dz,Sm as e,Nw as e$,$g as e0,zg as e1,Dg as e2,Lg as e3,Ig as e4,Fg as e5,um as e6,cm as e7,im as e8,oo as e9,jl as eA,Xv as eB,Qv as eC,$v as eD,ej as eE,ey as eF,Wx as eG,Vx as eH,u0 as eI,Ll as eJ,h0 as eK,m0 as eL,c0 as eM,l0 as eN,i0 as eO,zo as eP,b0 as eQ,g0 as eR,nj as eS,f0 as eT,d0 as eU,p0 as eV,x0 as eW,Ib as eX,Mb as eY,Tw as eZ,Pw as e_,lm as ea,by as eb,dy as ec,uy as ed,hy as ee,gy as ef,py as eg,my as eh,xy as ei,jy as ej,fy as ek,yy as el,vy as em,Ls as en,Hv as eo,Zv as ep,Jv as eq,qv as er,Wv as es,Uv as et,Vv as eu,Co as ev,Pl as ew,Yv as ex,Kv as ey,zv as ez,km as f,wv as f$,Cw as f0,t_ as f1,n_ as f2,Fb as f3,Mv as f4,Ev as f5,Iv as f6,r_ as f7,s_ as f8,sl as f9,Xy as fA,Ky as fB,dh as fC,Ex as fD,Px as fE,fl as fF,Tx as fG,Mx as fH,Ax as fI,Ox as fJ,Rx as fK,ih as fL,gl as fM,pl as fN,sx as fO,tx as fP,rl as fQ,xo as fR,Zb as fS,rx as fT,sv as fU,nv as fV,tv as fW,ev as fX,fv as fY,Tl as fZ,vv as f_,Xb as fa,Rv as fb,Bb as fc,Vb as fd,Hb as fe,Ov as ff,Pv as fg,Tv as fh,Nv as fi,Cv as fj,Av as fk,Dt as fl,uv as fm,hv as fn,pv as fo,Ix as fp,iv as fq,cv as fr,oi as fs,ov as ft,lv as fu,dv as fv,rv as fw,av as fx,ca as fy,Jy as fz,cr as g,_w as g$,yv as g0,_v as g1,r0 as g2,s0 as g3,or as g4,Kh as g5,op as g6,rp as g7,ip as g8,IE as g9,Cp as gA,Pp as gB,xp as gC,jp as gD,vp as gE,bp as gF,yp as gG,mp as gH,pp as gI,Ai as gJ,lo as gK,xm as gL,ym as gM,mm as gN,wm as gO,bm as gP,pm as gQ,to as gR,ar as gS,Ni as gT,t0 as gU,Or as gV,zw as gW,qo as gX,Iw as gY,cw as gZ,ww as g_,Do as ga,n0 as gb,dm as gc,wp as gd,dp as ge,up as gf,cp as gg,bv as gh,Bx as gi,Hx as gj,$x as gk,np as gl,ki as gm,Dh as gn,Rp as go,Ep as gp,Ip as gq,Lp as gr,Dp as gs,Fp as gt,zp as gu,Si as gv,Tp as gw,Np as gx,Sp as gy,kp as gz,Pa as h,_f as h$,xw as h0,bw as h1,yw as h2,gw as h3,vw as h4,qw as h5,Qj as h6,Sw as h7,kw as h8,v0 as h9,pb as hA,ub as hB,bo as hC,mb as hD,ob as hE,ab as hF,ib as hG,cb as hH,db as hI,rb as hJ,bb as hK,gb as hL,xv as hM,fg as hN,mg as hO,pg as hP,hg as hQ,ug as hR,dg as hS,cg as hT,lg as hU,ig as hV,Tf as hW,Cf as hX,Nf as hY,Sf as hZ,kf as h_,y0 as ha,w0 as hb,tj as hc,C0 as hd,_0 as he,fw as hf,zx as hg,Ly as hh,sb as hi,nb as hj,e0 as hk,Il as hl,Xj as hm,Bj as hn,Yj as ho,Uj as hp,qj as hq,Dj as hr,Rj as hs,zj as ht,Ml as hu,$j as hv,gj as hw,eb as hx,go as hy,fb as hz,Lb as i,bg as i$,wf as i0,jf as i1,vf as i2,yf as i3,xf as i4,bf as i5,gf as i6,mf as i7,pf as i8,hf as i9,sg as iA,ng as iB,tg as iC,po as iD,eg as iE,Qf as iF,Xf as iG,ta as iH,Jf as iI,Kf as iJ,mu as iK,Hp as iL,$f as iM,Tm as iN,Cm as iO,Mm as iP,Im as iQ,Lm as iR,em as iS,ao as iT,tm as iU,sm as iV,Nm as iW,fo as iX,wg as iY,Rg as iZ,Pg as i_,uf as ia,df as ib,lf as ic,of as id,cf as ie,tf as ig,ef as ih,Zm as ii,Jm as ij,Ym as ik,Df as il,Lf as im,If as io,Mf as ip,Ef as iq,Of as ir,Pf as is,Dm as it,ho as iu,Ff as iv,uo as iw,og as ix,ag as iy,rg as iz,zb as j,ij as j$,mo as j0,xg as j1,yg as j2,vg as j3,na as j4,jg as j5,Gr as j6,Fx as j7,ay as j8,Dy as j9,Q0 as jA,G0 as jB,$o as jC,$r as jD,ap as jE,Ri as jF,$b as jG,Ab as jH,Lx as jI,Nb as jJ,vb as jK,ny as jL,yb as jM,qx as jN,xb as jO,_m as jP,hm as jQ,hw as jR,Gp as jS,Me as jT,vh as jU,xi as jV,yi as jW,Em as jX,Br as jY,Xw as jZ,lj as j_,kv as ja,gv as jb,Lv as jc,Fy as jd,Iy as je,My as jf,kb as jg,ur as jh,Sb as ji,_b as jj,wb as jk,jb as jl,Ob as jm,oy as jn,ly as jo,iy as jp,sy as jq,Kn as jr,X0 as js,Z0 as jt,K0 as ju,Y0 as jv,V0 as jw,ew as jx,J0 as jy,U0 as jz,Tg as k,fL as k$,cj as k0,aj as k1,rj as k2,sj as k3,Kr as k4,Gi as k5,Xm as k6,Qm as k7,Km as k8,Wi as k9,W8 as kA,e8 as kB,kz as kC,I$ as kD,dL as kE,ZB as kF,C7 as kG,T7 as kH,k7 as kI,S7 as kJ,_7 as kK,N7 as kL,p9 as kM,c8 as kN,nD as kO,h7 as kP,X7 as kQ,p7 as kR,n7 as kS,s7 as kT,t7 as kU,r8 as kV,h9 as kW,u9 as kX,K8 as kY,w8 as kZ,XF as k_,ea as ka,Zr as kb,Qr as kc,Hm as kd,Xr as ke,Bm as kf,Hi as kg,Ft as kh,Jr as ki,Wm as kj,vr as kk,qi as kl,co as km,Vm as kn,Gm as ko,qm as kp,Um as kq,gr as kr,Fw as ks,Bw as kt,I8 as ku,q8 as kv,$7 as kw,F8 as kx,oI as ky,nz as kz,Hw as l,HI as l$,JL as l0,d9 as l1,tD as l2,eD as l3,qL as l4,H9 as l5,q9 as l6,M$ as l7,R$ as l8,E$ as l9,H7 as lA,$8 as lB,z8 as lC,jI as lD,z7 as lE,zB as lF,FB as lG,N8 as lH,sz as lI,G9 as lJ,V9 as lK,dI as lL,AF as lM,eH as lN,yL as lO,mz as lP,ez as lQ,HB as lR,BB as lS,kL as lT,TI as lU,GE as lV,e7 as lW,j8 as lX,BI as lY,zI as lZ,$I as l_,_9 as la,f9 as lb,f$ as lc,PL as ld,OL as le,BD as lf,$D as lg,L9 as lh,zM as li,FM as lj,YL as lk,KB as ll,GB as lm,WB as ln,VB as lo,eL as lp,Q8 as lq,Z8 as lr,pL as ls,RL as lt,B7 as lu,DB as lv,LB as lw,H8 as lx,B8 as ly,q7 as lz,_p as m,cL as m$,WI as m0,qI as m1,J7 as m2,bI as m3,K7 as m4,ZI as m5,zz as m6,gI as m7,s8 as m8,HL as m9,i7 as mA,c7 as mB,_8 as mC,Y7 as mD,Q7 as mE,Z7 as mF,LM as mG,XB as mH,vz as mI,B9 as mJ,hL as mK,k$ as mL,oL as mM,YF as mN,V8 as mO,L8 as mP,vL as mQ,sH as mR,nH as mS,D9 as mT,MD as mU,DD as mV,LD as mW,ID as mX,ED as mY,sD as mZ,tL as m_,A8 as ma,Oz as mb,RI as mc,PI as md,UI as me,GI as mf,EI as mg,j7 as mh,w7 as mi,v7 as mj,_I as mk,kI as ml,NI as mm,P7 as mn,CI as mo,SI as mp,g7 as mq,f7 as mr,m7 as ms,XI as mt,x7 as mu,b7 as mv,y7 as mw,l7 as mx,u7 as my,d7 as mz,lp as n,F$ as n$,tM as n0,lI as n1,QB as n2,S9 as n3,w9 as n4,j9 as n5,$9 as n6,RB as n7,EB as n8,MB as n9,KF as nA,rI as nB,XM as nC,MF as nD,EF as nE,nI as nF,tI as nG,RF as nH,KM as nI,UM as nJ,$M as nK,ZM as nL,E9 as nM,T9 as nN,R9 as nO,C9 as nP,M9 as nQ,O9 as nR,P9 as nS,JM as nT,A9 as nU,MM as nV,sI as nW,eI as nX,GM as nY,I9 as nZ,z$ as n_,IB as na,AB as nb,OB as nc,PB as nd,CB as ne,TB as nf,B$ as ng,DM as nh,G$ as ni,t8 as nj,aB as nk,JB as nl,q$ as nm,H$ as nn,SB as no,Y$ as np,V$ as nq,J$ as nr,X$ as ns,K$ as nt,U$ as nu,$$ as nv,IM as nw,NB as nx,AL as ny,IF as nz,Ng as o,d$ as o$,D$ as o0,LF as o1,VM as o2,N9 as o3,YM as o4,AM as o5,EM as o6,RM as o7,OM as o8,pz as o9,WD as oA,KD as oB,GD as oC,UD as oD,VD as oE,VL as oF,YD as oG,xD as oH,bD as oI,gD as oJ,jM as oK,r7 as oL,YB as oM,JD as oN,L$ as oO,TM as oP,wI as oQ,y$ as oR,xz as oS,V7 as oT,n$ as oU,m$ as oV,c$ as oW,p$ as oX,h$ as oY,u$ as oZ,n8 as o_,hz as oa,OF as ob,k9 as oc,DF as od,oM as oe,GL as of,iL as og,Lz as oh,BM as oi,Iz as oj,Y8 as ok,CF as ol,O$ as om,A$ as on,T$ as oo,N$ as op,C$ as oq,S$ as or,P$ as os,cF as ot,_$ as ou,pB as ov,jD as ow,qD as ox,HD as oy,zD as oz,Ag as p,_B as p$,a$ as p0,o$ as p1,r$ as p2,e$ as p3,Zz as p4,Xz as p5,Uz as p6,Jz as p7,Yz as p8,Vz as p9,JE as pA,YE as pB,VE as pC,cM as pD,lM as pE,UE as pF,eM as pG,xM as pH,KL as pI,TL as pJ,MI as pK,kB as pL,R8 as pM,E8 as pN,M8 as pO,X8 as pP,QF as pQ,O8 as pR,o7 as pS,a7 as pT,G7 as pU,uL as pV,vB as pW,yB as pX,wB as pY,jB as pZ,xB as p_,qz as pa,Qz as pb,s$ as pc,t$ as pd,i$ as pe,l$ as pf,Hz as pg,c9 as ph,QL as pi,TF as pj,Y9 as pk,sM as pl,aM as pm,rM as pn,iM as po,uM as pp,dM as pq,fM as pr,mM as ps,bM as pt,hM as pu,pM as pv,gM as pw,_F as px,KE as py,kF as pz,Ei as q,uI as q$,bB as q0,$F as q1,QM as q2,zF as q3,aD as q4,W$ as q5,fD as q6,eF as q7,vI as q8,ML as q9,aH as qA,rH as qB,Z9 as qC,U9 as qD,fI as qE,rL as qF,Kz as qG,y9 as qH,w$ as qI,U7 as qJ,oH as qK,z9 as qL,_M as qM,vM as qN,yM as qO,wM as qP,cz as qQ,yI as qR,A7 as qS,pI as qT,hI as qU,I7 as qV,E7 as qW,R7 as qX,iI as qY,nM as qZ,mI as q_,BL as qa,FL as qb,IL as qc,$L as qd,zL as qe,DL as qf,LL as qg,vF as qh,jF as qi,bF as qj,k8 as qk,yF as ql,wF as qm,gF as qn,D7 as qo,F7 as qp,xF as qq,RD as qr,pD as qs,dD as qt,cD as qu,uD as qv,hD as qw,tz as qx,AI as qy,OI as qz,Rn as r,nB as r$,UL as r0,XL as r1,WL as r2,L7 as r3,gL as r4,Q9 as r5,FI as r6,DI as r7,JI as r8,VI as r9,ZE as rA,g$ as rB,b$ as rC,Bz as rD,$z as rE,Mz as rF,FF as rG,wL as rH,uB as rI,gB as rJ,mD as rK,iB as rL,hB as rM,lB as rN,mB as rO,fB as rP,dB as rQ,cB as rR,_L as rS,sL as rT,FD as rU,nL as rV,Ez as rW,rD as rX,eB as rY,Z$ as rZ,tB as r_,QI as ra,KI as rb,U8 as rc,rz as rd,JF as re,fz as rf,PF as rg,SF as rh,NF as ri,iH as rj,s9 as rk,r9 as rl,n9 as rm,t9 as rn,e9 as ro,a9 as rp,tF as rq,j$ as rr,J9 as rs,UB as rt,rB as ru,sB as rv,ZL as rw,P8 as rx,nF as ry,x$ as rz,Cg as s,g9 as s$,mF as s0,pF as s1,uF as s2,hF as s3,dF as s4,fF as s5,iF as s6,lF as s7,aF as s8,rF as s9,qM as sA,ZF as sB,jL as sC,aI as sD,Sz as sE,CD as sF,oB as sG,AD as sH,ND as sI,PD as sJ,TD as sK,m9 as sL,l9 as sM,F9 as sN,o9 as sO,ZD as sP,K9 as sQ,QD as sR,WE as sS,W9 as sT,X9 as sU,tH as sV,OD as sW,Pz as sX,qB as sY,Tz as sZ,v9 as s_,oF as sa,sF as sb,h8 as sc,NL as sd,WM as se,EL as sf,C8 as sg,T8 as sh,xI as si,VF as sj,UF as sk,GF as sl,WF as sm,HF as sn,QE as so,qF as sp,XE as sq,BF as sr,lD as ss,lL as st,Gz as su,Wz as sv,W7 as sw,v$ as sx,$B as sy,mL as sz,gp as t,G8 as t$,b9 as t0,uz as t1,lz as t2,iz as t3,dz as t4,oz as t5,az as t6,YI as t7,i9 as t8,wz as t9,vD as tA,yD as tB,wD as tC,XD as tD,p8 as tE,LI as tF,II as tG,O7 as tH,y8 as tI,d8 as tJ,l8 as tK,o8 as tL,u8 as tM,f8 as tN,cI as tO,bL as tP,SL as tQ,SD as tR,aL as tS,J8 as tT,CM as tU,NM as tV,SM as tW,kM as tX,S8 as tY,x9 as tZ,Q$ as t_,_z as ta,Cz as tb,Nz as tc,yz as td,jz as te,CL as tf,Rz as tg,Az as th,bz as ti,gz as tj,xL as tk,Fz as tl,Dz as tm,PM as tn,HM as to,i8 as tp,a8 as tq,m8 as tr,b8 as ts,x8 as tt,g8 as tu,M7 as tv,iD as tw,oD as tx,kD as ty,_D as tz,Zw as u,D8 as u0,Yr as u1,Os as v,Pn as w,WN as x,GN as y,UN as z};
|