@codeyam-editor/codeyam-editor 0.1.14 → 0.1.15
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/agent-cli-install.js +102 -0
- package/npm/cloud.js +50 -53
- package/npm/editor.js +23 -0
- package/npm/fleet-add-failure.js +53 -2
- package/npm/fleet-auth.js +17 -1
- package/npm/launch-config.js +20 -3
- package/npm/launcher-boot-log.js +57 -0
- package/npm/operator-host-disk.js +44 -0
- package/npm/scenario-check.js +172 -1
- package/npm/scenario-metrics.js +101 -0
- package/npm/scenario-playwright.js +77 -5
- package/npm/utils.js +140 -21
- package/package.json +5 -5
- package/ui/dist/assets/{ContainerInspector-9w8TlRwl.js → ContainerInspector-Ceop11Fv.js} +1 -1
- package/ui/dist/assets/EditorShell-DjI5cEF_.js +366 -0
- package/ui/dist/assets/ScenarioDataPanel-D-nWT7xD.js +21 -0
- package/ui/dist/assets/{ScenarioDataPanelFullPage-DkysGs6X.js → ScenarioDataPanelFullPage-ZNFZcTQU.js} +1 -1
- package/ui/dist/assets/ScenarioRenderer-BW6QLGFW.js +26 -0
- package/ui/dist/assets/index-B3SMxYUB.css +1 -0
- package/ui/dist/assets/{index-CqKB9WVm.js → index-ClrdYzlw.js} +6 -6
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/EditorShell-CmEoMxKh.js +0 -366
- package/ui/dist/assets/ScenarioDataPanel-BM7COEfv.js +0 -21
- package/ui/dist/assets/ScenarioRenderer-M3HRiuEn.js +0 -26
- package/ui/dist/assets/index-Bk0fHYF3.css +0 -1
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
var iR=Object.defineProperty;var lR=(e,n,s)=>n in e?iR(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var an=(e,n,s)=>lR(e,typeof n!="symbol"?n+"":n,s);import{j as t}from"./markdown-C9tbsVHX.js";import{b as l,c as us,R as Mt}from"./react-nrLBr15I.js";import{r as cR,i as td,n as nd,a as Zt,b as ko,C as dR,c as $i,d as Fi,s as uR}from"./useEvents-DNb1olaj.js";import{by as pR,bz as hR,bA as fR,w as Bt,bB as mR,as as Ht,bC as st,S as gR,bD as Pt,bE as _g,bF as xl,bG as xR,bH as bR,bI as yR,bJ as vR,bK as jR,bL as wR,bM as sd,ar as Sg,bN as _R,bO as No,bP as Sn,bQ as SR,bR as kR,bS as Cr,bT as NR,bU as Tr,bV as kg,bW as Ng,bX as Ja,bY as CR,bZ as TR,u as PR,b_ as OR,b$ as RR,c0 as rd,c1 as ad,c2 as od,c3 as id,c4 as ld,c5 as ER,c6 as AR,c7 as MR,c8 as Rh,c9 as IR,ca as DR,cb as LR,cc as $R,cd as FR,ce as zR,cf as Eh,ao as BR,an as WR,am as HR,cg as qR,ch as UR,ci as Pr,cj as _a,ck as Or,cl as GR,b as YR,cm as Cg,cn as Rr,co as VR,cp as KR,cq as Ah,cr as Tg,cs as cd,ct as Mh,cu as JR,cv as XR,f as bl,cw as QR,e as dd,cx as Pg,cy as ZR,cz as eE,k as tE,cA as Ih,cB as nE,cC as sE,at as rE,cD as aE,cE as Dh,cF as oE,cG as iE,cH as Lh,cI as lE,cJ as cE,cK as dE,cL as uE,A as pE,F as hE}from"./ScenarioDataPanel-BM7COEfv.js";import{a as fE,e as mE,b as gE,c as ud,i as Og,l as me,g as pd,d as xE,f as bE,r as yE,p as jn,t as vE,u as jE,P as ps,w as wE,h as _E,s as $h,j as SE,k as kE}from"./index-CqKB9WVm.js";import{C as dt,a as mt,u as Co,c as To,d as NE}from"./useServerIdentity-CVuHTzjg.js";import{C as ms}from"./CyLogo-BIbFVvgW.js";import{M as Lt}from"./Markdown-BaLq9qkt.js";const CE=5e3,Fh=50;function TE(){const[e,n]=l.useState([]),[s,r]=l.useState(0),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[p,h]=l.useState(null),f=l.useRef("idle"),m=l.useRef([]),g=l.useRef(null);l.useEffect(()=>{m.current=e},[e]),l.useEffect(()=>{g.current=a},[a]);const x=l.useCallback(async()=>{if(f.current==="idle"){f.current="initial",c(!0),h(null);try{const v=await fetch(`/api/history?limit=${Fh}`);if(!v.ok)throw new Error(`HTTP ${v.status}`);const j=await v.json();n(j.entries??[]),r(j.total??0),o(j.nextCursor??null),j.error&&h(j.error)}catch(v){h(v instanceof Error?v.message:"Failed to load history")}finally{c(!1),f.current="idle"}}},[]),b=l.useCallback(async()=>{var j;if(f.current!=="idle")return;const v=(j=m.current[0])==null?void 0:j.commit.sha;if(!v){await x();return}f.current="poll";try{const _=await fetch(`/api/history?since=${encodeURIComponent(v)}`);if(!_.ok)throw new Error(`HTTP ${_.status}`);const S=await _.json(),w=new Set(m.current.map(N=>N.commit.sha)),k=(S.entries??[]).filter(N=>!w.has(N.commit.sha));k.length>0&&(n(N=>[...k,...N]),r(N=>N+k.length))}catch(_){h(_ instanceof Error?_.message:"Failed to poll history")}finally{f.current="idle"}},[x]),y=l.useCallback(async()=>{if(f.current!=="idle")return;const v=g.current;if(v){f.current="more",u(!0);try{const j=await fetch(`/api/history?limit=${Fh}&before=${encodeURIComponent(v)}`);if(!j.ok)throw new Error(`HTTP ${j.status}`);const _=await j.json();n(S=>[...S,..._.entries??[]]),o(_.nextCursor??null),typeof _.total=="number"&&r(_.total)}catch(j){h(j instanceof Error?j.message:"Failed to load more commits")}finally{u(!1),f.current="idle"}}},[]);return l.useEffect(()=>{x();const v=setInterval(()=>{b()},CE);return()=>clearInterval(v)},[x,b]),{rows:e,total:s,hasMore:a!==null,loading:i,loadingMore:d,error:p,loadMore:y,reload:x}}function Tn(){const[e,n]=l.useState({}),s=l.useRef({});return l.useEffect(()=>pR(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,p=typeof a.sourceVersion=="number"?a.sourceVersion:void 0,h=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||p!==s.current.sourceVersion||h!==s.current.liveReloadEnabled)&&(s.current={scenariosVersion:o,plansVersion:i,manualTestsVersion:c,testsVersion:d,claimsVersion:u,sourceVersion:p,liveReloadEnabled:h},n(s.current))}),[]),e}function qr(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i}=Tn(),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 p=await u.json();n(Array.isArray(p)?p.map(h=>({...h,dependsOn:Array.isArray(h.dependsOn)?h.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:e,loading:s,error:a,refetch:d}}function hd(e=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=${e}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const p=await u.json();s(Array.isArray(p)?p:[]),c.current=!0}catch(u){i(u instanceof Error?u.message:"Failed to load completed plans")}finally{a(!1)}},[e]);return l.useEffect(()=>{d()},[d]),{plans:n,loading:r,error:o,refetch:d}}function fd(){const[e,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(p=>typeof p=="string")))}catch(c){o(c instanceof Error?c.message:"Failed to load completed plan slugs")}finally{r(!1)}},[]);return l.useEffect(()=>{i()},[i]),{slugs:e,loading:s,error:a,refetch:i}}function Rg(e){const n=new Map;return e.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 PE="unknown";function Aa(e){const n=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${s}-${r}`}function OE(e,n){const s=Aa(n),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1),a=Aa(e);if(a===s)return"Today";if(a===Aa(r))return"Yesterday";const i=`${e.toLocaleDateString("en-US",{month:"short"})} ${e.getDate()}`;return e.getFullYear()===n.getFullYear()?i:`${i}, ${e.getFullYear()}`}function RE(e,n,s=new Date){const r=new Map;return e.forEach((a,o)=>{const i=new Date(n(a)),c=!isNaN(i.getTime()),d=c?Aa(i):PE;let u=r.get(d);u||(u={key:d,label:c?OE(i,s):"Unknown date",items:[]},r.set(d,u)),u.items.push({row:a,index:o})}),[...r.values()]}const EE=/\s*\[(skip ci|ci skip)\]/gi,zh=/^plan\s*:\s*/i,Bh=/^ignore proposed plan\s+/i,AE=/^chore(\([^)]*\))?\s*:/i,ME=/^write \d+ proposed plans?$/i,IE=/^(triage|reorder|prune|clean( up)?|remove|delete|rename|renumber|sync|tidy)\b.*\b(plans?|queue)\b/i;function Eg(e){return e.replace(EE,"").trim()}function DE(e){const n=Eg(e);if(zh.test(n)){const s=n.replace(zh,"").trim();return Bh.test(s)?{kind:"plan-ignored",title:s.replace(Bh,"").trim()}:ME.test(s)||IE.test(s)?{kind:"maintenance",title:n}:{kind:"plan-added",title:s}}return AE.test(n)&&/codeyam/i.test(n)?{kind:"maintenance",title:n}:{kind:"change",title:n}}function LE(e){return e.toLowerCase()==="chore"?"Maintenance":e}function Es(e){return{fields:Object.fromEntries(e.fields.map(n=>[n.key,n.value])),body:e.body}}function $E(e,n){return!e||!n?!1:JSON.stringify(Es(e))!==JSON.stringify(n)}function md(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function FE(e){return e&&(e.split(/[\\/]/).pop()??"").replace(/\.[^.]+$/,"")||null}function Wh(e,n){const s=n.trim().toLowerCase();if(!s)return!1;if(e.title.trim().toLowerCase()===s)return!0;const r=md(n);return r!==""&&(e.slug===r||FE(e.filePath)===r)}function zE({title:e,setAside:n,pending:s,completed:r,completedSlugs:a,builtTitles:o}){const i=s.find(h=>Wh(h,e)),c=r.find(h=>Wh(h,e)),d=i??c??null,u=a.has(md(e))||o.has(e.trim().toLowerCase());let p=null;return n?p="set-aside":i?p="queued":(c||u)&&(p="built"),{status:p,slug:(d==null?void 0:d.slug)??null,body:(d==null?void 0:d.body)??null}}function gd(e){const n=new Date(e);if(isNaN(n.getTime()))return e;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 Ag(e){switch(e){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 XG(e){let n=0,s=0,r=0;for(const a of e)a.status==="added"?n++:a.status==="deleted"?r++:s++;return{added:n,modified:s,deleted:r}}function Mg({commit:e}){const n=Eg(e.subject),s=[n,e.authorName].filter(Boolean).join(" · ");return t.jsxs("div",{"data-testid":"history-commit-row",title:s,className:"flex items-center gap-2.5 px-3.5 py-1.5 text-[13px]",children:[t.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--text-dim)]"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--text-secondary)]",children:n}),t.jsx("span",{className:"shrink-0 font-mono text-xs text-[var(--text-dim)]",children:e.shortSha}),t.jsx("span",{className:"shrink-0 text-xs text-[var(--text-dim)] tabular-nums",children:gd(e.timestamp)})]})}const QG=Object.freeze(Object.defineProperty({__proto__:null,CommitOnlyHistoryRow:Mg},Symbol.toStringTag,{value:"Module"})),BE=[/\.test\.[jt]sx?$/,/\.spec\.[jt]sx?$/,/__tests__\//,/tests?\//];function xd(e){return e.filter(n=>BE.some(s=>s.test(n.path)))}function WE(e){return e.replace(/```[\s\S]*?```/g," ").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/`([^`]*)`/g,"$1").replace(/^\s{0,3}(#{1,6}|>|[-*+]|\d+\.)\s+/gm,"").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(^|\s)[*_]([^*_\s][^*_]*?)[*_](?=\s|$|[.,!?:;])/g,"$1$2").replace(/\s+/g," ").trim()}const HE=192;function Po({children:e,variant:n="compact",maxHeight:s=HE,moreLabel:r="Show more",lessLabel:a="Show less",fadeColor:o="var(--bg-card)"}){const i=l.useRef(null),[c,d]=l.useState(!1),[u,p]=l.useState(!1);return l.useEffect(()=>{const h=i.current;if(!h)return;const f=()=>p(h.scrollHeight>s);f();const m=new ResizeObserver(f);return m.observe(h),()=>m.disconnect()},[e,s]),t.jsxs("div",{children:[t.jsxs("div",{ref:i,style:{maxHeight:c?"none":`${s}px`,overflow:"hidden",position:"relative"},children:[t.jsx(Lt,{variant:n,children:e}),!c&&u&&t.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2rem",background:`linear-gradient(transparent, ${o})`,pointerEvents:"none"}})]}),u&&t.jsx("button",{onClick:()=>d(h=>!h),className:"text-xs cursor-pointer mt-1",style:{color:"var(--accent-blue)",background:"none",border:"none",padding:0},children:c?a:r})]})}const ZG=Object.freeze(Object.defineProperty({__proto__:null,CollapsibleMarkdown:Po},Symbol.toStringTag,{value:"Module"}));function Oo({total:e,passed:n,failed:s,noun:r}){if(e===0)return null;const a=s>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]";return t.jsxs("span",{className:`text-xs ${a}`,children:[n,"/",e," ",r?`${r} `:"","passed"]})}const eY=Object.freeze(Object.defineProperty({__proto__:null,TestResultsBadge:Oo},Symbol.toStringTag,{value:"Module"}));function Ro({status:e}){const n=e==="added"?"var(--accent-green)":e==="deleted"?"var(--accent-red)":"var(--text-muted)",s=e==="added"?"+":e==="deleted"?"-":"~";return t.jsx("span",{className:"font-mono text-xs font-semibold",style:{color:n,minWidth:"0.75rem",textAlign:"center"},children:s})}const tY=Object.freeze(Object.defineProperty({__proto__:null,FileStatusIndicator:Ro},Symbol.toStringTag,{value:"Module"}));function gs(e,n){if(e.startsWith("http"))return e;const s=`/api/screenshots/${e}`;return typeof n=="number"?`${s}?cb=${n}`:s}function Ot({screenshotPath:e,cacheBuster:n,alt:s,className:r="",title:a,loading:o="eager"}){const[i,c]=l.useState("loading"),[d,u]=l.useState(!1),p=l.useRef(null),h=e?gs(e,n):"",f=()=>{c("success"),u(!0)},m=()=>{c("error"),u(!1)};return l.useEffect(()=>{c("loading"),u(!1);const g=p.current;g!=null&&g.complete&&(g.naturalHeight!==0?(c("success"),u(!0)):(c("error"),u(!1)))},[h]),e?t.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",title:a,children:[t.jsx("img",{ref:p,src:h,alt:s,loading:o,decoding:"async",onLoad:f,onError:m,className:r||"max-w-full max-h-full object-contain",style:{opacity:d?1:0,position:d?"relative":"absolute"}}),i==="loading"&&t.jsx("div",{className:"absolute inset-0 bg-[var(--bg-card)] animate-pulse rounded flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-[var(--text-dim)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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"})})}),i==="error"&&t.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:[t.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"}),t.jsx("span",{className:"text-[var(--text-dim)] whitespace-nowrap",children:"No Screenshot"})]})]}):t.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:t.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"})})}const nY=Object.freeze(Object.defineProperty({__proto__:null,SafeScreenshot:Ot},Symbol.toStringTag,{value:"Module"})),Ig=4,Dg="flex items-center justify-center overflow-hidden rounded-md border border-white/10 bg-[var(--bg-surface)]";function Lg({shot:e,onSelect:n}){const s=t.jsx("div",{className:`${Dg} h-16 w-24`,children:t.jsx(Ot,{screenshotPath:e.screenshotPath,cacheBuster:e.screenshotCapturedAtMs??void 0,alt:""})});return!n||!e.screenshotPath?t.jsx("div",{className:"shrink-0","data-testid":"history-lead-thumbnail",children:s}):t.jsx("button",{type:"button",tabIndex:-1,"aria-hidden":!0,"data-testid":"history-lead-thumbnail",onClick:()=>n(e),className:"block shrink-0 cursor-pointer rounded-md transition hover:ring-2 hover:ring-[var(--accent-primary)]",children:s})}function $g({screenshots:e,onSelect:n}){if(e.length===0)return null;const s=e.slice(0,Ig),r=e.length-s.length;return t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.map((a,o)=>{const i=t.jsx("div",{className:`${Dg} h-[42px] w-16`,children:t.jsx(Ot,{screenshotPath:a.screenshotPath,cacheBuster:a.screenshotCapturedAtMs??void 0,alt:a.name})}),c=`${a.screenshotPath??"missing"}:${a.name}:${o}`;return n&&a.screenshotPath?t.jsx("button",{type:"button",onClick:()=>n(a),"aria-label":`Preview ${a.name}`,title:a.name,className:"block shrink-0 cursor-pointer rounded-md transition hover:ring-2 hover:ring-[var(--accent-primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-primary)]",children:i},c):t.jsx("div",{title:a.name,className:"shrink-0",children:i},c)}),r>0&&t.jsxs("span",{className:"ml-1 shrink-0 text-xs text-[var(--text-dim)]",children:["+",r," ",r===1?"screen":"screens"]})]})}const sY=Object.freeze(Object.defineProperty({__proto__:null,HistoryLeadThumbnail:Lg,HistoryScreensStrip:$g,STRIP_LIMIT:Ig},Symbol.toStringTag,{value:"Module"}));function Eo({entry:e,commit:n,onSelectScreenshot:s,defaultExpanded:r=!1}){const[a,o]=l.useState(r),i=xd(e.modifiedFiles??[]),c=e.scenarioScreenshots??[],d=e.userRequest?WE(e.userRequest):"",u=!!e.userRequest||i.length>0,p=e.userRequest?"Show the full prompt":"Show test files",h=e.userRequest?"Hide the full prompt":"Hide test files";return t.jsxs("div",{"data-testid":"history-entry-card",className:"flex gap-3.5 rounded-xl border border-white/10 bg-white/[0.025] p-3.5",children:[c.length>0&&t.jsx(Lg,{shot:c[0],onSelect:s}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-xs leading-5 text-[var(--text-dim)]",children:[t.jsx("span",{"data-testid":"history-entry-type",className:`rounded bg-white/[0.06] px-1.5 font-medium capitalize ${Ag(e.type)}`,children:LE(e.type)}),n&&t.jsx("span",{className:"font-mono text-[var(--text-secondary)]",children:n.shortSha}),t.jsxs("span",{children:["· ",gd(e.timestamp)]}),(n==null?void 0:n.authorName)&&t.jsxs("span",{children:["· ",n.authorName]})]}),t.jsx("h3",{className:"text-[15px] font-medium leading-snug text-[var(--text-primary)]",children:e.title}),d&&!a&&t.jsx("p",{"data-testid":"history-entry-summary",className:"line-clamp-2 text-[13px] leading-relaxed text-[var(--text-secondary)]",children:d}),a&&t.jsxs("div",{className:"flex flex-col gap-2","data-testid":"history-entry-details",children:[e.userRequest&&t.jsx(Po,{children:e.userRequest}),i.length>0&&t.jsx(zg,{files:i})]}),u&&t.jsx("button",{type:"button",onClick:()=>o(f=>!f),className:"self-start cursor-pointer text-xs text-[var(--text-muted)] hover:text-[var(--accent-active)]",children:a?h:p}),t.jsx(Fg,{screenshots:c,hasTestFiles:i.length>0,testResults:e.testResults,onSelectScreenshot:s})]})]})}function Fg({screenshots:e,hasTestFiles:n,testResults:s,onSelectScreenshot:r}){const a=s?t.jsx(Oo,{total:s.total,passed:s.passed,failed:s.failed,noun:"tests"}):null;return e.length===0?t.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[t.jsxs("p",{className:"text-xs text-[var(--text-dim)]",children:["No screens changed",n?"":" · No test files changed"]}),a]}):t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5",children:[t.jsx($g,{screenshots:e,onSelect:r}),a&&t.jsx("span",{className:"shrink-0",children:a})]})}function zg({files:e}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-xs font-medium text-[var(--text-muted)]",children:"Test files"}),t.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(n=>t.jsxs("li",{className:"flex items-center gap-1.5",children:[t.jsx(Ro,{status:n.status}),t.jsx("span",{className:"truncate font-mono text-xs text-[var(--text-secondary)]",children:n.path})]},n.path))})]})}const rY=Object.freeze(Object.defineProperty({__proto__:null,CardFooter:Fg,HistoryEntryCard:Eo,TestFileList:zg},Symbol.toStringTag,{value:"Module"}));function Bg({label:e,children:n}){return t.jsxs("section",{"data-testid":"history-day-group","aria-label":e,children:[t.jsx("h2",{className:"mb-2 text-[11px] font-medium uppercase tracking-[0.08em] text-[var(--text-dim)]",children:e}),t.jsx("div",{className:"flex flex-col gap-2",children:n})]})}const aY=Object.freeze(Object.defineProperty({__proto__:null,HistoryDayGroup:Bg},Symbol.toStringTag,{value:"Module"}));function Ur({expanded:e,testId:n}){return t.jsx("span",{"aria-hidden":"true","data-testid":n,className:"inline-block shrink-0 text-xs leading-none text-[var(--text-dim)] transition-transform "+(e?"rotate-180":"rotate-0"),children:"⌄"})}const oY=Object.freeze(Object.defineProperty({__proto__:null,PlanDisclosureChevron:Ur},Symbol.toStringTag,{value:"Module"})),Wg="You'll be able to run a plan once the current build finishes.",qE="This plan is waiting on earlier plans that haven't finished yet.",UE="Another session is already working on this plan.";function GE(e){switch(e){case"building":return Wg;case"dependencies":return qE;case"claimed":return UE}}function Hg({message:e}){return t.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:e})}const iY=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedTooltip:Hg},Symbol.toStringTag,{value:"Module"}));function bd({slug:e,onRun:n,launching:s=!1,blockedReason:r=null}){const a=g=>{g.stopPropagation(),!s&&n(e)},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,[p,h]=l.useState(!1),f=r?GE(r):null,m=u&&p;return t.jsxs("button",{type:"button",onClick:a,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocus:()=>h(!0),onBlur:()=>h(!1),disabled:d,"data-testid":`plan-run-${e}`,"aria-label":u&&f?`Run — ${f}`:void 0,className:"relative "+o+(u?c:i),children:[s?"Launching…":"Run",m&&f?t.jsx(Hg,{message:f}):null]})}const lY=Object.freeze(Object.defineProperty({__proto__:null,PlanRunButton:bd},Symbol.toStringTag,{value:"Module"})),YE={queued:"Queued",built:"Built","set-aside":"Set aside"},VE={queued:"border-[var(--accent-active)] text-[var(--accent-active)]",built:"border-white/15 text-[var(--text-secondary)]","set-aside":"border-white/10 text-[var(--text-dim)]"};function qg({status:e}){return t.jsx("span",{"data-testid":"history-plan-status",className:`shrink-0 rounded-full border px-2 py-px text-[11px] leading-4 ${VE[e]}`,children:YE[e]})}function Ug({commit:e,title:n,setAside:s,plan:r,onRunPlan:a}){const[o,i]=l.useState(!1),c=`${s?"Plan set aside":"Plan added"}: ${n}`,d=r.status==="queued"?r.slug:null;return t.jsxs("div",{"data-testid":"history-plan-row",children:[t.jsxs("button",{type:"button",onClick:()=>i(u=>!u),"aria-expanded":o,title:[c,e.authorName].filter(Boolean).join(" · "),className:"flex w-full cursor-pointer items-center gap-2.5 rounded-md px-3.5 py-1.5 text-left text-[13px] hover:bg-white/[0.03]",children:[t.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--text-muted)]"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--text-secondary)]",children:c}),r.status&&t.jsx(qg,{status:r.status}),t.jsx("span",{className:"shrink-0 font-mono text-xs text-[var(--text-dim)]",children:e.shortSha}),t.jsx("span",{className:"shrink-0 text-xs text-[var(--text-dim)] tabular-nums",children:gd(e.timestamp)}),t.jsx(Ur,{expanded:o,testId:"history-plan-chevron"})]}),o&&t.jsxs("div",{"data-testid":"history-plan-details",className:"mt-1 mb-2 ml-7 mr-3.5 flex flex-col gap-3 rounded-lg border border-white/10 bg-white/[0.02] p-3.5",children:[r.body?t.jsx(Lt,{variant:"document",children:r.body}):t.jsx("p",{className:"text-xs text-[var(--text-dim)]",children:"This plan's file is no longer in the queue."}),d&&a&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(bd,{slug:d,onRun:u=>a(u,n)}),t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"Start building this plan now."})]})]})]})}const cY=Object.freeze(Object.defineProperty({__proto__:null,HistoryPlanStatusChip:qg,PlanHistoryRow:Ug},Symbol.toStringTag,{value:"Module"}));function Gg(e,n,s){const r=n?n.filter(o=>o.entry).length:-1,a=n?n.length:-1;l.useEffect(()=>{e(a<0?void 0:{builds:r,commits:a,total:s})},[e,r,a,s])}const KE=20;function Yg({onPreviewScreenshot:e,onRunPlan:n,onCounts:s}){const{rows:r,total:a,hasMore:o,loading:i,loadingMore:c,error:d,loadMore:u}=TE(),{plans:p}=qr(),{plans:h}=hd(KE),{slugs:f}=fd(),[m,g]=l.useState(!1),x=l.useMemo(()=>r.map(N=>({row:N,commitKind:N.entry?null:DE(N.commit.subject)})),[r]),b=m?0:x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)==="maintenance"}).length,y=l.useMemo(()=>m?r:x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)!=="maintenance"}).map(N=>N.row),[m,r,x]);Gg(s,i||r.length===0?null:y,a===void 0?void 0:Math.max(y.length,a-b));const v=l.useMemo(()=>new Set(r.flatMap(N=>N.entry?[N.entry.title.trim().toLowerCase()]:[])),[r]);if(i)return t.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading history..."});if(d&&r.length===0)return t.jsx("div",{className:"py-12",children:t.jsx(dt,{text:`Failed to load history: ${d}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});if(r.length===0)return t.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[t.jsx("p",{children:"No commits yet."}),t.jsx("p",{className:"mt-2 text-sm",children:"Commits and journal entries will appear here as you build features."})]});const j=x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)==="maintenance"}).length,_=m?x:x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)!=="maintenance"}),S=Rg(_.map(N=>N.row)),w=RE(_,N=>N.row.commit.timestamp),k=({row:N,commitKind:C},T)=>{if(N.entry)return t.jsx(Eo,{entry:N.entry,commit:N.commit,onSelectScreenshot:e?P=>e({...P,isLatest:S.get(P.name)===T}):void 0},N.commit.sha);if((C==null?void 0:C.kind)==="plan-added"||(C==null?void 0:C.kind)==="plan-ignored"){const P=C.kind==="plan-ignored";return t.jsx(Ug,{commit:N.commit,title:C.title,setAside:P,plan:zE({title:C.title,setAside:P,pending:p,completed:h,completedSlugs:f,builtTitles:v}),onRunPlan:n},N.commit.sha)}return t.jsx(Mg,{commit:N.commit},N.commit.sha)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-6",children:[w.length===0&&t.jsx("p",{className:"py-8 text-center text-sm text-[var(--text-dim)]",children:"Only maintenance commits so far."}),w.map(N=>t.jsx(Bg,{label:N.label,children:N.items.map(({row:C,index:T})=>k(C,T))},N.key))]}),t.jsxs("div",{className:"mt-5 flex flex-col items-center gap-3",children:[o?t.jsx("button",{type:"button",onClick:()=>void u(),disabled:c,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:c?"Loading...":"Load older commits"}):null,j>0&&t.jsx("button",{type:"button",onClick:()=>g(N=>!N),"aria-pressed":m,"data-testid":"history-maintenance-toggle",className:"cursor-pointer text-xs text-[var(--text-dim)] hover:text-[var(--text-secondary)]",children:m?`Hide maintenance commits (${j})`:`Show maintenance commits (${j})`})]})]})}const dY=Object.freeze(Object.defineProperty({__proto__:null,HistoryLiveList:Yg},Symbol.toStringTag,{value:"Module"})),JE="dec[ií]me|dec[ií]|escrib[ií]|escrib[ií]me|respond[eé]|respondeme|respondéme|pon[eé]|mand[aá]me|say|reply|type|answer|send|tell me",XE=new RegExp(`\\b(?:${JE})\\s+(?:with\\s+|con\\s+)?["“]([^"”\\n]{1,40})["”]`,"gi");function QE(e){const n=[];let s=0;for(const r of e.matchAll(XE)){const a=r.index??0,o=a+r[0].length-r[1].length-2;o>s&&n.push({kind:"text",value:e.slice(s,o)}),n.push({kind:"reply",value:r[1]}),s=a+r[0].length}return s<e.length&&n.push({kind:"text",value:e.slice(s)}),n}const Gr=l.createContext(null);function gr(e){var r;const n=(r=e.title)==null?void 0:r.trim();if(n)return n;const s=e.name.replace(/^\d{1,2}-/,"").replace(/-/g," ").trim();return!s||/^off\s?catalog$/i.test(s)?"Custom design":s}const Vg=["keep","iterate","versions","replace"],Kg=[2,3,4],yd=/```design-plan\s*([\s\S]*?)```/,Jg="Design plan:",Xg={verb:"replace"};function Qg(e,n){const s=/^(\d{1,2})-/.exec(e);return s?parseInt(s[1],10):n+1}function ZE(e){const n=e&&typeof e=="object"?e:{verb:e},s=Vg.find(a=>a===n.verb);if(!s)return Xg;if(s!=="versions")return{verb:s};const r=Kg.find(a=>a===n.count)??2;return{verb:s,count:r}}function Zg(e){try{const n=JSON.parse(e);return!n||typeof n!="object"||Array.isArray(n)?null:Object.fromEntries(Object.entries(n).map(([s,r])=>[s,ZE(r)]))}catch{return null}}function vd(e){return e.replace(yd,"").trim()}function eA(e){const n=yd.exec(e);return n?{suggestion:Zg(n[1])??{},text:vd(e)}:null}function tA(e,n){return e.map((s,r)=>{const a=n==null?void 0:n[s.filename];return{filename:s.filename,number:Qg(s.filename,r),name:gr(s),decision:a??Xg,suggested:a!==void 0}})}function nA(e,n,s,r){return e.map(a=>a.filename===n?{...a,decision:s==="versions"?{verb:s,count:r??a.decision.count??2}:{verb:s},suggested:!1}:a)}function sA(e){return e.verb==="versions"?`MULTIPLE VERSIONS x${e.count??2}`:e.verb.toUpperCase()}function rA(e,n){const s=e.map(o=>`#${o.number} ${o.name} (${o.filename}): ${sA(o.decision)}`),r=Object.fromEntries(e.map(o=>[o.filename,o.decision])),a=n.trim();return[`${Jg} ${s.join("; ")}.`,...a?[`My note: ${a}`]:[],"```design-plan",JSON.stringify(r),"```"].join(`
|
|
2
|
-
`)}function aA(e,n){switch(n.verb){case"keep":return`Keep #${e}`;case"iterate":return`Iterate #${e}`;case"versions":return`${n.count??2} versions of #${e}`;case"replace":return`Replace #${e}`}}function oA(e){var i;const n=e.trim();if(!n.startsWith(Jg))return null;const s=yd.exec(n),r=s?Zg(s[1]):null;if(!r)return null;const a=Object.entries(r).map(([c,d],u)=>({number:Qg(c,u),d})).sort((c,d)=>c.number-d.number).map(({number:c,d})=>aA(c,d)).join(" · "),o=((i=/My note: ([\s\S]*?)\s*```design-plan/.exec(n))==null?void 0:i[1].trim())??"";return{summary:a,note:o}}const Xa=42,ex={sliders:{},words:[],text:""};function Er(e){return`${e.left}|${e.right}`}function tx(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&"sliders"in e&&"words"in e&&"text"in e}function nx(e){return tx(e)?e:ex}function iA(e,n,s){const r={...e.sliders};return s===50?delete r[Er(n)]:r[Er(n)]=Math.max(0,Math.min(100,Math.round(s))),{...e,sliders:r}}function Hh(e,n,s){const r=n.trim();if(!r)return e;const a=e.words.includes(r)?e.words.filter(o=>o!==r):[...e.words,r].slice(-s);return{...e,words:a}}function lA(e,n){return{...e,text:n}}function cA(e,n){return e.flatMap(s=>{const r=n.sliders[Er(s)];return r===void 0?[]:r<Xa?[s.left.toLowerCase()]:r>100-Xa?[s.right.toLowerCase()]:[]})}function sx(e){return Object.keys(e.sliders).length>0||e.words.length>0||e.text.trim().length>0}function rx(e,n){const s=[...cA(e,n),...n.words.map(a=>a.toLowerCase())],r=n.text.trim();return r&&s.push(`“${r}”`),s.join(", ")}const Ma="Nothing",dA={picks:{},notes:{}};function ax(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&"picks"in e&&"notes"in e}function ox(e){return ax(e)?e:dA}function uA(e,n,s){const r=e.picks[n]??[];let a;return r.includes(s)?a=r.filter(o=>o!==s):s===Ma?a=[Ma]:a=[...r.filter(o=>o!==Ma),s],{...e,picks:{...e.picks,[n]:a}}}function pA(e,n,s){return{...e,notes:{...e.notes,[n]:s}}}function hA(e){return Object.values(e.picks).some(n=>n.length>0)||Object.values(e.notes).some(n=>n.trim().length>0)}function fA(e,n){return e.flatMap(s=>{const r=(n.picks[s.file]??[]).map(o=>o.toLowerCase()),a=(n.notes[s.file]??"").trim();return a&&r.push(`“${a}”`),r.length?[`${s.label}: ${r.join(", ")}`]:[]}).join("; ")}function mA(e){return`/api/editor-design-user-file?path=${encodeURIComponent(e)}`}const Cn="__idk",gA={answers:{},own:{}},xA=3,bA=6,yA=["Layout","Colors","Type","Illustrations","Mood"],vA=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function et(e){return typeof e=="string"?e.trim():""}function jA(e){if(!Array.isArray(e))return[];const n=new Set,s=[];for(const r of e){const a=typeof r=="string"?r.trim():et(r==null?void 0:r.label);if(!a||n.has(a))continue;n.add(a);const o=typeof r=="object"&&r?et(r.detail):"";s.push(o?{label:a,detail:o}:{label:a})}return s}function xr(e){return Array.isArray(e)?[...new Set(e.map(et).filter(Boolean))]:[]}function wA(e){if(!Array.isArray(e))return[];const n=[];for(const s of e){const[r,a,o]=Array.isArray(s)?[et(s[0]),et(s[1]),et(s[2])]:[et(s==null?void 0:s.label),et(s==null?void 0:s.hex),et(s==null?void 0:s.detail)];!r||!vA.test(a)||n.some(i=>i.label===r)||n.push(o?{label:r,hex:a,detail:o}:{label:r,hex:a})}return n}function qh(e){if(!Array.isArray(e))return[];const n=[];for(const s of e){const r=Array.isArray(s)?{left:s[0],right:s[1],value:s[2]}:s,a=et(r==null?void 0:r.left),o=et(r==null?void 0:r.right);if(!a||!o)continue;const i=typeof r.value=="number"?Math.max(0,Math.min(100,r.value)):50;n.push({left:a,right:o,value:i})}return n}function _A(e){if(!Array.isArray(e))return[];const n=[];for(const s of e){const r=s??{},a=typeof s=="string"?s.trim():et(r.file);if(!a||n.some(c=>c.file===a))continue;const o=et(r.label)||a.split("/").pop().replace(/\.[^.]+$/,""),i=et(r.placeholder)||void 0;n.push({file:a,label:o,sees:et(r.sees),...i?{placeholder:i}:{}})}return n}function SA(e){if(!e||typeof e!="object")return null;const n=e,s=et(n.id),r=et(n.title);if(!s||!r)return null;const a=et(n.why),o=jA(n.options),i=et(n.ownPlaceholder)||void 0;if(n.type==="palette"){const c=wA(n.options);if(c.length>0)return{id:s,type:"palette",title:r,why:a,options:c,ownPlaceholder:i}}if(n.type==="personality"){const c=qh(n.sliders),d=xr(n.words);if(c.length>0||d.length>0){const u=typeof n.maxWords=="number"&&n.maxWords>=1?Math.floor(n.maxWords):bA;return{id:s,type:"personality",title:r,why:a,sliders:c,moreSliders:qh(n.moreSliders),words:d,moreWords:xr(n.moreWords).filter(p=>!d.includes(p)),maxWords:u,textPlaceholder:et(n.textPlaceholder)||void 0}}}if(n.type==="refs"){const c=_A(n.images);if(c.length>0){const d=xr(n.parts);return{id:s,type:"refs",title:r,why:a,images:c,parts:d.length?d:yA}}}if(n.type==="multi"&&o.length>0){const c=typeof n.max=="number"&&n.max>=1?Math.floor(n.max):xA;return{id:s,type:"multi",title:r,why:a,options:o,max:c,ownPlaceholder:i}}return n.type!=="free"&&o.length>0?{id:s,type:"single",title:r,why:a,options:o,ownPlaceholder:i}:{id:s,type:"free",title:r,why:a,placeholder:et(n.placeholder)||void 0}}function kA(e){if(!e||typeof e!="object")return null;const n=e;if(!Array.isArray(n.questions))return null;const s=new Set,r=[];for(const i of n.questions){const c=SA(i);!c||s.has(c.id)||(s.add(c.id),r.push(c))}if(r.length===0)return null;const a={},o=n.defaults&&typeof n.defaults=="object"?n.defaults:{};for(const i of r){if(i.type==="free")continue;const c=o[i.id];if(i.type==="personality"){const u=xr(Array.isArray(c)?c:c==null?void 0:c.words).slice(0,i.maxWords);u.length&&(a[i.id]={...ex,words:u});continue}if(i.type==="refs"){const u={},p=c&&typeof c=="object"&&!Array.isArray(c)?c:{};for(const h of i.images){const f=xr(p[h.file]).filter(m=>i.parts.includes(m));f.length&&(u[h.file]=f)}Object.keys(u).length&&(a[i.id]={picks:u,notes:{}});continue}const d=new Set(i.options.map(u=>u.label));if((i.type==="single"||i.type==="palette")&&typeof c=="string"&&d.has(c)&&(a[i.id]=c),i.type==="multi"&&Array.isArray(c)){const u=c.filter(p=>typeof p=="string"&&d.has(p)).slice(0,i.max);u.length&&(a[i.id]=u)}}return{title:et(n.title)||"Quick questions before I design this",lede:et(n.lede),questions:r,defaults:a}}function Yr(e,n){const s=n.answers[e.id],r=(n.own[e.id]??"").trim();return e.type==="free"?typeof s=="string"&&s.trim().length>0:s===Cn?!0:e.type==="personality"?tx(s)&&sx(s):e.type==="refs"?ax(s)&&hA(s):Array.isArray(s)&&s.length>0||r.length>0}function Ao(e){return e.questions.filter(n=>n.type!=="free")}function ix(e,n){return Ao(e).filter(s=>Yr(s,n)).length}function NA(e,n){var s;return((s=Ao(e).find(r=>!Yr(r,n)))==null?void 0:s.id)??null}function CA(e,n){const s=Ao(e).length;return s===0?TA(e,n):ix(e,n)>=Math.min(2,s)}function TA(e,n){return e.questions.some(s=>s.type==="free"&&Yr(s,n))}function PA(e){return e.type==="multi"||e.type==="single"||e.type==="palette"?e.options.length:0}function OA(e,n,s,r){const a=Array.isArray(e.answers[n])?e.answers[n]:[];r<1&&(r=Number.MAX_SAFE_INTEGER);const o=a.includes(s)?a.filter(i=>i!==s):[...a,s].slice(-r);return{...e,answers:{...e.answers,[n]:o}}}function RA(e,n,s){const r={...e.own,[n.id]:s},a={...e.answers};return a[n.id]===Cn&&(a[n.id]=[]),{answers:a,own:r}}function EA(e,n){const s={...e.answers},r={...e.own};return s[n]===Cn?delete s[n]:(s[n]=Cn,delete r[n]),{answers:s,own:r}}function AA(e,n,s){return{...e,answers:{...e.answers,[n]:s}}}function MA(e,n,s){return{...e,answers:{...e.answers,[n]:s}}}function IA(e,n){const s={};for(const r of e.questions)if(r.type==="free"){const a=n.answers[r.id];typeof a=="string"&&a&&(s[r.id]=a)}else if(e.defaults[r.id]!==void 0){const a=e.defaults[r.id];s[r.id]=typeof a=="string"?[a]:a}else s[r.id]=Cn;return{answers:s,own:{}}}function DA(e,n){if(!Yr(e,n))return null;const s=n.answers[e.id],r=(n.own[e.id]??"").trim();return s===Cn?"Not sure, decide for me":e.type==="free"?s.trim():e.type==="personality"?rx([...e.sliders,...e.moreSliders],nx(s)):e.type==="refs"?fA(e.images,ox(s)):[...Array.isArray(s)?s:[],...r?[r]:[]].join(", ")}function LA(e,n){const s={},r={},a=[];for(const o of e.questions){const i=DA(o,n);if(i===null)continue;const c=n.answers[o.id];s[o.id]=typeof c=="string"?c.trim():c??[];const d=(n.own[o.id]??"").trim();d&&o.type!=="free"&&c!==Cn&&(r[o.id]=d),a.push({id:o.id,title:o.title,answer:i})}return{answers:s,own:r,summary:a}}const jd="I answered the questions in the preview. Read .codeyam/design/answers.json and continue.\r",$A="Before you design, ask me one more follow-up question here in the chat.\r";function FA(e){if(!Array.isArray(e))return;const n=e.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;if(typeof r.question!="string"||!Array.isArray(r.options))return[];const a=r.options.flatMap(o=>{if(!o||typeof o!="object")return[];const i=o;return typeof i.label=="string"?[{label:i.label,description:typeof i.description=="string"?i.description:""}]:[]});return a.length===0?[]:[{question:r.question,header:typeof r.header=="string"?r.header:"",multiSelect:r.multiSelect===!0,options:a}]});return n.length>0?n:void 0}const Ar={available:!1,working:!1,messages:[]},zA=new Set(["user","agent","activity"]);function lx(e){if(!e||typeof e!="object")return Ar;const n=e,s=Array.isArray(n.messages)?n.messages.flatMap(a=>{if(!a||typeof a!="object")return[];const o=a;return typeof o.id!="string"||typeof o.role!="string"||!zA.has(o.role)?[]:[{id:o.id,role:o.role,text:typeof o.text=="string"?o.text:"",items:Array.isArray(o.items)?o.items.filter(i=>typeof i=="string"):[]}]}):[],r=FA(n.question);return{available:n.available===!0,working:n.working===!0,messages:s,...r?{question:r}:{}}}function BA(e){return e.trim()===jd.trim()}function WA(e){const n=jd.trim();return e.some(s=>s.role==="user"&&s.text.trim().endsWith(n))}function Mo(e){const n=e.join(", ");return`I added ${e.length===1?"a file":`${e.length} files`} to .codeyam/design/user_files/: ${n}. Take a look and use ${e.length===1?"it":"them"}.`}const HA=/^I added (?:a file|\d+ files) to \.codeyam\/design\/user_files\/: (.+?)\. Take a look and use (?:it|them)\.(?:\s+([\s\S]*))?$/,qA=/^([\s\S]*?)\s*I added (?:a file|\d+ files) to \.codeyam\/design\/user_files\/: (.+?)\. Take a look and use (?:it|them)\.$/;function UA(e){const n=e.trim(),s=HA.exec(n);if(s)return{names:s[1].split(", "),rest:(s[2]??"").trim()};const r=qA.exec(n);return r?{names:r[2].split(", "),rest:r[1].trim()}:null}function cx(e){const n=e.trim();if(!n.startsWith("Iterate:"))return null;const s=/```json\s*([\s\S]*?)```/.exec(n);if(!s)return{designs:0};try{const r=JSON.parse(s[1]);return{designs:Object.keys(r).length}}catch{return{designs:0}}}function wd(e){return/\?[\s"'”’)\]*_]*$/.test(vd(e))}function _d(e){return`${e.replace(/\s*\n\s*/g," ").trim()}\r`}function GA(e){const n=[],s=/\*\*([^*]+)\*\*|`([^`]+)`/g;let r=0;for(const a of e.matchAll(s))a.index>r&&n.push({kind:"text",value:e.slice(r,a.index)}),n.push(a[1]!==void 0?{kind:"bold",value:a[1]}:{kind:"code",value:a[2]}),r=a.index+a[0].length;return r<e.length&&n.push({kind:"text",value:e.slice(r)}),n}function YA(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(n=>n.length>0)}function VA(e){const n=[];let s=[],r=null;const a=()=>{const o=s.join(`
|
|
3
|
-
`).trim();o&&n.push({kind:"text",value:o}),s=[]};for(const o of e.split(`
|
|
4
|
-
`))/^\s*```/.test(o)?r===null?(a(),r=[]):(n.push({kind:"code",value:r.join(`
|
|
5
|
-
`)}),r=null):r!==null?r.push(o):s.push(o);return r!==null&&n.push({kind:"code",value:r.join(`
|
|
6
|
-
`).trimEnd()}),a(),n}let Sd=new Set,Qa=null,dx=0;const yl=new Set;function ux(){dx+=1;for(const e of yl)e()}function KA(e){Sd=new Set(e),ux()}function Uh(e){Qa=e,ux()}function JA(e){return Sd.has(e)}function XA(){return Qa!==null}function QA(e){Qa&&Sd.has(e)&&Qa(e)}function ZA(e){return yl.add(e),()=>yl.delete(e)}function eM(){return dx}let kd=new Set,Za=null,px=0;const vl=new Set;function Gh(e,n){kd=new Set(e),Za=n,px+=1;for(const s of vl)s()}function tM(e){return Za!==null&&kd.has(e)}function nM(e){Za&&kd.has(e)&&Za(e)}function sM(e){return vl.add(e),()=>vl.delete(e)}function rM(){return px}const aM=/\b(?:design|dise(?:ñ|n)o)\s*#?\s*(\d{1,2})(?![\d])/gi;function oM(e){const n=[];let s=0;for(const r of e.matchAll(aM)){const a=r.index??0;a>s&&n.push({kind:"text",value:e.slice(s,a)}),n.push({kind:"design",value:r[0],number:parseInt(r[1],10)}),s=a+r[0].length}return s<e.length&&n.push({kind:"text",value:e.slice(s)}),n}const iM=/^:?-+:?$/;function zi(e){const n=[];let s="",r=!1;for(const a of e.trim())a==="`"&&(r=!r),a==="|"&&!r?(n.push(s.trim()),s=""):s+=a;return n.push(s.trim()),e.trim().startsWith("|")&&n.shift(),e.trim().endsWith("|")&&n.pop(),n}function lM(e){const n=e.split(`
|
|
7
|
-
`).map(o=>o.trim());if(n.length<2||n.some(o=>!o.includes("|")))return null;const s=zi(n[0]),r=zi(n[1]);if(r.length!==s.length||!r.every(o=>iM.test(o)))return null;const a=n.slice(2).map(o=>{const i=zi(o).slice(0,s.length);for(;i.length<s.length;)i.push("");return i});return{header:s,rows:a}}const cM=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/;function dM(e){const n=[];for(const s of e.split(`
|
|
8
|
-
`)){const r=cM.exec(s),a=n[n.length-1];if(r){const o={text:r[3],depth:Math.min(2,Math.floor(r[1].length/2))};(a==null?void 0:a.kind)==="list"?a.items.push(o):n.push({kind:"list",ordered:/\d/.test(r[2]),items:[o]})}else(a==null?void 0:a.kind)==="text"?a.text+=`
|
|
9
|
-
${s}`:n.push({kind:"text",text:s})}return n}const uM=/https?:\/\/[^\s<>"'`]+/g,pM=/[.,;:!?)\]}»]+$/;function hM(e){const n=[];let s=0;for(const r of e.matchAll(uM)){const a=r.index??0,o=r[0].replace(pM,"");a>s&&n.push({kind:"text",value:e.slice(s,a)}),n.push({kind:"link",value:o}),s=a+o.length}return s<e.length&&n.push({kind:"text",value:e.slice(s)}),n.length?n:[{kind:"text",value:e}]}let eo=null,Ia=0;const jl=new Set,hx=()=>jl.forEach(e=>e());function fM(){return eo}function mM(e){return jl.add(e),()=>jl.delete(e)}function gM(e){return Ia===0?!1:(eo=e,hx(),!0)}function fx(){eo!==null&&(eo=null,hx())}function xM(){return Ia+=1,()=>{Ia-=1,Ia===0&&fx()}}function mx({href:e,children:n}){return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",onClick:s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||gM(e)&&s.preventDefault()},className:"underline decoration-white/30 underline-offset-2 hover:decoration-white/70 cursor-pointer",style:{color:"inherit",overflowWrap:"anywhere"},children:n??e})}const uY=Object.freeze(Object.defineProperty({__proto__:null,ChatLink:mx},Symbol.toStringTag,{value:"Module"}));function gx({code:e}){return t.jsxs("div",{"data-testid":"design-chat-code-block",style:{margin:"2px 0 8px",borderRadius:8,border:"1px solid rgba(255,255,255,.06)",background:"rgba(0,0,0,.18)",display:"flex",alignItems:"flex-start",gap:8,padding:"8px 8px 8px 10px"},children:[t.jsx("pre",{style:{flex:1,minWidth:0,margin:0,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11.5,lineHeight:1.6,color:"#9a9a9a",maxHeight:168,overflowY:"auto",whiteSpace:"pre-wrap",overflowWrap:"anywhere",userSelect:"text"},children:e}),t.jsx(mt,{text:e,label:"Copy",copiedLabel:"✓ Copied",className:"shrink-0 px-2.5 py-1 text-xs font-medium rounded-md bg-[var(--accent-active)] text-[var(--text-on-accent,#111)] hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity cursor-pointer"})]})}const pY=Object.freeze(Object.defineProperty({__proto__:null,DesignChatCodeBlock:gx},Symbol.toStringTag,{value:"Module"}));function wl({text:e,showMark:n=!0,bright:s=!1,warning:r=!1,tint:a}){return t.jsxs("div",{"data-testid":"design-chat-agent","data-warning":r?"true":void 0,"data-tint":a??void 0,style:{color:r?"#e5c454":a??(s?"#e8e8e8":"#a2a2a2"),maxWidth:"96%",transition:"color 300ms"},children:[n&&t.jsx("div",{style:{color:"var(--accent-active, #D7FF63)",marginBottom:5,display:"flex"},children:t.jsx(ms,{markOnly:!0,className:"h-3.5"})}),VA(vd(e)).map((o,i,c)=>{var d;return o.kind==="code"?t.jsx(gx,{code:o.value},i):t.jsx(bM,{text:o.value,bright:s,leadsCode:((d=c[i+1])==null?void 0:d.kind)==="code"},i)})]})}function bM({text:e,bright:n=!1,leadsCode:s=!1}){const r=YA(e);return t.jsx(t.Fragment,{children:r.map((a,o)=>{const i=lM(a);if(i)return t.jsx(vM,{table:i},o);const c=dM(a);return c.map((d,u)=>{if(d.kind==="list")return t.jsx(yM,{ordered:d.ordered,items:d.items,bright:n},`${o}-${u}`);const p=s&&o===r.length-1&&u===c.length-1&&/:\s*$/.test(d.text);return t.jsx("p",{"data-instruction":p?"true":void 0,style:{margin:"0 0 6px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...p?{color:"var(--accent-active, #D7FF63)",fontWeight:600}:null},children:t.jsx(to,{text:d.text,bright:n})},`${o}-${u}`)})})})}function yM({ordered:e,items:n,bright:s}){const r=e?"ol":"ul";return t.jsx(r,{style:{margin:"0 0 8px",paddingLeft:"1.2em",listStyleType:e?"decimal":"disc"},children:n.map((a,o)=>t.jsx("li",{style:{marginLeft:`${a.depth*1.1}em`,marginBottom:3,listStyleType:a.depth>0?"circle":void 0,overflowWrap:"anywhere"},children:t.jsx(to,{text:a.text,bright:s})},o))})}function vM({table:e}){const n={padding:"4px 10px",textAlign:"left",verticalAlign:"top"};return t.jsx("div",{style:{overflowX:"auto",margin:"2px 0 8px"},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:"0.95em"},children:[t.jsx("thead",{children:t.jsx("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.14)"},children:e.header.map((s,r)=>t.jsx("th",{style:{...n,color:"#d6d6d6",fontWeight:500},children:t.jsx(to,{text:s})},r))})}),t.jsx("tbody",{children:e.rows.map((s,r)=>t.jsx("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.06)"},children:s.map((a,o)=>t.jsx("td",{style:n,children:t.jsx(to,{text:a})},o))},r))})]})})}const Yh={fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:"0.92em",padding:"0 4px",borderRadius:4,background:"rgba(255,255,255,.06)",color:"#c9c9c9"};function xx({value:e}){return l.useSyncExternalStore(ZA,eM),!JA(e)||!XA()?t.jsx("code",{style:Yh,children:e}):t.jsx("button",{type:"button",onClick:()=>QA(e),title:"Open this scenario in the preview",style:{...Yh,border:"none",cursor:"pointer",color:"var(--accent-active, #D7FF63)",textDecoration:"underline",textUnderlineOffset:2,textDecorationColor:"rgba(215,255,99,.45)"},children:e})}function to({text:e,bright:n=!1}){return t.jsx(t.Fragment,{children:GA(e).map((s,r)=>s.kind==="bold"?t.jsx("strong",{style:n?{color:"#ffffff",fontWeight:600}:{color:"#d6d6d6",fontWeight:500},children:t.jsx(Vh,{text:s.value})},r):s.kind==="code"?t.jsx(xx,{value:s.value},r):t.jsx("span",{children:t.jsx(Vh,{text:s.value})},r))})}function Vh({text:e}){return t.jsx(t.Fragment,{children:hM(e).map((n,s)=>n.kind==="link"?t.jsx(mx,{href:n.value},s):t.jsx(bx,{text:n.value},s))})}function bx({text:e}){const n=l.useContext(Gr);return n?t.jsx(t.Fragment,{children:QE(e).map((s,r)=>s.kind==="reply"?t.jsx("button",{type:"button","aria-label":`Reply ${s.value}`,title:`Send "${s.value}"`,onClick:()=>n(s.value),style:{display:"inline-flex",alignItems:"center",margin:"0 1px",padding:"0 8px",borderRadius:999,border:"1px solid rgba(215,255,99,.45)",background:"rgba(215,255,99,.08)",color:"var(--accent-active, #D7FF63)",font:"inherit",fontWeight:500,lineHeight:1.5,cursor:"pointer"},children:s.value},r):t.jsx(_l,{text:s.value},r))}):t.jsx(_l,{text:e})}function _l({text:e}){return l.useSyncExternalStore(sM,rM),t.jsx(t.Fragment,{children:oM(e).map((n,s)=>n.kind==="design"&&tM(n.number)?t.jsx("button",{type:"button",onClick:()=>nM(n.number),title:"Open this design",style:{background:"none",border:"none",padding:0,font:"inherit",cursor:"pointer",color:"var(--accent-active, #D7FF63)",textDecoration:"underline",textUnderlineOffset:2,textDecorationColor:"rgba(215,255,99,.45)"},children:n.value},s):n.value)})}const hY=Object.freeze(Object.defineProperty({__proto__:null,CodeRun:xx,DesignChatAgentMessage:wl,DesignRefs:_l,QuickReplies:bx},Symbol.toStringTag,{value:"Module"}));function yx({serviceName:e,onAsk:n}){const[s,r]=l.useState("");return t.jsxs("form",{className:"xsvc-row-ask",onSubmit:a=>{a.preventDefault();const o=s.trim();n(o?`About ${e}: ${o}`:`Tell me about ${e} in this project.`),r("")},children:[t.jsx("input",{className:"xsvc-row-ask-input","aria-label":`Ask about ${e}`,placeholder:`Ask about ${e}…`,value:s,onChange:a=>r(a.target.value)}),t.jsx("button",{type:"submit",className:"xsvc-setup-btn",children:"Ask"})]})}const fY=Object.freeze(Object.defineProperty({__proto__:null,ServiceAskField:yx},Symbol.toStringTag,{value:"Module"})),Wn=300,Kh=.85,vx="codeyam:results-panel-height";function jM(){try{const e=Number(window.localStorage.getItem(vx));return Number.isFinite(e)&&e>=Wn?e:Wn}catch{return Wn}}function Jh(e){try{window.localStorage.setItem(vx,String(Math.round(e)))}catch{}}function jx({children:e}){const[n,s]=l.useState(jM),r=l.useRef(null),a=o=>{var m,g;o.preventDefault();const i=o.clientY,c=n,d=((g=(m=r.current)==null?void 0:m.parentElement)==null?void 0:g.getBoundingClientRect().height)||window.innerHeight,u=Math.max(Wn,d*Kh);let p=c;const h=x=>{p=Math.min(u,Math.max(Wn,c+(i-x.clientY))),s(p)},f=()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",f),document.body.style.cursor="",Jh(p)};document.body.style.cursor="row-resize",window.addEventListener("pointermove",h),window.addEventListener("pointerup",f)};return t.jsxs("div",{ref:r,"data-testid":"build-pane-results",style:{position:"relative",flex:"0 0 auto",height:n,maxHeight:`${Kh*100}%`,minHeight:0,display:"flex",flexDirection:"column"},children:[t.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize the results panel",title:"Drag to resize","data-testid":"results-panel-resize",onPointerDown:a,onDoubleClick:()=>{s(Wn),Jh(Wn)},className:"group absolute left-0 right-0 z-10 flex justify-center",style:{top:-4,height:9,cursor:"row-resize"},children:t.jsx("span",{"aria-hidden":"true",className:"mt-[3px] h-[3px] w-10 rounded-full bg-white/0 transition-colors group-hover:bg-white/30"})}),e]})}const mY=Object.freeze(Object.defineProperty({__proto__:null,RESULTS_PANEL_MIN_HEIGHT:Wn,ResizableResultsPanel:jx},Symbol.toStringTag,{value:"Module"})),ht="#FF8B43",no="waiting on you",so="Waiting on you";function wx({title:e,body:n,nextAction:s,actionLabel:r,onAction:a,pending:o=!1,feedback:i,variant:c}){const{projectDir:d,inContainer:u,loaded:p}=Co(),h=hR({headline:e,explanation:n,nextAction:s,connection:p?fR(d,u):null});return t.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":c,className:"absolute inset-0 z-50 flex items-center justify-center p-6 animate-in fade-in duration-300",style:{background:"var(--bg-deep, #1b1b1b)"},children:t.jsxs("div",{role:"alert","aria-label":e,"data-testid":"preview-unhealthy-notice",className:"flex max-w-xs flex-col items-center text-center",children:[t.jsx("span",{"aria-hidden":"true",style:{width:8,height:8,borderRadius:"50%",background:ht,marginBottom:12}}),t.jsx("h3",{className:"text-[14px] font-medium text-[var(--text-primary)]",children:e}),t.jsx("p",{className:"mt-1.5 text-[12.5px] leading-relaxed text-[var(--text-muted)]",children:n}),a&&t.jsx("button",{type:"button","data-testid":"preview-unhealthy-overlay-retry",onClick:a,disabled:o,className:"mt-4 rounded-lg px-4 py-1.5 text-[12.5px] font-medium transition-opacity hover:opacity-90 disabled:opacity-60",style:{background:"var(--accent-active, #D7FF63)",color:"#1a1a1a"},children:o?"Checking…":r}),i&&t.jsx("p",{className:"mt-2 text-[11.5px] text-[var(--text-muted)]",children:i}),t.jsx(mt,{text:h,label:"Copy details",copiedLabel:"Copied",variant:"subtle",className:"mt-3 text-[11.5px] text-[var(--text-dim)] underline underline-offset-2 hover:text-[var(--text-secondary)]"})]})})}const gY=Object.freeze(Object.defineProperty({__proto__:null,PreviewStuckPanel:wx},Symbol.toStringTag,{value:"Module"}));function _x({title:e,body:n}){return t.jsxs("section",{"data-testid":"plan-preview-card","aria-label":`Plan: ${e}`,style:{border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.04)",borderRadius:10,padding:"12px 14px",marginBottom:10},children:[t.jsx("div",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:"var(--text-dim)",marginBottom:4},children:"The plan"}),t.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",marginBottom:6},children:e}),t.jsx("div",{style:{maxHeight:260,overflowY:"auto",fontSize:12.5,color:"var(--text-secondary)"},children:t.jsx(Lt,{variant:"document",children:n})})]})}const xY=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewCard:_x},Symbol.toStringTag,{value:"Module"}));function Wt({size:e=16}){return t.jsx("span",{"aria-hidden":"true","data-testid":"design-session-spinner",className:"animate-spin",style:{display:"inline-block",flex:"none",width:e,height:e,borderRadius:"50%",border:`${e>=24?3:2}px solid rgba(111,255,0,.18)`,borderTopColor:"var(--working)"}})}const bY=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionSpinner:Wt},Symbol.toStringTag,{value:"Module"}));function Kn({variant:e="sequence"}){return e==="pulse"?t.jsx("span",{"aria-hidden":"true","data-testid":"loading-dots","data-variant":"pulse",className:"animate-pulse motion-reduce:animate-none",style:{display:"inline-flex",marginLeft:1},children:"..."}):t.jsxs("span",{"aria-hidden":"true","data-testid":"loading-dots","data-variant":"sequence",className:"cy-loading-dots",style:{display:"inline-flex",marginLeft:1},children:[t.jsx("style",{children:`
|
|
10
|
-
@keyframes cy-loading-dot {
|
|
11
|
-
0%, 20% { opacity: .15; }
|
|
12
|
-
40%, 70% { opacity: 1; }
|
|
13
|
-
100% { opacity: .15; }
|
|
14
|
-
}
|
|
15
|
-
.cy-loading-dots > i {
|
|
16
|
-
font-style: normal;
|
|
17
|
-
opacity: .15;
|
|
18
|
-
animation: cy-loading-dot 1.4s infinite ease-in-out both;
|
|
19
|
-
}
|
|
20
|
-
.cy-loading-dots > i:nth-child(2) { animation-delay: .2s; }
|
|
21
|
-
.cy-loading-dots > i:nth-child(3) { animation-delay: .4s; }
|
|
22
|
-
@media (prefers-reduced-motion: reduce) {
|
|
23
|
-
.cy-loading-dots > i { animation: none; opacity: .6; }
|
|
24
|
-
}
|
|
25
|
-
`}),t.jsx("i",{children:"."}),t.jsx("i",{children:"."}),t.jsx("i",{children:"."})]})}const yY=Object.freeze(Object.defineProperty({__proto__:null,LoadingDots:Kn},Symbol.toStringTag,{value:"Module"}));function ro({name:e}){return t.jsxs("div",{role:"status","data-testid":"formalize-handoff",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,padding:24,textAlign:"center",background:"var(--bg-deep, #1e1e1e)"},children:[t.jsx(Wt,{size:18}),t.jsxs("div",{style:{fontSize:15,fontWeight:500,color:"var(--text-primary)"},children:["Preparing to finalize ",e?t.jsx("span",{children:e}):"your prototype",t.jsx(Kn,{})]}),t.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",maxWidth:420,lineHeight:1.5},children:"The agent is writing the plan. Build opens on its own when it's ready."})]})}const vY=Object.freeze(Object.defineProperty({__proto__:null,FormalizeHandoffPanel:ro},Symbol.toStringTag,{value:"Module"}));function Sx(e){const n=e.trim().toLowerCase().replace(/^[a-z]+:\/\//,"").replace(/[/?#].*$/,"").replace(/^www\./,"");return/^[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}$/.test(n)?n:null}function kx({onSave:e}){const[n,s]=l.useState(!1),[r,a]=l.useState(""),[o,i]=l.useState(null),[c,d]=l.useState(!1);if(!n)return t.jsx("button",{type:"button",className:"xsvc-setup-alt",onClick:()=>s(!0),children:"I already have one"});const u=async p=>{p.preventDefault();const h=Sx(r);if(!h){i("Enter a domain like elcarot.com");return}d(!0);try{await e(h)}catch(f){i(f instanceof Error?f.message:"Couldn't save it. Try again."),d(!1)}};return t.jsxs("form",{className:"xsvc-domain-form",onSubmit:p=>void u(p),children:[t.jsx("input",{autoFocus:!0,"aria-label":"Your domain",className:"xsvc-domain-input",placeholder:"yourdomain.com",value:r,onChange:p=>{a(p.target.value),i(null)}}),t.jsx("button",{type:"submit",className:"xsvc-setup-btn",disabled:c,children:c?"Saving…":"Save"}),o&&t.jsx("span",{role:"alert",className:"xsvc-domain-error",children:o})]})}const jY=Object.freeze(Object.defineProperty({__proto__:null,DomainCardEntry:kx,normalizeDomainInput:Sx},Symbol.toStringTag,{value:"Module"}));function Io({login:e,onSubmitCode:n,onOpenTerminal:s}){const[r,a]=l.useState(""),o=r.trim(),i=()=>{o&&(n(o),a(""))};return t.jsxs("div",{role:"group","aria-label":"The agent is waiting for you to sign in","data-testid":"design-chat-terminal-login",style:{border:"1px solid rgba(255,139,67,.4)",background:"rgba(255,139,67,.06)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,fontSize:13,color:"var(--text-secondary)"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:ht},children:"Needs you to sign in"}),t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500},children:"Sign in to continue"}),t.jsx("div",{style:{lineHeight:1.45},children:e.url?"Open the sign-in page, sign in, then paste the code it shows here.":"Sign in from the terminal, then paste the code the sign-in page shows here."}),e.url&&t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{alignSelf:"flex-start",padding:"5px 12px",borderRadius:8,background:"var(--accent-active, #D7FF63)",color:"#141414",fontSize:12.5,fontWeight:500,textDecoration:"none"},children:"Open the sign-in page"}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{type:"text","aria-label":"Sign-in code",placeholder:"Paste the code",value:r,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&i()},style:{flex:1,minWidth:0,padding:"5px 8px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"rgba(0,0,0,.2)",color:"var(--text-primary)",fontSize:12.5}}),t.jsx("button",{type:"button",onClick:i,disabled:!o,style:{padding:"5px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:o?"var(--text-primary)":"var(--text-muted)",fontSize:12.5,cursor:o?"pointer":"default"},children:"Send code"})]}),t.jsx("div",{style:{display:"flex",fontSize:11.5},children:t.jsx("button",{type:"button",onClick:s,style:{marginLeft:"auto",background:"none",border:"none",padding:0,color:"var(--text-secondary)",textDecoration:"underline",cursor:"pointer",fontSize:11.5},children:"Open Terminal"})})]})}const wY=Object.freeze(Object.defineProperty({__proto__:null,DesignChatTerminalLogin:Io},Symbol.toStringTag,{value:"Module"}));function Nx({sessionName:e,onCancel:n,onConfirm:s}){return l.useEffect(()=>{const r=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),t.jsx("div",{role:"presentation",onClick: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:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`Close this ${e}?`,"data-testid":"close-session-confirm",onClick:r=>r.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(420px, 100%)",display:"flex",flexDirection:"column",gap:12,boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[t.jsxs("div",{style:{fontSize:15,fontWeight:600,color:"var(--text-primary)"},children:["Close this ",e,"?"]}),t.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:"var(--text-secondary)"},children:"The chat closes and you go back to the start of this tab. What you asked for stays in the box, so you can pick it up again."}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,autoFocus:!0,style:{padding:"6px 14px",borderRadius:8,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-primary)",fontSize:13,cursor:"pointer"},children:"Keep working"}),t.jsx("button",{type:"button",onClick:s,style:{padding:"6px 14px",borderRadius:8,border:"1px solid var(--accent-danger, #f87171)",background:"transparent",color:"var(--accent-danger, #f87171)",fontSize:13,cursor:"pointer"},children:"Close session"})]})]})})}const _Y=Object.freeze(Object.defineProperty({__proto__:null,CloseSessionConfirmModal:Nx},Symbol.toStringTag,{value:"Module"})),Dn="#8ab4f8";function wM(e){for(const n of e??[]){const s=/\b(\d+)\s+(?:shells?|background (?:tasks?|shells?)|tasks?)\s+still running/i.exec(n);if(s)return Number(s[1])}return 0}function Cx(e){if(e<60)return`${e}s`;const n=Math.floor(e/60);return n<60?`${n}m ${e%60}s`:`${Math.floor(n/60)}h ${n%60}m`}const Tx="Check on the background task and continue where you left off.";function Px({since:e,onCheck:n}){const[s,r]=l.useState(()=>Date.now());l.useEffect(()=>{const o=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(o)},[]);const a=Math.max(0,Math.floor((s-e)/1e3));return t.jsxs("div",{role:"status","data-testid":"agent-chat-background-task",style:{border:`1px solid ${Dn}55`,background:`${Dn}12`,borderRadius:10,padding:"9px 12px",fontSize:12.5,color:Dn,display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:Dn,flex:"none"}}),t.jsxs("span",{style:{flex:1,minWidth:0},children:["Waiting for a background task (",Cx(a),"). The agent goes on by itself when it finishes."]}),n&&t.jsx("button",{type:"button",onClick:n,className:"hover:opacity-90",style:{border:`1px solid ${Dn}88`,background:"transparent",color:Dn,borderRadius:8,padding:"3px 10px",fontSize:12,cursor:"pointer"},children:"Check on it"})]})}const SY=Object.freeze(Object.defineProperty({__proto__:null,BackgroundTaskCard:Px,CHECK_BACKGROUND_TASK:Tx},Symbol.toStringTag,{value:"Module"}));function Xh(e){return/^\s*API Error\b/i.test(e)}const _M="Continue where you left off.";function Ox({text:e}){const n=l.useContext(Gr);return t.jsxs("div",{"data-testid":"agent-error-reply",role:"status",style:{border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.045)",borderRadius:10,padding:"12px 14px",display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-primary)",fontSize:13},children:[t.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:ht,flex:"none"}}),"The connection to the agent dropped"]}),t.jsx("div",{style:{color:"var(--text-muted)",fontSize:12.5},children:"It stopped before finishing, so nothing is running now. Ask it to pick up where it left off."}),n&&t.jsx("button",{type:"button",onClick:()=>n(_M),className:"hover:opacity-90",style:{alignSelf:"flex-start",marginTop:4,padding:"5px 14px",borderRadius:8,border:"none",background:"var(--accent-active, #D7FF63)",color:"#1a1a1a",fontSize:12.5,fontWeight:500,cursor:"pointer"},children:"Continue"}),t.jsx("div",{style:{color:"var(--text-dim)",fontSize:11.5,marginTop:2},children:e})]})}const kY=Object.freeze(Object.defineProperty({__proto__:null,AgentErrorReply:Ox},Symbol.toStringTag,{value:"Module"}));function Rx({row:e,ideaTotal:n}){var o;const s=((o=e.evidenceIds)==null?void 0:o.length)??0,r=e.evidenceSessions??0,a=(i,c)=>`${i} ${c}${i===1?"":"s"}`;return t.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]","data-testid":`feature-idea-evidence-${e.id}`,children:["Backed by ",a(s,"observation")," across"," ",a(r,"session"),e.ideaRank!==void 0&&n?t.jsxs("span",{className:"text-[var(--text-dim)]",children:[" ","· #",e.ideaRank," of ",n," feature ideas"]}):null]})}const NY=Object.freeze(Object.defineProperty({__proto__:null,FeatureIdeaEvidence:Rx},Symbol.toStringTag,{value:"Module"}));function Ex({id:e,note:n}){return n?t.jsx("p",{className:"text-[11px] text-[var(--text-dim)] mt-1","data-testid":`codeyam-improvement-decision-${e}`,children:n}):null}const CY=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementDecisionNote:Ex},Symbol.toStringTag,{value:"Module"}));function Ax({spaced:e,children:n}){return t.jsxs("div",{className:e?"mt-3":void 0,"data-testid":"codeyam-improvements-decided",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-1 text-[var(--text-dim)]",children:"Already sent or dismissed"}),t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:"These kept happening after you sent or dismissed them. Copy sends an updated report with the new count."}),t.jsx("ul",{className:"flex flex-col gap-2",children:n})]})}const TY=Object.freeze(Object.defineProperty({__proto__:null,DecidedCodeyamImprovements:Ax},Symbol.toStringTag,{value:"Module"}));function Mx({count:e}){return e<=0?null:t.jsxs("div",{className:"text-[10px] leading-snug text-[var(--text-muted)]","data-testid":"generated-glue-count",children:[e," generated isolation ",e===1?"file":"files"," changed — not product components, so not shown."]})}const PY=Object.freeze(Object.defineProperty({__proto__:null,GeneratedGlueNotice:Mx},Symbol.toStringTag,{value:"Module"}));function SM(e,n,s){if(n==="route-unwired"){const r=`scripts/gcp/vm-ingress.sh ${s??"<N>"} up`;return{headline:"This preview's host isn't routing the session handoff",explanation:"The editor tried to hand this preview a session, but the preview's host sends the handoff to the app instead of the editor. Nothing in the browser can fix that.",nextAction:`Whoever runs this deployment needs to route the handoff to the editor. On a CodeYam fleet VM, an operator runs ${r} (see docs/fleet-operations.md).`,command:r,offerReconnect:!1,feedback:null}}return{headline:"This preview has no editor session",explanation:e==="never-authenticated"?"The editor never handed this preview a session, so its live data can't load. No restart signed it out.":"The editor no longer recognizes this preview's session, so its live data can't load.",nextAction:"Ask the editor to reconnect this preview. Reloading the preview alone won't help — only the editor can hand it a session.",command:null,offerReconnect:!0,feedback:n==="failed"?"The editor couldn't reconnect this preview. Reload the editor tab itself (not the preview) and try again.":null}}function Ix({reason:e,reconnect:n,vmNumber:s,onReconnect:r}){const a=SM(e,n,s),o=a.command?t.jsxs(t.Fragment,{children:[a.nextAction.slice(0,a.nextAction.indexOf(a.command)),t.jsx("code",{children:a.command}),a.nextAction.slice(a.nextAction.indexOf(a.command)+a.command.length)]}):a.nextAction;return t.jsx(Bt,{severity:"warning",testId:"session-lost-notice",headline:a.headline,explanation:a.explanation,nextAction:o,nextActionText:a.nextAction,actions:a.offerReconnect?[{label:"Ask the editor to reconnect this preview",onClick:()=>r==null?void 0:r(),testId:"session-lost-reconnect",pending:n==="pending",pendingLabel:"Asking the editor…"}]:void 0,actionFeedback:a.feedback})}const OY=Object.freeze(Object.defineProperty({__proto__:null,SessionLostFramedNotice:Ix},Symbol.toStringTag,{value:"Module"})),kM={feature:"Feature",fix:"Fix",debt:"Tech debt"};function Dx({id:e,category:n}){return n===void 0?null:t.jsx("span",{className:"inline-block self-start px-1.5 py-px rounded border text-[10px] font-semibold uppercase tracking-wide border-[var(--border-default)] text-[var(--text-secondary)]","data-testid":`proposed-plan-category-${e}`,"data-category":n,children:kM[n]})}const RY=Object.freeze(Object.defineProperty({__proto__:null,ProposalCategoryTag:Dx},Symbol.toStringTag,{value:"Module"})),Hn="text-[10px] uppercase tracking-wide px-2 py-0.5 rounded border cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed transition",Lx=" border-[var(--accent-primary)] text-[var(--accent-primary)] hover:bg-[var(--accent-primary)] hover:text-[var(--surface-bg)]",ao=" border-[var(--border-default)] text-[var(--text-muted)] hover:text-[var(--text-primary)]",$x=" border-[var(--accent-danger,#f87171)] text-[var(--accent-danger,#f87171)] hover:bg-[var(--accent-danger,#f87171)] hover:text-[var(--surface-bg)]";function Fx({id:e,copied:n,confirming:s,busyAction:r,hasReport:a,copyFailed:o,canIgnore:i=!0,onCopy:c,onRequestIgnore:d,onConfirmIgnore:u,onCancelIgnore:p}){if(n)return t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-success,#4ade80)]","data-testid":`codeyam-improvement-copied-${e}`,children:"Copied — thanks!"});if(r==="ignore")return t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--text-muted)]",children:"Discarding…"});if(s)return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"Discard?"}),t.jsx("button",{type:"button",className:Hn+$x,onClick:u,"data-testid":`codeyam-improvement-confirm-ignore-${e}`,children:"Discard"}),t.jsx("button",{type:"button",className:Hn+ao,onClick:p,"data-testid":`codeyam-improvement-keep-${e}`,children:"Keep"})]});const h=r!==void 0;return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:Hn+Lx,disabled:h||!a,onClick:c,"data-testid":`codeyam-improvement-copy-${e}`,children:o?"Copy blocked":"Copy"}),i&&t.jsx("button",{type:"button",className:Hn+ao,disabled:h,onClick:d,"data-testid":`codeyam-improvement-ignore-${e}`,children:"Ignore"})]})}const EY=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementRowActions:Fx},Symbol.toStringTag,{value:"Module"}));function Sl(e){return!!e.decidedAt&&(e.status==="copied"||e.status==="ignored")}function NM(e){const n=e.status==="copied"?"Copied":e.status==="ignored"?"Ignored":null;if(!n)return null;const s=e.decidedAt?CM(e.decidedAt):null,r=s?`${n} ${s}`:n,a=e.sightingsAtDecision===void 0?0:Math.max(0,(e.sightings??0)-e.sightingsAtDecision);return a===0?r:`${r} · seen ${a} more ${a===1?"time":"times"} since`}function CM(e){const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"})}function Nd(e){return(e??0)>=2}function zx({id:e,sightings:n}){return Nd(n)?t.jsxs("span",{className:"text-[11px] text-[var(--text-dim)]","data-testid":`codeyam-improvement-sightings-${e}`,children:["Seen in ",n," sessions"]}):null}const AY=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementSightings:zx,isRecurringImprovement:Nd},Symbol.toStringTag,{value:"Module"}));function Bx(e){if(e.category)return e.category;if(e.kind==="feature")return"feature";if(e.kind==="tech-debt")return"debt"}function TM(e){return e>=4?"high":e===3?"medium":"low"}const PM={low:"Low Severity",medium:"Medium Severity",high:"High Severity"},OM={low:"Low Value",medium:"Medium Value",high:"High Value"};function RM(e){return e.source==="deferred-deliverable"||e.source==="feature-synthesis"||Bx(e)==="feature"?"value":"severity"}const EM={low:"var(--accent-yellow)",medium:"var(--accent-orange)",high:"var(--accent-red)"},AM={low:"color-mix(in srgb, var(--accent-green) 50%, white)",medium:"var(--accent-green)",high:"color-mix(in srgb, var(--accent-green) 70%, black)"};function Cd({id:e,severity:n,kind:s="severity"}){if(n===void 0)return null;const r=TM(n),a=s==="value";return t.jsx("span",{className:"inline-block self-start px-1.5 py-px rounded text-[10px] font-semibold uppercase tracking-wide",style:{background:(a?AM:EM)[r],color:"var(--text-on-accent)"},"data-testid":`proposed-plan-severity-${e}`,"data-severity":n,"data-severity-tier":r,"data-grade-kind":s,children:(a?OM:PM)[r]})}const MY=Object.freeze(Object.defineProperty({__proto__:null,ProposedPlanSeverityBadge:Cd},Symbol.toStringTag,{value:"Module"}));function Wx({row:e,report:n,busyAction:s,confirming:r,error:a,onCopied:o,onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d,writer:u}){const{failed:p,copy:h}=To({writer:u}),f=Nd(e.sightings),m=Sl(e),g=m?NM(e):null,[x,b]=l.useState(!1),y=m?x:e.status==="copied";return t.jsxs("li",{className:"p-2.5 rounded-md flex flex-col gap-1.5",style:{background:"var(--bg-deep)",border:"1px solid var(--border-subtle)"},"data-testid":`codeyam-improvement-${e.id}`,"data-status":e.status??"pending",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-snug",children:e.title}),e.reason&&t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mt-0.5",children:e.reason}),(e.severity!==void 0||f)&&t.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.severity!==void 0&&t.jsx(Cd,{id:e.id,severity:e.severity,kind:"severity"}),t.jsx(zx,{id:e.id,sightings:e.sightings})]}),t.jsx(Ex,{id:e.id,note:g})]}),!(m&&e.status==="ignored")&&t.jsx("div",{className:"shrink-0 flex items-center gap-1.5 pt-0.5",children:t.jsx(Fx,{id:e.id,copied:y,confirming:r,busyAction:s,hasReport:!!n,copyFailed:p,canIgnore:!m,onCopy:()=>{n&&h(n).then(v=>{v&&(m&&b(!0),o())})},onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d})})]}),r&&t.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"It won't be offered again."}),t.jsx(dt,{text:a,copyText:a,testId:`codeyam-improvement-error-${e.id}`})]})}const IY=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementRow:Wx},Symbol.toStringTag,{value:"Module"}));function Hx({count:e,expanded:n,onToggle:s,children:r,decided:a=null}){const o=e>0?`View all CodeYam improvements (${e})`:"View CodeYam improvements already sent or dismissed";return t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{type:"button",className:"text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] underline underline-offset-2","aria-expanded":n,"data-testid":"codeyam-improvements-view-all",onClick:s,children:n?"Hide CodeYam improvements":o}),n&&t.jsxs("div",{className:"mt-2","data-testid":"codeyam-improvements-tracked",children:[e>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:"These are rough edges CodeYam has hit in earlier sessions too. Copy any you'd like to send."}),t.jsx("ul",{className:"flex flex-col gap-2",children:r})]}),a&&t.jsx(Ax,{spaced:e>0,children:a})]})]})}const DY=Object.freeze(Object.defineProperty({__proto__:null,TrackedCodeyamImprovements:Hx},Symbol.toStringTag,{value:"Module"})),MM={margin:"10px 12px 0",padding:"8px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.04)",color:"var(--text-secondary)",fontSize:12.5,lineHeight:1.45,display:"flex",gap:8,alignItems:"flex-start"},IM={background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:0,fontSize:14,lineHeight:1};function kl({children:e,onDismiss:n,testId:s,role:r}){return t.jsxs("div",{role:r,"data-testid":s,style:MM,children:[t.jsx("span",{style:{flex:1},children:e}),t.jsx("button",{type:"button","aria-label":"Dismiss",onClick:n,style:IM,children:"×"})]})}const LY=Object.freeze(Object.defineProperty({__proto__:null,AgentChatNotice:kl},Symbol.toStringTag,{value:"Module"}));function Vr({width:e,height:n,scale:s,filled:r=!1,className:a,children:o}){const i=s<1?s:1;return t.jsx("div",{"data-scaled-viewport":"outer",className:r?"w-full h-full":void 0,style:r?void 0:{width:e*i,height:n*i,flexShrink:0,position:"relative"},children:t.jsx("div",{"data-scaled-viewport":"inner",className:r?"w-full h-full":a,style:r?void 0:{width:e,height:n,transform:i<1?`scale(${i})`:void 0,transformOrigin:"top left"},children:o})})}const $Y=Object.freeze(Object.defineProperty({__proto__:null,ScaledViewport:Vr},Symbol.toStringTag,{value:"Module"})),Qh="Next valid action: ";function DM(e){const n=e.split(`
|
|
26
|
-
`).map(r=>r.trim()).find(r=>r.startsWith(Qh)),s=n==null?void 0:n.slice(Qh.length).trim();return s||null}function qx({failure:e}){const n=DM(e),s=n?`To clear it, run: ${n}`:"Copy this report and hand it to the operator; the details below name the queue entry to release.";return t.jsx(Bt,{severity:"warning",testId:"proposed-plans-head-release-warning",className:"mt-2 flex flex-col gap-2 rounded border border-l-4 px-3 py-2 text-xs",headline:"Commit-queue slot still held",explanation:"The plan was written and pushed, but this machine could not give up its place at the front of the commit queue. Other machines wait behind it until it is cleared.",nextAction:n?t.jsxs(t.Fragment,{children:["To clear it, run ",t.jsx("code",{className:"font-mono",children:n})]}):s,nextActionText:s,diagnostics:e})}const FY=Object.freeze(Object.defineProperty({__proto__:null,HeadReleaseWarning:qx},Symbol.toStringTag,{value:"Module"})),LM={keep:"Keep",iterate:"Iterate",versions:"Multiple versions",replace:"Replace"},$M={keep:"Carry it into the next round unchanged",iterate:"Refine it in place, applying its notes",versions:"Make several variations of it",replace:"Redesign this slot from scratch"},Zh=e=>({padding:"3px 9px",borderRadius:999,border:`1px solid ${e?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.14)"}`,background:e?"rgba(215,255,99,.14)":"transparent",color:e?"var(--text-primary)":"var(--text-secondary)",fontSize:12,cursor:"pointer"});function Ux({row:e,onChoose:n,disabled:s=!1}){const{decision:r}=e;return t.jsxs("div",{"data-testid":"design-decision-row",style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[t.jsx("span",{style:{color:"rgba(255,255,255,.45)",fontVariantNumeric:"tabular-nums"},children:String(e.number).padStart(2,"0")}),t.jsx("span",{style:{color:"var(--text-primary)",overflowWrap:"anywhere"},children:e.name}),e.suggested&&t.jsx("span",{"data-testid":"design-decision-suggested",style:{fontSize:10.5,color:"var(--accent-active, #D7FF63)",whiteSpace:"nowrap"},children:"suggested"})]}),t.jsx("div",{role:"group","aria-label":`What to do with ${e.name}`,style:{display:"flex",flexWrap:"wrap",gap:5},children:Vg.map(a=>t.jsx("button",{type:"button","aria-pressed":r.verb===a,title:$M[a],disabled:s,onClick:()=>n(a),style:Zh(r.verb===a),children:LM[a]},a))}),r.verb==="versions"&&t.jsxs("div",{role:"group","aria-label":`How many versions of ${e.name}`,style:{display:"flex",alignItems:"center",gap:5,fontSize:12},children:["How many?",Kg.map(a=>t.jsx("button",{type:"button","aria-pressed":r.count===a,disabled:s,onClick:()=>n("versions",a),style:{...Zh(r.count===a),minWidth:28},children:a},a))]})]})}const zY=Object.freeze(Object.defineProperty({__proto__:null,DesignDecisionRow:Ux},Symbol.toStringTag,{value:"Module"}));function Td({href:e=typeof window<"u"?window.location.href:""}){return t.jsx("div",{"data-testid":"embedded-terminal-notice",className:"w-full h-full flex items-center justify-center text-center px-6",style:{background:"var(--bg-deep)",color:"var(--text-dim)"},children:t.jsxs("div",{className:"text-sm leading-relaxed",children:[t.jsx("div",{className:"font-medium",children:"The agent terminal is off inside an embedded preview"}),t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block mt-2 underline",style:{color:"var(--text-primary)"},children:"Open in a new tab"})]})})}const BY=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedTerminalNotice:Td},Symbol.toStringTag,{value:"Module"})),FM={spawned:"Started the agent's terminal",reattached:"Reconnected to an agent that was already running","prompt-written":"Typed the startup command","banner-ready":"The agent showed it was ready","prompt-accepted":"The agent accepted its prompt","prompt-rejected":"The agent rejected its prompt","startup-failed":"The agent failed to start","worker-ack":"The agent confirmed it is working"},ef={"inject-initial":"The editor typed /codeyam-editor","inject-retry":"The editor typed /codeyam-editor again","ui-escape":"The Build tab pressed Esc","ui-clear":"The Build tab typed /clear","ui-skill":"The Build tab typed /codeyam-editor"};function zM(e){if(e.event==="prompt-written"&&e.kind&&ef[e.kind])return ef[e.kind];const n=FM[e.event]??e.event,s=e.reason??e.kind;return s?`${n} (${s})`:n}function Gx({events:e}){return t.jsx("ol",{"data-testid":"build-launch-log",className:"mt-2 space-y-1 rounded border border-[var(--border)] p-3 text-xs text-[var(--text-dim)]",children:e.length===0?t.jsx("li",{children:"Nothing was recorded for this launch."}):e.map((n,s)=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-[var(--text-muted)]",children:new Date(n.ts).toLocaleTimeString()})," ",zM(n)]},`${n.ts}-${s}`))})}const WY=Object.freeze(Object.defineProperty({__proto__:null,BuildLaunchLog:Gx},Symbol.toStringTag,{value:"Module"}));function Yx(){return t.jsxs("div",{className:"rounded border border-dashed border-[var(--border-default)] bg-[var(--bg-card)] px-3 py-2 text-xs text-[var(--text-secondary)] leading-relaxed",children:[t.jsx("span",{className:"font-semibold text-[var(--text-primary)]",children:"Nothing on this page is linked to content yet."})," ","Its template has no content markers, so its text can't be edited by clicking it — use the side panel instead. To make it editable here, add the ",t.jsx("code",{className:"font-mono",children:"data-cms-entry"})," and"," ",t.jsx("code",{className:"font-mono",children:"data-cms-field"})," attributes from the “Content markers” table in @codeyam/cms's CMS_SETUP.md."]})}const HY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentNoMarkersHint:Yx},Symbol.toStringTag,{value:"Module"}));function BM(e){const n={};for(const s of e.collections??[])n[s.id]=Object.fromEntries(s.fields.map(r=>[r.name,{label:r.label,type:r.type}]));return n}function tf(e,n){if(e){const s=e.indexOf("/");if(s>0&&s<e.length-1)return{collection:e.slice(0,s),slug:e.slice(s+1)}}return n}function Bi(e,n){return!!e&&!!n&&e.collection===n.collection&&e.slug===n.slug}function WM(e,n){return e==="list"?n.split(",").map(s=>s.trim()).filter(Boolean):n}const HM=new Set(["text","textarea"]);function qM(e){return e.kind==="body"?"body":e.kind==="html"?"field":e.kind!=="field"?null:e.type&&!HM.has(e.type)?"field":null}function UM(e,n,s,r){return n==="body"?{...e,body:String(r)}:{...e,fields:{...e.fields,[s]:r}}}function GM(e){return e===1?"1 editable region":`${e} editable regions`}function nf(e,n){return{x:e.x*n,y:e.y*n,width:e.width*n,height:e.height*n}}function Vx({on:e,onChange:n}){return t.jsxs("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>n==null?void 0:n(!e),className:`flex items-center gap-1.5 px-2.5 py-0.5 rounded-full border ${e?"border-[var(--accent-primary)] text-[var(--accent-primary)] bg-[var(--lime-soft)]":"border-[var(--border-default)] text-[var(--text-secondary)]"}`,children:[t.jsx("span",{"aria-hidden":!0,className:`relative inline-block w-5 h-3 rounded-full ${e?"bg-[var(--accent-primary)]":"bg-[var(--border-default)]"}`,children:t.jsx("span",{className:"absolute top-0.5 w-2 h-2 rounded-full bg-[var(--bg-deep)]",style:{left:e?10:2}})}),"Edit on page"]})}const qY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEditSwitch:Vx},Symbol.toStringTag,{value:"Module"}));function Kx({address:e,editOnPage:n,regionCount:s,screenSizes:r,screenSize:a,onEditOnPageChange:o,onScreenSizeChange:i}){return t.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-dim)]",children:[t.jsx("span",{className:"flex-1 truncate font-mono",children:e}),n!==void 0?t.jsx(Vx,{on:n,onChange:o}):null,n&&s!==null?t.jsx("span",{className:"px-2.5 py-0.5 rounded-full border border-[var(--border-default)] text-[var(--text-secondary)]",children:GM(s)}):null,t.jsx("select",{value:a,"aria-label":"Screen size",onChange:c=>i==null?void 0:i(c.target.value),className:"text-xs px-1.5 py-0.5 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)]",children:r.map(c=>t.jsx("option",{value:c.name,children:c.name},c.name))})]})}const UY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPreviewHeader:Kx},Symbol.toStringTag,{value:"Module"}));function YM({anchor:e,paneWidth:n,paneHeight:s,width:r,estimatedHeight:a}){const o=Math.min(r,Math.max(260,n-16)),i=Math.max(8,Math.min(e.x,n-o-8)),c=e.y+e.height+10,d=e.y-10-a,u=c+a<=s?c:d>=0?d:Math.max(8,Math.min(e.y,s-a-8));return{left:i,top:u,width:o}}function Jx({saving:e=!1,onSave:n,onCancel:s}){return t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-[var(--border-subtle)]",children:[t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"Esc to cancel · ⌘S to save"}),t.jsxs("span",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:s,className:"text-xs px-2.5 py-1 rounded text-[var(--text-secondary)] hover:bg-[var(--bg-card)]",children:"Cancel"}),t.jsx("button",{type:"button",disabled:e,onClick:n,className:"text-xs px-3 py-1 rounded font-semibold bg-[var(--accent-primary)] text-[var(--text-on-accent)] disabled:opacity-60",children:e?"Saving…":"Save"})]})]})}const GY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPopoverFooter:Jx},Symbol.toStringTag,{value:"Module"}));function Pd({anchor:e,paneWidth:n,paneHeight:s,width:r=460,estimatedHeight:a=200,title:o,meta:i,saving:c=!1,error:d,onSave:u,onCancel:p,children:h}){const f=YM({anchor:e,paneWidth:n,paneHeight:s,width:r,estimatedHeight:a});return t.jsxs("div",{role:"dialog","aria-label":`Edit ${o}`,className:"absolute z-10 rounded-lg border border-[var(--border-default)] bg-[var(--bg-surface)] shadow-2xl",style:f,onKeyDown:m=>{m.key==="Escape"?(m.preventDefault(),p()):(m.metaKey||m.ctrlKey)&&m.key.toLowerCase()==="s"&&(m.preventDefault(),u())},children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-3 py-2 border-b border-[var(--border-subtle)]",children:[t.jsx("span",{className:"text-sm font-semibold text-[var(--text-primary)]",children:o}),i?t.jsx("span",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:i}):null]}),t.jsx("div",{className:"p-3",children:h}),t.jsx(dt,{text:d,rowClassName:"px-3 pb-2"}),t.jsx(Jx,{saving:c,onSave:u,onCancel:p})]})}const YY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentAnchoredPopover:Pd},Symbol.toStringTag,{value:"Module"})),Vt="w-full text-sm px-2 py-1.5 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-primary)]";function Od({def:e,value:n,onChange:s}){const r=Array.isArray(n)?n.join(", "):n??"",a=`sc-field-${e.name}`;switch(e.type){case"textarea":case"html":return t.jsx("textarea",{id:a,value:r,rows:e.type==="html"?5:3,onChange:o=>s(o.target.value),className:`${Vt} ${e.type==="html"?"font-mono text-xs":""}`});case"date":return t.jsx("input",{id:a,type:"date",value:r.slice(0,10),onChange:o=>s(o.target.value),className:Vt});case"list":return t.jsx("input",{id:a,value:r,placeholder:"Comma-separated",onChange:o=>s(o.target.value.split(",").map(i=>i.trim()).filter(Boolean)),className:Vt});case"image":return t.jsx("input",{id:a,value:r,placeholder:"/images/…",onChange:o=>s(o.target.value),className:`${Vt} font-mono text-xs`});default:return t.jsx("input",{id:a,value:r,onChange:o=>s(o.target.value),className:Vt})}}const VY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentFieldInput:Od,siteContentInputClass:Vt},Symbol.toStringTag,{value:"Module"}));function Xx({anchor:e,paneWidth:n,paneHeight:s,def:r,entryLabel:a,initialValue:o,saving:i,error:c,onSave:d,onCancel:u}){const[p,h]=l.useState(o);return t.jsx(Pd,{anchor:e,paneWidth:n,paneHeight:s,width:r.type==="html"?480:320,estimatedHeight:r.type==="html"?260:150,title:r.label??r.name,meta:[r.type??"text",a].filter(Boolean).join(" · "),saving:i,error:c,onSave:()=>d(p??""),onCancel:u,children:t.jsx(Od,{def:r,value:p,onChange:h})})}const KY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentFieldPopover:Xx},Symbol.toStringTag,{value:"Module"}));function VM(e,n){const s=new Set(e.map(a=>a.name)),r=Object.keys(n.fields).filter(a=>!s.has(a)).map(a=>({name:a,type:"text"}));return[...e,...r]}function KM(e,n,s,r,a){return e.slice(0,n)+r+e.slice(n,s)+a+e.slice(s)}function JM({saveStatus:e,saveError:n,dirty:s,modified:r}){return e==="saving"?"Saving…":e==="error"?n??"Save failed":s?"Unsaved changes":e==="saved"?"Saved · refreshing preview":r?"Saved · not committed yet":"No changes"}const XM=[{label:"B",title:"Bold",before:"**",after:"**"},{label:"I",title:"Italic",before:"_",after:"_"},{label:"H2",title:"Heading",before:`
|
|
27
|
-
## `,after:""},{label:"•",title:"List item",before:`
|
|
28
|
-
- `,after:""},{label:"Link",title:"Link",before:"[",after:"](https://)"}];function Rd({body:e,label:n="Body",onChange:s}){const r=l.useRef(null);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[t.jsx("span",{className:"flex-1 text-xs font-medium text-[var(--text-secondary)]",children:n}),XM.map(a=>t.jsx("button",{type:"button",title:a.title,onClick:()=>{const o=r.current;o&&(s==null||s(KM(e,o.selectionStart,o.selectionEnd,a.before,a.after)))},className:"text-xs px-1.5 py-0.5 rounded text-[var(--text-secondary)] hover:bg-[var(--bg-card)]",children:a.label},a.title))]}),t.jsx("textarea",{ref:r,value:e,rows:12,"aria-label":"Body",onChange:a=>s==null?void 0:s(a.target.value),className:`${Vt} font-mono text-xs leading-relaxed`})]})}const JY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentBodyEditor:Rd},Symbol.toStringTag,{value:"Module"}));function Qx({anchor:e,paneWidth:n,paneHeight:s,file:r,initialBody:a,saving:o,error:i,onSave:c,onCancel:d}){const[u,p]=l.useState(a);return t.jsx(Pd,{anchor:e,paneWidth:n,paneHeight:s,width:520,estimatedHeight:380,title:"Body",meta:r?`markdown · ${r}`:"markdown",saving:o,error:i,onSave:()=>c(u),onCancel:d,children:t.jsx(Rd,{body:u,label:null,onChange:p})})}const XY=Object.freeze(Object.defineProperty({__proto__:null,SiteContentBodyPopover:Qx},Symbol.toStringTag,{value:"Module"})),Ed="rounded ring-2 ring-[var(--accent-primary)] ring-offset-2 ring-offset-[var(--bg-deep)]";function Zx({inputId:e,label:n,required:s=!1,editingInPreview:r=!1,children:a}){return t.jsxs("div",{className:r?Ed:void 0,children:[t.jsxs("label",{htmlFor:e,className:"flex text-xs font-medium text-[var(--text-secondary)] mb-1",children:[t.jsxs("span",{className:"flex-1",children:[n,s?t.jsx("span",{className:"text-[var(--accent-red)]",children:" *"}):null]}),r?t.jsx("span",{className:"text-[var(--accent-primary)]",children:"● editing in preview"}):null]}),a]})}const QY=Object.freeze(Object.defineProperty({__proto__:null,EDITING_IN_PREVIEW_RING:Ed,SiteContentFieldRow:Zx},Symbol.toStringTag,{value:"Module"})),QM={reconnecting:{testId:"build-tab-reconnecting",headline:"Reconnecting to your running build…",explanation:"Your build kept running while this page was away. You’ll be back in the same session in a moment — nothing is restarted or sent again."},starting:{testId:"build-tab-starting",headline:"Starting your build…",explanation:"The agent is starting for your build request. It keeps going even if you close this tab."},interrupted:{testId:"build-tab-interrupted",headline:"Your build was interrupted",explanation:"A build was started for this project, but it is no longer running. Resume it or start again from here."}};function eb({phase:e}){const n=QM[e];return t.jsxs("div",{"data-testid":n.testId,className:"flex flex-col items-center justify-center h-full text-slate-500 space-y-4 px-10 text-center",children:[t.jsx("div",{className:"text-lg font-medium text-slate-400",children:n.headline}),t.jsx("p",{className:"max-w-md",children:n.explanation})]})}const ZY=Object.freeze(Object.defineProperty({__proto__:null,BuildTabConnectionPhasePanel:eb},Symbol.toStringTag,{value:"Module"}));function tb(){return t.jsxs("div",{role:"note",className:"text-xs px-3 py-2 rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] text-[var(--text-secondary)]",children:["Page addresses are guessed and every field is shown as plain text, because this site's ",t.jsx("code",{children:"@codeyam/cms"})," does not describe its content yet. Upgrading ",t.jsx("code",{children:"@codeyam/cms"})," to a version with the content manifest fixes both."]})}const eV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentInferredNotice:tb},Symbol.toStringTag,{value:"Module"}));function nb({onKeepEditing:e,onDiscard:n}){return t.jsxs("div",{role:"alertdialog","aria-label":"Unsaved changes",className:"absolute inset-x-0 top-0 p-4 rounded border border-[var(--border-default)] bg-[var(--bg-surface)] shadow-lg z-10",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] mb-1",children:"You have unsaved changes"}),t.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-3",children:"Leaving this page now throws away the edits you have not saved."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:e,className:"text-xs font-medium px-2.5 py-1 rounded bg-[var(--accent-primary)] text-[var(--text-on-accent)]",children:"Keep editing"}),t.jsx("button",{type:"button",onClick:n,className:"text-xs px-2.5 py-1 rounded text-[var(--accent-red)] hover:bg-[var(--bg-card)]",children:"Discard changes"})]})]})}const tV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentUnsavedDialog:nb},Symbol.toStringTag,{value:"Module"}));function sb({building:e,title:n,reason:s}){return t.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:t.jsxs("div",{className:"max-w-sm text-sm text-[var(--text-secondary)]",children:[t.jsx("div",{className:"font-medium text-[var(--text-primary)] mb-1",children:e?"Building your new page…":n}),e?"The site is restarting so it can serve the new page. This usually takes a few seconds.":s??"The site shows it inside other pages rather than at its own address."]})})}const nV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPreviewEmpty:sb},Symbol.toStringTag,{value:"Module"}));function rb({saveStatus:e,saveError:n,dirty:s,modified:r}){const a=JM({saveStatus:e,saveError:n,dirty:s,modified:r});return t.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-[var(--border-subtle)]",children:[e==="error"?t.jsx(dt,{text:a,rowClassName:"flex-1"}):t.jsx("span",{role:"status",className:`flex-1 text-xs ${s?"text-[var(--accent-orange)]":"text-[var(--text-dim)]"}`,children:a}),t.jsx("button",{type:"submit",disabled:!s||e==="saving",className:"text-sm font-medium px-3 py-1.5 rounded bg-[var(--accent-primary)] text-[var(--text-on-accent)] disabled:opacity-40",children:"Save"})]})}const sV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentSaveBar:rb},Symbol.toStringTag,{value:"Module"}));function ab({title:e,file:n,fields:s,draft:r,dirty:a,modified:o,saveStatus:i="idle",saveError:c,editingInPreview:d=null,onChange:u,onSave:p}){const h=(f,m)=>u==null?void 0:u({...r,fields:{...r.fields,[f]:m}});return t.jsxs("form",{className:"flex flex-col gap-3 min-h-0",onSubmit:f=>{f.preventDefault(),p==null||p()},onKeyDown:f=>{(f.metaKey||f.ctrlKey)&&f.key.toLowerCase()==="s"&&(f.preventDefault(),p==null||p())},children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--text-primary)] truncate",children:e}),t.jsx("div",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:n})]}),t.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto pr-1",children:[VM(s,r).map(f=>t.jsx(Zx,{inputId:`sc-field-${f.name}`,label:f.label??f.name,required:f.required,editingInPreview:d===f.name,children:t.jsx(Od,{def:f,value:r.fields[f.name],onChange:m=>h(f.name,m)})},f.name)),t.jsx("div",{className:d==="body"?Ed:void 0,children:t.jsx(Rd,{body:r.body,onChange:f=>u==null?void 0:u({...r,body:f})})})]}),t.jsx(rb,{saveStatus:i,saveError:c,dirty:a,modified:o})]})}const rV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEntryEditor:ab},Symbol.toStringTag,{value:"Module"}));function ob({entry:e,active:n,onSelect:s}){return t.jsxs("button",{type:"button","aria-current":n?"true":void 0,onClick:()=>s==null?void 0:s(e.slug),className:`w-full text-left px-2 py-1.5 rounded transition ${n?"bg-[var(--bg-card)]":"hover:bg-[var(--bg-card)]"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"flex-1 truncate text-sm text-[var(--text-primary)]",children:e.title}),e.modified?t.jsx("span",{title:"Uncommitted changes","aria-label":"modified",className:"w-1.5 h-1.5 rounded-full bg-[var(--accent-orange)]"}):null]}),t.jsxs("div",{className:"text-xs text-[var(--text-dim)] truncate",children:[e.date?`${e.date.slice(0,10)} · `:"",e.slug]})]})}const aV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEntryRow:ob},Symbol.toStringTag,{value:"Module"}));function ib({collection:e,active:n,onSelect:s}){const r=e.entries.some(a=>a.modified);return t.jsxs("button",{type:"button","aria-current":n?"true":void 0,onClick:()=>s==null?void 0:s(e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left transition ${n?"bg-[var(--bg-card)] text-[var(--text-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-card)]"}`,children:[t.jsx("span",{className:"flex-1 truncate",children:e.label}),r?t.jsx("span",{title:"Has uncommitted changes",className:"w-1.5 h-1.5 rounded-full bg-[var(--accent-orange)]"}):null,e.kind!=="singleton"?t.jsx("span",{className:"text-xs tabular-nums text-[var(--text-dim)]",children:e.entries.length}):null]})}const oV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentCollectionRow:ib},Symbol.toStringTag,{value:"Module"}));function ZM(e,n,s){const r=n.trim().toLowerCase();return e.filter(a=>!r||a.title.toLowerCase().includes(r)||a.slug.toLowerCase().includes(r)).slice().sort((a,o)=>s==="title"?a.title.localeCompare(o.title):(o.date??"").localeCompare(a.date??""))}function eI(e){return[{heading:"Collections",items:e.filter(n=>n.kind!=="singleton")},{heading:"Site",items:e.filter(n=>n.kind==="singleton")}].filter(n=>n.items.length>0)}function lb({collections:e,selectedId:n,onSelect:s}){return t.jsx("nav",{"aria-label":"Content collections",className:"flex flex-col gap-4",children:eI(e).map(r=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-dim)] mb-1.5 px-2",children:r.heading}),t.jsx("ul",{className:"flex flex-col",children:r.items.map(a=>t.jsx("li",{children:t.jsx(ib,{collection:a,active:a.id===n,onSelect:s})},a.id))})]},r.heading))})}const iV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentCollectionList:lb},Symbol.toStringTag,{value:"Module"}));function cb({testId:e}){return t.jsx("div",{"data-testid":e,className:"px-3 py-2 text-sm text-gray-400",children:"Getting the design agent ready…"})}const lV=Object.freeze(Object.defineProperty({__proto__:null,DesignAgentPreparing:cb},Symbol.toStringTag,{value:"Module"}));function db({requestedAt:e}){const n=e?new Date(e):null;return!n||Number.isNaN(n.getTime())?null:t.jsxs("p",{className:"mt-2 text-xs text-[var(--text-muted)]",children:["Build request saved ",n.toLocaleString(),"."]})}const cV=Object.freeze(Object.defineProperty({__proto__:null,BuildRequestSavedNote:db},Symbol.toStringTag,{value:"Module"}));function tI(e,n){const s=[...e.stateHistory].reverse().find(a=>a.state==="dispatching");if(!s)return null;const r=Date.parse(s.at);return Number.isNaN(r)?null:Math.max(0,Math.floor((n-r)/1e3))}function nI(e){const n=(a,o)=>`${a} ${o}${a===1?"":"s"}`;if(e<60)return n(e,"second");if(e>=3600){const a=Math.floor(e/3600),o=Math.floor(e%3600/60);return o===0?n(a,"hour"):`${n(a,"hour")} ${n(o,"minute")}`}const s=Math.floor(e/60),r=e%60;return r===0?n(s,"minute"):`${n(s,"minute")} ${n(r,"second")}`}function sI(e,n,s=null){const r=n==null?"a while":nI(n);return e&&s?{headline:"The editor can’t hear from the build agent",explanation:s,nextAction:"Open the build terminal to follow the agent’s work. Retrying will not fix this."}:e?{headline:"The build agent hasn’t started",explanation:`The agent was started ${r} ago but hasn’t accepted its first instruction. It may still be starting — if it does, your build picks up on its own.`,nextAction:"Retry the launch. If an agent is already running it is reused, so this never starts a second one."}:{headline:"The build agent is taking longer than usual",explanation:`The agent was started ${r} ago and hasn’t accepted its first instruction yet. Nothing has been stopped; it’s still starting.`,nextAction:"Keep waiting, or open the build terminal to see what the agent is doing."}}function Ad(e){return e==="delayed"||e==="launch-timeout"}function Md({state:e,waitSeconds:n,onOpenTerminal:s,onRetry:r,retryPending:a=!1,retryMessage:o=null,onViewLog:i,launchLog:c=null,cause:d=null}){if(!Ad(e))return null;const u=e==="launch-timeout",p=sI(u,n,d),h=[];return u&&r&&h.push({label:"Retry launch",onClick:r,pending:a,pendingLabel:"Retrying…",variant:"primary",testId:"build-launch-retry"}),s&&h.push({label:"Open the build terminal",onClick:s,variant:u?"secondary":"primary",testId:"build-launch-open-terminal"}),u&&i&&h.push({label:"View launch log",onClick:i,variant:"secondary",testId:"build-launch-view-log"}),t.jsx("div",{"data-testid":"build-launch-status-banner","data-state":e,children:t.jsx(Bt,{severity:u?"error":"warning",testId:"build-launch-status-notice",headline:p.headline,explanation:p.explanation,nextAction:p.nextAction,actions:h,actionFeedback:o||c?t.jsxs(t.Fragment,{children:[o?t.jsx("span",{"data-testid":"build-launch-retry-message",children:o}):null,c?t.jsx(Gx,{events:c}):null]}):null})})}const dV=Object.freeze(Object.defineProperty({__proto__:null,BuildLaunchStatusBanner:Md},Symbol.toStringTag,{value:"Module"}));function ub({message:e,onRetry:n,retrying:s=!1}){return t.jsx("div",{style:{marginBottom:"var(--spacing-md, 12px)",textAlign:"left"},children:t.jsx(Bt,{severity:"error",testId:"questionnaire-submit-error",headline:"Your answers weren't saved, so the build hasn't started",explanation:"Everything you entered is still here.",nextAction:"Try again. If it keeps failing, copy this report and send it to whoever set up this editor.",diagnostics:e,actions:[{label:"Retry",onClick:n,pending:s,pendingLabel:"Retrying…",variant:"primary"}]})})}const uV=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireSubmitErrorBanner:ub},Symbol.toStringTag,{value:"Module"})),sf="M1.2 0 L5 3 L8.8 0 L10 1.4 L5 5.4 L0 1.4 z",Sa=3,rI=1.6,aI=7,oI=9,iI=14.4;function pb({collapsed:e=!1}){const n=e?`translate(${Sa} ${aI}) scale(1 -1)`:`translate(${Sa} ${rI})`,s=e?`translate(${Sa} ${oI})`:`translate(${Sa} ${iI}) scale(1 -1)`;return t.jsxs("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:[t.jsx("path",{d:sf,transform:n}),t.jsx("path",{d:sf,transform:s})]})}const pV=Object.freeze(Object.defineProperty({__proto__:null,CollapseAllIcon:pb},Symbol.toStringTag,{value:"Module"}));function hb(){const e="M2 2 h4.5 v1.6 h-2.9 v2.9 h-1.6 z";return t.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:[0,90,180,270].map(n=>t.jsx("path",{d:e,transform:`rotate(${n} 8 8)`},n))})}const hV=Object.freeze(Object.defineProperty({__proto__:null,FullScreenIcon:hb},Symbol.toStringTag,{value:"Module"}));function Nl({label:e,onClick:n,pressed:s,children:r}){return t.jsx("button",{type:"button",onClick:n,"aria-label":e,title:e,"aria-pressed":s,className:"flex h-8 w-8 items-center justify-center rounded-lg transition text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-white/[0.08]",children:r})}const fV=Object.freeze(Object.defineProperty({__proto__:null,ToolbarIconButton:Nl},Symbol.toStringTag,{value:"Module"}));function fb({onOpenGallery:e,allCollapsed:n=!1,onToggleAll:s}){return!s&&!e?null:t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s?t.jsx(Nl,{label:n?"Open all sections":"Close all sections",onClick:s,pressed:n,children:t.jsx(pb,{collapsed:n})}):null,e?t.jsx(Nl,{label:"Full screen",onClick:e,children:t.jsx(hb,{})}):null]})}const mV=Object.freeze(Object.defineProperty({__proto__:null,RouteViewControls:fb},Symbol.toStringTag,{value:"Module"}));function mb({reason:e,providerLabel:n}){return t.jsx("p",{className:"text-xs text-[#FFD778]/70 mt-1",children:e==="waived-by-grant"?t.jsxs(t.Fragment,{children:["This step normally asks for your approval, but you chose to skip these check-ins for this piece of work — ",n," was meant to keep going. Continue picks the work back up; to be asked again, run"," ",t.jsx("code",{className:"font-mono",children:"codeyam-editor editor check-in-revoke"}),"."]}):e==="disabled-in-config"?t.jsxs(t.Fragment,{children:["This step normally asks for your approval, but this project has that check-in turned off in its workflow settings — ",n," was meant to keep going. Continue picks the work back up without you having to type."]}):t.jsxs(t.Fragment,{children:["This step doesn't ask anything of you — ",n," was meant to keep going. Continue picks the work back up without you having to type."]})})}const gV=Object.freeze(Object.defineProperty({__proto__:null,TurnEndedOffGateReasonBody:mb},Symbol.toStringTag,{value:"Module"}));function Id({envVar:e}){return t.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["The key is stored in",t.jsx("code",{className:"mx-1 text-[#D7FF63]",children:".codeyam/setup-connections.json"}),"(owner-only, gitignored) and injected into your app as",t.jsx("code",{className:"mx-1 text-[#D7FF63]",children:e})," — never committed."]})}const xV=Object.freeze(Object.defineProperty({__proto__:null,CredentialStorageNote:Id},Symbol.toStringTag,{value:"Module"}));function Dd({href:e}){return t.jsx("a",{href:e,target:"_blank",rel:"noreferrer",className:"inline-block text-sm text-[#7EA6FF] hover:underline",children:"Where to find this key →"})}const bV=Object.freeze(Object.defineProperty({__proto__:null,CredentialDocsLink:Dd},Symbol.toStringTag,{value:"Module"}));function gb({serviceName:e,envVar:n,onBack:s}){return t.jsxs("div",{"data-testid":"credential-request-saved",className:"space-y-3",children:[t.jsx("p",{className:"text-base text-[#D7FF63] font-medium",children:"Saved ✓"}),t.jsxs("p",{className:"text-sm text-[#CFCFCF]",children:["Your ",e," key is available to your app as",t.jsx("code",{className:"mx-1 text-[#D7FF63]",children:n}),". The agent has been told it's saved — you don't need to paste it into the chat."]}),t.jsx("button",{"data-testid":"credential-request-back",onClick:s,className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Back to preview"})]})}const yV=Object.freeze(Object.defineProperty({__proto__:null,CredentialRequestSaved:gb},Symbol.toStringTag,{value:"Module"}));function Ld({target:e,onStored:n}){const[s,r]=l.useState(""),[a,o]=l.useState(!1),[i,c]=l.useState(!1),[d,u]=l.useState(null),[p,h]=l.useState(!1),f=l.useCallback(async()=>{if(s.trim()){c(!0),u(null),h(!1);try{const g=await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:e.topic,provider:"passthrough",credential:s.trim(),credential_fields:{envVar:e.envVar}})});if(!g.ok){if(mR(g.status)==="transient"){h(!0),u(`The editor was briefly unreachable (HTTP ${g.status}). Your key wasn't rejected — try again.`);return}const b=await g.json().catch(()=>({}));u(b.error??`Could not store the key (HTTP ${g.status}).`);return}const x=await g.json().catch(()=>({}));if(x.success===!1||x.status==="error"){u(x.message??x.error??"The key was rejected.");return}r(""),n()}catch{h(!0),u("Could not reach the editor to store the key. Try again.")}finally{c(!1)}}},[s,e,n]),m=g=>{g.preventDefault(),f()};return t.jsxs("form",{"data-testid":"app-service-credential-form",onSubmit:m,className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{"data-testid":"app-service-credential-input",type:a?"text":"password",value:s,onChange:g=>r(g.target.value),placeholder:`${e.serviceName} API key`,autoFocus:!0,autoComplete:"off",spellCheck:!1,className:"flex-1 min-w-0 px-2 py-1.5 rounded bg-black border border-[#3A3A3A] text-white text-sm"}),t.jsx("button",{type:"button","data-testid":"app-service-credential-reveal",onClick:()=>o(g=>!g),className:"px-2 py-1.5 text-xs rounded-md border border-[#3A3A3A] text-[#8E8E8E] hover:text-white cursor-pointer",children:a?"Hide":"Show"}),t.jsx("button",{type:"submit",disabled:i||!s.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:i?"Saving…":"Save"})]}),d?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm text-[#FF8B43]",children:d}),p?t.jsx("button",{type:"button","data-testid":"app-service-credential-retry",onClick:()=>void f(),disabled:i||!s.trim(),className:"px-3 py-1.5 text-sm rounded-md border border-[#3A3A3A] text-white font-medium cursor-pointer disabled:opacity-50",children:i?"Saving…":"Retry"}):null]}):null]})}const vV=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialForm:Ld},Symbol.toStringTag,{value:"Module"}));function xb({message:e,hint:n,onRetry:s}){return t.jsxs("div",{role:"alert",style:{padding:"var(--spacing-md, 12px)",marginBottom:"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:[t.jsxs("div",{children:["Couldn't prepare design moodboards: ",e,". ",n]}),t.jsx("button",{type:"button",onClick:s,style:{marginTop:"var(--spacing-sm, 8px)",background:"transparent",border:"1px solid currentColor",color:"inherit",padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,cursor:"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:"Try again"})]})}const jV=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignPrepareErrorBanner:xb},Symbol.toStringTag,{value:"Module"})),Cl="Waiting for the agent to write the plan file…";function Tl(e){return`${e}-awaiting-formalize`}function $d({kind:e,inline:n=!1}){return n?t.jsx("span",{"data-testid":Tl(e),children:Cl}):t.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":Tl(e),children:Cl})}const wV=Object.freeze(Object.defineProperty({__proto__:null,AWAITING_FORMALIZE_CAPTION_TEXT:Cl,AwaitingFormalizeCaption:$d,awaitingFormalizeCaptionTestId:Tl},Symbol.toStringTag,{value:"Module"}));function bb({sectionTitle:e,headlineCount:n,refreshedCount:s}){return n>0||s<=0?null:t.jsxs("div",{className:"text-xs text-[var(--text-muted)] italic",children:["No ",e.toLowerCase()," demonstrate this work yet — the"," ",s," below were refreshed because a shared file changed."]})}const _V=Object.freeze(Object.defineProperty({__proto__:null,OnlyRefreshedNotice:bb},Symbol.toStringTag,{value:"Module"}));function yb({message:e}){return t.jsx("div",{className:"flex h-full items-center justify-center px-10",children:t.jsx(Bt,{severity:"error",testId:"build-launch-error",headline:"The session did not start",explanation:e,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 SV=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLaunchError:yb},Symbol.toStringTag,{value:"Module"}));function lI(e,n){return e?e.kind==="resume"?n?"Resuming…":`Resume session ${e.sessionId.slice(0,8)}`:n?"Starting…":"Start a new build session":"Checking…"}function vb({mode:e,recovering:n=!1,recovered:s=!1,onRecover:r,onKeepForLater:a}){return s?t.jsx("p",{"data-testid":"interrupted-build-recovered",className:"mt-6 text-sm font-medium text-[var(--accent-active)]",children:(e==null?void 0:e.kind)==="resume"?"Resuming your session — follow along on the Build tab.":"Your new build session is starting — follow along on the Build tab."}):t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx("button",{type:"button","data-testid":"interrupted-build-recover",onClick:r,disabled:!e||n,className:"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 disabled:cursor-not-allowed disabled:opacity-60",children:lI(e,n)}),t.jsx("button",{type:"button","data-testid":"interrupted-build-keep",onClick:a,disabled:n,className:"rounded px-3 py-2 text-xs font-medium uppercase tracking-wide text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer disabled:cursor-not-allowed",children:"Keep for later"})]})}const kV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildActions:vb},Symbol.toStringTag,{value:"Module"}));function jb({changedFiles:e,moreChangedFiles:n=0,resuming:s}){return t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"mt-6 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]",children:"What may already have changed"}),e.length===0?t.jsx("p",{"data-testid":"interrupted-build-no-changes",className:"mt-2 text-sm text-[var(--text-dim)]",children:"No files have changed since you made this request."}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mt-2 text-sm text-[var(--text-dim)]",children:s?"The interrupted build may have partly done this work. The resumed session remembers making these changes.":"The interrupted build may have partly done this work. The new session is told to check these files before redoing anything."}),t.jsx("ul",{"data-testid":"interrupted-build-changed-files",className:"mt-2 max-h-48 overflow-y-auto rounded border border-[var(--border-subtle)] px-3 py-2 font-mono text-xs",children:e.map(r=>t.jsxs("li",{className:"flex justify-between gap-4 py-0.5",children:[t.jsx("span",{className:"truncate",children:r.path}),t.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:r.change==="uncommitted"?"not saved to git":"committed"})]},r.path))}),n>0?t.jsxs("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:["…and ",n," more."]}):null]})]})}const NV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildChangedFiles:jb},Symbol.toStringTag,{value:"Module"}));function wb({mode:e}){return t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"mt-6 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]",children:"What happens next"}),t.jsx("p",{"data-testid":"interrupted-build-mode",className:"mt-2 text-sm text-[var(--text-primary)]",children:e?e.kind==="resume"?"The same agent session continues where it stopped, with its full history.":`A new agent session starts with your original request. ${e.reason} The new session is told the previous attempt was interrupted, so it inspects the current files before redoing work.`:"Checking whether the previous session can be continued…"})]})}const CV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildNextStep:wb},Symbol.toStringTag,{value:"Module"}));function _b({brief:e,designReferencePath:n=null,requestedAt:s=null}){const r=s?new Date(s):null,a=r&&!Number.isNaN(r.getTime())?r.toLocaleString():null;return t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"mt-6 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]",children:["What you asked for",a?` · ${a}`:""]}),t.jsx("blockquote",{"data-testid":"interrupted-build-brief",className:"mt-2 border-l-2 border-[var(--accent-active)] pl-4 text-sm italic text-[var(--text-dim)]",children:e}),n?t.jsxs("p",{className:"mt-2 text-xs text-[var(--text-muted)]",children:["Design reference: ",t.jsx("code",{children:n})]}):null]})}const TV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildRequestSummary:_b},Symbol.toStringTag,{value:"Module"}));function Sb({brief:e,designReferencePath:n=null,requestedAt:s=null,interruptionReason:r=null,mode:a,changedFiles:o,moreChangedFiles:i=0,recovering:c=!1,recovered:d=!1,error:u=null,onRecover:p,onKeepForLater:h}){return t.jsxs("section",{"data-testid":"interrupted-build-panel",className:"text-[var(--text-primary)]",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Your build was interrupted"}),t.jsxs("p",{className:"mt-2 text-sm text-[var(--text-dim)]",children:["The agent stopped before it finished.",r?` ${r}`:""," Nothing will restart until you choose to."]}),t.jsx(_b,{brief:e,designReferencePath:n,requestedAt:s}),t.jsx(jb,{changedFiles:o,moreChangedFiles:i,resuming:(a==null?void 0:a.kind)==="resume"}),t.jsx(wb,{mode:a}),u?t.jsx("p",{"data-testid":"interrupted-build-error",className:"mt-3 text-sm text-[var(--status-error,#f87171)]",children:u}):null,t.jsx(vb,{mode:a,recovering:c,recovered:d,onRecover:p,onKeepForLater:h})]})}const PV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildPanel:Sb},Symbol.toStringTag,{value:"Module"}));function cI(e){const[n,s]=l.useState(null),[r,a]=l.useState(!1),[o,i]=l.useState(!1),[c,d]=l.useState(null),u=l.useRef(!1);l.useEffect(()=>{if(!e)return;let h=!1;return fetch(`/api/editor-build-requests/${e}/recovery`).then(f=>{if(!f.ok)throw new Error(`HTTP ${f.status}`);return f.json()}).then(f=>{h||s(f)}).catch(()=>{h||d("Couldn’t load the details of the interrupted build.")}),()=>{h=!0}},[e]);const p=l.useCallback(()=>{!e||u.current||(u.current=!0,a(!0),d(null),fetch(`/api/editor-build-requests/${e}/recover`,{method:"POST"}).then(async h=>{const f=await h.json().catch(()=>({}));if(!h.ok)throw new Error(f.error??`HTTP ${h.status}`);i(!0)}).catch(h=>{d(`Couldn’t start the recovery: ${h.message}`),u.current=!1}).finally(()=>a(!1)))},[e]);return{details:n,recovering:r,recovered:o,error:c,recover:p}}const kb="codeyam.interruptedBuild.keptForLater";function Nb(e){try{return window.localStorage.getItem(kb)===e}catch{return!1}}function dI(e){try{window.localStorage.setItem(kb,e)}catch{}}function Fd({request:e,onRecovered:n,onKeptForLater:s}){var u,p;const{details:r,recovering:a,recovered:o,error:i,recover:c}=cI(e.id),d=l.useRef(!1);return l.useEffect(()=>{!o||d.current||(d.current=!0,n==null||n())},[o,n]),t.jsx(Sb,{brief:e.brief,designReferencePath:((u=e.designReference)==null?void 0:u.path)??null,requestedAt:e.createdAt,interruptionReason:((p=e.interruption)==null?void 0:p.reason)??null,mode:(r==null?void 0:r.mode)??null,changedFiles:(r==null?void 0:r.changedFiles)??[],moreChangedFiles:(r==null?void 0:r.moreChangedFiles)??0,recovering:a,recovered:o,error:i,onRecover:c,onKeepForLater:()=>{dI(e.id),s==null||s()}})}const OV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildRecovery:Fd},Symbol.toStringTag,{value:"Module"})),uI=1;function Cb({maxHeight:e,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),p=l.useCallback(()=>{const h=a.current;if(!h)return;const f=h.scrollHeight-h.clientHeight;c(f>0),u(h.scrollTop>=f-uI)},[]);return l.useEffect(()=>{p();const h=new ResizeObserver(p);return a.current&&h.observe(a.current),o.current&&h.observe(o.current),()=>h.disconnect()},[p,r]),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("div",{ref:a,"data-testid":s,onScroll:p,className:"overflow-y-auto",style:{maxHeight:`${e}px`},tabIndex:i?0:void 0,children:t.jsx("div",{ref:o,children:r})}),i&&!d&&t.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 RV=Object.freeze(Object.defineProperty({__proto__:null,ScrollFadeRegion:Cb},Symbol.toStringTag,{value:"Module"})),pI={"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"},hI=["no-surface","no-mock-seam"];function zd(e){return hI.includes(e)}function Tb({barrier:e}){const n=zd(e);return t.jsx("span",{className:`mtest-barrier ${n?"gap":"inherent"}`,"data-barrier":e,children:pI[e]})}const EV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestBarrierTag:Tb,isCodeyamGap:zd},Symbol.toStringTag,{value:"Module"}));function Pb({summary:e}){if(e.total===0||e.unsimulated===0)return null;const{total:n,unsimulated:s,gaps:r,inherent:a,unclassified:o}=e;return t.jsxs("div",{className:"mtest-gaps","data-testid":"manual-tests-gap-summary","data-total":n,"data-unsimulated":s,"data-gaps":r,"data-inherent":a,"data-unclassified":o,children:[t.jsxs("span",{className:"mtest-gaps-headline",children:[s," of ",n," test",n===1?"":"s"," ",s===1?"has":"have"," no simulation"]}),r>0?t.jsxs("span",{className:"mtest-barrier gap",children:[r," codeyam could show"]}):null,a>0?t.jsxs("span",{className:"mtest-barrier inherent",children:[a," need",a===1?"s":""," a real process or system"]}):null,o>0?t.jsxs("span",{className:"mtest-barrier unclassified",children:[o," unclassified"]}):null]})}const AV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestGapSummary:Pb},Symbol.toStringTag,{value:"Module"})),Ob="/codeyam-plan",Rb="/codeyam-prototype",oo="/codeyam-chat",fI="/codeyam-design";function Ls(e,n){const s=Mr(n);return s?`${e} ${s}`:e}function Mr(e){return e.replace(/\s+/g," ").trim()}function Pl(e,n,s){const r=s.trim();return r?`${e} returned ${n}: ${r}`:`${e} returned ${n} with an empty response body`}const rf="/api/editor-design-systems-install";async function Ol(){const e=await fetch(rf,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!e.ok){const n=await e.text().catch(()=>"");throw new Error(Pl(rf,e.status,n))}}let As=[],mI=0;function Bd(e){const n=mI++;return As.push({id:n,chatName:e}),()=>{As=As.filter(s=>s.id!==n)}}function Eb(){return As.length>0?As[As.length-1].chatName:null}function Ab({onClose:e,seedText:n}){l.useEffect(()=>Bd("design-tweak"),[]);const[s,r]=l.useState(!1);return l.useEffect(()=>{let a=!0;return Ol().catch(()=>{}).finally(()=>{a&&r(!0)}),()=>{a=!1}},[]),s?t.jsx(Ht,{chatName:"design-tweak",slashCommand:`${fI} ${n}`,seedText:n,height:360,onClose:e,beforeRelaunch:Ol}):t.jsx(cb,{testId:"design-tweak-chat-preparing"})}const MV=Object.freeze(Object.defineProperty({__proto__:null,DesignTweakChat:Ab},Symbol.toStringTag,{value:"Module"}));function Mb(){return t.jsx("p",{"data-testid":"design-switch-plan-explainer",style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"Your app already exists, so this adds a plan to your queue describing the switch: which colors and fonts change and which screens use them. Nothing in the app changes until you run it."})}const IV=Object.freeze(Object.defineProperty({__proto__:null,DesignSwitchPlanExplainer:Mb},Symbol.toStringTag,{value:"Module"}));function Ib({onClick:e}){return t.jsx("button",{type:"button","data-testid":"plan-tweak-designs",onClick:e,style:{marginTop:"var(--spacing-md, 12px)",padding:"10px 16px",borderRadius:8,border:"1px solid var(--accent-active, #D7FF63)",background:"transparent",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",cursor:"pointer"},children:"Tweak these designs"})}const DV=Object.freeze(Object.defineProperty({__proto__:null,TweakDesignsButton:Ib},Symbol.toStringTag,{value:"Module"}));function Db({count:e,selected:n}){const s=e===1?"":"s",r=n?`, with ${n} selected`:", none selected yet";return t.jsx("p",{"data-testid":"plan-design-context-note",style:{margin:"8px 0 0",fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:`Your request will mention the ${e} design${s} on screen${r}, so you can refer to them by number or name.`})}const LV=Object.freeze(Object.defineProperty({__proto__:null,DesignContextNote:Db},Symbol.toStringTag,{value:"Module"}));function Lb({title:e,onClick:n}){return t.jsxs("button",{type:"button",className:"mtest-delete","data-testid":"manual-test-delete",onClick:n,title:`Delete "${e}" — removes the test, not just its check`,"aria-label":`Delete "${e}"`,children:[t.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:t.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 $V=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteButton:Lb},Symbol.toStringTag,{value:"Module"}));function $b({busy:e,onCancel:n,onConfirm:s}){return t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,disabled:e,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:s,disabled:e,"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:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:e?"Deleting…":"Delete test"})]})}const FV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmActions:$b},Symbol.toStringTag,{value:"Module"}));function Fb({completed:e}){return e?t.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 zV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteReceiptWarning:Fb},Symbol.toStringTag,{value:"Module"}));function zb({title:e}){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Delete manual test?"}),t.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13},children:e}),t.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 BV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmHeader:zb},Symbol.toStringTag,{value:"Module"}));function xs(){const[e,n]=l.useState(()=>Date.now());return l.useEffect(()=>{const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[]),e}function Jn(e,n=Date.now()){if(!e)return"unknown";const s=Date.parse(e);if(Number.isNaN(s))return e;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 Wd({uuid:e,markedForRelease:n,onToggle:s,alwaysVisible:r=!1}){if(n)return t.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-${e}`,onClick:s,title:"Keep this entry in the queue",children:"Undo remove"});const a=r?"":"opacity-0 group-hover:opacity-100 transition-opacity ";return t.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-${e}`,onClick:s,title:"Mark this entry for removal",children:"Force release"})}const WV=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueReleaseButton:Wd},Symbol.toStringTag,{value:"Module"}));function Bb({entry:e,markedForRelease:n,onToggleRelease:s}){const r=xs(),a=e.meta,o=a.startedAt??e.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} (${Jn(o,r)})`},{key:"ref",label:"ref",value:e.refName},{key:"uuid",label:"uuid",value:e.uuid}];return t.jsxs("div",{className:"w-full","data-testid":`commit-queue-details-${e.uuid}`,children:[t.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:i.map(c=>t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-[var(--text-dim)]",children:c.label}),t.jsx("dd",{className:"font-mono break-all text-[var(--text-default)]","data-testid":`commit-queue-detail-${c.key}-${e.uuid}`,children:c.value})]},c.key))}),t.jsx("div",{className:"mt-3",children:t.jsx(Wd,{uuid:e.uuid,markedForRelease:n,onToggle:s,alwaysVisible:!0})})]})}const HV=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowDetails:Bb},Symbol.toStringTag,{value:"Module"}));function Wb({state:e}){return t.jsx("div",{style:{padding:"var(--spacing-lg, 16px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:e==="resolving"?"Finding the active round…":"No active round."})}const qV=Object.freeze(Object.defineProperty({__proto__:null,DesignRoundEmptyState:Wb},Symbol.toStringTag,{value:"Module"}));function Hb({providerLabel:e,open:n,onClick:s}){return t.jsxs("button",{type:"button",onClick:s,"aria-expanded":n,className:"mtest-ask"+(n?" open":""),"data-testid":"manual-test-ask",title:`Ask ${e} how to run this test, or have it fix the test`,children:[t.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:t.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 UV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestAskChatButton:Hb},Symbol.toStringTag,{value:"Module"}));function qb(e){return e.cliInstalled&&e.pluginInstalled&&e.projectInitialized}function gI(e){return e.cliInstalled||e.projectInitialized}function Rl({note:e}){return e?t.jsx("p",{className:"xsvc-broker-note",children:e}):null}function Ub({broker:e,category:n,onStart:s}){const r=n.toLowerCase();return!e.cliInstalled||!e.pluginInstalled?t.jsxs("div",{className:"xsvc-broker xsvc-broker-blocked",children:[t.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",e.name]}),t.jsxs("p",{className:"xsvc-broker-body",children:[e.cliInstalled?`The ${e.name} CLI is installed, but its projects plugin is not.`:`The ${e.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"," ",e.name," account and costs nothing."]}),t.jsx("code",{className:"xsvc-broker-cmd",children:e.installHint}),t.jsx(Rl,{note:e.note})]}):e.projectInitialized?t.jsxs("div",{className:"xsvc-broker",children:[t.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",e.name]}),t.jsxs("p",{className:"xsvc-broker-body",children:[e.projectName?`This project is connected to ${e.name} as "${e.projectName}".`:`This project is connected to ${e.name}.`," ",e.resourceCount>0?`${e.resourceCount} service${e.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."]}),t.jsx(Rl,{note:e.note}),t.jsx("button",{type:"button",className:"xsvc-broker-go",onClick:s,disabled:!qb(e),children:"Start setup"})]}):t.jsxs("div",{className:"xsvc-broker",children:[t.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",e.name]}),t.jsxs("p",{className:"xsvc-broker-body",children:["This project has not been connected to ",e.name," yet. The first step creates a project on your ",e.name," account and writes its records into this repository. A browser window may open for you to sign in."]}),t.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."}),t.jsx("button",{type:"button",className:"xsvc-broker-go",onClick:s,children:"Start setup"})]})}const GV=Object.freeze(Object.defineProperty({__proto__:null,BrokerNote:Rl,ProvisionWithBrokerCta:Ub},Symbol.toStringTag,{value:"Module"}));function Gb({title:e,onClose:n,children:s}){return t.jsxs("div",{role:"dialog","aria-label":e,children:[t.jsxs("div",{className:"xsvc-chatdock-head",children:[t.jsx("span",{children:e}),t.jsx("button",{type:"button",className:"xsvc-chatdock-close",onClick:n,children:"Close ✕"})]}),s]})}const YV=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesChatDock:Gb},Symbol.toStringTag,{value:"Module"}));function Yb({onClose:e,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"})},[]),t.jsx("div",{ref:r,children:t.jsx(Ht,{chatName:"manual-tests",slashCommand:n,seedText:s,height:360,onClose:e})})}const VV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestsChat:Yb},Symbol.toStringTag,{value:"Module"}));function xI(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Vb({steps:e}){const[n,s]=l.useState(!1),r=e.length>1,a=n?e:e.slice(0,1);return t.jsxs(t.Fragment,{children:[t.jsx("ol",{className:"mtest-steps",children:a.map((o,i)=>t.jsx("li",{children:o},i))}),r?t.jsx("button",{type:"button",className:"mtest-disclose",onClick:()=>s(o=>!o),"aria-expanded":n,children:n?"Show less":`Show all ${e.length} steps`}):null]})}const KV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestSteps:Vb},Symbol.toStringTag,{value:"Module"}));function El({surface:e,slot:n,onOpenUncovered:s}){if(e.kind==="scenario"){if(n==="context")return null;const r=e.scenarioType==="component";return t.jsxs("a",{className:"mtest-open primary",href:fE(e.slug),target:"_blank",rel:"noopener noreferrer",title:e.reason,children:["Open scenario",t.jsx("span",{className:"sname",children:e.name}),r?t.jsx("span",{className:"stype",children:"component"}):null,t.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:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})}return n==="action"?null:e.kind==="uncovered"?t.jsxs("div",{className:"mtest-uncovered",children:[t.jsx("span",{className:"lbl",children:"No scenario yet"}),t.jsx("span",{className:"uname",children:e.name}),t.jsx("span",{className:"ufile",children:e.file}),s?t.jsx("button",{type:"button",className:"mtest-uncovered-cta",onClick:()=>s(e.name),children:"Find it in Explore →"}):null]}):t.jsxs("div",{className:"mtest-nosurface",children:[e.barrier?t.jsx(Tb,{barrier:e.barrier}):null,t.jsx("span",{className:"note",children:e.note}),e.barrierDetail?t.jsx("span",{className:"bdetail",children:e.barrierDetail}):null]})}const JV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestSurfaceControl:El},Symbol.toStringTag,{value:"Module"})),af=["#7a4f6d","#4f6a7a","#6d7a4f","#7a5f4f","#5f4f7a","#4f7a63"];function Kb(e){const n=e.trim().toLowerCase();let s=0;for(let r=0;r<n.length;r+=1)s=(s+n.charCodeAt(r)*(r+1))%1e5;return af[s%af.length]}function Do({author:e}){const n=e.email?`${e.name} <${e.email}>`:e.name;return t.jsx("span",{"data-testid":"plan-author-avatar",title:n,"aria-label":`Author: ${n}`,style:{backgroundColor:Kb(e.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:e.initials})}const XV=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthorAvatar:Do,avatarTone:Kb},Symbol.toStringTag,{value:"Module"}));function Hd({test:e,onToggle:n,onOpenUncovered:s,onAskAbout:r,onDelete:a,askProviderLabel:o,chatOpen:i=!1,chatSlot:c,busy:d=!1,departing:u=!1}){const p=e.status==="completed";return t.jsxs("div",{className:"mtest-row"+(p?" done":"")+(u?" leaving":"")+(u==="pinned"?" pinned":""),"data-testid":"manual-test-row","data-test-id":e.id,"data-departing":u?u==="pinned"?"pinned":"true":void 0,children:[t.jsx("label",{className:"mtest-check",children:t.jsx("input",{type:"checkbox",checked:p,disabled:d,onChange:h=>n(e.id,h.target.checked),"aria-label":`Mark "${e.title}" verified`})}),t.jsxs("div",{className:"mtest-main",children:[t.jsx("div",{className:"mtest-title",children:e.title}),t.jsx("div",{className:"mtest-intent",children:e.intent}),t.jsx(El,{surface:e.surface,slot:"action"}),t.jsx(Vb,{steps:e.steps}),t.jsxs("div",{className:"mtest-expected",children:[t.jsx("span",{className:"lbl",children:"Expected"})," ",e.expected]}),t.jsx(El,{surface:e.surface,slot:"context",onOpenUncovered:s}),r||a?t.jsxs("div",{className:"mtest-ask-row",children:[r?t.jsx(Hb,{providerLabel:o??st(null),open:i,onClick:()=>r(e.id)}):null,a?t.jsx(Lb,{title:e.title,onClick:()=>a(e.id)}):null]}):null,p&&e.completion?t.jsxs("div",{className:"mtest-receipt","data-testid":"manual-test-receipt",children:[t.jsx(Do,{author:{name:e.completion.completedByName,email:e.completion.completedByEmail,initials:e.completion.completedByInitials??"?"}}),"verified ",xI(e.completion.completedAt)]}):null,c?t.jsx("div",{className:"mtest-row-chat","data-testid":"manual-test-row-chat",children:c}):null]})]})}const QV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRow:Hd},Symbol.toStringTag,{value:"Module"}));function Jb({tests:e,busyIds:n,onToggle:s,onOpenUncovered:r,onAskAboutTest:a,onDeleteTest:o,askProviderLabel:i,openTestChatId:c=null,testChatSlot:d}){const[u,p]=l.useState(!1),h=new Set(n);return e.length===0?null:t.jsxs("div",{className:"mtest-completed",children:[t.jsxs("button",{type:"button",className:"mtest-disclose",onClick:()=>p(f=>!f),"aria-expanded":u,"data-testid":"home-testing-completed-toggle",children:[u?"Hide":"Show"," ",e.length," completed"]}),u?t.jsx("div",{className:"mtest-list",children:e.map(f=>t.jsx(Hd,{test:f,onToggle:s,onOpenUncovered:r,onAskAbout:a,onDelete:o,askProviderLabel:i,chatOpen:c===f.id,chatSlot:c===f.id?d:null,busy:h.has(f.id)},f.id))}):null]})}const ZV=Object.freeze(Object.defineProperty({__proto__:null,ManualTestCompletedGroup:Jb},Symbol.toStringTag,{value:"Module"}));function Xb({status:e}){return e?e.neverGenerated?t.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:"No tests generated yet"}):e.lastGeneratedShaUnreachable?t.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"}):e.commitsSince==null?t.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:"Commits since last generated: unknown"}):t.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:e.commitsSince===0?"Up to date — 0 commits since tests were last generated":`${e.commitsSince} commit${e.commitsSince===1?"":"s"} since tests were last generated`}):null}const eK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestCountLine:Xb},Symbol.toStringTag,{value:"Module"}));function Da({value:e,label:n,detail:s,checked:r,enabled:a=!0,disabled:o=!1,onSelect:i}){return t.jsxs("label",{className:"mtest-range-opt"+(a?"":" disabled"),children:[t.jsx("input",{type:"radio",name:"mtest-range-choice",checked:r,disabled:o||!a,onChange:i}),t.jsx("span",{className:"mtest-range-opt-lbl",children:n}),s?t.jsx("span",{className:"mtest-range-opt-detail",children:s}):null]})}const tK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeOption:Da},Symbol.toStringTag,{value:"Module"})),bI=[10,25];function yI(e,n){switch(e){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=e==="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 Qb({choice:e,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 t.jsxs("div",{className:"mtest-range-opts",children:[t.jsx(Da,{value:"marker",label:"Since tests were last generated",detail:i,checked:e==="marker",enabled:s,disabled:o,onSelect:()=>n("marker")}),bI.map(c=>{const d=c===10?"count-10":"count-25";return t.jsx(Da,{value:d,label:`Last ${c} commits`,checked:e===d,disabled:o,onSelect:()=>n(d)},d)}),t.jsx(Da,{value:"commit",label:"Since a specific change…",detail:a?"":"no commits loaded",checked:e==="commit",enabled:a,disabled:o,onSelect:()=>n("commit")})]})}const nK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeOptions:Qb},Symbol.toStringTag,{value:"Module"}));function vI(e,n=Date.now()){const s=new Date(e).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 Zb({commit:e,selected:n,disabled:s=!1,onSelect:r}){return t.jsxs("button",{type:"button",className:"mtest-range-commit"+(n?" selected":""),onClick:r,disabled:s,"aria-pressed":n,children:[t.jsx("span",{className:"mtest-range-commit-subject",children:e.subject}),t.jsxs("span",{className:"mtest-range-commit-meta",children:[e.shortSha," · ",vI(e.timestamp)]})]})}const sK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCommitRow:Zb},Symbol.toStringTag,{value:"Module"}));function ey({commits:e,hiddenCount:n=0,selectedSha:s,onSelect:r,disabled:a=!1}){return t.jsxs(t.Fragment,{children:[e.length>0?t.jsx("div",{className:"mtest-range-commits","data-testid":"manual-tests-commits",children:e.map(o=>t.jsx(Zb,{commit:o,selected:s===o.sha,disabled:a,onSelect:()=>r(o.sha)},o.sha))}):null,n>0?t.jsxs("span",{className:"mtest-range-hidden",children:[n," bookkeeping commit",n===1?"":"s"," hidden"]}):null]})}const rK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCommitList:ey},Symbol.toStringTag,{value:"Module"}));function ty({value:e,onChange:n,onSubmit:s,onCancel:r,disabled:a=!1}){return t.jsxs("div",{className:"mtest-range-field",children:[t.jsx("label",{className:"mtest-range-lbl",htmlFor:"mtest-range-input",children:"Range"}),t.jsx("input",{id:"mtest-range-input",className:"mtest-range-input",type:"text",value:e,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 aK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCustomField:ty},Symbol.toStringTag,{value:"Module"}));function ny({resolved:e,awaitingCommit:n}){const s=e==null?n?"Pick a change to generate from.":"Name a range to generate from.":e.adHoc?"This run won’t move the last-generated marker.":"The usual run — moves the marker when it finishes.";return t.jsx("span",{className:"mtest-range-hint",children:s})}const oK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeHint:ny},Symbol.toStringTag,{value:"Module"}));function sy({canGenerate:e,onGenerate:n,onShowCustom:s,showCustomButton:r,onCancel:a,disabled:o=!1}){return t.jsxs("div",{className:"mtest-range-actions",children:[r?t.jsx("button",{type:"button",className:"mtest-btn subtle",onClick:s,disabled:o,children:"Type a range"}):null,a?t.jsx("button",{type:"button",className:"mtest-btn subtle",onClick:a,disabled:o,children:"Cancel"}):null,t.jsx("button",{type:"button",className:"mtest-btn primary",onClick:n,disabled:o||!e,"data-testid":"manual-tests-range-generate",children:"Generate"})]})}const iK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeActions:sy},Symbol.toStringTag,{value:"Module"}));function jI(e){return/^chore: update codeyam state\b/i.test(e.trim())}function ry({defaultRange:e,commitCount:n,recentCommits:s=[],onGenerate:r,onCancel:a,disabled:o=!1,initialChoice:i,initialSelectedSha:c=null}){const[d,u]=l.useState(i??(e?"marker":"commit")),[p,h]=l.useState(c??null),[f,m]=l.useState(""),[g,x]=l.useState(!1),b=s.filter(_=>!jI(_.subject)),y=s.find(_=>_.sha===p)??null,v=yI(d,{defaultRange:e,selectedCommit:y,customRange:f}),j=()=>{v&&!o&&r(v)};return t.jsxs("div",{className:"mtest-range","data-testid":"manual-tests-range",children:[t.jsx("div",{className:"mtest-range-title",children:"Which commits should it read?"}),t.jsx(Qb,{choice:d,onChoose:u,hasDefaultRange:e!=null,commitCount:n??null,commitsLoaded:s.length>0,disabled:o}),d==="commit"?t.jsx(ey,{commits:b,hiddenCount:s.length-b.length,selectedSha:p,onSelect:h,disabled:o}):null,g?t.jsx(ty,{value:f,onChange:_=>{m(_),u("custom")},onSubmit:j,onCancel:a,disabled:o}):null,t.jsxs("div",{className:"mtest-range-foot",children:[t.jsx(ny,{resolved:v,awaitingCommit:d==="commit"}),t.jsx(sy,{canGenerate:v!=null,onGenerate:j,onShowCustom:()=>x(!0),showCustomButton:!g,onCancel:a,disabled:o})]})]})}const lK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeControl:ry},Symbol.toStringTag,{value:"Module"}));function ay({range:e}){return e?t.jsxs("span",{className:"mtest-adhoc","data-testid":"manual-tests-adhoc-note",children:["Last run: ",e]}):null}const cK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestAdHocNote:ay},Symbol.toStringTag,{value:"Module"}));function oy({id:e,written:n,confirming:s,busyAction:r,onWrite:a,onRequestIgnore:o,onConfirmIgnore:i,onCancelIgnore:c}){if(n)return t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-success,#4ade80)]","data-testid":`proposed-plan-planned-${e}`,children:"Planned ✓"});const d=r!==void 0;return r==="ignore"?t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--text-muted)]","data-testid":`proposed-plan-discarding-${e}`,children:"Discarding…"}):s?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"Discard?"}),t.jsx("button",{type:"button",className:Hn+$x,disabled:d,onClick:i,"data-testid":`proposed-plan-confirm-ignore-${e}`,children:"Discard"}),t.jsx("button",{type:"button",className:Hn+ao,onClick:c,"data-testid":`proposed-plan-keep-${e}`,children:"Keep"})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:Hn+Lx,disabled:d,onClick:a,"data-testid":`proposed-plan-write-${e}`,children:r==="write"?"Planning…":"Plan"}),t.jsx("button",{type:"button",className:Hn+ao,disabled:d,onClick:o,"data-testid":`proposed-plan-ignore-${e}`,children:"Ignore"})]})}const dK=Object.freeze(Object.defineProperty({__proto__:null,ProposedPlanRowActions:oy},Symbol.toStringTag,{value:"Module"}));function iy({row:e,ideaTotal:n,busyAction:s,confirming:r,error:a,onWrite:o,onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d}){const u=Bx(e);return t.jsxs("li",{className:"p-2.5 rounded-md flex flex-col gap-1.5",style:{background:"var(--bg-deep)",border:"1px solid var(--border-subtle)"},"data-testid":`proposed-plan-${e.id}`,"data-status":e.status??"pending",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-snug",children:e.title}),e.reason&&t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mt-0.5",children:e.reason}),e.source==="deferred-deliverable"&&t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mt-1",children:"Left out of this build"}),(e.severity!==void 0||u!==void 0)&&t.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[t.jsx(Cd,{id:e.id,severity:e.severity,kind:RM(e)}),t.jsx(Dx,{id:e.id,category:u}),e.source==="feature-synthesis"&&t.jsx(Rx,{row:e,ideaTotal:n})]})]}),t.jsx("div",{className:"shrink-0 flex items-center gap-1.5 pt-0.5",children:t.jsx(oy,{id:e.id,written:e.status==="written",confirming:r,busyAction:s,onWrite:o,onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d})})]}),r&&t.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"It won't be offered again."}),t.jsx(dt,{text:a&&`${a} — try Plan again, or Ignore it.`,copyText:a,testId:`proposed-plan-error-${e.id}`})]})}const uK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteProposedPlanRow:iy},Symbol.toStringTag,{value:"Module"}));function Ir(e){return e.source==="codeyam-improvement"}function wI(e){return e.kind?e.kind==="feature":e.source==="deferred-deliverable"||e.source==="feature-synthesis"||e.category==="feature"}const _I=2;function of(e){const n=e.severity??_I;return Math.max(e.sightings??0,1)*n}function ly(e){const n=d=>d.rank??Number.POSITIVE_INFINITY,s=[...e].sort((d,u)=>{if(n(d)!==n(u))return n(d)<n(u)?-1:1;const p=(u.severity??0)-(d.severity??0);return p!==0?p:(u.sightings??0)-(d.sightings??0)}),r=s.flatMap((d,u)=>Ir(d)?[u]:[]),a=r.map(d=>s[d]).sort((d,u)=>of(u)-of(d)||(u.severity??0)-(d.severity??0));r.forEach((d,u)=>{s[d]=a[u]});const o=d=>d.source==="deferred-deliverable"?[0,0]:d.source==="feature-synthesis"?[1,d.ideaRank??Number.POSITIVE_INFINITY]:[2,0],i=s.flatMap((d,u)=>!Ir(d)&&wI(d)?[u]:[]),c=i.map(d=>s[d]).sort((d,u)=>{const[p,h]=o(d),[f,m]=o(u);return p-f||(h===m?0:h<m?-1:1)});return i.forEach((d,u)=>{s[d]=c[u]}),s}function cy(e){return e.some(n=>n.spotlighted)?{surfaced:e.filter(n=>n.spotlighted),tracked:e.filter(n=>!n.spotlighted)}:{surfaced:[...e],tracked:[]}}function dy({count:e,providerLabel:n,expanded:s,onToggle:r,children:a}){return t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{type:"button",className:"text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] underline underline-offset-2","aria-expanded":s,"data-testid":"proposed-plans-view-all",onClick:r,children:s?"Hide plans being considered":`View all plans being considered (${e})`}),s&&t.jsxs("div",{className:"mt-2","data-testid":"proposed-plans-tracked",children:[t.jsxs("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:[n," is tracking these plans but doesn't consider them worthy of bringing to your attention yet — you can plan them if you want."]}),t.jsx("ul",{className:"flex flex-col gap-2",children:a})]})]})}const pK=Object.freeze(Object.defineProperty({__proto__:null,TrackedProposedPlans:dy},Symbol.toStringTag,{value:"Module"}));function uy({rows:e,providerLabel:n="The agent",busyActions:s,errorsById:r,headReleaseFailure:a=null,initiallyExpanded:o=!1,onWrite:i,onIgnore:c}){const[d,u]=l.useState(null),[p,h]=l.useState(o),f=ly(e.filter(y=>y.status!=="ignored"&&y.status!=="retired"&&!Ir(y)));if(f.length===0&&!a)return null;const{surfaced:m,tracked:g}=cy(f),x=f.filter(y=>y.source==="feature-synthesis").length,b=y=>t.jsx(iy,{row:y,ideaTotal:x,busyAction:s[y.id],confirming:d===y.id,error:r[y.id],onWrite:()=>i(y.id),onRequestIgnore:()=>u(y.id),onConfirmIgnore:()=>{u(null),c(y.id)},onCancelIgnore:()=>u(null)},y.id);return t.jsxs("div",{className:"mb-4","data-testid":"feature-complete-proposed-plans",children:[m.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-2 text-[var(--text-dim)]",children:"Suggested plans"}),t.jsx("ul",{className:"flex flex-col gap-2",children:m.map(b)})]}),g.length>0&&t.jsx(dy,{count:g.length,providerLabel:n,expanded:p,onToggle:()=>h(y=>!y),children:g.map(b)}),a&&t.jsx(qx,{failure:a})]})}const hK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteProposedPlans:uy},Symbol.toStringTag,{value:"Module"}));function py({rows:e,reports:n,busyActions:s,errorsById:r,onCopied:a,onIgnore:o,writer:i,initiallyExpanded:c=!1}){const[d,u]=l.useState(null),[p,h]=l.useState(c),f=e.filter(Ir),m=f.filter(Sl),g=ly(f.filter(v=>!Sl(v)&&v.status!=="ignored"&&v.status!=="fixed"));if(g.length===0&&m.length===0)return null;const{surfaced:x,tracked:b}=cy(g),y=v=>t.jsx(Wx,{row:v,report:n[v.id],busyAction:s[v.id],confirming:d===v.id,error:r[v.id],onCopied:()=>a(v.id),onRequestIgnore:()=>u(v.id),onConfirmIgnore:()=>{u(null),o(v.id)},onCancelIgnore:()=>u(null),writer:i},v.id);return t.jsxs("div",{className:"mb-4","data-testid":"feature-complete-codeyam-improvements",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-1 text-[var(--text-dim)]",children:"CodeYam Improvements"}),t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:"These are rough edges in CodeYam itself, not changes to your app. If you don't mind clicking Copy and sending them to the CodeYam team, that would be really helpful."}),x.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:x.map(y)}),(b.length>0||m.length>0)&&t.jsx(Hx,{count:b.length,expanded:p,onToggle:()=>h(v=>!v),decided:m.length>0?m.map(y):null,children:b.map(y)})]})}const fK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteCodeyamImprovements:py},Symbol.toStringTag,{value:"Module"}));function hy({label:e,entries:n,labelColor:s,entryColor:r,labelTestId:a,entryTestId:o,entryKeyPrefix:i}){return n.length===0?null:t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:s},"data-testid":a,children:e}),t.jsx("ul",{className:"list-disc pl-4 flex flex-col gap-1",children:n.map(c=>t.jsx("li",{className:"text-xs leading-relaxed",style:{color:r},"data-testid":o,children:c},`${i}-${c}`))})]})}const mK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteBannerSection:hy},Symbol.toStringTag,{value:"Module"})),fy="Help me figure out what to do next.";function my({onSubmitPrompt:e,disabled:n}){return t.jsx("div",{className:"mt-4 pt-3 border-t border-[var(--border-subtle)] text-center",children:t.jsx("button",{type:"button",onClick:()=>e(fy),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 gK=Object.freeze(Object.defineProperty({__proto__:null,NOT_SURE_PROMPT:fy,NotSurePrompt:my},Symbol.toStringTag,{value:"Module"}));function gy({severeWarnings:e}){return e.length===0?null:t.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:t.jsx(hy,{label:"Read this first",entries:e,labelColor:"var(--accent-danger, #f87171)",entryColor:"var(--accent-danger, #f87171)",labelTestId:"feature-complete-warnings-label",entryTestId:"feature-complete-warning",entryKeyPrefix:"warning"})})}const xK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteBanner:gy},Symbol.toStringTag,{value:"Module"}));function xy({summary:e}){return t.jsxs("div",{className:"mb-6","data-testid":"feature-complete-summary",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wider text-[var(--green-300)] mb-1",children:"Feature complete"}),t.jsxs("h2",{className:"flex items-start gap-2 text-lg font-semibold text-[var(--text-primary)] mb-3",children:[t.jsx("svg",{"data-testid":"feature-complete-check","aria-hidden":"true",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"var(--green-300)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 mt-[5px]",children:t.jsx("path",{d:"M3 8.5l3.2 3.2L13 4.8"})}),t.jsx("span",{children:e.title})]}),t.jsx(gy,{severeWarnings:e.severeWarnings??[]}),e.summary&&t.jsx(Lt,{variant:"compact",children:e.summary})]})}const bK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteSummary:xy},Symbol.toStringTag,{value:"Module"})),Hs={backgroundColor:"#2d2d2d",backgroundImage:"radial-gradient(circle, rgba(255,255,255,.16) .7px, transparent 1.1px)",backgroundSize:"12px 12px"},SI={...Hs,margin:"8px 8px 8px 0",borderRadius:14,border:"1px solid var(--border-default)",boxShadow:"0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px rgba(0,0,0,.35)",overflow:"hidden"};function Al({message:e="No page selected."}){return t.jsx("div",{"data-testid":"agent-html-empty",className:"w-full h-full flex items-center justify-center text-sm",style:{...Hs,color:"rgba(255,255,255,.5)"},children:e})}const yK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlEmptyState:Al},Symbol.toStringTag,{value:"Module"}));function by({warnings:e}){return e.length===0?null:t.jsx("ul",{className:"px-3 py-2 border-b text-xs opacity-80 list-disc list-inside",children:e.map(n=>t.jsx("li",{children:n},n))})}const vK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlLintWarnings:by},Symbol.toStringTag,{value:"Module"}));function yy({title:e,onBackToApp:n}){return t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 border-b text-sm",children:[t.jsx("span",{className:"font-medium truncate",title:e,children:e}),t.jsx("button",{type:"button",onClick:n,className:"shrink-0 px-2 py-1 rounded border text-xs",children:"Back to app"})]})}const jK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlPaneHeader:yy},Symbol.toStringTag,{value:"Module"})),lf=5173;function $s(e){if(e.startsWith("http"))try{return new URL(e).pathname}catch{return e}return e.split("?")[0]??e}function Lo(e){return e?parseInt(e.port||(e.protocol==="https:"?"443":"80"),10):0}function $o(e,{appPort:n,currentPort:s,previewOrigin:r}){return e.startsWith("http")?e:r?`${r}${e}`:s===n?e:`http://localhost:${n}${e}`}function vy(e,n,s,r,a){if(s&&s.length>0)return $o(s,{appPort:r,currentPort:n,previewOrigin:a});const o=`/scenario/${e}`;return a?`${a}${o}`:n===lf?o:`http://localhost:${lf}${o}`}const kI=["/apps","/entities","/app","/build","/history","/settings","/plan"];function jy(e){if(!e)return!1;const n=$s(e);return kI.some(s=>n===s||n.startsWith(`${s}/`))}function wy(e,n,s){const r=typeof window<"u"?Lo(window.location):0;let a="";if(cR(e)==="component"?a=vy(e.slug,r,e.url,n,s):e.url&&(a=$o(e.url,{appPort:n,currentPort:r,previewOrigin:s})),a&&!jy(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",e.slug),o?c.pathname+c.search+c.hash:c.toString()}catch{return a}return a}const br="/credential-request",_y="/setup-terminal",Sy="/setup-browser";function qd(e){return e==="/design-exploration"||e==="/design-round"||e===br||e===_y||e===Sy||Ud(e)}function Ud(e){const n=e.split("?")[0]??e;return n==="/agent-html"||n.startsWith("/agent-html/")}function ky(e){const n=e.split("?")[0]??e;if(!n.startsWith("/agent-html/"))return null;const s=n.slice(12);return s.length>0?s:null}function NI(e){const n=ky(e);return n?`/api/editor-preview-html/${n}.html`:null}function CI(e,n,s){return e.startsWith("http")||e?e:s?`${s}/results`:`http://127.0.0.1:${n}/results`}function TI(e,n,s){return e.startsWith("http")||e?e:s?`${s}/plan-preview`:`http://127.0.0.1:${n}/plan-preview`}function Ny(e,n){if(!n)return null;for(const s of e)for(const r of s.scenarios)if(r.slug===n||r.id===n)return r;return null}function PI({directPreviewPath:e,fallbackPreviewPath:n,previewKind:s,selectedScenario:r,port:a,previewOrigin:o}){return s==="blank"?"":e&&(s==="application"||s==="results"||s==="plan-preview"||s==="agent-html")?s==="results"?CI(e,a,o):s==="plan-preview"?TI(e,a,o):e.startsWith("http")||qd(e)?e:o?`${o}${e}`:`http://127.0.0.1:${a}${e}`:r?wy({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 OI(e,n=Date.now()){const s=e.includes("?")?"&":"?";return`${e}${s}_cb=${n}`}function RI(e,n){const[s,r]=l.useState(null),[a,o]=l.useState(!1);return l.useEffect(()=>{if(o(!1),!e){r(null);return}let i=!1;return fetch("/api/editor-preview-html").then(c=>{if(!c.ok)throw new Error(`listing ${c.status}`);return c.json()}).then(c=>{if(i||!Array.isArray(c))return;const d=c.find(u=>u.name===e)??null;r(d),o(d===null)}).catch(()=>{}),()=>{i=!0}},[e,n]),{entry:s,missing:a}}function Cy({previewPath:e,onBackToApp:n,commandNonce:s}){const r=ky(e),a=NI(e),{entry:o,missing:i}=RI(r,s);if(!r||!a)return t.jsx(Al,{});const c=()=>{fetch("/api/dev-mode-preview-nav",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:"/",dimension:"Desktop"})}).catch(()=>{})},d=(o==null?void 0:o.title)??r,u=(o==null?void 0:o.url)??a;return t.jsxs("div",{className:"w-full h-full flex flex-col",children:[t.jsx(yy,{title:d,onBackToApp:n??c}),t.jsx(by,{warnings:(o==null?void 0:o.warnings)??[]}),i?t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Al,{message:"No preview yet"})}):t.jsx("iframe",{src:u,title:d,sandbox:"allow-scripts",className:"flex-1 w-full border-0 bg-white"},u)]})}const wK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlPreviewPane:Cy},Symbol.toStringTag,{value:"Module"}));function ur({color:e,testId:n,title:s,pulse:r=!1}){return t.jsx("span",{"data-testid":n,title:s,style:{backgroundColor:e},className:`mr-1.5 inline-block w-2 h-2 rounded-full ${r?"animate-pulse":""}`})}const _K=Object.freeze(Object.defineProperty({__proto__:null,NavTabDot:ur},Symbol.toStringTag,{value:"Module"})),EI={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 Ml({label:e,onSelect:n}){const[s,r]=l.useState(!1);return t.jsx("button",{type:"button",role:"menuitem",onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{...EI,background:s?"var(--bg-input)":"transparent"},children:e})}const SK=Object.freeze(Object.defineProperty({__proto__:null,AssetPickerMenuItem:Ml},Symbol.toStringTag,{value:"Module"}));function Ty({busy:e,onCancel:n,onConfirm:s}){return t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,disabled:e,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:s,disabled:e,"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:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:e?"Deleting…":"Delete plan"})]})}const kK=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmActions:Ty},Symbol.toStringTag,{value:"Module"}));function Py({dependents:e}){if(e.length===0)return null;const n=e.length===1;return t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[t.jsxs("span",{style:{color:"var(--accent-red)",fontSize:12},children:[e.length," queued plan",n?"":"s"," depend",n?"s":""," ","on this one and will stay blocked"]}),t.jsx(mt,{variant:"subtle",ariaLabel:"Copy the list of blocked plans",text:e.map(s=>`${s.title} (${s.slug})`).join(`
|
|
29
|
-
`)})]}),t.jsx("ul",{style:{margin:0,paddingLeft:18,color:"var(--text-secondary)",fontSize:12},children:e.map(s=>t.jsx("li",{children:s.title},s.slug))})]})}const NK=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteDependentsWarning:Py},Symbol.toStringTag,{value:"Module"}));function Oy({title:e,filePath:n}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Delete queued plan?"}),t.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13},children:e}),t.jsx("p",{style:{margin:0,color:"var(--text-muted)",fontSize:12},"data-testid":"plan-delete-file-path",children:n}),t.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 CK=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmHeader:Oy},Symbol.toStringTag,{value:"Module"}));function Ry({title:e,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]),t.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:t.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:[t.jsx(Oy,{title:e,filePath:s}),t.jsx(Py,{dependents:r}),o&&t.jsx(Bt,{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}),t.jsx(Ty,{busy:a,onCancel:i,onConfirm:c})]})})}const TK=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmModal:Ry},Symbol.toStringTag,{value:"Module"}));function Ey({onClick:e,disabled:n}){return t.jsx("button",{type:"button",onClick:e,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 PK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDeleteButton:Ey},Symbol.toStringTag,{value:"Module"})),AI="editor",MI="preview";function II(e){if(!e)return null;let n;try{n=new URL(e)}catch{return null}const s=n.hostname.split(".");if(s.length<3||s[1]!==AI)return null;const r=[s[0],MI,...s.slice(2)].join(".");return`${n.protocol}//${r}`}async function DI(e,n=4e3){if(!e)return"unknown";const s=new AbortController,r=setTimeout(()=>s.abort(),n);try{return await fetch(e,{credentials:"include",mode:"no-cors",redirect:"follow",signal:s.signal}),"answers"}catch{return s.signal.aborted?"unknown":"absent"}finally{clearTimeout(r)}}function io(e){return`codeyam-editor editor config-override previewOrigin ${e}`}function Gd(e,n=!0){const s=II(e),[r,a]=l.useState(!1);return l.useEffect(()=>{if(!n||!s){a(!1);return}let o=!1;return DI(s).then(i=>{o||a(i==="answers")}),()=>{o=!0}},[n,s]),r&&s?s:null}function LI(e){return`This editor is running on ${e.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 ${e.file}, or run this, which adds it for you after confirming: ${e.setupCommand}`}function $I(e){return e?"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 Ay({onDismiss:e,hint:n=null,onManagedFleetVm:s=!1,editorOrigin:r}){const a=r??(typeof window<"u"?window.location.origin:null),o=Gd(a),i=o!==null,c=i?`A preview host for this machine already exists and is answering: ${o}. Point the preview at it with:
|
|
30
|
-
|
|
31
|
-
${io(o)}
|
|
32
|
-
|
|
33
|
-
It takes effect immediately — the editor reloads its config in place, so no restart is needed.
|
|
34
|
-
|
|
35
|
-
If the preview then comes up blank, open ${o} in its own tab once and sign in there. Access is granted per address, and the sign-in page refuses to load inside a frame — so the first visit has to be a normal tab, and it only has to happen once.`:n?LI(n):$I(s);return t.jsx(Bt,{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?io(o):(n==null?void 0:n.stanza)??void 0,actions:[{label:"Dismiss",onClick:e,variant:"secondary",ariaLabel:"Dismiss preview origin notice",testId:"preview-dedicated-origin-notice-dismiss"}]})}const OK=Object.freeze(Object.defineProperty({__proto__:null,PreviewDedicatedOriginNotice:Ay},Symbol.toStringTag,{value:"Module"}));function My({title:e,body:n,spinner:s,restartCount:r,variant:a}){return t.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":a,className:"absolute inset-0 flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",style:{background:"var(--bg-deep, #1b1b1b)"},children:t.jsxs("div",{className:"flex max-w-xs flex-col items-center p-6 text-center",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[s?t.jsx("span",{"aria-hidden":"true","data-testid":"preview-waiting-spinner",className:"h-3 w-3 shrink-0 animate-spin rounded-full border-[1.5px] border-[rgba(255,255,255,.12)] border-t-[var(--working)]"}):t.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-3 w-3 shrink-0 text-[var(--text-muted)]","aria-hidden":"true",children:[t.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),t.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]}),t.jsx("h3",{className:"text-[13.5px] font-medium text-[var(--text-secondary)]",children:e}),r>0&&t.jsxs("span",{className:"text-[11.5px] text-[var(--text-dim)]",children:["#",r]})]}),t.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-[var(--text-dim)]",children:n})]})})}const RK=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingOverlay:My},Symbol.toStringTag,{value:"Module"}));function vt({widthPct:e,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 t.jsx("div",{style:{width:`${e}%`,height:n,borderRadius:4,background:r,backgroundSize:"200% 100%",animation:"mockup-skeleton-shimmer 1.6s linear infinite",opacity:s==="surface"?.85:1}})}const EK=Object.freeze(Object.defineProperty({__proto__:null,SkeletonBar:vt},Symbol.toStringTag,{value:"Module"}));function Fo(){return t.jsx("style",{children:`
|
|
36
|
-
@keyframes mockup-skeleton-shimmer {
|
|
37
|
-
0% { background-position: -200% 0; }
|
|
38
|
-
100% { background-position: 200% 0; }
|
|
39
|
-
}
|
|
40
|
-
`})}const AK=Object.freeze(Object.defineProperty({__proto__:null,SkeletonShimmerKeyframes:Fo},Symbol.toStringTag,{value:"Module"}));function Iy(){return t.jsx("li",{"aria-hidden":"true",className:"border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)]",children:t.jsxs("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(vt,{widthPct:42,heightPx:14})}),t.jsx(vt,{widthPct:6,heightPx:12})]})})}function Yd({count:e,testId:n,label:s="Loading plans"}){return t.jsxs(t.Fragment,{children:[t.jsx(Fo,{}),t.jsxs("div",{role:"status","aria-busy":"true",children:[t.jsx("span",{className:"sr-only",children:s}),t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":n??"plan-row-skeleton-list",children:Array.from({length:Math.max(e,1)},(r,a)=>t.jsx(Iy,{},a))})]})]})}const MK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowSkeleton:Iy,PlanRowSkeletonList:Yd},Symbol.toStringTag,{value:"Module"}));function Dy({count:e}){return t.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:e===1?"1 file queued":`${e} files queued`})}const IK=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCountLine:Dy},Symbol.toStringTag,{value:"Module"}));function zo(e,n,s){l.useEffect(()=>{const r=o=>{const i=o.target;e.current&&e.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)}},[e,n,s])}function Ly({onChooseFiles:e,onChooseFolder:n,onClose:s,triggerRef:r}){const a=l.useRef(null);return zo(a,s,r),t.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:[t.jsx(Ml,{label:"Files…",onSelect:()=>{e(),s()}}),t.jsx(Ml,{label:"Folder…",onSelect:()=>{n(),s()}})]})}const DK=Object.freeze(Object.defineProperty({__proto__:null,AssetPickerMenu:Ly},Symbol.toStringTag,{value:"Module"})),FI={webkitdirectory:""};function $y({fileInputRef:e,folderInputRef:n,onFolderPick:s}){const[r,a]=l.useState(!1),o=l.useRef(null);return t.jsxs("div",{style:{position:"relative",marginTop:"var(--spacing-xs, 4px)",marginBottom:"var(--spacing-sm, 8px)"},children:[t.jsx("input",{ref:n,type:"file",...FI,onChange:s,style:{display:"none"}}),t.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&&t.jsx(Ly,{onChooseFiles:()=>{var i;return(i=e.current)==null?void 0:i.click()},onChooseFolder:()=>{var i;return(i=n.current)==null?void 0:i.click()},onClose:()=>a(!1),triggerRef:o})]})}const LK=Object.freeze(Object.defineProperty({__proto__:null,ChooseAssetsButton:$y},Symbol.toStringTag,{value:"Module"}));function Fy({value:e}){const[n,s]=l.useState(!1),r=async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}};return t.jsx("button",{type:"button",onClick:r,"data-testid":"copy-path-button",title:n?"Copied":`Copy ${e}`,"aria-label":n?"Copied":`Copy ${e}`,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 $K=Object.freeze(Object.defineProperty({__proto__:null,CopyPathButton:Fy},Symbol.toStringTag,{value:"Module"}));function zy({slug:e,count:n,tooltip:s}){return n<=0?null:t.jsxs("span",{"data-testid":`plan-row-blocked-${e}`,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 FK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowBlockedChip:zy},Symbol.toStringTag,{value:"Module"}));function Vd({children:e,testId:n}){return t.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:e})}const zK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowTag:Vd},Symbol.toStringTag,{value:"Module"}));function Kd({mode:e}){return t.jsx(Vd,{children:e})}const BK=Object.freeze(Object.defineProperty({__proto__:null,PlanModeBadge:Kd},Symbol.toStringTag,{value:"Module"}));function Jd({title:e,timestamp:n,tone:s="primary"}){return t.jsxs("span",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"min-w-0 truncate text-sm "+(s==="muted"?"text-[var(--text-muted)]":"text-[var(--text-primary)]"),children:e}),t.jsx("span",{className:"shrink-0 text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:Jn(n)})]})}const WK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowTitleWithAge:Jd},Symbol.toStringTag,{value:"Module"}));function By({slug:e,handleRef:n,attributes:s,listeners:r}){return t.jsx("span",{ref:n,"data-testid":`plan-drag-${e}`,"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 HK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDragHandle:By},Symbol.toStringTag,{value:"Module"}));function Kr({title:e,count:n,expanded:s,onToggle:r,testId:a}){return t.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:[t.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:"⌄"}),t.jsx("span",{className:"text-sm text-[var(--text-primary)] "+(s?"font-medium":"font-normal"),children:e}),t.jsxs("span",{className:"text-sm text-[var(--text-dim)]",children:["(",n,")"]})]})}const qK=Object.freeze(Object.defineProperty({__proto__:null,PlanSectionHeader:Kr},Symbol.toStringTag,{value:"Module"}));function Wy({slug:e,identity:n,step:s,age:r,dead:a}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{"data-testid":`plan-claim-identity-${e}`,children:["claimed by ",n]}),s&&t.jsx("span",{"data-testid":`plan-claim-step-${e}`,children:s}),t.jsxs("span",{"data-testid":`plan-claim-started-${e}`,children:["started ",r]}),a&&t.jsx("span",{className:"text-[var(--text-muted)]",children:"(inactive)"})]})}const UK=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRowMeta:Wy},Symbol.toStringTag,{value:"Module"}));function Hy({slug:e,title:n,timestamp:s,position:r,author:a,dragHandleRef:o,dragHandleAttributes:i,dragHandleListeners:c}){return t.jsxs(t.Fragment,{children:[o&&t.jsx(By,{slug:e,handleRef:o,attributes:i,listeners:c}),typeof r=="number"&&t.jsxs("span",{className:"text-xs text-[var(--text-dim)] tabular-nums min-w-[1.25rem]",children:[r,"."]}),a&&t.jsx(Do,{author:a}),t.jsx("span",{className:"flex-1 min-w-0",children:t.jsx(Jd,{title:n,timestamp:s})})]})}const GK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowIdentity:Hy},Symbol.toStringTag,{value:"Module"}));function qy(e){return{dead:e.sessionAlive===!1}}function Uy({claim:e,staleFetch:n=!1}){const s=xs(),{dead:r}=qy(e),a=e.claimedBy.agentProvider??"agent",o=r?" (inactive)":"",i=Jn(e.claimedBy.startedAt,s),c=e.source==="local"?`● this session · started ${i}`:e.source==="same-machine"?`claimed by ${a}@${e.claimedBy.machine} (same machine) · ${i}`:`claimed by ${a}@${e.claimedBy.machine} · ${i}`;return t.jsxs("span",{"data-testid":`plan-row-claim-badge-${e.slug}`,title:`Source: ${e.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 YK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowClaimBadge:Uy},Symbol.toStringTag,{value:"Module"}));function zI({isAgentBuilding:e=!1,unsatisfiedDepCount:n=0,claim:s}){return e?"building":n>0?"dependencies":s&&s.source!=="local"?"claimed":null}function Gy({slug:e,mode:n,expanded:s,onRun:r,launching:a=!1,blocked:o=!1,unsatisfiedDepCount:i=0,unsatisfiedDepTooltip:c,claim:d,staleFetch:u=!1}){return t.jsxs(t.Fragment,{children:[t.jsx(Kd,{mode:n}),t.jsx(zy,{slug:e,count:i,tooltip:c}),d&&t.jsx(Uy,{claim:d,staleFetch:u}),r&&t.jsx(bd,{slug:e,onRun:r,launching:a,blockedReason:zI({isAgentBuilding:o,unsatisfiedDepCount:i,claim:d})}),t.jsx(Ur,{expanded:s,testId:`plan-row-chevron-${e}`})]})}const VK=Object.freeze(Object.defineProperty({__proto__:null,PlanRowControls:Gy},Symbol.toStringTag,{value:"Module"}));function Il({children:e,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 t.jsx("p",{"data-testid":r,className:`${o} text-sm ${a}`,children:e})}const KK=Object.freeze(Object.defineProperty({__proto__:null,PlanSectionStatus:Il},Symbol.toStringTag,{value:"Module"})),Dl="#6b6b70",BI={doc:["#2F6FEB","Word document"],docx:["#2F6FEB","Word document"],pdf:["#E5484D","PDF"],xls:["#1F9D55","Spreadsheet"],xlsx:["#1F9D55","Spreadsheet"],csv:["#1F9D55","Spreadsheet"],ppt:["#E8712A","Presentation"],pptx:["#E8712A","Presentation"],key:["#E8712A","Presentation"],fig:["#A259FF","Figma file"],sketch:["#E8A33A","Sketch file"],md:["#56657A","Markdown"],txt:[Dl,"Text"]},WI=new Set(["png","jpg","jpeg","gif","webp","svg","avif"]);function HI(e){return e<1024*1024?`${Math.max(1,Math.round(e/1024))} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qI(e,n){const s=e.lastIndexOf("."),r=s>0&&s<e.length-1?e.slice(s+1).toLowerCase():"",a=HI(n);if(WI.has(r))return{ext:r.slice(0,4),color:Dl,kind:"Image",size:a,isImage:!0};const o=BI[r];return o?{ext:r.slice(0,4),color:o[0],kind:o[1],size:a,isImage:!1}:{ext:r?r.slice(0,4):"file",color:Dl,kind:r?`${r.toUpperCase()} file`:"File",size:a,isImage:!1}}function Yy(e){const[n,s]=l.useState(null);return l.useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){s(null);return}const r=URL.createObjectURL(e);return s(r),()=>URL.revokeObjectURL(r)},[e]),n}function Jr({file:e,onRemove:n}){const s=qI(e.name,e.size),r=Yy(s.isImage?e:null);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,maxWidth:230,padding:4,borderRadius:9,background:"#232325",border:"1px solid rgba(255,255,255,.12)",boxShadow:"0 1px 0 rgba(255,255,255,.06) inset, 0 3px 8px rgba(0,0,0,.22)",fontSize:12,color:"var(--text-primary)"},children:[r?t.jsx("span",{"aria-hidden":"true",style:{flex:"none",width:28,height:28,borderRadius:5,background:`center / cover url("${r}")`}}):t.jsx("span",{"aria-hidden":"true","data-testid":"file-type-icon",style:{flex:"none",position:"relative",width:22,height:28,borderRadius:"3px 7px 3px 3px",background:s.color,display:"grid",placeItems:"end center",paddingBottom:3,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:6.5,fontWeight:600,letterSpacing:".02em",color:"#fff",textTransform:"uppercase",overflow:"hidden"},children:s.ext}),t.jsxs("span",{style:{display:"flex",flexDirection:"column",minWidth:0,lineHeight:1.2},children:[t.jsx("span",{title:e.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:e.name}),t.jsxs("span",{style:{fontSize:10.5,color:"#a8a8ae"},children:[s.kind," · ",s.size]})]}),t.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,onClick:n,style:{flex:"none",width:20,height:20,borderRadius:5,border:"none",background:"none",color:"#a8a8ae",cursor:"pointer",fontSize:13},children:"×"})]})}const JK=Object.freeze(Object.defineProperty({__proto__:null,OnboardingFileChip:Jr},Symbol.toStringTag,{value:"Module"})),cf=84,df=320;function qs({value:e,onChange:n,testId:s,placeholder:r="Describe the change you want",onSubmit:a,canSubmit:o=!0,files:i=[],onAddFiles:c,onRemoveFile:d,busy:u=!1,error:p=null,minHeight:h=cf}){const f=l.useRef(null),m=l.useRef(null),[g,x]=l.useState(!1);l.useLayoutEffect(()=>{const y=f.current;if(!y)return;y.style.height="auto";const v=Math.min(df,Math.max(h,y.scrollHeight));y.style.height=`${v}px`,y.style.overflowY=y.scrollHeight>df?"auto":"hidden"},[e,h]);const b=u?`Saving ${i.length===1?i[0].name:`${i.length} files`}…`:i.length>0?`${i.length} file${i.length>1?"s":""} attached`:"Drop or paste files and screenshots";return t.jsxs("div",{className:"mt-4",children:[p&&t.jsx("div",{role:"alert",className:"mb-1.5 text-xs text-[var(--accent-danger,#f87171)]",children:p}),t.jsxs("div",{"data-testid":`${s}-box`,"data-dragging":g?"true":"false",onDragOver:y=>{c&&(y.preventDefault(),x(!0))},onDragLeave:y=>{y.currentTarget.contains(y.relatedTarget)||x(!1)},onDrop:y=>{var j;if(!c)return;y.preventDefault(),x(!1);const v=Array.from(((j=y.dataTransfer)==null?void 0:j.files)??[]);v.length&&c(v)},className:`rounded-2xl border bg-[var(--bg-input)] transition-colors focus-within:border-[var(--line-strong)] ${g?"border-dashed border-[var(--accent-active)]":"border-[rgba(255,255,255,.09)]"}`,children:[t.jsx("textarea",{ref:f,value:e,onChange:y=>n(y.target.value),onKeyDown:y=>{!a||u||y.key!=="Enter"||y.shiftKey||y.nativeEvent.isComposing||(y.preventDefault(),a())},onPaste:y=>{var j;if(!c)return;const v=Array.from(((j=y.clipboardData)==null?void 0:j.files)??[]);v.length!==0&&(y.preventDefault(),c(v))},placeholder:r,rows:h<cf?1:3,disabled:u,"data-testid":s,"aria-label":r,style:{minHeight:h},className:"block w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-sm leading-relaxed text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:outline-none"}),i.length>0&&t.jsx("div",{"aria-label":"Attached files","data-testid":`${s}-attachments`,className:`flex flex-wrap gap-1.5 px-3 pt-1.5 ${u?"opacity-60":""}`,children:i.map((y,v)=>t.jsx(Jr,{file:y,onRemove:()=>d==null?void 0:d(v)},`${y.name}-${v}`))}),(c||a)&&t.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2 pb-3",children:[c&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{var y;return(y=m.current)==null?void 0:y.click()},disabled:u,"aria-label":"Add files",title:"Add files or screenshots","data-testid":`${s}-add-files`,className:"grid h-8 w-8 flex-none place-items-center rounded-lg border border-[var(--line-strong)] bg-[rgba(255,255,255,.07)] text-lg leading-none text-[var(--text-primary)] cursor-pointer transition-colors hover:border-white/[0.35] hover:bg-[rgba(255,255,255,.16)] disabled:cursor-not-allowed",children:t.jsx("span",{"aria-hidden":"true",children:"+"})}),t.jsx("input",{ref:m,type:"file",multiple:!0,hidden:!0,"data-testid":`${s}-file-input`,onChange:y=>{const v=Array.from(y.target.files??[]);y.target.value="",v.length&&c(v)}}),t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--text-dim)]",children:b})]}),t.jsx("span",{className:"flex-1"}),a&&t.jsx("button",{type:"button",onClick:a,disabled:u||!o,"aria-label":"Send",title:"Send (Enter)","data-testid":`${s}-send`,className:"grid h-9 w-9 flex-none place-items-center rounded-[10px] bg-[var(--accent-active)] text-[var(--text-on-accent)] transition-opacity hover:opacity-90 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M12.5 3.5v4a2 2 0 0 1-2 2H3.5M6 7l-2.5 2.5L6 12"})})})]})]})]})}const XK=Object.freeze(Object.defineProperty({__proto__:null,ChangeDescriptionInput:qs},Symbol.toStringTag,{value:"Module"})),Vy=t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 9.5l6 6 6-6"})}),Ky=t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})}),Jy=t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Xy=t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})}),Qy=t.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 3a9 9 0 1 0 9 9"}),t.jsx("path",{d:"M12 3v9l6 3"}),t.jsx("path",{d:"M16 4h5V9"})]}),QK=Object.freeze(Object.defineProperty({__proto__:null,CHAT_ICON:Ky,CHEVRON_ICON:Vy,EMPTY_MARK_ICON:Qy,EYE_ICON:Jy,EYE_OFF_ICON:Xy},Symbol.toStringTag,{value:"Module"}));async function Us(e){const n=new FormData;for(const a of e)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??e.map(a=>a.relativePath)}function UI(e,n){if(!n.has(e))return e;const s=e.lastIndexOf("."),r=s>0?e.slice(0,s):e,a=s>0?e.slice(s):"";let o=2;for(;n.has(`${r}-${o}${a}`);)o+=1;return`${r}-${o}${a}`}function Bo(){const[e,n]=l.useState([]),[s,r]=l.useState(!1),[a,o]=l.useState(null);return{files:e,addFiles:d=>n(u=>{const p=new Set(u.map(f=>f.name)),h=[...u];for(const f of d){const m=UI(f.name,p);p.add(m),h.push(m===f.name?f:new File([f],m,{type:f.type}))}return h}),removeFile:d=>n(u=>u.filter((p,h)=>h!==d)),clear:()=>n([]),saving:s,error:a,save:async()=>{if(o(null),e.length===0)return"";r(!0);try{await Us(e.map((d,u)=>({id:`draft-${Date.now()}-${u}`,file:d,relativePath:d.name,description:""})))}catch(d){return o(d instanceof Error?d.message:"Couldn't add those files."),null}finally{r(!1)}return Mo(e.map(d=>d.name))}}}function Xd({draft:e,onDraftChange:n,onSubmit:s,onAsk:r,placeholder:a,testId:o}){const i=l.useRef(null),c=Bo(),d=()=>{var u;if(c.files.length===0){(u=i.current)==null||u.requestSubmit();return}c.save().then(p=>{p!==null&&(c.clear(),r==null||r([p,e.trim()].filter(Boolean).join(" ")))})};return t.jsx("form",{ref:i,onSubmit:s,children:t.jsx(qs,{value:e,onChange:n,testId:o,placeholder:a,onSubmit:d,files:c.files,onAddFiles:c.addFiles,onRemoveFile:c.removeFile,busy:c.saving,error:c.error,minHeight:40})})}const ZK=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesComposer:Xd},Symbol.toStringTag,{value:"Module"})),GI=[{prompt:"Import my services from .env",label:"Import from .env"},{prompt:"Scan package.json and Cargo.toml for services",label:t.jsx(t.Fragment,{children:"Scan package.json & Cargo.toml"})},{prompt:"Help me add a service manually",label:"Add one manually"}];function Zy({draft:e,onDraftChange:n,onSubmit:s,onAsk:r,brokerStarter:a}){return t.jsx("div",{className:"xsvc-empty-wrap",children:t.jsxs("div",{className:"xsvc-empty-card",children:[t.jsx("div",{className:"xsvc-empty-mark","aria-hidden":"true",children:Qy}),t.jsx("h2",{children:"No external services mapped yet"}),t.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."}),t.jsxs("div",{className:"xsvc-chat-hero",children:[t.jsxs("div",{className:"xsvc-lead",children:[Ky,"Chat with the AI"]}),t.jsx(Xd,{draft:e,onDraftChange:n,onSubmit:s,onAsk:r,placeholder:"e.g. We use Anthropic for the AI, Vercel for hosting, and our domain is codeyam.com",testId:"xsvc-empty-input"}),t.jsxs("div",{className:"xsvc-chips",children:[GI.map(o=>t.jsxs("button",{type:"button",className:"xsvc-chip",onClick:()=>r==null?void 0:r(o.prompt),children:[t.jsx("span",{className:"g",children:"↳"}),o.label]},o.prompt)),a?t.jsxs("button",{type:"button",className:"xsvc-chip",onClick:a.onSelect,children:[t.jsx("span",{className:"g",children:"✦"}),a.label]}):null]})]})]})})}const eJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesEmptyState:Zy},Symbol.toStringTag,{value:"Module"})),Ke=({children:e})=>t.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:e}),uf={vercel:t.jsx(Ke,{children:t.jsx("path",{d:"M12 4l8 14H4z",fill:"currentColor",stroke:"none"})}),netlify:t.jsxs(Ke,{children:[t.jsx("path",{d:"M12 3l9 9-9 9-9-9z"}),t.jsx("path",{d:"M12 8v8M8 12h8"})]}),cloudflare:t.jsx(Ke,{children:t.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:t.jsxs(Ke,{children:[t.jsx("circle",{cx:"12",cy:"10",r:"6"}),t.jsx("path",{d:"M9 15l-1 5 4-2 4 2-1-5"})]}),github:t.jsxs(Ke,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"8"}),t.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:t.jsx(Ke,{children:t.jsx("path",{d:"M12 4v16M4 12h16M6.3 6.3l11.4 11.4M17.7 6.3L6.3 17.7"})}),neon:t.jsx(Ke,{children:t.jsx("path",{d:"M5 19V5l14 14V5"})}),stripe:t.jsx(Ke,{children:t.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"})})},pf={"Code hosting":t.jsxs(Ke,{children:[t.jsx("circle",{cx:"6",cy:"7",r:"2.4"}),t.jsx("circle",{cx:"6",cy:"17",r:"2.4"}),t.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),t.jsx("path",{d:"M6 9.4v5.2M17 11.4c0 3-3 3.6-6 4.2"})]}),"Package registry":t.jsxs(Ke,{children:[t.jsx("path",{d:"M12 3l8 4.2v9.6L12 21l-8-4.2V7.2z"}),t.jsx("path",{d:"M4 7.2l8 4.3 8-4.3M12 11.5V21"})]}),"Cloud platform":t.jsx(Ke,{children:t.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":t.jsxs(Ke,{children:[t.jsx("path",{d:"M12 3v3.5M12 17.5V21M3 12h3.5M17.5 12H21"}),t.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"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Cache & queue":t.jsxs(Ke,{children:[t.jsx("path",{d:"M4 7h16M4 12h16M4 17h16"}),t.jsx("circle",{cx:"8",cy:"7",r:"1.3",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:"1.3",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"10",cy:"17",r:"1.3",fill:"currentColor",stroke:"none"})]}),"Storage & media":t.jsxs(Ke,{children:[t.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"2"}),t.jsx("circle",{cx:"9",cy:"10",r:"1.8"}),t.jsx("path",{d:"M4 17l4.5-4.5L13 17M13 14l2.5-2.5L20 16"})]}),Messaging:t.jsx(Ke,{children:t.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:t.jsxs(Ke,{children:[t.jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),t.jsx("path",{d:"M15 15l5 5"})]}),Containers:t.jsxs(Ke,{children:[t.jsx("rect",{x:"3",y:"10",width:"5",height:"5",rx:"0.8"}),t.jsx("rect",{x:"9.5",y:"10",width:"5",height:"5",rx:"0.8"}),t.jsx("rect",{x:"9.5",y:"4.5",width:"5",height:"5",rx:"0.8"}),t.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":t.jsxs(Ke,{children:[t.jsx("path",{d:"M4 12a8 8 0 0 1 13.7-5.6M20 12a8 8 0 0 1-13.7 5.6"}),t.jsx("path",{d:"M17 3v4h-4M7 21v-4h4"})]}),Domain:t.jsxs(Ke,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.5"}),t.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:t.jsxs(Ke,{children:[t.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"6",rx:"1.5"}),t.jsx("rect",{x:"3.5",y:"13.5",width:"17",height:"6",rx:"1.5"}),t.jsx("path",{d:"M7 7.5h.01M7 16.5h.01"})]}),Payments:t.jsxs(Ke,{children:[t.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),t.jsx("path",{d:"M3 9.5h18"})]}),Database:t.jsxs(Ke,{children:[t.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),t.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),t.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Database ORM":t.jsxs(Ke,{children:[t.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),t.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),t.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Backend platform":t.jsxs(Ke,{children:[t.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),t.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),t.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),Authentication:t.jsxs(Ke,{children:[t.jsx("circle",{cx:"9",cy:"9",r:"4"}),t.jsx("path",{d:"M12 12l7 7M16 16l2-2M18.5 13.5l1.5 1.5"})]}),"Transactional email":t.jsxs(Ke,{children:[t.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),t.jsx("path",{d:"M3.5 7l8.5 6 8.5-6"})]}),"Product analytics":t.jsxs(Ke,{children:[t.jsx("path",{d:"M4 20V4M4 20h16"}),t.jsx("path",{d:"M8 16v-3M12 16V8M16 16v-6"})]}),"Error monitoring":t.jsxs(Ke,{children:[t.jsx("path",{d:"M12 3l8 4v5c0 5-3.5 8-8 9-4.5-1-8-4-8-9V7z"}),t.jsx("path",{d:"M12 8.5v4M12 15.5h.01"})]})},YI={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 ev(e){return e&&YI[e]||null}function tv({providerId:e,category:n}){return e&&uf[e]?uf[e]:n&&pf[n]?pf[n]:null}const tJ=Object.freeze(Object.defineProperty({__proto__:null,G:Ke,ProviderLogo:tv,providerBrand:ev},Symbol.toStringTag,{value:"Module"}));function nv(e){return e.length<=10?"•".repeat(Math.max(e.length,6)):`${e.slice(0,6)}••••••••••${e.slice(-4)}`}function Qd({apiKey:e}){const[n,s]=l.useState(!1);return t.jsxs("div",{className:"xsvc-detrow",children:[t.jsx("span",{className:"xsvc-detlabel",children:"API key"}),t.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:[t.jsx("span",{className:"mono",children:n?e:nv(e)}),t.jsx("span",{className:"eye","aria-hidden":"true",children:n?Xy:Jy})]})]})}const nJ=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:Qd,maskKey:nv},Symbol.toStringTag,{value:"Module"}));function Zd({svc:e,category:n,expanded:s,onToggle:r,onAction:a,onAsk:o}){var d,u,p;const i=tv({providerId:e.providerId,category:e.category}),c=ev(e.providerId);return t.jsxs("div",{className:`xsvc-rowwrap${s?" open":""}`,children:[t.jsxs("div",{className:`xsvc-row${e.attn?" attn":""}${e.pending?" pending":""}`,role:"button",tabIndex:0,"aria-expanded":s,onClick:r,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),r())},children:[t.jsx("div",{className:`xsvc-tile t-${e.tone??"lime"}`,style:c?{background:c.bg,color:c.fg}:void 0,children:i??e.monogram??e.name.slice(0,1).toUpperCase()}),t.jsxs("div",{className:"xsvc-rmain",children:[t.jsxs("div",{className:"xsvc-rname",children:[e.name,(d=e.tags)==null?void 0:d.filter(h=>h.kind!=="origin").map((h,f)=>t.jsx("span",{className:`xsvc-tag ${h.kind}`,children:h.text},f))]}),t.jsx("div",{className:"xsvc-rdesc",children:e.desc})]}),t.jsxs("div",{className:"xsvc-rright",children:[n?t.jsx("span",{className:"xsvc-rcat",children:n}):null,e.actionLabel?t.jsx("button",{type:"button",className:"xsvc-addkey",onClick:h=>{h.stopPropagation(),e.actionKey&&a&&a(e.actionKey)},children:e.actionLabel}):t.jsxs("div",{className:"xsvc-rmeta",children:[e.metaBig?t.jsx("div",{className:"big",children:e.metaBig}):null,e.metaLil?t.jsx("div",{className:"lil",children:e.metaLil}):null]}),t.jsx("span",{className:`xsvc-arr${s?" down":""}`,"aria-hidden":"true",children:Vy})]})]}),s?t.jsxs("div",{className:"xsvc-detail",children:[(u=e.detail)==null?void 0:u.map((h,f)=>t.jsxs("div",{className:"xsvc-detrow",children:[t.jsx("span",{className:"xsvc-detlabel",children:h.label}),t.jsx("span",{className:`xsvc-detval${h.mono?" mono":""}`,children:h.value})]},f)),e.apiKey?t.jsx(Qd,{apiKey:e.apiKey}):null,!((p=e.detail)!=null&&p.length)&&!e.apiKey?t.jsx("div",{className:"xsvc-detrow",children:t.jsx("span",{className:"xsvc-detval",children:e.desc})}):null,o?t.jsx(yx,{serviceName:e.name,onAsk:o}):null]}):null]})}const sJ=Object.freeze(Object.defineProperty({__proto__:null,ServiceRow:Zd},Symbol.toStringTag,{value:"Module"})),VI="pending:custom-domain";function sv({groups:e,onAction:n,onSaveDomain:s,onAsk:r}){const[a,o]=l.useState(null),i=e.flatMap(u=>u.items.map((p,h)=>({svc:p,category:p.category??u.label,key:`${u.label}:${p.name}:${h}`}))),c=[...i.filter(u=>!u.svc.pending&&u.svc.attn),...i.filter(u=>!u.svc.pending&&!u.svc.attn)],d=i.filter(u=>u.svc.pending);return t.jsxs("div",{className:"xsvc-groups",children:[c.length>0&&t.jsxs("section",{className:"xsvc-group","aria-label":"In use",children:[t.jsxs("div",{className:"xsvc-group-head",children:[t.jsx("span",{className:"xsvc-seclabel",children:"In use"}),t.jsxs("span",{className:"xsvc-seccount",children:[c.length," ",c.length===1?"service":"services"]})]}),t.jsx("div",{className:"xsvc-rows",children:c.map(({svc:u,category:p,key:h})=>t.jsx(Zd,{svc:u,category:p,expanded:a===h,onToggle:()=>o(f=>f===h?null:h),onAction:n,onAsk:r},h))})]}),d.length>0&&t.jsxs("section",{className:"xsvc-group","aria-label":"Not set up yet",children:[t.jsxs("div",{className:"xsvc-group-head",children:[t.jsx("span",{className:"xsvc-seclabel",children:"Not set up yet"}),t.jsx("span",{className:"xsvc-seccount",children:"add when you need them"})]}),t.jsx("div",{className:"xsvc-setup-grid",children:d.map(({svc:u,category:p,key:h})=>t.jsxs("div",{"data-testid":"xsvc-setup-card",className:"xsvc-setup-card",children:[t.jsx("div",{className:"xsvc-setup-name",children:p}),t.jsx("div",{className:"xsvc-setup-desc",children:u.name}),u.actionLabel?t.jsxs("button",{type:"button",className:"xsvc-setup-btn",onClick:()=>{u.actionKey&&n&&n(u.actionKey)},children:[t.jsx("span",{children:u.actionLabel}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}):null,u.actionKey===VI&&s?t.jsx(kx,{onSave:s}):null]},h))})]})]})}const rJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServiceGroupList:sv},Symbol.toStringTag,{value:"Module"}));function eu({sort:e,onSortChange:n}){return t.jsxs("div",{className:"xsvc-toolbar",children:[t.jsx("span",{className:"xsvc-sortlbl",children:"Sort by"}),t.jsxs("div",{className:"xsvc-seg",children:[t.jsx("button",{type:"button",className:e==="type"?"on":"",onClick:()=>n("type"),children:"Type"}),t.jsx("button",{type:"button",className:e==="provider"?"on":"",onClick:()=>n("provider"),children:"Provider"})]})]})}const aJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSortToolbar:eu},Symbol.toStringTag,{value:"Module"})),KI=["When does codeyam.com renew?","What's my monthly spend?","Anything missing a key?"];function rv({onPick:e}){return t.jsx("span",{className:"xsvc-chips",children:KI.map(n=>t.jsx("button",{type:"button",className:"xsvc-chip",onClick:()=>e(n),children:n},n))})}const oJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSuggestionChips:rv},Symbol.toStringTag,{value:"Module"}));function av({draft:e,onDraftChange:n,onSubmit:s,onAsk:r,chatSlot:a,bare:o=!1}){const i=!a&&e.trim()==="";return t.jsxs("div",{className:o?"xsvc-askcard xsvc-askcard-bare":"xsvc-askcard",children:[t.jsx(Xd,{draft:e,onDraftChange:n,onSubmit:s,onAsk:r,placeholder:"Ask the AI about your domains, keys, subscriptions…",testId:"xsvc-ask-input"}),i?t.jsx("div",{className:"xsvc-ask-suggestions",children:t.jsx(rv,{onPick:c=>{n(c),r==null||r(c)}})}):null,a?t.jsx("div",{className:"xsvc-ask-chat",children:a}):null]})}const iJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesAskCard:av},Symbol.toStringTag,{value:"Module"}));function ov({shots:e,initialIndex:n=0,onSelect:s,onClose:r}){const a=e.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(x=>o(x+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]),e.length===0)return null;const p=e[i],h=i===0,f=i===a,m="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 t.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:t.jsxs("div",{className:"flex flex-1 min-h-0 flex-col px-6 py-4",onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-[11px] font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:p.routeLabel}),t.jsx("p",{className:"truncate text-lg font-semibold text-[var(--text-primary)]",children:p.name})]}),t.jsxs("span",{className:"flex-none text-xs font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:[i+1," / ",e.length]}),t.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:"✕"})]}),t.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-4",children:[t.jsx("button",{type:"button",onClick:()=>d(-1),disabled:h,"aria-label":"Previous scenario",className:m,children:"‹"}),t.jsx("button",{type:"button",onClick:()=>{s(p.slug),r()},"aria-label":`Open ${p.name} live`,className:"flex min-h-0 flex-1 cursor-pointer items-center justify-center self-stretch",children:t.jsx("div",{className:"flex max-h-[80vh] max-w-[90vw] items-center justify-center",children:t.jsx(Ot,{screenshotPath:p.screenshotPath??void 0,cacheBuster:p.screenshotCapturedAtMs??void 0,alt:p.name,className:"max-h-[80vh] max-w-[90vw] object-contain"})})}),t.jsx("button",{type:"button",onClick:()=>d(1),disabled:f,"aria-label":"Next scenario",className:m,children:"›"})]}),t.jsx("div",{className:"mt-4 flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>{s(p.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 lJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioGalleryModal:ov},Symbol.toStringTag,{value:"Module"}));function iv({reason:e}){const{headline:n,detail:s}=lv(e);return t.jsxs("div",{className:"py-4 text-sm text-[var(--text-dim)]",children:[t.jsx("p",{className:"text-[var(--text-secondary)]",children:n}),s?t.jsx("p",{className:"mt-1",children:s}):null]})}function lv(e){switch(e.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:`${e.count} component ${Cs(e.count,"scenario")} name ${Cs(e.count,"a component","components")} not in the glossary${hf(e.examples)}.`,detail:"Deconstruct or register those components so they can be surfaced here."};case"not-visual-components":return{headline:`${e.count} ${Cs(e.count,"component")} matched glossary ${Cs(e.count,"entry","entries")} but ${Cs(e.count,"is","are")} not recognized as visual ${Cs(e.count,"component","components")}${hf(e.examples)}.`,detail:"Check `components.fileExtensions` in .codeyam/stack.json — a stack whose components are not .tsx/.jsx must list its own extensions."}}}function Cs(e,n,s){return e===1?n:s??`${n}s`}function hf(e){return e.length===0?"":` (e.g. ${e.join(", ")})`}const cJ=Object.freeze(Object.defineProperty({__proto__:null,ComponentSurfaceReasonNote:iv,describeReason:lv},Symbol.toStringTag,{value:"Module"})),JI="Good question. We'll explain this plainly as we go, and you can ask anything at any step. Nothing happens until you say go.",XI=[{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 QI(e){const n=e.toLowerCase();for(const s of XI)if(s.keywords.some(r=>n.includes(r)))return s.answer;return JI}const ZI={"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 Ee(e){return ZI[e]}const eD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function tD(e){const n=/^(\d{4})-(\d{2})$/.exec(e);if(!n)return e;const s=Number(n[2])-1;return s<0||s>11?e:`${eD[s]} ${n[1]}`}function nD(e,n){const s=/^(\d{4})-(\d{2})$/.exec(e);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 sD=12;function rD(e,n){return e.staleness==="low"?!1:nD(e.verified,n)>sD}function Xn({fact:e,asOf:n=new Date}){if(e.staleness==="low")return null;const s=rD(e,n);return t.jsxs("span",{className:"fact-fresh"+(s?" stale":""),title:`Source: ${e.source}`,children:[s?"needs re-check · ":"verified ",tD(e.verified)]})}const dJ=Object.freeze(Object.defineProperty({__proto__:null,FactFreshness:Xn},Symbol.toStringTag,{value:"Module"}));function ft({size:e=15,color:n="var(--green-300)"}){return t.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:n,strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 8.4l3 3 7-7.4"})})}function Wo(){return t.jsx("div",{className:"pv-logo",children:t.jsx("svg",{width:"26",height:"22",viewBox:"0 0 26 22",fill:"#0a0a0a","aria-hidden":"true",children:t.jsx("path",{d:"M13 0l13 22H0z"})})})}function cv(){return t.jsx("div",{className:"journey",children:t.jsxs("div",{className:"jrow",children:[t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:"jtile",children:"💻"}),t.jsx("div",{className:"jlbl",children:"Your computer"}),t.jsx("div",{className:"jsub",children:"Only you can see it"})]}),t.jsxs("div",{className:"jconn",children:[t.jsx("span",{className:"jpacket"}),t.jsx("span",{children:"→"})]}),t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:"jtile lime",children:"☁️"}),t.jsx("div",{className:"jlbl",children:"Hosting"}),t.jsx("div",{className:"jsub",children:"A home on the internet"})]}),t.jsxs("div",{className:"jconn",children:[t.jsx("span",{className:"jpacket",style:{animationDelay:"1.8s"}}),t.jsx("span",{children:"→"})]}),t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:"jtile",children:"🌍"}),t.jsx("div",{className:"jlbl",children:"Anyone, anywhere"}),t.jsx("div",{className:"jsub",children:"Opens with a link"})]})]})})}function dv(){const e=Ee("vercel.hobby");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"reasons",children:[t.jsxs("div",{className:"reason",children:[t.jsx(ft,{}),t.jsxs("span",{children:[t.jsx("b",{children:"Free to start."})," No credit card, no surprise bills for an app this size."]})]}),t.jsxs("div",{className:"reason",children:[t.jsx(ft,{}),t.jsxs("span",{children:[t.jsx("b",{children:"Built for how your app is made."})," It deploys the way your app already works, so it just runs."]})]}),t.jsxs("div",{className:"reason",children:[t.jsx(ft,{}),t.jsxs("span",{children:[t.jsx("b",{children:"Your own web address later."})," Launch on a free link today, add a custom domain whenever you like."]})]})]}),t.jsxs("p",{className:"reason-foot",children:["One catch worth knowing: ",e.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.",t.jsx(Xn,{fact:e})]})]})}function uv(){return t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Free tier"}),t.jsx("span",{className:"chip",children:"Custom domain later"}),t.jsx("span",{className:"chip",children:"~5 min to set up"})]})}function pv(){const[e,n]=l.useState(!1);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>n(s=>!s),children:[e?"Hide other options":"Vercel not for you? See other options",t.jsx("span",{className:"chev",style:{transform:e?"rotate(180deg)":"none"},children:"⌄"})]}),e?t.jsxs("div",{className:"alts",children:[t.jsxs("div",{className:"altcard",children:[t.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#16a3a3,#0d6e6e)"},children:"N"}),t.jsxs("div",{className:"altbody",children:[t.jsx("div",{className:"altname",children:"Netlify"}),t.jsx("div",{className:"altdesc",children:"Also free to start and very similar to set up. A solid pick if you'd rather use it."})]}),t.jsx("button",{type:"button",className:"altpick",children:"Use this"})]}),t.jsxs("div",{className:"altcard",children:[t.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#f6821f,#c25e0a)"},children:"C"}),t.jsxs("div",{className:"altbody",children:[t.jsx("div",{className:"altname",children:"Cloudflare Pages"}),t.jsx("div",{className:"altdesc",children:"Best if you expect heavy worldwide traffic. A little more to learn up front."})]}),t.jsx("button",{type:"button",className:"altpick",children:"Use this"})]})]}):null]})}const aD=[{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 hv(){const[e,n]=l.useState(-1);return t.jsx("div",{className:"faq",children:aD.map((s,r)=>t.jsxs("div",{className:"faqitem",children:[t.jsxs("button",{type:"button",className:"faqq"+(e===r?" open":""),onClick:()=>n(e===r?-1:r),children:[s.t,t.jsx("span",{className:"chev",children:"⌄"})]}),e===r?t.jsx("div",{className:"faqa",children:s.a}):null]},s.t))})}function fv(){const[e,n]=l.useState(""),[s,r]=l.useState(null),a=o=>{r(QI(o)),n("")};return t.jsxs("div",{className:"ask",children:[t.jsxs("div",{className:"askrow",children:[t.jsx("input",{value:e,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&e.trim()&&a(e)},placeholder:'Ask anything, e.g. "Is it really free?" or "Can I use my own domain?"'}),t.jsx("button",{type:"button",onClick:()=>e.trim()&&a(e),"aria-label":"Ask",children:"↑"})]}),t.jsx("div",{className:"asknote",children:"Ask before you commit to anything."}),s?t.jsxs("div",{className:"askans",children:[t.jsx("span",{className:"askav",children:"‹Y"}),t.jsx("div",{className:"at",children:s})]}):null]})}const uJ=Object.freeze(Object.defineProperty({__proto__:null,Alts:pv,AskBox:fv,Check:ft,Chips:uv,Faq:hv,Journey:cv,Reasons:dv,VercelMark:Wo},Symbol.toStringTag,{value:"Module"})),oD={"chrome.devConsole":{url:"https://chrome.google.com/webstore/devconsole",label:"Open the Chrome Web Store developer dashboard"},"chrome.register":{url:Ee("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 iD(e){return oD[e]}function Jt({linkKey:e,label:n}){const s=iD(e);return t.jsxs("a",{className:"setup-extlink",href:s.url,target:"_blank",rel:"noreferrer noopener",children:[t.jsx("span",{className:"setup-extlink-label",children:n??s.label}),t.jsx("span",{className:"setup-extlink-glyph","aria-hidden":"true",children:"↗"})]})}function Ne({children:e}){return t.jsx("div",{className:"reasons",children:e})}function $({lead:e,children:n}){return t.jsxs("div",{className:"reason",children:[t.jsx(ft,{}),t.jsxs("span",{children:[t.jsx("b",{children:e})," ",n]})]})}function tu({spaced:e=!1,children:n}){return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",style:e?{marginTop:24}:void 0,children:"Keep a changelog"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"One CHANGELOG.md, grouped by version.",children:["Follow the ",t.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."]}),t.jsxs($,{lead:"Or generate it from your commits.",children:["If you write ",t.jsx("b",{children:"Conventional Commits"})," (",t.jsx("code",{children:"feat:"}),","," ",t.jsx("code",{children:"fix:"}),", ",t.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 Ho(){return t.jsxs("div",{className:"setup-note",style:{marginTop:14},children:[t.jsxs("p",{children:["Publishing to ",t.jsx("b",{children:"Firefox Add-ons (AMO)"})," or ",t.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."]}),t.jsxs("p",{children:[t.jsx("b",{children:"Fees differ:"})," the"," ",t.jsx("b",{children:Ee("chromeStore.fee").value})," registration fee is Chrome-only and one-time — Firefox AMO and Edge Add-ons charge no developer fee."]}),t.jsxs("div",{className:"setup-note-links",children:[t.jsx(Jt,{linkKey:"firefox.amoDevHub"}),t.jsx(Jt,{linkKey:"edge.partnerDashboard"})]})]})}const pJ=Object.freeze(Object.defineProperty({__proto__:null,ChangelogSection:tu,ReqItem:$,ReqList:Ne,SetupExternalLink:Jt,StoreAlternativesNote:Ho},Symbol.toStringTag,{value:"Module"}));function Wi(e){const n=mE(e);if(n)return{selectedAppDir:n,selectedEntityHash:null};const s=gE(e);return s?{selectedAppDir:null,selectedEntityHash:s}:{selectedAppDir:null,selectedEntityHash:null}}function Hi(e){return`${ud()}/apps/${e}`}function mv(e){return`${ud()}/entities/${e}`}function Xr(e,n){const s=`${e}:${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 bs(e){return(e.split("/").pop()??e).replace(/\.[^.]+$/,"")}function Ll(e){if(!e.pageFilePath)return null;const n=e.entityName??bs(e.pageFilePath);return Xr(e.pageFilePath,n)}function gv(e){const n=Ll(e);return n===null?null:mv(n)}function yr({href:e,onNavigate:n,children:s,...r}){return t.jsx("a",{...r,href:e,onClick:a=>{a.button===0&&!a.metaKey&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&(a.preventDefault(),n())},children:s})}const hJ=Object.freeze(Object.defineProperty({__proto__:null,NavLink:yr},Symbol.toStringTag,{value:"Module"}));function xv({scenario:e,onSelect:n}){const s=e.screenshotPaths[0]??null;return t.jsxs("button",{type:"button",onClick:n,className:`relative text-left w-full${n?" cursor-pointer group/thumb":""}`,children:[t.jsx("div",{className:"aspect-[16/10] w-full flex items-center justify-center overflow-hidden rounded border border-[var(--line-strong)] bg-[var(--bg-card)] transition group-hover/thumb:border-[var(--text-muted)]",style:{contentVisibility:"auto",containIntrinsicSize:"auto 160px"},children:t.jsx(Ot,{screenshotPath:s??void 0,alt:e.name,loading:"lazy"})}),e.dimensions.length>0?t.jsx("span",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1 py-0.5 text-[8px] text-white",children:e.dimensions[0]}):null,t.jsx("p",{className:"mt-1.5 truncate text-[13px] text-[var(--text-dim)]",children:e.name})]})}const fJ=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardThumbnail:xv},Symbol.toStringTag,{value:"Module"}));function bv({routeEntity:e,variant:n}){const s=e.scenarios.length;return n==="explore"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm font-bold uppercase tracking-wider text-[var(--text-primary)] group-hover:underline",children:e.displayName}),s>0?t.jsxs("span",{className:"text-sm text-[var(--text-dim)]",children:["(",s,")"]}):null]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] transition",children:e.displayName}),t.jsx("span",{className:"font-mono text-xs text-[var(--text-dim)]",children:e.route}),s>0?t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["[",s,"]"]}):null,t.jsx("span",{className:"ml-auto text-xs text-[var(--text-dim)] group-hover:text-[var(--text-muted)] transition",children:"›"})]})}const mJ=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardHeading:bv},Symbol.toStringTag,{value:"Module"}));function yv({collapsed:e,onToggle:n,disclosable:s}){return s?t.jsx("button",{type:"button",onClick:n,"aria-label":e?"Expand group":"Collapse group",className:"shrink-0 w-5 text-[var(--text-dim)] hover:text-[var(--text-primary)] transition text-xs",children:e?"▸":"▾"}):t.jsx("span",{className:"shrink-0 w-5"})}const gJ=Object.freeze(Object.defineProperty({__proto__:null,RouteGroupDisclosure:yv},Symbol.toStringTag,{value:"Module"})),ff={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5"};function nu({routeEntity:e,onSelectRoute:n,onSelectScenario:s,columns:r=4,defaultCollapsed:a=!1,collapsed:o,onToggleCollapsed:i,headingVariant:c="default"}){const d=e.scenarios.length,[u,p]=l.useState(a),h=o!==void 0&&i!==void 0,f=h?o:u,m=h?i:()=>p(_=>!_),g=gv(e),x=c==="explore",b=x?"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",y=t.jsx(bv,{routeEntity:e,variant:c}),v=t.jsx(yv,{collapsed:f,onToggle:m,disclosable:d>0}),j=g?t.jsx(yr,{href:g,onNavigate:()=>n(e.route),className:b,children:y}):t.jsx("button",{onClick:()=>n(e.route),className:b,type:"button",children:y});return t.jsxs("div",{className:"mb-10 border-b border-[var(--border-subtle)] pb-8",children:[t.jsx("div",{className:"flex items-center gap-2",children:x?t.jsxs(t.Fragment,{children:[j,v]}):t.jsxs(t.Fragment,{children:[v,j]})}),d>0&&!f?t.jsx("div",{className:`mt-4 grid gap-x-5 gap-y-9 ${ff[r]??ff[4]}`,children:e.scenarios.map(_=>t.jsx(xv,{scenario:_,onSelect:s?()=>s(_.slug):void 0},_.slug))}):d===0?t.jsx("p",{className:`mt-1 text-[10px] text-[var(--text-dim)]${x?"":" pl-7"}`,children:"No scenarios yet"}):null]})}const xJ=Object.freeze(Object.defineProperty({__proto__:null,RouteListCard:nu},Symbol.toStringTag,{value:"Module"})),qo="bg-white/[0.035] border border-white/[0.06]",Qr=`flex items-center gap-0.5 rounded-[10px] ${qo} p-[3px] shrink-0`,lD=`inline-flex items-center rounded-[9px] ${qo} p-[3px] shrink-0`;function Gs(e,n="text"){return`${n==="icon"?"flex h-7 w-9 items-center justify-center rounded-[7px]":n==="compact"?"px-3 py-1 text-[12.5px] rounded-md":"flex items-center gap-1.5 px-3 py-1 text-[13px] font-medium rounded-[7px]"} cursor-pointer transition ${e?"bg-white/[0.11] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`}function vv({active:e,onChange:n,counts:s}){const r=(a,o)=>{const i=e===a,c=s==null?void 0:s[a];return t.jsxs("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>n(a),title:c!=null?`${c} ${c===1?"simulation":"simulations"}`:void 0,className:Gs(i),children:[o,c!=null?t.jsx("span",{"aria-hidden":"true","data-testid":`route-kind-count-${a}`,className:`text-xs font-normal tabular-nums ${i?"text-[var(--text-secondary)]":"text-[var(--text-dim)]"}`,children:c}):null]})};return t.jsxs("div",{role:"tablist","aria-label":"Simulation kind",className:Qr,children:[r("pages","Pages"),r("components","Components")]})}const bJ=Object.freeze(Object.defineProperty({__proto__:null,RouteKindToggle:vv},Symbol.toStringTag,{value:"Module"}));function su(){return t.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:[t.jsx("circle",{cx:"7",cy:"7",r:"4.5"}),t.jsx("path",{d:"M10.4 10.4 L14 14"})]})}const yJ=Object.freeze(Object.defineProperty({__proto__:null,SearchIcon:su},Symbol.toStringTag,{value:"Module"}));function jv({value:e,onChange:n,scopeLabel:s}){return t.jsxs("div",{className:"relative min-w-0 flex-1",children:[t.jsx("span",{className:"pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-[var(--text-dim)]",children:t.jsx(su,{})}),t.jsx("input",{type:"search",value:e,onChange:r=>n(r.target.value),placeholder:`Search ${s}`,"aria-label":`Search ${s}`,className:`w-full rounded-[10px] ${qo} 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 vJ=Object.freeze(Object.defineProperty({__proto__:null,RouteSearchField:jv},Symbol.toStringTag,{value:"Module"}));function cD(e){const n=[];for(const s of e)for(const r of s.scenarios)for(const a of r.dimensions)n.includes(a)||n.push(a);return n}function dD(e,n){return n===null?e:e.map(s=>({...s,scenarios:s.scenarios.filter(r=>r.dimensions.includes(n))})).filter(s=>s.scenarios.length>0)}function uD(e){const n=e.toLowerCase();return/(tablet|ipad)/.test(n)?"tablet":/(mobile|phone|android|pixel)/.test(n)?"phone":"desktop"}function wv({kind:e,size:n=16}){const s={viewBox:"0 0 24 24",width:n,height:n,fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};return e==="phone"?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"7.5",y:"3",width:"9",height:"18",rx:"2"}),t.jsx("path",{d:"M11 17.5h2"})]}):e==="tablet"?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"5",y:"3",width:"14",height:"18",rx:"2"}),t.jsx("path",{d:"M11 17.5h2"})]}):t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"3",y:"4.5",width:"18",height:"12",rx:"1.5"}),t.jsx("path",{d:"M9 20h6M12 16.5V20"})]})}function _v({dimensions:e,active:n,onChange:s}){return e.length<2?null:t.jsx("div",{role:"group","aria-label":"Screen size",className:Qr,children:e.map(r=>{const a=r===n;return t.jsx("button",{type:"button","aria-label":r,title:a?`${r} (click to show all sizes)`:r,"aria-pressed":a,onClick:()=>s(a?null:r),className:Gs(a,"icon"),children:t.jsx(wv,{kind:uD(r)})},r)})})}const jJ=Object.freeze(Object.defineProperty({__proto__:null,DimensionDeviceIcon:wv,RouteDimensionFilter:_v},Symbol.toStringTag,{value:"Module"}));function Sv({columns:e}){const a=(12-(e-1)*1.6)/e;return t.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:Array.from({length:e},(o,i)=>t.jsx("rect",{x:2+i*(a+1.6),y:3,width:a,height:10,rx:.7},i))})}const wJ=Object.freeze(Object.defineProperty({__proto__:null,GridColumnsIcon:Sv},Symbol.toStringTag,{value:"Module"}));function kv({columns:e,onChange:n,options:s=[2,3,4,5]}){return t.jsx("div",{role:"group","aria-label":"Thumbnails per row",title:"Thumbnails per row",className:Qr,children:s.map(r=>t.jsx("button",{type:"button",onClick:()=>n(r),"aria-label":`${r} per row`,"aria-pressed":e===r,className:Gs(e===r,"icon"),children:t.jsx(Sv,{columns:r})},r))})}const _J=Object.freeze(Object.defineProperty({__proto__:null,GridDensityControl:kv},Symbol.toStringTag,{value:"Module"}));function qi(e){const n=[];for(const s of e)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 pD(e){const[n,s]=l.useState(()=>new Set),r=l.useMemo(()=>e.filter(d=>d.disclosable).map(d=>d.key),[e]),a=l.useCallback(d=>n.has(d),[n]),o=l.useCallback(d=>{s(u=>{const p=new Set(u);return p.has(d)?p.delete(d):p.add(d),p})},[]),i=r.length>0&&r.every(d=>n.has(d)),c=l.useCallback(()=>{s(d=>r.length>0&&r.every(p=>d.has(p))?new Set:new Set(r))},[r]);return{isCollapsed:a,toggle:o,toggleAll:c,allCollapsed:i,canToggleAll:r.length>0}}function mf(e,n){return e.route??e.displayName??String(n)}function Nv({pages:e,components:n,componentSurfaceReason:s=null,onSelectRoute:r,onSelectScenario:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(4),[u,p]=l.useState(""),[h,f]=l.useState(null),[m,g]=l.useState(!1),x=o==="components",b=x?n:e,y=l.useMemo(()=>qi(b),[b]),v=y.length>0&&!!a,j=l.useMemo(()=>cD(b),[b]),_=h!==null&&j.includes(h)?h:null,S=l.useMemo(()=>{const C=dD(b,_),T=u.trim().toLowerCase();return T?C.filter(P=>P.displayName.toLowerCase().includes(T)):C},[b,_,u]),w=l.useMemo(()=>S.map((C,T)=>({key:mf(C,T),disclosable:C.scenarios.length>0})),[S]),k=pD(w),N=l.useMemo(()=>({pages:qi(e).length,components:qi(n).length}),[e,n]);return t.jsxs("div",{children:[m&&v?t.jsx(ov,{shots:y,onSelect:C=>a==null?void 0:a(C),onClose:()=>g(!1)}):null,t.jsxs("div",{"data-testid":"route-list-toolbar",className:"flex flex-wrap items-center gap-3 mb-9",children:[t.jsx(vv,{active:o,onChange:i,counts:N}),t.jsx("div",{className:"w-full max-w-[280px] min-w-[180px] flex-1 flex",children:t.jsx(jv,{value:u,onChange:p,scopeLabel:x?"components":"pages"})}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsx(_v,{dimensions:j,active:_,onChange:f}),t.jsx(kv,{columns:c,onChange:d}),t.jsx("span",{"aria-hidden":"true",className:"mx-1 h-6 w-px bg-white/[0.1]"}),t.jsx(fb,{onOpenGallery:v?()=>g(!0):void 0,allCollapsed:k.allCollapsed,onToggleAll:k.canToggleAll?k.toggleAll:void 0})]})]}),S.length>0?S.map((C,T)=>{const P=mf(C,T);return t.jsx(nu,{routeEntity:C,onSelectRoute:r,onSelectScenario:a,columns:c,collapsed:k.isCollapsed(P),onToggleCollapsed:()=>k.toggle(P),headingVariant:"explore"},P)}):b.length>0?t.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",x?"components":"pages"," match “",u.trim(),"”."]}):x&&s?t.jsx(iv,{reason:s}):t.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",x?"components":"pages"," yet."]})]})}const SJ=Object.freeze(Object.defineProperty({__proto__:null,RouteListTabs:Nv},Symbol.toStringTag,{value:"Module"}));function ru(e,n){const s=e.url??"Uncategorized",r=n.find(o=>o.route===s),a=(r==null?void 0:r.scenarios)??[e];if(!e.url&&e.componentName){const o=a.filter(i=>i.componentName===e.componentName);return o.length?o:[e]}return a}function $l(e){const n=e.replace(/\s*\[[^\]]*\]\s*$/,""),s=n.indexOf(" - ");return s===-1?{pageName:null,stateName:n}:{pageName:n.slice(0,s),stateName:n.slice(s+3)}}function Cv(e){return td(e)?e.componentName??$l(e.name).pageName:$l(e.name).pageName}function Uo(e){return $l(e.name).stateName}function Tv({currentScenario:e,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=m=>{d.current={dx:m.clientX-i.x,dy:m.clientY-i.y},m.currentTarget.setPointerCapture(m.pointerId)},p=m=>{d.current&&c({x:m.clientX-d.current.dx,y:m.clientY-d.current.dy})},h=m=>{d.current=null,m.currentTarget.releasePointerCapture(m.pointerId)},f=l.useMemo(()=>ru(e,n),[e,n]);return t.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:[t.jsxs("div",{onPointerDown:u,onPointerMove:p,onPointerUp:h,className:"flex items-center justify-between px-3 py-2 border-b border-[#3d3d3d] cursor-move select-none",children:[t.jsx("span",{className:"text-[11px] font-mono font-semibold tracking-widest text-gray-300",children:"SCENARIOS"}),t.jsx("button",{type:"button",onClick:a,onPointerDown:m=>m.stopPropagation(),"aria-label":"Close scenarios",className:"text-gray-400 hover:text-white text-lg leading-none px-1 cursor-pointer",children:"×"})]}),t.jsx("div",{className:"overflow-y-auto p-2 flex flex-col gap-2 flex-1 min-h-0",children:f.map(m=>{const g=m.slug===e.slug,x=m.screenshotPaths[0];return t.jsxs("button",{type:"button",onClick:()=>s(m.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:[t.jsx("div",{className:"w-24 h-16 shrink-0 rounded-md overflow-hidden border border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:x?t.jsx("img",{src:gs(x),alt:"",className:"w-full h-full object-cover"}):t.jsx("span",{className:"text-[10px] text-gray-600",children:"No preview"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[11px] text-gray-500 truncate",children:m.url??"component"}),t.jsx("div",{className:`text-sm font-medium truncate ${g?"text-white":"text-gray-200"}`,children:Uo(m)})]})]},m.slug)})}),t.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 kJ=Object.freeze(Object.defineProperty({__proto__:null,LivePageScenariosModal:Tv},Symbol.toStringTag,{value:"Module"})),ys={apps:[],isSingleApp:!1,onSelectApps:()=>{},onSelectApp:()=>{},onSelectRoute:()=>{}};function hD(e){const[n,s]=l.useState({status:"idle"}),{scenariosVersion:r}=Tn();return l.useEffect(()=>{if(!e){s({status:"idle"});return}let a=!1;return s({status:"loading"}),(async()=>{try{const o=await fetch(`/api/entities/${e}`);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(nd):[]};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}},[e,r]),n}function La({message:e}){return t.jsx("div",{className:"px-5 py-8",children:t.jsx(dt,{text:e,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}const NJ=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentError:La},Symbol.toStringTag,{value:"Module"}));function Fl(){return t.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"Loading routes..."})}const CJ=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentLoading:Fl},Symbol.toStringTag,{value:"Module"}));function fD(e){return e.kind==="function"?"Functions don't have visual scenarios. Coverage for this function lives in its unit tests.":e.kind==="component"?`No component scenarios for ${e.displayName}. Create one with \`codeyam-editor editor register\` or capture from the live preview.`:"No scenarios for this entity yet."}function Pv({entityRef:e,onNavigate:n}){return t.jsxs("button",{type:"button",onClick:()=>n(e.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:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.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:e.kind}),t.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:e.name})]}),t.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:e.filePath})]})}const TJ=Object.freeze(Object.defineProperty({__proto__:null,EntityRefCard:Pv},Symbol.toStringTag,{value:"Module"}));function $a({refs:e,onNavigate:n}){return t.jsx("ul",{className:"grid grid-cols-1 gap-1",children:e.map(s=>t.jsx("li",{children:t.jsx(Pv,{entityRef:s,onNavigate:n})},s.hash))})}const PJ=Object.freeze(Object.defineProperty({__proto__:null,EntityRefList:$a},Symbol.toStringTag,{value:"Module"}));function mD(e,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]),p=l.useCallback(()=>{a(!1)},[]),h=l.useCallback(async()=>{if(!(!o.trim()||c)){d(!0);try{const f=await fetch(`/api/scenarios/${encodeURIComponent(e)}`);if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await f.json();m.name=o.trim(),await fetch(`/api/scenarios/${encodeURIComponent(e)}`,{method:"DELETE"}),await fetch("/api/scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),a(!1),s()}catch{}finally{d(!1)}}},[o,c,e,s]);return{renaming:r,renameName:o,renameSaving:c,setRenameName:i,startRename:u,cancelRename:p,submitRename:h}}function gD(e,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(e)}`,{method:"DELETE"}),s()}catch{}finally{a(!1)}}},[n,e,s]);return{deleting:r,handleDelete:o}}function xD({mocks:e,seeds:n}){const s=[];return e>0&&s.push(`${e} ${e===1?"mock":"mocks"} overridden`),n>0&&s.push(`${n} ${n===1?"seed":"seeds"} overridden`),s.length===0?null:s.join(" · ")}function Ov({overrideCounts:e}){const n=e?xD(e):null;return n?t.jsx("div",{className:"text-xs text-[var(--text-dim)] mt-1",children:n}):null}const OJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowOverrideBadge:Ov},Symbol.toStringTag,{value:"Module"})),bD=new Set(["Desktop"]);function Rv(e){var n,s;return(n=e.componentName)!=null&&n.trim()?`Isolated ${e.componentName.trim()} component`:(s=e.url)!=null&&s.trim()?`Renders ${e.url.trim()}`:e.scenarioType==="component"?"Component scenario":"Application scenario"}function Ev({scenario:e,isSelected:n}){var r;const s=e.dimensions.length>0&&!(e.dimensions.length===1&&bD.has(e.dimensions[0]));return t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`text-base font-medium truncate ${n?"text-[var(--accent-active)]":"text-[var(--text-primary)]"}`,children:e.name}),(r=e.description)!=null&&r.trim()?t.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1 whitespace-pre-line",children:e.description}):t.jsx("div",{className:"text-sm text-[var(--text-dim)] italic mt-1",children:Rv(e)}),t.jsx(Ov,{overrideCounts:e.overrideCounts}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:e.dimensions.join(", ")}):null,e.componentName?t.jsx("span",{className:"text-xs text-[var(--accent-purple)]",children:e.componentName}):null]})]})}const RJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowMeta:Ev,deriveRowLabel:Rv},Symbol.toStringTag,{value:"Module"}));function Av({screenshotPath:e,cacheBuster:n}){return t.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:t.jsx(Ot,{screenshotPath:e??void 0,cacheBuster:n??void 0,alt:""})})}const EJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowThumbnail:Av},Symbol.toStringTag,{value:"Module"}));function Mv({onViewData:e,onRename:n,onDelete:s,deleting:r}){return t.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[t.jsx("button",{onClick:e,className:"text-xs text-[var(--accent-active)] hover:opacity-70 cursor-pointer bg-transparent border-none p-0",children:"View / Edit Data"}),t.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"}),t.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 AJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowActions:Mv},Symbol.toStringTag,{value:"Module"}));function Iv({name:e,saving:n,onChange:s,onSubmit:r,onCancel:a}){return t.jsxs("form",{className:"flex items-center gap-2",onSubmit:r,onClick:o=>o.stopPropagation(),children:[t.jsx("input",{type:"text",value:e,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}),t.jsx("button",{type:"submit",disabled:n||!e.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"}),t.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 MJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRenameForm:Iv},Symbol.toStringTag,{value:"Module"}));function Dv({scenario:e,isSelected:n,onSelect:s,onViewData:r,onScenariosChanged:a,children:o}){const i=mD(e.slug,e.name,a),{deleting:c,handleDelete:d}=gD(e.slug,e.name,a);return t.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:[t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(Av,{screenshotPath:e.screenshotPaths[0]??null,cacheBuster:e.screenshotCapturedAtMs}),t.jsx("div",{className:"flex-1 min-w-0",children:i.renaming?t.jsx(Iv,{name:i.renameName,saving:i.renameSaving,onChange:i.setRenameName,onSubmit:u=>{u.preventDefault(),i.submitRename()},onCancel:i.cancelRename}):t.jsxs(t.Fragment,{children:[t.jsx(Ev,{scenario:e,isSelected:n}),n&&t.jsx(Mv,{onViewData:u=>{u.stopPropagation(),r()},onRename:u=>{u.stopPropagation(),i.startRename()},onDelete:d,deleting:c})]})})]}),o&&t.jsx("div",{className:"mt-3 cursor-default",onClick:u=>u.stopPropagation(),children:o})]})}const IJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRow:Dv},Symbol.toStringTag,{value:"Module"}));function Lv(){return t.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 DJ=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioEmptyState:Lv},Symbol.toStringTag,{value:"Module"}));function au({scenarios:e,selectedSlug:n,onSelectScenario:s,onScenariosChanged:r}){const[a,o]=l.useState(null);return e.length===0?t.jsx(Lv,{}):t.jsx("div",{className:"grid grid-cols-1 gap-2",children:e.map(i=>t.jsx(Dv,{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&&t.jsx(gR,{variant:"inline",slug:i.slug,scenarioName:i.name,onClose:()=>o(null)})},i.slug))})}const LJ=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioList:au},Symbol.toStringTag,{value:"Module"})),yD="This component renders no other tracked components.",vD="This component imports no tracked functions.",jD="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 $v({activeTab:e,entity:n,componentRefs:s,functionRefs:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){return t.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[e==="scenarios"&&(n.scenarios.length===0?t.jsx(pr,{copy:fD(n)}):t.jsx(au,{scenarios:n.scenarios,selectedSlug:a,onSelectScenario:o,onScenariosChanged:c})),e==="components"&&(s.length===0?t.jsx(pr,{copy:yD}):t.jsx($a,{refs:s,onNavigate:i})),e==="functions"&&(r.length===0?t.jsx(pr,{copy:vD}):t.jsx($a,{refs:r,onNavigate:i})),e==="callers"&&(n.callers.length===0?t.jsx(pr,{copy:jD}):t.jsx($a,{refs:n.callers,onNavigate:i}))]})}function pr({copy:e}){return t.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:e})}const $J=Object.freeze(Object.defineProperty({__proto__:null,EmptyTabCopy:pr,EntityDetailContent:$v},Symbol.toStringTag,{value:"Module"}));function wD(e){return typeof e!="string"&&typeof e.onClick=="function"}function _D(e){return typeof e=="string"?e:e.label}function SD(e,n){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),n())}function Fv({segments:e}){if(e.length===0)return null;const n=e.length-1;return t.jsx("span",{className:"text-sm",style:{color:"var(--text-muted)"},children:e.map((s,r)=>{const a=_D(s),o=r===n,i=!o&&wD(s);return t.jsxs("span",{children:[t.jsx("span",{style:{color:"var(--text-dim)"},children:" / "}),i?t.jsx("button",{type:"button",onClick:s.onClick,onKeyDown:c=>SD(c,s.onClick),className:"cursor-pointer hover:text-[var(--text-primary)] transition",style:{color:"inherit",background:"none",padding:0},children:a}):t.jsx("span",{style:o?{color:"var(--text-primary)"}:void 0,children:a})]},r)})})}const FJ=Object.freeze(Object.defineProperty({__proto__:null,BreadcrumbNav:Fv},Symbol.toStringTag,{value:"Module"}));function Go({apps:e,selectedApp:n,selectedRouteEntity:s,currentEntity:r,isSingleApp:a,onSelectApps:o,onSelectApp:i,onSelectRoute:c}){const d=[];if(!a&&e.length>0&&d.push({label:"Apps",onClick:o}),n){const p=s!==null||r!=null;a&&!p||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}),t.jsx(Fv,{segments:d})}const zJ=Object.freeze(Object.defineProperty({__proto__:null,EntityBreadcrumb:Go},Symbol.toStringTag,{value:"Module"}));function zv({entity:e,app:n=null,routeEntity:s=null,navContext:r=ys}){var o;const a=e.kind==="component"?"Component":"Function";return t.jsxs("header",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[t.jsx("div",{className:"mb-1",children:t.jsx(Go,{apps:r.apps,selectedApp:n,selectedRouteEntity:s,currentEntity:e,isSingleApp:r.isSingleApp,onSelectApps:r.onSelectApps,onSelectApp:r.onSelectApp,onSelectRoute:r.onSelectRoute})}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.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}),t.jsx("h2",{className:"text-base font-semibold text-[var(--text-primary)]",children:e.displayName})]}),t.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:e.filePath}),((o=e.glossaryEntry)==null?void 0:o.description)&&t.jsx("p",{className:"mt-2 text-xs text-[var(--text-secondary)]",children:e.glossaryEntry.description})]})}const BJ=Object.freeze(Object.defineProperty({__proto__:null,EntityDetailHeader:zv},Symbol.toStringTag,{value:"Module"})),kD=["scenarios","components","functions"];function ou({activeTab:e,onTabChange:n,scenarioCount:s,componentCount:r=0,functionCount:a=0,callersCount:o=0,tabs:i=kD}){const c={scenarios:"Scenarios",components:"Components",functions:"Functions",callers:"Callers"},d={scenarios:s,components:r,functions:a,callers:o};return t.jsx("div",{className:"flex w-full border-t border-b border-[var(--border-default)]",children:i.map(u=>t.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 ${e===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 WJ=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityTabs:ou},Symbol.toStringTag,{value:"Module"})),ND=["scenarios","components","functions"],CD=["scenarios","callers"];function Bv({app:e=null,navContext:n=ys,routeEntity:s=null,entity:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){const[d,u]=l.useState("scenarios"),{componentRefs:p,functionRefs:h}=l.useMemo(()=>{const m=[],g=[];for(const x of r.directImports)x.kind==="function"?g.push(x):m.push(x);return{componentRefs:m,functionRefs:g}},[r.directImports]),f=r.kind==="function"?CD:ND;return t.jsxs("div",{className:"flex flex-col",children:[t.jsx(zv,{app:e,navContext:n,routeEntity:s,entity:r}),t.jsx(ou,{activeTab:d,onTabChange:u,scenarioCount:r.scenarios.length,componentCount:p.length,functionCount:h.length,callersCount:r.callers.length,tabs:f}),t.jsx($v,{activeTab:d,entity:r,componentRefs:p,functionRefs:h,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c})]})}const HJ=Object.freeze(Object.defineProperty({__proto__:null,EntityDetail:Bv},Symbol.toStringTag,{value:"Module"}));function TD(e){const n=[],s=[];for(const r of e)Og(r.url)||(r.scenarioType==="component"?s.push(r):n.push(r));return{application:n,component:s}}function Wv({scenario:e,onPreview:n}){const s=e.screenshotPaths.length>0,[r,a]=l.useState(!1),o=s&&!r;return t.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?t.jsx("img",{src:gs(e.screenshotPaths[0],e.screenshotCapturedAtMs),alt:e.name,className:"mb-2 w-full rounded border border-[var(--border-default)]",onError:()=>a(!0)}):t.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"}),t.jsx("p",{className:"text-sm font-medium text-[var(--text-secondary)]",children:e.name}),t.jsxs("div",{className:"mt-1 flex gap-1",children:[e.hasMocks&&t.jsx("span",{className:"rounded bg-[var(--accent-blue)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-blue)]",children:"mocks"}),e.hasSeed&&t.jsx("span",{className:"rounded bg-[var(--accent-purple)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-purple)]",children:"seed"}),e.dimensions.map(i=>t.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 text-xs text-[var(--text-muted)]",children:i},i))]})]})}const qJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioCard:Wv},Symbol.toStringTag,{value:"Module"}));function zl({label:e,scenarios:n,onSelectScenario:s,className:r}){return t.jsxs("section",{className:r,children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:e}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.map(a=>t.jsx(Wv,{scenario:a,onPreview:()=>s(a.slug)},a.slug))})]})}const UJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioTypeSection:zl},Symbol.toStringTag,{value:"Module"}));function Hv({feature:e,passed:n,failed:s,total:r}){return t.jsxs("div",{className:"px-5 py-2 flex items-center gap-3",children:[t.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:e}),t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[r," test",r!==1?"s":""]}),r>0&&t.jsxs("span",{className:`text-xs font-medium ${s>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]"}`,children:[n,"/",r]})]})}const GJ=Object.freeze(Object.defineProperty({__proto__:null,TestGroupHeader:Hv},Symbol.toStringTag,{value:"Module"}));function qv({test:e}){const n=(e.description??"").length>0,s=e.status==="passed"?"text-[var(--accent-green)]":e.status==="failed"?"text-[var(--accent-red)]":"text-[var(--text-dim)]",r=e.status==="passed"?"✓":e.status==="failed"?"✗":"○";return t.jsxs("div",{className:"flex items-start gap-2 py-1 px-3",children:[t.jsx("span",{className:`text-xs leading-5 ${s}`,children:r}),t.jsx("div",{className:"min-w-0",children:n?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:e.description}),t.jsx("p",{className:"font-mono text-[10px] text-[var(--text-dim)] truncate",children:e.key})]}):t.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:e.key})})]})}const YJ=Object.freeze(Object.defineProperty({__proto__:null,TestGroupRow:qv},Symbol.toStringTag,{value:"Module"}));function Uv({groups:e}){return e.length===0?t.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No tests found."}):t.jsx("div",{className:"py-3",children:e.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 t.jsxs("div",{className:"mb-1",children:[t.jsx(Hv,{feature:n.feature,passed:s,failed:r,total:a}),t.jsx("div",{className:"px-5 pb-2",children:n.tests.map((o,i)=>t.jsx(qv,{test:o},`${o.file}-${o.key??o.line??i}`))})]},n.feature)})})}const VJ=Object.freeze(Object.defineProperty({__proto__:null,TestGroupList:Uv},Symbol.toStringTag,{value:"Module"}));function Gv({allScenarios:e,testGroups:n,onSelectScenario:s}){const{application:r,component:a}=TD(e),o=r.length>0||a.length>0;return t.jsxs("div",{className:"px-5 py-5",children:[o?t.jsxs(t.Fragment,{children:[r.length>0&&t.jsx(zl,{label:"Application",scenarios:r,onSelectScenario:s}),a.length>0&&t.jsx(zl,{label:"Component",scenarios:a,onSelectScenario:s,className:r.length>0?"mt-8":void 0})]}):t.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No scenarios yet"}),t.jsx("div",{className:"mt-8",children:t.jsx(Uv,{groups:n})})]})}const KJ=Object.freeze(Object.defineProperty({__proto__:null,NonWebAppDetail:Gv},Symbol.toStringTag,{value:"Module"}));function PD(e,n){const s=[],r=[];for(const a of e){const o=bs(a);/^[A-Z]/.test(o)&&!o.startsWith("use")?s.push(a):r.push(a)}return{componentImports:s,functionImports:r}}function Yv({ancestor:e,onNavigateToEntity:n}){const s=n?()=>n(Xr(e.filePath,bs(e.filePath))):void 0;return t.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:[t.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:e.displayName}),t.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:e.filePath})]})}const JJ=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainCard:Yv},Symbol.toStringTag,{value:"Module"}));function Vv({layoutChain:e,onNavigateToEntity:n}){return e.length===0?null:t.jsxs("section",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[t.jsx("h3",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:"Layout chain"}),t.jsx("div",{className:"flex flex-col gap-1",children:e.map(s=>t.jsx(Yv,{ancestor:s,onNavigateToEntity:n},`${s.kind}:${s.filePath}`))})]})}const XJ=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainSection:Vv},Symbol.toStringTag,{value:"Module"}));function OD({importPath:e,derivedName:n,allScenarios:s,routeEntities:r}){const a=s.filter(i=>i.scenarioType==="component"&&(i.pageFilePath===e||i.componentName===n)),o=r.filter(i=>i.directImports.length===1&&i.directImports[0]===e&&bs(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 Fa(e){const n=[];for(const s of e.split("/"))s===""||s==="."||(s===".."?n.pop():n.push(s));return n.join("/")}function RD(e){const n=new Map;for(const[s,r]of Object.entries(e)){const a=Fa(s),o=bs(a),i=Xr(a,o);n.has(i)||n.set(i,{hash:i,filePath:a,entityName:o,imports:r.imports.map(Fa),importedBy:r.importedBy.map(Fa)})}return n}function ED(e,n){if(!e)return null;const s=Fa(n);for(const r of e.values())if(r.filePath===s)return r;return null}function Kv(e,n){if(!e)return[];const s=[];for(const r of n){const a=ED(e,r);a&&s.push(a)}return s}function AD(e,n){return e.find(s=>s.pageFilePath===n)??null}function Jv(e){const n=e.split("/"),s=n.pop()??e,r=n.join("/");return{fileName:s,dirPath:r}}function Xv({displayName:e,entity:n,isNavigable:s}){return t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-lg font-semibold text-[var(--text-secondary)]",children:e}),n?t.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?t.jsx("span",{className:"ml-auto text-[10px] text-[var(--text-dim)]",children:"→"}):null]})}const QJ=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCardHeader:Xv},Symbol.toStringTag,{value:"Module"}));function Qv({scenarios:e,onSelectScenario:n}){return e.length===0?t.jsx("p",{className:"mt-1 text-[10px] text-[var(--text-dim)]",children:"No scenarios"}):t.jsxs("div",{className:"mt-2 flex flex-row gap-1.5",children:[e.slice(0,4).map(s=>{const r=s.screenshotPaths[0]??null;return t.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),n(s.slug)},className:"flex w-[192px] shrink-0 flex-col gap-1 transition",children:[t.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:t.jsx(Ot,{screenshotPath:r??void 0,alt:s.name})}),t.jsx("span",{className:"w-full truncate text-center text-[10px] text-[var(--text-secondary)]",children:s.name})]},s.slug)}),e.length>4&&t.jsx("div",{className:"flex h-[120px] items-center px-1",children:t.jsxs("span",{className:"text-[10px] text-[var(--text-dim)]",children:["+",e.length-4]})})]})}const ZJ=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyScenarioStrip:Qv},Symbol.toStringTag,{value:"Module"}));function Zv({importPath:e,entity:n,scenarios:s,onNavigate:r,onSelectScenario:a}){const{fileName:o,dirPath:i}=Jv(e),c=(n==null?void 0:n.entityName)??o.replace(/\.[^.]+$/,"");return t.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:[t.jsx(Xv,{displayName:c,entity:n,isNavigable:r!==null}),t.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[i,"/"]}),t.jsx(Qv,{scenarios:s,onSelectScenario:a})]})}const eX=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCard:Zv},Symbol.toStringTag,{value:"Module"}));function ej(){return t.jsx("p",{className:"py-4 text-center text-xs text-[var(--text-dim)]",children:"No dependencies found"})}const tX=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyEmptyState:ej},Symbol.toStringTag,{value:"Module"}));function tj({directImports:e,entityLookup:n,allScenarios:s,routeEntities:r,onNavigateToRoute:a,onNavigateToEntity:o,onSelectScenario:i}){const c=l.useMemo(()=>Kv(n,e),[n,e]);return e.length===0?t.jsx(ej,{}):t.jsx("div",{className:"grid grid-cols-1 gap-1",children:e.map(d=>{const u=c.find(x=>x.filePath===d)??null,p=(u==null?void 0:u.entityName)??bs(d),h=OD({importPath:d,derivedName:p,allScenarios:s??[],routeEntities:r??[]}),f=AD(r??[],d),m=Xr(d,p),g=f?()=>a(f.route):o?()=>o(m):null;return t.jsx(Zv,{importPath:d,entity:u,scenarios:h,onNavigate:g,onSelectScenario:i},d)})})}const nX=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyList:tj},Symbol.toStringTag,{value:"Module"}));function MD(e,n,s){const r=new Set,a=e.replace(/\.(ts|tsx)$/,"");r.add(`${a}.test.ts`),r.add(`${a}.test.tsx`);const o=n.get(e);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 nj({status:e}){return e==="passed"?t.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-green)]",children:"✓"}):e==="failed"?t.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-red)]",children:"✗"}):t.jsx("span",{className:"mt-0.5 text-xs text-[var(--text-dim)]",children:"○"})}const sX=Object.freeze(Object.defineProperty({__proto__:null,TestStatusIcon:nj},Symbol.toStringTag,{value:"Module"}));function sj({test:e}){const n=e.description.length>0;return t.jsxs("div",{className:"flex items-start gap-2 py-1",children:[t.jsx(nj,{status:e.status}),t.jsx("div",{children:n?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:e.description}),t.jsx("p",{className:"font-mono text-xs text-[var(--text-dim)]",children:e.key})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:e.key}),t.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:"no description"})]})})]})}const rX=Object.freeze(Object.defineProperty({__proto__:null,TestItem:sj},Symbol.toStringTag,{value:"Module"}));function rj({importPath:e,entityName:n,tests:s,onNavigate:r}){const{dirPath:a}=Jv(e);return t.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:[t.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:n}),t.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[a,"/"]}),t.jsx("div",{className:"mt-2",children:s.length>0?t.jsx("div",{className:"space-y-0.5",children:s.map((o,i)=>t.jsx(sj,{test:o},`${o.file}:${o.key??o.line??i}`))}):t.jsx("p",{className:"text-xs text-[var(--text-dim)] italic",children:"No tests"})})]})}const aX=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionCard:rj},Symbol.toStringTag,{value:"Module"}));function aj(){return t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No function imports found"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-dim)]",children:"This component only imports other components"})]})}const oX=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionEmptyState:aj},Symbol.toStringTag,{value:"Module"}));function oj({functionImports:e,entityLookup:n,testGroups:s,onNavigateToEntity:r}){const a=l.useMemo(()=>Kv(n,e),[n,e]);return e.length===0?t.jsx(aj,{}):t.jsx("div",{className:"grid grid-cols-1 gap-1",children:e.map(o=>{const i=a.find(p=>p.filePath===o)??null,c=(i==null?void 0:i.entityName)??bs(o),d=MD(o,n,s),u=r?()=>r(Xr(o,c)):null;return t.jsx(rj,{importPath:o,entityName:c,tests:d,onNavigate:u},o)})})}const iX=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionList:oj},Symbol.toStringTag,{value:"Module"}));function ij({activeTab:e,routeEntity:n,componentImports:s,functionImports:r,testGroups:a,selectedSlug:o,entityLookup:i,allScenarios:c,routeEntities:d,onSelectScenario:u,onNavigateToRoute:p,onNavigateToEntity:h,onScenariosChanged:f}){return t.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[e==="scenarios"&&t.jsx(au,{scenarios:n.scenarios,selectedSlug:o,onSelectScenario:u,onScenariosChanged:f}),e==="components"&&t.jsx(tj,{directImports:s,entityLookup:i,allScenarios:c,routeEntities:d,onNavigateToRoute:p,onNavigateToEntity:h,onSelectScenario:u}),e==="functions"&&t.jsx(oj,{functionImports:r,entityLookup:i,testGroups:a,onNavigateToEntity:h})]})}const lX=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailContent:ij},Symbol.toStringTag,{value:"Module"}));function lj({displayName:e,pageFilePath:n,app:s=null,routeEntity:r=null,navContext:a=ys}){return t.jsxs("div",{className:"px-5 py-4",children:[t.jsx("div",{className:"mb-2",children:t.jsx(Go,{apps:a.apps,selectedApp:s,selectedRouteEntity:r,isSingleApp:a.isSingleApp,onSelectApps:a.onSelectApps,onSelectApp:a.onSelectApp,onSelectRoute:a.onSelectRoute})}),t.jsx("h2",{className:"text-xl font-medium text-[var(--text-primary)]",children:e}),n?t.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--text-dim)]",children:n}):null]})}const cX=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailHeader:lj},Symbol.toStringTag,{value:"Module"}));function cj({app:e=null,navContext:n=ys,routeEntity:s,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,testGroups:c,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:p,onScenariosChanged:h}){const[f,m]=l.useState("scenarios"),{componentImports:g,functionImports:x}=l.useMemo(()=>PD(s.directImports),[s.directImports]);return t.jsxs("div",{className:"flex flex-col",children:[t.jsx(lj,{app:e,navContext:n,routeEntity:s,displayName:s.displayName,pageFilePath:s.pageFilePath}),t.jsx(Vv,{layoutChain:s.layoutChain??[],onNavigateToEntity:p}),t.jsx(ou,{activeTab:f,onTabChange:m,scenarioCount:s.scenarios.length,componentCount:g.length,functionCount:x.length}),t.jsx(ij,{activeTab:f,routeEntity:s,componentImports:g,functionImports:x,testGroups:c,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:p,onScenariosChanged:h})]})}const dX=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetail:cj},Symbol.toStringTag,{value:"Module"}));function dj(){return t.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No routes discovered yet."})}const uX=Object.freeze(Object.defineProperty({__proto__:null,RouteListEmptyState:dj},Symbol.toStringTag,{value:"Module"}));function uj({label:e="Pages"}={}){return t.jsx("div",{className:"mb-3",children:t.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)]",children:e})})}const pX=Object.freeze(Object.defineProperty({__proto__:null,RouteListSectionHeader:uj},Symbol.toStringTag,{value:"Module"}));function Bl({label:e,routeEntities:n,onSelectRoute:s,onSelectScenario:r,className:a}){return t.jsxs("div",{className:a,children:[t.jsx(uj,{label:e}),t.jsx("div",{children:n.map(o=>t.jsx(nu,{routeEntity:o,onSelectRoute:s,onSelectScenario:r},o.route))})]})}const hX=Object.freeze(Object.defineProperty({__proto__:null,RouteListSection:Bl},Symbol.toStringTag,{value:"Module"}));function pj({providerLabel:e,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 t.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 ${e} to investigate why this page is not shown`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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 ${e}`]})}const fX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageInvestigateButton:pj},Symbol.toStringTag,{value:"Module"}));function hj({displayName:e,path:n}){return t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm text-[var(--text-primary)] truncate",children:e}),t.jsx("p",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:n})]})}const mX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRowSummary:hj},Symbol.toStringTag,{value:"Module"}));function ID(e,n){return n==="scaffold"?[`The page \`${e}\` 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(`
|
|
41
|
-
|
|
42
|
-
`):[`The page \`${e}\` 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(`
|
|
43
|
-
|
|
44
|
-
`)}function DD({path:e,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.",ID(e,n),"Propose the concrete change and, once the user agrees, make it. Prefer real edits and commands over generic advice."].join(`
|
|
45
|
-
|
|
46
|
-
`)}function fj(e){return e.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}function mj({page:e}){const[n,s]=l.useState(!1),{config:r}=Pt(),a=st(r==null?void 0:r.provider);return t.jsxs("div",{className:"border border-[var(--border-subtle)] rounded mb-2",children:[t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx(hj,{displayName:e.displayName,path:e.path}),t.jsx(pj,{providerLabel:a,chatOpen:n,onToggleChat:()=>s(o=>!o)})]}),n&&t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:t.jsx(Ht,{chatName:`fix-unsurfaced-${fj(e.path)}`,prompt:DD({path:e.path,reason:e.reason}),height:360,onClose:()=>s(!1)})})]})}const gX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRow:mj,chatSlug:fj},Symbol.toStringTag,{value:"Module"}));function gj({label:e,pages:n}){return n.length===0?null:t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"mb-2 text-xs text-[var(--text-dim)]",children:e}),n.map(s=>t.jsx(mj,{page:s},s.path))]})}const xX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageGroup:gj},Symbol.toStringTag,{value:"Module"}));function xj({count:e,collapsed:n,onToggle:s}){return t.jsxs("button",{type:"button",onClick:s,className:"mb-3 flex items-center gap-2 cursor-pointer group","aria-expanded":!n,children:[t.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:t.jsx("path",{d:"M9 18l6-6-6-6"})}),t.jsxs("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)] group-hover:text-[var(--text-primary)]",children:["Not shown (",e,")"]})]})}const bX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSectionHeader:xj},Symbol.toStringTag,{value:"Module"})),LD=[{reason:"missing-from-glossary",label:"Missing from glossary"},{reason:"scaffold",label:"Marked as scaffold"}];function bj({pages:e}){const[n,s]=l.useState(!0);return e.length===0?null:t.jsxs("div",{className:"mt-8",children:[t.jsx(xj,{count:e.length,collapsed:n,onToggle:()=>s(r=>!r)}),!n&&t.jsx("div",{children:LD.map(({reason:r,label:a})=>t.jsx(gj,{label:a,pages:e.filter(o=>o.reason===r)},r))})]})}const yX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSection:bj},Symbol.toStringTag,{value:"Module"}));function yj({routeEntities:e,unsurfacedPages:n=[],componentSurfaceReason:s=null,onSelectRoute:r,onSelectScenario:a,tabbed:o=!1}){if(e.length===0&&n.length===0)return t.jsx(dj,{});const i=e.filter(d=>(d.kind??"application")==="application"),c=e.filter(d=>d.kind==="component");return o?t.jsx("div",{className:"px-5 pb-5",children:t.jsx(Nv,{pages:i,components:c,componentSurfaceReason:s,onSelectRoute:r,onSelectScenario:a})}):t.jsxs("div",{className:"px-5 py-5",children:[e.length===0&&t.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&&t.jsx(Bl,{label:"Pages",routeEntities:i,onSelectRoute:r,onSelectScenario:a}),c.length>0&&t.jsx(Bl,{label:"Components",routeEntities:c,onSelectRoute:r,onSelectScenario:a,className:i.length>0?"mt-8":void 0}),t.jsx(bj,{pages:n})]})}const vX=Object.freeze(Object.defineProperty({__proto__:null,RouteList:yj},Symbol.toStringTag,{value:"Module"}));function iu({app:e=null,navContext:n=ys,isWeb:s,routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,routesLoading:i,routesError:c,selectedEntityHash:d,selectedRouteEntity:u,testGroups:p,selectedSlug:h,entityLookup:f,allScenarios:m,onSelectScenario:g,onSelectRoute:x,onSelectEntity:b,onBackToRoutes:y,onScenariosChanged:v,routeListTabbed:j=!1}){const _=hD(d&&!u?d:null);return s?i?t.jsx(Fl,{}):c?t.jsx(La,{message:c}):u?t.jsx(cj,{app:e,navContext:n,routeEntity:u,selectedSlug:h,entityLookup:f,allScenarios:m,routeEntities:r,testGroups:p,onSelectScenario:g,onNavigateToRoute:x,onNavigateToEntity:b,onScenariosChanged:v}):d?_.status==="loading"||_.status==="idle"?t.jsx(Fl,{}):_.status==="not-found"?t.jsx(La,{message:"Entity not found. The dependency graph may need to be refreshed."}):_.status==="error"?t.jsx(La,{message:_.message}):t.jsx(Bv,{app:e,navContext:n,routeEntity:u,entity:_.entity,selectedSlug:h,onSelectScenario:g,onNavigateToEntity:b??(()=>{}),onScenariosChanged:v}):t.jsx(yj,{routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,onSelectRoute:x,onSelectScenario:g,tabbed:j}):t.jsx(Gv,{allScenarios:m,testGroups:p,onSelectScenario:g})}const jX=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContent:iu},Symbol.toStringTag,{value:"Module"}));function vj({children:e}){return t.jsx("div",{style:{display:"flex",alignItems:"center",minHeight:40,margin:"0 0 16px",fontFamily:'"IBM Plex Sans", sans-serif',WebkitFontSmoothing:"antialiased"},children:t.jsx("h2",{className:"home-sectitle",style:{color:"var(--text-strong)",margin:0},children:e})})}const wX=Object.freeze(Object.defineProperty({__proto__:null,ExploreSectionHeading:vj},Symbol.toStringTag,{value:"Module"})),$D={id:"simulations",label:"Simulations"},FD={id:"site-content",label:"Site Content"},zD={id:"setup",label:"Setup"};function jj({active:e,onChange:n,showSetup:s=!1,showSiteContent:r=!1,children:a}){const o=[$D,...r?[FD]:[],...s?[zD]:[]];return o.length===1?t.jsx("div",{children:a}):t.jsxs("div",{children:[t.jsx("div",{role:"tablist","aria-label":"Explore your app",className:"flex items-center gap-6 border-b border-[var(--border-subtle)] mb-5",children:o.map(i=>{const c=i.id===e;return t.jsx("button",{type:"button",role:"tab","aria-selected":c,onClick:()=>n(i.id),className:`font-sans text-xs font-semibold tracking-wide uppercase pb-2 -mb-px border-b-2 transition ${c?"text-[var(--text-primary)] border-[var(--text-primary)]":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-secondary)]"}`,children:i.label},i.id)})}),t.jsx("div",{role:"tabpanel",children:a})]})}const _X=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreTabs:jj},Symbol.toStringTag,{value:"Module"}));async function Ts(e){const n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error??`Request failed (${e.status})`);return n}function gf(e,n,s,r){return fetch("/api/site-content/entry",{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:n,slug:s,fields:r.fields,body:r.body})})}const bn={async entry(e,n){const s=new URLSearchParams({collection:e,slug:n});return Ts(await fetch(`/api/site-content/entry?${s}`))},async save(e,n,s){return Ts(await gf("PUT",e,n,s))},async savePartial(e,n,s,r){return Ts(await fetch("/api/site-content/entry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:e,slug:n,fields:s,body:r})}))},async saveSetting(e,n){await Ts(await fetch("/api/site-content/setting",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:n})}))},async create(e,n,s){return Ts(await gf("POST",e,n,s))},async goLive(){await Ts(await fetch("/api/site-content/live",{method:"POST"}))},async restartDevServer(){await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart",waitForHealthy:!0})})}};function BD({manifest:e,open:n,entry:s,draft:r,onEntrySaved:a,onSaved:o,onError:i,onOpenCollection:c}){const[d,u]=l.useState(!0),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(),b=l.useRef(null),y=l.useMemo(()=>BM(e),[e]),v=(w,k)=>{var C;const N=(C=e.collections)==null?void 0:C.find(T=>T.id===(w==null?void 0:w.collection));return(N==null?void 0:N.fields.find(T=>T.name===k.field))??{name:k.field,label:k.label,type:k.kind==="html"?"html":k.type}},j=async(w,k)=>{if(Bi(w,n)&&r)return{value:k?r.fields[k]:r.body,file:s==null?void 0:s.file};const N=await bn.entry(w.collection,w.slug),C=Es(N);return{value:k?C.fields[k]:C.body,file:N.file}},_=async(w,k,N,C)=>{if(w==="setting"){await bn.saveSetting(N,Array.isArray(C)?C.join(", "):C);return}if(!k)throw new Error("This text isn't linked to an entry, so there is nowhere to save it.");const P=w==="body"?await bn.savePartial(k.collection,k.slug,{},String(C)):await bn.savePartial(k.collection,k.slug,{[N]:C});Bi(k,n)&&a(P,R=>UM(R,w,N,C))},S=()=>{b.current=null,h(null),m(null)};return{onPage:d,onPageChange:w=>{u(w),S()},fields:y,scrollY:g,popover:p,editingField:f,onSelect:w=>{var T;if(w.kind==="nav"){const P=(T=e.collections)==null?void 0:T.find(R=>R.id==="navigation"||R.id==="nav");P&&c(P.id);return}const k=w.kind==="setting"?null:tf(w.entry,n);b.current={sel:w,ref:k},x(w.scrollY),m(Bi(k,n)?w.kind==="body"?"body":w.field:null);const N=qM(w);if(!k||!w.rect||!N)return;const C=w.rect;if(N==="body")j(k,null).then(({value:P,file:R})=>h({kind:"body",rect:C,file:R,body:String(P??"")}),P=>i(String(P)));else{const P=v(k,w);j(k,w.field).then(({value:R})=>h({kind:"field",rect:C,def:P,entryLabel:`${k.collection}/${k.slug}`,value:R}),R=>i(String(R)))}},onCommit:w=>{const k=w.kind==="setting"?null:tf(w.entry,n),N=k?v(k,{kind:w.kind,entry:w.entry,field:w.field}):void 0;x(w.scrollY),m(null),_(w.kind,k,w.field,WM(N==null?void 0:N.type,w.value)).then(o,C=>i(C instanceof Error?C.message:String(C)))},onCancel:S,onPopoverSave:w=>{const k=b.current;!k||!p||(h({...p,saving:!0,error:void 0}),_(k.sel.kind,k.ref,k.sel.field,w).then(()=>{S(),o()},N=>h(C=>C&&{...C,saving:!1,error:N instanceof Error?N.message:String(N)})))}}}function Wl(e,n){return(n==null?void 0:n.previewOrigin)??(e==null?void 0:e.previewOrigin)??null}function lu(e,n){if(!e||!/^https?:\/\//i.test(e))return!0;const s=typeof window<"u"?window.location.origin:null;if(!s)return!1;try{return new URL(e).origin===s}catch{return!0}}function wj(e){return e!=null&&e.fields.some(n=>n.name==="name")?"name":"title"}function _j(e){const n=wj(e);return((e==null?void 0:e.fields)??[]).filter(s=>s.required&&s.name!==n)}function WD(e,n,s){return!e.title.trim()||!n||_j(s).some(r=>!String(e.fields[r.name]??"").trim())}function HD(e,n){return e==="pages"?`/${n}/`:`/${e}/${n}/`}async function qD(e,n,s=fetch){const r=`http://127.0.0.1:${e}${n}`;try{const o=await(await s(`/api/probe-url?url=${encodeURIComponent(r)}`)).json();return!!(o!=null&&o.ok)}catch{return!1}}async function xf(e,n,s,{fetchImpl:r=fetch,delayMs:a=1e3,sleep:o=i=>new Promise(c=>setTimeout(c,i))}={}){for(let i=0;i<s;i+=1){if(await qD(e,n,r))return!0;i<s-1&&await o(a)}return!1}function Sj({label:e,entries:n,selectedSlug:s,search:r="",sort:a="date",onSearchChange:o,onSortChange:i,onSelect:c,onNew:d}){const u=ZM(n,r,a);return t.jsxs("div",{className:"flex flex-col gap-2 min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"flex-1 text-sm font-semibold text-[var(--text-primary)]",children:e}),t.jsx("button",{type:"button",onClick:d,className:"text-xs font-medium px-2 py-1 rounded border border-[var(--border-default)] text-[var(--text-primary)] hover:bg-[var(--bg-card)]",children:"+ New page"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"search",value:r,placeholder:"Search","aria-label":`Search ${e}`,onChange:p=>o==null?void 0:o(p.target.value),className:"flex-1 min-w-0 text-sm px-2 py-1 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-primary)]"}),t.jsxs("select",{value:a,"aria-label":"Sort entries",onChange:p=>i==null?void 0:i(p.target.value),className:"text-xs px-1.5 py-1 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)]",children:[t.jsx("option",{value:"date",children:"Newest"}),t.jsx("option",{value:"title",children:"A–Z"})]})]}),t.jsxs("ul",{className:"flex flex-col overflow-y-auto",children:[u.map(p=>t.jsx("li",{children:t.jsx(ob,{entry:p,active:p.slug===s,onSelect:c})},p.slug)),u.length===0?t.jsx("li",{className:"px-2 py-3 text-xs text-[var(--text-dim)]",children:r.trim()?"No entries match.":"No entries yet."}):null]})]})}const SX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEntryList:Sj},Symbol.toStringTag,{value:"Module"}));function kj({collections:e,draft:n,derivedSlug:s,creating:r=!1,error:a,onChange:o,onCreate:i,onCancel:c}){const d=e.find(f=>f.id===n.collectionId),u=_j(d),p=n.slug??s,h=WD(n,p,d);return t.jsxs("form",{className:"flex flex-col gap-3 max-w-lg",onSubmit:f=>{f.preventDefault(),h||i==null||i()},children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--text-primary)]",children:"New page"}),t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:["Collection",t.jsx("select",{value:n.collectionId,onChange:f=>o==null?void 0:o({...n,collectionId:f.target.value}),className:`${Vt} mt-1`,children:e.filter(f=>f.kind!=="singleton").map(f=>t.jsx("option",{value:f.id,children:f.singular??f.label},f.id))})]}),t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:["Title",t.jsx("input",{value:n.title,autoFocus:!0,onChange:f=>o==null?void 0:o({...n,title:f.target.value}),className:`${Vt} mt-1`})]}),t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:["Address",t.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[t.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)]",children:["/",n.collectionId==="pages"?"":`${n.collectionId}/`]}),t.jsx("input",{value:p,onChange:f=>o==null?void 0:o({...n,slug:f.target.value}),className:`${Vt} font-mono text-xs`})]})]}),u.map(f=>t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:[f.label??f.name,t.jsx("span",{className:"text-[var(--accent-red)]",children:" *"}),t.jsx("input",{type:f.type==="date"?"date":"text",value:String(n.fields[f.name]??""),onChange:m=>o==null?void 0:o({...n,fields:{...n.fields,[f.name]:m.target.value}}),className:`${Vt} mt-1`})]},f.name)),t.jsx(dt,{text:a}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx("button",{type:"submit",disabled:h||r,className:"text-sm font-medium px-3 py-1.5 rounded bg-[var(--accent-primary)] text-[var(--text-on-accent)] disabled:opacity-40",children:r?"Creating…":"Create"}),t.jsx("button",{type:"button",onClick:c,className:"text-sm px-3 py-1.5 rounded text-[var(--text-secondary)] hover:bg-[var(--bg-card)]",children:"Cancel"})]})]})}const kX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentNewEntry:kj},Symbol.toStringTag,{value:"Module"}));function UD(e,n){return e<=0||n<=0?1:Math.min(1,e/n)}function GD(e,{enabled:n,fields:s,scrollY:r,onSelect:a,onCommit:o,onCancel:i}){const[c,d]=l.useState(null),[u,p]=l.useState(null),h=l.useRef({onSelect:a,onCommit:o,onCancel:i});h.current={onSelect:a,onCommit:o,onCancel:i};const f=l.useCallback(b=>{var y,v;(v=(y=e.current)==null?void 0:y.contentWindow)==null||v.postMessage(b,"*")},[e]),m=l.useCallback(b=>{n?f({type:"codeyam:content-edit:activate",fields:s,scrollY:b?r:void 0}):(f({type:"codeyam:content-edit:deactivate"}),p(null))},[n,s,r,f]);l.useEffect(()=>{m(!1)},[n,s,f]),l.useEffect(()=>{function b(y){var _,S,w,k,N,C,T,P;const v=(_=e.current)==null?void 0:_.contentWindow;if(!v||y.source!==v)return;const j=y.data;if(!(!j||typeof j.type!="string"))switch(j.type){case"codeyam:content-edit:regions":d(((S=j.payload)==null?void 0:S.count)??0);break;case"codeyam:content-edit:select":{const R=j.payload;p(R),(k=(w=h.current).onSelect)==null||k.call(w,R);break}case"codeyam:content-edit:commit":p(null),(C=(N=h.current).onCommit)==null||C.call(N,j.payload);break;case"codeyam:content-edit:cancel":p(null),(P=(T=h.current).onCancel)==null||P.call(T);break}}return window.addEventListener("message",b),()=>window.removeEventListener("message",b)},[e]);const g=l.useCallback(()=>{p(null),f({type:"codeyam:content-edit:cancel"})},[f]),x=l.useCallback(()=>{d(null),p(null),m(!0)},[m]);return{regionCount:c,selection:u,clearSelection:g,handleFrameLoad:x}}const YD={};function Nj({url:e,displayPath:n,emptyTitle:s="This entry has no page of its own",urlReason:r,urlGuessed:a=!1,reloadNonce:o=0,building:i=!1,screenSizes:c,screenSize:d,onScreenSizeChange:u,editOnPage:p,onEditOnPageChange:h,editFields:f=YD,editScrollY:m,editPopover:g=null,onEditSelect:x,onEditCommit:b,onEditCancel:y,onEditPopoverSave:v}){const j=l.useRef(null),_=l.useRef(null),[S,w]=l.useState({width:0,height:0}),k=c.find(R=>R.name===d)??c[0]??{name:"Desktop",width:1440,height:900},N=UD(S.width,k.width),C=!!e&&!i,T=GD(_,{enabled:!!p&&C,fields:f,scrollY:m,onSelect:x,onCommit:b,onCancel:y});l.useEffect(()=>{const R=j.current;if(!R||typeof ResizeObserver>"u")return;const L=new ResizeObserver(([M])=>w({width:M.contentRect.width,height:M.contentRect.height}));return L.observe(R),()=>L.disconnect()},[]);const P=()=>{T.clearSelection(),y==null||y()};return t.jsxs("div",{className:"flex flex-col gap-2 min-h-0 h-full",children:[t.jsx(Kx,{address:e?`${n??e}${a?" (guessed)":""}`:"No page",editOnPage:C?p:void 0,regionCount:T.regionCount,screenSizes:c,screenSize:k.name,onEditOnPageChange:h,onScreenSizeChange:u}),C&&p&&T.regionCount===0?t.jsx(Yx,{}):null,t.jsxs("div",{ref:j,className:"relative flex-1 min-h-[320px] overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:[C?t.jsx("iframe",{ref:_,src:e,title:"Page preview",onLoad:T.handleFrameLoad,style:{width:k.width,height:k.height,border:"none",background:"white",transform:`scale(${N})`,transformOrigin:"top left"}},`${e}#${o}`):t.jsx(sb,{building:i,title:s,reason:r}),C&&(g==null?void 0:g.kind)==="body"?t.jsx(Qx,{anchor:nf(g.rect,N),paneWidth:S.width,paneHeight:S.height,file:g.file,initialBody:g.body,saving:g.saving,error:g.error,onSave:R=>v==null?void 0:v(R),onCancel:P},`body-${o}`):null,C&&(g==null?void 0:g.kind)==="field"?t.jsx(Xx,{anchor:nf(g.rect,N),paneWidth:S.width,paneHeight:S.height,def:g.def,entryLabel:g.entryLabel,initialValue:g.value,saving:g.saving,error:g.error,onSave:R=>v==null?void 0:v(R),onCancel:P},`field-${g.def.name}-${o}`):null]})]})}const NX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPreview:Nj},Symbol.toStringTag,{value:"Module"}));function Cj({manifest:e,selectedCollectionId:n,selectedSlug:s,entry:r,draft:a,dirty:o=!1,saveStatus:i="idle",saveError:c,newEntry:d,newEntryDerivedSlug:u="",newEntryCreating:p=!1,newEntryError:h,pendingSwitch:f=!1,search:m="",sort:g="date",previewUrl:x,previewReloadNonce:b=0,previewBuilding:y=!1,screenSizes:v,screenSize:j,onSelectCollection:_,onSelectEntry:S,onSearchChange:w,onSortChange:k,onDraftChange:N,onSave:C,onStartNew:T,onNewEntryChange:P,onCreate:R,onCancelNew:L,onConfirmSwitch:M,onCancelSwitch:O,onScreenSizeChange:z,edit:I}){const Y=e.collections??[],W=Y.find(D=>D.id===n)??null,A=(W==null?void 0:W.entries.find(D=>D.slug===s))??null,B=e.source==="inferred";return t.jsxs("div",{className:"flex flex-col gap-3",children:[B?t.jsx(tb,{}):null,t.jsxs("div",{className:"grid gap-4 min-h-[560px]",style:{gridTemplateColumns:"240px minmax(320px, 400px) minmax(0, 1fr)"},children:[t.jsxs("div",{className:"flex flex-col gap-4 min-h-0 border-r border-[var(--border-subtle)] pr-3",children:[t.jsx(lb,{collections:Y,selectedId:n,onSelect:_}),W&&W.kind!=="singleton"?t.jsx(Sj,{label:W.label,entries:W.entries,selectedSlug:s,search:m,sort:g,onSearchChange:w,onSortChange:k,onSelect:S,onNew:T}):null]}),t.jsxs("div",{className:"relative min-h-0",children:[d?t.jsx(kj,{collections:Y,draft:d,derivedSlug:u,creating:p,error:h,onChange:P,onCreate:R,onCancel:L}):r&&a?t.jsx(ab,{title:(A==null?void 0:A.title)??r.slug,file:r.file,fields:(W==null?void 0:W.fields)??[],draft:a,dirty:o,modified:r.modified,saveStatus:i,saveError:c,editingInPreview:(I==null?void 0:I.editingField)??null,onChange:N,onSave:C}):t.jsx("div",{className:"text-sm text-[var(--text-dim)] pt-8 text-center",children:"Pick a page on the left to edit it, or add a new one."}),f?t.jsx(nb,{onKeepEditing:O,onDiscard:M}):null]}),t.jsx(Nj,{url:d?null:x,displayPath:A==null?void 0:A.url,emptyTitle:d||!A?"Nothing to preview yet":"This entry has no page of its own",urlReason:d?"The preview appears once the page is created.":A?A.urlReason:"Pick a page to preview it here.",urlGuessed:B,reloadNonce:b,building:y,screenSizes:v,screenSize:j,onScreenSizeChange:z,editOnPage:I==null?void 0:I.onPage,onEditOnPageChange:I==null?void 0:I.onPageChange,editFields:I==null?void 0:I.fields,editScrollY:I==null?void 0:I.scrollY,editPopover:I==null?void 0:I.popover,onEditSelect:I==null?void 0:I.onSelect,onEditCommit:I==null?void 0:I.onCommit,onEditCancel:I==null?void 0:I.onCancel,onEditPopoverSave:I==null?void 0:I.onPopoverSave})]})]})}const CX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPanel:Cj},Symbol.toStringTag,{value:"Module"}));function Tj({manifest:e,refresh:n,selectedApp:s}){var H;const{config:r}=Pt(),a=(s==null?void 0:s.port)??(r==null?void 0:r.port)??3e3,o=Wl(r,s),i=U=>$o(U,{appPort:a,currentPort:typeof window<"u"?Lo(window.location):0,previewOrigin:o}),c=Object.entries((r==null?void 0:r.screenSizes)??{}).map(([U,pe])=>({name:U,width:pe.width,height:pe.height})),d=(r==null?void 0:r.defaultScreenSize)??"Desktop",u=e.collections??[],[p,h]=l.useState({collectionId:((H=u.find(U=>U.kind!=="singleton"))==null?void 0:H.id)??"",slug:null}),[f,m]=l.useState(null),[g,x]=l.useState(null),[b,y]=l.useState("idle"),[v,j]=l.useState(),[_,S]=l.useState(null),[w,k]=l.useState(null),[N,C]=l.useState(!1),[T,P]=l.useState(),[R,L]=l.useState(""),[M,O]=l.useState("date"),[z,I]=l.useState(d),[Y,W]=l.useState(0),[A,B]=l.useState(!1),D=l.useRef(!1);l.useEffect(()=>{D.current||(D.current=!0,bn.goLive().then(()=>W(U=>U+1),()=>{}))},[]);const J=$E(f,g),te=l.useCallback(async U=>{if(h(U),k(null),y("idle"),j(void 0),L(""),!U.slug){m(null),x(null);return}try{const pe=await bn.entry(U.collectionId,U.slug);m(pe),x(Es(pe))}catch(pe){m(null),x(null),j(String(pe))}},[]),oe=U=>{J?S(U):te(U)},se=async()=>{if(!(!f||!g||!J)){y("saving");try{const U=await bn.save(f.collection,f.slug,g);m(U),x(Es(U)),y("saved"),W(pe=>pe+1),n()}catch(U){y("error"),j(U instanceof Error?U.message:String(U))}}},G=w?md(w.title):"",le=async()=>{if(!w)return;const U=w.slug??G,pe=wj(u.find(ge=>ge.id===w.collectionId));C(!0),P(void 0);try{const ge=await bn.create(w.collectionId,U,{fields:{[pe]:w.title,...w.fields},body:""});await n(),k(null),h({collectionId:ge.collection,slug:ge.slug}),m(ge),x(Es(ge));const Me=HD(ge.collection,U);await xf(a,Me,3)||(B(!0),await bn.restartDevServer(),await xf(a,Me,30),B(!1)),W(Ce=>Ce+1)}catch(ge){P(ge instanceof Error?ge.message:String(ge))}finally{C(!1)}},ue=BD({manifest:e,open:f?{collection:f.collection,slug:f.slug}:null,entry:f,draft:g,onEntrySaved:(U,pe)=>{m(U),x(ge=>pe(ge??Es(U)))},onSaved:()=>{y("saved"),j(void 0),W(U=>U+1),n()},onError:U=>{y("error"),j(U)},onOpenCollection:U=>oe({collectionId:U,slug:null})}),ne=u.find(U=>U.id===p.collectionId),E=ne==null?void 0:ne.entries.find(U=>U.slug===p.slug);return t.jsx(Cj,{manifest:e,selectedCollectionId:p.collectionId,selectedSlug:p.slug,entry:f,draft:g,dirty:J,saveStatus:b,saveError:v,newEntry:w,newEntryDerivedSlug:G,newEntryCreating:N,newEntryError:T,pendingSwitch:_!==null,search:R,sort:M,previewUrl:E!=null&&E.url?i(E.url):null,previewReloadNonce:Y,previewBuilding:A,screenSizes:c,screenSize:z,onSelectCollection:U=>oe({collectionId:U,slug:null}),onSelectEntry:U=>oe({collectionId:p.collectionId,slug:U}),onSearchChange:L,onSortChange:O,onDraftChange:U=>{x(U),b!=="saving"&&y("idle")},onSave:()=>void se(),onStartNew:()=>k({collectionId:p.collectionId,title:"",slug:null,fields:{}}),onNewEntryChange:k,onCreate:()=>void le(),onCancelNew:()=>k(null),onConfirmSwitch:()=>{const U=_;S(null),U&&te(U)},onCancelSwitch:()=>S(null),onScreenSizeChange:I,edit:ue})}const TX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPanelConnected:Tj},Symbol.toStringTag,{value:"Module"}));function VD(){const[e,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/site-content");if(!r.ok){n({detected:!1});return}n(await r.json())}catch{n({detected:!1})}},[]);return l.useEffect(()=>{s()},[s]),{manifest:e,refresh:s}}function Pj({appDetailProps:e,selectedApp:n,setupSlot:s}){var c,d;const[r,a]=l.useState("simulations"),o=VD(),i=!!((c=o.manifest)!=null&&c.detected);return t.jsx("div",{style:{padding:"14px 10% 50px"},children:t.jsxs("div",{style:{width:"100%",maxWidth:2200,marginInline:"auto",borderTop:"0.5px solid var(--line-subtle)",paddingTop:26},children:[t.jsx(vj,{children:"Explore your app"}),t.jsxs(jj,{active:r,onChange:a,showSetup:!!s,showSiteContent:i,children:[r==="simulations"?t.jsx("div",{className:"-mx-5",children:t.jsx(iu,{...e,app:n,isWeb:(n==null?void 0:n.type)==="web",selectedEntityHash:e.selectedEntityHash??null,routeListTabbed:!0})}):null,r==="site-content"&&((d=o.manifest)!=null&&d.detected)?t.jsx(Tj,{manifest:o.manifest,refresh:o.refresh,selectedApp:n}):null,r==="setup"?s:null]})]})})}const PX=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreSection:Pj},Symbol.toStringTag,{value:"Module"}));function Pe({icon:e,title:n,meta:s,onBack:r,crumbLabel:a,assistKey:o}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:r,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:r,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("button",{type:"button",onClick:r,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:a??n})]}),t.jsxs("div",{className:"htitle",children:[t.jsx("div",{className:"hic",children:e}),t.jsxs("div",{children:[t.jsx("div",{className:"h",children:n}),t.jsx("div",{className:"hmeta",children:s})]})]})]})}function qn({topic:e,step:n,onBack:s}){return t.jsxs("div",{className:"crumbs",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:s,children:e})]}):t.jsx("span",{children:e}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:n})]})}function wn({steps:e,currentKey:n}){const s=e.findIndex(r=>r.key===n);return t.jsx("div",{className:"flowbar",children:e.map((r,a)=>t.jsxs("span",{style:{display:"contents"},children:[a>0?t.jsx("span",{className:"fsep"}):null,t.jsxs("span",{className:"fstep"+(a<s?" done":a===s?" active":""),children:[t.jsx("span",{className:"fn",children:a<s?"✓":a+1}),r.label]})]},r.key))})}function Ie({label:e,note:n,status:s,onComplete:r,onRevert:a,onBack:o,doneLabel:i="Completed"}){const[c,d]=l.useState(!1);return s==="done"||c?t.jsx("div",{className:"cta-wrap",children:t.jsxs("div",{className:"cta-done",children:[t.jsxs("span",{className:"cta-done-check",children:[t.jsx("span",{className:"ce",children:"✓"})," ",i]}),t.jsxs("div",{className:"cta-done-actions",children:[o?t.jsx("button",{type:"button",className:"lf-back",onClick:o,children:"Back to Setup"}):null,a?t.jsx("button",{type:"button",className:"cta-revert",onClick:()=>{a(),d(!1)},children:"Mark as not complete"}):null]})]})}):t.jsxs("div",{className:"cta-wrap",children:[t.jsxs("button",{type:"button",className:"cta",onClick:()=>{r(),d(!0)},children:[t.jsx("span",{className:"ce",children:"✓"})," ",e]}),t.jsx("div",{className:"cta-note",children:n})]})}const OX=Object.freeze(Object.defineProperty({__proto__:null,SetupCompleteCta:Ie,SetupDetailHeader:Pe,SetupFlowBar:wn,SetupSubCrumb:qn},Symbol.toStringTag,{value:"Module"}));function Yo({initial:e,color:n}){return t.jsx("div",{className:"altmark",style:{background:n,width:46,height:46},children:e})}function cu({provider:e}){return t.jsxs("div",{className:"provcard"+(e.bestFit?" best":""),children:[t.jsx(Yo,{initial:e.initial,color:e.color}),t.jsxs("div",{className:"provbody",children:[t.jsxs("div",{className:"provtop",children:[t.jsx("span",{className:"provname",children:e.name}),e.bestFit?t.jsx("span",{className:"bestfit",children:"Best fit"}):null]}),t.jsx("div",{className:"provdesc",children:e.description}),t.jsx("div",{className:"reasons",children:e.reasons.map(n=>t.jsxs("div",{className:"reason",children:[t.jsx(ft,{}),t.jsxs("span",{children:[t.jsx("b",{children:n.lead})," ",n.rest]})]},n.lead))}),t.jsx("div",{className:"chips",children:e.chips.map(n=>t.jsx("span",{className:"chip",children:n},n))})]})]})}function Oj({alts:e}){const[n,s]=l.useState(!1);return e.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>s(r=>!r),children:[n?"Hide other options":"Not for you? See other options",t.jsx("span",{className:"chev",style:{transform:n?"rotate(180deg)":"none"},children:"⌄"})]}),n?t.jsx("div",{className:"alts",children:e.map(r=>t.jsxs("div",{className:"altcard",children:[t.jsx("div",{className:"altmark",style:{background:r.color},children:r.initial}),t.jsxs("div",{className:"altbody",children:[t.jsx("div",{className:"altname",children:r.name}),t.jsx("div",{className:"altdesc",children:r.description})]}),t.jsx("button",{type:"button",className:"altpick",children:"Use this"})]},r.name))}):null]})}function Nt({items:e}){return e.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),t.jsx(Rj,{items:e})]})}function Rj({items:e}){const[n,s]=l.useState(-1);return e.length===0?null:t.jsx("div",{className:"faq",children:e.map((r,a)=>t.jsxs("div",{className:"faqitem",children:[t.jsxs("button",{type:"button",className:"faqq"+(n===a?" open":""),onClick:()=>s(n===a?-1:a),children:[r.q,t.jsx("span",{className:"chev",children:"⌄"})]}),n===a?t.jsx("div",{className:"faqa",children:r.a}):null]},r.q))})}const RX=Object.freeze(Object.defineProperty({__proto__:null,Alternatives:Oj,FaqSection:Nt,ProviderCard:cu,ProviderMark:Yo,TopicFaq:Rj},Symbol.toStringTag,{value:"Module"}));function du({icon:e,title:n,meta:s,crumbLabel:r,assistKey:a,onBack:o,lead:i,illustration:c,chatPrompt:d,onChatWithAI:u,faqs:p}){return t.jsxs("div",{className:"hosting-screen setup-topic",children:[t.jsx(Pe,{icon:e,title:n,meta:s,crumbLabel:r,onBack:o,assistKey:a}),t.jsx("div",{className:"lead",children:i}),c,t.jsx("div",{className:"cta-wrap",children:t.jsx("button",{type:"button",className:"cta",onClick:()=>u==null?void 0:u(d),children:"Chat with the AI about this"})}),t.jsx(Nt,{items:p})]})}const EX=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPage:du},Symbol.toStringTag,{value:"Module"}));function is({before:e,after:n}){return t.jsxs("div",{className:"setup-ill ill-split",children:[t.jsxs("div",{className:"isplit",children:[t.jsx("div",{className:"isplit-tag",children:e.tag}),e.items.map(s=>t.jsxs("div",{className:"isplit-row",children:[t.jsx("span",{className:"mk",children:"✕"}),t.jsx("span",{children:s})]},s))]}),t.jsx("div",{className:"isplit-arrow",children:"→"}),t.jsxs("div",{className:"isplit after",children:[t.jsx("div",{className:"isplit-tag",children:n.tag}),n.items.map(s=>t.jsxs("div",{className:"isplit-row",children:[t.jsx("span",{className:"mk",children:"✓"}),t.jsx("span",{children:s})]},s))]})]})}function ls({rows:e}){return t.jsx("div",{className:"setup-ill",children:t.jsx("div",{className:"ill-stack",children:e.map(n=>t.jsxs("div",{className:n.lime?"istack-row lime":"istack-row",children:[t.jsx("span",{className:"istack-emoji",children:n.emoji}),t.jsx("span",{className:"istack-lbl",children:n.label}),n.sub?t.jsx("span",{className:"istack-sub",children:n.sub}):null]},n.label))})})}function cs({center:e,satellites:n}){return t.jsx("div",{className:"setup-ill",children:t.jsxs("div",{className:"ill-orbit",children:[t.jsxs("div",{className:"iorbit-center",children:[t.jsx("div",{className:"iorbit-tile",children:e.emoji}),t.jsx("div",{className:"iorbit-lbl",children:e.label})]}),t.jsx("div",{className:"iorbit-sats",children:n.map(s=>t.jsx("div",{className:"iorbit-sat",children:s},s))})]})})}function za({bars:e}){return t.jsx("div",{className:"setup-ill",children:t.jsx("div",{className:"ill-bars",children:e.map(n=>t.jsxs("div",{className:n.lime?"ibar lime":"ibar",children:[t.jsx("div",{className:"ibar-fill",style:{height:`${n.pct}%`}}),t.jsx("div",{className:"ibar-lbl",children:n.label})]},n.label))})})}function In({emoji:e,caption:n,chips:s}){return t.jsxs("div",{className:"setup-ill",children:[t.jsxs("div",{className:"ill-emblem",children:[t.jsx("div",{className:"iemblem-tile",children:e}),t.jsx("div",{className:"iemblem-chips",children:s.map(r=>t.jsx("span",{className:"iemblem-chip",children:r},r))})]}),t.jsx("div",{className:"ill-cap",children:n})]})}function Hl({channels:e}){return t.jsx("div",{className:"setup-ill",children:t.jsx("div",{className:"ill-channels",children:e.map(n=>t.jsxs("div",{className:n.on?"ichan on":"ichan",children:[t.jsx("div",{className:"ichan-lbl",children:n.label}),t.jsx("div",{className:"ichan-track",children:Array.from({length:n.dots}).map((s,r)=>t.jsxs(l.Fragment,{children:[r>0?t.jsx("span",{className:"ichan-line"}):null,t.jsx("span",{className:"ichan-dot"})]},r))})]},n.label))})})}const AX=Object.freeze(Object.defineProperty({__proto__:null,SetupBars:za,SetupChannels:Hl,SetupEmblem:In,SetupOrbit:cs,SetupSplit:is,SetupStack:ls},Symbol.toStringTag,{value:"Module"}));function Ln({nodes:e}){return t.jsx("div",{className:"journey",children:t.jsx("div",{className:"jrow",children:e.map((n,s)=>t.jsxs(l.Fragment,{children:[t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:n.lime?"jtile lime":"jtile",children:n.emoji}),t.jsx("div",{className:"jlbl",children:n.label}),t.jsx("div",{className:"jsub",children:n.sub})]}),s===e.length-1?null:t.jsxs("div",{className:"jconn",children:[t.jsx("span",{className:"jpacket"}),t.jsx("span",{children:"→"})]})]},n.label))})})}const MX=Object.freeze(Object.defineProperty({__proto__:null,SetupJourney:Ln},Symbol.toStringTag,{value:"Module"}));function Ej(e){var a;const n=Object.values(((a=e.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 Aj(e){const n=e??[];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 KD=5e3,bf={headSha:null,branch:null};function JD(){const[e,n]=l.useState([]),[s,r]=l.useState(bf),[a,o]=l.useState(!0),[i,c]=l.useState(null),d=l.useRef(!1),u=l.useCallback(async h=>{if(!d.current){d.current=!0,h&&o(!0);try{const f=await fetch("/api/reviews");if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await f.json();n(m.reviews??[]),r(m.repoState??bf),c(m.error??null)}catch(f){c(f instanceof Error?f.message:"Failed to load reviews")}finally{h&&o(!1),d.current=!1}}},[]),p=l.useCallback(()=>u(!0),[u]);return l.useEffect(()=>{u(!0);const h=setInterval(()=>{u(!1)},KD);return()=>clearInterval(h)},[u]),{reviews:e,repoState:s,loading:a,error:i,reload:p}}function XD(e,n){var r;const s=(r=e.pr)==null?void 0:r.headRef;return!!s&&!!n.branch&&n.branch===s}function zn({label:e,children:n}){return t.jsxs("div",{className:"mb-2",children:[t.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:e}),t.jsx("div",{className:"mt-0.5",children:n})]})}const IX=Object.freeze(Object.defineProperty({__proto__:null,LabeledSection:zn},Symbol.toStringTag,{value:"Module"}));function Mj({files:e}){return e.length===0?null:t.jsx("div",{className:"max-h-32 overflow-y-auto",children:e.map(n=>t.jsxs("p",{className:"font-mono text-xs text-[var(--text-muted)]",children:[t.jsx(Ro,{status:n.status})," ",n.path]},n.path))})}const DX=Object.freeze(Object.defineProperty({__proto__:null,ModifiedFilesList:Mj},Symbol.toStringTag,{value:"Module"}));function QD(e){switch(e){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 Ij({finding:e}){const n=QD(e.severity),s=e.file&&(e.line!=null?`${e.file}:${e.line}`:e.file);return t.jsxs("div",{className:"flex flex-col gap-1 rounded border px-3 py-2",style:{borderColor:"var(--border-subtle)",background:"var(--bg-card)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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:e.severity}),s&&t.jsx("span",{className:"font-mono text-xs truncate",style:{color:"var(--text-secondary)"},children:s})]}),t.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.comment})]})}const LX=Object.freeze(Object.defineProperty({__proto__:null,ReviewFindingRow:Ij},Symbol.toStringTag,{value:"Module"}));function ZD(e){switch(e){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:e}}}function ql({label:e,path:n,onPreview:s}){const r=`${e} capture`,a=!!n&&!!s;return t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide",style:{color:"var(--text-dim)"},children:e}),t.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:t.jsx(Ot,{screenshotPath:n,alt:r})})]})}function Dj({pair:e,walkable:n,headRef:s,prNumber:r,onPreviewImage:a}){const o=ZD(e.status),i=e.status==="new",c=e.diffRatio!=null?`${(e.diffRatio*100).toFixed(1)}% changed`:null;return t.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border p-3",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-xs font-medium",style:{color:"var(--text-primary)"},children:e.slug}),t.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}),e.beforeStale&&t.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&&t.jsx("span",{className:"text-[10px]",style:{color:"var(--text-dim)"},children:c})]}),t.jsxs("div",{className:"flex gap-2",children:[!i&&t.jsx(ql,{label:"Before",path:e.beforePath,onPreview:a}),t.jsx(ql,{label:"After",path:e.afterPath,onPreview:a})]}),e.note&&t.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.note}),n?t.jsx("a",{href:`/scenario/${encodeURIComponent(e.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 →"}):t.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?t.jsxs(t.Fragment,{children:[" — ",t.jsxs("span",{className:"font-mono",children:["gh pr checkout ",r]})]}):s?t.jsxs(t.Fragment,{children:[" — ",t.jsxs("span",{className:"font-mono",children:["git checkout ",s]})]}):null]})]})}const $X=Object.freeze(Object.defineProperty({__proto__:null,CapturePane:ql,ScenarioComparisonRow:Dj},Symbol.toStringTag,{value:"Module"}));function Lj({scenarios:e,walkable:n,headRef:s,prNumber:r,onPreviewImage:a}){const[o,i]=l.useState(!1),{changed:c,created:d,unchanged:u}=Aj(e);if((e??[]).length===0)return t.jsx(zn,{label:"Impacted scenarios",children:t.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 p=h=>t.jsx(Dj,{pair:h,walkable:n,headRef:s,prNumber:r,onPreviewImage:a},h.slug);return t.jsx(zn,{label:"Impacted scenarios",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[c.map(p),d.map(p),u.length>0&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>i(h=>!h),"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(p)]})]})})}const FX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioImpactSection:Lj},Symbol.toStringTag,{value:"Module"}));function $j({review:e,repoState:n,onPreviewImage:s}){var d,u,p,h,f,m,g,x,b;const r=Ej(e),a=XD(e,n),o=e.findings??[],i=((d=e.tests)==null?void 0:d.added)??[],c=(((u=e.blastRadius)==null?void 0:u.changedFiles)??[]).map(y=>({path:y,status:"modified"}));return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((p=e.pr)==null?void 0:p.number)!=null&&t.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",e.pr.number]}),((h=e.pr)==null?void 0:h.author)&&t.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",e.pr.author]}),((f=e.pr)==null?void 0:f.url)&&t.jsx("a",{href:e.pr.url,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"View PR ↗"}),e.postedCommentUrl&&t.jsx("a",{href:e.postedCommentUrl,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"Posted comment ↗"})]}),((m=e.pr)==null?void 0:m.title)&&t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:e.pr.title})]}),t.jsx(Lj,{scenarios:e.scenarios??[],walkable:a,headRef:(g=e.pr)==null?void 0:g.headRef,prNumber:(x=e.pr)==null?void 0:x.number,onPreviewImage:s}),e.narrative&&t.jsx(zn,{label:"What this PR does",children:t.jsx(Po,{children:e.narrative})}),t.jsx(zn,{label:"Tests",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Oo,{total:r.total,passed:r.passed,failed:r.failed}),i.length>0?t.jsx("ul",{className:"flex flex-col gap-1.5",children:i.map((y,v)=>t.jsxs("li",{className:"flex flex-col",children:[t.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:y.name??y.file??"test"}),y.description&&t.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:y.description})]},y.file??y.name??v))}):t.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No new tests added."})]})}),o.length>0&&t.jsx(zn,{label:`Findings (${o.length})`,children:t.jsx("div",{className:"flex flex-col gap-2",children:o.map((y,v)=>t.jsx(Ij,{finding:y},`${y.file??"f"}-${v}`))})}),((b=e.alignment)==null?void 0:b.summary)&&t.jsx(zn,{label:"Codeyam alignment",children:t.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.alignment.summary})}),c.length>0&&t.jsx(zn,{label:"Changed files",children:t.jsx(Mj,{files:c})})]})}const zX=Object.freeze(Object.defineProperty({__proto__:null,ReviewDetailCard:$j},Symbol.toStringTag,{value:"Module"}));function eL(e){const n=e.findings??[];return{blocker:n.filter(s=>s.severity==="blocker").length,concern:n.filter(s=>s.severity==="concern").length,total:n.length}}function tL(e){return e==null?null:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function Fj({review:e,repoState:n,expanded:s,onToggle:r}){var d,u,p;if(e.parseError)return t.jsxs("div",{className:"rounded-lg border p-4",style:{borderColor:"var(--accent-red)",background:"var(--bg-card)"},children:[t.jsxs("p",{className:"text-sm font-medium",style:{color:"var(--accent-red)"},children:[e.id,": could not read digest"]}),t.jsx(dt,{text:e.parseError,copyText:`${e.id}: could not read digest
|
|
47
|
-
${e.parseError??""}`,className:"text-xs text-[var(--text-dim)]",rowClassName:"mt-1"})]});const a=Aj(e.scenarios),o=eL(e),i=Ej(e),c=tL(e.createdAtMs);return t.jsxs("div",{className:"rounded-lg border",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",onClick:r,className:"flex w-full flex-col gap-2 px-4 py-3 text-left",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((d=e.pr)==null?void 0:d.number)!=null&&t.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",e.pr.number]}),t.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:((u=e.pr)==null?void 0:u.title)??e.id}),((p=e.pr)==null?void 0:p.author)&&t.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",e.pr.author]}),c&&t.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["· ",c]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[t.jsxs("span",{style:{color:"var(--accent-orange)"},children:[a.changed.length," changed"]}),t.jsxs("span",{style:{color:"var(--accent-green)"},children:[a.created.length," new"]}),t.jsxs("span",{style:{color:"var(--text-dim)"},children:[a.unchanged.length," unchanged"]}),o.total>0&&t.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&&t.jsxs("span",{style:{color:i.failed>0?"var(--accent-red)":"var(--accent-green)"},children:[i.passed,"/",i.total," passed"]})]})]}),s&&t.jsx("div",{className:"px-4 pb-4 pt-1",style:{borderTop:"1px solid var(--border-subtle)"},children:t.jsx($j,{review:e,repoState:n})})]})}const BX=Object.freeze(Object.defineProperty({__proto__:null,ReviewCard:Fj},Symbol.toStringTag,{value:"Module"}));function zj({deviceLabel:e,actions:n}){return t.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:[t.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:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9"}),t.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"}),t.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"font-semibold",children:["Web preview — no ",e," running."]})," ",t.jsx("span",{style:{color:"var(--text-dim)"},children:"Boot a simulator for native fidelity (gestures, haptics, native storage)."})]}),n?t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:n}):null]})}const WX=Object.freeze(Object.defineProperty({__proto__:null,WebFallbackNotice:zj},Symbol.toStringTag,{value:"Module"}));function Bj({previewOrigin:e,onRecheck:n}){const s=()=>{window.open(e,"_blank","noopener")};return t.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:t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsx("span",{className:"text-base font-semibold",children:"Sign in to see the Live Preview"})]}),t.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."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.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"}),t.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 HX=Object.freeze(Object.defineProperty({__proto__:null,PreviewSignInNotice:Bj},Symbol.toStringTag,{value:"Module"}));function Wj({onReload:e,onReconnect:n,visible:s=!0,reason:r="lost",framed:a=!1,reconnect:o="idle",vmNumber:i=null}){return s?!a&&r==="lost"?t.jsx("div",{"data-testid":"session-lost-banner",className:"fixed inset-0 z-50 flex items-start justify-center bg-black/70 p-3",children:t.jsx("div",{className:"w-full max-w-2xl rounded-lg",style:{background:"var(--surface-page)"},children:t.jsx(Bt,{severity:"warning",testId:"session-lost-notice",headline:"This tab was signed out of the editor",explanation:"The editor no longer recognizes this tab's session — usually because it restarted. It tried to sign back in automatically and couldn't, so this page has stopped updating.",nextAction:"Reload this tab to get a fresh session. Nothing you've built is lost.",actions:[{label:"Reload this tab",onClick:e,testId:"session-lost-banner-reload"}]})})}):t.jsx("div",{"data-testid":"session-lost-strip",className:"pointer-events-none fixed inset-x-0 bottom-0 z-50 flex justify-center p-3",children:t.jsx("div",{className:"pointer-events-auto w-full max-w-2xl rounded-lg",style:{background:"var(--surface-page)"},children:a?t.jsx(Ix,{reason:r,reconnect:o,vmNumber:i,onReconnect:n}):t.jsx(Bt,{severity:"warning",testId:"session-lost-notice",headline:"This tab has no editor session",explanation:"None of this tab's requests to the editor have been accepted, so its live data can't load. No restart signed it out — it never had a session on this address.",nextAction:"Open the editor from its own address, or reload this tab.",actions:[{label:"Reload this tab",onClick:e,testId:"session-lost-banner-reload"}]})})}):null}const qX=Object.freeze(Object.defineProperty({__proto__:null,SessionLostBanner:Wj},Symbol.toStringTag,{value:"Module"}));function uu(){return t.jsxs("div",{style:{padding:"var(--spacing-lg, 16px)"},children:[t.jsx("h3",{style:{margin:0,color:"var(--text-primary)"},children:"Design exploration"}),t.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 UX=Object.freeze(Object.defineProperty({__proto__:null,MockupGridEmptyState:uu},Symbol.toStringTag,{value:"Module"}));function Ul({onRunTests:e,disabled:n,currentRunner:s}){return n?t.jsxs("span",{className:"text-xs font-medium text-[var(--text-dim)] inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-current border-r-transparent"}),s?`Running ${s}…`:"Running…"]}):t.jsx("span",{role:"button",tabIndex:0,onClick:r=>{r.stopPropagation(),e()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.stopPropagation(),e())},className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer",children:"Run Tests"})}const GX=Object.freeze(Object.defineProperty({__proto__:null,RunTestsButton:Ul},Symbol.toStringTag,{value:"Module"}));function Hj({passed:e,failed:n,notRun:s}){const r=e+n+s;if(r===0)return null;const a=2,o=[{count:e,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,p)=>u+p,0),d=i.map(u=>u/c*100);return t.jsx("div",{className:"h-1.5 flex-1 rounded-full bg-[var(--bg-input)] overflow-hidden max-w-32",children:t.jsx("div",{className:"h-full flex",children:o.map((u,p)=>t.jsx("div",{className:"h-full transition-all",style:{width:`${d[p]}%`,background:u.color}},u.color))})})}const YX=Object.freeze(Object.defineProperty({__proto__:null,TestBar:Hj},Symbol.toStringTag,{value:"Module"}));function pu({tests:e,loading:n,refreshing:s,onRunTests:r,currentRunner:a}){const o=e.total>0,i=e.discovered>0,c=e.discovered>e.total?e.discovered-e.total:0;return n?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("div",{className:"h-1.5 w-16 rounded-full bg-[var(--bg-input)] animate-pulse"}),t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:s?"Running tests…":"Loading tests…"})]}):o?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx(Hj,{passed:e.passed,failed:e.failed,notRun:c}),t.jsxs("span",{className:"text-xs font-medium text-[var(--accent-green)]",children:[e.passed," passed"]}),e.failed>0&&t.jsxs("span",{className:"text-xs font-medium text-[var(--accent-red)]",children:["· ",e.failed," failed"]}),e.ignored>0&&t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",e.ignored," skipped"]}),c>0&&t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",c," not run"]}),r&&t.jsx(Ul,{onRunTests:r,disabled:s,currentRunner:a})]}):i?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[e.discovered," ",e.discovered===1?"test":"tests"," (not run)"]}),r&&t.jsx(Ul,{onRunTests:r})]}):t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"No tests"})}const VX=Object.freeze(Object.defineProperty({__proto__:null,AppTestSummary:pu},Symbol.toStringTag,{value:"Module"}));function qj({tests:e,loading:n,refreshing:s,onRunTests:r,currentRunner:a}){return t.jsxs("div",{className:"px-5 pb-5 pt-2 flex items-center gap-5 border-t border-[var(--border-default)]",children:[t.jsx(pu,{tests:e,loading:n,refreshing:s,onRunTests:r,currentRunner:a}),t.jsx("span",{className:"text-[var(--text-dim)] group-hover:text-[var(--accent-active)] transition ml-auto text-sm",children:"→"})]})}const KX=Object.freeze(Object.defineProperty({__proto__:null,AppCardFooter:qj},Symbol.toStringTag,{value:"Module"}));function hu({type:e}){const n=e==="web";return t.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 JX=Object.freeze(Object.defineProperty({__proto__:null,AppTypeBadge:hu},Symbol.toStringTag,{value:"Module"}));function Uj({app:e}){return t.jsxs("div",{className:"px-5 pt-5 pb-2",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:e.name}),t.jsx(hu,{type:e.type})]}),e.description?t.jsx("p",{className:"text-sm text-[var(--text-muted)] leading-relaxed",children:e.description}):null]})}const XX=Object.freeze(Object.defineProperty({__proto__:null,AppCardHeader:Uj},Symbol.toStringTag,{value:"Module"}));function Gj({thumbnails:e}){return t.jsx("div",{className:"flex gap-2 overflow-hidden",children:e.map((n,s)=>t.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:t.jsx(Ot,{screenshotPath:n.path,cacheBuster:n.cacheBuster??void 0,alt:""})},`${n.path}:${s}`))})}const QX=Object.freeze(Object.defineProperty({__proto__:null,ThumbnailStrip:Gj},Symbol.toStringTag,{value:"Module"}));function Yj({thumbnails:e}){return t.jsx("div",{className:"px-5 py-3 flex-1",children:e.length>0?t.jsx(Gj,{thumbnails:e.slice(0,4)}):t.jsx("div",{className:"h-20"})})}const ZX=Object.freeze(Object.defineProperty({__proto__:null,AppCardScenarioStrip:Yj},Symbol.toStringTag,{value:"Module"}));function Vj({stats:e,onClick:n,testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o}){const{app:i,tests:c,scenarios:d}=e;return t.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:[t.jsx(Uj,{app:i}),t.jsx(Yj,{thumbnails:d.thumbnails}),t.jsx(qj,{tests:c,loading:s,refreshing:r,onRunTests:a,currentRunner:o})]})}const eQ=Object.freeze(Object.defineProperty({__proto__:null,AppCard:Vj},Symbol.toStringTag,{value:"Module"}));function fu({coverage:e,prefix:n,testId:s,className:r,onClick:a}){if(!e||e.totalLines===0)return null;const o=`${Math.round(e.percent)}% coverage`,i=t.jsxs(t.Fragment,{children:[n??"",o]}),c=`${e.hitLines}/${e.totalLines} lines covered`;return a?t.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}):t.jsx("span",{className:r??"text-xs font-medium text-[var(--text-secondary)]","data-testid":s??"coverage-badge",title:c,children:i})}const tQ=Object.freeze(Object.defineProperty({__proto__:null,CoverageBadge:fu},Symbol.toStringTag,{value:"Module"}));function Kj({app:e,showDetail:n,navContext:s=ys,stats:r,testsLoading:a,testsRefreshing:o,onRunTests:i,currentRunner:c,coverage:d,onCoverageClick:u}){if(n)return null;const p=!!(d&&d.totalLines>0);return t.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-default)]",children:[t.jsx("div",{className:"mb-2",children:t.jsx(Go,{apps:s.apps,selectedApp:e,selectedRouteEntity:null,isSingleApp:s.isSingleApp,onSelectApps:s.onSelectApps,onSelectApp:s.onSelectApp,onSelectRoute:s.onSelectRoute})}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:e.name}),t.jsx(hu,{type:e.type})]}),p?t.jsx(fu,{coverage:d,testId:"app-detail-coverage",onClick:u}):null]}),e.description?t.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:e.description}):null,r?t.jsx("div",{className:"mt-3",children:t.jsx(pu,{tests:r.tests,loading:a,refreshing:o,onRunTests:i,currentRunner:c})}):null]})}const nQ=Object.freeze(Object.defineProperty({__proto__:null,AppDetailHeader:Kj},Symbol.toStringTag,{value:"Module"}));function Jj({name:e,id:n,capabilitiesTally:s,expanded:r,onToggle:a}){const o=e??n;return t.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:[t.jsx("span",{className:`inline-block transition-transform ${r?"rotate-90":""}`,children:"▶"}),t.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["Stack",o?` — ${o}`:""]}),e&&n?t.jsxs("span",{className:"text-[var(--text-dim)]",children:["(",n,")"]}):null,t.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",s]})]})}const sQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelSummary:Jj},Symbol.toStringTag,{value:"Module"})),Gl=["layout-web","interactions-click","interactions-touch-gestures","native-haptics","native-geolocation","native-clipboard","native-network","native-storage","routing","http-mocks","real-device"],Xj={"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"}},Qj={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 nL(e){var n;return((n=Xj[e])==null?void 0:n.label)??e}function sL(e,n){var a,o;const s=(a=Xj[e])==null?void 0:a.description,r=((o=Qj[n])==null?void 0:o.meaning)??"";return s?`${s}. ${r}`:r}function Zj({capabilities:e,defaultExpanded:n=!1}){const[s,r]=l.useState(n),a=Gl.filter(c=>c in e),o=Object.keys(e).filter(c=>!Gl.includes(c)),i={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const c of a){const d=e[c];d in i&&(i[d]+=1)}return t.jsxs("div",{className:"px-5 py-2","data-testid":"capabilities-panel",children:[t.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:[t.jsx("span",{className:`inline-block transition-transform ${s?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Stack capabilities"}),t.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",i.verified," verified · ",i.stubbed," stubbed ·"," ",i.manual," manual · ",i["not-applicable"]," n/a"]})]}),s?t.jsxs("div",{className:"mt-2 space-y-1","data-testid":"capabilities-rows",children:[a.map(c=>t.jsx(Yl,{token:c,state:e[c]},c)),o.length>0?t.jsxs("div",{className:"mt-3","data-testid":"capabilities-unknown-group",children:[t.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-[var(--accent-warn)]",children:[t.jsx("span",{title:"These tokens aren't recognized — likely typos",children:"⚠"}),"Unknown capabilities"]}),o.map(c=>t.jsx(Yl,{token:c,state:e[c],unknown:!0},c))]}):null]}):null]})}function Yl({token:e,state:n,unknown:s}){const r=Qj[n],a=s?"This token isn't recognized — may be a typo.":sL(e,n);return t.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs","data-testid":`capability-row-${e}`,children:[t.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-secondary)]",children:[nL(e),t.jsx("span",{className:"cursor-help text-[var(--text-dim)]",title:a,"aria-label":a,children:"ⓘ"})]}),t.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 rQ=Object.freeze(Object.defineProperty({__proto__:null,AppCapabilitiesPanel:Zj,CapabilityRow:Yl},Symbol.toStringTag,{value:"Module"}));function ew({capabilities:e}){return e&&Object.keys(e).length>0?t.jsx(Zj,{capabilities:e,defaultExpanded:!1}):t.jsxs("div",{className:"text-xs text-[var(--text-dim)]","data-testid":"stack-capabilities-empty-hint",children:["Capabilities not declared. Run"," ",t.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 aQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackCapabilitiesSlot:ew},Symbol.toStringTag,{value:"Module"}));function tw({fields:e,capabilities:n}){return t.jsxs("div",{className:"mt-2 space-y-2","data-testid":"stack-body",children:[e.description?t.jsx("p",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-description",children:e.description}):null,e.technologies.length>0?t.jsx("ul",{className:"flex flex-wrap gap-1","data-testid":"stack-technologies",children:e.technologies.map(s=>t.jsx("li",{className:"rounded bg-[var(--bg-subtle)] px-1.5 py-0.5 text-[10px] text-[var(--text-secondary)]",children:s},s))}):null,e.commands.length>0?t.jsx("dl",{className:"space-y-0.5 text-xs","data-testid":"stack-commands",children:e.commands.map(({key:s,value:r})=>t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("dt",{className:"w-10 text-[var(--text-dim)]",children:s}),t.jsx("dd",{className:"text-[var(--text-secondary)]",children:t.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5",children:r})})]},s))}):null,e.routingSummary?t.jsxs("div",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-routing",children:[t.jsx("span",{className:"text-[var(--text-dim)]",children:"routing"})," ",e.routingSummary]}):null,t.jsx("div",{className:"border-t border-[var(--border-subtle)] pt-2",children:t.jsx(ew,{capabilities:n})})]})}const oQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelBody:tw},Symbol.toStringTag,{value:"Module"}));function nw({skip:e=!1}={}){const[n,s]=l.useState(null);return l.useEffect(()=>{if(e)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}},[e]),n}const rL=["dev","test","build"];function Un(e){return typeof e=="string"&&e.length>0?e:null}function sw(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function aL(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function oL(e){const n=sw(e);if(!n)return[];const s=[];for(const r of rL){const a=Un(n[r]);a&&s.push({key:r,value:a})}return s}function iL(e){const n=sw(e);if(!n)return null;const s=Un(n.type);if(!s)return null;const r=Un(n.pagesDir)??Un(n.isolationRoute)??Un(n.componentManifest);return r?`${s} (${r})`:s}function lL(e){const n=e.capabilities;return!n||typeof n!="object"||Array.isArray(n)?null:n}function cL(e){if(!e||Object.keys(e).length===0)return"capabilities not declared";const n={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const s of Gl){const r=e[s];r&&r in n&&(n[r]+=1)}return`${n.verified} verified · ${n.stubbed} stubbed · ${n.manual} manual · ${n["not-applicable"]} n/a`}function dL(e){return e?{id:Un(e.id),name:Un(e.name),description:Un(e.description),technologies:aL(e.technologies),commands:oL(e.commands),routingSummary:iL(e.routing)}:{id:null,name:null,description:null,technologies:[],commands:[],routingSummary:null}}function rw({stack:e,defaultExpanded:n=!1}){const s=e!==void 0,[r,a]=l.useState(n),o=nw({skip:s}),i=s?e:o;if(!i||Object.keys(i).length===0)return null;const c=dL(i),d=lL(i);return t.jsxs("div",{className:"px-5 py-2","data-testid":"stack-panel",children:[t.jsx(Jj,{name:c.name,id:c.id,capabilitiesTally:cL(d),expanded:r,onToggle:()=>a(u=>!u)}),r?t.jsx(tw,{fields:c,capabilities:d}):null]})}const iQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanel:rw},Symbol.toStringTag,{value:"Module"}));function aw({app:e,navContext:n=ys,routeEntities:s,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesRefreshing:i,routesError:c,selectedEntityHash:d,selectedRouteEntity:u,testGroups:p,selectedSlug:h,entityLookup:f,allScenarios:m,onSelectScenario:g,onSelectRoute:x,onSelectEntity:b,onBackToRoutes:y,onScenariosChanged:v,coverage:j,showProjectBand:_,onCoverageClick:S,stats:w,testsLoading:k,testsRefreshing:N,onRunTests:C,currentRunner:T}){const P=e.type==="web",R=!!_&&!u;return t.jsxs("div",{children:[R?t.jsx(rw,{}):null,t.jsx(Kj,{app:e,showDetail:!!(u||d),navContext:n,stats:w,testsLoading:k,testsRefreshing:N,onRunTests:C,currentRunner:T,coverage:R?j:void 0,onCoverageClick:S}),t.jsx(iu,{app:e,navContext:n,isWeb:P,routeEntities:s,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesRefreshing:i,routesError:c,selectedEntityHash:d??null,selectedRouteEntity:u,testGroups:p,selectedSlug:h,entityLookup:f,allScenarios:m,onSelectScenario:g,onSelectRoute:x,onSelectEntity:b,onBackToRoutes:y,onScenariosChanged:v})]})}const lQ=Object.freeze(Object.defineProperty({__proto__:null,AppDetail:aw},Symbol.toStringTag,{value:"Module"}));function ow({screenshots:e,onSelect:n}){return e.length===0?null:t.jsx("div",{className:"flex flex-wrap gap-2",children:e.map((s,r)=>{const a=!!n&&!!s.screenshotPath,o=t.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:t.jsx(Ot,{screenshotPath:s.screenshotPath,cacheBuster:s.screenshotCapturedAtMs??void 0,alt:s.name})});return t.jsxs("div",{className:"text-center",children:[a?t.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,t.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 cQ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioThumbnailGrid:ow},Symbol.toStringTag,{value:"Module"})),uL="calc(100vh - 110px)";function Kt({children:e,testId:n,fill:s=!1}){return t.jsx("div",{className:s?"flex min-h-0 flex-1 flex-col overflow-y-auto px-2":"overflow-y-auto px-4 py-4",style:s?void 0:{maxHeight:uL},"data-testid":n,children:e})}const dQ=Object.freeze(Object.defineProperty({__proto__:null,TabScrollPanel:Kt},Symbol.toStringTag,{value:"Module"}));function iw(){const{reviews:e,repoState:n,loading:s,error:r}=JD(),[a,o]=l.useState(null);return s?t.jsx(Kt,{children:t.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading reviews..."})}):r&&e.length===0?t.jsx(Kt,{children:t.jsx("div",{className:"py-12",children:t.jsx(dt,{text:`Failed to load reviews: ${r}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}):e.length===0?t.jsx(Kt,{children:t.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[t.jsx("p",{children:"No PR digests yet."}),t.jsxs("p",{className:"mt-2 text-sm",children:["Run"," ",t.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:"/codeyam-review-pr"})," ","to digest an incoming pull request."]})]})}):t.jsx(Kt,{children:t.jsx("div",{className:"flex flex-col gap-3",children:e.map(i=>t.jsx(Fj,{review:i,repoState:n,expanded:a===i.id,onToggle:()=>o(c=>c===i.id?null:i.id)},i.id))})})}const uQ=Object.freeze(Object.defineProperty({__proto__:null,ReviewsTab:iw},Symbol.toStringTag,{value:"Module"}));function pL({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"11",cy:"11",r:"7"}),t.jsx("path",{d:"m20 20-3.5-3.5"})]})}function hL({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),t.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"}),t.jsx("path",{d:"M9 12h6"}),t.jsx("path",{d:"M9 16h6"})]})}function hs({size:e=20}){return t.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"})})}function Zr({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),t.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),t.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function ot({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function Ys({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}function pt({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.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"}),t.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"}),t.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),t.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function mu({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),t.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),t.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),t.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),t.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),t.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),t.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),t.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]})}function Fs({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("polyline",{points:"4 17 10 11 4 5"}),t.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function kn({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),t.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]})}function Xt({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),t.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),t.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function nt({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),t.jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]})}function Yn({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),t.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 It({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.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"}),t.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),t.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})}function gu({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}const pQ=Object.freeze(Object.defineProperty({__proto__:null,BellIcon:gu,BoxIcon:It,CardIcon:kn,ChartIcon:Xt,CloudIcon:hs,DatabaseIcon:Zr,DocIcon:nt,ExploreIcon:pL,GlobeIcon:Yn,LockIcon:ot,MailIcon:Ys,PlansIcon:hL,RocketIcon:pt,SetupIcon:mu,TerminalIcon:Fs},Symbol.toStringTag,{value:"Module"})),fL=[{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"}],mL={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 lw({intent:e="add",onSubmit:n,onCancel:s}){const r=mL[e],[a,o]=l.useState(""),[i,c]=l.useState(""),[d,u]=l.useState("box"),[p,h]=l.useState(!1),[f,m]=l.useState(null),g=a.trim(),x=g.length>0&&!p,b=async y=>{if(y.preventDefault(),!x){g.length===0&&m("Please enter a name.");return}h(!0),m(null);try{await n({name:g,desc:i.trim(),icon:d})}catch(v){m(v instanceof Error?v.message:"Something went wrong."),h(!1)}};return t.jsxs("div",{className:"learn-screen",children:[t.jsx("div",{className:"atf-backdrop",role:"presentation",onClick:s}),t.jsxs("div",{className:"atf-modal",role:"dialog","aria-modal":"true","aria-label":r.title,children:[t.jsx("div",{className:"atf-title",children:r.title}),t.jsx("p",{className:"atf-lead",children:r.lead}),t.jsxs("form",{onSubmit:b,children:[t.jsxs("label",{className:"atf-field",children:[t.jsx("span",{className:"atf-label",children:"Name"}),t.jsx("input",{className:"atf-input",type:"text",value:a,autoFocus:!0,placeholder:e==="ask"?"e.g. Cloudflare, a regional payment processor…":"e.g. Error monitoring, a custom step…",onChange:y=>o(y.target.value)})]}),t.jsxs("label",{className:"atf-field",children:[t.jsxs("span",{className:"atf-label",children:["What is it for? ",t.jsx("span",{className:"atf-optional",children:"(optional)"})]}),t.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)})]}),t.jsxs("label",{className:"atf-field",children:[t.jsx("span",{className:"atf-label",children:"Icon"}),t.jsx("select",{className:"atf-input",value:d,onChange:y=>u(y.target.value),children:fL.map(y=>t.jsx("option",{value:y.key,children:y.label},y.key))})]}),f?t.jsx("div",{className:"atf-error",children:t.jsx(dt,{text:f,className:""})}):null,t.jsxs("div",{className:"atf-actions",children:[t.jsx("button",{type:"button",className:"atf-btn atf-btn-ghost",onClick:s,disabled:p,children:"Cancel"}),t.jsx("button",{type:"submit",className:"atf-btn atf-btn-primary",disabled:!x,children:p?r.submitting:r.submit})]})]})]})]})}const hQ=Object.freeze(Object.defineProperty({__proto__:null,AddTopicForm:lw},Symbol.toStringTag,{value:"Module"}));function cw({onAdd:e,onAsk:n}){return t.jsxs("div",{className:"setup-addrow",children:[t.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."}),t.jsxs("div",{className:"setup-addrow-btns",children:[t.jsx("button",{type:"button",className:"setup-addbtn",onClick:e,children:"+ Add a topic"}),t.jsx("button",{type:"button",className:"setup-addbtn setup-addbtn-ask",onClick:n,children:"Ask the AI about a service"})]})]})}const fQ=Object.freeze(Object.defineProperty({__proto__:null,SetupAddTopicRow:cw},Symbol.toStringTag,{value:"Module"}));function gL(){const[e,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 e??[])r.set(a.key,a);return r},[e]);return{concepts:e,byKey:r=>s.get(r)}}const xL={concepts:[],byKey:()=>{}},Vo=l.createContext(xL);function dw({children:e}){const n=gL();return t.jsx(Vo.Provider,{value:n,children:e})}function uw(){return l.useContext(Vo)}function pw(e){return l.useContext(Vo).byKey(e)}const mQ=Object.freeze(Object.defineProperty({__proto__:null,ConceptsContext:Vo,ConceptsProvider:dw,useConcept:pw,useConceptIndex:uw},Symbol.toStringTag,{value:"Module"}));function Ba({k:e,children:n}){const s=pw(e),[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useId(),d=r!==null,u=()=>{var h;const p=(h=o.current)==null?void 0:h.getBoundingClientRect();p&&a({top:p.bottom+6,left:p.left})};return l.useEffect(()=>{if(!d)return;const p=f=>{var g,x;const m=f.target;!((g=o.current)!=null&&g.contains(m))&&!((x=i.current)!=null&&x.contains(m))&&a(null)},h=f=>{f.key==="Escape"&&a(null)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",h)}},[d]),s?t.jsxs("span",{className:"concept-term-wrap",children:[t.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?us.createPortal(t.jsxs("div",{ref:i,className:"concept-popover",id:c,role:"dialog",style:{top:r.top,left:r.left},children:[t.jsx("span",{className:"concept-popover-term",children:s.term}),s.category?t.jsx("span",{className:"concept-popover-cat",children:s.category}):null,t.jsx("div",{className:"concept-popover-body",children:t.jsx(Lt,{variant:"compact",children:s.body})})]}),document.body):null]}):t.jsx(t.Fragment,{children:n})}const gQ=Object.freeze(Object.defineProperty({__proto__:null,ConceptTerm:Ba},Symbol.toStringTag,{value:"Module"}));function hw(e){const n=e.evidence[0];return n?`found ${n.value} in ${n.source}`:e.source==="declared"?"declared by the agent":"detected in this project"}function fw({service:e,onDismiss:n,onAddCredential:s}){var i;const r=(((i=e.envVars)==null?void 0:i.length)??0)>0,a=r&&!e.credentialPresent,o=r&&e.credentialPresent;return t.jsxs("div",{className:"detected-service",children:[t.jsx("span",{className:"ds-tag",children:e.source}),t.jsx("span",{className:"ds-name",children:e.name}),t.jsx("span",{className:"ds-why",children:hw(e)}),o?t.jsx("span",{className:"ds-key-set","data-testid":`ds-key-set-${e.key}`,children:"Key set"}):null,a&&s?t.jsx("button",{type:"button",className:"ds-add-key",onClick:()=>s(e),"aria-label":`Add key for ${e.name}`,children:"Add key"}):null,n?t.jsx("button",{type:"button",className:"ds-dismiss",onClick:()=>n(e.key),"aria-label":`Dismiss ${e.name}`,children:"Dismiss"}):null]})}const xQ=Object.freeze(Object.defineProperty({__proto__:null,DetectedServiceRow:fw,evidenceSummary:hw},Symbol.toStringTag,{value:"Module"})),bL={terminal:Fs,cloud:hs,database:Zr,lock:ot,mail:Ys,card:kn,chart:Xt,doc:nt,globe:Yn,box:It,bell:gu,rocket:pt};function yL(e){return bL[e]??mu}function vL(e){return e==="done"?"trow done":e==="next"||e==="in-progress"?"trow next":"trow soon"}function jL(e){return e==="done"?"set up":e==="in-progress"?"in progress":e==="next"?"next":"explore"}function Wa({topics:e,detectedServices:n,onBack:s,onOpenHosting:r,onOpenTopic:a,onOpenLibraries:o,onDismissService:i,onAddCredential:c,onCreateTopic:d,onOpenConcepts:u}){const p=x=>{x.key==="hosting"?r():a==null||a(x.key)},h=new Map;for(const x of n??[]){if(x.status==="dismissed")continue;const b=h.get(x.topic)??[];b.push(x),h.set(x.topic,b)}const[f,m]=l.useState(null),g=async x=>{if(!d)return;const b=await d(x);m(null),a==null||a(b.key)};return t.jsxs("div",{className:"learn-screen",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:s,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Setup"})]}),t.jsx("div",{className:"h",children:"Setup"}),t.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?t.jsxs("div",{className:"concepts-nudge",children:["New to terms like ",t.jsx(Ba,{k:"hosting",children:"hosting"}),", a"," ",t.jsx(Ba,{k:"domain",children:"domain"}),", or"," ",t.jsx(Ba,{k:"ssl-https",children:"HTTPS"}),"? Tap any underlined word for a plain-language explainer, or"," ",t.jsx("button",{type:"button",className:"concepts-nudge-link",onClick:u,children:"browse what these words mean"}),"."]}):null,t.jsx("div",{className:"tlist",children:e===null?Array.from({length:5}).map((x,b)=>t.jsxs("div",{className:"trow soon","aria-hidden":"true",children:[t.jsx("div",{className:"tic"}),t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:" "}),t.jsx("div",{className:"td",children:" "})]})]},b)):e.map(x=>{const b=yL(x.icon),y=h.get(x.key)??[];return t.jsxs("div",{className:"trow-group",children:[t.jsxs("button",{type:"button",className:vL(x.status),onClick:()=>p(x),children:[t.jsx("div",{className:"tic",children:t.jsx(b,{size:20})}),t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:x.name}),t.jsx("div",{className:"td",children:x.desc})]}),t.jsx("span",{className:"tt",children:jL(x.status)}),t.jsx("span",{className:"arrow",children:"→"})]}),y.length>0?t.jsx("div",{className:"detected-services",children:y.map(v=>t.jsx(fw,{service:v,onDismiss:i,onAddCredential:c},v.key))}):null]},x.key)})}),o&&t.jsxs("div",{className:"setup-libraries-section",children:[t.jsx("div",{className:"seclabel",children:"Libraries"}),t.jsxs("button",{type:"button",className:"trow",onClick:o,children:[t.jsx("div",{className:"tic",children:t.jsx(It,{size:20})}),t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:"Libraries you depend on"}),t.jsx("div",{className:"td",children:"Every third-party library your app pulls in — what it is, its version, and how to update it."})]}),t.jsx("span",{className:"tt",children:"auto"}),t.jsx("span",{className:"arrow",children:"→"})]})]}),d?t.jsx(cw,{onAdd:()=>m("add"),onAsk:()=>m("ask")}):null,f&&d?t.jsx(lw,{intent:f,onSubmit:g,onCancel:()=>m(null)}):null]})}const bQ=Object.freeze(Object.defineProperty({__proto__:null,LearnSetupScreen:Wa},Symbol.toStringTag,{value:"Module"}));function vr({command:e,writer:n}){const{copied:s,copy:r}=To({writer:n});return t.jsxs("div",{className:"rl-cmd",children:[t.jsx("code",{className:"rl-cmd-text",children:e}),t.jsx("button",{type:"button",className:"rl-copy",onClick:()=>{r(e).catch(()=>{})},"aria-label":`Copy command: ${e}`,children:s?"Copied!":"Copy"})]})}const yQ=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyCommandRow:vr},Symbol.toStringTag,{value:"Module"}));function wL(e){return e==="dev"?"dev":e==="transitive"?"transitive":"direct"}function mw({lib:e,copyWriter:n}){return t.jsxs("div",{className:"lib-row",children:[t.jsxs("div",{className:"lib-head",children:[t.jsx("span",{className:"lib-name",children:e.name}),t.jsx("span",{className:"lib-version",children:e.version||"—"}),t.jsx("span",{className:`lib-kind ${e.kind}`,children:wL(e.kind)}),e.outdated&&t.jsx("span",{className:"lib-outdated",title:"A newer version is available",children:"outdated"})]}),e.description?t.jsx("div",{className:"lib-desc",children:e.description}):t.jsx("div",{className:"lib-desc muted",children:"A library this project depends on. No description on file yet."}),t.jsxs("div",{className:"lib-meta",children:[e.category&&t.jsx("span",{className:"lib-tag",children:e.category}),e.license&&t.jsxs("span",{className:"lib-license",children:["License: ",e.license]}),e.homepage&&t.jsx("a",{className:"lib-docs",href:e.homepage,target:"_blank",rel:"noreferrer",children:"Docs ↗"})]}),t.jsx(vr,{command:e.updateCommand,writer:n})]})}const vQ=Object.freeze(Object.defineProperty({__proto__:null,LibraryRow:mw},Symbol.toStringTag,{value:"Module"}));function _L(e,n){return n?`${e.name} ${e.description??""} ${e.category??""}`.toLowerCase().includes(n):!0}function gw({group:e,query:n,forceOpen:s,copyWriter:r}){const[a,o]=l.useState(e.libraries.length<=8),i=e.libraries.filter(d=>_L(d,n));if(n&&i.length===0)return null;const c=s||a;return t.jsxs("section",{className:"lib-group",children:[t.jsxs("button",{type:"button",className:"lib-group-head","aria-expanded":c,onClick:()=>o(d=>!d),children:[t.jsx("span",{className:"lib-group-icon",children:t.jsx(It,{size:18})}),t.jsx("span",{className:"lib-group-title",children:e.ecosystem}),t.jsxs("span",{className:"lib-group-count",children:[i.length," ",i.length===1?"library":"libraries"]}),t.jsx("span",{className:"lib-group-path",children:e.manifestPath}),t.jsx("span",{className:"lib-group-chevron",children:c?"▾":"▸"})]}),c&&t.jsx("div",{className:"lib-rows",children:i.map(d=>t.jsx(mw,{lib:d,copyWriter:r},d.name))})]})}const jQ=Object.freeze(Object.defineProperty({__proto__:null,LibraryGroupSection:gw},Symbol.toStringTag,{value:"Module"}));function xw({groups:e,onBack:n,copyWriter:s}){const[r,a]=l.useState(""),o=r.trim().toLowerCase(),i=l.useMemo(()=>(e??[]).reduce((c,d)=>c+d.libraries.length,0),[e]);return t.jsxs("div",{className:"learn-screen libraries-screen",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:n,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("button",{type:"button",onClick:n,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Libraries"})]}),t.jsx("div",{className:"h",children:"Libraries"}),t.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."}),e===null?t.jsx("div",{className:"lib-loading","aria-hidden":"true",children:"Reading your project's libraries…"}):e.length===0?t.jsxs("div",{className:"lib-empty",children:[t.jsx("div",{className:"lib-empty-title",children:"No libraries yet"}),t.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."})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"lib-searchbar",children:t.jsx("input",{type:"search",className:"lib-search",placeholder:`Search ${i} libraries…`,value:r,onChange:c=>a(c.target.value),"aria-label":"Search libraries"})}),t.jsx("div",{className:"lib-groups",children:e.map(c=>t.jsx(gw,{group:c,query:o,forceOpen:o.length>0,copyWriter:s},c.manifestPath))})]})]})}const wQ=Object.freeze(Object.defineProperty({__proto__:null,LibrariesCatalogScreen:xw},Symbol.toStringTag,{value:"Module"}));function xu(e){switch(e){case"real-data":return t.jsx(is,{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 t.jsx(is,{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 t.jsx(is,{before:{tag:"Cryptic",items:["Confusing errors","Guess the flags"]},after:{tag:"Polished",items:["Clear help & output","Helpful messages"]}});case"forms":return t.jsx(is,{before:{tag:"Without setup",items:["Submissions lost","Spam gets through"]},after:{tag:"With setup",items:["Reliably delivered","Spam filtered out"]}});case"custom-domain":return t.jsx(is,{before:{tag:"Default link",items:["Generic address","Hard to remember"]},after:{tag:"Your domain",items:["yourname.com","Secure & trusted"]}});case"accounts":return t.jsx(cs,{center:{emoji:"🔑",label:"Sign-in"},satellites:["✉️ Email link","🔵 Google","🍎 Apple","🔒 Password"]});case"emails":return t.jsx(cs,{center:{emoji:"✉️",label:"Your app sends"},satellites:["👋 Welcome","🔑 Password reset","🧾 Receipt","🔔 Notification"]});case"api-auth":return t.jsx(cs,{center:{emoji:"🛡️",label:"Your API"},satellites:["🎟️ API key","🪪 Token","⛔ Revoke anytime"]});case"cors-origins":return t.jsx(cs,{center:{emoji:"🚦",label:"Your API"},satellites:["✅ your-site.com","✅ app.your-site.com","⛔ everyone else"]});case"comments-search":return t.jsx(cs,{center:{emoji:"📚",label:"Your content"},satellites:["🔍 Fast search","💬 Comments","🛡️ Moderation"]});case"analytics-monitoring":return t.jsx(za,{bars:[{label:"Visits",pct:62},{label:"Signups",pct:40},{label:"Active",pct:78,lime:!0},{label:"Errors",pct:16}]});case"analytics-seo":return t.jsx(za,{bars:[{label:"Search",pct:70,lime:!0},{label:"Direct",pct:45},{label:"Social",pct:30},{label:"Referral",pct:22}]});case"logging-monitoring":return t.jsx(za,{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 t.jsx(ls,{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 t.jsx(ls,{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 t.jsx(ls,{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 t.jsx(ls,{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 t.jsx(ls,{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 t.jsx(ls,{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 t.jsx(Hl,{channels:[{label:"Stable",dots:5},{label:"Beta",dots:5,on:!0}]});case"pre-release-versions":return t.jsx(Hl,{channels:[{label:"latest",dots:4},{label:"next",dots:4,on:!0}]});case"legal":return t.jsx(In,{emoji:"⚖️",caption:"Clear, honest, above board",chips:["Privacy policy","Terms of service","Plain language"]});case"data-safety":return t.jsx(In,{emoji:"🛡️",caption:"Collect less, protect the rest",chips:["Minimize","Encrypt","Declare clearly"]});case"supply-chain":return t.jsx(In,{emoji:"🔗",caption:"Trust the code you depend on",chips:["Scan for risk","Pin versions","Verify builds"]});case"secrets":return t.jsx(In,{emoji:"🔑",caption:"Out of the code, in a safe store",chips:["Never committed","Easy to rotate","Per-environment"]});case"readme-license":return t.jsx(In,{emoji:"📖",caption:"The first things visitors read",chips:["What it is","How to use it","What's allowed"]});case"install-docs":return t.jsx(In,{emoji:"📘",caption:"From zero to running, fast",chips:["Install","First example","Common task"]});case"examples":return t.jsx(In,{emoji:"🧩",caption:"Show it solving real tasks",chips:["Runnable","Real use cases","Copy & tweak"]});case"publish":return t.jsx(Ln,{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 t.jsx(Ln,{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 t.jsx(Ln,{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 t.jsx(Ln,{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 t.jsx(Ln,{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 t.jsx(Ln,{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 t.jsx(cs,{center:{emoji:"💳",label:"Secure checkout"},satellites:["💳 One-off","🔁 Subscriptions","🧾 Receipts","↩️ Refunds"]});case"shell-completions":return t.jsx(is,{before:{tag:"Without",items:["Memorize flags","Typos & retries"]},after:{tag:"With completions",items:["Tab to complete","Commands & options"]}});default:return null}}const _Q=Object.freeze(Object.defineProperty({__proto__:null,illustrationForTopic:xu},Symbol.toStringTag,{value:"Module"})),SL="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.",kL=[{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."}],NL=["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(`
|
|
48
|
-
`);function bw({onBack:e,onChatWithAI:n}){return t.jsx(du,{icon:t.jsx(Zr,{size:26}),title:"Use real data",crumbLabel:"Real data",meta:"Foundation · about 10 minutes",assistKey:"real-data",onBack:e,lead:SL,illustration:xu("real-data"),chatPrompt:NL,onChatWithAI:n,faqs:kL})}const SQ=Object.freeze(Object.defineProperty({__proto__:null,RealDataScreen:bw},Symbol.toStringTag,{value:"Module"})),Ko={entitySingular:"item",entityPlural:"items",savedThings:"saved items",purchaseNoun:"purchase"},CL=800;function yf(e){switch(e){case"ready":return"ready";case"error":return"error";case"connected":case"provisioning":return"provisioning";default:return"provisioning"}}function bu(e,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)},[]),p=l.useCallback(g=>{var b,y;const x=yf(g.status);x==="ready"?(u(),o({label:((b=g.result)==null?void 0:b.label)??"",value:((y=g.result)==null?void 0:y.value)??""}),r("ready")):x==="error"?(u(),c(g.message??"Connection failed."),r("error")):r("provisioning")},[u]),h=l.useCallback(async()=>{try{const g=await fetch(`/api/setup/connection-status?topic=${encodeURIComponent(e)}`);if(!g.ok)return;p(await g.json())}catch{}},[e,p]),f=l.useCallback(g=>{u(),c(null),o(null),r("connecting"),(async()=>{try{const b=await(await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:e,provider:n,credential:g})})).json().catch(()=>({}));p(b),yf(b.status)==="provisioning"&&(d.current=setInterval(()=>void h(),CL))}catch(x){u(),c(x instanceof Error?x.message:"Connection failed."),r("error")}})()},[e,n,p,h,u]),m=l.useCallback(()=>{u(),r("idle"),o(null),c(null)},[u]);return l.useEffect(()=>u,[u]),{stage:s,result:a,error:i,connect:f,reset:m}}const TL="accounts";function PL(e){switch(e){case"clerk":return"Clerk";case"supabase_auth":return"Supabase Auth";default:return e}}function yw({provider:e,app:n=Ko,startedOn:s="recently",onComplete:r}){const{stage:a,result:o,error:i,connect:c,reset:d}=bu(TL,e),[u,p]=l.useState(""),h=PL(e);return a==="ready"?t.jsxs(t.Fragment,{children:[o&&(o.label||o.value)&&t.jsxs("div",{className:"url-card",role:"status",children:[t.jsx("span",{className:"ucglobe",children:"✅"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:o.label||"Connected"}),t.jsx("div",{className:"uc-u",children:o.value})]})]}),t.jsx(Nu,{app:n,startedOn:s,onComplete:r})]}):a==="error"?t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"real-error",role:"alert",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"real-error-title",children:["Couldn’t connect ",h]}),t.jsx(mt,{variant:"icon",text:`Couldn’t connect ${h}: ${i}`})]}),t.jsx("div",{className:"real-error-msg",children:i})]}),t.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{p(""),d()},children:"Try again"})]}):a==="connecting"||a==="provisioning"?t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsxs("div",{className:"deploy-t",children:["Setting up ",h]}),t.jsx("div",{className:"deploy-d",children:a==="connecting"?`Connecting to ${h}…`:"Provisioning your sign-in keys…"})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{className:"dep-bar-indeterminate"})})]}):t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"ph",children:["Connect ",h]}),t.jsxs("div",{className:"psub",children:["Paste your ",h," 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."]}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("label",{className:"real-token-label",htmlFor:"accounts-secret-key",children:[h," secret key"]}),t.jsx("input",{id:"accounts-secret-key",type:"password",className:"real-token-input",placeholder:`Paste your ${h} secret key`,value:u,onChange:f=>p(f.target.value)}),t.jsxs("button",{type:"button",className:"auth-btn",disabled:u.trim().length===0,onClick:()=>c(u.trim()),children:["Connect ",h]})]}),t.jsx("div",{className:"reassure",children:"🔒 Your key is stored locally and never shown."})]})}const kQ=Object.freeze(Object.defineProperty({__proto__:null,AccountsRealConnect:yw},Symbol.toStringTag,{value:"Module"}));function un(e,n,s){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",children:s})}function zs({size:e=16}){return un(e,1.9,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 2 4 5v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V5z"}),t.jsx("path",{d:"m9 12 2 2 4-4"})]}))}function yu({size:e=16}){return un(e,2,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1.5 1.5"}),t.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1.5-1.5"})]}))}function vu({size:e=16}){return un(e,1.8,t.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}))}function ju({size:e=16}){return un(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("path",{d:"M3 9h18"})]}))}function OL({size:e=16}){return un(e,2,t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"M12 16v-4M12 8h.01"})]}))}function RL({size:e=16}){return un(e,2,t.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 EL({size:e=16}){return un(e,2,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 2 3 7v10l9 5 9-5V7z"}),t.jsx("path",{d:"M3 7l9 5 9-5M12 12v10"})]}))}function AL({size:e=16}){return un(e,2,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 7v5l3 2"}),t.jsx("circle",{cx:"12",cy:"12",r:"9"})]}))}function ML({size:e=13}){return un(e,2,t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"m15 9-6 6M9 9l6 6"})]}))}function fs({size:e=13}){return un(e,2.5,t.jsx("path",{d:"m5 12 5 5L20 6"}))}function vw({size:e=16}){return t.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:2,className:"rd-spin",children:[t.jsx("circle",{cx:"12",cy:"12",r:"9",strokeOpacity:".3"}),t.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",strokeLinecap:"round"})]})}const NQ=Object.freeze(Object.defineProperty({__proto__:null,ChatIcon:RL,CheckGlyph:fs,ClockIcon:AL,CubeIcon:EL,InfoCircleIcon:OL,LinkIcon:yu,ListLinesIcon:vu,ScreenIcon:ju,ShieldCheckIcon:zs,SpinnerIcon:vw,XCircleIcon:ML},Symbol.toStringTag,{value:"Module"})),IL={"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."}]},DL={"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."}]},LL={"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."}]},$L={"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."}]},FL={"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."}]},zL={"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."}]},BL={"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.`}]},WL={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."}]},HL={"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)."}]},qL={...IL,...DL,...LL,...$L,...FL,...zL,...BL,...WL,...HL};function jw(e){return qL[e]??[]}function UL({topicName:e,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 **${e}** — 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(`
|
|
49
|
-
`)}function Vn({assistKey:e,topicName:n,goalId:s,buttonLabel:r}){const a=jw(e).find(c=>c.id===s),[o,i]=l.useState(!1);return a?t.jsxs("div",{className:"setup-goal-assist mt-4",children:[t.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&&t.jsx("div",{className:"mt-3 rounded-md border border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:t.jsx(Ht,{chatName:`setup-${e}-${a.id}`,prompt:UL({topicName:n,goal:a}),height:360,onClose:()=>i(!1)})})]}):null}const CQ=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssist:Vn},Symbol.toStringTag,{value:"Module"}));function Ae({assistKey:e,topicName:n}){const s=jw(e);return s.length===0?null:t.jsx(t.Fragment,{children:s.map(r=>t.jsx(Vn,{assistKey:e,topicName:n,goalId:r.id,buttonLabel:`Ask AI to help: ${r.label}`},r.id))})}const TQ=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssistList:Ae},Symbol.toStringTag,{value:"Module"})),GL=1800;function Jo({config:e,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,GL))},u=e.connectColor==="green"?{"--connect":"var(--green)"}:void 0;return t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:e.badge}),t.jsxs("div",{children:[t.jsxs("h1",{className:"su-title",children:[e.title," ",t.jsx("span",{className:"su-chip notset",children:"Not set up"})]}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:e.providerName})]}),t.jsx("p",{className:"su-lead",children:e.lead})]})]}),t.jsxs("div",{className:"su-explain",children:[t.jsxs("div",{className:"su-eh",children:[t.jsx("span",{className:"su-q",children:"?"}),e.explainerHeading]}),t.jsx("div",{className:"su-lede",children:e.lede}),t.jsx("div",{className:"su-erows",children:e.explainerRows.map(p=>t.jsxs("div",{className:"su-erow",children:[t.jsx("div",{className:"su-en",children:p.icon}),t.jsxs("div",{className:"su-et",children:[t.jsx("b",{children:p.title}),t.jsx("span",{children:p.desc})]})]},p.title))}),t.jsxs("div",{className:"su-why",children:[t.jsxs("div",{className:"su-wh",children:[t.jsx(zs,{size:15}),e.whyHeading]}),e.whyRows.map(p=>t.jsxs("div",{className:"su-whyrow",children:[t.jsx("span",{className:"su-wc",children:t.jsx(fs,{size:11})}),t.jsxs("p",{children:[t.jsx("b",{children:p.lead})," ",p.rest]})]},p.lead))]})]}),t.jsxs("div",{className:"su-connect",style:u,children:[t.jsx("div",{className:"su-ct",children:e.connectTitle}),t.jsx("div",{className:"su-cd",children:e.connectDesc}),t.jsx("button",{type:"button",className:"su-cbtn",onClick:d,disabled:s,children:s?t.jsxs(t.Fragment,{children:[t.jsx(vw,{size:16}),"Opening ",e.providerName,"…"]}):t.jsxs(t.Fragment,{children:[t.jsx(yu,{size:16}),e.connectButtonLabel]})}),t.jsx("div",{className:"su-reassure",children:e.reassure.map(p=>t.jsxs("span",{children:[t.jsx(fs,{size:13}),p]},p))})]}),e.alternatives&&e.alternatives.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:"su-alt-toggle",onClick:()=>o(p=>!p),children:[a?"Hide other options":e.altToggleLabel," ",t.jsx("span",{className:"su-chev"+(a?" open":""),children:"⌄"})]}),a?t.jsx("div",{className:"su-alts",children:e.alternatives.map(p=>t.jsxs("div",{className:"su-altrow",children:[t.jsx("div",{className:"su-altmark",style:{background:p.color},children:p.monogram}),t.jsxs("div",{className:"su-altbody",children:[t.jsx("div",{className:"su-altname",children:p.name}),t.jsx("div",{className:"su-altdesc",children:p.desc}),p.factKey?t.jsxs("div",{className:"su-altfact",children:[Ee(p.factKey).value,t.jsx(Xn,{fact:Ee(p.factKey)})]}):null]}),t.jsx("button",{type:"button",className:"su-altpick"+(i===p.name?" picked":""),onClick:()=>c(p.name),children:i===p.name?"Selected ✓":"Use this"})]},p.name))}):null]}):null,t.jsx("div",{className:"su-uplabel",children:e.lockedLabel}),t.jsx("div",{className:"su-locked",children:e.lockedSteps.map(p=>t.jsxs("div",{className:"su-lrow",children:[t.jsx("div",{className:"su-ln",children:p.icon}),t.jsxs("div",{className:"su-lt",children:[t.jsx("b",{children:p.title}),t.jsx("span",{children:p.desc})]}),t.jsx("span",{className:"su-lk",children:t.jsx(ot,{size:15})})]},p.title))}),e.faq&&e.faq.length>0?t.jsx(Nt,{items:e.faq}):null,e.assistKey?t.jsx(Ae,{assistKey:e.assistKey,topicName:e.title}):null]})}const PQ=Object.freeze(Object.defineProperty({__proto__:null,SetupNotConnected:Jo},Symbol.toStringTag,{value:"Module"}));function Xo({children:e}){return t.jsx("div",{className:"su-steps",children:e})}function ln({state:e,num:n,title:s,pill:r,desc:a,children:o}){return t.jsxs("div",{className:"su-step",children:[t.jsxs("div",{className:"su-rail",children:[t.jsx("div",{className:"su-node "+e,children:e==="done"?t.jsx(fs,{size:15}):n}),t.jsx("div",{className:"su-line"})]}),t.jsxs("div",{className:"su-scon",children:[t.jsxs("div",{className:"su-stitle",children:[s,r?t.jsx("span",{className:"su-pill",children:r}):null]}),t.jsx("div",{className:"su-sdesc",children:a}),o]})]})}function wu({monogram:e,name:n,detail:s,monogramStyle:r}){return t.jsxs("div",{className:"su-acct",children:[t.jsx("div",{className:"su-av",style:r,children:e}),t.jsxs("div",{className:"su-ainfo",children:[t.jsx("b",{children:n}),t.jsx("span",{children:s})]}),t.jsx("button",{type:"button",className:"su-chg",children:"Change"})]})}function ww({methods:e,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 t.jsx("div",{className:"su-methods",children:e.map(o=>t.jsxs("button",{type:"button",className:"su-mchip"+(s.has(o.key)?" on":""),onClick:()=>a(o.key),"aria-pressed":s.has(o.key),children:[t.jsx("span",{className:"su-ck",children:t.jsx(fs,{size:11})}),o.icon,o.label]},o.key))})}function Qo({children:e}){return t.jsxs("div",{className:"su-field",children:[t.jsx("span",{className:"su-edit",children:"Edit"}),e]})}function _w({examples:e}){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 t.jsx("div",{className:"su-examples",children:e.map((a,o)=>t.jsxs("button",{type:"button",className:"su-ex"+(n.has(o)?" added":""),onClick:()=>r(o),children:[t.jsx("span",{className:"su-plus",children:n.has(o)?"✓":"+"}),a]},a))})}function Zo({items:e}){return t.jsx("div",{className:"su-builds",children:e.map(n=>t.jsxs("div",{className:"su-bitem",children:[t.jsx("div",{className:"su-bx",children:t.jsx(fs,{size:13})}),t.jsxs("div",{className:"su-bmain",children:[t.jsx("b",{children:n.title}),t.jsx("span",{children:n.caption})]}),t.jsx("span",{className:"su-where",children:n.where})]},n.title))})}function ei({accent:e,icon:n,children:s}){const r={"--note-accent":e==="amber"?"var(--amber)":"var(--blue)"};return t.jsxs("div",{className:"su-note",style:r,children:[n,t.jsx("p",{children:s})]})}function ti({label:e,note:n,onPlan:s}){const[r,a]=l.useState(!1),o=()=>{r||(a(!0),s==null||s())};return t.jsxs("div",{className:"su-foot",children:[t.jsx("button",{type:"button",className:"su-cta",onClick:o,disabled:r,children:r?"Added to your plans ✓":t.jsxs(t.Fragment,{children:[e," ",t.jsx("span",{className:"su-ar",children:"→"})]})}),t.jsx("div",{className:"su-fnote",children:n})]})}const OQ=Object.freeze(Object.defineProperty({__proto__:null,BuildList:Zo,ControlNote:ei,EditableField:Qo,ExampleChips:_w,MethodChips:ww,SetupAccountRow:wu,SetupPlanFooter:ti,SetupStep:ln,SetupStepper:Xo},Symbol.toStringTag,{value:"Module"}));function Vs(e,n,s){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",children:s})}function lo({size:e=16}){return Vs(e,1.7,t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),t.jsx("path",{d:"M5 20a7 7 0 0 1 14 0"})]}))}function Sw({size:e=16}){return Vs(e,1.8,t.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"}))}function _u({size:e=16}){return Vs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M22 2 11 13"}),t.jsx("path",{d:"M22 2 15 22l-4-9-9-4z"})]}))}function kw({size:e=16}){return Vs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 9v4M12 17h.01"}),t.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 Vl({size:e=16}){return Vs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"m22 7-10 6L2 7"}),t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"})]}))}function Nw({size:e=16}){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"currentColor",children:t.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 Cw({size:e=16}){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"currentColor",children:t.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 Tw({size:e=16}){return Vs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 3 3 8l9 5 9-5-9-5z"}),t.jsx("path",{d:"M3 8v5l9 5 9-5V8"})]}))}const RQ=Object.freeze(Object.defineProperty({__proto__:null,AppleGlyph:Cw,ArrowRightIcon:Sw,GoogleGlyph:Nw,GraduationIcon:Tw,MagicLinkIcon:Vl,PaperPlaneIcon:_u,PersonIcon:lo,WarningTriangleIcon:kw},Symbol.toStringTag,{value:"Module"})),YL=[1e3,2e3,4e3,8e3];async function Su(e,n,s=YL){for(let r=0;;r++){try{const a=await(n?fetch(e,n):fetch(e));if(!(a.status>=500)||r>=s.length)return a}catch(a){if(r>=s.length)throw a}await new Promise(a=>setTimeout(a,s[r]))}}function ku(){const[e,n]=l.useState(null),s=l.useCallback(async()=>{try{const a=await Su("/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:e,dismiss:r,refetch:s}}function ni({topic:e}){const{services:n}=ku();if(!n)return null;const s=n.find(a=>a.topic===e&&a.status!=="dismissed");if(!s)return null;const r=s.evidence.map(a=>a.value).join(", ");return t.jsxs("div",{className:"wired-provider",role:"note",children:[t.jsxs("div",{className:"wired-provider-title",children:[t.jsx("b",{children:s.name})," is already wired in this project"]}),t.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 EQ=Object.freeze(Object.defineProperty({__proto__:null,WiredProviderBanner:ni},Symbol.toStringTag,{value:"Module"}));function VL(e){return{accent:"blue",assistKey:"accounts",badge:t.jsx(lo,{size:25}),title:"Let people sign in",providerName:"Supabase",connectColor:"lime",lead:`Right now everyone using your app is anonymous, so a ${e.entitySingular} they save vanishes the moment they close the tab. Give people their own account and their ${e.savedThings} and settings follow them on any device. CodeYam uses Supabase.`,explainerHeading:"New to accounts? Here's the short version",lede:t.jsxs(t.Fragment,{children:[t.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"," ",e.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:t.jsx(lo,{size:16}),title:"Everything stays tied to them",desc:t.jsxs(t.Fragment,{children:["Their ",e.savedThings," and profile are remembered"," ",t.jsx("em",{children:"even after they close the app"}),", instead of resetting."]})},{icon:t.jsx(Sw,{size:16}),title:"It follows them across devices",desc:t.jsxs(t.Fragment,{children:["Sign in on a phone, see the same ",e.savedThings," on a laptop,"," ",t.jsx("em",{children:"anywhere they sign in"}),"."]})},{icon:t.jsx(ot,{size:16}),title:"It keeps private things private",desc:t.jsxs(t.Fragment,{children:["Accounts let you say ",t.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:t.jsx(vu,{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 ${e.entitySingular}."`},{icon:t.jsx(ju,{size:15}),title:"CodeYam builds your sign-in screens",desc:`A sign-in screen, a "sign in to save" prompt, per-person ${e.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 (${Ee("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 KL=[{key:"google",label:"Google",icon:t.jsx(Nw,{size:15})},{key:"apple",label:"Apple",icon:t.jsx(Cw,{size:15})},{key:"email",label:"Email",icon:t.jsx(Vl,{size:15})},{key:"magic",label:"Magic link",icon:t.jsx(Vl,{size:15})}];function Nu({app:e,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:`/${e.entitySingular}`},{title:`Each person's own ${e.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 t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:t.jsx(lo,{size:25})}),t.jsxs("div",{children:[t.jsx("h1",{className:"su-title",children:"Let people sign in"}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:"Supabase"})," · the sign-in tech behind modern apps"]}),t.jsxs("p",{className:"su-lead",children:["Give people their own account so their ",e.savedThings," and settings follow them on any device. CodeYam builds the screens and handles the security, you just decide who gets in."]})]})]}),t.jsxs("div",{className:"su-remember",children:[t.jsx("span",{className:"su-rdot"}),t.jsxs("div",{className:"su-widget-body",children:[t.jsxs("b",{children:["You started this on ",n,"."]}),t.jsx("span",{children:"Sign-in methods are chosen — one step left before you can plan it."})]}),t.jsx("span",{className:"su-ago",children:"resumed today"})]}),t.jsxs("div",{className:"su-learn",children:[t.jsxs("div",{className:"su-lhd",children:[t.jsx(Tw,{size:15}),'What "accounts" actually means']}),t.jsxs("p",{children:["Right now everyone using your app is ",t.jsx("b",{children:"anonymous"})," — nothing they do is tied to them, so a saved ",e.entitySingular," disappears when they close the tab."]}),t.jsxs("p",{children:["Accounts give each person a ",t.jsx("b",{children:"private space"}),": their own"," ",e.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.`]})]}),t.jsx("div",{className:"su-seclabel",children:"Set it up"}),t.jsxs(Xo,{children:[t.jsx(ln,{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:t.jsx(ww,{methods:KL,initialSelected:["google","apple","email"]})}),t.jsx(ln,{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:t.jsxs(Qo,{children:["Let people ",t.jsx("b",{children:"browse freely"})," without an account. Only ask them to sign in when they ",t.jsxs("b",{children:["save an ",e.entitySingular]})," or"," ",t.jsxs("b",{children:["buy a ",e.purchaseNoun]}),"."]})}),t.jsx(ln,{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:t.jsx(Zo,{items:r})})]}),t.jsxs(ei,{accent:"blue",icon:t.jsx(ot,{size:17}),children:[t.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."]}),t.jsx(ti,{label:"Plan these 4 changes",note:t.jsxs(t.Fragment,{children:["They'll land in your ",t.jsx("b",{children:"Plan"})," tab, ready to build after your current session."]}),onPlan:s})]})}function Pw({onBack:e,onComplete:n,app:s=Ko,initialConnected:r=!1,startedOn:a="recently",connector:o}){const[i,c]=l.useState(r),d=!!o&&!i;return t.jsxs("div",{className:"setup-screen accent-blue",children:[t.jsxs("div",{className:"su-crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"/"}),t.jsx("b",{children:"Accounts & sign-in"})]}),t.jsx(ni,{topic:"accounts"}),i?t.jsx(Nu,{app:s,startedOn:a,onComplete:n}):d?t.jsx(yw,{provider:o.provider,app:s,startedOn:a,onComplete:n}):t.jsx(Jo,{config:VL(s),onConnect:()=>c(!0)})]})}const AQ=Object.freeze(Object.defineProperty({__proto__:null,AccountsConnected:Nu,AccountsScreen:Pw},Symbol.toStringTag,{value:"Module"})),JL="hello@your-app.com",XL={monogram:"R",name:"Your app",detail:"you@your-app.com · re_live_…"};function QL(e){return{accent:"amber",assistKey:"emails",badge:t.jsx(Ys,{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:t.jsxs(t.Fragment,{children:[t.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:t.jsx(_u,{size:16}),title:"It sends reliably",desc:t.jsxs(t.Fragment,{children:["Receipts, password resets, and welcome notes go out"," ",t.jsx("em",{children:"the instant your app asks"}),", from your own address."]})},{icon:t.jsx(zs,{size:16}),title:"It stays out of spam",desc:t.jsxs(t.Fragment,{children:["Resend handles the technical reputation work behind the scenes, so your emails ",t.jsx("em",{children:"actually arrive"})," instead of vanishing."]})},{icon:t.jsx(Xt,{size:16}),title:"It shows you what happened",desc:t.jsxs(t.Fragment,{children:["See what was sent, delivered, or opened ",t.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 ${Ee("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:t.jsx(zs,{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:t.jsx(vu,{size:15}),title:"Tell us which emails to send",desc:`Plain language, like "a receipt after each ${e.purchaseNoun}, and a welcome note on sign-up."`},{icon:t.jsx(ju,{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 Ow({app:e,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 & ${e.purchaseNoun} email`,caption:`With the ${e.entitySingular} details and a ${e.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 t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:t.jsx(Ys,{size:25})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"su-title",children:["Send emails from your app"," ",t.jsxs("span",{className:"su-chip connected",children:[t.jsx(fs,{size:11}),"Connected"]})]}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:"Resend"})]}),t.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."})]})]}),t.jsxs("div",{className:"su-statusbar",children:[t.jsx("div",{className:"su-widget-ic",children:t.jsx(zs,{size:16})}),t.jsxs("div",{className:"su-widget-body",children:[t.jsx("b",{children:"Your sending address is verified"}),t.jsxs("span",{children:["Emails go out from ",t.jsx("code",{children:n}),", so they look like you, not a robot."]})]}),t.jsx("button",{type:"button",className:"su-chg",children:"Manage"})]}),t.jsxs(Xo,{children:[t.jsx(ln,{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:t.jsx(wu,{monogram:s.monogram,name:s.name,detail:s.detail,monogramStyle:{background:"#ffd400",color:"#1a1a1a"}})}),t.jsxs(ln,{state:"done",num:2,title:"Which emails should your app send?",desc:"Plain language is fine — this is what shapes the emails below.",children:[t.jsxs(Qo,{children:["A ",t.jsx("b",{children:"welcome note"})," when someone signs up, a"," ",t.jsxs("b",{children:["receipt with their ",e.purchaseNoun]})," after a purchase, and a"," ",t.jsx("b",{children:"password reset link"})," when they ask for one."]}),t.jsx(_w,{examples:[`A reminder the day before an ${e.entitySingular}`,`A note when an ${e.entitySingular} is cancelled`,`A monthly "what's on" roundup`]})]}),t.jsx(ln,{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:t.jsx(Zo,{items:a})})]}),t.jsxs(ei,{accent:"amber",icon:t.jsx(_u,{size:17}),children:[t.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."]}),t.jsx(ti,{label:"Plan these 4 emails",note:t.jsxs(t.Fragment,{children:["They'll land in your ",t.jsx("b",{children:"Plan"})," tab, previewable before anything sends, and easy to reword anytime."]}),onPlan:r})]})}function Rw({onBack:e,onComplete:n,app:s=Ko,initialConnected:r=!1,verifiedAddress:a=JL,account:o=XL}){const[i,c]=l.useState(r);return t.jsxs("div",{className:"setup-screen accent-amber",children:[t.jsxs("div",{className:"su-crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"/"}),t.jsx("b",{children:"Sending emails"})]}),t.jsx(ni,{topic:"emails"}),i?t.jsx(Ow,{app:s,verifiedAddress:a,account:o,onComplete:n}):t.jsx(Jo,{config:QL(s),onConnect:()=>c(!0)})]})}const MQ=Object.freeze(Object.defineProperty({__proto__:null,EmailsConnected:Ow,EmailsScreen:Rw},Symbol.toStringTag,{value:"Module"}));function ka(e){return[{key:"connect",label:e.flowLabels[0]},{key:"provision",label:e.flowLabels[1]},{key:"ready",label:e.flowLabels[2]}]}function Cu({config:e,provider:n,onBack:s,onComplete:r,onRevert:a}){const{stage:o,result:i,error:c,connect:d,reset:u}=bu(e.key,n),[p,h]=l.useState("");return o==="idle"?t.jsxs(t.Fragment,{children:[t.jsx(qn,{topic:e.crumbLabel??e.title,step:e.flowLabels[0],onBack:s}),t.jsx(wn,{steps:ka(e),currentKey:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsx("div",{className:"ph",children:e.connect.heading}),t.jsx("div",{className:"psub",children:e.connect.sub}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("div",{className:"cbtitle",children:[t.jsx(Yo,{initial:e.recommended.initial,color:e.recommended.color}),t.jsxs("div",{children:[t.jsxs("div",{className:"cbt",children:["Connect ",e.recommended.name]}),t.jsxs("div",{className:"cbd",children:["Paste a ",e.recommended.name," API token to connect your real account."]})]})]}),t.jsx("label",{className:"real-token-label",htmlFor:"real-token",children:"API token"}),t.jsx("input",{id:"real-token",type:"password",className:"real-token-input",placeholder:`Paste your ${e.recommended.name} token`,value:p,onChange:f=>h(f.target.value)}),t.jsx("button",{type:"button",className:"auth-btn",disabled:p.trim().length===0,onClick:()=>d(p.trim()),children:e.connect.continueLabel})]}),t.jsxs("div",{className:"reassure",children:["🔒 ",e.connect.reassure]})]})]}):o==="error"?t.jsxs(t.Fragment,{children:[t.jsx(qn,{topic:e.crumbLabel??e.title,step:e.flowLabels[0],onBack:s}),t.jsx(wn,{steps:ka(e),currentKey:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"real-error",role:"alert",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("div",{className:"real-error-title",children:"Couldn’t connect"}),t.jsx(mt,{variant:"icon",text:`Couldn’t connect: ${c}`})]}),t.jsx("div",{className:"real-error-msg",children:c})]}),t.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{h(""),u()},children:"Try again"})]})]}):o==="ready"?t.jsxs(t.Fragment,{children:[t.jsx(qn,{topic:e.crumbLabel??e.title,step:e.flowLabels[2]}),t.jsx(wn,{steps:ka(e),currentKey:"ready"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"live-hero",children:[t.jsx("div",{className:"lh-em",children:"🎉"}),t.jsx("div",{className:"lh-t",children:e.ready.title}),t.jsx("div",{className:"lh-d",children:e.ready.desc})]}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"✅"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:(i==null?void 0:i.label)||e.ready.resultLabel}),t.jsx("div",{className:"uc-u",children:(i==null?void 0:i.value)||e.ready.resultValue})]})]}),t.jsxs("div",{className:"live-foot",children:[t.jsxs("span",{className:"done-pill",children:[t.jsx(ft,{})," ",e.ready.donePill]}),t.jsx("button",{type:"button",className:"lf-back",onClick:()=>r==null?void 0:r(),children:"Back to Setup"}),a?t.jsx("button",{type:"button",className:"lf-revert",onClick:a,children:"Mark as not complete"}):null]})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(qn,{topic:e.crumbLabel??e.title,step:e.flowLabels[1]}),t.jsx(wn,{steps:ka(e),currentKey:"provision"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:e.provisionTitle}),t.jsx("div",{className:"deploy-d",children:o==="connecting"?`Connecting to ${e.recommended.name}…`:e.provisionDesc})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const IQ=Object.freeze(Object.defineProperty({__proto__:null,RealSetupFlow:Cu},Symbol.toStringTag,{value:"Module"})),ZL={monogram:"AC",name:"Your app",detail:"you@your-app.com · acct_…"};function e4(e){return{accent:"indigo",assistKey:"payments",badge:t.jsx(kn,{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:t.jsxs(t.Fragment,{children:[t.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:t.jsx(ot,{size:16}),title:"It takes the payment safely",desc:t.jsxs(t.Fragment,{children:["The buyer types their card into ",t.jsx("em",{children:"Stripe's"})," secure screen, not yours. Sensitive numbers never sit in your app."]})},{icon:t.jsx(kn,{size:16}),title:"It charges the card",desc:t.jsxs(t.Fragment,{children:["Stripe talks to the banks and approves the payment in"," ",t.jsx("em",{children:"a few seconds"}),", then tells your app it went through."]})},{icon:t.jsx(Xt,{size:16}),title:"It pays you",desc:t.jsxs(t.Fragment,{children:["The money lands in ",t.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 (${Ee("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:t.jsx(zs,{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:t.jsx(yu,{size:15}),title:"Tell us what you're selling",desc:`A sentence in plain language, like "${e.entitySingular} ${e.purchaseNoun}s, $10 to $45."`},{icon:t.jsx(kn,{size:15}),title:"CodeYam builds your checkout",desc:`A "Get ${e.purchaseNoun}s" button, a payment screen, and an emailed receipt — each one a plan you preview before it ships.`}]}}function t4(e){return{key:"payments",connector:{provider:"stripe"},Icon:kn,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 ${e.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 Ew(){const[e,n]=l.useState("test");return t.jsxs("div",{className:"su-modebar",children:[t.jsx("div",{className:"su-widget-ic",children:t.jsx(kw,{size:16})}),t.jsxs("div",{className:"su-widget-body",children:[t.jsx("b",{children:e==="test"?"You're in test mode":"You're live"}),t.jsx("span",{children:e==="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."})]}),t.jsxs("div",{className:"su-seg",children:[t.jsx("button",{type:"button",className:e==="test"?"on":"",onClick:()=>n("test"),children:"Test"}),t.jsx("button",{type:"button",className:"live"+(e==="live"?" on":""),onClick:()=>n("live"),children:"Live"})]})]})}function Aw({app:e,account:n,onComplete:s}){const r=[{title:`A "Get ${e.purchaseNoun}s" button`,caption:`Added to each ${e.entitySingular} so people can buy in one tap.`,where:`/${e.entitySingular}`},{title:"A checkout screen",caption:"Card payment, Apple Pay, and Google Pay, hosted by Stripe.",where:"/checkout"},{title:`An emailed receipt & ${e.purchaseNoun}`,caption:`Stripe sends the card payment receipt automatically; CodeYam adds your own branded confirmation with the ${e.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 t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:t.jsx(kn,{size:25})}),t.jsxs("div",{children:[t.jsx("h1",{className:"su-title",children:"Accept payments"}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:"Stripe"})," · the payments tech behind millions of apps"]}),t.jsxs("p",{className:"su-lead",children:["Let people pay inside your app — buy a ",e.purchaseNoun,", leave a tip, subscribe. CodeYam handles the wiring; you just describe what you're selling and preview every screen before it goes live."]})]})]}),t.jsx(Ew,{}),t.jsxs(Xo,{children:[t.jsx(ln,{state:"done",num:1,title:"Connect your Stripe account",pill:"Connected",desc:"CodeYam never sees your customers' card numbers — Stripe handles that part.",children:t.jsx(wu,{monogram:n.monogram,name:n.name,detail:n.detail})}),t.jsx(ln,{state:"done",num:2,title:"What are you selling?",desc:"Plain language is fine — this is what shapes the screens below.",children:t.jsxs(Qo,{children:[e.entitySingular," ",e.purchaseNoun,"s, one-off purchases from"," ",t.jsx("b",{children:"$10 to $45"}),". Buyers get a ",e.purchaseNoun," by email."]})}),t.jsx(ln,{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:t.jsx(Zo,{items:r})})]}),t.jsxs(ei,{accent:"amber",icon:t.jsx(ot,{size:17}),children:[t.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."]}),t.jsx(ti,{label:"Plan these 4 changes",note:t.jsxs(t.Fragment,{children:["They'll land in your ",t.jsx("b",{children:"Plan"})," tab, ready to build after your current session, and previewable before anything ships."]}),onPlan:s})]})}function Mw({onBack:e,onComplete:n,onRevert:s,app:r=Ko,initialConnected:a=!1,account:o=ZL,connector:i}){const[c,d]=l.useState(a);let u;return i&&c?u=t.jsx(Cu,{config:t4(r),provider:i.provider,onBack:()=>d(!1),onComplete:n,onRevert:s}):c?u=t.jsx(Aw,{app:r,account:o,onComplete:n}):u=t.jsx(Jo,{config:e4(r),onConnect:()=>d(!0)}),t.jsxs("div",{className:"setup-screen accent-indigo",children:[t.jsxs("div",{className:"su-crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"/"}),t.jsx("b",{children:"Payments"})]}),t.jsx(ni,{topic:"payments"}),u]})}const DQ=Object.freeze(Object.defineProperty({__proto__:null,ModeBar:Ew,PaymentsConnected:Aw,PaymentsScreen:Mw},Symbol.toStringTag,{value:"Module"}));function Rt({config:e,onBack:n,onComplete:s,status:r,onRevert:a}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(e.Icon,{size:26}),title:e.title,crumbLabel:e.crumbLabel,meta:e.meta,onBack:n,assistKey:e.key}),e.leads.map(o=>t.jsx("p",{className:"lead"+(o.dim?" dim":""),children:o.text},o.text)),e.sections.map(o=>t.jsxs("div",{children:[t.jsx("div",{className:"seclabel",children:o.heading}),o.body?t.jsx("p",{className:"lead dim",children:o.body}):null,o.bullets?t.jsx("div",{className:"reasons",children:o.bullets.map(i=>t.jsxs("div",{className:"reason",children:[t.jsx(ft,{}),t.jsxs("span",{children:[i.lead?t.jsxs("b",{children:[i.lead," "]}):null,i.text]})]},i.text))}):null]},o.heading)),e.options&&e.options.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",children:e.optionsLabel??"Your options"}),e.options.map(o=>t.jsx(cu,{provider:o},o.name))]}):null,t.jsx(Nt,{items:e.faq}),t.jsx(Ae,{assistKey:e.key,topicName:e.title}),t.jsx(Ie,{label:e.doneLabel,note:e.doneNote??"You can revisit this anytime.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const LQ=Object.freeze(Object.defineProperty({__proto__:null,TeachSetupScreen:Rt},Symbol.toStringTag,{value:"Module"})),n4={key:"analytics-monitoring",Icon:Xt,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 Iw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:n4,onBack:e,onComplete:n,status:s,onRevert:r})}const $Q=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsMonitoringScreen:Iw},Symbol.toStringTag,{value:"Module"})),s4={key:"legal",Icon:nt,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 Dw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:s4,onBack:e,onComplete:n,status:s,onRevert:r})}const FQ=Object.freeze(Object.defineProperty({__proto__:null,LegalScreen:Dw},Symbol.toStringTag,{value:"Module"}));function Lw({config:e,onBack:n,onSetup:s}){return t.jsxs(t.Fragment,{children:[t.jsx(Pe,{icon:t.jsx(e.Icon,{size:26}),title:e.title,crumbLabel:e.crumbLabel,meta:e.meta,onBack:n,assistKey:e.key}),e.leads.map(r=>t.jsx("p",{className:"lead"+(r.dim?" dim":""),children:r.text},r.text)),t.jsx("div",{className:"seclabel",children:e.recommendLabel}),t.jsx(cu,{provider:e.recommended}),t.jsx(Oj,{alts:e.alternatives}),t.jsxs("div",{className:"cta-wrap",children:[t.jsx("button",{type:"button",className:"cta",onClick:s,children:e.ctaLabel}),t.jsx("div",{className:"cta-note",children:e.ctaNote})]}),t.jsx(Nt,{items:e.faq}),t.jsx(Ae,{assistKey:e.key,topicName:e.title})]})}const zQ=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupOverview:Lw},Symbol.toStringTag,{value:"Module"})),vf=1100,r4=700;function Tu(e){return[{key:"connect",label:e.flowLabels[0]},{key:"provision",label:e.flowLabels[1]},{key:"ready",label:e.flowLabels[2]}]}function $w({config:e,onBack:n,onContinue:s}){return t.jsxs(t.Fragment,{children:[t.jsx(qn,{topic:e.crumbLabel??e.title,step:e.flowLabels[0],onBack:n}),t.jsx(wn,{steps:Tu(e),currentKey:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsx("div",{className:"ph",children:e.connect.heading}),t.jsx("div",{className:"psub",children:e.connect.sub}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("div",{className:"cbtitle",children:[t.jsx(Yo,{initial:e.recommended.initial,color:e.recommended.color}),t.jsxs("div",{children:[t.jsxs("div",{className:"cbt",children:["Sign in with ",e.recommended.name]}),t.jsxs("div",{className:"cbd",children:["We'll open ",e.recommended.name," in a new tab and bring you right back."]})]})]}),t.jsx("div",{className:"grant",children:e.connect.grants.map(r=>t.jsxs("div",{className:"grantrow",children:[t.jsx(ft,{color:"var(--blue-300)"}),t.jsx("span",{children:r})]},r))}),t.jsx("button",{type:"button",className:"auth-btn",onClick:s,children:e.connect.continueLabel}),t.jsxs("div",{className:"auth-row",children:[t.jsx("button",{type:"button",className:"auth-ghost",onClick:s,children:"I already have an account"}),t.jsx("button",{type:"button",className:"auth-ghost",onClick:s,children:"Create one for me"})]})]}),t.jsxs("div",{className:"reassure",children:["🔒 ",e.connect.reassure]})]})]})}function Fw({config:e,onDone:n}){const s=e.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*vf));return c.push(setTimeout(()=>o.current(),s.length*vf+r4)),()=>c.forEach(clearTimeout)},[s.length]);const i=Math.round(r/s.length*100);return t.jsxs(t.Fragment,{children:[t.jsx(qn,{topic:e.crumbLabel??e.title,step:e.flowLabels[1]}),t.jsx(wn,{steps:Tu(e),currentKey:"provision"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:e.provisionTitle}),t.jsx("div",{className:"deploy-d",children:e.provisionDesc})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{style:{width:i+"%"}})}),t.jsx("div",{className:"dep-steps",children:s.map((c,d)=>t.jsxs("div",{className:"dep-step "+(d<r?"done":d===r?"active":"todo"),children:[t.jsx("div",{className:"dot",children:d<r?t.jsx(ft,{size:12,color:"#0a0a0a"}):null}),t.jsx("div",{className:"sl",children:c})]},c))})]})]})}function zw({config:e,onFinish:n,onRevert:s}){return t.jsxs(t.Fragment,{children:[t.jsx(qn,{topic:e.crumbLabel??e.title,step:e.flowLabels[2]}),t.jsx(wn,{steps:Tu(e),currentKey:"ready"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"live-hero",children:[t.jsx("div",{className:"lh-em",children:"🎉"}),t.jsx("div",{className:"lh-t",children:e.ready.title}),t.jsx("div",{className:"lh-d",children:e.ready.desc})]}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"✅"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:e.ready.resultLabel}),t.jsx("div",{className:"uc-u",children:e.ready.resultValue})]})]}),t.jsxs("div",{className:"live-foot",children:[t.jsxs("span",{className:"done-pill",children:[t.jsx(ft,{})," ",e.ready.donePill]}),t.jsx("button",{type:"button",className:"lf-back",onClick:n,children:"Back to Setup"}),s?t.jsx("button",{type:"button",className:"lf-revert",onClick:s,children:"Mark as not complete"}):null]})]})]})}const BQ=Object.freeze(Object.defineProperty({__proto__:null,SimulatedConnect:$w,SimulatedProvision:Fw,SimulatedReady:zw},Symbol.toStringTag,{value:"Module"}));function ea({config:e,onBack:n,onComplete:s,onRevert:r}){const[a,o]=l.useState("overview");let i;return a==="overview"?i=t.jsx(Lw,{config:e,onBack:n,onSetup:()=>o("connect")}):e.connector?i=t.jsx(Cu,{config:e,provider:e.connector.provider,onBack:()=>o("overview"),onComplete:()=>{s==null||s(),n()},onRevert:r?()=>{r(),n()}:void 0}):a==="connect"?i=t.jsx($w,{config:e,onBack:()=>o("overview"),onContinue:()=>o("provision")}):a==="provision"?i=t.jsx(Fw,{config:e,onDone:()=>o("ready")}):i=t.jsx(zw,{config:e,onFinish:()=>{s==null||s(),n()},onRevert:r?()=>{r(),n()}:void 0}),t.jsx("div",{className:"hosting-screen",children:i})}const WQ=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupScreen:ea},Symbol.toStringTag,{value:"Module"})),a4={key:"publish",Icon:hs,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:`${Ee("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. ${Ee("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: ${Ee("cloudflarePages.free").value.toLowerCase()}, so traffic spikes won't cost you. Netlify's free tier: ${Ee("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 Bw({onBack:e,onComplete:n,onRevert:s}){return t.jsx(ea,{config:a4,onBack:e,onComplete:n,onRevert:s})}const HQ=Object.freeze(Object.defineProperty({__proto__:null,PublishScreen:Bw},Symbol.toStringTag,{value:"Module"})),o4={key:"custom-domain",Icon:Yn,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 Ww({onBack:e,onComplete:n,onRevert:s}){return t.jsx(ea,{config:o4,onBack:e,onComplete:n,onRevert:s})}const qQ=Object.freeze(Object.defineProperty({__proto__:null,CustomDomainScreen:Ww},Symbol.toStringTag,{value:"Module"})),i4={key:"data-safety",Icon:Zr,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 Hw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:i4,onBack:e,onComplete:n,status:s,onRevert:r})}const UQ=Object.freeze(Object.defineProperty({__proto__:null,DataSafetyScreen:Hw},Symbol.toStringTag,{value:"Module"})),l4={key:"forms",Icon:Ys,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 ${Ee("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 qw({onBack:e,onComplete:n,onRevert:s}){return t.jsx(ea,{config:l4,onBack:e,onComplete:n,onRevert:s})}const GQ=Object.freeze(Object.defineProperty({__proto__:null,FormsScreen:qw},Symbol.toStringTag,{value:"Module"})),c4={key:"analytics-seo",Icon:Xt,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 Uw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:c4,onBack:e,onComplete:n,status:s,onRevert:r})}const YQ=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsSeoScreen:Uw},Symbol.toStringTag,{value:"Module"})),d4={key:"redirects-404",Icon:Yn,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 Gw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:d4,onBack:e,onComplete:n,status:s,onRevert:r})}const VQ=Object.freeze(Object.defineProperty({__proto__:null,RedirectsNotFoundScreen:Gw},Symbol.toStringTag,{value:"Module"})),u4={key:"performance-images",Icon:pt,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 Yw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:u4,onBack:e,onComplete:n,status:s,onRevert:r})}const KQ=Object.freeze(Object.defineProperty({__proto__:null,PerformanceImagesScreen:Yw},Symbol.toStringTag,{value:"Module"})),p4={key:"comments-search",Icon:nt,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 Vw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:p4,onBack:e,onComplete:n,status:s,onRevert:r})}const JQ=Object.freeze(Object.defineProperty({__proto__:null,CommentsSearchScreen:Vw},Symbol.toStringTag,{value:"Module"})),Os={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."}},h4=[Os.crates,Os.npm,Os.pypi,Os.rubygems,Os.homebrew];function Kw(e){return Os[e]}function Jw({registry:e,onBack:n,onComplete:s,status:r,onRevert:a}){const o=e?Kw(e):null;return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(It,{size:26}),title:"Publish to a registry",meta:"Foundation · about 20 minutes",onBack:n,assistKey:"publish-registry"}),t.jsxs("p",{className:"lead",children:["This kind of project doesn't go live at a web address — it ships to a"," ",t.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?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"seclabel",children:["Your registry: ",o.name," (",o.ecosystem,")"]}),t.jsxs(Ne,{children:[t.jsxs($,{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?t.jsxs(t.Fragment,{children:[" ",o.note]}):null]}),t.jsx($,{lead:`Users then run \`${o.installCommand}\`.`,children:"Once published, anyone can install your package with one command — no clone, no build from source."}),t.jsxs($,{lead:"Your package gets a public page.",children:[o.name," hosts a page at"," ",t.jsx("code",{children:o.packagePage})," — the link you share so people can find, install, and trust the package."]})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Before your first publish"}),t.jsxs(Ne,{children:[t.jsxs($,{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 (",t.jsx("code",{children:"@you/tool"}),") or an org account."]}),t.jsxs($,{lead:"Turn on two-factor auth — registries expect it.",children:[Ee("registry.twoFactor").value,"."," ",t.jsx(Xn,{fact:Ee("registry.twoFactor")})," A token alone often isn't enough; set up 2FA before the release deadline, not during it."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:o.publishCommand}),t.jsx("span",{className:"chip",children:"Tokened account"}),t.jsx("span",{className:"chip",children:"Public package page"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",children:"Pick your registry"}),t.jsx(Ne,{children:h4.map(i=>t.jsxs($,{lead:`${i.name} — ${i.ecosystem}.`,children:["Publish with ",t.jsx("code",{children:i.publishCommand}),"; users install with"," ",t.jsx("code",{children:i.installCommand}),".",i.note?t.jsxs(t.Fragment,{children:[" ",i.note]}):null]},i.kind))}),t.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."})]}),t.jsx(Ae,{assistKey:"publish-registry",topicName:"Publish to a registry"}),t.jsx(Ie,{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 XQ=Object.freeze(Object.defineProperty({__proto__:null,PublishRegistryScreen:Jw},Symbol.toStringTag,{value:"Module"}));function Xw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"Versioning & changelog",meta:"About 20 minutes",onBack:e,assistKey:"versioning-changelog"}),t.jsxs("p",{className:"lead",children:["A version number is a promise. ",t.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."]}),t.jsx("div",{className:"seclabel",children:"The three numbers"}),t.jsxs(Ne,{children:[t.jsx($,{lead:"PATCH (1.2.x) — bug fixes only.",children:"Nothing user-visible changes except that something broken now works. Always safe to take."}),t.jsx($,{lead:"MINOR (1.x.0) — new, backward-compatible features.",children:"Existing usage keeps working; there's just more available."}),t.jsx($,{lead:"MAJOR (x.0.0) — breaking changes.",children:"You removed or changed something people relied on. Bumping major is how you warn them."}),t.jsxs($,{lead:"Before 1.0.0 (0.x) — anything may break.",children:["The most-missed rule for new tools: while you're on a"," ",t.jsx("code",{children:"0.x"})," version, semver lets a ",t.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."]})]}),t.jsx(tu,{spaced:!0,children:t.jsxs($,{lead:"Tag each release in git.",children:["A ",t.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.']})}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"MAJOR.MINOR.PATCH"}),t.jsx("span",{className:"chip",children:"CHANGELOG.md"}),t.jsx("span",{className:"chip",children:"git tag vX.Y.Z"})]}),t.jsx(Ae,{assistKey:"versioning-changelog",topicName:"Versioning & changelog"}),t.jsx(Ie,{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:e})]})}const QQ=Object.freeze(Object.defineProperty({__proto__:null,VersioningChangelogScreen:Xw},Symbol.toStringTag,{value:"Module"}));function Qw({registry:e,onBack:n,onComplete:s,status:r,onRevert:a}){const o=e?Kw(e):null;return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"Install docs",meta:"About 30 minutes · writing time",onBack:n,assistKey:"install-docs"}),t.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"," ",t.jsx("b",{children:"install command"})," and a tiny working example."]}),t.jsx("div",{className:"seclabel",children:"A good README opens with"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"A real first command to run.",children:["For a CLI, show an actual invocation — a quickstart like"," ",t.jsx("code",{children:"yourtool init"})," and the always-works"," ",t.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."]}),t.jsx($,{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."}),t.jsxs($,{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 (",t.jsx("code",{children:o?o.packagePage:"the registry listing"}),") gives readers the canonical source."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Install line first"}),t.jsx("span",{className:"chip",children:"Real command, not a snippet"}),t.jsx("span",{className:"chip",children:"Badges + package link"}),t.jsx("span",{className:"chip",children:o?o.name:"Any registry"})]}),t.jsx(Ae,{assistKey:"install-docs",topicName:"Install docs"}),t.jsx(Ie,{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 ZQ=Object.freeze(Object.defineProperty({__proto__:null,InstallDocsScreen:Qw},Symbol.toStringTag,{value:"Module"}));function Zw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(pt,{size:26}),title:"Release builds",meta:"About 45 minutes · CI setup",onBack:e,assistKey:"release-builds"}),t.jsxs("p",{className:"lead",children:["Not everyone installs from a registry — many people just want a binary they can run. ",t.jsx("b",{children:"Cross-platform release builds"})," produce that binary for each operating system, so users download one file and go."]}),t.jsx("div",{className:"seclabel",children:"What to produce"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsxs($,{lead:"Build on a git tag, in CI.",children:["A push of ",t.jsx("code",{children:"v1.2.0"})," triggers the release workflow, so binaries always match a real, tagged version — no laptop builds. A tool like ",t.jsx("code",{children:"cargo-dist"}),", ",t.jsx("code",{children:"goreleaser"}),", or electron-builder wires up the whole matrix-build-sign-publish flow instead of you hand-writing it."]}),t.jsxs($,{lead:"Attach them to a GitHub Release.",children:["Upload the binaries (and their checksums) to the tagged"," ",t.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."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"macOS · Linux · Windows"}),t.jsx("span",{className:"chip",children:"Signed + notarized"}),t.jsx("span",{className:"chip",children:"Tag-triggered CI"}),t.jsx("span",{className:"chip",children:"GitHub Releases"}),t.jsx("span",{className:"chip",children:"Checksums"})]}),t.jsx(Ae,{assistKey:"release-builds",topicName:"Release builds"}),t.jsx(Ie,{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:e})]})}const eZ=Object.freeze(Object.defineProperty({__proto__:null,ReleaseBuildsScreen:Zw},Symbol.toStringTag,{value:"Module"}));function e_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(Fs,{size:26}),title:"Shell completions",meta:"About 30 minutes · polish",onBack:e,assistKey:"shell-completions"}),t.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."}),t.jsx("div",{className:"seclabel",children:"How it works"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Generate a completion script per shell.",children:["Most CLI frameworks emit completion scripts for ",t.jsx("code",{children:"bash"}),","," ",t.jsx("code",{children:"zsh"}),", ",t.jsx("code",{children:"fish"}),", and PowerShell from your command definitions — you don't hand-write them."]}),t.jsxs($,{lead:"Ship a `completions` subcommand.",children:["A ",t.jsx("code",{children:"yourtool completions zsh"})," command lets users (and your install docs) print the script for their shell on demand."]}),t.jsx($,{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."}),t.jsxs($,{lead:"Generate a man page from the same source.",children:["The sibling polish step: most CLI frameworks also emit a"," ",t.jsx("code",{children:"man"})," page from your command definitions, so"," ",t.jsx("code",{children:"man yourtool"})," works the way completions do — generated, not hand-written."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"bash · zsh · fish"}),t.jsx("span",{className:"chip",children:"Generated, not hand-written"}),t.jsx("span",{className:"chip",children:"completions subcommand"})]}),t.jsx(Ae,{assistKey:"shell-completions",topicName:"Shell completions"}),t.jsx(Ie,{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:e})]})}const tZ=Object.freeze(Object.defineProperty({__proto__:null,ShellCompletionsScreen:e_},Symbol.toStringTag,{value:"Module"}));function t_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(Fs,{size:26}),title:"Command-line UX",meta:"About 30 minutes · the interface contract",onBack:e,assistKey:"cli-ux"}),t.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."}),t.jsx("div",{className:"seclabel",children:"The conventions every CLI follows"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsxs($,{lead:"Exit codes mean something.",children:[t.jsx("code",{children:"0"})," for success, non-zero for failure — and ideally distinct codes for distinct failures. This is how"," ",t.jsx("code",{children:"cmd && next"})," and CI know whether to continue, so an error that exits 0 silently breaks every script wrapping you."]}),t.jsx($,{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."`})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"--help · --version"}),t.jsx("span",{className:"chip",children:"Meaningful exit codes"}),t.jsx("span",{className:"chip",children:"stdout = data, stderr = noise"})]}),t.jsx(Ae,{assistKey:"cli-ux",topicName:"Command-line UX"}),t.jsx(Ie,{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:e})]})}const nZ=Object.freeze(Object.defineProperty({__proto__:null,CliUxScreen:t_},Symbol.toStringTag,{value:"Module"}));function n_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(ot,{size:26}),title:"Security & supply chain",meta:"About 45 minutes · trust",onBack:e,assistKey:"supply-chain"}),t.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."}),t.jsx("div",{className:"seclabel",children:"What a published artifact owes its users"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Audit your own dependencies.",children:["Run ",t.jsx("code",{children:"cargo audit"})," (Rust) or ",t.jsx("code",{children:"npm audit"})," /"," ",t.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."]}),t.jsx($,{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."}),t.jsxs($,{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 (",t.jsx("code",{children:"cargo sbom"}),", ",t.jsx("code",{children:"npm sbom"}),","," ",t.jsx("code",{children:"syft"}),")."]}),t.jsxs($,{lead:"Sign your releases so they can be verified.",children:[Ee("supplyChain.signedReleases").value,"."," ",t.jsx(Xn,{fact:Ee("supplyChain.signedReleases")})," ","Pair that with published checksums (and a ",t.jsx("code",{children:"cosign"})," signature for binaries) so an install can prove it got exactly what you built."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"audit in CI"}),t.jsx("span",{className:"chip",children:"SBOM per release"}),t.jsx("span",{className:"chip",children:"Signed & verifiable"})]}),t.jsx(Ae,{assistKey:"supply-chain",topicName:"Security & supply chain"}),t.jsx(Ie,{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:e})]})}const sZ=Object.freeze(Object.defineProperty({__proto__:null,SupplyChainScreen:n_},Symbol.toStringTag,{value:"Module"}));function s_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"Examples & doctests",meta:"About 40 minutes · adoption",onBack:e,assistKey:"examples"}),t.jsxs("p",{className:"lead",children:["Reference docs say what each function does; ",t.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."]}),t.jsx("div",{className:"seclabel",children:"What to ship"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Runnable examples, not snippets in a README.",children:["Put complete programs in an ",t.jsx("code",{children:"examples/"})," directory that build and run as-is (",t.jsx("code",{children:"cargo run --example quickstart"}),"). A snippet a user has to assemble themselves is a snippet that's subtly wrong."]}),t.jsx($,{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."}),t.jsxs($,{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 (",t.jsx("code",{children:"cargo test --doc"}),", Python's"," ",t.jsx("code",{children:"doctest"}),"). It means the snippet in your reference can't silently rot — if the API changes, the doctest fails CI."]}),t.jsxs($,{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 ",t.jsx("code",{children:"examples/"})," and run the doctests on every commit so a broken one fails the build."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"examples/ directory"}),t.jsx("span",{className:"chip",children:"One-minute quickstart"}),t.jsx("span",{className:"chip",children:"Doctests run in CI"})]}),t.jsx(Ae,{assistKey:"examples",topicName:"Examples & doctests"}),t.jsx(Ie,{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:e})]})}const rZ=Object.freeze(Object.defineProperty({__proto__:null,ExamplesScreen:s_},Symbol.toStringTag,{value:"Module"}));function r_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"API docs",meta:"Foundation · about 30 minutes",onBack:e,assistKey:"api-docs"}),t.jsxs("p",{className:"lead",children:["For a library, the public API ",t.jsx("i",{children:"is"})," the product — so its reference docs matter as much as the code. The trick is to"," ",t.jsx("b",{children:"generate docs from the source"}),", so they can't drift out of date."]}),t.jsx("div",{className:"seclabel",children:"Generate, don't hand-write"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"A generator for your language.",children:[t.jsx("code",{children:"docs.rs"})," for Rust, ",t.jsx("code",{children:"TypeDoc"})," for TypeScript,"," ",t.jsx("code",{children:"Sphinx"})," (or the more modern"," ",t.jsx("code",{children:"MkDocs + mkdocstrings"}),") for Python — each reads your source and produces a browsable site."]}),t.jsx($,{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."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"docs.rs · TypeDoc · Sphinx"}),t.jsx("span",{className:"chip",children:"From doc comments"}),t.jsx("span",{className:"chip",children:"Auto-built on publish"})]}),t.jsx(Ae,{assistKey:"api-docs",topicName:"API docs"}),t.jsx(Ie,{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:e})]})}const aZ=Object.freeze(Object.defineProperty({__proto__:null,ApiDocsScreen:r_},Symbol.toStringTag,{value:"Module"})),f4={key:"api-docs",Icon:nt,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 a_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:f4,onBack:e,onComplete:n,status:s,onRevert:r})}const oZ=Object.freeze(Object.defineProperty({__proto__:null,BackendApiDocsScreen:a_},Symbol.toStringTag,{value:"Module"}));function o_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"Versioning policy",meta:"About 20 minutes · a decision",onBack:e,assistKey:"semver-policy"}),t.jsxs("p",{className:"lead",children:["Other people's code depends on yours. A breaking change you ship quietly breaks their builds. A written ",t.jsx("b",{children:"versioning policy"})," is the promise that makes your library safe to depend on."]}),t.jsx("div",{className:"seclabel",children:"Decide and write down"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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)."}),t.jsx($,{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."}),t.jsxs($,{lead:"Let a tool catch breaks for you.",children:["You don't have to spot every breaking change by eye:"," ",t.jsx("code",{children:"cargo-semver-checks"})," (Rust) and"," ",t.jsx("code",{children:"api-extractor"})," (TypeScript) diff your public API against the last release and fail CI when a change needs a MAJOR bump."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Public API = the contract"}),t.jsx("span",{className:"chip",children:"Breaking → MAJOR"}),t.jsx("span",{className:"chip",children:"Deprecate before removing"})]}),t.jsx(Ae,{assistKey:"semver-policy",topicName:"Versioning policy"}),t.jsx(Ie,{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:e})]})}const iZ=Object.freeze(Object.defineProperty({__proto__:null,SemverPolicyScreen:o_},Symbol.toStringTag,{value:"Module"}));function i_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"Readme & license",meta:"About 30 minutes",onBack:e,assistKey:"readme-license"}),t.jsxs("p",{className:"lead",children:["Two files decide whether someone adopts your library: the"," ",t.jsx("b",{children:"README"})," tells them what it does, and the ",t.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.`]}),t.jsx("div",{className:"seclabel",children:"A README that earns trust"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{lead:"Install + a minimal example.",children:'The fastest path from "interested" to "it works on my machine".'})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Pick a license"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Library copyleft (LGPL, MPL-2.0) — share changes, not callers.",children:["For a library, the relevant copyleft is ",t.jsx("b",{children:"LGPL"})," or"," ",t.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 ",t.jsx("b",{children:"GPL"})," forces every consumer to be GPL too, which usually kills adoption for a library — reach for it only on purpose."]})]}),t.jsx(Ne,{children:t.jsxs($,{lead:"Declare the license in your package manifest, too.",children:["A LICENSE file alone isn't enough — set the ",t.jsx("code",{children:"license"})," field in your manifest (",t.jsx("code",{children:"Cargo.toml"}),", ",t.jsx("code",{children:"package.json"}),","," ",t.jsx("code",{children:"pyproject.toml"}),") so the registry detects and displays it on the package page."]})}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"README first line"}),t.jsx("span",{className:"chip",children:"LICENSE file + manifest field"}),t.jsx("span",{className:"chip",children:"MIT · Apache-2.0 · LGPL/MPL"})]}),t.jsx(Ae,{assistKey:"readme-license",topicName:"Readme & license"}),t.jsx(Ie,{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:e})]})}const lZ=Object.freeze(Object.defineProperty({__proto__:null,ReadmeLicenseScreen:i_},Symbol.toStringTag,{value:"Module"}));function l_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(Xt,{size:26}),title:"Changelog & CI",meta:"About 40 minutes · automation",onBack:e,assistKey:"changelog-ci"}),t.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."}),t.jsx(tu,{}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Automate the release"}),t.jsxs(Ne,{children:[t.jsx($,{lead:"CI runs tests on every change.",children:"A green pipeline is the precondition for any release — no publishing from an untested commit."}),t.jsxs($,{lead:"A tag triggers publish.",children:["Pushing ",t.jsx("code",{children:"v1.2.0"})," runs the release job: test, build, and publish to the registry. The version published always matches the tag."]}),t.jsxs($,{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 (",t.jsx("code",{children:"CARGO_REGISTRY_TOKEN"}),","," ",t.jsx("code",{children:"NPM_TOKEN"}),"). The current best practice is"," ",t.jsx("b",{children:"OIDC trusted publishing"}),": ",Ee("registry.oidc").value,"."," ",t.jsx(Xn,{fact:Ee("registry.oidc")})]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"CHANGELOG.md"}),t.jsx("span",{className:"chip",children:"Tests on every push"}),t.jsx("span",{className:"chip",children:"Tag → publish"}),t.jsx("span",{className:"chip",children:"OIDC or token"})]}),t.jsx(Ae,{assistKey:"changelog-ci",topicName:"Changelog & CI"}),t.jsx(Ie,{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:e})]})}const cZ=Object.freeze(Object.defineProperty({__proto__:null,ChangelogCiScreen:l_},Symbol.toStringTag,{value:"Module"})),m4=Ee("flyio.pricing"),g4={key:"deploy-target",connector:{provider:"render"},Icon:hs,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:m4.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 c_({onBack:e,onComplete:n,onRevert:s}){return t.jsx(ea,{config:g4,onBack:e,onComplete:n,onRevert:s})}const dZ=Object.freeze(Object.defineProperty({__proto__:null,DeployTargetScreen:c_},Symbol.toStringTag,{value:"Module"})),x4={key:"database-backups",Icon:Zr,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 d_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:x4,onBack:e,onComplete:n,status:s,onRevert:r})}const uZ=Object.freeze(Object.defineProperty({__proto__:null,DatabaseBackupsScreen:d_},Symbol.toStringTag,{value:"Module"}));function b4(){const[e,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:e}}const y4={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 u_(e,n){const s=[...e,...n];return s.length===0?y4:{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 p_(e,n){return{key:"secrets",Icon:ot,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:[u_(e,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 h_({onBack:e,onComplete:n,status:s,onRevert:r}){const{env:a}=b4(),o=p_((a==null?void 0:a.envKeys)??[],(a==null?void 0:a.serviceEnvVars)??[]);return t.jsx(Rt,{config:o,onBack:e,onComplete:n,status:s,onRevert:r})}const pZ=Object.freeze(Object.defineProperty({__proto__:null,SecretsScreen:h_,buildConfig:p_,secretsSection:u_},Symbol.toStringTag,{value:"Module"})),v4={key:"api-auth",Icon:ot,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 f_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:v4,onBack:e,onComplete:n,status:s,onRevert:r})}const hZ=Object.freeze(Object.defineProperty({__proto__:null,ApiAuthScreen:f_},Symbol.toStringTag,{value:"Module"})),j4={key:"cors-origins",Icon:Yn,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 m_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:j4,onBack:e,onComplete:n,status:s,onRevert:r})}const fZ=Object.freeze(Object.defineProperty({__proto__:null,CorsOriginsScreen:m_},Symbol.toStringTag,{value:"Module"})),w4={key:"background-jobs",Icon:pt,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 g_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:w4,onBack:e,onComplete:n,status:s,onRevert:r})}const mZ=Object.freeze(Object.defineProperty({__proto__:null,BackgroundJobsScreen:g_},Symbol.toStringTag,{value:"Module"})),_4={key:"logging-monitoring",Icon:Xt,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 x_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Rt,{config:_4,onBack:e,onComplete:n,status:s,onRevert:r})}const gZ=Object.freeze(Object.defineProperty({__proto__:null,LoggingMonitoringScreen:x_},Symbol.toStringTag,{value:"Module"}));function Kl({onBack:e,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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(pt,{size:26}),title:"Staging & preview deploys",meta:"About 15 minutes · then automatic on every push",onBack:e,assistKey:"staging-preview"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Per-branch preview deploys"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Get a URL for every branch or pull request.",children:["Hosts like ",t.jsx("b",{children:"Vercel"})," and ",t.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."]}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"A shared staging environment"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Share it privately"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx(Nt,{items:a}),t.jsx(Ae,{assistKey:"staging-preview",topicName:"Staging & preview deploys"}),t.jsx(Ie,{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:e})]})}const xZ=Object.freeze(Object.defineProperty({__proto__:null,StagingPreviewScreen:Kl},Symbol.toStringTag,{value:"Module"}));function b_({onBack:e,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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(pt,{size:26}),title:"Staging environment",meta:"About 30 minutes · a one-time environment to stand up",onBack:e,assistKey:"staging-environment"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Make it prod-like, but isolated"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Rehearse the risky parts"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to production"}),t.jsx(Ne,{children:t.jsx($,{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."})}),t.jsx(Nt,{items:a}),t.jsx(Ae,{assistKey:"staging-environment",topicName:"Staging environment"}),t.jsx(Ie,{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:e})]})}const bZ=Object.freeze(Object.defineProperty({__proto__:null,StagingEnvironmentScreen:b_},Symbol.toStringTag,{value:"Module"}));function Jl({onBack:e,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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(pt,{size:26}),title:"Pre-release channel",meta:"About 15 minutes · then one extra command per pre-release",onBack:e,assistKey:"pre-release-channel"}),t.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 ",t.jsx("code",{children:"latest"})," stays exactly where it is until you're ready to promote."]}),t.jsx("div",{className:"seclabel",children:"Publish on a separate channel"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Use a next / beta tag instead of latest.",children:["Publish the pre-release under a dist-tag like ",t.jsx("code",{children:"next"})," or"," ",t.jsx("code",{children:"beta"})," (npm), a ",t.jsx("code",{children:"--pre"})," flag on other registries, or a GitHub ",t.jsx("b",{children:"pre-release"})," for binaries. A normal install still resolves ",t.jsx("code",{children:"latest"}),", so the default install is untouched."]}),t.jsxs($,{lead:"Tag a semver pre-release version.",children:["Version it with a pre-release identifier — ",t.jsx("code",{children:"1.2.0-rc.1"}),","," ",t.jsx("code",{children:"1.2.0-beta.2"}),". Semver excludes these from ordinary version ranges, so a dependent on ",t.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."]})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Let testers opt in"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Tell testers the one install command.",children:["A tester installs the channel explicitly — ",t.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."]}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to stable"}),t.jsx(Ne,{children:t.jsxs($,{lead:"Cut the stable version when it holds up.",children:["Drop the pre-release suffix (",t.jsx("code",{children:"1.2.0-rc.1"})," →"," ",t.jsx("code",{children:"1.2.0"}),") and publish it to ",t.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."]})}),t.jsx(Nt,{items:a}),t.jsx(Ae,{assistKey:"pre-release-channel",topicName:"Pre-release channel"}),t.jsx(Ie,{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:e})]})}const yZ=Object.freeze(Object.defineProperty({__proto__:null,PreReleaseScreen:Jl},Symbol.toStringTag,{value:"Module"}));function Le(e,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 **${e}**. ${n}`,"","Walk me through it and make the changes you safely can in my project, asking me before anything destructive."].join(`
|
|
50
|
-
`)}const S4={"staging-preview":{Icon:pt,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:Le("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:Yn,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:Le("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:ot,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:Le("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:Ys,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:Le("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:kn,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:Le("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:Xt,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:Le("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:It,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:Le("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:nt,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:Le("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:nt,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:Le("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:ot,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:Le("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:ot,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:Le("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:pt,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:Le("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:Yn,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:Le("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:It,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:Le("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:pt,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:Le("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:It,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:Le("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:Xt,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:Le("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:Yn,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:Le("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:ot,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:Le("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:hs,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:Le("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:pt,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:Le("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:hs,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:Le("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:It,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:Le("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:nt,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:Le("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:It,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:Le("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:nt,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:Le("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:nt,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:Le("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:nt,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:Le("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:It,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:Le("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:pt,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:Le("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:Fs,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:Le("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:Fs,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:Le("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:ot,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:Le("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:pt,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:Le("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:pt,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:Le("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."}]}},k4={"real-data":bw,accounts:Pw,emails:Rw,payments:Mw,"analytics-monitoring":Iw,legal:Dw,"data-safety":Hw,publish:Bw,"custom-domain":Ww,forms:qw,"analytics-seo":Uw,"redirects-404":Gw,"performance-images":Yw,"comments-search":Vw,"publish-registry":Jw,"versioning-changelog":Xw,"install-docs":Qw,"release-builds":Zw,"shell-completions":e_,"cli-ux":t_,"api-docs":r_,examples:s_,"semver-policy":o_,"readme-license":i_,"supply-chain":n_,"changelog-ci":l_,"deploy-target":c_,"database-backups":d_,secrets:h_,"api-auth":f_,"cors-origins":m_,"background-jobs":g_,"logging-monitoring":x_,"staging-preview":Kl,"deploy-previews":Kl,"staging-environment":b_,"pre-release-channel":Jl,"pre-release-versions":Jl};function y_({onBack:e,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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(mu,{size:26}),title:a,meta:"Guided screen coming soon",onBack:e,assistKey:n??""}),t.jsx("p",{className:"lead",children:o}),t.jsx("div",{className:"cta-wrap",children:t.jsx("button",{type:"button",className:"cta",onClick:e,children:"Back to Setup"})})]})}function v_({topicKey:e,topicName:n,topicDesc:s,isBackend:r=!1,onBack:a,onComplete:o,onChatWithAI:i}){const c=S4[e];if(c)return t.jsx(du,{icon:t.jsx(c.Icon,{size:26}),title:c.title,crumbLabel:c.crumbLabel,meta:c.meta,assistKey:e,onBack:a,lead:c.lead,illustration:xu(e)??t.jsx(Ln,{nodes:c.journey}),chatPrompt:c.chatPrompt,onChatWithAI:i,faqs:c.faqs});const d=e==="api-docs"&&r?a_:k4[e];return d?t.jsx(d,{onBack:a,onComplete:()=>o==null?void 0:o(e),onChatWithAI:i}):t.jsx(y_,{onBack:a,topicKey:e,topicName:n,topicDesc:s})}const vZ=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPlaceholder:y_,SetupTopicRouter:v_},Symbol.toStringTag,{value:"Module"}));function j_({onBack:e}){const{concepts:n}=uw(),[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 t.jsxs("div",{className:"learn-screen concepts-glossary",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"What these words mean"})]}),t.jsx("div",{className:"h",children:"What these words mean"}),t.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."}),t.jsx("input",{type:"search",className:"concept-search",placeholder:"Search terms…",value:s,onChange:c=>r(c.target.value),"aria-label":"Search terms"}),t.jsx("div",{className:"tlist",children:n===null?Array.from({length:6}).map((c,d)=>t.jsx("div",{className:"trow soon","aria-hidden":"true",children:t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:" "}),t.jsx("div",{className:"td",children:" "})]})},d)):i.length===0?t.jsxs("div",{className:"concept-empty",children:['No terms match "',s,'".']}):i.map(c=>{const d=a===c.key;return t.jsxs("div",{className:"concept-row",children:[t.jsxs("button",{type:"button",className:"trow soon","aria-expanded":d,onClick:()=>o(d?null:c.key),children:[t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:c.term}),c.category?t.jsx("div",{className:"td",children:c.category}):null]}),t.jsx("span",{className:"arrow",children:d?"−":"+"})]}),d?t.jsx("div",{className:"concept-row-body",children:t.jsx(Lt,{variant:"compact",children:c.body})}):null]},c.key)})})]})}const jZ=Object.freeze(Object.defineProperty({__proto__:null,ConceptsGlossaryScreen:j_},Symbol.toStringTag,{value:"Module"}));function N4(e){const n=(e??"").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 w_({summary:e}){const{tally:n,attention:s}=N4(e);return n?t.jsxs("p",{className:"xsvc-count xsvc-count-row",children:[t.jsx("b",{children:n}),s?t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"attn",children:s})]}):null]}):null}const wZ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSummary:w_},Symbol.toStringTag,{value:"Module"}));function __({summary:e,sort:n,onSortChange:s}){return t.jsxs("div",{className:"xsvc-listbar",children:[t.jsx(w_,{summary:e}),t.jsx(eu,{sort:n,onSortChange:s})]})}const _Z=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesListBar:__},Symbol.toStringTag,{value:"Module"})),C4="All providers";function T4(e,n){const s=e??[];return n==="type"?s.filter(r=>r.items.length>0):[{label:C4,items:s.flatMap(r=>r.items.map(a=>a.category?a:{...a,category:r.label})).slice().sort((r,a)=>r.name.localeCompare(a.name))}]}function S_({groups:e,loading:n=!1,summary:s,onBack:r,onOpenChat:a,onAction:o,defaultSort:i="type",chatSlot:c,embedded:d=!1,brokerStarter:u,onSaveDomain:p}){const h=Array.isArray(e)&&e.some(j=>j.items.length>0),[f,m]=l.useState(i),[g,x]=l.useState(""),b=l.useRef(null),y=j=>{j.preventDefault(),a==null||a(g.trim()||void 0)},v=h?T4(e,f):[];return t.jsx("div",{className:d?"xsvc xsvc-embedded":"xsvc",children:t.jsxs("div",{className:"xsvc-scroll",children:[d?null:t.jsx("div",{className:"xsvc-crumbs",children:t.jsx("button",{type:"button",className:"xsvc-back",onClick:r,"aria-label":"Back to Home",children:"‹ Home"})}),t.jsxs("div",{className:"xsvc-head",children:[d?null:t.jsxs("div",{className:"xsvc-titlerow",children:[t.jsx("h1",{children:"External Services"}),h?t.jsx("span",{className:"xsvc-count",children:s??"Every outside service, in one place."}):null]}),d||!h?t.jsx("p",{className:d?"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]}),h?t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:b,"aria-hidden":"true"}),t.jsx(av,{draft:g,onDraftChange:x,onSubmit:y,onAsk:a,chatSlot:c,bare:d}),t.jsx("div",{className:"xsvc-divider",role:"presentation"}),d?t.jsx(__,{summary:s,sort:f,onSortChange:m}):t.jsx(eu,{sort:f,onSortChange:m}),t.jsx(sv,{groups:v,onAction:o,onSaveDomain:p,onAsk:a?j=>{var _,S;x(j),a(j),(S=(_=b.current)==null?void 0:_.scrollIntoView)==null||S.call(_,{behavior:"smooth",block:"start"})}:void 0})]}):n?t.jsx("p",{"data-testid":"xsvc-loading",role:"status",className:"xsvc-sub",children:"Loading services…"}):t.jsx(Zy,{draft:g,onDraftChange:x,onSubmit:y,onAsk:a,brokerStarter:u})]})})}const SZ=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:Qd,ExternalServicesScreen:S_,ServiceRow:Zd},Symbol.toStringTag,{value:"Module"})),Dr="your-app.vercel.app",P4=[{key:"connect",label:"Connect"},{key:"deploying",label:"Deploy"},{key:"live",label:"Go live"}];function Pu({onBack:e}){return t.jsx(Pe,{icon:t.jsx(hs,{size:26}),title:"Hosting & going live",crumbLabel:"Hosting",meta:"Foundation · about 10 minutes",onBack:e,assistKey:"hosting"})}function Bs({stage:e}){return t.jsx(wn,{steps:P4,currentKey:e})}const kZ=Object.freeze(Object.defineProperty({__proto__:null,FlowBar:Bs,HSHeader:Pu,HS_URL:Dr},Symbol.toStringTag,{value:"Module"}));function O4(){const[e,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:e}}function k_({onBack:e,onSetup:n}){const{target:s}=O4(),r=(s==null?void 0:s.detectedHost)??null;return t.jsxs(t.Fragment,{children:[t.jsx(Pu,{onBack:e}),t.jsxs("p",{className:"lead",children:["Right now your app only runs on ",t.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."]}),t.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."}),t.jsx(cv,{}),r&&t.jsxs("div",{className:"hosting-detected",role:"note",children:[t.jsxs("div",{className:"hosting-detected-title",children:["This project is already configured for ",t.jsx("b",{children:r.name})]}),t.jsxs("div",{className:"hosting-detected-detail",children:["We found ",t.jsx("code",{children:r.evidence})," in your project — let's use"," ",r.name,".",(s==null?void 0:s.buildCommand)&&t.jsxs(t.Fragment,{children:[" ","It builds with ",t.jsx("code",{children:s.buildCommand}),s.outputDir&&t.jsxs(t.Fragment,{children:[" ","into ",t.jsx("code",{children:s.outputDir})]}),"."]})]})]}),t.jsx("div",{className:"seclabel",children:r?"Or start fresh with our recommendation":"Recommended for your app"}),t.jsxs("div",{className:"provcard best",children:[t.jsx(Wo,{}),t.jsxs("div",{className:"provbody",children:[t.jsxs("div",{className:"provtop",children:[t.jsx("span",{className:"provname",children:"Vercel"}),t.jsx("span",{className:"bestfit",children:"Best fit"})]}),t.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."}),t.jsx(dv,{}),t.jsx(uv,{})]})]}),t.jsx(pv,{}),t.jsxs("div",{className:"cta-wrap",children:[t.jsxs("button",{type:"button",className:"cta",onClick:n,children:[t.jsx("span",{className:"ce",children:"☁️"})," Set up hosting with Vercel"]}),t.jsx("div",{className:"cta-note",children:"We'll walk you through every step. Nothing goes live until you say so."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),t.jsx(hv,{}),t.jsx(fv,{}),t.jsx(Ae,{assistKey:"hosting",topicName:"Hosting & going live"})]})}const NZ=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewGuided:k_},Symbol.toStringTag,{value:"Module"}));function N_({onBack:e,onContinue:n,tokenMode:s=!1}){const[r,a]=l.useState("");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Connect Vercel"})]}),t.jsx(Bs,{stage:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsx("div",{className:"ph",children:"🔗 Connect your Vercel account"}),t.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."}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("div",{className:"cbtitle",children:[t.jsx(Wo,{}),t.jsxs("div",{children:[t.jsx("div",{className:"cbt",children:"Sign in with Vercel"}),t.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?t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"real-token-label",htmlFor:"hosting-token",children:"Vercel access token"}),t.jsx("input",{id:"hosting-token",type:"password",className:"real-token-input",placeholder:"Paste your Vercel token",value:r,onChange:o=>a(o.target.value)}),t.jsxs("button",{type:"button",className:"auth-btn",disabled:r.trim().length===0,onClick:()=>n(r.trim()),children:[t.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:t.jsx("path",{d:"M13 0l13 22H0z"})}),"Deploy with Vercel"]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grant",children:[t.jsxs("div",{className:"grantrow",children:[t.jsx(ft,{color:"var(--blue-300)"}),t.jsx("span",{children:"Create one project to hold your app"})]}),t.jsxs("div",{className:"grantrow",children:[t.jsx(ft,{color:"var(--blue-300)"}),t.jsx("span",{children:"Publish updates when you choose to go live"})]}),t.jsxs("div",{className:"grantrow",children:[t.jsx(ft,{color:"var(--blue-300)"}),t.jsx("span",{children:"Nothing else. We can't touch your other accounts or files"})]})]}),t.jsxs("button",{type:"button",className:"auth-btn",onClick:()=>n(),children:[t.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:t.jsx("path",{d:"M13 0l13 22H0z"})}),"Continue with Vercel"]}),t.jsxs("div",{className:"auth-row",children:[t.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>n(),children:"I already have an account"}),t.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>n(),children:"Create one for me"})]})]})]}),t.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 CZ=Object.freeze(Object.defineProperty({__proto__:null,HostingConnectStep:N_},Symbol.toStringTag,{value:"Module"})),Na=["Packaging up your app","Uploading it to Vercel","Giving it a web address","Turning it on"],jf=1100,R4=700;function C_({onDone:e}){const[n,s]=l.useState(0),r=l.useRef(e);r.current=e,l.useEffect(()=>{const o=[];for(let i=1;i<=Na.length;i++)o.push(setTimeout(()=>s(i),i*jf));return o.push(setTimeout(()=>r.current(),Na.length*jf+R4)),()=>o.forEach(clearTimeout)},[]);const a=Math.round(n/Na.length*100);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Going live"})]}),t.jsx(Bs,{stage:"deploying"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),t.jsx("div",{className:"deploy-d",children:"This usually takes under a minute. You can keep working, we'll let you know."})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{style:{width:a+"%"}})}),t.jsx("div",{className:"dep-steps",children:Na.map((o,i)=>t.jsxs("div",{className:"dep-step "+(i<n?"done":i===n?"active":"todo"),children:[t.jsx("div",{className:"dot",children:i<n?t.jsx(ft,{size:12,color:"#0a0a0a"}):null}),t.jsx("div",{className:"sl",children:o})]},o))})]})]})}const TZ=Object.freeze(Object.defineProperty({__proto__:null,HostingDeployStep:C_},Symbol.toStringTag,{value:"Module"})),E4="hosting";function T_({provider:e,credential:n,onDone:s,onRetry:r}){const{stage:a,result:o,error:i,connect:c}=bu(E4,e),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"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Going live"})]}),t.jsx(Bs,{stage:"deploying"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"real-error",role:"alert",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("div",{className:"real-error-title",children:"Couldn’t put your app online"}),t.jsx(mt,{variant:"icon",text:`Couldn’t put your app online: ${i}`})]}),t.jsx("div",{className:"real-error-msg",children:i})]}),t.jsx("button",{type:"button",className:"auth-btn",onClick:r,children:"Try again"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Going live"})]}),t.jsx(Bs,{stage:"deploying"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),t.jsx("div",{className:"deploy-d",children:a==="connecting"?"Connecting to your hosting account…":"Building and publishing your app. This usually takes under a minute."})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const PZ=Object.freeze(Object.defineProperty({__proto__:null,HostingRealDeployStep:T_},Symbol.toStringTag,{value:"Module"})),A4=1600;function P_(e){const{copied:n,copy:s}=To({resetMs:A4}),r=l.useCallback(()=>{s(e)},[s,e]);return{copied:n,copy:r}}function O_({onFinish:e,liveUrl:n}){const s=n??Dr,r=n??"https://"+Dr,{copied:a,copy:o}=P_(r);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Live"})]}),t.jsx(Bs,{stage:"live"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"live-hero",children:[t.jsx("div",{className:"lh-em",children:"🎉"}),t.jsx("div",{className:"lh-t",children:"Your app is live"}),t.jsx("div",{className:"lh-d",children:"Anyone with this link can open your app right now."})]}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"🌍"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:"Your link"}),t.jsx("div",{className:"uc-u",children:s})]}),t.jsxs("div",{className:"uc-actions",children:[t.jsx("button",{type:"button",className:"btn-copy",onClick:o,children:a?"✓ Copied":"Copy link"}),t.jsx("button",{type:"button",className:"btn-visit",disabled:!n,onClick:n?()=>window.open(n,"_blank","noopener"):void 0,children:"Visit →"})]})]}),t.jsxs("div",{className:"domain-row",children:[t.jsx("span",{className:"dre",children:"🏷️"}),t.jsxs("div",{children:[t.jsx("div",{className:"drt",children:"Want your own web address?"}),t.jsx("div",{className:"drd",children:"Connect a custom domain. Optional, and you can do it anytime."})]}),t.jsx("button",{type:"button",className:"drbtn",children:"Add a domain"})]}),t.jsxs("div",{className:"live-foot",children:[t.jsxs("span",{className:"done-pill",children:[t.jsx(ft,{})," Hosting is now set up"]}),t.jsx("button",{type:"button",className:"lf-back",onClick:e,children:"Back to Setup"})]})]})]})}const OZ=Object.freeze(Object.defineProperty({__proto__:null,HostingLiveStep:O_},Symbol.toStringTag,{value:"Module"}));function R_({onBack:e,onRedeploy:n}){const{copied:s,copy:r}=P_("https://"+Dr),[a,o]=l.useState(!0);return t.jsxs(t.Fragment,{children:[t.jsx(Pu,{onBack:e}),t.jsxs("div",{className:"conn-card",children:[t.jsx(Wo,{}),t.jsxs("div",{className:"conn-body",children:[t.jsxs("div",{className:"conn-top",children:[t.jsx("span",{className:"conn-name",children:"Connected to Vercel"}),t.jsxs("span",{className:"conn-live",children:[t.jsx("span",{className:"lbdot"}),"Live"]})]}),t.jsxs("div",{className:"conn-acct",children:["Account ",t.jsx("b",{children:"your-app"})," · connected today"]})]}),t.jsx("button",{type:"button",className:"conn-disc",children:"Disconnect"})]}),t.jsx("div",{className:"seclabel",children:"Your live app"}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"🌍"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:"Your link"}),t.jsx("div",{className:"uc-u",children:Dr})]}),t.jsxs("div",{className:"uc-actions",children:[t.jsx("button",{type:"button",className:"btn-copy",onClick:r,children:s?"✓ Copied":"Copy link"}),t.jsx("button",{type:"button",className:"btn-visit",children:"Visit →"})]})]}),t.jsx("div",{className:"seclabel",style:{marginTop:28},children:"Latest deploy"}),t.jsxs("div",{className:"dep-card",children:[t.jsxs("div",{className:"depc-row",children:[t.jsx("span",{className:"depc-dot"}),t.jsxs("div",{className:"depc-main",children:[t.jsx("div",{className:"depc-t",children:"Live · deployed 2 minutes ago"}),t.jsx("div",{className:"depc-d",children:"Built and published from your latest changes."})]}),t.jsx("button",{type:"button",className:"depc-btn",onClick:n,children:"Redeploy"})]}),t.jsxs("div",{className:"depc-toggle",children:[t.jsxs("div",{children:[t.jsx("div",{className:"depc-tt",children:"Publish changes automatically"}),t.jsx("div",{className:"depc-td",children:"When you make changes, we'll put them live for you. Turn this off to publish by hand."})]}),t.jsx("span",{className:"toggle"+(a?" on":""),onClick:()=>o(i=>!i),role:"switch","aria-checked":a,tabIndex:0,children:t.jsx("span",{})})]})]})]})}const RZ=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewConnected:R_},Symbol.toStringTag,{value:"Module"}));function E_({direction:e="guided",onBack:n,onComplete:s,connector:r,onOpenSharedBrowser:a}){const[o,i]=l.useState("overview"),[c,d]=l.useState(""),[u,p]=l.useState(void 0),h=r!==void 0;let f;return o==="overview"?f=e==="connected"?t.jsx(R_,{onBack:n,onRedeploy:()=>i("deploying")}):t.jsx(k_,{onBack:n,onSetup:()=>i("connect")}):o==="connect"?f=t.jsx(N_,{onBack:()=>i("overview"),tokenMode:h,onContinue:m=>{h&&d(m??""),i("deploying")}}):o==="deploying"?f=h?t.jsx(T_,{provider:r.provider,credential:c,onDone:m=>{p(m),i(e==="connected"?"overview":"live")},onRetry:()=>i("connect")}):t.jsx(C_,{onDone:()=>i(e==="connected"?"overview":"live")}):f=t.jsx(O_,{liveUrl:u,onFinish:()=>{s==null||s(),n()}}),t.jsxs("div",{className:"hosting-screen",children:[f,a&&t.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[12px]",children:[t.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 →"}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:"Walk the hosting console together — you and the assistant both drive."})]})]})}const EZ=Object.freeze(Object.defineProperty({__proto__:null,HostingScreen:E_},Symbol.toStringTag,{value:"Module"}));function A_({recipe:e,onBack:n,onMarkDone:s,status:r,onRevert:a,copyWriter:o}){return t.jsxs("div",{className:"learn-screen run-locally-screen",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:n,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("button",{type:"button",onClick:n,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Run it locally"})]}),t.jsx("div",{className:"h",children:"Run it locally"}),t.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."}),e===null?t.jsx("div",{className:"rl-loading","aria-hidden":"true",children:"Loading run instructions…"}):t.jsxs("div",{className:"rl-sections",children:[e.prereqs.length>0&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Prerequisites"}),t.jsx("ul",{className:"rl-prereqs",children:e.prereqs.map(i=>t.jsxs("li",{className:"rl-prereq",children:[t.jsx("span",{className:"rl-prereq-label",children:i.label}),t.jsx("span",{className:"rl-prereq-detail",children:i.detail})]},i.label))})]}),e.install&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Install"}),t.jsx(vr,{command:e.install,writer:o})]}),t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:e.runLabel||"Run"}),t.jsx(vr,{command:e.run,writer:o})]}),e.loadSteps&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:e.loadSteps.label}),t.jsx("ol",{className:"rl-load-steps",children:e.loadSteps.steps.map(i=>t.jsx("li",{className:"rl-load-step",children:i},i))}),e.loadTarget&&t.jsxs("div",{className:"rl-load-target",children:[t.jsx("div",{className:"rl-load-target-label",children:e.loadTarget.label}),t.jsx(vr,{command:e.loadTarget.path,writer:o})]})]}),e.reachableAt&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Open it"}),t.jsxs("div",{className:"rl-reachable",children:["Once it's running, open"," ",t.jsx("a",{className:"rl-url",href:e.reachableAt,target:"_blank",rel:"noreferrer",children:e.reachableAt}),"."]})]}),e.notes.length>0&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Notes"}),t.jsx("ul",{className:"rl-notes",children:e.notes.map(i=>t.jsx("li",{className:"rl-note",children:i},i))})]}),t.jsx(Ae,{assistKey:"run-locally",topicName:"Run it locally"}),s&&t.jsx(Ie,{label:"Got it — mark as done",note:"You can revisit these steps anytime.",status:r,onComplete:()=>s(),onRevert:a,onBack:n})]})]})}const AZ=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyScreen:A_},Symbol.toStringTag,{value:"Module"}));function M_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(ot,{size:26}),title:"Store accounts",meta:"Foundation · about 15 minutes",onBack:e,assistKey:"store-accounts"}),t.jsxs("p",{className:"lead",children:["To publish your extension, you first register as a developer with the"," ",t.jsx("b",{children:"Chrome Web Store"}),". This is a one-time setup that gives you a dashboard for uploading, updating, and managing your listing."]}),t.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."}),t.jsx(Jt,{linkKey:"chrome.devConsole"}),t.jsx("div",{className:"seclabel",children:"What you'll do"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Pay the one-time developer fee.",children:["The Chrome Web Store charges a single"," ",t.jsx("b",{children:Ee("chromeStore.fee").value})," registration fee per account — not per extension. There's no recurring cost. The registration guide walks through the exact steps."]}),t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx(Jt,{linkKey:"chrome.register",label:"Read the Chrome Web Store registration guide"}),t.jsx(Ho,{}),t.jsx(Ae,{assistKey:"store-accounts",topicName:"Store accounts"}),t.jsx(Ie,{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:e})]})}const MZ=Object.freeze(Object.defineProperty({__proto__:null,StoreAccountsScreen:M_},Symbol.toStringTag,{value:"Module"}));function I_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(It,{size:26}),title:"Store assets",meta:"About 30 minutes · design time",onBack:e,assistKey:"extension-store-assets"}),t.jsxs("p",{className:"lead",children:["Your store listing needs a set of images at ",t.jsx("b",{children:"exact dimensions"}),". The store rejects assets that are the wrong size, so it's worth getting these right before you submit."]}),t.jsx("div",{className:"seclabel",children:"Required"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Recommended"}),t.jsxs(Ne,{children:[t.jsx($,{lead:"Small promo tile — 440×280.",children:"Shown in store listings and search results. A clean tile noticeably improves install rates."}),t.jsx($,{lead:"Marquee promo tile — 1400×560.",children:"Only used if the store features your extension, but worth having ready."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"PNG or JPEG"}),t.jsx("span",{className:"chip",children:"No misleading imagery"}),t.jsx("span",{className:"chip",children:"Up to 5 screenshots"})]}),t.jsx(Jt,{linkKey:"chrome.devConsole",label:"Upload assets in the developer dashboard"}),t.jsx(Ae,{assistKey:"extension-store-assets",topicName:"Store assets"}),t.jsx(Ie,{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:e})]})}const IZ=Object.freeze(Object.defineProperty({__proto__:null,ExtensionAssetsScreen:I_},Symbol.toStringTag,{value:"Module"})),D_={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 Lr(e){const n=e.trim();return n.includes("://")||n.startsWith("*")||n==="<all_urls>"}function M4(e){const n=e.trim();return n==="<all_urls>"?!0:Lr(n)?n.replace(/^\*?:\/\//,"").split("/")[0]==="*":!1}function I4(e){const n=e.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.":M4(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.`:Lr(n)?`Run only on the specific sites this pattern matches (${n}).`:D_[n]??"Explain, in one plain sentence, exactly what this permission lets your extension do for the user."}function D4(e){const n=e.trim();return Lr(n)||n in D_}const L4=["storage","activeTab","scripting","https://api.example.com/*"];function Xl({perm:e}){return t.jsxs("div",{className:"reason",children:[t.jsx(ft,{}),t.jsxs("span",{children:[t.jsx("b",{children:t.jsx("code",{children:e})})," ",I4(e),D4(e)?null:t.jsx("span",{className:"bestfit",style:{marginLeft:8},children:"needs your wording"})]})]},e)}function L_({permissions:e=L4,onBack:n,onComplete:s,status:r,onRevert:a}){const o=e.filter(Lr),i=e.filter(c=>!Lr(c));return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(ot,{size:26}),title:"Permissions",meta:"About 20 minutes · often missed",onBack:n,assistKey:"permissions-justification"}),t.jsxs("p",{className:"lead",children:["The store asks you to justify ",t.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."]}),t.jsxs("p",{className:"lead dim",children:["These are read from your ",t.jsx("code",{children:"manifest.json"}),". Review the suggested justification for each and tighten it to match what your extension actually does."]}),t.jsxs("div",{className:"asknote",style:{marginTop:4},children:[t.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."]}),t.jsx("div",{className:"seclabel",children:"API permissions you request"}),i.length===0?t.jsx("p",{className:"lead dim",children:"Your manifest requests no API permissions to justify here."}):t.jsx("div",{className:"reasons",children:i.map(c=>t.jsx(Xl,{perm:c},c))}),t.jsx("div",{className:"seclabel",children:"Host permissions"}),o.length===0?t.jsx("p",{className:"lead dim",children:"Your manifest requests no host permissions — the easiest possible review on this axis."}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"lead dim",children:["Host permissions are submitted in a ",t.jsx("b",{children:"separate field"})," on the dashboard and scrutinised the hardest — narrow them to the exact origins you need."]}),t.jsx("div",{className:"reasons",children:o.map(c=>t.jsx(Xl,{perm:c},c))})]}),e.length===0&&t.jsx("p",{className:"lead dim",children:"Your manifest requests no special permissions — there's nothing to justify. That's the easiest possible review."}),t.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."}),t.jsx(Jt,{linkKey:"chrome.devConsole",label:"Submit justifications in the developer dashboard"}),t.jsx(Ae,{assistKey:"permissions-justification",topicName:"Permissions"}),t.jsx(Ie,{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 DZ=Object.freeze(Object.defineProperty({__proto__:null,PermissionRow:Xl,PermissionsJustificationScreen:L_},Symbol.toStringTag,{value:"Module"}));function $_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"Privacy policy",meta:"About 20 minutes · disclosure required for every extension",onBack:e,assistKey:"privacy-policy"}),t.jsxs("p",{className:"lead",children:["A privacy policy at a public URL is required for any extension that accesses user data. Separately, ",t.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."]}),t.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.`}),t.jsx("div",{className:"seclabel",children:'The "Privacy practices" tab'}),t.jsxs("p",{className:"lead dim",children:["The disclosure lives on the dashboard's ",t.jsx("b",{children:"Privacy practices"})," tab. You can't submit until you check its three mandatory certifications:"]}),t.jsxs(Ne,{children:[t.jsx($,{lead:"You don't sell or transfer data to third parties",children:"outside of approved use cases."}),t.jsx($,{lead:"You don't use or transfer data for purposes unrelated",children:"to your extension's single purpose."}),t.jsx($,{lead:"You don't use or transfer data to determine creditworthiness",children:"or for lending purposes."})]}),t.jsx("div",{className:"seclabel",children:"Your policy must cover"}),t.jsxs(Ne,{children:[t.jsx($,{lead:"What you collect.",children:"List the categories of data — settings, content the user enters, usage analytics — in plain terms."}),t.jsx($,{lead:"Why you collect it.",children:"Tie each category to a feature. The store cross-checks this against your permission justifications."}),t.jsx($,{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."}),t.jsx($,{lead:"How users can reach you.",children:"A contact method for privacy questions or deletion requests."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Hosted at a public URL"}),t.jsx("span",{className:"chip",children:"Linked in the dashboard"}),t.jsx("span",{className:"chip",children:"Matches your data disclosure"})]}),t.jsx(Ae,{assistKey:"privacy-policy",topicName:"Privacy policy"}),t.jsx(Ie,{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:e})]})}const LZ=Object.freeze(Object.defineProperty({__proto__:null,ExtensionPrivacyPolicyScreen:$_},Symbol.toStringTag,{value:"Module"}));function F_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(ot,{size:26}),title:"OAuth & sign-in verification",meta:"Days to weeks · a separate review from the store listing",onBack:e,assistKey:"oauth-verification"}),t.jsxs("p",{className:"lead",children:["If your extension signs users in with Google, the OAuth"," ",t.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."]}),t.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."}),t.jsxs("div",{className:"asknote",style:{marginTop:4},children:[t.jsx("b",{children:"Two reviews, two timelines:"})," the store reviews your extension listing; Google separately reviews the ",t.jsx("b",{children:"OAuth consent screen"})," tied to your Cloud project. Approval on one is not approval on the other."]}),t.jsx("div",{className:"seclabel",children:"How long depends on the scopes you ask for"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",children:"Before you submit for verification"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Separate from the store review"}),t.jsx("span",{className:"chip",children:"Sensitive scopes = verification"}),t.jsx("span",{className:"chip",children:"Restricted scopes = security assessment"})]}),t.jsx(Jt,{linkKey:"google.oauthConsent"}),t.jsx(Ae,{assistKey:"oauth-verification",topicName:"OAuth & sign-in verification"}),t.jsx(Ie,{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:e})]})}const $Z=Object.freeze(Object.defineProperty({__proto__:null,OAuthVerificationScreen:F_},Symbol.toStringTag,{value:"Module"}));function z_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(nt,{size:26}),title:"Single purpose & listing quality",meta:"About 30 minutes · two of the top rejection causes",onBack:e,assistKey:"single-purpose-listing"}),t.jsxs("p",{className:"lead",children:["Every extension must have a ",t.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."]}),t.jsx("p",{className:"lead dim",children:"Write your one-sentence purpose first. Everything else — permissions, the description, the category — should follow from it."}),t.jsx("div",{className:"seclabel",children:"The single-purpose policy"}),t.jsxs(Ne,{children:[t.jsx($,{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.`}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",children:"Listing quality"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{lead:"The right category.",children:"Pick the category that matches the purpose. A mismatched category is a flag and hurts discovery."}),t.jsx($,{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.`})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"One sentence, one purpose"}),t.jsx("span",{className:"chip",children:"Description matches behavior"}),t.jsx("span",{className:"chip",children:"Honest title & category"})]}),t.jsx(Jt,{linkKey:"chrome.devConsole",label:"Edit the listing description in the developer dashboard"}),t.jsx(Ae,{assistKey:"single-purpose-listing",topicName:"Single purpose & listing quality"}),t.jsx(Ie,{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:e})]})}const FZ=Object.freeze(Object.defineProperty({__proto__:null,SinglePurposeListingScreen:z_},Symbol.toStringTag,{value:"Module"}));function B_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(It,{size:26}),title:"Manifest & versioning",meta:"About 15 minutes · enforced before review even starts",onBack:e,assistKey:"manifest-versioning"}),t.jsxs("p",{className:"lead",children:["Your ",t.jsx("code",{children:"manifest.json"})," has to satisfy a few hard rules before the store will accept an upload at all — these checks run"," ",t.jsx("b",{children:"before"})," any human review. Getting them right means your Submit step goes through on the first try instead of bouncing."]}),t.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."}),t.jsx("div",{className:"seclabel",children:"The rules the store enforces"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Manifest V3 is required.",children:[t.jsx("code",{children:'"manifest_version": 3'}),". V2 is no longer accepted for new uploads — a service worker replaces the old background page, and blocking ",t.jsx("code",{children:"webRequest"})," is gone."]}),t.jsxs($,{lead:"The version must strictly increase on every upload.",children:["Bump ",t.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."]}),t.jsxs($,{lead:"Use a valid version format.",children:["One to four dot-separated integers (e.g. ",t.jsx("code",{children:"1.2.0"}),"). Each part is compared numerically, so ",t.jsx("code",{children:"1.10"})," is newer than"," ",t.jsx("code",{children:"1.9"}),"."]})]}),t.jsx("div",{className:"seclabel",children:"Worth setting deliberately"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Keep name, description, and icons in sync.",children:["The manifest's ",t.jsx("code",{children:"name"}),"/",t.jsx("code",{children:"description"})," seed your listing, and the icon set here is what the store and toolbar render."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"manifest_version: 3"}),t.jsx("span",{className:"chip",children:"version strictly increases"}),t.jsx("span",{className:"chip",children:"minimum_chrome_version set"})]}),t.jsx(Ae,{assistKey:"manifest-versioning",topicName:"Manifest & versioning"}),t.jsx(Ie,{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:e})]})}const zZ=Object.freeze(Object.defineProperty({__proto__:null,ManifestVersioningScreen:B_},Symbol.toStringTag,{value:"Module"}));function W_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(pt,{size:26}),title:"Submit for review",meta:"About 15 minutes · then a review wait",onBack:e,assistKey:"submit-review"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Packaging & submitting"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Put manifest.json at the zip root.",children:["The ",t.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."]}),t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"What to expect"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx(Jt,{linkKey:"chrome.devConsole",label:"Upload and submit in the developer dashboard"}),t.jsx(Ho,{}),t.jsx(Ae,{assistKey:"submit-review",topicName:"Submit for review"}),t.jsx(Ie,{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:e})]})}const BZ=Object.freeze(Object.defineProperty({__proto__:null,SubmitReviewScreen:W_},Symbol.toStringTag,{value:"Module"})),$4=[{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 ${Ee("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 ${Ee("chromeStore.fee").value} developer account if you want the unlisted-listing path (link-shareable, auto-updating, and trusted by Chrome).`}];function H_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{icon:t.jsx(pt,{size:26}),title:"Share with testers",meta:"About 10 minutes · no public listing",onBack:e,assistKey:"share-testing"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Load unpacked (zip handoff)"}),t.jsxs(Ne,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Put manifest.json at the zip root.",children:["The ",t.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."]}),t.jsxs($,{lead:"Know the trade-offs.",children:["There is ",t.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."]})]}),t.jsx(Vn,{assistKey:"share-testing",topicName:"Share with testers",goalId:"zip-load-unpacked",buttonLabel:'Ask AI to help with the "Load Unpacked (Zip Handoff)" goal'}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Unlisted / private Web Store listing"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Upload to the store, but hide it.",children:["You still upload to the Chrome Web Store, but set visibility to"," ",t.jsx("b",{children:"Unlisted"})," (link-shareable, not discoverable in search) or"," ",t.jsx("b",{children:"Private"})," (restricted to named testers). Anyone with the link installs in one click — no Developer mode, no warning."]}),t.jsx($,{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."}),t.jsxs($,{lead:"It still needs the one-time developer account.",children:["An unlisted listing requires the same"," ",t.jsx("b",{children:Ee("chromeStore.fee").value})," developer registration as a public one (see the ",t.jsx("b",{children:"Store accounts"})," topic). An unlisted listing also still goes through review — it just isn't publicly discoverable once approved."]})]}),t.jsx(Jt,{linkKey:"chrome.devConsole",label:"Upload an unlisted build in the developer dashboard"}),t.jsx(Vn,{assistKey:"share-testing",topicName:"Share with testers",goalId:"unlisted-listing",buttonLabel:'Ask AI to help with the "Unlisted / Private Web Store Listing" goal'}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Self-hosted .crx + update_url (advanced)"}),t.jsxs(Ne,{children:[t.jsxs($,{lead:"Host the packed .crx and an update manifest.",children:["Pack the extension to a ",t.jsx("code",{children:".crx"}),", host it alongside an update manifest, and point the manifest's ",t.jsx("code",{children:"update_url"})," at it. This is the only path that needs no store account at all."]}),t.jsxs($,{lead:"Chrome blocks off-store .crx for ordinary users.",children:["For a normal browser profile, Chrome refuses to install an off-store",t.jsx("code",{children:".crx"}),". This path really exists for"," ",t.jsx("b",{children:"managed / enterprise"})," force-install via admin policy (e.g. a company's device management) — not for casual beta testers."]})]}),t.jsx(Vn,{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'}),t.jsx(Nt,{items:$4}),t.jsx(Ho,{}),t.jsx(Ie,{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:e})]})}const WZ=Object.freeze(Object.defineProperty({__proto__:null,ExtensionDistributionScreen:H_},Symbol.toStringTag,{value:"Module"}));function Qn({tone:e="cost",title:n,children:s}){const r=e==="wait"?"⏳":e==="size"?"⬇":"$";return t.jsxs("div",{className:"sd-callout "+e,children:[t.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:r}),t.jsxs("div",{children:[t.jsx("div",{className:"sd-callout-t",children:n}),t.jsx("div",{className:"sd-callout-b",children:s})]})]})}function $t({store:e,badge:n,enrollUrl:s,enrollLabel:r,children:a}){const o=e==="ios"?"Apple App Store":"Google Play",i=e==="ios"?"":"▶";return t.jsxs("div",{className:"sd-store "+e,children:[t.jsx("div",{className:"sd-store-mark","aria-hidden":"true",children:i}),t.jsxs("div",{className:"sd-store-body",children:[t.jsxs("div",{className:"sd-store-top",children:[t.jsx("span",{className:"sd-store-name",children:o}),t.jsx("span",{className:"sd-store-badge",children:n})]}),t.jsx("div",{className:"sd-store-desc",children:a}),s&&t.jsx("a",{className:"sd-store-enroll",href:s,target:"_blank",rel:"noreferrer noopener",children:r??"Enrol →"})]})]})}function Zn({items:e}){return t.jsx("div",{className:"sd-checks",children:e.map((n,s)=>t.jsxs("div",{className:"sd-check",children:[t.jsx(ft,{}),t.jsx("span",{children:n})]},s))})}const HZ=Object.freeze(Object.defineProperty({__proto__:null,CheckList:Zn,CostCallout:Qn,StoreCard:$t},Symbol.toStringTag,{value:"Module"}));function vs(e){return e==="ios"||e==="both"}function Ks(e){return e==="android"||e==="both"}const wf=["swift","swiftui","ios","uikit"],_f=["kotlin","android","jetpack-compose"];function Sf(e,n){return e&&!n?"ios":n&&!e?"android":null}function F4(e){if(!e)return"both";const n=e.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(e.framework??"").toLowerCase();if(s){const a=Sf(wf.some(o=>s.includes(o)),_f.some(o=>s.includes(o)));if(a)return a}const r=String(e.id??"").toLowerCase().split("-");if(r.some(Boolean)){const a=Sf(wf.some(o=>r.includes(o)),_f.some(o=>r.includes(o)));if(a)return a}return"both"}function q_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=vs(e),i=Ks(e),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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(ot,{size:26}),title:"Developer accounts",meta:"One-time setup · paid · about 20 minutes",assistKey:"dev-accounts"}),t.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."}),t.jsxs(Qn,{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.":""]}),t.jsx("div",{className:"seclabel",children:"What to set up"}),o?t.jsxs($t,{store:"ios",badge:Ee("appleDeveloper.fee").value,enrollUrl:"https://developer.apple.com/programs/enroll/",enrollLabel:"Enrol in the Apple Developer Program →",children:["Enrol in the ",t.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 ",t.jsx("b",{children:"up to ~2 weeks"}),", so start this well before your planned launch."]}):null,i?t.jsxs($t,{store:"android",badge:Ee("googlePlay.fee").value,enrollUrl:"https://play.google.com/console/signup",enrollLabel:"Open Google Play Console signup →",children:["Register for the ",t.jsx("b",{children:"Google Play Console"})," at play.google.com/console. The fee is one-time, not yearly. ",Ee("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,t.jsx(Qn,{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."}),t.jsx(Nt,{items:c}),t.jsx(Ae,{assistKey:"dev-accounts",topicName:"Developer accounts"}),t.jsx(Ie,{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 qZ=Object.freeze(Object.defineProperty({__proto__:null,DevAccountsScreen:q_},Symbol.toStringTag,{value:"Module"}));function U_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=vs(e),i=Ks(e),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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(It,{size:26}),title:"Store assets",meta:"Design work · about 1–2 hours",assistKey:"store-assets"}),t.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."}),t.jsx("div",{className:"seclabel",children:"The essentials, everywhere"}),t.jsx(Zn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Screenshots"})," — captured on the exact device sizes each store asks for, not scaled-up phone shots."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"No placeholder art"}),' — "lorem ipsum" screens and stock icons are the most common rejection reason.']})]}),t.jsx("div",{className:"seclabel",children:"Per store"}),o?t.jsxs($t,{store:"ios",badge:Ee("appleScreenshots.iphone").value,children:["The App Store's primary iPhone set is now the ",t.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 ",Ee("appleScreenshots.ipad").value," master. App previews (short videos) are optional but help conversion."]}):null,i?t.jsxs($t,{store:"android",badge:"512×512 icon + feature graphic",children:["Google Play needs a ",t.jsx("b",{children:"512×512"})," icon (not the 1024×1024 iOS master), a 1024×500 ",t.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,t.jsx(Nt,{items:c}),t.jsx(Ae,{assistKey:"store-assets",topicName:"Store assets"}),t.jsx(Ie,{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 UZ=Object.freeze(Object.defineProperty({__proto__:null,StoreAssetsScreen:U_},Symbol.toStringTag,{value:"Module"}));function G_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=vs(e),i=Ks(e);return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(nt,{size:26}),title:"Store listing",meta:"Writing + forms · about 45 minutes",assistKey:"store-listing"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Write these"}),t.jsx(Zn,{items:[t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Title & subtitle"})," — clear over clever. The first few words are what shows in search results."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Description"})," — lead with what the app does and who it's for; keep the keyword-stuffing out, both stores penalise it."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Category"})," — pick the one your app actually fits; it affects where you rank."]})]}),t.jsx("div",{className:"seclabel",children:"Privacy is required now"}),o?t.jsxs($t,{store:"ios",badge:"Nutrition labels",children:["Apple's ",t.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?t.jsxs($t,{store:"android",badge:"Data safety form",children:["Google Play's ",t.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,t.jsx(Ae,{assistKey:"store-listing",topicName:"Store listing"}),t.jsx(Ie,{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 GZ=Object.freeze(Object.defineProperty({__proto__:null,StoreListingScreen:G_},Symbol.toStringTag,{value:"Module"}));function Y_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=vs(e),i=Ks(e),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:Ee("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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(pt,{size:26}),title:"Testing & distribution",meta:"Build + review · hours to days",assistKey:"testing-distribution"}),t.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."}),t.jsxs(Qn,{tone:"size",title:"First native build pulls a large SDK",children:["Producing a real device build downloads the platform toolchain — often",t.jsx("b",{children:" 8–12 GB"})," and ",t.jsx("b",{children:"10–30 minutes"})," the first time. Run the iOS pre-flight checks in ",t.jsx("code",{children:"MOBILE_SETUP.md"})," before you kick it off so a missing platform SDK surfaces in seconds, not ten minutes in."]}),t.jsx("div",{className:"seclabel",children:"Get a build to testers"}),o?t.jsxs(t.Fragment,{children:[t.jsxs($t,{store:"ios",badge:"TestFlight",children:["Upload to ",t.jsx("b",{children:"TestFlight"})," from Xcode or your CI. Internal testers (up to 100 on your team) get builds instantly; ",t.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.`]}),t.jsx(Vn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-testflight",buttonLabel:"Ask AI to help: Prep a TestFlight upload"})]}):null,i?t.jsxs(t.Fragment,{children:[t.jsxs($t,{store:"android",badge:"Internal testing",children:["Use a Play Console ",t.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: ",Ee("playStore.closedTestGate").value," ","(the 14-day clock resets below 12). Organisation accounts are generally not subject to this."]}),t.jsx(Vn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-play-internal",buttonLabel:"Ask AI to help: Set up Play internal testing"})]}):null,t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Get ready for store review"}),t.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."}),t.jsxs(Qn,{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 ",t.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."]}),t.jsx(Vn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-store-review",buttonLabel:"Ask AI to help: Get ready for store review"}),t.jsx(Nt,{items:c}),t.jsx(Ie,{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 YZ=Object.freeze(Object.defineProperty({__proto__:null,TestingDistributionScreen:Y_},Symbol.toStringTag,{value:"Module"}));function V_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=vs(e),i=Ks(e),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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(gu,{size:26}),title:"Push notifications",meta:"Optional · about 1 hour",assistKey:"push-notifications"}),t.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."}),t.jsx("div",{className:"seclabel",children:"The delivery services"}),o?t.jsxs($t,{store:"ios",badge:"APNs",children:["Apple's ",t.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?t.jsxs($t,{store:"android",badge:"FCM",children:["Google's ",t.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,t.jsx("div",{className:"seclabel",children:"Get this right"}),t.jsx(Zn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Make them opt-in and useful."})," Noisy notifications get your app muted or uninstalled."]}),t.jsxs(t.Fragment,{children:[t.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."]})]}),t.jsx(Nt,{items:c}),t.jsx(Ae,{assistKey:"push-notifications",topicName:"Push notifications"}),t.jsx(Ie,{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 VZ=Object.freeze(Object.defineProperty({__proto__:null,PushNotificationsScreen:V_},Symbol.toStringTag,{value:"Module"}));function K_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(Xt,{size:26}),title:"Crash reporting",meta:"Recommended · about 30 minutes",assistKey:"crash-reporting"}),t.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."}),t.jsx("div",{className:"seclabel",children:"What you'll get"}),t.jsx(Zn,{items:[t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Stack traces"})," pointing at the exact line that failed, grouped so you see which crash hits the most people first."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Device context"})," — OS version, model, and steps — so you can reproduce instead of guessing."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Trends over time"})," so you can tell whether a release made things better or worse."]})]}),t.jsx("div",{className:"seclabel",children:"Common tools"}),t.jsxs("p",{className:"lead dim",children:[t.jsx("b",{children:"Firebase Crashlytics"})," (free, works on both platforms) and"," ",t.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."]}),t.jsxs("div",{className:"sd-callout size",children:[t.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:"⬇"}),t.jsxs("div",{children:[t.jsx("div",{className:"sd-callout-t",children:"Upload your symbols, or reports are noise"}),t.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."})]})]}),t.jsx(Ae,{assistKey:"crash-reporting",topicName:"Crash reporting"}),t.jsx(Ie,{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 KZ=Object.freeze(Object.defineProperty({__proto__:null,CrashReportingScreen:K_},Symbol.toStringTag,{value:"Module"}));function J_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=vs(e),i=Ks(e),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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(kn,{size:26}),title:"In-app purchases & subscriptions",meta:"When you sell inside the app · about 30 minutes",assistKey:"in-app-purchases"}),t.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 ",t.jsx("i",{children:"their"})," billing, take a cut, and reject apps that route around it. Getting this right early saves a painful rewrite later."]}),t.jsx(Qn,{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."}),t.jsx("div",{className:"seclabel",children:"What you'll wire up"}),o?t.jsxs($t,{store:"ios",badge:Ee("appStore.commission").value,children:["Use ",t.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 ",Ee("appStore.commission").value,"."," ",t.jsx(Xn,{fact:Ee("appStore.commission")})]}):null,i?t.jsxs($t,{store:"android",badge:Ee("googlePlay.commission").value,children:["Use the ",t.jsx("b",{children:"Google Play Billing Library"})," to define products in the Play Console and launch the billing flow. Google's service fee is"," ",Ee("googlePlay.commission").value,"."," ",t.jsx(Xn,{fact:Ee("googlePlay.commission")})]}):null,t.jsx("div",{className:"seclabel",children:"The rule that gets apps rejected"}),t.jsx(Zn,{items:[t.jsxs(t.Fragment,{children:[t.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.']}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Verify entitlements server-side."})," Validate the receipt or purchase token on your backend before unlocking — never trust the client alone."]})]}),t.jsx(Nt,{items:c}),t.jsx(Ae,{assistKey:"in-app-purchases",topicName:"In-app purchases & subscriptions"}),t.jsx(Ie,{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 JZ=Object.freeze(Object.defineProperty({__proto__:null,InAppPurchasesScreen:J_},Symbol.toStringTag,{value:"Module"}));function X_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=vs(e),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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(ot,{size:26}),title:"App privacy & tracking",meta:"Submission gate · about 30 minutes",assistKey:"app-privacy"}),t.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.`}),t.jsx("div",{className:"seclabel",children:"The gates that apply everywhere"}),t.jsx(Zn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",children:"iOS only — the tracking prompt"}),t.jsxs(Qn,{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"," ",t.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,t.jsx(Nt,{items:i}),t.jsx(Ae,{assistKey:"app-privacy",topicName:"App privacy & tracking"}),t.jsx(Ie,{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 XZ=Object.freeze(Object.defineProperty({__proto__:null,AppPrivacyScreen:X_},Symbol.toStringTag,{value:"Module"}));function Q_({platform:e="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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Pe,{onBack:n,icon:t.jsx(nt,{size:26}),title:"Getting through review",meta:"Before you submit · about 20 minutes",assistKey:"app-review"}),t.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."}),t.jsx(Qn,{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."}),t.jsx("div",{className:"seclabel",children:"Clear these before submitting"}),t.jsx(Zn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]})]}),t.jsx(Nt,{items:o}),t.jsx(Ae,{assistKey:"app-review",topicName:"Getting through review"}),t.jsx(Ie,{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 QZ=Object.freeze(Object.defineProperty({__proto__:null,AppReviewScreen:Q_},Symbol.toStringTag,{value:"Module"})),Ui={rows:[],total:0,truncated:!1,repo:null,screenshotsRepoRelDir:"",loading:!1,error:null};function z4(e){const[n,s]=l.useState(Ui),r=(e==null?void 0:e.from)??null,a=(e==null?void 0:e.to)??null;return l.useEffect(()=>{if(r===null||a===null){s(Ui);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({...Ui,error:c instanceof Error?c.message:"Failed to load range"})}),()=>{o=!0}},[r,a]),n}function B4(e){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 e){if(!u.entry){d++;continue}c++;const p=u.entry.type||"other";n[p]=(n[p]??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 h of xd(u.entry.modifiedFiles??[]))o.add(h.path);for(const h of u.entry.scenarioScreenshots??[])a.has(h.name)||(a.add(h.name),i.push(h))}return{totalChanges:c,byType:n,testFilesTouched:o.size,testTotals:s,screenshots:i,contributors:[...r],hiddenCommitOnlyCount:d}}const W4=[{key:"all-time",label:"All time",shortLabel:"All time"},{key:"last-24h",label:"Last 24 hours",shortLabel:"24h"},{key:"last-3d",label:"Last 3 days",shortLabel:"3 days"},{key:"last-week",label:"Last week",shortLabel:"Week"},{key:"last-month",label:"Last month",shortLabel:"Month"}],Ca=864e5;function H4(e,n){const s=n.toISOString();switch(e){case"last-24h":return{from:new Date(n.getTime()-Ca).toISOString(),to:s};case"last-3d":return{from:new Date(n.getTime()-3*Ca).toISOString(),to:s};case"last-week":return{from:new Date(n.getTime()-7*Ca).toISOString(),to:s};case"last-month":return{from:new Date(n.getTime()-30*Ca).toISOString(),to:s};case"all-time":case"custom":return null}}function q4(e){const n=new Date(e.from),s=new Date(e.to);if(isNaN(n.getTime())||isNaN(s.getTime()))return`${e.from} – ${e.to}`;const r=p=>p.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 Z_({selection:e,onChange:n,now:s=new Date,counts:r}){const[a,o]=l.useState(""),[i,c]=l.useState(""),[d,u]=l.useState(e.preset==="custom"),p=g=>{u(!1),n({preset:g,range:H4(g,s)})},h=(g,x)=>{o(g),c(x),g&&x&&n({preset:"custom",range:{from:new Date(`${g}T00:00:00Z`).toISOString(),to:new Date(`${x}T23:59:59Z`).toISOString()}})},f=e.preset==="custom"||d,m="rounded-md border border-white/10 bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]";return t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:Qr,role:"group","aria-label":"Time range",children:W4.map(g=>{const x=e.preset===g.key;return t.jsx("button",{type:"button",title:g.label,onClick:()=>p(g.key),"aria-pressed":x,className:Gs(x,"compact"),children:g.shortLabel},g.key)})}),t.jsx("button",{type:"button",onClick:()=>u(g=>!g),"aria-expanded":d,className:`cursor-pointer rounded-md px-2 py-1 text-[12.5px] transition ${f?"text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`,children:"Pick dates"}),r&&t.jsx(U4,{counts:r})]}),d&&t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-[var(--text-dim)]",children:["From",t.jsx("input",{type:"date","aria-label":"Custom range start",value:a,onChange:g=>h(g.target.value,i),className:m})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-[var(--text-dim)]",children:["To",t.jsx("input",{type:"date","aria-label":"Custom range end",value:i,onChange:g=>h(a,g.target.value),className:m})]})]})]})}function U4({counts:e}){const{builds:n,commits:s,total:r}=e,a=r===void 0?s:Math.max(r,s),o=r===void 0?`${s} commit${s===1?"":"s"}`:`${s} of ${a} commit${a===1?"":"s"}`;return t.jsxs("p",{"data-testid":"history-count",className:"ml-auto text-xs text-[var(--text-dim)] tabular-nums",children:[n>0&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[n," build",n===1?"":"s"]}),t.jsx("span",{"aria-hidden":!0,children:" · "})]}),t.jsx("span",{children:o})]})}const ZZ=Object.freeze(Object.defineProperty({__proto__:null,HistoryRangeSelector:Z_},Symbol.toStringTag,{value:"Module"}));function G4(e){const{rangeLabel:n,summary:s,rows:r,repo:a,screenshotsRepoRelDir:o}=e,i=(a==null?void 0:a.rawUrlTemplate)??null,c=[];c.push(`# Change digest — ${n}`),c.push(""),c.push(Y4(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 p=u.entry;c.push(""),c.push(`## ${p.title}`),c.push(""),c.push(`- **Type:** ${p.type}`),c.push(`- **Commit:** \`${u.commit.shortSha}\``),p.description&&(c.push(""),c.push(p.description));const h=xd(p.modifiedFiles??[]);if(h.length>0){c.push(""),c.push("**Test files:**");for(const m of h)c.push(`- \`${m.path}\``)}const f=p.scenarioScreenshots??[];if(f.length>0)if(c.push(""),i)for(const m of f){if(!m.screenshotPath)continue;const g=i.replace("{sha}",u.commit.sha).replace("{path}",V4(o,m.screenshotPath));c.push(``)}else{c.push("**Screenshots (local only):**");for(const m of f)c.push(`- ${m.name}`)}}return c.join(`
|
|
51
|
-
`)}function Y4(e){const n=[];n.push(`**${e.totalChanges}** change${e.totalChanges===1?"":"s"}`);const s=Object.entries(e.byType).map(([r,a])=>`${a} ${r}`);return s.length>0&&n.push(s.join(", ")),n.push(`${e.testFilesTouched} test file${e.testFilesTouched===1?"":"s"}`),e.testTotals.total>0&&n.push(`${e.testTotals.passed}/${e.testTotals.total} tests passed`),n.push(`${e.screenshots.length} screenshot${e.screenshots.length===1?"":"s"}`),n.join(" · ")}function V4(e,n){const s=e.replace(/\/+$/,""),r=n.replace(/^\/+/,"");return s?`${s}/${r}`:r}function e0({summary:e}){return t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[t.jsxs("span",{className:"text-[var(--text-primary)]",children:[e.totalChanges," change",e.totalChanges===1?"":"s"]}),Object.entries(e.byType).map(([n,s])=>t.jsxs("span",{className:Ag(n),children:[s," ",n]},n)),t.jsxs("span",{className:"text-[var(--text-muted)]",children:[e.testFilesTouched," test file",e.testFilesTouched===1?"":"s"]}),t.jsx(Oo,{total:e.testTotals.total,passed:e.testTotals.passed,failed:e.testTotals.failed}),t.jsxs("span",{className:"text-[var(--text-muted)]",children:[e.screenshots.length," screenshot",e.screenshots.length===1?"":"s"]}),e.contributors.length>0&&t.jsx("span",{className:"text-[var(--text-dim)]",children:e.contributors.join(", ")})]})}const eee=Object.freeze(Object.defineProperty({__proto__:null,HistoryDigestStatRow:e0},Symbol.toStringTag,{value:"Module"}));function t0({rangeLabel:e,summary:n,rows:s,repo:r,screenshotsRepoRelDir:a,truncated:o,onPreviewScreenshot:i}){const[c,d]=l.useState(!1),u=Rg(s),p=async()=>{const h=G4({rangeLabel:e,summary:n,rows:s,repo:r,screenshotsRepoRelDir:a});try{await navigator.clipboard.writeText(h),d(!0),setTimeout(()=>d(!1),2e3)}catch{}};return n.totalChanges===0?t.jsxs("div",{children:[t.jsx(Ql,{rangeLabel:e,onCopy:p,copied:c}),t.jsxs("div",{className:"py-10 text-center text-[var(--text-dim)]",children:[t.jsx("p",{children:"No changes in this window."}),n.hiddenCommitOnlyCount>0&&t.jsxs("p",{className:"mt-2 text-xs",children:[n.hiddenCommitOnlyCount," non-journaled commit",n.hiddenCommitOnlyCount===1?"":"s"," hidden."]})]})]}):t.jsxs("div",{children:[t.jsx(Ql,{rangeLabel:e,onCopy:p,copied:c}),t.jsx(e0,{summary:n}),n.hiddenCommitOnlyCount>0&&t.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&&t.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&&t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"mb-1 text-xs font-medium text-[var(--text-muted)]",children:"Screenshots"}),t.jsx(ow,{screenshots:n.screenshots,onSelect:i?h=>i({...h,isLatest:u.get(h.name)===K4(s,h.name)}):void 0})]}),t.jsx("div",{className:"flex flex-col gap-3",children:s.map((h,f)=>h.entry?t.jsx(Eo,{entry:h.entry,commit:h.commit,onSelectScreenshot:i?m=>i({...m,isLatest:u.get(m.name)===f}):void 0},h.commit.sha):null)})]})}function Ql({rangeLabel:e,onCopy:n,copied:s}){return t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-primary)]",children:e}),t.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 K4(e,n){return e.findIndex(s=>{var r;return(((r=s.entry)==null?void 0:r.scenarioScreenshots)??[]).some(a=>a.name===n)})}const tee=Object.freeze(Object.defineProperty({__proto__:null,DigestHeader:Ql,HistoryDigest:t0},Symbol.toStringTag,{value:"Module"}));function n0(){return t.jsxs("div",{className:"mb-4",children:[t.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:"History"}),t.jsx("p",{className:"mt-1 text-sm text-[var(--text-dim)]",children:"Everything built in this project, newest first."})]})}function s0({onPreviewScreenshot:e,onRunPlan:n}={}){const[s,r]=l.useState({preset:"all-time",range:null}),[a,o]=l.useState(void 0);return t.jsxs(Kt,{children:[t.jsx(n0,{}),t.jsx(Z_,{selection:s,onChange:r,counts:a}),s.range?t.jsx(J4,{range:s.range,onPreviewScreenshot:e,onCounts:o}):t.jsx(Yg,{onPreviewScreenshot:e,onRunPlan:n,onCounts:o})]})}function J4({range:e,onPreviewScreenshot:n,onCounts:s}){const{rows:r,truncated:a,repo:o,screenshotsRepoRelDir:i,loading:c,error:d}=z4(e);if(Gg(s,c||d?null:r),c)return t.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading digest..."});if(d)return t.jsx("div",{className:"py-12",children:t.jsx(dt,{text:`Failed to load digest: ${d}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});const u=B4(r);return t.jsx(t0,{rangeLabel:q4(e),summary:u,rows:r,repo:o,screenshotsRepoRelDir:i,truncated:a,onPreviewScreenshot:n})}const nee=Object.freeze(Object.defineProperty({__proto__:null,HistoryTab:s0,HistoryTabHeader:n0},Symbol.toStringTag,{value:"Module"})),r0=1,hr={sound:"soft-double-tap",systemNotification:!0,idleOnStop:!0,idleOnNotification:!0,settingsVersion:r0},Zl=[{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"}],a0="codeyam-editor-notifications";function o0(){try{const e=localStorage.getItem(a0);if(!e)return hr;const n=JSON.parse(e),s={...hr,...n};return typeof(n==null?void 0:n.settingsVersion)!="number"&&(s.idleOnStop=hr.idleOnStop,s.settingsVersion=r0),s}catch{return hr}}function i0(e){localStorage.setItem(a0,JSON.stringify(e))}const X4={"soft-double-tap":e=>([0,.12].forEach(n=>{const s=e.createOscillator(),r=e.createGain();s.connect(r),r.connect(e.destination),s.type="sine",s.frequency.value=392,r.gain.setValueAtTime(.25,e.currentTime+n),r.gain.exponentialRampToValueAtTime(.01,e.currentTime+n+.1),s.start(e.currentTime+n),s.stop(e.currentTime+n+.1)}),{count:2,longestStopSec:.22}),"gentle-chime":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="sine",n.frequency.setValueAtTime(523,e.currentTime),n.frequency.setValueAtTime(659,e.currentTime+.15),s.gain.setValueAtTime(.3,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.4),n.start(),n.stop(e.currentTime+.4),{count:1,longestStopSec:.4}},"warm-ding":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="sine",n.frequency.value=330,s.gain.setValueAtTime(.35,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.6),n.start(),n.stop(e.currentTime+.6),{count:1,longestStopSec:.6}},"mellow-two-tone":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="sine",n.frequency.setValueAtTime(294,e.currentTime),n.frequency.setValueAtTime(440,e.currentTime+.18),s.gain.setValueAtTime(.3,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.5),n.start(),n.stop(e.currentTime+.5),{count:1,longestStopSec:.5}},"triangle-bell":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="triangle",n.frequency.value=523,s.gain.setValueAtTime(.4,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.8),n.start(),n.stop(e.currentTime+.8),{count:1,longestStopSec:.8}}};function Gi(e,n){const s=n;me(e,{name:s==null?void 0:s.name,message:s==null?void 0:s.message})}function Ou(e){if(e==="off")return;me("audio-playsound-entered",{soundId:e});let n;try{n=new AudioContext}catch(r){Gi("audio-context-failed",r);return}me("audio-context-created",{state:n.state});const s=()=>{let r;try{r=X4[e](n)}catch(a){Gi("audio-context-failed",a),n.close().catch(()=>{});return}me("audio-oscillators-scheduled",{soundId:e,count:r.count,longestStopSec:r.longestStopSec}),setTimeout(()=>{n.close().then(()=>me("audio-context-closed")).catch(()=>{})},(r.longestStopSec+.1)*1e3)};n.state==="running"?s():n.state==="suspended"?(me("audio-context-resume-attempted"),n.resume().then(()=>{me("audio-context-resume-ok",{state:n.state}),s()},r=>{Gi("audio-context-resume-failed",r),n.close().catch(()=>{})})):(me("audio-context-failed",{name:"UnexpectedState",message:`AudioContext state "${n.state}"`}),n.close().catch(()=>{}))}function ec({label:e,checked:n,onChange:s,className:r}){return t.jsxs("label",{className:`flex items-center gap-2 cursor-pointer${r?` ${r}`:""}`,children:[t.jsx("input",{type:"checkbox",checked:n,onChange:a=>s(a.target.checked),className:"accent-green-500"}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:e})]})}const see=Object.freeze(Object.defineProperty({__proto__:null,IdleTriggerCheckbox:ec},Symbol.toStringTag,{value:"Module"}));function l0({settings:e,onChange:n,providerLabel:s,soundAsSubmenu:r=!1}){var u;const a=e.idleOnStop??!0,o=e.idleOnNotification??!0,[i,c]=l.useState(!1),d=t.jsx("div",{className:"flex flex-col gap-0.5",children:Zl.map(p=>t.jsx("button",{onClick:()=>{n({...e,sound:p.id}),p.id!=="off"&&Ou(p.id)},className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors whitespace-nowrap",style:{background:e.sound===p.id?"var(--bg-input)":"transparent",color:e.sound===p.id?"var(--text-primary)":"var(--text-secondary)"},children:p.label},p.id))});return t.jsxs(t.Fragment,{children:[r?t.jsxs("div",{className:"relative",children:[t.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,"data-testid":"notification-sound-row",onClick:()=>c(p=>!p),className:"w-full flex items-center gap-2 text-[11px] px-2 py-1 rounded cursor-pointer transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Sound"}),t.jsx("span",{className:"ml-auto truncate",style:{color:"var(--text-primary)"},children:((u=Zl.find(p=>p.id===e.sound))==null?void 0:u.label)??""}),t.jsx("span",{"aria-hidden":"true",children:"›"})]}),i&&t.jsx("div",{role:"menu","data-testid":"notification-sound-menu",className:"absolute right-full top-0 mr-2 rounded-lg shadow-xl p-2 z-50",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:d})]}):t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Notification sound"}),d]}),t.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[t.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Trigger idle on"}),t.jsx(ec,{label:`${s} stops`,checked:a,onChange:p=>n({...e,idleOnStop:p})}),t.jsx(ec,{label:`${s} sends a notification`,checked:o,onChange:p=>n({...e,idleOnNotification:p}),className:"mt-1"})]}),t.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.systemNotification,onChange:p=>{const h=p.target.checked;n({...e,systemNotification:h}),h&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"System notification"})]}),t.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"&&t.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 ree=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsControls:l0},Symbol.toStringTag,{value:"Module"})),c0="codeyam-editor-notifications-prompted",Q4="codeyam-editor-notifications";function d0(){try{localStorage.setItem(c0,"1")}catch{}}function Z4(){try{return localStorage.getItem(c0)!==null||localStorage.getItem(Q4)!==null}catch{return!0}}function u0({settings:e,onChange:n,providerLabel:s}){const[r,a]=l.useState(()=>!Z4());if(!r)return null;const o=()=>{d0(),a(!1)},i=()=>{n({...e,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission(),o()};return t.jsxs("div",{className:"rounded-lg px-4 py-2.5 mb-3 flex items-center gap-3",style:{background:"color-mix(in srgb, var(--blue-300) 7%, var(--surface-card))",border:"1px solid color-mix(in srgb, var(--blue-300) 45%, transparent)"},children:[t.jsx("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--blue-300)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:"M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3H4a4 4 0 0 0 2-3v-3a7 7 0 0 1 4-6M9 17v1a3 3 0 0 0 6 0v-1"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-strong)"},children:["Get notified when ",s," finishes"]}),t.jsx("span",{style:{fontSize:"12px",color:"var(--text-faint)",marginLeft:8},children:"We'll ping you when the agent stops or pauses."})]}),t.jsx("button",{onClick:i,className:"shrink-0 cursor-pointer transition-colors",style:{background:"var(--blue-300)",color:"var(--surface-page)",fontSize:"12.5px",fontWeight:600,borderRadius:9,padding:"7px 14px"},children:"Enable"}),t.jsx("button",{onClick:o,className:"shrink-0 cursor-pointer",style:{color:"var(--text-faint)",fontSize:"12px"},children:"Not now"})]})}const aee=Object.freeze(Object.defineProperty({__proto__:null,NotificationSetupBanner:u0},Symbol.toStringTag,{value:"Module"})),e3="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 t3(){const e=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:e,hasFocus:n,hidden:s,idleDebug:r,userAgent:a}}function kf(e){return e.length===0?"_(no events in window)_":`\`\`\`jsonl
|
|
52
|
-
${e.map(s=>JSON.stringify(s)).join(`
|
|
53
|
-
`)}
|
|
54
|
-
\`\`\``}function Yi(e,n){return e.trim().length===0?`_(${n} empty)_`:`\`\`\`
|
|
55
|
-
${e}
|
|
56
|
-
\`\`\``}function n3(e){var b,y,v;const{bundle:n,browser:s,uiBufferText:r,prompt:a,agentName:o}=e,i=(n==null?void 0:n.now)??new Date().toISOString(),c=(n==null?void 0:n.session)??pd(),d=(n==null?void 0:n.windowMinutes)??10,u=((b=n==null?void 0:n.environment)==null?void 0:b.editorVersion)??"unknown",p=((y=n==null?void 0:n.environment)==null?void 0:y.platform)??"unknown",h=((v=n==null?void 0:n.environment)==null?void 0:v.projectDir)??"unknown",f=(a??e3).trim(),m=[`- 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(`
|
|
57
|
-
`),g=n&&n.truncations.length>0?`> **Truncations:** ${n.truncations.join("; ")}`:"";return["# CodeYam Notification Debug Bundle","",f,"","---","",`**Captured:** ${i}`,`**UI session:** ${c} (window: last ${d} minutes)`,`**Editor version:** ${u}`,`**Platform:** ${p}`,`**Project:** ${h}`,o?`**Agent:** ${o}`:null,"","**Browser state:**",m,"",g,"","## UI idle trace (persisted)","",kf((n==null?void 0:n.uiTrace)??[]),"","## UI idle trace (in-memory ring buffer — may be ahead of persisted)","",Yi(r,"in-memory buffer"),"","## Rust idle trace","",kf((n==null?void 0:n.rustTrace)??[]),"","## editor-server.log (filtered to idle= within window)","",Yi((n==null?void 0:n.editorServerLog)??"","editor-server.log"),"","## dev-server.log (last lines)","",Yi((n==null?void 0:n.devServerLog)??"","dev-server.log"),""].filter(j=>j!==null).join(`
|
|
58
|
-
`)}async function s3(e={}){const n=encodeURIComponent(pd());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=t3(),o=xE({agentName:e.agentName});return{markdown:n3({bundle:s,browser:a,uiBufferText:o,prompt:e.prompt,agentName:e.agentName}),bundle:s,error:r}}const r3=1500;function a3(e=r3){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??e)},[e]);return l.useEffect(()=>()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),{label:n,flash:a}}const o3=2500;function p0({agentName:e}){const[n,s]=l.useState(!1),{label:r,flash:a}=a3(o3),o=async()=>{s(!0);const{markdown:i,bundle:c,error:d}=await s3({agentName:e});try{await navigator.clipboard.writeText(i);const u=((c==null?void 0:c.uiTrace.length)??0)+((c==null?void 0:c.rustTrace.length)??0),p=Math.round(i.length/1024*10)/10,h=d?`Copied (offline — ${u} events, ${p} KB)`:`Copied ${u} events · ${p} KB`;a(h)}catch{a("Copy failed")}finally{s(!1)}};return t.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 oee=Object.freeze(Object.defineProperty({__proto__:null,DebugNotificationsButton:p0},Symbol.toStringTag,{value:"Module"}));function h0(){const[e,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:e}}function i3(e){return e==="waiting-for-auth"||e==="dispatching"||e==="delayed"||e==="launch-timeout"||e==="unverified"}const l3=3e3;function si(){const[e,n]=l.useState(void 0),[s,r]=l.useState(0);l.useEffect(()=>{let o=!1;return fetch("/api/editor-build-requests/current").then(i=>{if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}).then(i=>{o||n(i.request??null)}).catch(()=>{o||n(null)}),()=>{o=!0}},[s]);const a=i3(e==null?void 0:e.state);return l.useEffect(()=>{if(!a)return;const o=setTimeout(()=>r(i=>i+1),l3);return()=>clearTimeout(o)},[a,e]),e}function f0({appStatsLength:e,configLoading:n,scenariosLoading:s,setupAnswersSaved:r,hasStepState:a}){return e===0&&!n&&!s&&r===!1&&!a}const c3={building:{headline:"Building your project…",explanation:"Your app will appear here as it’s built. The agent is working on it now on the Build tab — open it to follow along."},preparing:{headline:"Starting your build…",explanation:"Your answers are saved and the agent is starting. It keeps going even if you close this tab."},"waiting-for-auth":{headline:"Waiting for you to sign in",explanation:"Your build request is saved. The agent will start on its own as soon as you sign in to your AI provider — no need to come back to this page."},"launch-delayed":{headline:"Your build is taking longer to start",explanation:"Your answers are saved and the agent was started, but it hasn’t picked up its first instruction yet. Nothing has been stopped — it’s still starting."},"launch-timeout":{headline:"Your build hasn’t started yet",explanation:"Your answers are saved and the agent was started, but it still hasn’t picked up its first instruction. You can retry the launch — it never starts a second agent."},failed:{headline:"Your build couldn’t start",explanation:"Your answers are saved, but the agent could not be started. Open the Build tab to try again."},unconfirmed:{headline:"Build status unknown",explanation:"We can’t confirm build status right now — the editor couldn’t reach the process that runs the agent. Open the Build tab to check on it."},interrupted:{headline:"Your build was interrupted",explanation:"A build was started for this project, but it is no longer running. Open the Build tab to resume it or start again."},"not-started":{headline:"Build not started",explanation:"Your answers are saved, but no build is running yet. Open the Build tab to start building your app."}};function m0({projectDescription:e,status:n="not-started",buildRequestedAt:s=null,failureReason:r=null,launchRecovery:a=null}){const{headline:o,explanation:i}=c3[n];return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-xl font-semibold",children:o}),t.jsx("blockquote",{className:"mt-4 border-l-2 border-[var(--accent-active)] pl-4 text-sm italic text-[var(--text-dim)]",children:e}),t.jsx("p",{className:"mt-6 text-sm text-[var(--text-dim)]",children:i}),n==="failed"&&r?t.jsxs("p",{className:"mt-3 text-sm text-[var(--text-primary)]",children:[t.jsx("span",{className:"font-medium",children:"What went wrong:"})," ",r]}):null,a?t.jsx("div",{className:"mt-4",children:a}):null,t.jsx(db,{requestedAt:s})]})}const iee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateBuildingPanel:m0},Symbol.toStringTag,{value:"Module"}));function g0(){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"No app scaffolded yet"}),t.jsxs("p",{className:"mt-4 text-sm text-[var(--text-dim)]",children:["Your project hasn’t been scaffolded yet. Open the"," ",t.jsx("strong",{children:"Build"})," tab to start building."]})]})}const lee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateNoAppPanel:g0},Symbol.toStringTag,{value:"Module"}));function x0({onClick:e}){return t.jsx("button",{type:"button",onClick:e,"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 cee=Object.freeze(Object.defineProperty({__proto__:null,OpenBuildTabButton:x0},Symbol.toStringTag,{value:"Module"}));function b0({projectDescription:e,status:n="not-started",buildRequestedAt:s=null,failureReason:r=null,launchRecovery:a=null,onOpenBuildTab:o}){const i=e!==null&&e.trim().length>0;return t.jsxs("div",{className:"mx-auto max-w-2xl px-5 py-12 text-[var(--text-primary)]",children:[i?t.jsx(m0,{projectDescription:e,status:n,buildRequestedAt:s,failureReason:r,launchRecovery:a}):t.jsx(g0,{}),t.jsx(x0,{onClick:o})]})}const dee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyState:b0},Symbol.toStringTag,{value:"Module"})),d3={"launch-in-flight":"A launch is already under way — give it a moment.","worker-unknown":"The editor couldn’t check whether the agent is still running, so it didn’t start another. Try again shortly.","not-applicable":"This build is no longer waiting to start."};function u3(e){return d3[e??""]??"The retry didn’t start."}function y0(e){const n=(e==null?void 0:e.state)==="delayed"||(e==null?void 0:e.state)==="launch-timeout",[s,r]=l.useState(()=>Date.now()),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),p=(e==null?void 0:e.id)??null;l.useEffect(()=>{if(!n)return;const m=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(m)},[n]),l.useEffect(()=>{c(null),u(null)},[p,e==null?void 0:e.state]);const h=l.useCallback(()=>{p&&(o(!0),c(null),fetch(`/api/editor-build-requests/${p}/retry-launch`,{method:"POST"}).then(m=>m.json()).then(m=>{m.success||c(u3(m.outcome))}).catch(()=>c("The editor couldn’t be reached to retry.")).finally(()=>o(!1)))},[p]),f=l.useCallback(()=>{p&&fetch(`/api/editor-build-requests/${p}/launch-log`).then(m=>m.json()).then(m=>u(m.events??[])).catch(()=>u([]))},[p]);return{waitSeconds:e?tI(e,s):null,onRetry:h,retryPending:a,retryMessage:i,onViewLog:f,launchLog:d}}function v0({stats:e,onSelectApp:n,testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o}){return t.jsx("div",{className:"flex flex-col gap-4",children:e.map(i=>t.jsx(Vj,{stats:i,onClick:()=>n(i.app.dir),testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o},i.app.dir))})}const uee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewGrid:v0},Symbol.toStringTag,{value:"Module"}));function j0({projectTitle:e,coverage:n,onCoverageClick:s}){return t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:e}),t.jsx(fu,{coverage:n,testId:"app-overview-coverage",onClick:s})]})}const pee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewHeader:j0},Symbol.toStringTag,{value:"Module"}));function w0(){return t.jsxs("span",{className:"hbuild-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{children:"."}),t.jsx("span",{children:"."})]})}const hee=Object.freeze(Object.defineProperty({__proto__:null,AnimatedEllipsis:w0},Symbol.toStringTag,{value:"Module"}));function _0({screenshotPath:e}){return t.jsx("span",{className:"hbuild-thumb",children:e?t.jsx(Ot,{screenshotPath:e,alt:""}):t.jsx("span",{className:"hbuild-nothumb",children:"No preview yet"})})}const fee=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardThumbnail:_0},Symbol.toStringTag,{value:"Module"})),p3=28,h3=21,f3=4,m3=5,g3={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"},x3={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"},b3={1:"Triage",2:"Route",3:"Wrap Up",4:"Complete"},y3={1:"Ground",2:"Generate",3:"Iterate",4:"Resolve",5:"Return"},v3={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."},j3={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."},w3={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."},_3={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."},S3={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"},k3={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"},N3={1:"Working out what you need",2:"Deciding how to help",3:"Checking this is what you wanted",4:"All done"},C3={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"},T3=[{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]}],P3=[{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]}],O3=[{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]}],R3=[{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]}],E3={ui:g3,backend:x3,assist:b3,design:y3},A3={ui:v3,backend:j3,assist:w3,design:_3},M3={ui:p3,backend:h3,assist:f3,design:m3},I3={ui:"UI Flow",backend:"Backend Flow",assist:"Assist Flow",design:"Design Round"},D3=["ui","backend","assist","design"];function qt(e){return D3.includes(e)?e:"ui"}function Ru(e,n){return E3[qt(n)][e]??"?"}function S0(e,n){return A3[qt(n)][e]??""}function Eu(e){return M3[qt(e)]}function k0(e){return I3[qt(e)]}function N0(e,n){const s=qt(n);return{description:S0(e,s),label:Ru(e,s),prefix:k0(s),totalSteps:Eu(s)}}const L3={ui:S3,backend:k3,assist:N3,design:C3},$3={ui:T3,backend:P3,assist:O3,design:R3};function C0(e,n){return L3[qt(n)][e]??""}function Au(e){return $3[qt(e)]}function F3(e,n){const s=Au(n);return s.find(a=>a.phaseSteps.includes(e))??s[0]}function z3(e,n){var r;const s=qt(n);return{...Mu(e,s),phaseLabel:((r=F3(e,s))==null?void 0:r.phaseLabel)??"",description:S0(e,s)}}function Mu(e,n){const s=qt(n);return B3(C0(e,s),Ru(e,s))}function B3(e,n){return e===""||e===n?{primary:e||n,secondary:null}:{primary:e,secondary:n}}function T0({position:e,phase:n,mode:s}){return!s&&!e?null:t.jsxs("span",{className:"hbuild-step",children:[s?t.jsx("span",{className:"hbuild-flow",children:k0(s)}):null,e?t.jsxs("span",{className:"hbuild-pos",children:["Step ",e,":"]}):null,n?t.jsx("span",{className:"hbuild-phase",children:n}):null]})}const mee=Object.freeze(Object.defineProperty({__proto__:null,BuildingStepLine:T0},Symbol.toStringTag,{value:"Module"})),W3={building:{state:"Working",ellipsis:!0,attn:!1},"needs-input":{state:so,ellipsis:!1,attn:!0},waiting:{state:so,ellipsis:!1,attn:!0}};function P0({feature:e,stepLabel:n,stepPosition:s=null,status:r="building",progress:a=null,mode:o,thumbnailPath:i=null,onOpen:c}){const d=W3[r],u=r==="building";return t.jsxs("button",{type:"button",className:"hbuild-card active"+(d.attn?" attn":""),onClick:c,children:[t.jsx(_0,{screenshotPath:i}),t.jsxs("span",{className:"hbuild-main",children:[t.jsxs("span",{className:"hbuild-title",children:[u?t.jsx("span",{className:"hbuild-spinner","aria-hidden":"true"}):null,e,t.jsxs("span",{className:"hbuild-state",children:[d.state,d.ellipsis?t.jsx(w0,{}):null]})]}),t.jsx(T0,{position:s,phase:n,mode:o}),u?t.jsx("span",{className:"hbuild-bar",children:t.jsx("span",{style:{width:a!=null?`${Math.round(a*100)}%`:"12%"}})}):null]}),t.jsxs("span",{className:"hbuild-cta",children:["Build ",t.jsx("span",{"aria-hidden":"true",children:"→"})]})]})}const gee=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardActive:P0},Symbol.toStringTag,{value:"Module"}));function O0({lastBuiltLabel:e,onStart:n}){return t.jsxs("button",{type:"button",className:"hbuild-card",onClick:n,children:[t.jsxs("span",{className:"hbuild-main",children:[t.jsx("span",{className:"hbuild-ready",children:"Ready to build?"}),e?t.jsxs("span",{className:"hbuild-last",children:["Your last build: ",t.jsx("b",{children:e})]}):null]}),t.jsxs("span",{className:"hbuild-cta",children:["Build ",t.jsx("span",{"aria-hidden":"true",children:"→"})]})]})}const xee=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardIdle:O0},Symbol.toStringTag,{value:"Module"}));function R0({onReset:e}){return t.jsxs("button",{type:"button","data-testid":"build-status-reset",onClick:e,className:"hbuild-reset",children:[t.jsx("span",{"aria-hidden":"true",children:"⊗"})," Reset build"]})}const bee=Object.freeze(Object.defineProperty({__proto__:null,BuildResetLink:R0},Symbol.toStringTag,{value:"Module"}));function E0({onReset:e}){const[n,s]=l.useState(!1),r=l.useRef(null);return l.useEffect(()=>{if(!n)return;const a=i=>{var c;(c=r.current)!=null&&c.contains(i.target)||s(!1)},o=i=>{i.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",a),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",o)}},[n]),t.jsxs("div",{className:"hbuild-menu",ref:r,children:[t.jsx("button",{type:"button",className:"hbuild-menu-btn","aria-label":"More build actions",title:"More build actions","aria-expanded":n,onClick:()=>s(a=>!a),children:t.jsx("span",{"aria-hidden":"true",children:"···"})}),n?t.jsx("div",{className:"hbuild-menu-pop","data-testid":"build-card-menu",children:t.jsx(R0,{onReset:()=>{s(!1),e()}})}):null]})}const yee=Object.freeze(Object.defineProperty({__proto__:null,BuildCardMenu:E0},Symbol.toStringTag,{value:"Module"}));function Iu({isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,thumbnailPath:c=null,lastBuiltLabel:d,onOpenBuilding:u,onStartNewFeature:p,onResetBuild:h}){return e?t.jsxs("div",{className:"hbuild-wrap"+(h?" has-menu":""),children:[t.jsx(P0,{feature:n||"your latest change",stepLabel:s,stepPosition:r,status:a,progress:o,mode:i,thumbnailPath:c,onOpen:u}),h?t.jsx(E0,{onReset:h}):null]}):t.jsx(O0,{lastBuiltLabel:d,onStart:p??u})}const vee=Object.freeze(Object.defineProperty({__proto__:null,BuildingDoor:Iu},Symbol.toStringTag,{value:"Module"}));function A0({isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,onOpenBuilding:c,onResetBuild:d}){return e?t.jsx("section",{"data-testid":"home-build-status-section",className:"mt-6 mb-6",children:t.jsx(Iu,{isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r,buildingStatus:a,buildingProgress:o,buildingMode:i,onOpenBuilding:c,onStartNewFeature:c,onResetBuild:d})}):null}const jee=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildStatusSection:A0},Symbol.toStringTag,{value:"Module"}));async function Vi(e,n){try{const s=await e.json();if(typeof s.error=="string"&&s.error)return`${n} failed (${e.status}): ${s.error}`}catch{}return`${n} failed (${e.status})`}function Ki(e,n){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function M0(e,n){const s=_g(),r=(o,i,c)=>(xl({launchId:s,role:"build",event:"submit-failed",stage:o,httpStatus:c}),{ok:!1,launchId:s,error:i});let a;try{if(e.description){const u=await Ki("/api/editor-project-info",{projectDescription:e.description,allowOverwrite:!0});if(!u.ok)return r("project-info",await Vi(u,"Saving the description"),u.status)}const o={appFormats:e.appFormats,techStackId:e.techStackId,designApproach:e.designApproach};e.defaultDevice&&(o.defaultDevice=e.defaultDevice);const i=await Ki("/api/editor-setup-answers",o);if(!i.ok)return r("setup-answers",await Vi(i,"Saving the answers"),i.status);const c=await Ki("/api/editor-build-requests",n?{submissionKey:n}:{});if(!c.ok)return r("build-request",await Vi(c,"Recording the build request"),c.status);const d=await c.json();if(typeof d.requestId!="string"||!d.requestId)return r("build-request","The server did not return a request id",c.status);a=d.requestId}catch(o){return r("network",o instanceof Error?o.message:"Could not reach the editor")}return xl({launchId:s,role:"build",event:"submitted"}),xR(s),{ok:!0,launchId:s,requestId:a}}function H3(e,n,s=()=>null){const[r,a]=l.useState(!1),[o,i]=l.useState(null),c=l.useRef(!1);return{submit:l.useCallback(async()=>{if(c.current)return;c.current=!0,a(!0),i(null);const u=await M0(e,s());if(c.current=!1,a(!1),!u.ok){i(u.error);return}n(u.requestId)},[e,n,s]),submitting:r,error:o}}const q3={providerDeclared:!0,providerAuth:"authenticated"};function I0(e){return!e.providerDeclared||e.providerAuth!=="authenticated"}const Nf=["prompt","notifications"];function U3(e,n=q3){const s=I0(n)?["provider",...Nf]:Nf;return e==="files"||e==="chat"?[...s,"design-details"]:s}const D0="codeyam.questionnaire.draft";function L0(e){return`${D0}:${e}`}function $0(e){if(e===null||typeof e!="object")return!1;const n=e;if(typeof n.step!="number"||!Number.isFinite(n.step)||typeof n.savedAt!="string"||n.designChatLaunched!==void 0&&typeof n.designChatLaunched!="boolean"||n.submissionKey!==void 0&&typeof n.submissionKey!="string")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"||r.provider!==void 0&&r.provider!==null&&typeof r.provider!="string")}const Du="/api/editor-questionnaire-draft";async function F0(){try{const e=await fetch(Du);if(!e.ok)return null;const n=await e.json();return $0(n)?n:null}catch{return null}}function G3(e){try{const n=localStorage.getItem(L0(e));if(n===null)return null;const s=JSON.parse(n);return $0(s)?s:null}catch{return null}}function Y3(e){try{localStorage.removeItem(L0(e))}catch{}}async function V3(e){const n=await F0();if(n!==null)return n;const s=G3(e);return s===null?null:(z0(s),Y3(e),s)}function z0(e,n){try{fetch(Du,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(async s=>{if(!s.ok||!n)return;const r=await s.json();typeof r.submissionKey=="string"&&r.submissionKey&&n(r.submissionKey)}).catch(()=>{})}catch{}}function Cf(){try{fetch(Du,{method:"DELETE"}).catch(()=>{})}catch{}}function K3(){try{localStorage.removeItem(D0)}catch{}}function Ji(e,n,s){return JSON.stringify({step:e,answers:n,designChatLaunched:s})}function J3(e,n,s,r){return e===null||e.savedAt<=n?null:{step:e.step,answers:s?r:e.answers,designChatLaunched:e.designChatLaunched??!1,savedAt:e.savedAt}}function X3(){const[e,n]=l.useState([]);return l.useEffect(()=>{fetch("/api/editor-stacks").then(s=>s.json()).then(n).catch(()=>{})},[]),{techStacks:e}}function Q3(e){const n=e.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"}const Z3=1500;function e$(e,n,s){const[r,a]=l.useState(null),[o,i]=l.useState(!1),[c,d]=l.useState(null);return l.useEffect(()=>{const u=setTimeout(()=>i(!0),Z3);return()=>clearTimeout(u)},[]),l.useEffect(()=>{r!==null||e===null||!(n!=="unknown"&&!s)&&!o||(a(I0({providerDeclared:e.providerDeclared,providerAuth:n})),e.providerDeclared&&d(e.provider))},[r,e,o,s,n]),{askForProvider:r,declaredProvider:c}}function t$({selected:e,authProvider:n,authState:s,probeInFlight:r,authReason:a=null}){return e===null||n!==e||r||s==="unknown"?"settling":s==="authenticated"?"connected":a==="credentials-not-persisted"?"signed-in-not-stored":"needs-login"}function n$(e,n){const[s,r]=l.useState(null),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=l.useCallback(async()=>{try{const p=await fetch("/api/agent-readiness");if(!p.ok)return;r(await p.json())}catch{}},[]);l.useEffect(()=>{d()},[d,e]);const u=l.useCallback(async()=>{o(!0),c(null);try{const h=await(await fetch("/api/agent-install",{method:"POST"})).json();h.installed||c(h.detail??"The install did not complete.")}catch(p){c(p instanceof Error?p.message:String(p))}finally{o(!1),await d(),await(n==null?void 0:n())}},[n,d]);return{readiness:s,installing:a,installError:i,install:u,refresh:d}}function s$(e,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>e||(r.preventDefault(),n(o))}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,n])}function B0({badge:e,label:n,selected:s,dashed:r=!1,onClick:a,children:o}){return t.jsxs("div",{children:[t.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:[t.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:e}),n]}),o]})}const wee=Object.freeze(Object.defineProperty({__proto__:null,OnboardingListItem:B0},Symbol.toStringTag,{value:"Module"}));function W0({provider:e,status:n,cliMissing:s,npmAvailable:r,installing:a,installError:o,onSignIn:i,onInstall:c,onContinueWithoutSignIn:d,storeDurability:u="unobserved",claudeLaunch:p={binaryMismatch:!1,configMissingAtLaunch:!1}}){const h=st(e),f=e==="claude"?bR(p,h):null,m=e==="claude"&&s&&r;return t.jsxs("div",{"data-testid":"provider-auth-status",style:{marginTop:18,padding:"16px 20px",borderRadius:14,border:"1px solid rgba(255,255,255,.09)",background:"var(--bg-input)",display:"flex",flexDirection:"column",gap:12},children:[t.jsx("span",{style:{fontSize:14,color:"var(--text-secondary)"},children:yR(n,h)}),n==="signed-in-not-stored"&&t.jsx("span",{style:{fontSize:13.5,color:"var(--text-muted)"},children:vR(u,h)}),f!==null&&t.jsx("span",{"data-testid":"provider-auth-launch-note",style:{fontSize:13.5,color:"var(--text-muted)"},children:f}),s&&t.jsxs("span",{style:{fontSize:13.5,color:"var(--text-muted)"},children:["The ",h," command-line tool isn't installed on this machine",r?".":", and npm isn't available to install it."]}),t.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[jR(n)&&t.jsx("button",{type:"button",onClick:i,style:{padding:"9px 18px",borderRadius:10,border:"1px solid var(--accent-active)",background:"var(--accent-active)",color:"var(--text-on-accent, #14170a)",fontSize:14,cursor:"pointer"},children:m?`Install and sign in to ${h}`:`Sign in to ${h}`}),s&&r&&t.jsx("button",{type:"button",onClick:c,disabled:a,style:{padding:"9px 18px",borderRadius:10,border:"1px solid rgba(255,255,255,.18)",background:"transparent",color:"var(--text-secondary)",fontSize:14,cursor:a?"default":"pointer"},children:a?"Installing…":`Install ${h}`}),wR(n)&&t.jsx("button",{type:"button",onClick:d,style:{padding:"9px 18px",borderRadius:10,border:"1px solid transparent",background:"transparent",color:"var(--text-muted)",fontSize:14,cursor:"pointer",textDecoration:"underline"},children:"Continue without signing in"})]}),o!==null&&t.jsx("span",{style:{fontSize:13,color:"var(--text-error, #ff8a8a)"},children:o})]})}const _ee=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireProviderAuthPanel:W0},Symbol.toStringTag,{value:"Module"})),Xi=[{id:"claude",badge:"1",how:"Sign in with your Anthropic account"},{id:"codex",badge:"2",how:"Paste an OpenAI API key"},{id:"gemini",badge:"3",how:"Paste a Google AI API key"},{id:"opencode",badge:"4",how:"Paste an API key"}];function H0({selected:e,onSelect:n,onContinueWithoutSignIn:s,onSignedIn:r}){const a=sd(),[o,i]=l.useState(!1),c=l.useCallback(()=>a.refresh(),[a]),{readiness:d,installing:u,installError:p,install:h}=n$(e,c);s$(Xi.length,b=>{n(Xi[b-1].id)});const f=d!==null&&d.provider===e,m=e!==null&&a.provider!==e,g=a.refresh;l.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>void g(),1e3);return()=>window.clearInterval(b)},[m,g]);const x=t$({selected:e,authProvider:a.provider,authState:a.state,probeInFlight:a.probeInFlight,authReason:a.reason});return t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:34,fontWeight:600,letterSpacing:"-.02em",color:"var(--text-primary)",marginBottom:10},children:"Which AI should build this?"}),t.jsx("p",{style:{fontSize:14.5,color:"var(--text-muted)",marginBottom:34},children:"Pick the coding agent that writes your code. You can sign in now or later — you'll need to before the first build runs."}),t.jsxs("div",{style:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:9,textAlign:"left"},children:[Xi.map(b=>t.jsx(B0,{badge:b.badge,label:`${st(b.id)} — ${b.how}`,selected:e===b.id,onClick:()=>n(b.id)},b.id)),e!==null&&t.jsx(W0,{provider:e,status:x,cliMissing:f&&!d.agentInstalled,npmAvailable:f&&d.npmAvailable,installing:u,installError:p,onSignIn:()=>i(!0),onInstall:()=>void h(),onContinueWithoutSignIn:s,storeDurability:a.storeDurability,claudeLaunch:a.claudeLaunch})]}),o&&e!==null&&t.jsx(Sg,{provider:e,onAuthenticated:()=>{i(!1),_R(),r()},onClose:()=>i(!1)})]})}const See=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireProviderStep:H0},Symbol.toStringTag,{value:"Module"}));function r$({description:e,launched:n}){const[s,r]=l.useState({kind:"preparing"}),a=l.useRef(n),o=l.useRef(0),i=l.useCallback(async()=>{const c=++o.current,d=()=>o.current===c;r({kind:"preparing"});try{const u=!a.current,[p,h,f]=await Promise.all([fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:e,allowOverwrite:!0})}),fetch("/api/editor-design-systems-install",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}),u?fetch("/api/editor-design-reset",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}):Promise.resolve(null)]);if(!h.ok){const m=await h.text().catch(()=>"");throw new Error(Pl("/api/editor-design-systems-install",h.status,m))}if(f&&!f.ok){const m=await f.text().catch(()=>"");throw new Error(Pl("/api/editor-design-reset",f.status,m))}p.ok||console.warn("[useDesignPrepare] editor-project-info failed; skill will prompt for description",p.status),d()&&r({kind:"ready"})}catch(u){d()&&r({kind:"error",message:u instanceof Error?u.message:String(u)})}},[e]);return l.useEffect(()=>(i(),()=>{o.current+=1}),[i]),{prepare:s,runPrepare:i}}function a$(e,n){const s=l.useRef(n);l.useEffect(()=>{s.current=n},[n]),l.useEffect(()=>{if(!e)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)}},[e])}function q0(){const{sendToAgent:e,agentReady:n}=No();return{sendToAgent:l.useCallback(r=>{const a=Eb();return a?n?(Sn(r,a),!0):!1:e(r)},[e,n]),agentReady:n}}function ri({view:e,onChange:n,className:s=""}){return t.jsx("div",{role:"group","aria-label":"View",className:`${lD} ${s}`,children:["chat","terminal"].map(r=>t.jsx("button",{type:"button","aria-pressed":e===r,onClick:()=>n(r),"data-testid":`chat-view-${r}`,className:Gs(e===r,"compact"),children:r==="chat"?"Chat":"Terminal"},r))})}const kee=Object.freeze(Object.defineProperty({__proto__:null,ChatTerminalToggle:ri},Symbol.toStringTag,{value:"Module"}));function ta(e=!0){const[n,s]=l.useState(void 0),r=l.useRef(!0);return l.useEffect(()=>{if(!e)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)}},[e]),n}const o$=1500;function Lu(e,n="/api/editor-design-chat"){const[s,r]=l.useState(Ar);return l.useEffect(()=>{if(!e)return;let a=!1,o="";r(Ar);const i=async()=>{try{const d=await fetch(n);if(!d.ok)return;const u=await d.text();if(a||u===o)return;o=u,r(lx(JSON.parse(u)))}catch{}};i();const c=window.setInterval(()=>void i(),o$);return()=>{a=!0,window.clearInterval(c)}},[e,n]),s}function Tf(e){return e.map(n=>`${n.filename}|${n.url}`).sort().join(`
|
|
59
|
-
`)}let Gn=null,tc=!1;const nc=new Set;function ai(){for(const e of nc)e()}function Pf(){return Gn}function i$(e){Gn={...e,id:`iterate-${Date.now()}`,stage:"planning"},ai()}function $u(){!Gn||Gn.stage==="designing"||(Gn={...Gn,stage:"designing"},ai())}function Of(){Gn&&(Gn=null,ai())}function l$(e){tc!==e&&(tc=e,ai())}function Rf(){return tc}function U0(e){return nc.add(e),()=>nc.delete(e)}function Fu(){return l.useSyncExternalStore(U0,Pf,Pf)}function G0(){return l.useSyncExternalStore(U0,Rf,Rf)}function c$(e){const n=l.useCallback(()=>SR(e),[e]);return l.useSyncExternalStore(kR,n,n)}const fr=/^(\s*)[❯›▶]\s+(\S.*)$/,Ef=/^\d+[.)]\s/,d$=/^[\s─━═╌┄▔▁-]{10,}$/;function zu(e){if(!e)return null;const n=e.map(f=>f.replace(/\s+$/,""));let s=-1,r=0;for(let f=n.length-1;f>=0;f--){const m=fr.exec(n[f]);if(m&&(m[1].length>=2||Ef.test(m[2]))){s=f,r=m[1].length;break}}if(s<0)return null;const a=fr.exec(n[s])[2];if(Ef.test(a))return f$(n,s);const o=r+2,i=f=>{var g;if(((g=fr.exec(f))==null?void 0:g[1].length)===r)return!0;const m=f.length-f.trimStart().length;return f.trim()!==""&&m===o};let c=s;for(;c>0&&i(n[c-1]);)c--;let d=s;for(let f=s+1;f<n.length;f++)if(n[f].trim()!=="")if(i(n[f]))d=f;else break;const u=[];for(let f=c;f<=d;f++){if(n[f].trim()==="")continue;const m=fr.exec(n[f]),g=(m&&m[1].length===r?m[2]:n[f].trim()).replace(/\s{2,}/g," · ");u.push({label:g,selected:!!m&&m[1].length===r})}if(u.length<2)return null;const p=Y0(n,c);if(p.length===0)return null;const h=n.slice(d+1).map(f=>f.trim()).filter(Boolean);return{text:K0(p),options:u,hint:V0(h)}}const u$=/^\s*←.*→\s*$/;function Y0(e,n){const s=[];let r=0;for(let a=n-1;a>=0&&s.length<12;a--){const o=e[a];if(d$.test(o)||u$.test(o))break;if(o.trim()===""){if(++r>=2&&s.length>0)break;continue}r=0,s.unshift(o.trim().replace(p$,""))}return s}const p$=/^[│┃▎▌|]\s?/,h$=/[─━═╌┄]{6,}/;function V0(e){const n=e[0];return n!==void 0&&!h$.test(n)?n:null}const Af=/^(\s*)(?:[❯›▶]\s*)?(\d+[.)]\s+\S.*)$/;function f$(e,n){const s=h=>{const f=Af.exec(h);return f?h.indexOf(f[2]):-1},r=s(e[n]),a=h=>s(h)===r,o=h=>h.trim()===""||h.length-h.trimStart().length>r;let i=n;for(let h=n-1;h>=0;h--)if(a(e[h]))i=h;else if(!o(e[h]))break;let c=n;for(let h=n+1;h<e.length;h++)if(a(e[h]))c=h;else if(!o(e[h]))break;const d=[];for(let h=i;h<=c;h++){if(!a(e[h]))continue;const f=Af.exec(e[h]);d.push({label:f[2].trim().replace(/\s{2,}/g," · "),selected:fr.test(e[h])})}if(d.length<2)return null;const u=Y0(e,i);if(u.length===0)return null;const p=e.slice(c+1).filter(h=>!o(h)||h.trim()==="").map(h=>h.trim()).filter(Boolean);return{text:K0(u),options:d,hint:V0(p)}}function K0(e){return e.length<=1?e:[e[0],e.slice(1).join(" ")]}function J0(e){return/^type something/i.test(e.replace(/^\d+[.)]\s*/,""))}function oi(e,n,s){return[...na(e,n).slice(0,-1),s,"\r"]}function na(e,n){const s=Math.max(0,e.options.findIndex(a=>a.selected)),r=n>s?"\x1B[B":"\x1B[A";return[...Array(Math.abs(n-s)).fill(r),"\r"]}let X0=null;const sc=new Set;function Mf(){return X0}function If(e){X0=e;for(const n of sc)n()}function m$(e){return sc.add(e),()=>sc.delete(e)}function g$(){return l.useSyncExternalStore(m$,Mf,Mf)}function xn(e,n){if(!n)return e;const s=e.includes("?")?"&":"?";return`${e}${s}round=${encodeURIComponent(n)}`}const x$=3e3;function Q0(e,n){const[s,r]=l.useState({ready:null,target:null});return l.useEffect(()=>{if(!n)return;let a=!1;const o=async()=>{try{const[c,d]=await Promise.all([fetch(xn("/api/editor-mockups",e)),fetch(xn("/api/editor-mockups-target",e))]);if(!c.ok||!d.ok)return;const u=await c.json(),p=await d.json();if(a)return;const h=Array.isArray(u)?u.length:0,f=typeof p.count=="number"?p.count:null;r(m=>m.ready===h&&m.target===f?m:{ready:h,target:f})}catch{}};o();const i=window.setInterval(()=>void o(),x$);return()=>{a=!0,window.clearInterval(i)}},[e,n]),s}function ii(e,n){const s=[...e],r=n.filter(a=>!e.slice(a.after).some(o=>o.role==="user"&&y$(o.text,a.text)));for(const a of[...r].sort((o,i)=>i.after-o.after)){const o=e.slice(a.after).some(i=>i.role==="agent");s.splice(Math.min(a.after,s.length),0,{id:`${o?"sent":"pending"}-${a.id}`,role:"user",text:a.text,items:[]})}return s}function b$(e,n,s=n,r=[]){const a=[];let o=[],i=0;const c=new Map;for(const m of r)c.set(m.afterId,[...c.get(m.afterId)??[],m]);const d=m=>{for(const g of c.get(m)??[])o.push({role:"milestone",milestone:g});c.delete(m)};let u=e.length;for(;u>0&&e[u-1].role==="user"&&e[u-1].id.startsWith("pending-");)u--;let p=!1;const h=m=>{const g=`turn-${i++}`;let x=[],b=0;const y=v=>{x.length>0&&a.push({kind:"steps",id:b===0?`${g}-steps`:`${g}-steps-${b}`,items:x,live:v}),b++,x=[]};o.forEach(v=>{if(v.role==="activity")x.push(...v.items);else if(v.role==="agent")y(!1),a.push({kind:"reply",id:v.id,text:v.text});else if(v.role==="milestone"){y(!1);const{milestone:j}=v;a.push({kind:"milestone",id:`milestone-${j.id}`,text:j.text,detail:j.detail})}}),m?x.length>0?y(!0):a.push({kind:"working",id:`${g}-working`}):y(!1),o=[]};d(null),e.forEach((m,g)=>{if(m.role==="user"){if(o.length>0){const x=s&&g>=u;h(x),p=p||x}a.push({kind:"user",id:m.id,text:m.text,pending:m.id.startsWith("pending-")})}else o.push(m);d(m.id)});for(const m of[...c.keys()])d(m);const f=e.length>0&&e[e.length-1].role==="user";return(o.length>0||n&&f&&!p)&&h(n),a}function y$(e,n){const s=a=>a.replace(/\s+/g," ").trim(),r=s(n);return r!==""&&s(e).endsWith(r)}const cn=16,yn={padding:`0 ${cn}px 10px`,flex:"0 1 auto",minHeight:0,overflowY:"auto"};function Z0(e,n){if(!e)return[];const s=[];for(const r of Array.from(e.items)){if(r.kind!=="file")continue;const a=r.getAsFile();if(!a)continue;if(!a.type.startsWith("image/")){s.push(a);continue}const o=a.name.includes(".")?a.name.slice(a.name.lastIndexOf(".")):`.${a.type.slice(6)}`;s.push(new File([a],`pasted-${n}-${s.length+1}${o}`,{type:a.type}))}return s}function Bu({file:e,onRemove:n}){const s=Yy(e);return t.jsx("span",{role:"img","aria-label":e.name,title:e.name,"data-testid":"composer-image-preview",style:{position:"relative",display:"inline-block",width:64,height:64,borderRadius:8,border:"1px solid rgba(255,255,255,.12)",background:s?`center / cover no-repeat url("${s}")`:"#232325",boxShadow:"0 3px 8px rgba(0,0,0,.22)"},children:t.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,onClick:n,style:{position:"absolute",top:-6,right:-6,width:18,height:18,borderRadius:"50%",border:"1px solid rgba(255,255,255,.2)",background:"#2a2a2c",color:"#d4d4d8",cursor:"pointer",fontSize:11,lineHeight:1,display:"grid",placeItems:"center",padding:0},children:"×"})})}const Nee=Object.freeze(Object.defineProperty({__proto__:null,ComposerImagePreview:Bu},Symbol.toStringTag,{value:"Module"})),Df=20,Lf=160;function li({onSend:e,disabled:n=!1,busyNote:s,awaiting:r=!1,draft:a,onDraftChange:o}){const[i,c]=l.useState(""),d=a??i,u=o??c,[p,h]=l.useState([]),[f,m]=l.useState(!1),[g,x]=l.useState(!1),b=l.useRef(null),y=l.useRef(null),v=!n&&!f&&(d.trim().length>0||p.length>0),j=w=>h(k=>[...k,...w]);l.useLayoutEffect(()=>{const w=b.current;if(!w)return;w.style.height="auto";const k=Math.min(Math.max(w.scrollHeight,Df),Lf);w.style.height=`${k}px`,w.style.overflowY=w.scrollHeight>Lf?"auto":"hidden"},[d]);const _=async()=>{if(!v)return;m(!0);const w=await e(d.trim(),p);m(!1),w&&(u(""),h([]))},S=w=>{w.preventDefault(),x(!1);const k=Array.from(w.dataTransfer.files??[]);k.length>0&&j(k)};return t.jsxs("div",{style:{padding:`6px ${cn}px 10px`,flex:"none"},children:[s&&t.jsx("div",{role:"alert",style:{fontSize:12,color:"var(--accent-danger, #f87171)",margin:"0 2px 6px"},children:s}),r&&t.jsx("style",{children:`
|
|
60
|
-
@keyframes cy-composer-await {
|
|
61
|
-
0%, 100% { box-shadow: 0 0 0 2px rgba(255,139,67,.04); }
|
|
62
|
-
50% { box-shadow: 0 0 0 3px rgba(255,139,67,.1); }
|
|
63
|
-
}
|
|
64
|
-
@media (prefers-reduced-motion: reduce) {
|
|
65
|
-
[data-testid="design-chat-composer"] { animation: none !important; }
|
|
66
|
-
}
|
|
67
|
-
`}),t.jsxs("div",{"data-testid":"design-chat-composer","data-awaiting":r?"true":"false",onDragOver:w=>{w.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:S,style:{border:`1px solid ${g?"var(--accent-active, #D7FF63)":r?"rgba(255,139,67,.45)":"rgba(255,255,255,.12)"}`,boxShadow:r?"0 0 0 2px rgba(255,139,67,.04)":"none",animation:r?"cy-composer-await 2.4s ease-in-out infinite":void 0,transition:"border-color .2s, box-shadow .2s",borderRadius:12,background:"rgba(255,255,255,.03)",padding:"8px 10px",display:"flex",flexDirection:"column",gap:6},children:[t.jsx("textarea",{ref:b,"aria-label":"Message the design agent",placeholder:n?"Waiting for the agent…":r?"Type your answer…":"Reply, or ask for changes…",value:d,rows:1,onChange:w=>u(w.target.value),onPaste:w=>{const k=Z0(w.clipboardData,Date.now());k.length!==0&&(w.preventDefault(),j(k))},onKeyDown:w=>{w.key==="Enter"&&!w.shiftKey&&!w.nativeEvent.isComposing&&(w.preventDefault(),_())},style:{width:"100%",resize:"none",background:"none",border:0,outline:"none",color:"var(--text-primary)",fontSize:13,lineHeight:1.45,fontFamily:"var(--font-chat)",minHeight:Df}}),p.length>0&&t.jsx("div",{"data-testid":"design-chat-attachments",style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:8,paddingTop:6,opacity:f?.6:1},children:p.map((w,k)=>{const N=()=>h(C=>C.filter((T,P)=>P!==k));return w.type.startsWith("image/")?t.jsx(Bu,{file:w,onRemove:N},`${w.name}-${k}`):t.jsx(Jr,{file:w,onRemove:N},`${w.name}-${k}`)})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("button",{type:"button","aria-label":"Add files",title:"Add reference files",onClick:()=>{var w;return(w=y.current)==null?void 0:w.click()},className:"border border-white/[0.12] bg-transparent text-[var(--text-secondary)] transition-colors hover:border-white/[0.3] hover:bg-white/[0.1] hover:text-[var(--text-primary)]",style:{width:26,height:26,borderRadius:7,cursor:"pointer",display:"grid",placeItems:"center",fontSize:16,lineHeight:1},children:"+"}),t.jsx("input",{ref:y,type:"file",multiple:!0,hidden:!0,"data-testid":"design-chat-file-input",onChange:w=>{const k=Array.from(w.target.files??[]);w.target.value="",k.length>0&&j(k)}}),t.jsx("span",{style:{fontSize:11.5,color:"rgba(255,255,255,.35)"},children:f&&p.length>0?`Uploading ${p.length===1?p[0].name:`${p.length} files`}…`:p.length>0?`${p.length} file${p.length>1?"s":""} attached`:"Drop or paste files here too"}),t.jsx("span",{style:{flex:1}}),t.jsx("button",{type:"button","aria-label":"Send",disabled:!v,onClick:()=>void _(),style:{width:28,height:28,borderRadius:8,border:"none",display:"grid",placeItems:"center",cursor:v?"pointer":"default",background:v?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.08)",color:v?"var(--text-on-accent, #111)":"rgba(255,255,255,.35)"},children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M8 13V3M3.5 7.5L8 3l4.5 4.5"})})})]})]})]})}const Cee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatComposer:li},Symbol.toStringTag,{value:"Module"}));function eS({initialRows:e,onSend:n,disabled:s=!1}){const[r,a]=l.useState(e);return t.jsxs("div",{"data-testid":"design-chat-decision-card",style:{border:"1px solid rgba(215,255,99,.35)",background:"rgba(215,255,99,.05)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:10,fontSize:13,color:"var(--text-secondary)"},children:[t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500},children:"What should happen to each design?"}),r.map(o=>t.jsx(Ux,{row:o,disabled:s,onChoose:(i,c)=>a(d=>nA(d,o.filename,i,c))},o.filename)),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{type:"button",disabled:s,onClick:()=>n(r),style:{padding:"6px 12px",borderRadius:8,border:"none",cursor:s?"default":"pointer",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)",fontSize:12.5,fontWeight:600,opacity:s?.6:1},children:"Send choices"}),t.jsx("span",{style:{fontSize:11.5,color:"rgba(255,255,255,.4)"},children:"Anything typed below is sent with it."})]})]})}const Tee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatDecisionCard:eS},Symbol.toStringTag,{value:"Module"})),$f="codeyam:turn-start:",Ff=new Map;function v$(e,n){const s=Ff.get(e);if(s!==void 0)return s;let r=n;try{const a=window.sessionStorage.getItem($f+e),o=a===null?NaN:Number(a);Number.isFinite(o)?r=o:window.sessionStorage.setItem($f+e,String(n))}catch{}return Ff.set(e,r),r}function tS({items:e,live:n=!1,mark:s,onOpenTerminal:r,timerKey:a}){const[o,i]=l.useState(!1),c=j$(n,a),d=n&&e.length>0?e.length-1:-1,u=d>=0?e.slice(0,d):e,p=l.useRef(null);return l.useEffect(()=>{var h,f;o&&((f=(h=p.current)==null?void 0:h.scrollIntoView)==null||f.call(h,{block:"nearest",behavior:"smooth"}))},[o]),t.jsxs("div",{ref:p,"data-testid":"design-chat-activity","data-live":n?"true":"false",style:{fontSize:12,color:"rgba(255,255,255,.4)"},children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":o?"Hide steps":"Show steps",onClick:()=>i(!o),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"inherit",fontSize:12,display:"flex",alignItems:s?"center":"flex-start",gap:8,textAlign:"left",maxWidth:"100%"},children:[t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:8,transition:"transform 150ms",transform:o?"rotate(90deg)":"none"},children:"›"}),s,t.jsx("span",{children:`${e.length} step${e.length===1?"":"s"}`}),c!==null&&t.jsxs("span",{"data-testid":"design-chat-elapsed",style:{color:"rgba(255,255,255,.7)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11.5},children:["(",Cx(c),")"]})]}),o&&u.length>0&&t.jsx("ol",{style:{margin:"6px 0 0",padding:"0 0 0 12px",borderLeft:"1px solid rgba(255,255,255,.1)",listStyle:"none",display:"flex",flexDirection:"column",gap:5},children:u.map((h,f)=>t.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:8,whiteSpace:"pre-wrap",overflowWrap:"anywhere",color:n?"rgba(255,255,255,.32)":void 0},children:[n&&t.jsx("span",{"aria-hidden":"true",style:{flexShrink:0,width:12,display:"grid",placeItems:"center",marginTop:3},children:t.jsx("span",{style:{fontSize:10,lineHeight:1,color:"rgba(215,255,99,.55)"},children:"✓"})}),t.jsx("span",{children:h})]},f))}),d>=0&&t.jsxs("div",{"data-testid":"design-chat-current-step",style:{display:"flex",alignItems:"flex-start",gap:8,margin:o&&u.length>0?"5px 0 0":"6px 0 0",color:"rgba(255,255,255,.88)",overflowWrap:"anywhere"},children:[t.jsx("span",{"aria-hidden":"true",style:{flexShrink:0,width:8,display:"grid",placeItems:"center",marginTop:3},children:t.jsx(Wt,{size:10})}),t.jsxs("span",{children:[e[d].replace(/[.…]+$/,""),t.jsx(Kn,{})]})]}),d>=0&&r&&t.jsxs("div",{"data-testid":"design-chat-terminal-hint",style:{margin:"4px 0 0 16px",fontSize:11.5,color:"rgba(255,255,255,.3)"},children:["To see exactly what's happening, switch to the"," ",t.jsx("button",{type:"button",onClick:r,className:"cursor-pointer hover:!text-[var(--text-primary)]",style:{background:"none",border:"none",padding:0,font:"inherit",color:"rgba(255,255,255,.5)",textDecoration:"underline",textUnderlineOffset:2,cursor:"pointer"},children:"terminal"})]})]})}function j$(e,n){const s=()=>n?v$(n,Date.now()):Date.now(),r=l.useRef(e?s():null),[a,o]=l.useState(e&&r.current!==null?Math.floor((Date.now()-r.current)/1e3):null);return l.useEffect(()=>{if(!e)return;r.current===null&&(r.current=s());const i=()=>o(Math.floor((Date.now()-(r.current??Date.now()))/1e3));i();const c=window.setInterval(i,1e3);return()=>window.clearInterval(c)},[e]),a}const Pee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatActivity:tS},Symbol.toStringTag,{value:"Module"}));function w$(e){let n=-1;for(const c of e.matchAll(/\?(?=[\s)"'»]|$)/g))n=c.index??-1;if(n<0)return e;const s=e.slice(0,n),r=s.lastIndexOf("¿"),a=Math.max(...[".","!","?",":",`
|
|
68
|
-
`].map(c=>s.lastIndexOf(c)));let o=r>a?r:a+1;for(;o<n&&/\s/.test(e[o]);)o+=1;const i=e.slice(o,n+1);return i.length<2||/[`*]/.test(i)?e:`${e.slice(0,o)}**${i}**${e.slice(n+1)}`}const _$=80;function S$(e,n,s){const r=n.slice(0,s).filter(i=>i.kind==="user"),a=r[r.length-1],o=a&&a.kind==="user"?a.text.replace(/\s+/g," ").trim().slice(0,40):"";return`${e}:${r.length}:${o}`}const k$=[];function sa({messages:e,working:n,pending:s=[],emptyState:r,awaitingReply:a=!1,startingText:o="Starting the design agent…",waiting:i=!1,intro:c,milestones:d=k$,onOpenTerminal:u,timerScope:p,lastReplyBackground:h=!1}){var _;const f=l.useRef(null),m=l.useRef(!0),g=l.useMemo(()=>ii(e,s),[e,s]),x=!i&&(n||g.some(S=>S.id.startsWith("pending-"))),b=!i&&n,y=l.useMemo(()=>b$(g,x,b,d),[g,x,b,d]);l.useLayoutEffect(()=>{const S=f.current;S&&m.current&&(S.scrollTop=S.scrollHeight)},[y]),l.useLayoutEffect(()=>{const S=f.current;S&&a&&(S.scrollTop=S.scrollHeight,m.current=!0)},[a]);const v=(_=[...y].reverse().find(S=>S.kind==="reply"))==null?void 0:_.id,j=y.length>0&&y[y.length-1].kind==="reply";return t.jsxs("div",{ref:f,"data-testid":"design-chat-feed",role:"log","aria-live":"polite",onScroll:S=>{const w=S.currentTarget;m.current=w.scrollHeight-w.scrollTop-w.clientHeight<_$},style:{flex:1,minHeight:96,overflow:"auto",display:"flex",flexDirection:"column",gap:12,padding:`14px ${cn}px`,fontSize:13,lineHeight:1.6,fontFamily:"var(--font-chat)"},children:[c,y.length===0&&r,y.length===0&&!r&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,color:"var(--text-muted)",fontSize:13},children:[t.jsx(Wt,{}),o]}),y.map((S,w)=>{var C;const k=S.kind==="steps"&&!S.live&&((C=y[w+1])==null?void 0:C.kind)==="reply",N=S.kind==="reply"&&w>0&&y[w-1].kind==="steps";return S.kind==="reply"?j&&S.id===v&&Xh(S.text)?t.jsx(Ox,{text:S.text},S.id):a&&j&&S.id===v?t.jsxs("div",{"data-testid":"design-chat-awaiting",style:{border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.055)",borderRadius:10,padding:"10px 12px 4px"},children:[t.jsx(wl,{text:w$(S.text),showMark:!N,bright:!0}),t.jsxs("div",{style:{margin:"2px 0 6px",display:"flex",alignItems:"center",gap:7,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:"#cfcfcf"},children:[t.jsx("span",{"aria-hidden":"true","data-testid":"design-chat-awaiting-dot",className:"animate-pulse motion-reduce:animate-none",style:{width:7,height:7,borderRadius:"50%",background:ht,flex:"none"}}),"Waiting for your answer"]})]},S.id):t.jsx(wl,{text:S.text,showMark:!N,warning:Xh(S.text),tint:h&&S.id===v?Dn:void 0},S.id):S.kind==="steps"?t.jsx(tS,{items:S.items,live:S.live,onOpenTerminal:u,timerKey:p&&S.live?S$(p,y,w):void 0,mark:k?t.jsx("span",{style:{color:"var(--accent-active, #D7FF63)",display:"flex"},children:t.jsx(ms,{markOnly:!0,className:"h-3.5"})}):void 0},S.id):S.kind==="milestone"?t.jsxs("div",{"data-testid":"design-chat-milestone",role:"separator","aria-label":`Step ${S.detail} complete: ${S.text}`,style:{display:"flex",alignItems:"center",gap:12,margin:"8px 0 10px",fontSize:12.5},children:[t.jsxs("span",{style:{color:"var(--working)",whiteSpace:"nowrap",maxWidth:"80%",overflow:"hidden",textOverflow:"ellipsis"},children:[t.jsx("span",{"aria-hidden":"true",children:"✓ "}),t.jsxs("span",{style:{color:"rgba(255,255,255,.55)"},children:["Step ",S.detail,":"]})," ",t.jsx("span",{style:{color:"var(--text-primary)"},children:S.text})," · Complete!"]}),t.jsx("span",{"aria-hidden":"true",style:{flex:1,height:1,background:"rgba(255,255,255,.12)"}})]},S.id):S.kind==="working"?t.jsxs("div",{"data-testid":"design-chat-thinking",style:{display:"flex",alignItems:"center",gap:8,color:"rgba(255,255,255,.5)",fontSize:12.5},children:[t.jsx(Wt,{size:12}),t.jsxs("span",{children:["Working",t.jsx(Kn,{})]})]},S.id):BA(S.text)?t.jsx("div",{"data-testid":"design-chat-answered",style:{borderLeft:"2px solid rgba(255,255,255,.14)",padding:"2px 0 2px 10px",color:"rgba(255,255,255,.45)"},children:"You answered the questions in the preview."},S.id):t.jsx("div",{"data-testid":"design-chat-user","data-pending":S.pending?"true":"false",style:{alignSelf:"flex-end",maxWidth:"88%",padding:"8px 10px",borderRadius:"12px 12px 4px 12px",background:"rgba(255,255,255,.06)",color:"#d6d6d6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",opacity:S.pending?.75:1},children:t.jsx(nS,{text:S.text})},S.id)})]})}function nS({text:e}){const n=oA(e);if(n)return t.jsxs("span",{"data-testid":"design-chat-decision",children:[n.summary,n.note&&t.jsx("span",{style:{display:"block",marginTop:4},children:n.note})]});const s=cx(e);if(s)return t.jsxs("span",{"data-testid":"design-chat-iterate",children:["Make a new round from my feedback",s.designs>0&&t.jsxs("span",{style:{display:"block",marginTop:4,fontSize:11,color:"rgba(255,255,255,.5)"},children:["Ratings and notes on ",s.designs," ",s.designs===1?"design":"designs"]})]});const r=UA(e);return r?t.jsxs(t.Fragment,{children:[r.rest?t.jsx("div",{style:{marginBottom:6},children:r.rest}):null,t.jsx("div",{"data-testid":"design-chat-files",style:{display:"flex",flexWrap:"wrap",gap:6},children:r.names.map(a=>t.jsxs("span",{"data-testid":"design-chat-file",title:a,style:{display:"inline-flex",alignItems:"center",gap:4,maxWidth:"100%",whiteSpace:"nowrap",fontSize:11,padding:"1px 8px",borderRadius:999,border:"1px solid rgba(255,255,255,.14)",color:"rgba(255,255,255,.6)"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:t.jsx("path",{d:"M13.5 7.5l-5.6 5.6a3.2 3.2 0 01-4.5-4.5l5.9-5.9a2.1 2.1 0 013 3l-5.9 5.9a1.1 1.1 0 01-1.5-1.5l5.3-5.3"})}),t.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:a})]},a))})]}):t.jsx(t.Fragment,{children:e})}const Oee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatFeed:sa,UserMessageBody:nS},Symbol.toStringTag,{value:"Module"}));function sS({pick:e}){const n=e.number?`${String(e.number).padStart(2,"0")} ${e.name}`:e.name;return t.jsxs("div",{"data-testid":"design-chat-pick",style:{border:"1px solid rgba(215,255,99,.35)",background:"rgba(215,255,99,.07)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:10,fontSize:13,color:"var(--text-secondary)"},children:[t.jsxs("div",{children:["You picked ",t.jsx("b",{style:{color:"var(--text-primary)",fontWeight:500},children:n}),". I'll turn it into your design system and the first screens of the app."]}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{type:"button",disabled:e.busy,onClick:e.confirm,style:{padding:"6px 12px",borderRadius:8,border:"none",cursor:e.busy?"default":"pointer",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)",fontSize:12.5,fontWeight:600,opacity:e.busy?.6:1},children:e.busy?"Starting…":`Continue with ${e.name}`}),t.jsx("button",{type:"button",disabled:e.busy,onClick:e.cancel,style:{padding:"6px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-secondary)",fontSize:12.5,cursor:"pointer"},children:"Keep exploring"})]})]})}const Ree=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPickCard:sS},Symbol.toStringTag,{value:"Module"})),rS="border border-[rgba(255,255,255,.14)] outline-none focus:border-[#FF8B43] focus-visible:outline-none";function Wu({onAnswer:e,attach:n,disabled:s=!1,autoFocus:r=!1,placeholder:a,ariaLabel:o,resetKey:i}){const[c,d]=l.useState(""),[u,p]=l.useState([]),[h,f]=l.useState(!1),[m,g]=l.useState(!1);l.useEffect(()=>{d(""),p([])},[i]);const x=_=>p(S=>[...S,..._]),b=s||h,y=!b&&(c.trim()!==""||u.length>0),v=async()=>{if(!y)return;let _=c.trim();if(u.length>0&&n){f(!0);const S=await n(u);if(f(!1),S===null)return;_=_?`${S} ${_}`:S}e(_),d(""),p([])},j=_=>{if(!n)return;_.preventDefault(),g(!1);const S=Array.from(_.dataTransfer.files??[]);S.length>0&&x(S)};return t.jsxs("form",{onSubmit:_=>{_.preventDefault(),v()},onDragOver:_=>{n&&(_.preventDefault(),g(!0))},onDragLeave:()=>g(!1),onDrop:j,style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{type:"text",autoFocus:r,value:c,onChange:_=>d(_.target.value),onPaste:_=>{if(!n)return;const S=Z0(_.clipboardData,Date.now());S.length!==0&&(_.preventDefault(),x(S))},disabled:b,placeholder:h?"Adding your files…":a,"aria-label":o,className:rS,style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:8,background:"rgba(0,0,0,.15)",color:"var(--text-primary)",fontSize:13,borderColor:m?"var(--accent-active, #D7FF63)":void 0}}),t.jsx("button",{type:"submit",disabled:!y,style:{padding:"7px 12px",borderRadius:8,border:"1px solid rgba(255,139,67,.5)",background:"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:y?"pointer":"default",opacity:y?1:.5},children:"Answer"})]}),u.length>0&&t.jsx("div",{"data-testid":"own-answer-attachments",style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:8,opacity:h?.6:1},children:u.map((_,S)=>{const w=()=>p(k=>k.filter((N,C)=>C!==S));return _.type.startsWith("image/")?t.jsx(Bu,{file:_,onRemove:w},`${_.name}-${S}`):t.jsx(Jr,{file:_,onRemove:w},`${_.name}-${S}`)})})]})}const Eee=Object.freeze(Object.defineProperty({__proto__:null,OWN_ANSWER_FOCUS_CLASS:rS,OwnAnswerField:Wu},Symbol.toStringTag,{value:"Module"})),Hu=1e4,qu={border:"1px solid rgba(255,139,67,.6)",background:"rgba(255,139,67,.12)"};function co(){return t.jsx("span",{"data-testid":"answer-sent-mark",style:{marginLeft:"auto",flexShrink:0,fontSize:11.5,fontWeight:500,color:ht,whiteSpace:"nowrap"},children:"✓ Answer sent"})}const Aee=Object.freeze(Object.defineProperty({__proto__:null,ANSWER_SENT_RELEASE_MS:Hu,ANSWER_SENT_STYLE:qu,AnswerSentMark:co},Symbol.toStringTag,{value:"Module"})),N$=90,zf=e=>e.replace(/[\s*`]+/g,"");function jr(e,n){if(!n)return-1;const s=zf(n.text.join(" "));return e.findIndex(r=>r.question.trim()!==""&&s.endsWith(zf(r.question)))}function Uu({questions:e,screenPrompt:n,send:s,onAnswered:r,onOpenTerminal:a,attach:o}){const[i,c]=l.useState(0),[d,u]=l.useState(null);l.useEffect(()=>{if(!d)return;const v=window.setTimeout(()=>u(null),Hu);return()=>window.clearTimeout(v)},[d]);const p=jr(e,n),h=p>=0?p:Math.min(i,e.length-1),f=e[h],m=(d==null?void 0:d.question)===f.question,g=v=>n&&p===h?n.options.findIndex(j=>v(j.label.replace(/^\d+[.)]\s*/,""))):-1,x=(v,j,_)=>{u({question:f.question,k:j}),c(h+1),r==null||r({text:_,last:h===e.length-1}),v.forEach((S,w)=>window.setTimeout(()=>s(S),w*N$))},b=v=>{const j=f.options[v].label,_=g(S=>S===j);x(n&&_>=0?na(n,_):[...Array(v).fill("\x1B[B"),"\r"],v,j)},y=v=>{const j=g(J0);x(n&&j>=0?oi(n,j,v):[...Array(f.options.length).fill("\x1B[B"),v,"\r"],-1,v)};return t.jsxs("div",{role:"group","aria-label":"The agent is asking you a question","data-testid":"design-chat-question",style:{border:"1px solid rgba(255,139,67,.4)",background:"rgba(255,139,67,.06)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,fontSize:13,color:"var(--text-secondary)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:ht},children:f.header||"Question"}),e.length>1&&t.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:[h+1," of ",e.length]})]}),t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500,lineHeight:1.45},children:f.question}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[f.options.map((v,j)=>{const _=m&&(d==null?void 0:d.k)===j;return t.jsxs("button",{type:"button",disabled:m||f.multiSelect,"aria-pressed":_,onClick:()=>b(j),style:{textAlign:"left",padding:"7px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.02)",..._?qu:{},color:"var(--text-primary)",cursor:m||f.multiSelect?"default":"pointer",opacity:m&&!_?.4:1,display:"flex",flexDirection:"column",gap:2},children:[t.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[t.jsx("span",{style:{fontSize:13,fontWeight:500},children:v.label}),_&&t.jsx(co,{})]}),v.description&&t.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.4},children:v.description})]},v.label)}),m&&(d==null?void 0:d.k)===-1&&t.jsx("div",{style:{display:"flex",padding:"2px 2px 0"},children:t.jsx(co,{})})]}),!f.multiSelect&&t.jsx(Wu,{onAnswer:y,attach:o,disabled:m,resetKey:h,placeholder:"Something else in mind? Type your answer",ariaLabel:"Your own answer"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11.5},children:[f.multiSelect&&t.jsx("span",{style:{color:"var(--text-muted)"},children:"You can pick more than one here: choose them in the Terminal."}),t.jsx("button",{type:"button",onClick:a,style:{marginLeft:"auto",background:"none",border:"none",padding:0,color:"var(--text-secondary)",textDecoration:"underline",cursor:"pointer",fontSize:11.5,whiteSpace:"nowrap"},children:"Open Terminal"})]})]})}const Mee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatQuestionCard:Uu,questionOnScreen:jr},Symbol.toStringTag,{value:"Module"})),C$=/\s*(Ready to submit your answers\?)\s*$/i;function T$(e){if(!e.includes("●"))return{items:[],tail:e};const n=C$.exec(e);return{items:(n?e.slice(0,n.index):e).split("●").map(a=>a.trim()).filter(Boolean).map(a=>{const o=a.lastIndexOf("→");return o<0?{question:a,answer:""}:{question:a.slice(0,o).trim(),answer:a.slice(o+1).trim()}}),tail:n?n[1]:""}}function ci({prompt:e,onChoose:n,onAnswer:s,onOpenTerminal:r,attach:a}){const[o,i]=l.useState(null),[c,d]=l.useState(null),u=e.text.join("|");l.useEffect(()=>i(null),[u]),l.useEffect(()=>{if(o===null)return;const g=window.setTimeout(()=>i(null),Hu);return()=>window.clearTimeout(g)},[o]);const p=o!==null,h=g=>{c!==null&&(i(c),s(c,g),d(null))},f=e.options.some(g=>/submit answers/i.test(g.label)),m=T$(e.text[1]??"");return t.jsxs("div",{role:"group","aria-label":"The agent is waiting for an answer","data-testid":"design-chat-terminal-prompt",style:{border:f?"1px solid rgba(215,255,99,.45)":"1px solid rgba(255,139,67,.4)",background:f?"rgba(215,255,99,.05)":"rgba(255,139,67,.06)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,fontSize:13,color:"var(--text-secondary)"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:f?"var(--accent-active)":ht},children:f?"Last step: review and submit":"Needs your answer"}),t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500},children:e.text[0]}),m.items.length>0?t.jsxs(t.Fragment,{children:[t.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:m.items.map((g,x)=>t.jsxs("li",{style:{lineHeight:1.45},children:[t.jsx("div",{children:g.question}),g.answer&&t.jsxs("div",{style:{color:"var(--text-primary)",fontWeight:500},children:[t.jsx("span",{"aria-hidden":"true",children:"→ "}),t.jsx("span",{children:g.answer})]})]},x))}),m.tail&&t.jsx("div",{style:{color:"var(--text-primary)"},children:m.tail})]}):e.text[1]&&t.jsx("div",{style:{lineHeight:1.45},children:e.text[1]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:2},children:e.options.map((g,x)=>{const b=o===x;return t.jsxs("button",{type:"button",disabled:p,"aria-current":g.selected?"true":void 0,"aria-pressed":b,onClick:()=>{if(J0(g.label)){d(x);return}i(x),n(x)},style:b?{display:"flex",alignItems:"baseline",gap:8,textAlign:"left",padding:"6px 10px",borderRadius:8,...qu,color:"var(--text-primary)",fontSize:12.5,cursor:"default"}:f&&/submit answers/i.test(g.label)?{textAlign:"left",padding:"6px 10px",borderRadius:8,border:"1px solid var(--accent-active)",background:"var(--accent-active)",color:"var(--text-on-accent, #111)",fontWeight:500,fontSize:12.5,cursor:p?"default":"pointer",opacity:p?.4:1}:{textAlign:"left",padding:"6px 10px",borderRadius:8,border:`1px solid ${g.selected?"rgba(255,139,67,.5)":"rgba(255,255,255,.12)"}`,background:g.selected?"rgba(255,139,67,.1)":"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:p?"default":"pointer",opacity:p?.4:1},children:[g.label,b&&t.jsx(co,{})]},`${x}-${g.label}`)})}),c!==null&&t.jsx(Wu,{autoFocus:!0,onAnswer:h,attach:a,disabled:p,placeholder:"Type your answer…",ariaLabel:"Your answer"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11.5},children:[e.hint&&t.jsx("span",{style:{color:"var(--text-muted)"},children:e.hint}),t.jsx("button",{type:"button",onClick:r,style:{marginLeft:"auto",background:"none",border:"none",padding:0,color:"var(--text-secondary)",textDecoration:"underline",cursor:"pointer",fontSize:11.5},children:"Open Terminal"})]})]})}const Iee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatTerminalPrompt:ci},Symbol.toStringTag,{value:"Module"})),P$=[/Paste code here if prompted/i,/Use the url below to sign in/i],O$=["claude.com","claude.ai","anthropic.com"];function Gu(e){if(!e||!e.some(a=>P$.some(o=>o.test(a))))return null;const n=e.map(a=>a.trim()),s=n.findIndex(a=>a.startsWith("https://"));if(s<0)return{url:null};let r="";for(let a=s;a<n.length&&n[a]!==""&&!/\s/.test(n[a]);a++)r+=n[a];return{url:R$(r)?r:null}}function R$(e){try{const{protocol:n,hostname:s}=new URL(e);return n==="https:"&&O$.some(r=>s===r||s.endsWith(`.${r}`))}catch{return!1}}const aS=["Make them bolder","Try a darker version","Mix my two favorites","Show me 3 new directions"],oS=["Keep the ones you suggest","Keep my top-rated ones","Keep none, start fresh"];function iS({items:e,onPick:n}){return t.jsx("div",{"data-testid":"design-chat-suggestions",style:{display:"flex",flexWrap:"wrap",gap:6,padding:"0 12px 8px"},children:e.map(s=>t.jsx("button",{type:"button",onClick:()=>n(s),style:{fontSize:12,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer"},children:s},s))})}const Dee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatSuggestions:iS,GALLERY_SUGGESTIONS:aS,ITERATE_SUGGESTIONS:oS},Symbol.toStringTag,{value:"Module"})),uo="initial-design",lS=90,cS=6e3,dS=12e3;function uS({terminal:e}){var ne;const[n,s]=l.useState("chat"),r=Lu(!0);l.useEffect(()=>Bd(uo),[]);const{sendToAgent:a,agentReady:o}=q0(),[i,c]=l.useState(null),[d,u]=l.useState(""),[p,h]=l.useState([]),f=l.useRef([]),m=E=>{const H=_d(E),U=Cr(a,H);return U?(f.current.push(U),S(),h(pe=>[...pe,{id:`${Date.now()}-${pe.length}`,text:H.replace(/\r$/,""),after:r.messages.length}]),!0):!1},g=g$(),x=ta(),{ready:b}=Q0(x??void 0,x!==void 0),[y,v]=l.useState(!1);l.useEffect(()=>{if(r.available||!o){v(!1);return}const E=window.setTimeout(()=>v(!0),dS);return()=>window.clearTimeout(E)},[r.available,o]);const j=Fu(),_=j==null?void 0:j.id,S=()=>{(j==null?void 0:j.stage)==="planning"&&$u()};l.useEffect(()=>{j&&h(E=>E.some(H=>H.id===j.id)?E:[...E,{id:j.id,text:j.prompt,after:r.messages.length}])},[_]);const w=ii(r.messages,p).some(E=>E.id.startsWith("pending-")),k=c$(uo),N=l.useMemo(()=>zu(k),[k]),C=l.useMemo(()=>Gu(k),[k]),T=!!N||!!C,P=l.useRef([]);l.useEffect(()=>()=>{P.current.forEach(E=>window.clearTimeout(E)),P.current=[],f.current.forEach(E=>E()),f.current=[]},[]);const R=E=>E.forEach((H,U)=>{P.current.push(window.setTimeout(()=>a(H),U*lS))}),L=E=>{N&&R(na(N,E))},M=(E,H)=>{N&&R(oi(N,E,H))},O=!T&&!r.question&&(r.working||w);l.useEffect(()=>{l$(O)},[O]),l.useEffect(()=>{if(!j||j.stage!=="planning"||!w||r.working||T)return;const E=window.setTimeout(()=>a("\r"),cS);return()=>window.clearTimeout(E)},[j,w,r.working,T,a]);const z=[...r.messages].reverse().find(E=>E.role==="user"),I=(j==null?void 0:j.stage)==="planning"&&z!==void 0&&cx(z.text)!==null&&((ne=r.messages[r.messages.length-1])==null?void 0:ne.role)==="agent",Y=!O&&o&&!g&&!T,W=r.messages[r.messages.length-1],A=Y&&(I||(W==null?void 0:W.role)==="agent"&&wd(W.text)),B=l.useMemo(()=>{var E;return I&&j&&j.designs.length>0?tA(j.designs,((E=eA((W==null?void 0:W.text)??""))==null?void 0:E.suggestion)??null):null},[I,j,W==null?void 0:W.text]),D=Y&&B!==null,J=Y?I?B?null:oS:!j&&(b??0)>0?aS:null:null,te=async E=>{c(null);try{await Us(E.map((H,U)=>({id:`chat-${Date.now()}-${U}`,file:H,relativePath:H.name,description:""})))}catch(H){return c(H instanceof Error?H.message:"Couldn't add those files."),null}return Mo(E.map(H=>H.name))},oe=async(E,H)=>{c(null);let U=E;if(H.length>0){const pe=await te(H);if(pe===null)return!1;U=E?`${pe} ${E}`:pe}return m(U)},se=r.messages.some(E=>E.role==="agent"),G=o?T?"waiting on you":!se&&!y?"working":r.available?O?"working":"waiting on you":"running":"starting",le=G==="working"||G==="starting",ue=A||!!r.question||G==="waiting on you";return t.jsx(Gr.Provider,{value:E=>void m(E),children:t.jsxs("div",{"data-testid":"design-session-chat-pane",style:{display:"flex",flexDirection:"column",flex:1,minHeight:0,height:"100%"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid rgba(255,255,255,.08)",flex:"none"},children:[t.jsx(ri,{view:n,onChange:s}),t.jsxs("span",{"data-testid":"design-session-agent-status",style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6,fontSize:12,color:ue?ht:le?"var(--working)":"rgba(255,255,255,.45)"},children:[le&&!ue?t.jsx(Wt,{size:11}):t.jsx("span",{"aria-hidden":"true",className:ue?"animate-pulse":void 0,style:{width:8,height:8,borderRadius:"50%",background:ue?ht:"rgba(255,255,255,.35)"}}),t.jsxs("span",{children:[ue?so:G.charAt(0).toUpperCase()+G.slice(1),ue?t.jsx(Kn,{variant:"pulse"}):le&&t.jsx(Kn,{})]})]})]}),t.jsxs("div",{style:{position:"relative",flex:1,minHeight:0},children:[t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column"},children:e}),n==="chat"&&t.jsxs("div",{"data-testid":"design-session-chat-view",style:{position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",background:"var(--bg-deep, #141414)"},children:[t.jsx(sa,{messages:r.messages,working:r.working,waiting:T,pending:p,awaitingReply:A,onOpenTerminal:()=>s("terminal"),emptyState:y?t.jsxs("div",{"data-testid":"design-chat-log-missing",style:{fontSize:13,color:"var(--text-muted)",display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"},children:["The chat can't read this session's messages yet. The agent is running: follow it in the terminal.",t.jsx("button",{type:"button",onClick:()=>s("terminal"),style:{padding:"5px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:"pointer"},children:"Open Terminal"})]}):void 0}),r.question&&t.jsx("div",{style:yn,children:t.jsx(Uu,{questions:r.question,screenPrompt:N,send:E=>void a(E),onOpenTerminal:()=>s("terminal"),attach:te})}),C&&!N&&t.jsx("div",{style:yn,children:t.jsx(Io,{login:C,onSubmitCode:E=>R([E,"\r"]),onOpenTerminal:()=>s("terminal")})}),N&&!r.question&&t.jsx("div",{style:yn,children:t.jsx(ci,{prompt:N,onChoose:L,onAnswer:M,onOpenTerminal:()=>s("terminal"),attach:te})}),g&&t.jsx("div",{style:yn,children:t.jsx(sS,{pick:g})}),D&&t.jsx("div",{style:{padding:"0 12px 10px",maxHeight:"50%",overflowY:"auto",flex:"none"},children:t.jsx(eS,{initialRows:B,onSend:E=>{m(rA(E,d))&&u("")}},W==null?void 0:W.id)}),J&&t.jsx(iS,{items:J,onPick:E=>void m(E)}),t.jsx(li,{disabled:!o,busyNote:i,awaiting:A,draft:d,onDraftChange:u,onSend:oe})]})]})]})})}const Lee=Object.freeze(Object.defineProperty({__proto__:null,CHAT_UNAVAILABLE_AFTER_MS:dS,DESIGN_SESSION_CHAT_NAME:uo,DesignSessionChatPane:uS,ITERATE_NUDGE_AFTER_MS:cS,TERMINAL_KEY_GAP_MS:lS},Symbol.toStringTag,{value:"Module"}));function rc({description:e,launched:n,onLaunched:s,onDesignSelected:r,onPreviewUrl:a,variant:o="chat"}){l.useEffect(()=>(a==null||a("/design-exploration"),()=>{a==null||a(null)}),[a]);const{prepare:i,runPrepare:c}=r$({description:e,launched:n}),[d,u]=l.useState(!1);return l.useEffect(()=>{i.kind==="ready"&&u(!0)},[i.kind]),l.useEffect(()=>{i.kind==="ready"&&!n&&s()},[i.kind,n,s]),a$(n,r),t.jsx("div",{"data-testid":"design-session-chat",style:{display:"flex",flexDirection:"column",flex:1,minHeight:0,height:"100%"},children:n&&d?t.jsx(uS,{terminal:t.jsx(Ht,{chatName:uo,slashCommand:"/codeyam-design",height:"100%",beforeRelaunch:Ol})}):i.kind==="error"?t.jsx("div",{style:{margin:"var(--spacing-md, 12px)"},children:t.jsx(xb,{message:i.message,hint:"Or skip to build from the canvas on the right.",onRetry:()=>void c()})}):t.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,padding:"16px 14px",fontSize:13,color:"var(--text-muted)"},children:[t.jsx("span",{"aria-hidden":"true",className:"animate-spin",style:{width:14,height:14,borderRadius:"50%",border:"2px solid rgba(199,240,74,.15)",borderTopColor:"var(--accent-active)"}}),o==="files"?"Reading your files and getting the design agent ready…":"Getting the design agent ready…"]})})}const $ee=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatStep:rc},Symbol.toStringTag,{value:"Module"}));function Yu(){return t.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 Fee=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireIntroBanner:Yu},Symbol.toStringTag,{value:"Module"}));function pS({progress:e,onBack:n,onNext:s,nextLabel:r="Next",nextEnabled:a=!0,hideFooter:o=!1,wide:i=!1,children:c}){return t.jsxs("div",{style:{position:"fixed",inset:0,zIndex:60,background:"var(--bg-deep)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",padding:"14px 26px",flexShrink:0,zIndex:4},children:[t.jsx("span",{style:{color:"var(--text-primary)",display:"flex"},children:t.jsx(ms,{className:"h-5"})}),t.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"}),t.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:1.5,background:"rgba(255,255,255,.06)"},children:t.jsx("i",{"data-testid":"onboarding-progress-fill",style:{display:"block",height:"100%",width:`${Math.round(e*100)}%`,background:"var(--accent-active)",transition:"width .5s cubic-bezier(.2,.8,.2,1)"}})})]}),t.jsx("div",{style:{flex:1,minHeight:0,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"20px 26px 90px",overflowY:"auto",overscrollBehavior:"contain"},children:t.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&&t.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&&t.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"}),t.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 zee=Object.freeze(Object.defineProperty({__proto__:null,OnboardingShell:pS},Symbol.toStringTag,{value:"Module"})),hS=3,Ha=112,E$=.5;function fS({value:e,onChange:n,onSubmit:s,files:r,onAddFiles:a,onRemoveFile:o}){const i=l.useRef(null),c=l.useRef(null),[d,u]=l.useState(!1),[p,h]=l.useState(!1),f=e.trim().length>=hS;l.useLayoutEffect(()=>{const g=i.current;if(!g)return;g.style.height="auto";const x=Math.max(Ha,Math.round(window.innerHeight*E$)),b=Math.min(x,Math.max(Ha,g.scrollHeight));g.style.height=`${b}px`,g.style.overflowY=g.scrollHeight>x?"auto":"hidden"},[e]),l.useEffect(()=>{const g=i.current;g&&(g.focus(),g.setSelectionRange(g.value.length,g.value.length))},[]);const m=()=>{f&&s(e)};return t.jsxs("div",{children:[t.jsxs("div",{"data-testid":"prompt-box","data-dragging":d?"true":"false",onDragOver:g=>{g.preventDefault(),u(!0)},onDragLeave:g=>{g.currentTarget.contains(g.relatedTarget)||u(!1)},onDrop:g=>{var b;g.preventDefault(),u(!1);const x=Array.from(((b=g.dataTransfer)==null?void 0:b.files)??[]);x.length&&a(x)},style:{textAlign:"left",background:d?"#2d3020":"var(--bg-input)",border:`1px ${d?"dashed":"solid"} ${d?"var(--accent-active)":p?"var(--line-strong)":"rgba(255,255,255,.09)"}`,borderRadius:16,transition:"border-color .15s, background .15s"},children:[t.jsx("textarea",{ref:i,value:e,onChange:g=>n(g.target.value),onFocus:()=>h(!0),onBlur:()=>h(!1),onKeyDown:g=>{g.key!=="Enter"||g.shiftKey||(g.preventDefault(),m())},onPaste:g=>{var b;const x=Array.from(((b=g.clipboardData)==null?void 0:b.files)??[]);x.length!==0&&(g.preventDefault(),a(x))},placeholder:"Ask CodeYam to build...","aria-label":"Describe what you want to build",style:{display:"block",width:"100%",minHeight:Ha,resize:"none",background:"none",border:0,padding:"20px 22px 6px",fontSize:17,lineHeight:1.5,fontFamily:"inherit",color:"var(--text-primary)",outline:"none"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px 12px"},children:[t.jsxs("button",{type:"button",onClick:()=>{var g;return(g=c.current)==null?void 0:g.click()},title:"Specs, designs, brand assets, screenshots",className:"border border-[var(--line-strong)] bg-white/[0.07] transition-colors hover:border-white/[0.35] hover:bg-white/[0.14]",style:{flex:"none",display:"inline-flex",alignItems:"center",gap:7,height:34,padding:"0 13px 0 10px",borderRadius:9,color:"var(--text-primary)",fontSize:13,fontWeight:500,cursor:"pointer"},children:[t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"var(--accent-active)",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M13.5 7.5l-5.6 5.6a3.2 3.2 0 01-4.5-4.5l5.9-5.9a2.1 2.1 0 013 3l-5.9 5.9a1.1 1.1 0 01-1.5-1.5l5.3-5.3"})}),"Add files"]}),t.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)",minWidth:0},children:"Add every doc you have: specs, designs, brand assets, screenshots."}),t.jsx("span",{style:{flex:1}}),t.jsx("button",{type:"button",onClick:m,disabled:!f,"aria-label":"Start design session",title:"Start design session (Enter)",style:{flex:"none",width:36,height:36,borderRadius:10,border:"none",display:"grid",placeItems:"center",background:f?"var(--accent-active)":"rgba(255,255,255,.08)",color:f?"var(--text-on-accent)":"var(--text-dim)",cursor:f?"pointer":"not-allowed"},children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 8h10M8.5 3.5L13 8l-4.5 4.5"})})})]}),t.jsx("input",{ref:c,type:"file",multiple:!0,"aria-label":"Add files",hidden:!0,onChange:g=>{const x=Array.from(g.target.files??[]);x.length&&a(x),g.target.value=""}})]}),r.length>0&&t.jsx("div",{"aria-label":"Attached files",style:{display:"flex",flexWrap:"wrap",gap:6,padding:"12px 2px 0"},children:r.map((g,x)=>t.jsx(Jr,{file:g,onRemove:()=>o(x)},`${g.name}-${x}`))})]})}const Bee=Object.freeze(Object.defineProperty({__proto__:null,MIN_IDEA_LENGTH:hS,OnboardingPromptBox:fS,PROMPT_MIN_HEIGHT:Ha},Symbol.toStringTag,{value:"Module"}));function mS({selectedName:e,onOpen:n,onClear:s}){return e?t.jsxs("div",{style:{marginTop:8,fontSize:12.5},children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Tech stack: "}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:e}),t.jsx("button",{type:"button",onClick:n,style:Bf,children:"Change"}),t.jsx("button",{type:"button",onClick:s,style:Bf,children:"Clear"})]}):t.jsx("div",{style:{marginTop:8},children:t.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 Bf={background:"none",border:"none",padding:0,marginLeft:10,fontSize:12.5,fontFamily:"inherit",color:"var(--text-dim)",textDecoration:"underline",textUnderlineOffset:3,cursor:"pointer"},Wee=Object.freeze(Object.defineProperty({__proto__:null,StackPickerCollapsed:mS},Symbol.toStringTag,{value:"Module"}));function gS({matches:e,totalStacks:n,query:s,selectedStackId:r,onChoose:a}){return e.length===0?t.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.`}):t.jsx("ul",{role:"listbox","aria-label":"Tech stacks",style:{listStyle:"none",margin:"8px 0 0",padding:0,maxHeight:188,overflowY:"auto"},children:e.map(o=>t.jsx("li",{children:t.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,t.jsx("span",{style:{marginLeft:8,fontSize:11.5,color:"var(--text-dim)"},children:o.description})]})},o.id))})}const Hee=Object.freeze(Object.defineProperty({__proto__:null,StackPickerResults:gS},Symbol.toStringTag,{value:"Module"}));function xS({stacks:e,selectedStackId:n,onSelectStack:s}){const[r,a]=l.useState(!1),[o,i]=l.useState(""),c=l.useRef(null),d=e.find(h=>h.id===n)??null;l.useEffect(()=>{var h;r&&((h=c.current)==null||h.focus())},[r]);const u=l.useMemo(()=>{const h=o.trim().toLowerCase();return h?e.filter(f=>f.name.toLowerCase().includes(h)||f.description.toLowerCase().includes(h)):e},[e,o]),p=h=>{s(h.id),i(""),a(!1)};return r?t.jsxs("div",{style:{marginTop:8},children:[t.jsx("input",{ref:c,type:"text",value:o,onChange:h=>i(h.target.value),onKeyDown:h=>{if(h.key==="Escape"){h.stopPropagation(),i(""),a(!1);return}if(h.key==="Enter"){h.preventDefault(),h.stopPropagation();const f=u[0];f&&p(f)}},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"}}),t.jsx(gS,{matches:u,totalStacks:e.length,query:o,selectedStackId:n,onChoose:p})]}):t.jsx(mS,{selectedName:(d==null?void 0:d.name)??null,onOpen:()=>a(!0),onClear:()=>s(null)})}const qee=Object.freeze(Object.defineProperty({__proto__:null,OnboardingStackPicker:xS},Symbol.toStringTag,{value:"Module"})),bS=[{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 yS({appFormats:e,onToggleFormat:n}){return t.jsxs("div",{role:"group","aria-label":"What kind of thing",style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:8,marginBottom:16},children:[t.jsx("style",{children:`
|
|
69
|
-
.cy-type-chip:not([aria-pressed="true"]):hover {
|
|
70
|
-
border-color: rgba(215,255,99,.55) !important;
|
|
71
|
-
color: var(--text-primary) !important;
|
|
72
|
-
background: rgba(215,255,99,.06) !important;
|
|
73
|
-
}
|
|
74
|
-
.cy-type-chip:focus-visible { outline: 2px solid var(--accent-active); outline-offset: 2px; }
|
|
75
|
-
`}),bS.map(({id:s,label:r})=>{const a=e.includes(s);return t.jsx("button",{type:"button",className:"cy-type-chip","aria-pressed":a,onClick:()=>n(s),style:{background:a?"var(--accent-active)":"rgba(255,255,255,.06)",border:`1px solid ${a?"var(--accent-active)":"rgba(255,255,255,.2)"}`,borderRadius:999,padding:"8px 16px",fontSize:13.5,fontWeight:a?600:500,color:a?"var(--text-on-accent, #14170a)":"rgba(255,255,255,.82)",cursor:"pointer",transition:"background .16s, border-color .16s, color .16s"},children:r},s)})]})}const Uee=Object.freeze(Object.defineProperty({__proto__:null,OnboardingTypeChips:yS,PRODUCT_TYPES:bS},Symbol.toStringTag,{value:"Module"}));function vS({value:e,onChange:n,onSubmit:s,stacks:r=[],selectedStackId:a=null,onSelectStack:o,appFormats:i=[],onToggleFormat:c,files:d=[],onAddFiles:u,onRemoveFile:p}){return t.jsxs("div",{children:[t.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?"}),t.jsxs("div",{style:{maxWidth:720,margin:"0 auto",textAlign:"left"},children:[t.jsx(yS,{appFormats:i,onToggleFormat:c??(()=>{})}),t.jsx(fS,{value:e,onChange:n,onSubmit:s,files:d,onAddFiles:u??(()=>{}),onRemoveFile:p??(()=>{})}),t.jsx(xS,{stacks:r,selectedStackId:a,onSelectStack:o??(()=>{})})]})]})}const Gee=Object.freeze(Object.defineProperty({__proto__:null,OnboardingPromptStep:vS},Symbol.toStringTag,{value:"Module"}));function jS({sound:e,onChange:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontSize:12.5,color:"var(--text-dim)"},children:"Sound"}),t.jsx("select",{value:e,"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:Zl.map(s=>t.jsx("option",{value:s.id,children:s.label},s.id))})]})}const Yee=Object.freeze(Object.defineProperty({__proto__:null,NotificationSoundSelect:jS},Symbol.toStringTag,{value:"Module"}));function wS({onBack:e,onNext:n}){const[s,r]=l.useState(()=>o0());l.useEffect(()=>{d0()},[]);function a(d){r(d),i0(d)}function o(){const d=s.sound==="off"?"soft-double-tap":s.sound;a({...s,systemNotification:!0,sound:d}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function i(){a({...s,systemNotification:!1,sound:"off"})}const c=s.systemNotification;return t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:34,fontWeight:600,letterSpacing:"-.02em",color:"var(--text-primary)",lineHeight:1.15,marginBottom:10},children:"Building takes a few minutes"}),t.jsx("p",{style:{fontSize:15,lineHeight:1.55,color:"var(--text-muted)",marginBottom:20},children:"I'll let you know the moment I need you."}),t.jsxs("div",{style:{maxWidth:720,margin:"0 auto",textAlign:"left"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minHeight:46,padding:"0 14px 0 18px",background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:14},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontSize:14,color:"var(--text-secondary)",cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:c,onChange:d=>d.target.checked?o():i(),style:{width:15,height:15,accentColor:"var(--accent-active)",cursor:"pointer"}}),"Ping me when the build is done"]}),t.jsx("span",{style:{flex:1}}),c&&t.jsx(jS,{sound:s.sound,onChange:d=>{a({...s,sound:d}),d!=="off"&&Ou(d)}})]}),(e||n)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",marginTop:14},children:[e&&t.jsx("button",{type:"button",onClick:e,style:{background:"none",border:"none",padding:0,fontSize:13.5,color:"var(--text-dim)",cursor:"pointer"},children:"← Back"}),t.jsx("span",{style:{flex:1}}),n&&t.jsx("button",{type:"button","data-testid":"onboarding-notifications-next",onClick:n,style:{height:36,padding:"0 16px",borderRadius:10,border:"none",background:"var(--accent-active)",color:"var(--text-on-accent, #14170a)",fontSize:14,fontWeight:700,cursor:"pointer"},children:"Next →"})]})]})]})}const Vee=Object.freeze(Object.defineProperty({__proto__:null,OnboardingNotificationsStep:wS},Symbol.toStringTag,{value:"Module"}));function _S(e){const{projectDir:n,loaded:s}=Co(),r=l.useRef(!1);l.useEffect(()=>{s&&!r.current&&(r.current=!0,K3())},[s]);const[a,o]=l.useState(void 0);return l.useEffect(()=>{if(!s)return;if(n===null){o(null);return}let i=!1;return V3(n).then(c=>{i||o(c)}).catch(()=>{i||o(null)}),()=>{i=!0}},[s,n]),!s||a===void 0?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:t.jsx(Yu,{})}):t.jsx(SS,{...e,projectDir:n,initialDraft:a})}function SS({onComplete:e,onPreviewUrl:n,projectDir:s,initialDraft:r,skipDesignSignal:a=0}){const[o,i]=l.useState(()=>r?r.step:1),[c,d]=l.useState(()=>(r==null?void 0:r.answers)??{appFormats:[],description:"",techStackId:null,designApproach:null,defaultDevice:"Desktop",provider:null}),[u,p]=l.useState(null),[h,f]=l.useState([]),[m,g]=l.useState(()=>(r==null?void 0:r.designChatLaunched)??!1),x=l.useRef(m),{techStacks:b}=X3(),{config:y,refetch:v}=Pt(),j=sd(),{askForProvider:_,declaredProvider:S}=e$(y,j.state,j.probeInFlight);l.useEffect(()=>{S!==null&&d(X=>X.provider?X:{...X,provider:S})},[S]);const w=U3(c.designApproach,{providerDeclared:!_,providerAuth:_?"needs-login":"authenticated"}),k=w[o-1],N=o===w.length;l.useEffect(()=>{_!==null&&o>w.length&&i(w.length)},[_,o,w.length]);const C=l.useRef(Ji(o,c,m)),T=l.useRef((r==null?void 0:r.savedAt)??""),P=l.useRef(!1),R=l.useRef((r==null?void 0:r.submissionKey)??null),L=l.useCallback(X=>{R.current=X},[]),M=l.useCallback(()=>R.current,[]),O=l.useRef(!0);l.useEffect(()=>{if(O.current){O.current=!1;return}if(s===null)return;const X=Ji(o,c,m);if(X===C.current)return;C.current=X;const Q=new Date().toISOString();T.current=Q,z0({step:o,answers:c,designChatLaunched:m,savedAt:Q,submissionKey:R.current??void 0},L)},[o,c,m,s,L]);const z=l.useCallback(X=>{P.current=!0,d(X)},[]),I=l.useRef(c);l.useEffect(()=>{I.current=c},[c]);const Y=l.useCallback(X=>{z(Q=>({...Q,provider:X})),(async()=>{try{await fetch("/api/editor-provider",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:X})})}catch{}await v(),await j.refresh()})()},[z,j,v]),W=l.useCallback(()=>{g(!0)},[]),[A,B]=l.useState(0),[D,J]=l.useState(x.current?{state:"pending"}:{state:"ready",active:null});l.useEffect(()=>{if(!x.current)return;let X=!1;return(async()=>{try{const re=await(await fetch("/api/editor-design-state")).json();X||J({state:"ready",active:re.active??null})}catch{X||J({state:"ready",active:null})}})(),()=>{X=!0}},[A]),l.useEffect(()=>{if(s===null)return;const X=()=>{document.visibilityState==="visible"&&F0().then(Q=>{Q!=null&&Q.submissionKey&&(R.current=Q.submissionKey);const re=J3(Q,T.current,P.current,I.current);re!==null&&(T.current=re.savedAt,re.designChatLaunched&&!x.current&&(x.current=!0,J({state:"pending"}),B(ce=>ce+1)),C.current=Ji(re.step,re.answers,re.designChatLaunched),i(re.step),g(re.designChatLaunched),d(re.answers))})};return document.addEventListener("visibilitychange",X),()=>document.removeEventListener("visibilitychange",X)},[s]);const te=l.useCallback(X=>{d(Q=>({...Q,appFormats:Q.appFormats.includes(X)?Q.appFormats.filter(re=>re!==X):[...Q.appFormats,X]}))},[]),oe=l.useCallback(X=>{d(Q=>({...Q,techStackId:X}))},[]),se=l.useCallback(X=>{f(Q=>[...Q,...X])},[]),G=l.useCallback(X=>{f(Q=>Q.filter((re,ce)=>ce!==X))},[]),le=l.useCallback(()=>{s!==null&&Cf(),e==null||e(c)},[c,e,s]),{submit:ue,submitting:ne,error:E}=H3(c,le,M),H=E?t.jsx(ub,{message:E,onRetry:()=>void ue(),retrying:ne}):null,U=l.useRef(a);l.useEffect(()=>{if(a===U.current)return;U.current=a;const X={...c,designApproach:"skip"};(async()=>(await M0(X,M())).ok&&(s!==null&&Cf(),e==null||e(X)))()},[a,c,e,s,M]);const pe=l.useRef(!1);l.useEffect(()=>{pe.current||D.state==="ready"&&k==="design-details"&&(c.designApproach==="chat"||c.designApproach==="files")&&u!==null&&u!==D.active&&(pe.current=!0,ue())},[k,c.designApproach,u,ue,D]);const ge=j.refresh,Me=l.useCallback(()=>{k==="provider"&&ge(),i(X=>X+1)},[k,ge]),Ce=l.useCallback(()=>{i(X=>X-1)},[]),De=(()=>{switch(k){case"provider":return!!c.provider;case"prompt":return c.description.trim().length>2;case"notifications":return!0;case"design-details":return c.designApproach==="chat"?u!==null:!0;default:return!0}})(),Be=l.useCallback(X=>{d(Q=>({...Q,description:X,appFormats:Q.appFormats.length>0?Q.appFormats:[Q3(X)],designApproach:h.length>0?"files":"chat"})),h.length>0&&Us(h.map((Q,re)=>({id:`prompt-${re}`,file:Q,relativePath:Q.name,description:""}))).catch(Q=>{console.warn("[NewProjectQuestionnaire] could not save prompt files",Q)}),i(Q=>Q+1)},[h]);if(_===null)return t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:t.jsx(Yu,{})});if(k){const X=k==="design-details";if(X)return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[H,t.jsx(rc,{description:c.description,launched:m,onLaunched:W,onDesignSelected:p,onPreviewUrl:n,variant:c.designApproach==="files"?"files":"chat"})]});const Q=N?ue:Me;return t.jsxs(pS,{progress:w.length>1?(o-1)/(w.length-1):0,onBack:o>1?Ce:void 0,onNext:Q,nextEnabled:De&&!ne,hideFooter:k!=="provider",children:[H,t.jsxs("div",{style:{animation:"onboardingSlideIn .44s cubic-bezier(.2,.8,.2,1) both"},children:[k==="provider"&&t.jsx(H0,{selected:c.provider??null,onSelect:Y,onContinueWithoutSignIn:Me,onSignedIn:Me}),k==="prompt"&&t.jsx(vS,{value:c.description,onChange:re=>d(ce=>({...ce,description:re})),onSubmit:Be,stacks:b,selectedStackId:c.techStackId,onSelectStack:oe,appFormats:c.appFormats,onToggleFormat:te,files:h,onAddFiles:se,onRemoveFile:G}),k==="notifications"&&t.jsx(wS,{onBack:Ce,onNext:()=>{ne||Q()}}),X&&t.jsx(rc,{description:c.description,launched:m,onLaunched:W,onDesignSelected:p,onPreviewUrl:n,variant:c.designApproach==="files"?"files":"chat"})]},k)]})}return null}const Kee=Object.freeze(Object.defineProperty({__proto__:null,NewProjectQuestionnaire:_S,NewProjectQuestionnaireInner:SS},Symbol.toStringTag,{value:"Module"}));function kS({projectTitle:e,projectDescription:n,stats:s,coverage:r,onSelectApp:a,configLoading:o,scenariosLoading:i,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:p,stepState:h,onPreviewUrl:f,onComplete:m,onOpenBuildTab:g,onCoverageClick:x,isBuilding:b=!1,buildingLabel:y,buildingStepLabel:v,buildingStepPosition:j,buildingStatus:_,buildingProgress:S,onResetBuild:w,emptyStateBuildStatus:k,skipDesignSignal:N=0}){const{saved:C}=h0(),T=si(),[P,R]=l.useState(null),L=y0(T);return s.length===0?o||i||C===null?null:f0({appStatsLength:s.length,configLoading:!!o,scenariosLoading:!!i,setupAnswersSaved:C,hasStepState:!!h})?t.jsx(_S,{onPreviewUrl:f,onComplete:m,skipDesignSignal:N}):(T==null?void 0:T.state)==="interrupted"&&P!==T.id&&!Nb(T.id)?t.jsx("div",{className:"mx-auto max-w-2xl px-5 py-12",children:t.jsx(Fd,{request:T,onRecovered:g??(()=>{}),onKeptForLater:()=>R(T.id)})}):t.jsx(b0,{projectDescription:n??null,status:k,buildRequestedAt:(T==null?void 0:T.createdAt)??null,failureReason:(T==null?void 0:T.failureReason)??null,launchRecovery:T&&Ad(T.state)?t.jsx(Md,{state:T.state,cause:T.failureReason??null,...L,onOpenTerminal:g}):null,onOpenBuildTab:g??(()=>{})}):t.jsx("div",{className:"px-5 py-5",children:t.jsxs("div",{style:{width:"100%",maxWidth:1e3,marginInline:"auto"},children:[t.jsx(j0,{projectTitle:e,coverage:r,onCoverageClick:x}),t.jsx(A0,{isBuilding:b,buildingLabel:y,buildingStepLabel:v,buildingStepPosition:j,buildingStatus:_,buildingProgress:S,buildingMode:h==null?void 0:h.mode,onOpenBuilding:g??(()=>{}),onResetBuild:w??(()=>{})}),t.jsx(v0,{stats:s,onSelectApp:a,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:p})]})})}const Jee=Object.freeze(Object.defineProperty({__proto__:null,AppOverview:kS},Symbol.toStringTag,{value:"Module"}));function NS({sessionContent:e,stepIndicator:n}){return t.jsxs("div",{className:"flex flex-col h-full",children:[n,e]})}const Xee=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLayout:NS},Symbol.toStringTag,{value:"Module"}));function CS({activeTab:e,launchBanner:n=null,buildTab:s,resultsPanel:r,minimizedResults:a,resultsMode:o,badgeGutter:i=!0}){return t.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:e==="build"?"visible":"hidden",pointerEvents:e==="build"?"auto":"none"},children:[n?t.jsx("div",{className:"shrink-0 p-2",children:n}):null,t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[t.jsx("div",{style:{flex:"1 1 auto",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:s}),o==="full"?t.jsx(jx,{children:r}):null,o==="minimized"?a:null]}),i&&t.jsx("div",{"data-testid":"build-pane-badge-gutter","aria-hidden":"true",className:"h-6 shrink-0"})]})}const Qee=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPaneLayout:CS},Symbol.toStringTag,{value:"Module"}));function A$(e="build"){return{title:`CodeYam found a saved ${e} session`,description:"",buttonLabel:"Resume Session",providersLabel:null}}function M$(e,n){const s=st(e),r=st(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 I$({resumeMode:e,previousProvider:n,currentProvider:s,sessionKind:r="build"}){return e!=="handoff"||n==null||s==null||n===s?A$(r):M$(n,s)}const Wf=140;function D$(e){const n=e.trim();return n.startsWith("/")||n.startsWith("The session was interrupted.")}function L$(e){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.role!=="user"||!s.text.trim()||D$(s.text))continue;const r=s.text.replace(/\s+/g," ").trim();return r.length<=Wf?r:`${r.slice(0,Wf-1).trimEnd()}…`}return null}function $$(e){return e==="prototype"||e==="plan"||e==="chat"?e:"build"}function Qi(e,n){return`${e} ${n}${e===1?"":"s"} ago`}function F$(e){if(e==null||e<0)return null;if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return Qi(n,"minute");const s=Math.floor(n/60);return s<24?Qi(s,"hour"):Qi(Math.floor(s/24),"day")}function TS({label:e,onContinue:n}){return t.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:e})}const Zee=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryActionButton:TS},Symbol.toStringTag,{value:"Module"}));function PS({children:e}){return t.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:t.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:e})})}const ete=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryDialog:PS},Symbol.toStringTag,{value:"Module"}));function OS({description:e,title:n}){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--text-primary)"},children:n}),e&&t.jsx("p",{className:"text-sm mb-4",style:{color:"var(--text-muted)"},children:e})]})}const tte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryHeader:OS},Symbol.toStringTag,{value:"Module"}));function Rs({label:e,rowClassName:n,value:s}){return t.jsxs("div",{className:n,children:[t.jsxs("span",{style:{color:"var(--text-muted)"},children:[e,":"]})," ",t.jsx("span",{style:{color:"var(--text-primary)"},children:s})]})}const nte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummaryRow:Rs},Symbol.toStringTag,{value:"Module"}));function RS({featureName:e,editorStep:n,editorStepLabel:s,providersLabel:r,lastRequest:a=null,lastActive:o=null}){return!e&&(n==null||!s)&&!r&&!a&&!o?null:t.jsxs("div",{className:"rounded p-3 mb-5 text-sm flex flex-col gap-1",style:{background:"var(--bg-deep)"},children:[e&&t.jsx(Rs,{label:"Feature",value:e}),n!=null&&s&&t.jsx(Rs,{label:"Step",value:`${n} (${s})`}),a&&t.jsx(Rs,{label:"Last request",value:a}),o&&t.jsx(Rs,{label:"Last active",value:o}),r&&t.jsx(Rs,{label:"Providers",value:r})]})}const ste=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummary:RS},Symbol.toStringTag,{value:"Module"}));function z$(e){const n=l.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),e())},[e]);l.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n])}function B$(e){const[n,s]=l.useState(void 0);return l.useEffect(()=>{if(s(void 0),!e)return;let r=!1;return fetch(`/api/editor-agent-chat?session=${encodeURIComponent(e)}`).then(a=>a.ok?a.json():void 0).then(a=>{r||!a||s(a.available?L$(a.messages):null)}).catch(()=>{}),()=>{r=!0}},[e]),n}function ES({featureName:e,editorStep:n,workflowMode:s,previousProvider:r,currentProvider:a,resumeMode:o,sessionId:i=null,activity:c=null,idleSeconds:d=null,onContinue:u,onStartOver:p,onEmptySession:h}){const f=I$({resumeMode:o,previousProvider:r,currentProvider:a,sessionKind:$$(c)}),m=n==null?null:Ru(n,s),g=B$(i);z$(u);const x=g===null&&!e&&n==null,b=l.useRef(!1);return l.useEffect(()=>{x&&h&&!b.current&&(b.current=!0,h())},[x,h]),t.jsxs(PS,{children:[t.jsx(OS,{title:f.title,description:f.description}),t.jsx(RS,{featureName:e,editorStep:n,editorStepLabel:m,providersLabel:f.providersLabel,lastRequest:g===null?"Nothing asked yet":g??null,lastActive:F$(d)}),t.jsx(TS,{label:f.buttonLabel,onContinue:u}),p&&t.jsx("button",{type:"button",onClick:p,className:"mt-3 w-full text-center text-xs underline underline-offset-2 cursor-pointer transition",style:{color:"var(--text-muted)"},children:"Start over"})]})}const rte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecovery:ES},Symbol.toStringTag,{value:"Module"}));function AS({currentProvider:e,editorStep:n,featureName:s,onContinue:r,onStartOver:a,onEmptySession:o,previousProvider:i,resumeMode:c,workflowMode:d,sessionId:u,activity:p,idleSeconds:h}){return t.jsx(ES,{featureName:s,editorStep:n,workflowMode:d,previousProvider:i,currentProvider:e,resumeMode:c,sessionId:u,activity:p,idleSeconds:h,onContinue:r,onStartOver:a,onEmptySession:o})}const ate=Object.freeze(Object.defineProperty({__proto__:null,BuildTabRecoveryPanel:AS},Symbol.toStringTag,{value:"Module"}));function js(){let e=!1;const n=new Set;return{get:()=>e,set:s=>{if(e!==s){e=s;for(const r of n)r()}},subscribe:s=>(n.add(s),()=>n.delete(s))}}const Vu=js(),Ku=js(),MS=Vu.get,Ju=Vu.set,IS=Vu.subscribe,ac=Ku.get,Xu=Ku.set,DS=Ku.subscribe;function W$({sessionDecision:e,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&&(e==="continue"||e==="fresh"||e==="no-session")&&(r!==null||n!==null),shouldResumeSameProvider:e==="continue"&&(n==null?void 0:n.resumeMode)==="resume"}}const LS="codeyam:chat-milestones:",oc=new Map;function H$(e){const n=oc.get(e);if(n)return n;try{const s=window.sessionStorage.getItem(LS+e);if(!s)return null;const r=JSON.parse(s);return Array.isArray(r.milestones)?(r.milestones=r.milestones.filter(a=>a&&"afterId"in a),oc.set(e,r),r):null}catch{return null}}function Hf(e,n){oc.set(e,n);try{window.sessionStorage.setItem(LS+e,JSON.stringify(n))}catch{}}const $S="codeyam.buildChatExperimentalNoticeDismissed",q$="Chat is an experimental feature designed to make working with AI more intuitive and friendly. It is still experimental, though, so for now we recommend continuing to use the Terminal which shows the raw agent output";function U$(){try{return window.localStorage.getItem($S)==="1"}catch{return!1}}function G$(){try{window.localStorage.setItem($S,"1")}catch{}}const qf="linear-gradient(to right, transparent, var(--border-default) 20%, var(--border-default) 80%, transparent) 1";function ra(e){return e==="top"?{borderTop:"1px solid",borderImage:qf}:{borderBottom:"1px solid",borderImage:qf}}function Y$(e){for(const n of e??[]){if(!/Waiting for API response/i.test(n))continue;const s=/will retry in\s+([0-9hms ]+?)(?:\s*·|\s*$)/i.exec(n);return{retryIn:s?s[1].trim():null}}return null}const Uf="⏺",V$=/^[A-Za-z][\w.:-]*\(/,K$=/^\s*(⎿|[─━╭╰│]|[✻✶✳✢·*]\s|❯|>\s)/;function J$(e){const n=e??[];let s=-1;for(let i=n.length-1;i>=0;i--)if(n[i].startsWith(`${Uf} `)){s=i;break}if(s<0)return null;const r=n[s].slice(Uf.length+1);if(V$.test(r))return null;const a=[r.trimEnd()];for(let i=s+1;i<n.length;i++){const c=n[i];if(c.trim()===""){a.push("");continue}if(!c.startsWith(" ")||K$.test(c))break;a.push(c.slice(2).trimEnd())}return a.join(`
|
|
76
|
-
`).replace(/\n{3,}/g,`
|
|
77
|
-
|
|
78
|
-
`).trim()||null}function Zi(e){return e.replace(/[*_`#>]/g,"").replace(/\s+/g," ").trim().toLowerCase()}function X$(e,n){if(!n)return e;const s=Zi(n).slice(0,60);return!s||e.filter(a=>a.role==="agent").slice(-3).some(a=>Zi(a.text).startsWith(s)||s.startsWith(Zi(a.text).slice(0,60)))?e:[...e,{id:"live-reply",role:"agent",text:n,items:[]}]}const Qu=l.createContext(null);function FS({title:e,workflow:n=null,children:s}){const[r,a]=l.useState(0),o=l.useCallback(()=>(a(h=>h+1),()=>a(h=>h-1)),[]),i=(n==null?void 0:n.step)??0,c=(n==null?void 0:n.total)??0,d=(n==null?void 0:n.mode)??"",u=l.useMemo(()=>i>0?{step:i,total:c,mode:d}:null,[i,c,d]),p=l.useMemo(()=>({title:e,workflow:u,claim:o}),[e,u,o]);return t.jsx(Qu.Provider,{value:p,children:s(r>0)})}function zS(){const e=l.useContext(Qu),n=e==null?void 0:e.claim;return l.useLayoutEffect(()=>n?n():void 0,[n]),e?e.title:null}function BS(){var e;return((e=l.useContext(Qu))==null?void 0:e.workflow)??null}const ote=Object.freeze(Object.defineProperty({__proto__:null,SessionHeaderProvider:FS,useSessionHeaderTitle:zS,useSessionWorkflow:BS},Symbol.toStringTag,{value:"Module"})),WS=15e3,Q$=90;function Z$(e,n){if(!n)return!1;const s=r=>`${r.text.join(`
|
|
79
|
-
`)}
|
|
80
|
-
${r.options.map(a=>a.label).join(`
|
|
81
|
-
`)}`;return s(e)===s(n)}const Gf="waiting for a background task",Yf=Dn,eF=2e3,Vf=8e3;function aa({renderTerminal:e,initialSessionId:n=null,height:s="100%",label:r,sessionName:a,onClose:o,footer:i,headerNote:c,handoff:d,intro:u,renderWrittenFile:p,onWaitingOnUser:h,onNeedsYouChange:f,startFreshOnNewRequest:m=!1,initialRequest:g=null,onWorkingChange:x,initialView:b="chat",experimentalNotice:y}){const[v,j]=l.useState(b),[_,S]=l.useState(U$),w=()=>{S(!0),G$()},[k,N]=l.useState(!1),C=zS(),[T,P]=l.useState(n),[R,L]=l.useState(null),M=l.useRef(null),[O,z]=l.useState(!1),[I,Y]=l.useState(null),[W,A]=l.useState(null),[B,D]=l.useState(!1),J=l.useRef(m);J.current=m;const te=l.useMemo(()=>({onSessionId:ae=>{ae&&P(ae)},onNotice:Y,onScreen:L,onSender:ae=>{M.current=ae,z(!!ae)},onReattached:ae=>{ae&&J.current&&D(!0)}}),[]),oe=l.useMemo(()=>e(te),[te,e]),se=T?`/api/editor-agent-chat?session=${encodeURIComponent(T)}`:"",G=Lu(!!T,se);l.useEffect(()=>{!B||!G.available||(D(!1),A({session:T,count:G.messages.length}))},[B,G.available,G.messages.length,T]);const le=W&&W.session===T?W.count:null,ue=l.useMemo(()=>le===null?G.messages:G.messages.slice(le),[G.messages,le]),ne=ae=>{var ke;return((ke=M.current)==null?void 0:ke.call(M,ae))??!1},[E,H]=l.useState(()=>g?[{id:"opening-request",text:g,after:0}]:[]),[U,pe]=l.useState(null),ge=ae=>{const ke=_d(ae);return Cr(ne,ke)?(H(Ze=>[...Ze,{id:`${Date.now()}-${Ze.length}`,text:ke.replace(/\r$/,""),after:ue.length}]),!0):!1},Me=ae=>void ge(ae),Ce=async ae=>{pe(null);try{await Us(ae.map((ke,Ze)=>({id:`chat-${Date.now()}-${Ze}`,file:ke,relativePath:ke.name,description:""})))}catch(ke){return pe(ke instanceof Error?ke.message:"Couldn't add those files."),null}return Mo(ae.map(ke=>ke.name))},De=async(ae,ke)=>{pe(null);let Ze=ae;if(ke.length>0){const _t=await Ce(ke);if(_t===null)return!1;Ze=ae?`${_t} ${ae}`:_t}return ge(Ze)},Be=l.useMemo(()=>ii(ue,E),[ue,E]),X=Be.length===0,[Q,re]=l.useState(!1),ce=!G.available||X;l.useEffect(()=>{if(!ce||!O){re(!1);return}const ae=window.setTimeout(()=>re(!0),WS);return()=>window.clearTimeout(ae)},[ce,O]);const _e=l.useMemo(()=>zu(R),[R]),Te=l.useMemo(()=>G.working?X$(ue,J$(R)):ue,[G.working,ue,R]),Oe=l.useMemo(()=>Y$(R),[R]),he=l.useMemo(()=>wM(R),[R]),xe=l.useMemo(()=>Gu(R),[R]),Fe=ae=>ae.forEach((ke,Ze)=>{window.setTimeout(()=>ne(ke),Ze*Q$)}),[F,ee]=l.useState(null),[de,ie]=l.useState(0),fe=()=>{_e&&ee(_e),ie(Date.now())},[ve,be]=l.useState(!1);l.useEffect(()=>{if(!de)return;be(!0);const ae=window.setTimeout(()=>be(!1),Vf);return()=>window.clearTimeout(ae)},[de]);const We=ve&&!!_e&&Z$(_e,F),ze=!!_e&&!We||!!xe,Re=ae=>{_e&&(fe(),Fe(na(_e,ae)))},Ye=(ae,ke)=>{_e&&(fe(),Fe(oi(_e,ae,ke)))},rt=G.question?G.question.map(ae=>ae.question).join(`
|
|
82
|
-
`):null,[je,Ve]=l.useState(null),[Se,Qe]=l.useState(!1);l.useEffect(()=>{if(je===null)return;Qe(!1);const ae=window.setTimeout(()=>Qe(!0),Vf);return()=>window.clearTimeout(ae)},[je]),l.useEffect(()=>{je!==null&&rt!==je&&Ve(null)},[rt,je]);const K=Se&&!!G.question&&!!_e&&jr(G.question,_e)>=0,V=je!==null&&je===rt&&!K,we=ae=>{fe(),ae.last&&(Ve(rt),H(ke=>[...ke,{id:`answer-${Date.now()}`,text:ae.text,after:ue.length}]))},Ue=G.question&&!V&&!(_e===null&&jr(G.question,F)>=0)?G.question:null,Ge=!!Ue&&!!_e&&jr(Ue,_e)<0,gt=Be.some(ae=>ae.id.startsWith("pending-")),at=!ze&&!Ue&&(G.working||gt),it=l.useMemo(()=>{for(let ae=ue.length-1;ae>=0;ae--){const ke=ue[ae];if(ke.role==="activity")for(let Ze=ke.items.length-1;Ze>=0;Ze--){const _t=/^(?:Wrote|Edited) (.+)$/.exec(ke.items[Ze]);if(_t)return _t[1]}}return null},[ue]),Je=BS(),xt=G.messages.length>0?G.messages[G.messages.length-1].id:null,He=l.useRef(xt);He.current=xt;const[jt,q]=l.useState([]),Ft=l.useRef(jt);Ft.current=jt;const Et=l.useRef(null),wt=l.useRef(null);l.useEffect(()=>{if(!T||wt.current===T)return;wt.current=T;const ae=H$(T);ae&&(Ft.current=ae.milestones,q(ae.milestones),Et.current=ae.lastStep)},[T]),l.useEffect(()=>{if(T&&wt.current!==T)return;const ae=Et.current;if(Et.current=(Je==null?void 0:Je.step)??null,!Je||ae===null||Je.step<=ae){T&&Hf(T,{milestones:Ft.current,lastStep:Et.current});return}const ke=Array.from({length:Je.step-ae},(_t,ws)=>ae+ws),Ze=[...Ft.current,...ke.map((_t,ws)=>({id:`${_t}-${Ft.current.length+ws}`,text:Mu(_t,Je.mode).primary,detail:`${_t}/${Je.total}`,afterId:He.current}))];q(Ze),T&&Hf(T,{milestones:Ze,lastStep:Je.step})},[Je,T]);const es=Je?Math.min(1,Math.max(0,(Je.step-1)/Je.total)):null,Pn=ue[ue.length-1],en=O&&!at&&!ze&&(Pn==null?void 0:Pn.role)==="agent"&&wd(Pn.text),Ct=!!d&&!ze&&!Ue,ts=O&&!ze&&!Ct&&!X&&G.available&&!at&&he===0,[On,Rn]=l.useState(!1);l.useEffect(()=>{if(!ts){Rn(!1);return}const ae=window.setTimeout(()=>Rn(!0),eF);return()=>window.clearTimeout(ae)},[ts]);const tn=O?ze?"waiting on you":Ct?"working":X?Q?"running":"starting":G.available?at?"working":he>0?Gf:On?"waiting on you":"working":"running":"starting",nn=O&&(!!Ue||ze),At=!Ct&&(en||!!Ue||tn==="waiting on you"),En=l.useRef(!1),pn=l.useRef(h);pn.current=h,l.useEffect(()=>{var ae;nn&&!En.current&&((ae=pn.current)==null||ae.call(pn)),En.current=nn},[nn]);const qe=l.useRef(f);qe.current=f,l.useEffect(()=>{var ae;(ae=qe.current)==null||ae.call(qe,At)},[At]),l.useEffect(()=>()=>{var ae;return(ae=qe.current)==null?void 0:ae.call(qe,!1)},[]);const lt=!At&&(tn==="working"||tn==="starting"),Xe=!At&&tn===Gf,[hn,fn]=l.useState(null);l.useEffect(()=>{fn(Xe?Date.now():null)},[Xe]);const ns=O&&(lt||Xe),sn=l.useRef(x);sn.current=x,l.useEffect(()=>{var ae;(ae=sn.current)==null||ae.call(sn,ns)},[ns]),l.useEffect(()=>()=>{var ae;return(ae=sn.current)==null?void 0:ae.call(sn,!1)},[]);const Zs=lt?t.jsx("span",{"data-testid":"agent-chat-status-mark","data-mark":"spinner",style:{display:"flex",flex:"none"},children:t.jsx(Wt,{size:11})}):t.jsx("span",{"aria-hidden":"true","data-testid":"agent-chat-status-mark","data-mark":"dot",className:At?"animate-pulse":void 0,style:{flex:"none",width:8,height:8,borderRadius:"50%",background:At?ht:Xe?Yf:"rgba(255,255,255,.35)"}}),er=t.jsxs("span",{"data-testid":"agent-chat-status","data-needs-you":At?"true":"false",style:{flex:"none",fontSize:12,fontWeight:400,color:At?ht:lt?"var(--working)":Xe?Yf:"rgba(255,255,255,.45)",whiteSpace:"nowrap"},children:[At?so:tn.charAt(0).toUpperCase()+tn.slice(1),At?t.jsx(Kn,{variant:"pulse"}):(lt||Xe)&&t.jsx(Kn,{})]});return t.jsx(Gr.Provider,{value:Me,children:t.jsxs("div",{role:"region","aria-label":r,"data-testid":"agent-chat-pane",style:{display:"flex",flexDirection:"column",height:s,minHeight:0,flex:s==="100%"?1:void 0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:`8px ${cn}px`,...ra("bottom"),flex:"none",position:"relative"},children:[es!==null&&t.jsx("div",{"aria-hidden":"true","data-testid":"agent-chat-progress","data-progress":es.toFixed(3),style:{position:"absolute",left:0,bottom:-1,height:2,width:`${es*100}%`,background:"var(--working)",borderRadius:"0 2px 2px 0",transition:"width 600ms ease",pointerEvents:"none"}}),C?t.jsx("div",{"data-testid":"agent-chat-session-title",style:{minWidth:0,flex:"0 1 auto"},children:C(lt?{mark:null,label:null,note:c}:{mark:Zs,label:er,note:c})}):t.jsxs("span",{style:{display:"flex",flex:"none",flexDirection:"column",gap:2,minWidth:0},children:[t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[Zs,er]}),c&&t.jsx("span",{style:{fontSize:11.5,color:"var(--text-muted)"},children:c})]}),t.jsx(ri,{view:v,onChange:j,className:"ml-auto"}),o&&t.jsx("button",{type:"button","aria-label":"Close session",title:"Close session",onClick:()=>N(!0),className:"hover:bg-white/[0.06] hover:text-[var(--text-primary)]",style:{background:"none",border:"none",padding:4,marginRight:-4,borderRadius:6,color:"rgba(255,255,255,.45)",cursor:"pointer",display:"flex",alignItems:"center"},children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:t.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})}),o&&k&&t.jsx(Nx,{sessionName:a,onCancel:()=>N(!1),onConfirm:()=>{N(!1),o()}})]}),t.jsxs("div",{style:{position:"relative",flex:1,minHeight:0},children:[t.jsx("div",{"aria-hidden":"true","data-testid":"agent-chat-header-shadow",style:{position:"absolute",top:0,left:0,right:0,height:20,zIndex:2,pointerEvents:"none",background:"linear-gradient(to bottom, rgba(0,0,0,.5), rgba(0,0,0,0))"}}),t.jsx("div",{style:{position:"absolute",inset:0,zIndex:0,display:"flex",flexDirection:"column",paddingLeft:14},children:oe}),v==="chat"&&Ct&&t.jsx("div",{"data-testid":"agent-chat-handoff",style:{position:"absolute",inset:0,zIndex:3},children:d}),v==="chat"&&(O||G.messages.length>0)&&t.jsxs("div",{"data-testid":"agent-chat-view",style:{position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",background:"var(--bg-deep, #141414)"},children:[y&&!_&&t.jsx(kl,{role:"note",testId:"agent-chat-experimental-notice",onDismiss:w,children:y}),I&&t.jsx(kl,{role:"status",testId:"agent-chat-notice",onDismiss:()=>Y(null),children:I}),t.jsx(sa,{messages:Te,working:G.working,waiting:ze,intro:u,pending:E,milestones:jt,timerScope:T,lastReplyBackground:Xe,onOpenTerminal:()=>j("terminal"),awaitingReply:en,startingText:`Starting the ${a}…`,emptyState:Q?t.jsxs("div",{"data-testid":"agent-chat-log-missing",style:{fontSize:13,color:"var(--text-muted)",display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"},children:["The chat can't read this agent's messages. It is running: follow it in the terminal.",t.jsx("button",{type:"button",onClick:()=>j("terminal"),style:{padding:"5px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:"pointer"},children:"Open Terminal"})]}):void 0}),Xe&&hn!==null&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:yn,children:t.jsx(Px,{since:hn,onCheck:()=>void ge(Tx)})}),Oe&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:yn,children:t.jsxs("div",{role:"status","data-testid":"agent-chat-api-retry",style:{border:"1px solid rgba(239,111,111,.4)",background:"rgba(239,111,111,.08)",borderRadius:10,padding:"9px 12px",fontSize:12.5,color:"#ef8f8f",display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:"#ef6f6f",flex:"none"}}),t.jsxs("span",{children:["Can't reach the AI right now.",Oe.retryIn?` Retrying in ${Oe.retryIn}.`:" Retrying."," Check your network."]})]})}),Ue&&!Ge&&t.jsxs("div",{"data-testid":"agent-chat-card-slot",style:yn,children:[it&&p?p(it):null,t.jsx(Uu,{questions:Ue,screenPrompt:_e,send:ae=>void ne(ae),onAnswered:we,onOpenTerminal:()=>j("terminal"),attach:Ce})]}),xe&&!_e&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:yn,children:t.jsx(Io,{login:xe,onSubmitCode:ae=>Fe([ae,"\r"]),onOpenTerminal:()=>j("terminal")})}),_e&&!We&&(!Ue||Ge)&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:yn,children:t.jsx(ci,{prompt:_e,onChoose:Re,onAnswer:Ye,onOpenTerminal:()=>j("terminal"),attach:Ce})}),t.jsx(li,{disabled:!O,busyNote:U,awaiting:en,onSend:De})]})]}),i&&t.jsx("div",{"data-testid":"agent-chat-footer",style:{flex:"none",padding:`0 ${cn}px 10px`},children:i})]})})}const ite=Object.freeze(Object.defineProperty({__proto__:null,AGENT_CHAT_UNAVAILABLE_AFTER_MS:WS,AgentChatPane:aa},Symbol.toStringTag,{value:"Module"})),qa=8e3,tF="agent-banner-ready",nF="agent-auth-required";let po=!1,ho=!1,_n=[],Kf=!1,$n=null,Bn=null,Ua=!1;function sF(){Kf||typeof window>"u"||(Kf=!0,window.addEventListener(tF,()=>{const e=!ho;if(e){ho=!0;const n=_n;_n=[];for(const s of n)s("banner")}if(Ua&&(Ua=!1,Bn&&$n===null)){me("dispatch-rename-after-auth",{label:Bn.label,reason:"first-observed-frame-after-auth"}),$n=Bn,Tr(Bn.label,Bn.send,void 0,"rename-coordinator-after-auth");return}$n&&(me("dispatch-rename-reapply",{label:$n.label,reason:e?"first-observed-frame":"second-observed-frame"}),Tr($n.label,$n.send,void 0,"rename-coordinator-reapply"))}),window.addEventListener(nF,()=>{Ua=!0,me("agent-auth-required-observed",{});const e=_n;_n=[];for(const n of e)n("auth-required")}))}sF();function rF(){return ho?Promise.resolve("banner"):new Promise(e=>{let n=!1;const s=a=>{n||(n=!0,clearTimeout(r),e(a))};_n.push(s);const r=setTimeout(()=>{if(n)return;n=!0;const a=_n.indexOf(s);a>=0&&_n.splice(a,1),e("fallback")},qa)})}async function HS(e,n,s=0,r=NR,a=!1){if(po){me("dispatch-rename-suppressed",{caller:n,label:e});return}po=!0,Bn={label:e,send:r},me("dispatch-rename",{phase:"queued",caller:n,label:e,fallbackMs:qa,postReadyDelayMs:s});const o=await rF();if(o==="auth-required"){me("dispatch-rename-deferred-for-auth",{caller:n,label:e});return}if(a&&o==="fallback"){me("dispatch-rename-skipped-no-banner",{caller:n,label:e,fallbackMs:qa});return}s>0&&await new Promise(i=>setTimeout(i,s)),o==="fallback"&&me("dispatch-rename-fallback",{caller:n,label:e,fallbackMs:qa}),me("dispatch-rename",{phase:"fired",caller:n,label:e,source:o,postReadyDelayMs:s}),$n={label:e,send:r},Tr(e,r,void 0,n)}function aF(){po=!1,ho=!1,_n=[],$n=null,Bn=null,Ua=!1}function oF(){po=!1,_n=[],Bn=null}const iF="Editor";function qS(e){return e??iF}function lF({provider:e,agentStartMode:n,currentFeature:s}){const r=l.useRef(!1);l.useEffect(()=>{if(!(r.current||!kg(e)||n!=="fresh")){if(s!==null){r.current=!0;return}r.current=!0,HS(qS(s),"build-session-seed",Ng,void 0,!0)}},[e,n,s])}function ic(e,n){const[s,r]=l.useState(e),a=l.useRef(null);return l.useEffect(()=>{if(e!==!1){a.current!==null&&(window.clearTimeout(a.current),a.current=null),r(e);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)}},[e,n]),s}function cF(e,n){const[s,r]=l.useState(!1),a=l.useRef(null);return l.useEffect(()=>{if(!e){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)}},[e,n]),s}const dF=120*1e3,wr=1500;class uF{constructor(n,s,r=me){an(this,"deferred",!1);an(this,"userActiveSinceLastOutput",!1);an(this,"lastActivitySource",null);an(this,"lastActivityAt",null);an(this,"lastNotificationTime",null);an(this,"actions");an(this,"env");an(this,"now");an(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<wr;if(s&&r&&c)return this.userActiveSinceLastOutput=!1,this.log("suppressed-user-active",i),"suppressed";if(a!==null&&a<dF)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 US({onDismiss:e,providerLabel:n}){return t.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:t.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FFB454]/60 bg-[#2a1f0d]",children:[t.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FFB454] shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm text-[#FFD199]",children:[n," needs"," ",t.jsx("span",{className:"font-medium",children:"your approval to continue"}),"."]}),t.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."})]}),t.jsx("button",{type:"button",onClick:e,className:"shrink-0 p-0.5 mt-1 text-[#FFD199]/60 hover:text-[#FFD199] transition-colors cursor-pointer",title:"Dismiss",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const lte=Object.freeze(Object.defineProperty({__proto__:null,BlockedBanner:US},Symbol.toStringTag,{value:"Module"}));function GS({snippet:e,onRetry:n,onDismiss:s,providerLabel:r}){return t.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:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium text-sm mb-1",children:[r," didn't start"]}),t.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:e})]}),t.jsxs("div",{className:"flex items-start gap-2 shrink-0",children:[t.jsx(mt,{variant:"subtle",text:e,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"}),t.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"}),t.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 cte=Object.freeze(Object.defineProperty({__proto__:null,BuildTabStartupError:GS},Symbol.toStringTag,{value:"Module"}));function YS(e=768){const n=`(max-width: ${e-.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 VS=[{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 KS({defaultOpen:e=!1,currentFeature:n=null}){return YS()?t.jsx(JS,{defaultOpen:e,currentFeature:n}):null}function JS({defaultOpen:e=!1,currentFeature:n=null}){const{config:s}=Pt(),[r,a]=l.useState(e),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(()=>a(!1),[]);zo(o,c,i);const d=s&&s.mobileTerminalCommands.length>0?s.mobileTerminalCommands:VS,u=l.useCallback(f=>{f.submit?Ja(f.send):CR(f.send),a(!1)},[]),p=l.useCallback(()=>{Tr(qS(n),void 0,void 0,"mobile-command-menu"),a(!1)},[n]),h=kg(s==null?void 0:s.provider);return t.jsxs("div",{className:"absolute top-2 right-2 z-20 flex flex-col items-end",children:[t.jsx("button",{ref:i,type:"button","data-testid":"mobile-command-menu-toggle","aria-haspopup":"menu","aria-expanded":r,"aria-label":"Terminal commands",onClick:()=>a(f=>!f),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&&t.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((f,m)=>t.jsx("button",{type:"button",role:"menuitem","data-testid":`mobile-command-${m}`,onClick:()=>u(f),className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:f.label},`${f.label}-${m}`)),h&&t.jsx("button",{type:"button",role:"menuitem","data-testid":"mobile-command-rename-session",onClick:p,className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:"Rename Session"})]})]})}const dte=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MOBILE_TERMINAL_COMMANDS:VS,MobileTerminalCommandMenu:KS,MobileTerminalCommandMenuPanel:JS},Symbol.toStringTag,{value:"Module"}));function pF(e){const n=Math.floor(e/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 XS({silentMs:e,onDismiss:n,providerLabel:s}){const{sendToAgent:r,agentReady:a}=No();return t.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:t.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FF5A5A]/60 bg-[#2a0d0d]",children:[t.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FF5A5A] shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm text-[#FF8B8B]",children:[s," has been mid-turn with no output for"," ",t.jsx("span",{className:"font-medium",children:pF(e)}),"."]}),t.jsxs("p",{className:"text-xs text-[#FF8B8B]/70 mt-1",children:["If you no longer see the input box, interrupt (Ctrl-C) to bring it back, then ask ",s," to resume. If you can still type,"," ",s," may just be on a long step."]})]}),t.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)"}),t.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:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const ute=Object.freeze(Object.defineProperty({__proto__:null,StuckTurnBanner:XS},Symbol.toStringTag,{value:"Module"})),hF="codeyam.terminalScrollDebug";function fF(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem(hF))==="1"}catch{return!1}}function ar(e,n,s){if(fF())try{const r=n.buffer.active,a={trigger:e,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 Zu(e){const[n,s]=l.useState(0);l.useEffect(()=>{if(n===0)return;const a=window.setTimeout(()=>s(0),e);return()=>window.clearTimeout(a)},[n,e]);const r=l.useCallback(()=>{s(a=>a+1)},[]);return[n>0,r]}function mF(e=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),e);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 gF({session:e,attempts:n,max:s}){return e!=="stale"?"check-transport":n<s?"reacquire":"give-up"}async function Jf(e=1500){try{const n=await fetch("/api/session-info",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(e)});if(!n.ok)return null;const s=await n.json();return xF(s==null?void 0:s.buildSessionExit)}catch{return null}}function xF(e){if(typeof e!="object"||e===null)return null;const n=e;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 bF({baseline:e,current:n}){return n?e===void 0?{kind:"transport"}:e===null?{kind:"process-death",report:n}:n.atUnixSecs!==e.atUnixSecs||n.pid!==e.pid?{kind:"process-death",report:n}:{kind:"transport"}:{kind:"transport"}}function di(){return t.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 pte=Object.freeze(Object.defineProperty({__proto__:null,TerminalCopiedToast:di},Symbol.toStringTag,{value:"Module"}));function yF(e){return e==="waived-by-grant"||e==="disabled-in-config"?e:"not-a-check-in"}const vF=1e4;let vn=null;const lc=new Set;function jF(e,n){if(!(!e&&(vn!=null&&vn.serverInjects)&&!vn.consumed)){vn={serverInjects:e,launchId:n,at:Date.now(),consumed:!1};for(const s of[...lc])s()}}function wF(){vn=null}function QS(e,n){return e.serverInjects&&!e.consumed?(e.consumed=!0,{owner:"server",launchId:e.launchId,basis:n}):{owner:"browser",launchId:e.launchId,basis:n}}function _F(){const e=vn;return e?(Date.now()-e.at>vF&&(e.consumed=!0),QS(e,"open")):null}function SF(e){return new Promise(n=>{const s=()=>{vn&&(a(),n(QS(vn,"frame")))},r=setTimeout(()=>{a(),n({owner:"server",launchId:null,basis:"no-answer"})},e),a=()=>{clearTimeout(r),lc.delete(s)};lc.add(s)})}const or=15,kF=3,NF=2,CF=5e3;function ZS({provider:e,agentStartMode:n,sessionId:s,onAgentIdle:r,onAgentActive:a,onAgentBlocked:o,onAgentStuckTurn:i,onAgentTurnEndedOffGate:c,onUserInput:d,onStartupFailed:u,onStartupFailedCleared:p,suppressReconnectOnStopBuilding:h=!1,launchIntent:f=!1,reconnectingLabel:m,binding:g}){if(Zt())return t.jsx(Td,{});const x=l.useRef(null),b=l.useRef(null),y=l.useRef(null),v=l.useRef(null),j=l.useRef(null),_=l.useRef(!1),S=l.useRef(n??"fresh"),w=l.useRef(s??null),k=l.useRef(f),N=l.useRef(null),[C,T]=l.useState({kind:"connecting"}),P=l.useRef(null),[R,L]=l.useState(0),[M,O]=Zu(1200);l.useEffect(()=>{S.current=n??"fresh",w.current=s??null,k.current=f},[n,s,f]);const z=l.useRef(r);z.current=r;const I=l.useRef(a);I.current=a;const Y=l.useRef(o);Y.current=o;const W=l.useRef(i);W.current=i;const A=l.useRef(c);A.current=c;const B=l.useRef(d);B.current=d;const D=l.useRef(u);D.current=u;const J=l.useRef(p);J.current=p;const te=TR({wsRef:j,insertInput:E=>{var H,U;((H=j.current)==null?void 0:H.readyState)===WebSocket.OPEN&&j.current.send(JSON.stringify({type:"input",data:E})),_a(),(U=B.current)==null||U.call(B)}}),oe=l.useRef(te);oe.current=te;const se=l.useCallback(E=>{var H;return((H=j.current)==null?void 0:H.readyState)===WebSocket.OPEN?(j.current.send(JSON.stringify({type:"input",data:E})),!0):!1},[]);PR(se,C.kind==="open");const G=l.useRef(g);G.current=g;const le=C.kind==="open";l.useEffect(()=>{var E,H;(H=(E=G.current)==null?void 0:E.onSender)==null||H.call(E,le?se:null)},[se,le]);const ue=OR(j,oe);RR(ue,C.kind==="open");const ne=l.useCallback(()=>{v.current===null&&(v.current=requestAnimationFrame(()=>{var E;v.current=null,(E=b.current)==null||E.scrollToBottom()}))},[]);return rd(x,()=>{var ge;const E=y.current,H=b.current,U=x.current;if(!E||!H)return;if(!Or(H,U)){ar("resize-skipped-degenerate",H,U);return}const pe=Rh(H.buffer.active);ar("resize-before-fit",H,U),E.fit(),((ge=j.current)==null?void 0:ge.readyState)===WebSocket.OPEN&&j.current.send(JSON.stringify({type:"resize",cols:H.cols,rows:H.rows})),ar("resize-after-fit",H,U),pe&&ne()}),l.useEffect(()=>{if(!x.current||_.current)return;_.current=!0;const E=new ad.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",scrollback:CF,rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),H=new od.FitAddon;E.loadAddon(H),E.open(x.current),b.current=E;let U;y.current=H;const pe=id(E,x.current,{onError:ie=>oe.current.showError(ie),onCopy:()=>O()}),ge=E.onScroll(()=>{ar("scroll",E,x.current)}),Me=ld(E,{sendInput:ie=>{var fe,ve;((fe=j.current)==null?void 0:fe.readyState)===WebSocket.OPEN&&j.current.send(JSON.stringify({type:"input",data:ie})),_a(),(ve=B.current)==null||ve.call(B)}});requestAnimationFrame(()=>{H.fit(),E.focus()});let Ce=!1,De=0,Be=!1,X=0,Q=0,re,ce=null;P.current=()=>{ce==null||ce(),ce=null,De=0,T({kind:"reconnecting",attempt:1,maxAttempts:or}),_e()};function _e(){Be=!1,re=void 0,Jf().then(ie=>{re=ie});try{const ie=new WebSocket(ER({provider:e,mode:S.current,sessionId:w.current??void 0,launch:k.current,launchId:k.current?N.current=MR(N.current):void 0,cols:E.cols,rows:E.rows,capture:AR()}));j.current=ie,ie.binaryType="arraybuffer",ie.onmessage=fe=>{var ve,be,We,ze,Re,Ye,rt,je,Ve,Se,Qe,K;if(fe.data instanceof ArrayBuffer){const V=Rh(E.buffer.active);E.write(new Uint8Array(fe.data)),(ve=G.current)!=null&&ve.onScreen&&(U!==void 0&&window.clearTimeout(U),U=window.setTimeout(()=>{var we,Ue;U=void 0,(Ue=(we=G.current)==null?void 0:we.onScreen)==null||Ue.call(we,IR(E))},300)),V&&(ar("replay-write",E,x.current),ne())}else if(typeof fe.data=="string")try{const V=JSON.parse(fe.data);if(V.type==="error"){Ce=!0,T({kind:"server-error",message:DR(V)});return}if(V.type==="session-id")jF(V.serverInjectsLaunch===!0,N.current),(We=(be=G.current)==null?void 0:be.onSessionId)==null||We.call(be,V.sessionId??null),S.current="resume",w.current=V.sessionId??null;else if(V.type==="session-notice")typeof V.text=="string"&&((Re=(ze=G.current)==null?void 0:ze.onNotice)==null||Re.call(ze,V.text));else if(V.type==="agent-idle"||V.type==="claude-idle"){const we=typeof V.source=="string"?V.source:void 0;me("ws-message-received",{type:V.type,source:we}),(Ye=z.current)==null||Ye.call(z,we),window.dispatchEvent(new CustomEvent("build-agent-idle",{detail:{source:we}}))}else if(V.type==="agent-blocked"){const we=typeof V.source=="string"?V.source:void 0;me("ws-message-received-blocked",{type:V.type,source:we}),(rt=Y.current)==null||rt.call(Y,we)}else if(V.type==="agent-active"||V.type==="claude-active")me("ws-message-received-active",{type:V.type}),(je=I.current)==null||je.call(I);else if(V.type==="agent-stuck-turn"){const we=typeof V.silentMs=="number"?V.silentMs:0;if(me("ws-message-received-stuck-turn",{silentMs:we,source:typeof V.source=="string"?V.source:void 0}),LR(E.buffer.active,E.buffer.active.cursorY,E.cols,E.rows)){me("stuck-turn-suppressed-input-box-visible",{silentMs:we});return}(Ve=W.current)==null||Ve.call(W,we)}else if(V.type==="agent-turn-ended-off-gate"){const we=typeof V.step=="number"?V.step:0,Ue=typeof V.label=="string"?V.label:"",Ge=yF(V.reason);me("ws-message-received-turn-ended-off-gate",{step:we,slug:typeof V.slug=="string"?V.slug:void 0,reason:Ge}),(Se=A.current)==null||Se.call(A,{step:we,label:Ue,reason:Ge})}else if(V.type==="idle-diag"){const{site:we,event:Ue,...Ge}=V;me(`rust:${Ue??"unknown"}`,{site:we,...Ge})}else V.type==="drop-complete"?oe.current.resolveDrop(String(V.id??""),String(V.path??"")):V.type==="drop-error"?oe.current.rejectDrop(String(V.id??""),String(V.message??"drop failed")):V.type==="startup-failed"?(Qe=D.current)==null||Qe.call(D,String(V.snippet??"")):V.type==="startup-failed-cleared"?(K=J.current)==null||K.call(J):V.type==="agent-banner-ready"?(me("agent-banner-ready",{}),window.dispatchEvent(new CustomEvent("agent-banner-ready"))):V.type==="agent-auth-required"?(me("agent-auth-required",{}),window.dispatchEvent(new CustomEvent("agent-auth-required"))):V.type==="agent-auth-resolved"&&(me("agent-auth-resolved",{}),window.dispatchEvent(new CustomEvent("agent-auth-resolved")))}catch{}},ie.onopen=()=>{De=0,Be=!0,X=0,Q=0,T({kind:"open"}),me("ws-open"),ie.send(JSON.stringify({type:"resize",cols:E.cols,rows:E.rows}));try{typeof localStorage<"u"&&localStorage.getItem("codeyam.idleDebug")==="1"&&(ie.send(JSON.stringify({type:"enable-idle-diag",sessionId:pd()})),me("idle-diag-enabled"))}catch{}},ie.onerror=()=>{},ie.onclose=async()=>{if(me("ws-close",{reconnectAttempts:De}),wF(),oe.current.cancelAllDrops("Not connected"),Ce){T(We=>We.kind==="server-error"?We:{kind:"ended"}),E.writeln(`\r
|
|
83
|
-
\x1B[90m[Terminal session ended]\x1B[0m`);return}T({kind:"reconnecting",attempt:Math.min(De+1,or),maxAttempts:or});const fe=await $R();if(Ce)return;if(fe){T({kind:"server-stopped"}),ce==null||ce(),ce=FR(2e3,()=>{Ce||window.location.reload()});return}const ve=await Jf();if(Ce)return;const be=bF({baseline:re,current:ve});if(be.kind==="process-death"){T({kind:"session-died",report:be.report});return}if(Be)X=0;else{X++;const We=await bE();if(Ce)return;const ze=gF({session:We,attempts:Q,max:NF});if(ze==="reacquire"){Q++,T({kind:"session-stale"});const Ye=await yE();if(Ce)return;if(Ye){X=0,_e();return}T({kind:"session-stale",canRetry:!0});return}if(ze==="give-up"){T({kind:"session-stale",canRetry:!0});return}const Re=await mF();if(Ce)return;if(!Re||X>=kF){T({kind:"edge-unreachable"});return}}if(De<or){const We=De<4?1e3*Math.pow(2,De):1e4;De++,T({kind:"reconnecting",attempt:De,maxAttempts:or}),setTimeout(()=>{Ce||_e()},We)}else T({kind:"failed"})}}catch{T({kind:"failed"})}}try{H.fit()}catch{}_e();let Te=0;const Oe=1e3;function he(){var fe;const ie=Date.now();ie-Te>=Oe&&((fe=j.current)==null?void 0:fe.readyState)===WebSocket.OPEN&&(j.current.send(JSON.stringify({type:"browser-activity"})),Te=ie)}document.addEventListener("mousemove",he),document.addEventListener("keydown",he),document.addEventListener("mousedown",he),E.onData(ie=>{var fe,ve;((fe=j.current)==null?void 0:fe.readyState)===WebSocket.OPEN?j.current.send(JSON.stringify({type:"input",data:ie})):L(be=>be+1),_a(),(ve=B.current)==null||ve.call(B)});const xe=x.current;function Fe(ie){var Re,Ye,rt;const fe=ie,ve=qR(fe.clipboardData);if(ve.length>0){ie.preventDefault(),ie.stopPropagation(),oe.current.handleImageFiles(ve);return}const be=((Re=fe.clipboardData)==null?void 0:Re.getData("text"))??"";if(!be)return;ie.preventDefault(),ie.stopPropagation();const We=be.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),ze=E.modes.bracketedPasteMode?`\x1B[200~${We}\x1B[201~`:We;((Ye=j.current)==null?void 0:Ye.readyState)===WebSocket.OPEN?j.current.send(JSON.stringify({type:"input",data:ze})):L(je=>je+1),_a(),(rt=B.current)==null||rt.call(B)}xe.addEventListener("paste",Fe,!0);function F(ie){var be,We;const fe=ie.detail;if(!fe)return;((be=j.current)==null?void 0:be.readyState)===WebSocket.OPEN?((We=j.current)==null||We.send(JSON.stringify({type:"input",data:fe})),me("terminal-send-input",{len:fe.length,firstChars:fe.slice(0,16),wsOpen:!0,dropped:!1})):me("terminal-send-input",{len:fe.length,firstChars:fe.slice(0,16),wsOpen:!1,dropped:!0})}window.addEventListener("terminal-send-input",F),zR();function ee(){UR(x.current)||(Pr(),E.focus())}window.addEventListener("terminal-focus",ee);function de(){var ie;Ce=!0,(ie=j.current)==null||ie.close(),T({kind:"ended"}),E.reset()}return h&&window.addEventListener("build-session-stopped",de),()=>{var ie;Ce=!0,ce==null||ce(),ce=null,P.current=null,document.removeEventListener("mousemove",he),document.removeEventListener("keydown",he),document.removeEventListener("mousedown",he),window.removeEventListener("terminal-send-input",F),GR(),window.removeEventListener("terminal-focus",ee),h&&window.removeEventListener("build-session-stopped",de),xe.removeEventListener("paste",Fe,!0),Me(),ge.dispose(),v.current!==null&&(cancelAnimationFrame(v.current),v.current=null),(ie=j.current)==null||ie.close(),pe(),E.dispose(),_.current=!1}},[e,ne]),t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},"data-terminal-emulator":!0,onDragEnter:te.dropHandlers.onDragEnter,onDragOver:te.dropHandlers.onDragOver,onDragLeave:te.dropHandlers.onDragLeave,onDrop:te.dropHandlers.onDrop,onPaste:te.pasteHandler,children:[t.jsx("div",{ref:x,className:"flex-1",tabIndex:-1,style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3,outline:"none"},onPointerDown:()=>{Eh(x.current,()=>{var E;return(E=b.current)==null?void 0:E.focus()})},onClick:()=>{Eh(x.current,()=>{var E;return(E=b.current)==null?void 0:E.focus()})}}),te.dragActive&&t.jsx(BR,{}),te.errorToast&&t.jsx(WR,{message:te.errorToast}),M&&t.jsx(di,{}),t.jsx(HR,{status:C,pulseKey:R,onRefresh:()=>window.location.reload(),reconnectingLabel:m,onDismissServerStopped:()=>{var E;return(E=P.current)==null?void 0:E.call(P)}})]})}const hte=Object.freeze(Object.defineProperty({__proto__:null,TerminalEmulator:ZS},Symbol.toStringTag,{value:"Module"}));function ek({step:e,label:n,onDismiss:s,providerLabel:r,reason:a="not-a-check-in"}){const{sendToAgent:o,agentReady:i}=No(),c=a!=="not-a-check-in";return t.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:t.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FFC53D]/60 bg-[#2a2000]",children:[t.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FFC53D] shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm text-[#FFD778]",children:[r," stopped at"," ",t.jsxs("span",{className:"font-medium",children:["step ",e,", ",n]})," ",c?"— a check-in that isn't pausing this cycle.":"— a step that isn't a decision point."]}),t.jsx(mb,{reason:a,providerLabel:r})]}),t.jsx("button",{type:"button",disabled:!i,onClick:()=>o("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:i?`Tell ${r} to resume the workflow`:"No agent connected",children:"Continue"}),t.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:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const fte=Object.freeze(Object.defineProperty({__proto__:null,TurnEndedOffGateBanner:ek},Symbol.toStringTag,{value:"Module"}));function tk({onAgentActive:e,onAgentIdle:n,onAgentBlocked:s,onUserInput:r,provider:a,sessionId:o,shouldResumeSameProvider:i,currentFeature:c,binding:d}){const[u,p]=l.useState(null),[h,f]=l.useState(0),[m,g]=l.useState(null),[x,b]=l.useState(!1),[y,v]=l.useState(!1),[j,_]=l.useState(null),[S,w]=l.useState(null),[k,N]=l.useState(!1),C=ic(x,wr),T=cF(j!==null,wr),P=ic(T,wr);lF({provider:a,agentStartMode:i?"resume":"fresh",currentFeature:c}),l.useEffect(()=>()=>{aF()},[]);const R=l.useCallback(A=>{p(A)},[]),L=l.useCallback(()=>{p(null)},[]),M=l.useCallback(()=>{p(null),f(A=>A+1)},[]),O=l.useCallback(A=>{g(null),b(!1),n(A)},[n]),z=l.useCallback(()=>{g(null),b(!1),_(null),e()},[e]),I=l.useCallback(A=>{g(null),b(!1),j===null&&N(!1),_(A),w(A)},[j]),Y=l.useCallback(A=>{g(null),_(null),x||v(!1),b(!0),s(A)},[s,x]),W=l.useCallback(()=>{g(null),_(null),N(!0),b(!1),r()},[r]);return t.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[u!==null&&t.jsx(GS,{snippet:u,onRetry:M,onDismiss:L,providerLabel:st(a)}),C===!0&&!y&&t.jsx(US,{onDismiss:()=>v(!0),providerLabel:st(a)}),m!==null&&t.jsx(XS,{silentMs:m,onDismiss:()=>g(null),providerLabel:st(a)}),P===!0&&!k&&S!==null&&t.jsx(ek,{step:S.step,label:S.label,reason:S.reason,onDismiss:()=>{N(!0),_(null)},providerLabel:st(a)}),t.jsxs("div",{className:"relative flex flex-col flex-1 min-h-0",children:[t.jsx(ZS,{provider:a,agentStartMode:i?"resume":"fresh",sessionId:i?o:null,onAgentIdle:O,onAgentActive:z,onAgentBlocked:Y,onAgentStuckTurn:g,onAgentTurnEndedOffGate:I,onUserInput:W,onStartupFailed:R,onStartupFailedCleared:L,suppressReconnectOnStopBuilding:!0,binding:d,launchIntent:!0,reconnectingLabel:"Reconnecting to your running build…"},h),t.jsx(KS,{currentFeature:c}),t.jsx("div",{className:"absolute top-2 left-2 z-20 md:left-auto md:right-2",children:t.jsx(YR,{className:"rounded-full bg-gray-800/90 px-3 py-1.5 shadow-lg ring-1 ring-white/10 backdrop-blur"})})]})]})}const mte=Object.freeze(Object.defineProperty({__proto__:null,BuildTabTerminalSession:tk},Symbol.toStringTag,{value:"Module"}));function Tt(){const e=()=>{typeof window<"u"&&window.dispatchEvent(new Event("terminal-focus"))};e();const n=requestAnimationFrame(e),s=setTimeout(e,50);return()=>{cancelAnimationFrame(n),clearTimeout(s)}}function nk({onClick:e,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 t.jsxs("button",{type:"button",onClick:n?void 0:e,disabled:n,"aria-disabled":n,"data-testid":"start-chat",className:`${s} ${r}`,children:["Start Chat",!n&&t.jsx("span",{"aria-hidden":"true",className:"text-base leading-none",children:"↓"})]})}const gte=Object.freeze(Object.defineProperty({__proto__:null,StartChatButton:nk},Symbol.toStringTag,{value:"Module"}));function sk({draft:e,onDraftChange:n,onStart:s,providerLabel:r}){return t.jsxs(t.Fragment,{children:[t.jsx(qs,{value:e,onChange:n,testId:"chat-describe-input",placeholder:"Ask anything about the project or CodeYam",onSubmit:s}),t.jsx(nk,{onClick:s}),t.jsxs("p",{className:"mt-2 text-xs text-[var(--text-dim)]",children:[r," reads the project's description, deliverables and scenarios before answering."]})]})}const xte=Object.freeze(Object.defineProperty({__proto__:null,BuildChatLaunchPanel:sk},Symbol.toStringTag,{value:"Module"}));function ep(e,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:d=>{const u=d?`${s} ${d}`:s;o(Ls(e,u)),c(Mr(u)||null)},close:()=>{o(null),c(null)},clearDraft:()=>r("")}}function tp(e,n){const s=l.useRef(n);s.current=n;const r=l.useRef(e);l.useEffect(()=>{e!==r.current&&(r.current=e,s.current())},[e])}const fo="chat";function rk({onClose:e,slashCommand:n,seedText:s,footer:r,headerNote:a,handoff:o}){return t.jsx(aa,{label:"Chat agent",sessionName:"chat",onClose:e,footer:r,headerNote:a,handoff:o,onNeedsYouChange:Ju,onWorkingChange:Xu,renderTerminal:i=>t.jsx(Ht,{chatName:fo,slashCommand:n??oo,seedText:s,height:"100%",onClose:e,binding:i})})}const bte=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CHAT_CHAT_NAME:fo,BuildChatAgentChat:rk},Symbol.toStringTag,{value:"Module"}));function ak(e){return Cg("miniagent-output",e)}function np({question:e,children:n}){return t.jsxs("div",{"data-testid":"activity-exit-control",className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"text-[var(--text-dim)]",children:e}),t.jsx("div",{className:"inline-flex items-stretch divide-x divide-[var(--border-default)] rounded-md border border-[var(--border-default)] bg-[rgba(255,255,255,.02)]",children:n})]})}function sp({testId:e,label:n,hint:s,disabled:r,onClick:a}){const o=`${e}-hint`;return t.jsxs("span",{className:"group relative flex",children:[t.jsx("button",{type:"button",onClick:a,disabled:r,"data-testid":e,"aria-describedby":o,className:"px-2.5 py-1 text-xs transition-colors "+(r?"text-[var(--text-dim)] cursor-not-allowed":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[rgba(255,255,255,.05)] cursor-pointer"),children:n}),t.jsx("span",{id:o,role:"tooltip",className:"pointer-events-none absolute right-0 bottom-full z-30 mb-1.5 hidden w-60 rounded-md border border-[var(--border-default)] bg-[var(--bg-deep,#141414)] px-2.5 py-2 text-left text-xs leading-snug text-[var(--text-secondary)] shadow-lg group-hover:block group-focus-within:block",children:s})]})}const yte=Object.freeze(Object.defineProperty({__proto__:null,ActivityExitControl:np,ExitOption:sp},Symbol.toStringTag,{value:"Module"})),ok='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 rp({chatName:e,disabled:n=!1,onDone:s}){const[r,a]=l.useState(!1),o=l.useRef(!1),i=async()=>{if(!(n||o.current)){o.current=!0,a(!0);try{Sn(ok,e),await ak(Rr),Sn("\r",e),s==null||s()}finally{o.current=!1,a(!1)}}},c=n||r;return t.jsx(sp,{testId:"activity-done",label:"I'm done",hint:"Just stops here. Your changes stay in the working tree as they are; no plan is written and nothing is committed.",disabled:c,onClick:i})}const vte=Object.freeze(Object.defineProperty({__proto__:null,ACTIVITY_DONE_INSTRUCTION:ok,ActivityDoneButton:rp},Symbol.toStringTag,{value:"Module"})),ik='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 ap({chatName:e,disabled:n=!1,onClick:s}){const[r,a]=l.useState(!1),o=l.useRef(!1),i=async()=>{if(!(n||o.current)){o.current=!0,a(!0);try{Sn(ik,e),await ak(Rr),Sn("\r",e),s==null||s()}finally{o.current=!1,a(!1)}}},c=n||r;return t.jsx(sp,{testId:"finish-and-formalize",label:"Formalize in Build",hint:"Turns what you prototyped into a plan and opens it in Build, where it gets tests, scenarios and a commit.",disabled:c,onClick:i})}const jte=Object.freeze(Object.defineProperty({__proto__:null,FINISH_AND_FORMALIZE_INSTRUCTION:ik,FinishAndFormalizeButton:ap},Symbol.toStringTag,{value:"Module"}));function lk({escalatedToPrototype:e=!1,onDone:n,initialDraft:s="",initiallyOpen:r=!0,launchSignal:a=0,onLaunched:o}){const[i,c]=l.useState(r),d=ep(oo,s),[u,p]=l.useState(!1),{config:h}=Pt(),f=st(h==null?void 0:h.provider);tp(a,()=>{p(!1),d.close(),c(!1),o==null||o()});const m=()=>{d.open(),Tt(),c(!0)},g=()=>{d.close(),c(!1)};return i?t.jsx("div",{"data-testid":"build-chat-pane",className:"flex min-h-0 flex-1 flex-col",children:t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsx(rk,{headerNote:u?t.jsx($d,{kind:"chat",inline:!0}):void 0,handoff:u?t.jsx(ro,{name:null}):void 0,onClose:g,slashCommand:d.seededCommand??void 0,seedText:d.seedText??void 0,footer:t.jsx("div",{className:"flex justify-end",children:t.jsxs(np,{question:e?"Done prototyping?":"Done chatting?",children:[t.jsx(rp,{chatName:fo,disabled:u,onDone:n}),e&&t.jsx(ap,{chatName:fo,disabled:u,onClick:()=>p(!0)})]})})})})}):t.jsx("div",{"data-testid":"build-chat-pane",className:"px-2 py-4",children:t.jsx(sk,{draft:d.draft,onDraftChange:d.setDraft,onStart:m,providerLabel:f})})}const wte=Object.freeze(Object.defineProperty({__proto__:null,BuildChatPane:lk},Symbol.toStringTag,{value:"Module"})),mo="prototype";function ck({onClose:e,slashCommand:n,seedText:s,footer:r,headerNote:a,handoff:o}){return t.jsx(aa,{label:"Prototype agent",sessionName:"prototype session",onClose:e,footer:r,headerNote:a,handoff:o,onNeedsYouChange:Ju,onWorkingChange:Xu,renderTerminal:i=>t.jsx(Ht,{chatName:mo,slashCommand:n??Rb,seedText:s,height:"100%",onClose:e,binding:i})})}const _te=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_CHAT_NAME:mo,PrototypeAgentChat:ck},Symbol.toStringTag,{value:"Module"})),dk="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 uk(){return t.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:[t.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Build in progress."})," ",dk]})}const Ste=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_BUILDING_IN_PROGRESS_MESSAGE:dk,PrototypeBuildingInProgressBanner:uk},Symbol.toStringTag,{value:"Module"}));function cc({disabled:e=!1,onStart:n}){const s="mt-3 inline-flex items-center gap-3 rounded-lg px-4 py-2.5 text-sm font-medium transition-opacity",r=e?"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 t.jsxs("button",{type:"button",onClick:e?void 0:n,disabled:e,"aria-disabled":e,title:e?"Building is in progress.":void 0,"data-testid":"start-prototyping",className:`${s} ${r}`,children:["Start Prototyping",!e&&t.jsx("span",{"aria-hidden":"true",className:"text-base leading-none",children:"↓"})]})}const kte=Object.freeze(Object.defineProperty({__proto__:null,StartPrototypingButton:cc},Symbol.toStringTag,{value:"Module"}));function pk(e,n){return`Launches a chat window with ${e} to ${n==="describe"?"describe your plan":"start prototyping"}.`}function hk({providerLabel:e,kind:n}){return t.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":`plan-chat-launch-caption-${n}`,children:pk(e,n)})}const Nte=Object.freeze(Object.defineProperty({__proto__:null,PlanChatLaunchCaption:hk,planChatLaunchCaptionText:pk},Symbol.toStringTag,{value:"Module"}));function fk({isAgentBuilding:e,featureName:n=null,onLaunched:s,onDone:r,initiallyOpen:a=!1,launchSignal:o=0,initialDraft:i=""}){const[c,d]=l.useState(a),u=ep(Rb,i),[p,h]=l.useState(!1),f=Bo(),{config:m}=Pt(),g=st(m==null?void 0:m.provider);tp(o,()=>{h(!1),d(!1),u.clearDraft(),f.clear(),s==null||s()});const x=v=>{u.open(v||void 0),Tt(),d(!0)},b=()=>{if(!e){if(f.files.length===0){x("");return}f.save().then(v=>{v!==null&&x(v)})}},y=()=>{u.close(),d(!1)};return e&&p?t.jsx("div",{"data-testid":"prototype-pane",className:"flex min-h-0 flex-1 flex-col",children:t.jsx(ro,{name:n})}):e?t.jsxs("div",{"data-testid":"prototype-pane",className:"px-2 py-4",children:[t.jsx(uk,{}),t.jsx(cc,{disabled:!0,onStart:()=>{}})]}):c?t.jsx("div",{"data-testid":"prototype-pane",className:"flex min-h-0 flex-1 flex-col",children:t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsx(ck,{headerNote:p?t.jsx($d,{kind:"prototype",inline:!0}):void 0,handoff:p?t.jsx(ro,{name:null}):void 0,onClose:y,slashCommand:u.seededCommand??void 0,seedText:u.seedText??void 0,footer:t.jsx("div",{className:"flex justify-end",children:t.jsxs(np,{question:"Done prototyping?",children:[t.jsx(rp,{chatName:mo,disabled:p,onDone:r}),t.jsx(ap,{chatName:mo,disabled:p,onClick:()=>h(!0)})]})})})})}):t.jsxs("div",{"data-testid":"prototype-pane",className:"px-2 py-4",children:[t.jsx(qs,{value:u.draft,onChange:u.setDraft,testId:"prototype-describe-input",placeholder:"Describe what you want to prototype",onSubmit:b,files:f.files,onAddFiles:f.addFiles,onRemoveFile:f.removeFile,busy:f.saving,error:f.error}),t.jsx(cc,{onStart:b}),t.jsx(hk,{providerLabel:g,kind:"prototype"})]})}const Cte=Object.freeze(Object.defineProperty({__proto__:null,PrototypePane:fk},Symbol.toStringTag,{value:"Module"}));function mk(){return t.jsxs("div",{"data-testid":"formalize-intro",style:{border:"1px solid rgba(255,255,255,.1)",background:"rgba(255,255,255,.03)",borderRadius:10,padding:"10px 12px",display:"flex",gap:10,alignItems:"flex-start"},children:[t.jsx("span",{style:{color:"var(--accent-active, #D7FF63)",display:"flex",marginTop:3,flex:"none"},children:t.jsx(ms,{markOnly:!0,className:"h-3.5"})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("span",{style:{color:"var(--text-primary)",fontWeight:500},children:"Formalizing your prototype"}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:"The plan is written. Now the agent turns what you prototyped into finished work: it reads the code carefully, adds tests and scenarios for it, checks that everything passes, and commits it. Each step shows below, and it will ask you whenever it needs a decision."})]})]})}const Tte=Object.freeze(Object.defineProperty({__proto__:null,FormalizeIntro:mk},Symbol.toStringTag,{value:"Module"})),op=js(),TF=op.get,Xf=op.set,PF=op.subscribe;function OF(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return l.useMemo(()=>r=>{n.forEach(a=>a(r))},n)}const ui=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Js(e){const n=Object.prototype.toString.call(e);return n==="[object Window]"||n==="[object global]"}function ip(e){return"nodeType"in e}function Dt(e){var n,s;return e?Js(e)?e:ip(e)&&(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window:window}function lp(e){const{Document:n}=Dt(e);return e instanceof n}function oa(e){return Js(e)?!1:e instanceof Dt(e).HTMLElement}function gk(e){return e instanceof Dt(e).SVGElement}function Xs(e){return e?Js(e)?e.document:ip(e)?lp(e)?e:oa(e)||gk(e)?e.ownerDocument:document:document:document}const dn=ui?l.useLayoutEffect:l.useEffect;function cp(e){const n=l.useRef(e);return dn(()=>{n.current=e}),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 RF(){const e=l.useRef(null),n=l.useCallback((r,a)=>{e.current=setInterval(r,a)},[]),s=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[n,s]}function $r(e,n){n===void 0&&(n=[e]);const s=l.useRef(e);return dn(()=>{s.current!==e&&(s.current=e)},n),s}function ia(e,n){const s=l.useRef();return l.useMemo(()=>{const r=e(s.current);return s.current=r,r},[...n])}function go(e){const n=cp(e),s=l.useRef(null),r=l.useCallback(a=>{a!==s.current&&(n==null||n(a,s.current)),s.current=a},[]);return[s,r]}function dc(e){const n=l.useRef();return l.useEffect(()=>{n.current=e},[e]),n.current}let el={};function la(e,n){return l.useMemo(()=>{if(n)return n;const s=el[e]==null?0:el[e]+1;return el[e]=s,e+"-"+s},[e,n])}function xk(e){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 p=o[d];p!=null&&(o[d]=p+e*u)}return o},{...n})}}const Ms=xk(1),Fr=xk(-1);function EF(e){return"clientX"in e&&"clientY"in e}function dp(e){if(!e)return!1;const{KeyboardEvent:n}=Dt(e.target);return n&&e instanceof n}function AF(e){if(!e)return!1;const{TouchEvent:n}=Dt(e.target);return n&&e instanceof n}function uc(e){if(AF(e)){if(e.touches&&e.touches.length){const{clientX:n,clientY:s}=e.touches[0];return{x:n,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:n,clientY:s}=e.changedTouches[0];return{x:n,y:s}}}return EF(e)?{x:e.clientX,y:e.clientY}:null}const zr=Object.freeze({Translate:{toString(e){if(!e)return;const{x:n,y:s}=e;return"translate3d("+(n?Math.round(n):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:n,scaleY:s}=e;return"scaleX("+n+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[zr.Translate.toString(e),zr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:n,duration:s,easing:r}=e;return n+" "+s+"ms "+r}}}),Qf="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function MF(e){return e.matches(Qf)?e:e.querySelector(Qf)}const IF={display:"none"};function DF(e){let{id:n,value:s}=e;return Mt.createElement("div",{id:n,style:IF},s)}function LF(e){let{id:n,announcement:s,ariaLiveType:r="assertive"}=e;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 Mt.createElement("div",{id:n,style:a,role:"status","aria-live":r,"aria-atomic":!0},s)}function $F(){const[e,n]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&n(r)},[]),announcement:e}}const bk=l.createContext(null);function FF(e){const n=l.useContext(bk);l.useEffect(()=>{if(!n)throw new Error("useDndMonitor must be used within a children of <DndContext>");return n(e)},[e,n])}function zF(){const[e]=l.useState(()=>new Set),n=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:a,event:o}=r;e.forEach(i=>{var c;return(c=i[a])==null?void 0:c.call(i,o)})},[e]),n]}const BF={draggable:`
|
|
84
|
-
To pick up a draggable item, press the space bar.
|
|
85
|
-
While dragging, use the arrow keys to move the item.
|
|
86
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
87
|
-
`},WF={onDragStart(e){let{active:n}=e;return"Picked up draggable item "+n.id+"."},onDragOver(e){let{active:n,over:s}=e;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(e){let{active:n,over:s}=e;return s?"Draggable item "+n.id+" was dropped over droppable area "+s.id:"Draggable item "+n.id+" was dropped."},onDragCancel(e){let{active:n}=e;return"Dragging was cancelled. Draggable item "+n.id+" was dropped."}};function HF(e){let{announcements:n=WF,container:s,hiddenTextDescribedById:r,screenReaderInstructions:a=BF}=e;const{announce:o,announcement:i}=$F(),c=la("DndLiveRegion"),[d,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),FF(l.useMemo(()=>({onDragStart(h){let{active:f}=h;o(n.onDragStart({active:f}))},onDragMove(h){let{active:f,over:m}=h;n.onDragMove&&o(n.onDragMove({active:f,over:m}))},onDragOver(h){let{active:f,over:m}=h;o(n.onDragOver({active:f,over:m}))},onDragEnd(h){let{active:f,over:m}=h;o(n.onDragEnd({active:f,over:m}))},onDragCancel(h){let{active:f,over:m}=h;o(n.onDragCancel({active:f,over:m}))}}),[o,n])),!d)return null;const p=Mt.createElement(Mt.Fragment,null,Mt.createElement(DF,{id:r,value:a.draggable}),Mt.createElement(LF,{id:c,announcement:i}));return s?us.createPortal(p,s):p}var ct;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ct||(ct={}));function xo(){}function Zf(e,n){return l.useMemo(()=>({sensor:e,options:n??{}}),[e,n])}function qF(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return l.useMemo(()=>[...n].filter(r=>r!=null),[...n])}const Qt=Object.freeze({x:0,y:0});function yk(e,n){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function vk(e,n){let{data:{value:s}}=e,{data:{value:r}}=n;return s-r}function UF(e,n){let{data:{value:s}}=e,{data:{value:r}}=n;return r-s}function em(e){let{left:n,top:s,height:r,width:a}=e;return[{x:n,y:s},{x:n+a,y:s},{x:n,y:s+r},{x:n+a,y:s+r}]}function jk(e,n){if(!e||e.length===0)return null;const[s]=e;return s[n]}function tm(e,n,s){return n===void 0&&(n=e.left),s===void 0&&(s=e.top),{x:n+e.width*.5,y:s+e.height*.5}}const GF=e=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=e;const a=tm(n,n.left,n.top),o=[];for(const i of r){const{id:c}=i,d=s.get(c);if(d){const u=yk(tm(d),a);o.push({id:c,data:{droppableContainer:i,value:u}})}}return o.sort(vk)},YF=e=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=e;const a=em(n),o=[];for(const i of r){const{id:c}=i,d=s.get(c);if(d){const u=em(d),p=a.reduce((f,m,g)=>f+yk(u[g],m),0),h=Number((p/4).toFixed(4));o.push({id:c,data:{droppableContainer:i,value:h}})}}return o.sort(vk)};function VF(e,n){const s=Math.max(n.top,e.top),r=Math.max(n.left,e.left),a=Math.min(n.left+n.width,e.left+e.width),o=Math.min(n.top+n.height,e.top+e.height),i=a-r,c=o-s;if(r<a&&s<o){const d=n.width*n.height,u=e.width*e.height,p=i*c,h=p/(d+u-p);return Number(h.toFixed(4))}return 0}const KF=e=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=e;const a=[];for(const o of r){const{id:i}=o,c=s.get(i);if(c){const d=VF(c,n);d>0&&a.push({id:i,data:{droppableContainer:o,value:d}})}}return a.sort(UF)};function JF(e,n,s){return{...e,scaleX:n&&s?n.width/s.width:1,scaleY:n&&s?n.height/s.height:1}}function wk(e,n){return e&&n?{x:e.left-n.left,y:e.top-n.top}:Qt}function XF(e){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+e*c.y,bottom:i.bottom+e*c.y,left:i.left+e*c.x,right:i.right+e*c.x}),{...s})}}const QF=XF(1);function ZF(e){if(e.startsWith("matrix3d(")){const n=e.slice(9,-1).split(/, /);return{x:+n[12],y:+n[13],scaleX:+n[0],scaleY:+n[5]}}else if(e.startsWith("matrix(")){const n=e.slice(7,-1).split(/, /);return{x:+n[4],y:+n[5],scaleX:+n[0],scaleY:+n[3]}}return null}function ez(e,n,s){const r=ZF(n);if(!r)return e;const{scaleX:a,scaleY:o,x:i,y:c}=r,d=e.left-i-(1-a)*parseFloat(s),u=e.top-c-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),p=a?e.width/a:e.width,h=o?e.height/o:e.height;return{width:p,height:h,top:u,right:d+p,bottom:u+h,left:d}}const tz={ignoreTransform:!1};function Qs(e,n){n===void 0&&(n=tz);let s=e.getBoundingClientRect();if(n.ignoreTransform){const{transform:u,transformOrigin:p}=Dt(e).getComputedStyle(e);u&&(s=ez(s,u,p))}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 nm(e){return Qs(e,{ignoreTransform:!0})}function nz(e){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}function sz(e,n){return n===void 0&&(n=Dt(e).getComputedStyle(e)),n.position==="fixed"}function rz(e,n){n===void 0&&(n=Dt(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=n[a];return typeof o=="string"?s.test(o):!1})}function pi(e,n){const s=[];function r(a){if(n!=null&&s.length>=n||!a)return s;if(lp(a)&&a.scrollingElement!=null&&!s.includes(a.scrollingElement))return s.push(a.scrollingElement),s;if(!oa(a)||gk(a)||s.includes(a))return s;const o=Dt(e).getComputedStyle(a);return a!==e&&rz(a,o)&&s.push(a),sz(a,o)?s:r(a.parentNode)}return e?r(e):s}function _k(e){const[n]=pi(e,1);return n??null}function tl(e){return!ui||!e?null:Js(e)?e:ip(e)?lp(e)||e===Xs(e).scrollingElement?window:oa(e)?e:null:null}function Sk(e){return Js(e)?e.scrollX:e.scrollLeft}function kk(e){return Js(e)?e.scrollY:e.scrollTop}function pc(e){return{x:Sk(e),y:kk(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function Nk(e){return!ui||!e?!1:e===document.scrollingElement}function Ck(e){const n={x:0,y:0},s=Nk(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},a=e.scrollTop<=n.y,o=e.scrollLeft<=n.x,i=e.scrollTop>=r.y,c=e.scrollLeft>=r.x;return{isTop:a,isLeft:o,isBottom:i,isRight:c,maxScroll:r,minScroll:n}}const az={x:.2,y:.2};function oz(e,n,s,r,a){let{top:o,left:i,right:c,bottom:d}=s;r===void 0&&(r=10),a===void 0&&(a=az);const{isTop:u,isBottom:p,isLeft:h,isRight:f}=Ck(e),m={x:0,y:0},g={x:0,y:0},x={height:n.height*a.y,width:n.width*a.x};return!u&&o<=n.top+x.height?(m.y=ut.Backward,g.y=r*Math.abs((n.top+x.height-o)/x.height)):!p&&d>=n.bottom-x.height&&(m.y=ut.Forward,g.y=r*Math.abs((n.bottom-x.height-d)/x.height)),!f&&c>=n.right-x.width?(m.x=ut.Forward,g.x=r*Math.abs((n.right-x.width-c)/x.width)):!h&&i<=n.left+x.width&&(m.x=ut.Backward,g.x=r*Math.abs((n.left+x.width-i)/x.width)),{direction:m,speed:g}}function iz(e){if(e===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}=e.getBoundingClientRect();return{top:n,left:s,right:r,bottom:a,width:e.clientWidth,height:e.clientHeight}}function Tk(e){return e.reduce((n,s)=>Ms(n,pc(s)),Qt)}function lz(e){return e.reduce((n,s)=>n+Sk(s),0)}function cz(e){return e.reduce((n,s)=>n+kk(s),0)}function dz(e,n){if(n===void 0&&(n=Qs),!e)return;const{top:s,left:r,bottom:a,right:o}=n(e);_k(e)&&(a<=0||o<=0||s>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const uz=[["x",["left","right"],lz],["y",["top","bottom"],cz]];class up{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=pi(s),a=Tk(r);this.rect={...n},this.width=n.width,this.height=n.height;for(const[o,i,c]of uz)for(const d of i)Object.defineProperty(this,d,{get:()=>{const u=c(r),p=a[o]-u;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class _r{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 pz(e){const{EventTarget:n}=Dt(e);return e instanceof n?e:Xs(e)}function nl(e,n){const s=Math.abs(e.x),r=Math.abs(e.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 zt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(zt||(zt={}));function sm(e){e.preventDefault()}function hz(e){e.stopPropagation()}var $e;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})($e||($e={}));const Pk={start:[$e.Space,$e.Enter],cancel:[$e.Esc],end:[$e.Space,$e.Enter,$e.Tab]},fz=(e,n)=>{let{currentCoordinates:s}=n;switch(e.code){case $e.Right:return{...s,x:s.x+25};case $e.Left:return{...s,x:s.x-25};case $e.Down:return{...s,y:s.y+25};case $e.Up:return{...s,y:s.y-25}}};class pp{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 _r(Xs(s)),this.windowListeners=new _r(Dt(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(zt.Resize,this.handleCancel),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(zt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:n,onStart:s}=this.props,r=n.node.current;r&&dz(r),s(Qt)}handleKeyDown(n){if(dp(n)){const{active:s,context:r,options:a}=this.props,{keyboardCodes:o=Pk,coordinateGetter:i=fz,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,p=u?{x:u.left,y:u.top}:Qt;this.referenceCoordinates||(this.referenceCoordinates=p);const h=i(n,{active:s,context:r.current,currentCoordinates:p});if(h){const f=Fr(h,p),m={x:0,y:0},{scrollableAncestors:g}=r.current;for(const x of g){const b=n.code,{isTop:y,isRight:v,isLeft:j,isBottom:_,maxScroll:S,minScroll:w}=Ck(x),k=iz(x),N={x:Math.min(b===$e.Right?k.right-k.width/2:k.right,Math.max(b===$e.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(b===$e.Down?k.bottom-k.height/2:k.bottom,Math.max(b===$e.Down?k.top:k.top+k.height/2,h.y))},C=b===$e.Right&&!v||b===$e.Left&&!j,T=b===$e.Down&&!_||b===$e.Up&&!y;if(C&&N.x!==h.x){const P=x.scrollLeft+f.x,R=b===$e.Right&&P<=S.x||b===$e.Left&&P>=w.x;if(R&&!f.y){x.scrollTo({left:P,behavior:c});return}R?m.x=x.scrollLeft-P:m.x=b===$e.Right?x.scrollLeft-S.x:x.scrollLeft-w.x,m.x&&x.scrollBy({left:-m.x,behavior:c});break}else if(T&&N.y!==h.y){const P=x.scrollTop+f.y,R=b===$e.Down&&P<=S.y||b===$e.Up&&P>=w.y;if(R&&!f.x){x.scrollTo({top:P,behavior:c});return}R?m.y=x.scrollTop-P:m.y=b===$e.Down?x.scrollTop-S.y:x.scrollTop-w.y,m.y&&x.scrollBy({top:-m.y,behavior:c});break}}this.handleMove(n,Ms(Fr(h,this.referenceCoordinates),m))}}}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()}}pp.activators=[{eventName:"onKeyDown",handler:(e,n,s)=>{let{keyboardCodes:r=Pk,onActivation:a}=n,{active:o}=s;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const c=o.activatorNode.current;return c&&e.target!==c?!1:(e.preventDefault(),a==null||a({event:e.nativeEvent}),!0)}return!1}}];function rm(e){return!!(e&&"distance"in e)}function am(e){return!!(e&&"delay"in e)}class hp{constructor(n,s,r){var a;r===void 0&&(r=pz(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=Xs(i),this.documentListeners=new _r(this.document),this.listeners=new _r(r),this.windowListeners=new _r(Dt(i)),this.initialCoordinates=(a=uc(o))!=null?a:Qt,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(zt.Resize,this.handleCancel),this.windowListeners.add(zt.DragStart,sm),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),this.windowListeners.add(zt.ContextMenu,sm),this.documentListeners.add(zt.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(am(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(rm(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(zt.Click,hz,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(zt.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=uc(n))!=null?s:Qt,u=Fr(a,d);if(!r&&c){if(rm(c)){if(c.tolerance!=null&&nl(u,c.tolerance))return this.handleCancel();if(nl(u,c.distance))return this.handleStart()}if(am(c)&&nl(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===$e.Esc&&this.handleCancel()}removeTextSelection(){var n;(n=this.document.getSelection())==null||n.removeAllRanges()}}const mz={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class fp extends hp{constructor(n){const{event:s}=n,r=Xs(s.target);super(n,mz,r)}}fp.activators=[{eventName:"onPointerDown",handler:(e,n)=>{let{nativeEvent:s}=e,{onActivation:r}=n;return!s.isPrimary||s.button!==0?!1:(r==null||r({event:s}),!0)}}];const gz={move:{name:"mousemove"},end:{name:"mouseup"}};var hc;(function(e){e[e.RightClick=2]="RightClick"})(hc||(hc={}));class xz extends hp{constructor(n){super(n,gz,Xs(n.event.target))}}xz.activators=[{eventName:"onMouseDown",handler:(e,n)=>{let{nativeEvent:s}=e,{onActivation:r}=n;return s.button===hc.RightClick?!1:(r==null||r({event:s}),!0)}}];const sl={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class bz extends hp{constructor(n){super(n,sl)}static setup(){return window.addEventListener(sl.move.name,n,{capture:!1,passive:!1}),function(){window.removeEventListener(sl.move.name,n)};function n(){}}}bz.activators=[{eventName:"onTouchStart",handler:(e,n)=>{let{nativeEvent:s}=e,{onActivation:r}=n;const{touches:a}=s;return a.length>1?!1:(r==null||r({event:s}),!0)}}];var Sr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Sr||(Sr={}));var bo;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bo||(bo={}));function yz(e){let{acceleration:n,activator:s=Sr.Pointer,canScroll:r,draggingRect:a,enabled:o,interval:i=5,order:c=bo.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:h,threshold:f}=e;const m=jz({delta:h,disabled:!o}),[g,x]=RF(),b=l.useRef({x:0,y:0}),y=l.useRef({x:0,y:0}),v=l.useMemo(()=>{switch(s){case Sr.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Sr.DraggableRect:return a}},[s,a,d]),j=l.useRef(null),_=l.useCallback(()=>{const w=j.current;if(!w)return;const k=b.current.x*y.current.x,N=b.current.y*y.current.y;w.scrollBy(k,N)},[]),S=l.useMemo(()=>c===bo.TreeOrder?[...u].reverse():u,[c,u]);l.useEffect(()=>{if(!o||!u.length||!v){x();return}for(const w of S){if((r==null?void 0:r(w))===!1)continue;const k=u.indexOf(w),N=p[k];if(!N)continue;const{direction:C,speed:T}=oz(w,N,v,n,f);for(const P of["x","y"])m[P][C[P]]||(T[P]=0,C[P]=0);if(T.x>0||T.y>0){x(),j.current=w,g(_,i),b.current=T,y.current=C;return}}b.current={x:0,y:0},y.current={x:0,y:0},x()},[n,_,r,x,o,i,JSON.stringify(v),JSON.stringify(m),g,u,S,p,JSON.stringify(f)])}const vz={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function jz(e){let{delta:n,disabled:s}=e;const r=dc(n);return ia(a=>{if(s||!r||!a)return vz;const o={x:Math.sign(n.x-r.x),y:Math.sign(n.y-r.y)};return{x:{[ut.Backward]:a.x[ut.Backward]||o.x===-1,[ut.Forward]:a.x[ut.Forward]||o.x===1},y:{[ut.Backward]:a.y[ut.Backward]||o.y===-1,[ut.Forward]:a.y[ut.Forward]||o.y===1}}},[s,n,r])}function wz(e,n){const s=n!=null?e.get(n):void 0,r=s?s.node.current:null;return ia(a=>{var o;return n==null?null:(o=r??a)!=null?o:null},[r,n])}function _z(e,n){return l.useMemo(()=>e.reduce((s,r)=>{const{sensor:a}=r,o=a.activators.map(i=>({eventName:i.eventName,handler:n(i.handler,r)}));return[...s,...o]},[]),[e,n])}var Br;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Br||(Br={}));var fc;(function(e){e.Optimized="optimized"})(fc||(fc={}));const om=new Map;function Sz(e,n){let{dragging:s,dependencies:r,config:a}=n;const[o,i]=l.useState(null),{frequency:c,measure:d,strategy:u}=a,p=l.useRef(e),h=b(),f=$r(h),m=l.useCallback(function(y){y===void 0&&(y=[]),!f.current&&i(v=>v===null?y:v.concat(y.filter(j=>!v.includes(j))))},[f]),g=l.useRef(null),x=ia(y=>{if(h&&!s)return om;if(!y||y===om||p.current!==e||o!=null){const v=new Map;for(let j of e){if(!j)continue;if(o&&o.length>0&&!o.includes(j.id)&&j.rect.current){v.set(j.id,j.rect.current);continue}const _=j.node.current,S=_?new up(d(_),_):null;j.rect.current=S,S&&v.set(j.id,S)}return v}return y},[e,o,s,h,d]);return l.useEffect(()=>{p.current=e},[e]),l.useEffect(()=>{h||m()},[s,h]),l.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),l.useEffect(()=>{h||typeof c!="number"||g.current!==null||(g.current=setTimeout(()=>{m(),g.current=null},c))},[c,h,m,...r]),{droppableRects:x,measureDroppableContainers:m,measuringScheduled:o!=null};function b(){switch(u){case Br.Always:return!1;case Br.BeforeDragging:return s;default:return!s}}}function Ok(e,n){return ia(s=>e?s||(typeof n=="function"?n(e):e):null,[n,e])}function kz(e,n){return Ok(e,n)}function Nz(e){let{callback:n,disabled:s}=e;const r=cp(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 hi(e){let{callback:n,disabled:s}=e;const r=cp(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 Cz(e){return new up(Qs(e),e)}function im(e,n,s){n===void 0&&(n=Cz);const[r,a]=l.useState(null);function o(){a(d=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=d??s)!=null?u:null}const p=n(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const i=Nz({callback(d){if(e)for(const u of d){const{type:p,target:h}=u;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){o();break}}}}),c=hi({callback:o});return dn(()=>{o(),e?(c==null||c.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(c==null||c.disconnect(),i==null||i.disconnect())},[e]),r}function Tz(e){const n=Ok(e);return wk(e,n)}const lm=[];function Pz(e){const n=l.useRef(e),s=ia(r=>e?r&&r!==lm&&e&&n.current&&e.parentNode===n.current.parentNode?r:pi(e):lm,[e]);return l.useEffect(()=>{n.current=e},[e]),s}function Oz(e){const[n,s]=l.useState(null),r=l.useRef(e),a=l.useCallback(o=>{const i=tl(o.target);i&&s(c=>c?(c.set(i,pc(i)),new Map(c)):null)},[]);return l.useEffect(()=>{const o=r.current;if(e!==o){i(o);const c=e.map(d=>{const u=tl(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,pc(u)]):null}).filter(d=>d!=null);s(c.length?new Map(c):null),r.current=e}return()=>{i(e),i(o)};function i(c){c.forEach(d=>{const u=tl(d);u==null||u.removeEventListener("scroll",a)})}},[a,e]),l.useMemo(()=>e.length?n?Array.from(n.values()).reduce((o,i)=>Ms(o,i),Qt):Tk(e):Qt,[e,n])}function cm(e,n){n===void 0&&(n=[]);const s=l.useRef(null);return l.useEffect(()=>{s.current=null},n),l.useEffect(()=>{const r=e!==Qt;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?Fr(e,s.current):Qt}function Rz(e){l.useEffect(()=>{if(!ui)return;const n=e.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of n)s==null||s()}},e.map(n=>{let{sensor:s}=n;return s}))}function Ez(e,n){return l.useMemo(()=>e.reduce((s,r)=>{let{eventName:a,handler:o}=r;return s[a]=i=>{o(i,n)},s},{}),[e,n])}function Rk(e){return l.useMemo(()=>e?nz(e):null,[e])}const dm=[];function Az(e,n){n===void 0&&(n=Qs);const[s]=e,r=Rk(s?Dt(s):null),[a,o]=l.useState(dm);function i(){o(()=>e.length?e.map(d=>Nk(d)?r:new up(n(d),d)):dm)}const c=hi({callback:i});return dn(()=>{c==null||c.disconnect(),i(),e.forEach(d=>c==null?void 0:c.observe(d))},[e]),a}function Mz(e){if(!e)return null;if(e.children.length>1)return e;const n=e.children[0];return oa(n)?n:e}function Iz(e){let{measure:n}=e;const[s,r]=l.useState(null),a=l.useCallback(u=>{for(const{target:p}of u)if(oa(p)){r(h=>{const f=n(p);return h?{...h,width:f.width,height:f.height}:f});break}},[n]),o=hi({callback:a}),i=l.useCallback(u=>{const p=Mz(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),r(p?n(p):null)},[n,o]),[c,d]=go(i);return l.useMemo(()=>({nodeRef:c,rect:s,setRef:d}),[s,c,d])}const Dz=[{sensor:fp,options:{}},{sensor:pp,options:{}}],Lz={current:{}},Ga={draggable:{measure:nm},droppable:{measure:nm,strategy:Br.WhileDragging,frequency:fc.Optimized},dragOverlay:{measure:Qs}};class kr 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 $z={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new kr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:xo},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ga,measureDroppableContainers:xo,windowRect:null,measuringScheduled:!1},Fz={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:xo,draggableNodes:new Map,over:null,measureDroppableContainers:xo},fi=l.createContext(Fz),Ek=l.createContext($z);function zz(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new kr}}}function Bz(e,n){switch(n.type){case ct.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:n.initialCoordinates,active:n.active}};case ct.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:n.coordinates.x-e.draggable.initialCoordinates.x,y:n.coordinates.y-e.draggable.initialCoordinates.y}}};case ct.DragEnd:case ct.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ct.RegisterDroppable:{const{element:s}=n,{id:r}=s,a=new kr(e.droppable.containers);return a.set(r,s),{...e,droppable:{...e.droppable,containers:a}}}case ct.SetDroppableDisabled:{const{id:s,key:r,disabled:a}=n,o=e.droppable.containers.get(s);if(!o||r!==o.key)return e;const i=new kr(e.droppable.containers);return i.set(s,{...o,disabled:a}),{...e,droppable:{...e.droppable,containers:i}}}case ct.UnregisterDroppable:{const{id:s,key:r}=n,a=e.droppable.containers.get(s);if(!a||r!==a.key)return e;const o=new kr(e.droppable.containers);return o.delete(s),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function Wz(e){let{disabled:n}=e;const{active:s,activatorEvent:r,draggableNodes:a}=l.useContext(fi),o=dc(r),i=dc(s==null?void 0:s.id);return l.useEffect(()=>{if(!n&&!r&&o&&i!=null){if(!dp(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 p of[d.current,u.current]){if(!p)continue;const h=MF(p);if(h){h.focus();break}}})}},[r,n,a,i,o]),null}function Hz(e,n){let{transform:s,...r}=n;return e!=null&&e.length?e.reduce((a,o)=>o({transform:a,...r}),s):s}function qz(e){return l.useMemo(()=>({draggable:{...Ga.draggable,...e==null?void 0:e.draggable},droppable:{...Ga.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Ga.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Uz(e){let{activeNode:n,measure:s,initialRect:r,config:a=!0}=e;const o=l.useRef(!1),{x:i,y:c}=typeof a=="boolean"?{x:a,y:a}:a;dn(()=>{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 p=s(u),h=wk(p,r);if(i||(h.x=0),c||(h.y=0),o.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const f=_k(u);f&&f.scrollBy({top:h.y,left:h.x})}},[n,i,c,r,s])}const Ak=l.createContext({...Qt,scaleX:1,scaleY:1});var Fn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Fn||(Fn={}));const Gz=l.memo(function(n){var s,r,a,o;let{id:i,accessibility:c,autoScroll:d=!0,children:u,sensors:p=Dz,collisionDetection:h=KF,measuring:f,modifiers:m,...g}=n;const x=l.useReducer(Bz,void 0,zz),[b,y]=x,[v,j]=zF(),[_,S]=l.useState(Fn.Uninitialized),w=_===Fn.Initialized,{draggable:{active:k,nodes:N,translate:C},droppable:{containers:T}}=b,P=k!=null?N.get(k):null,R=l.useRef({initial:null,translated:null}),L=l.useMemo(()=>{var je;return k!=null?{id:k,data:(je=P==null?void 0:P.data)!=null?je:Lz,rect:R}:null},[k,P]),M=l.useRef(null),[O,z]=l.useState(null),[I,Y]=l.useState(null),W=$r(g,Object.values(g)),A=la("DndDescribedBy",i),B=l.useMemo(()=>T.getEnabled(),[T]),D=qz(f),{droppableRects:J,measureDroppableContainers:te,measuringScheduled:oe}=Sz(B,{dragging:w,dependencies:[C.x,C.y],config:D.droppable}),se=wz(N,k),G=l.useMemo(()=>I?uc(I):null,[I]),le=rt(),ue=kz(se,D.draggable.measure);Uz({activeNode:k!=null?N.get(k):null,config:le.layoutShiftCompensation,initialRect:ue,measure:D.draggable.measure});const ne=im(se,D.draggable.measure,ue),E=im(se?se.parentElement:null),H=l.useRef({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:J,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),U=T.getNodeFor((s=H.current.over)==null?void 0:s.id),pe=Iz({measure:D.dragOverlay.measure}),ge=(r=pe.nodeRef.current)!=null?r:se,Me=w?(a=pe.rect)!=null?a:ne:null,Ce=!!(pe.nodeRef.current&&pe.rect),De=Tz(Ce?null:ne),Be=Rk(ge?Dt(ge):null),X=Pz(w?U??se:null),Q=Az(X),re=Hz(m,{transform:{x:C.x-De.x,y:C.y-De.y,scaleX:1,scaleY:1},activatorEvent:I,active:L,activeNodeRect:ne,containerNodeRect:E,draggingNodeRect:Me,over:H.current.over,overlayNodeRect:pe.rect,scrollableAncestors:X,scrollableAncestorRects:Q,windowRect:Be}),ce=G?Ms(G,C):null,_e=Oz(X),Te=cm(_e),Oe=cm(_e,[ne]),he=Ms(re,Te),xe=Me?QF(Me,re):null,Fe=L&&xe?h({active:L,collisionRect:xe,droppableRects:J,droppableContainers:B,pointerCoordinates:ce}):null,F=jk(Fe,"id"),[ee,de]=l.useState(null),ie=Ce?re:Ms(re,Oe),fe=JF(ie,(o=ee==null?void 0:ee.rect)!=null?o:null,ne),ve=l.useRef(null),be=l.useCallback((je,Ve)=>{let{sensor:Se,options:Qe}=Ve;if(M.current==null)return;const K=N.get(M.current);if(!K)return;const V=je.nativeEvent,we=new Se({active:M.current,activeNode:K,event:V,options:Qe,context:H,onAbort(Ge){if(!N.get(Ge))return;const{onDragAbort:at}=W.current,it={id:Ge};at==null||at(it),v({type:"onDragAbort",event:it})},onPending(Ge,gt,at,it){if(!N.get(Ge))return;const{onDragPending:xt}=W.current,He={id:Ge,constraint:gt,initialCoordinates:at,offset:it};xt==null||xt(He),v({type:"onDragPending",event:He})},onStart(Ge){const gt=M.current;if(gt==null)return;const at=N.get(gt);if(!at)return;const{onDragStart:it}=W.current,Je={activatorEvent:V,active:{id:gt,data:at.data,rect:R}};us.unstable_batchedUpdates(()=>{it==null||it(Je),S(Fn.Initializing),y({type:ct.DragStart,initialCoordinates:Ge,active:gt}),v({type:"onDragStart",event:Je}),z(ve.current),Y(V)})},onMove(Ge){y({type:ct.DragMove,coordinates:Ge})},onEnd:Ue(ct.DragEnd),onCancel:Ue(ct.DragCancel)});ve.current=we;function Ue(Ge){return async function(){const{active:at,collisions:it,over:Je,scrollAdjustedTranslate:xt}=H.current;let He=null;if(at&&xt){const{cancelDrop:jt}=W.current;He={activatorEvent:V,active:at,collisions:it,delta:xt,over:Je},Ge===ct.DragEnd&&typeof jt=="function"&&await Promise.resolve(jt(He))&&(Ge=ct.DragCancel)}M.current=null,us.unstable_batchedUpdates(()=>{y({type:Ge}),S(Fn.Uninitialized),de(null),z(null),Y(null),ve.current=null;const jt=Ge===ct.DragEnd?"onDragEnd":"onDragCancel";if(He){const q=W.current[jt];q==null||q(He),v({type:jt,event:He})}})}}},[N]),We=l.useCallback((je,Ve)=>(Se,Qe)=>{const K=Se.nativeEvent,V=N.get(Qe);if(M.current!==null||!V||K.dndKit||K.defaultPrevented)return;const we={active:V};je(Se,Ve.options,we)===!0&&(K.dndKit={capturedBy:Ve.sensor},M.current=Qe,be(Se,Ve))},[N,be]),ze=_z(p,We);Rz(p),dn(()=>{ne&&_===Fn.Initializing&&S(Fn.Initialized)},[ne,_]),l.useEffect(()=>{const{onDragMove:je}=W.current,{active:Ve,activatorEvent:Se,collisions:Qe,over:K}=H.current;if(!Ve||!Se)return;const V={active:Ve,activatorEvent:Se,collisions:Qe,delta:{x:he.x,y:he.y},over:K};us.unstable_batchedUpdates(()=>{je==null||je(V),v({type:"onDragMove",event:V})})},[he.x,he.y]),l.useEffect(()=>{const{active:je,activatorEvent:Ve,collisions:Se,droppableContainers:Qe,scrollAdjustedTranslate:K}=H.current;if(!je||M.current==null||!Ve||!K)return;const{onDragOver:V}=W.current,we=Qe.get(F),Ue=we&&we.rect.current?{id:we.id,rect:we.rect.current,data:we.data,disabled:we.disabled}:null,Ge={active:je,activatorEvent:Ve,collisions:Se,delta:{x:K.x,y:K.y},over:Ue};us.unstable_batchedUpdates(()=>{de(Ue),V==null||V(Ge),v({type:"onDragOver",event:Ge})})},[F]),dn(()=>{H.current={activatorEvent:I,active:L,activeNode:se,collisionRect:xe,collisions:Fe,droppableRects:J,draggableNodes:N,draggingNode:ge,draggingNodeRect:Me,droppableContainers:T,over:ee,scrollableAncestors:X,scrollAdjustedTranslate:he},R.current={initial:Me,translated:xe}},[L,se,Fe,xe,N,ge,Me,J,T,ee,X,he]),yz({...le,delta:C,draggingRect:xe,pointerCoordinates:ce,scrollableAncestors:X,scrollableAncestorRects:Q});const Re=l.useMemo(()=>({active:L,activeNode:se,activeNodeRect:ne,activatorEvent:I,collisions:Fe,containerNodeRect:E,dragOverlay:pe,draggableNodes:N,droppableContainers:T,droppableRects:J,over:ee,measureDroppableContainers:te,scrollableAncestors:X,scrollableAncestorRects:Q,measuringConfiguration:D,measuringScheduled:oe,windowRect:Be}),[L,se,ne,I,Fe,E,pe,N,T,J,ee,te,X,Q,D,oe,Be]),Ye=l.useMemo(()=>({activatorEvent:I,activators:ze,active:L,activeNodeRect:ne,ariaDescribedById:{draggable:A},dispatch:y,draggableNodes:N,over:ee,measureDroppableContainers:te}),[I,ze,L,ne,y,A,N,ee,te]);return Mt.createElement(bk.Provider,{value:j},Mt.createElement(fi.Provider,{value:Ye},Mt.createElement(Ek.Provider,{value:Re},Mt.createElement(Ak.Provider,{value:fe},u)),Mt.createElement(Wz,{disabled:(c==null?void 0:c.restoreFocus)===!1})),Mt.createElement(HF,{...c,hiddenTextDescribedById:A}));function rt(){const je=(O==null?void 0:O.autoScrollEnabled)===!1,Ve=typeof d=="object"?d.enabled===!1:d===!1,Se=w&&!je&&!Ve;return typeof d=="object"?{...d,enabled:Se}:{enabled:Se}}}),Yz=l.createContext(null),um="button",Vz="Draggable";function Kz(e){let{id:n,data:s,disabled:r=!1,attributes:a}=e;const o=la(Vz),{activators:i,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:h,over:f}=l.useContext(fi),{role:m=um,roleDescription:g="draggable",tabIndex:x=0}=a??{},b=(d==null?void 0:d.id)===n,y=l.useContext(b?Ak:Yz),[v,j]=go(),[_,S]=go(),w=Ez(i,n),k=$r(s);dn(()=>(h.set(n,{id:n,key:o,node:v,activatorNode:_,data:k}),()=>{const C=h.get(n);C&&C.key===o&&h.delete(n)}),[h,n]);const N=l.useMemo(()=>({role:m,tabIndex:x,"aria-disabled":r,"aria-pressed":b&&m===um?!0:void 0,"aria-roledescription":g,"aria-describedby":p.draggable}),[r,m,x,b,g,p.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:N,isDragging:b,listeners:r?void 0:w,node:v,over:f,setNodeRef:j,setActivatorNodeRef:S,transform:y}}function Jz(){return l.useContext(Ek)}const Xz="Droppable",Qz={timeout:25};function Zz(e){let{data:n,disabled:s=!1,id:r,resizeObserverConfig:a}=e;const o=la(Xz),{active:i,dispatch:c,over:d,measureDroppableContainers:u}=l.useContext(fi),p=l.useRef({disabled:s}),h=l.useRef(!1),f=l.useRef(null),m=l.useRef(null),{disabled:g,updateMeasurementsFor:x,timeout:b}={...Qz,...a},y=$r(x??r),v=l.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),m.current=null},b)},[b]),j=hi({callback:v,disabled:g||!i}),_=l.useCallback((N,C)=>{j&&(C&&(j.unobserve(C),h.current=!1),N&&j.observe(N))},[j]),[S,w]=go(_),k=$r(n);return l.useEffect(()=>{!j||!S.current||(j.disconnect(),h.current=!1,j.observe(S.current))},[S,j]),l.useEffect(()=>(c({type:ct.RegisterDroppable,element:{id:r,key:o,disabled:s,node:S,rect:f,data:k}}),()=>c({type:ct.UnregisterDroppable,key:o,id:r})),[r]),l.useEffect(()=>{s!==p.current.disabled&&(c({type:ct.SetDroppableDisabled,id:r,key:o,disabled:s}),p.current.disabled=s)},[r,o,s,c]),{active:i,rect:f,isOver:(d==null?void 0:d.id)===r,node:S,over:d,setNodeRef:w}}function Wr(e,n,s){const r=e.slice();return r.splice(s<0?r.length+s:s,0,r.splice(n,1)[0]),r}function e6(e,n){return e.reduce((s,r,a)=>{const o=n.get(r);return o&&(s[a]=o),s},Array(e.length))}function Ta(e){return e!==null&&e>=0}function t6(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==n[s])return!1;return!0}function n6(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Mk=e=>{let{rects:n,activeIndex:s,overIndex:r,index:a}=e;const o=Wr(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}},Pa={scaleX:1,scaleY:1},s6=e=>{var n;let{activeIndex:s,activeNodeRect:r,index:a,rects:o,overIndex:i}=e;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,...Pa}:null}const d=r6(o,a,s);return a>s&&a<=i?{x:0,y:-c.height-d,...Pa}:a<s&&a>=i?{x:0,y:c.height+d,...Pa}:{x:0,y:0,...Pa}};function r6(e,n,s){const r=e[n],a=e[n-1],o=e[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 Ik="Sortable",Dk=Mt.createContext({activeIndex:-1,containerId:Ik,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Mk,disabled:{draggable:!1,droppable:!1}});function a6(e){let{children:n,id:s,items:r,strategy:a=Mk,disabled:o=!1}=e;const{active:i,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:p}=Jz(),h=la(Ik,s),f=c.rect!==null,m=l.useMemo(()=>r.map(w=>typeof w=="object"&&"id"in w?w.id:w),[r]),g=i!=null,x=i?m.indexOf(i.id):-1,b=u?m.indexOf(u.id):-1,y=l.useRef(m),v=!t6(m,y.current),j=b!==-1&&x===-1||v,_=n6(o);dn(()=>{v&&g&&p(m)},[v,m,g,p]),l.useEffect(()=>{y.current=m},[m]);const S=l.useMemo(()=>({activeIndex:x,containerId:h,disabled:_,disableTransforms:j,items:m,overIndex:b,useDragOverlay:f,sortedRects:e6(m,d),strategy:a}),[x,h,_.draggable,_.droppable,j,m,b,d,f,a]);return Mt.createElement(Dk.Provider,{value:S},n)}const o6=e=>{let{id:n,items:s,activeIndex:r,overIndex:a}=e;return Wr(s,r,a).indexOf(n)},i6=e=>{let{containerId:n,isSorting:s,wasDragging:r,index:a,items:o,newIndex:i,previousItems:c,previousContainerId:d,transition:u}=e;return!u||!r||c!==o&&a===i?!1:s?!0:i!==a&&n===d},l6={duration:200,easing:"ease"},Lk="transform",c6=zr.Transition.toString({property:Lk,duration:0,easing:"linear"}),d6={roleDescription:"sortable"};function u6(e){let{disabled:n,index:s,node:r,rect:a}=e;const[o,i]=l.useState(null),c=l.useRef(s);return dn(()=>{if(!n&&s!==c.current&&r.current){const d=a.current;if(d){const u=Qs(r.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&i(p)}}s!==c.current&&(c.current=s)},[n,s,r,a]),l.useEffect(()=>{o&&i(null)},[o]),o}function p6(e){let{animateLayoutChanges:n=i6,attributes:s,disabled:r,data:a,getNewIndex:o=o6,id:i,strategy:c,resizeObserverConfig:d,transition:u=l6}=e;const{items:p,containerId:h,activeIndex:f,disabled:m,disableTransforms:g,sortedRects:x,overIndex:b,useDragOverlay:y,strategy:v}=l.useContext(Dk),j=h6(r,m),_=p.indexOf(i),S=l.useMemo(()=>({sortable:{containerId:h,index:_,items:p},...a}),[h,a,_,p]),w=l.useMemo(()=>p.slice(p.indexOf(i)),[p,i]),{rect:k,node:N,isOver:C,setNodeRef:T}=Zz({id:i,data:S,disabled:j.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...d}}),{active:P,activatorEvent:R,activeNodeRect:L,attributes:M,setNodeRef:O,listeners:z,isDragging:I,over:Y,setActivatorNodeRef:W,transform:A}=Kz({id:i,data:S,attributes:{...d6,...s},disabled:j.draggable}),B=OF(T,O),D=!!P,J=D&&!g&&Ta(f)&&Ta(b),te=!y&&I,oe=te&&J?A:null,G=J?oe??(c??v)({rects:x,activeNodeRect:L,activeIndex:f,overIndex:b,index:_}):null,le=Ta(f)&&Ta(b)?o({id:i,items:p,activeIndex:f,overIndex:b}):_,ue=P==null?void 0:P.id,ne=l.useRef({activeId:ue,items:p,newIndex:le,containerId:h}),E=p!==ne.current.items,H=n({active:P,containerId:h,isDragging:I,isSorting:D,id:i,index:_,items:p,newIndex:ne.current.newIndex,previousItems:ne.current.items,previousContainerId:ne.current.containerId,transition:u,wasDragging:ne.current.activeId!=null}),U=u6({disabled:!H,index:_,node:N,rect:k});return l.useEffect(()=>{D&&ne.current.newIndex!==le&&(ne.current.newIndex=le),h!==ne.current.containerId&&(ne.current.containerId=h),p!==ne.current.items&&(ne.current.items=p)},[D,le,h,p]),l.useEffect(()=>{if(ue===ne.current.activeId)return;if(ue!=null&&ne.current.activeId==null){ne.current.activeId=ue;return}const ge=setTimeout(()=>{ne.current.activeId=ue},50);return()=>clearTimeout(ge)},[ue]),{active:P,activeIndex:f,attributes:M,data:S,rect:k,index:_,newIndex:le,items:p,isOver:C,isSorting:D,isDragging:I,listeners:z,node:N,overIndex:b,over:Y,setNodeRef:B,setActivatorNodeRef:W,setDroppableNodeRef:T,setDraggableNodeRef:O,transform:U??G,transition:pe()};function pe(){if(U||E&&ne.current.newIndex===_)return c6;if(!(te&&!dp(R)||!u)&&(D||H))return zr.Transition.toString({...u,property:Lk})}}function h6(e,n){var s,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(s=e==null?void 0:e.draggable)!=null?s:n.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:n.droppable}}function yo(e){if(!e)return!1;const n=e.data.current;return!!(n&&"sortable"in n&&typeof n.sortable=="object"&&"containerId"in n.sortable&&"items"in n.sortable&&"index"in n.sortable)}const f6=[$e.Down,$e.Right,$e.Up,$e.Left],m6=(e,n)=>{let{context:{active:s,collisionRect:r,droppableRects:a,droppableContainers:o,over:i,scrollableAncestors:c}}=n;if(f6.includes(e.code)){if(e.preventDefault(),!s||!r)return;const d=[];o.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=a.get(h.id);if(f)switch(e.code){case $e.Down:r.top<f.top&&d.push(h);break;case $e.Up:r.top>f.top&&d.push(h);break;case $e.Left:r.left>f.left&&d.push(h);break;case $e.Right:r.left<f.left&&d.push(h);break}});const u=YF({collisionRect:r,droppableRects:a,droppableContainers:d});let p=jk(u,"id");if(p===(i==null?void 0:i.id)&&u.length>1&&(p=u[1].id),p!=null){const h=o.get(s.id),f=o.get(p),m=f?a.get(f.id):null,g=f==null?void 0:f.node.current;if(g&&m&&h&&f){const b=pi(g).some((w,k)=>c[k]!==w),y=$k(h,f),v=g6(h,f),j=b||!y?{x:0,y:0}:{x:v?r.width-m.width:0,y:v?r.height-m.height:0},_={x:m.left,y:m.top};return j.x&&j.y?_:Fr(_,j)}}}};function $k(e,n){return!yo(e)||!yo(n)?!1:e.data.current.sortable.containerId===n.data.current.sortable.containerId}function g6(e,n){return!yo(e)||!yo(n)||!$k(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function mp({filePath:e}){return t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{"data-testid":"plan-expanded-header-file-path",className:"text-xs font-mono text-[var(--text-dim)] break-all",children:e}),t.jsx(Fy,{value:e})]})})}const Pte=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedHeader:mp},Symbol.toStringTag,{value:"Module"}));function gp({title:e}){return t.jsx("div",{"data-testid":"plan-expanded-title",className:"px-3 pt-2 text-sm font-medium text-[var(--text-primary)] break-words",children:e})}const Ote=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedTitle:gp},Symbol.toStringTag,{value:"Module"}));function x6(){const[e,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:e,error:s}}function b6(){const[e,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:e,error:s}}function y6(e,n){return n.filter(s=>s.slug!==e&&(s.dependsOn??[]).includes(e)).map(s=>({slug:s.slug,title:s.title}))}function Fk({slug:e,onClose:n}){return t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:t.jsx(Ht,{chatName:`edit-plan-${e}`,slashCommand:`/codeyam-edit-plan ${e}`,height:360,onClose:n})})}const Rte=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedChat:Fk},Symbol.toStringTag,{value:"Module"}));function zk({titleDraft:e,bodyDraft:n,saving:s,error:r,onTitleChange:a,onBodyChange:o,onSave:i,onCancel:c}){const d=Math.min(20,Math.max(8,n.split(`
|
|
88
|
-
`).length));return t.jsxs("div",{className:"border-t border-[var(--border-subtle)] px-3 py-2 flex flex-col gap-2",children:[t.jsx("input",{type:"text",value:e,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)]"}),t.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&&t.jsx(dt,{text:r,className:"text-xs text-[var(--accent-red)]"}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.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"}),t.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 Ete=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedEdit:zk},Symbol.toStringTag,{value:"Module"}));function Bk(e){const n=[];let s={title:null,lines:[]};const r=()=>{(s.title!==null||s.lines.some(a=>a.trim()))&&n.push(s)};for(const a of e.split(`
|
|
89
|
-
`)){const o=/^##\s+(.+?)\s*$/.exec(a);o?(r(),s={title:o[1],lines:[]}):s.lines.push(a)}return r(),n.map(a=>({title:a.title,body:a.lines.join(`
|
|
90
|
-
`)}))}function Wk({body:e}){const n=Bk(e),[s,r]=l.useState(()=>new Set([0])),a=o=>r(i=>{const c=new Set(i);return c.has(o)?c.delete(o):c.add(o),c});return t.jsx("div",{className:"flex flex-col",children:n.map((o,i)=>{const c=s.has(i);return o.title===null?t.jsx(Lt,{variant:"document",children:o.body},i):t.jsxs("section",{className:i>0?"border-t border-white/[.06]":"",children:[t.jsx("h2",{className:"m-0",children:t.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>a(i),className:"group flex w-full items-center gap-2 py-2 text-left cursor-pointer",children:[t.jsx("span",{"aria-hidden":"true",className:"w-3 text-[10px] text-gray-500 group-hover:text-gray-300",children:c?"▾":"▸"}),t.jsx("span",{className:"text-[13px] font-medium text-gray-200 group-hover:text-white",children:o.title})]})}),c&&t.jsx("div",{className:"pb-3 pl-5",children:t.jsx(Lt,{variant:"document",children:o.body})})]},i)})})}const Ate=Object.freeze(Object.defineProperty({__proto__:null,PlanDocument:Wk,splitPlanSections:Bk},Symbol.toStringTag,{value:"Module"}));function Hk({onClick:e}){return t.jsx("button",{type:"button",onClick:e,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 Mte=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditButton:Hk},Symbol.toStringTag,{value:"Module"}));function qk({providerLabel:e,onClick:n}){return t.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 ${e} seeded with this plan's contents`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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 ",e]})}const Ite=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditChatButton:qk},Symbol.toStringTag,{value:"Module"}));function Uk({dep:e}){const n=!e.satisfied&&e.title===null,s=e.satisfied?"completed":n?"missing":"blocked",r=e.satisfied?{borderColor:"var(--border-subtle)",color:"var(--text-dim)"}:{borderColor:"var(--accent-warn, #c08a2c)",color:"var(--accent-warn, #c08a2c)"};return t.jsxs("li",{"data-testid":`plan-row-dep-${e.slug}`,className:"text-sm flex items-center gap-2",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border whitespace-nowrap",style:r,children:s}),t.jsx("span",{className:e.satisfied?"text-[var(--text-dim)] truncate":"text-[var(--text-primary)] truncate",children:n?`missing: ${e.slug}`:e.title??e.slug})]})}const Dte=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDependencyEntry:Uk},Symbol.toStringTag,{value:"Module"}));function xp({dependencies:e}){return t.jsxs("div",{"data-testid":"plan-row-deps",className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mb-1.5",children:"Depends on"}),t.jsx("ul",{className:"flex flex-col gap-1",children:e.map(n=>t.jsx(Uk,{dep:n},n.slug))})]})}const Lte=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedDependencies:xp},Symbol.toStringTag,{value:"Module"}));function Gk({title:e,filePath:n,body:s,providerLabel:r,onEdit:a,onChat:o,onDelete:i,dependencies:c}){return t.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[t.jsx(gp,{title:e}),c&&c.length>0&&t.jsx(xp,{dependencies:c}),t.jsx("div",{className:"px-4 py-2 max-h-[55vh] overflow-y-auto",children:t.jsx(Wk,{body:s})}),t.jsx(mp,{filePath:n}),t.jsxs("div",{className:"flex gap-2 justify-between px-3 py-2 border-t border-[var(--border-subtle)]",children:[t.jsx(Ey,{onClick:i}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Hk,{onClick:a}),t.jsx(qk,{providerLabel:r,onClick:o})]})]})]})}const $te=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedView:Gk},Symbol.toStringTag,{value:"Module"}));function Yk({plan:e,dependencies:n}){const[s,r]=l.useState("view"),[a,o]=l.useState(!1),[i,c]=l.useState(e.title),[d,u]=l.useState(e.body),{updatePlan:p,saving:h,error:f}=b6(),{deletePlan:m,deleting:g,error:x}=x6(),{plans:b}=qr(),{config:y}=Pt(),v=st(y==null?void 0:y.provider);return l.useEffect(()=>{c(e.title),u(e.body),r("view"),o(!1)},[e.slug]),s==="chat"?t.jsx(Fk,{slug:e.slug,onClose:()=>r("view")}):s==="edit"?t.jsx(zk,{titleDraft:i,bodyDraft:d,saving:h,error:f,onTitleChange:c,onBodyChange:u,onSave:async()=>{try{await p(e.slug,{title:i,body:d}),r("view")}catch{}},onCancel:()=>{c(e.title),u(e.body),r("view")}}):t.jsxs(t.Fragment,{children:[t.jsx(Gk,{title:e.title,filePath:e.filePath,body:e.body,providerLabel:v,onEdit:()=>r("edit"),onChat:()=>r("chat"),onDelete:()=>o(!0),dependencies:n}),a&&t.jsx(Ry,{title:e.title,slug:e.slug,filePath:e.filePath,dependents:y6(e.slug,b),busy:g,error:x,onCancel:()=>o(!1),onConfirm:async()=>{try{await m(e.slug)}catch{}}})]})}const Fte=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedBody:Yk},Symbol.toStringTag,{value:"Module"}));function bp({plan:e,expanded:n,onToggle:s,onRun:r,launching:a=!1,blocked:o=!1,position:i,dragHandleRef:c,dragHandleAttributes:d,dragHandleListeners:u,sortableRef:p,sortableStyle:h,isDragging:f=!1,unsatisfiedDepCount:m=0,unsatisfiedDepTooltip:g,dependencies:x,claim:b,staleFetch:y=!1,expandedBodyVariant:v="full",author:j}){const _=S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),s())};return t.jsxs("li",{ref:p,style:h,className:`border border-[var(--plan-row-border,var(--border-subtle))] rounded-lg bg-[var(--plan-row-bg,var(--bg-surface))] transition-colors hover:border-[var(--text-dim)] hover:bg-[var(--bg-card)] ${f?"opacity-60 shadow-lg":""}`,children:[t.jsxs("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:_,className:"w-full text-left px-3 py-2 flex items-center justify-between gap-3 bg-transparent cursor-pointer",children:[t.jsx(Hy,{slug:e.slug,title:e.title,timestamp:e.createdAt,position:i,author:j,dragHandleRef:c,dragHandleAttributes:d,dragHandleListeners:u}),t.jsx(Gy,{slug:e.slug,mode:e.mode,expanded:n,onRun:r,launching:a,blocked:o,unsatisfiedDepCount:m,unsatisfiedDepTooltip:g,claim:b,staleFetch:y})]}),n&&(v==="view"?t.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[t.jsx(gp,{title:e.title}),x&&x.length>0&&t.jsx(xp,{dependencies:x}),t.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:t.jsx(Lt,{variant:"compact",children:e.body})}),t.jsx(mp,{filePath:e.filePath})]}):t.jsx(Yk,{plan:e,dependencies:x}))]})}const zte=Object.freeze(Object.defineProperty({__proto__:null,PlanRow:bp},Symbol.toStringTag,{value:"Module"}));function Vk({plan:e,position:n,expanded:s,onToggle:r,onRun:a,launching:o,blocked:i,draggable:c,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:p,claim:h,staleFetch:f,author:m}){const{attributes:g,listeners:x,setNodeRef:b,setActivatorNodeRef:y,transform:v,transition:j,isDragging:_}=p6({id:e.slug,disabled:!c}),S={transform:zr.Transform.toString(v),transition:j};return t.jsx(bp,{plan:e,expanded:s,onToggle:r,onRun:a,launching:o,blocked:i,position:n,sortableRef:b,sortableStyle:S,isDragging:_,dragHandleRef:c?y:void 0,dragHandleAttributes:c?g:void 0,dragHandleListeners:c?x:void 0,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:p,claim:h,staleFetch:f,author:m})}const Bte=Object.freeze(Object.defineProperty({__proto__:null,SortablePlanRow:Vk},Symbol.toStringTag,{value:"Module"}));function v6(e,n){const[s,r]=l.useState(null),[a,o]=l.useState(null);return l.useEffect(()=>{r(null)},[e]),{items:s??e,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 mi({plans:e,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i=!1,onReorder:c,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:p,staleFetch:h,showAuthors:f=!1,skeletonCount:m=3}){const[g,x]=l.useState(null),{items:b,error:y,reorder:v}=v6(e,c?k=>c(k.map(N=>N.slug)):void 0),_=n&&b.length===0?m:b.length,[S,w]=l.useState(!0);return t.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5",children:[t.jsx(Kr,{title:"Queued Plans",count:_,expanded:S,onToggle:()=>w(k=>!k),testId:"queued-plans-header"}),o&&t.jsxs(Il,{tone:"error",spacing:"tight",children:["Failed to launch plan: ",o]}),y&&t.jsxs(Il,{tone:"error",spacing:"tight",children:["Failed to reorder plans: ",y]}),S&&t.jsx(yp,{plans:b,loading:n,error:s,expandedSlug:g,onToggle:k=>x(N=>N===k?null:k),onRun:r,launchingSlug:a??null,blocked:i,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:p,staleFetch:h,onReorder:v??void 0,showAuthors:f,skeletonCount:m})]})}function yp({plans:e,loading:n,error:s,expandedSlug:r,onToggle:a,onRun:o,launchingSlug:i,blocked:c,onReorder:d,depAnnotationsBySlug:u,dependenciesBySlug:p,claimsBySlug:h,staleFetch:f,showAuthors:m=!1,skeletonCount:g=3}){const x=qF(Zf(fp,{activationConstraint:{distance:4}}),Zf(pp,{coordinateGetter:m6})),b=l.useMemo(()=>e.map(_=>_.slug),[e]),y=s?t.jsx(dt,{text:`Failed to load plans: ${s}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):null;if(n&&e.length===0)return t.jsx(Yd,{count:g});if(e.length===0)return y;const v=_=>{const{active:S,over:w}=_;if(!w||S.id===w.id||!d)return;const k=e.findIndex(C=>C.slug===S.id),N=e.findIndex(C=>C.slug===w.id);k===-1||N===-1||d(Wr(e,k,N))},j=t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"plan-list",children:e.map((_,S)=>{const w=u==null?void 0:u[_.slug],k=h==null?void 0:h.get(_.slug);return t.jsx(Vk,{plan:_,position:S+1,expanded:r===_.slug,onToggle:()=>a(_.slug),onRun:o,launching:i===_.slug,blocked:c,draggable:!!d,unsatisfiedDepCount:w==null?void 0:w.count,unsatisfiedDepTooltip:w==null?void 0:w.tooltip,dependencies:p==null?void 0:p[_.slug],claim:k,staleFetch:f,author:m?_.author:void 0},_.slug)})});return d?t.jsxs(t.Fragment,{children:[y,t.jsx(Gz,{sensors:x,collisionDetection:GF,onDragEnd:v,children:t.jsx(a6,{items:b,strategy:s6,children:j})})]}):t.jsxs(t.Fragment,{children:[y,j]})}const Wte=Object.freeze(Object.defineProperty({__proto__:null,QueuedChangesBody:yp,QueuedChangesSection:mi},Symbol.toStringTag,{value:"Module"})),mc="build-reset-requested";function j6(){window.dispatchEvent(new CustomEvent(mc))}const gc="build-empty-session-close";function w6(){window.dispatchEvent(new CustomEvent(gc))}function Kk({awaitingPlanLaunchChoice:e,configLoading:n,sessionLoading:s,sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i,provider:c,onContinueSession:d,onStartOver:u,onAgentIdle:p,onAgentBlocked:h,onAgentActive:f,onUserInput:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:w=!1,buildActivity:k="menu",chatEscalatedToPrototype:N=!1,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P=0,connectionPhase:R=null}){var B;const L=l.useSyncExternalStore(PF,TF),M=()=>{Xf(!0),T==null||T()};l.useEffect(()=>{w&&Xf(!1)},[w]);const{recoveryFeatureName:O,recoveryStep:z,recoveryMode:I,showTerminal:Y,shouldResumeSameProvider:W}=W$({sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i}),A=r==="completed"&&!(a!=null&&a.cycleClosed);return r==="pending"||A?t.jsx(AS,{featureName:O,editorStep:z,workflowMode:I,currentProvider:c,previousProvider:(a==null?void 0:a.provider)??null,resumeMode:(a==null?void 0:a.resumeMode)??"fresh",sessionId:(a==null?void 0:a.sessionId)??null,activity:((B=a==null?void 0:a.liveBuildActivity)==null?void 0:B.activity)??null,idleSeconds:(a==null?void 0:a.sessionIdleSeconds)??null,onContinue:d,onStartOver:u??j6,onEmptySession:w6}):k==="prototype"?t.jsx(Kt,{testId:"build-activity-prototype",fill:!0,children:t.jsx(fk,{isAgentBuilding:S&&!w,featureName:(i==null?void 0:i.feature)??null,initiallyOpen:!0,onDone:C,onLaunched:M,launchSignal:P})}):k==="chat"?t.jsx(Kt,{testId:"build-activity-chat",fill:!0,children:t.jsx(lk,{escalatedToPrototype:N,onDone:C,onLaunched:M,launchSignal:P})}):e&&g.length>0&&a===null&&i===null?t.jsx(Kt,{children:t.jsx(mi,{plans:g,loading:x,error:b,onRun:D=>{var te;const J=((te=g.find(oe=>oe.slug===D))==null?void 0:te.title)??D;y(D,J)},launchingSlug:v,launchError:j,blocked:S,onReorder:_})}):Y?t.jsx(aa,{label:"Build agent",sessionName:"build session",initialView:"terminal",experimentalNotice:q$,initialSessionId:W?(a==null?void 0:a.sessionId)??null:null,onWaitingOnUser:()=>h("chat-question"),onNeedsYouChange:Ju,onWorkingChange:Xu,intro:L?t.jsx(mk,{}):void 0,renderTerminal:D=>t.jsx(tk,{provider:c,shouldResumeSameProvider:W,sessionId:(a==null?void 0:a.sessionId)??null,onAgentIdle:p,onAgentBlocked:h,onAgentActive:f,onUserInput:m,currentFeature:(i==null?void 0:i.feature)??null,binding:D})}):j?t.jsx(yb,{message:j}):R?t.jsx(eb,{phase:R}):r==="no-session"&&i===null?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-slate-500 space-y-4 px-10 text-center",children:[t.jsx("div",{className:"text-lg font-medium text-slate-400",children:"Ready to build"}),t.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 Hte=Object.freeze(Object.defineProperty({__proto__:null,BuildTabSessionContent:Kk},Symbol.toStringTag,{value:"Module"}));function _6(e){return e?{step:e.step??0,feature:e.feature??null,startedAt:e.startedAt??"",...e.featureStartedAt?{featureStartedAt:e.featureStartedAt}:{},mode:qt(e.mode),slug:e.slug??null,slugVisits:e.slugVisits??{}}:null}const S6=3e3;function ca(){const[e,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=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{const d=_6(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,S6),()=>{a.current&&clearInterval(a.current)}),[i]),{stepState:e,loading:s,refetch:i}}const yt={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,liveBuildActivity:null,sessionIdleSeconds:null};function k6(e){return{hasSession:(e==null?void 0:e.hasSession)??yt.hasSession,resumeMode:(e==null?void 0:e.resumeMode)??yt.resumeMode,provider:(e==null?void 0:e.provider)??yt.provider,feature:(e==null?void 0:e.feature)??yt.feature,step:(e==null?void 0:e.step)??yt.step,mode:(e==null?void 0:e.mode)==null?yt.mode:qt(e.mode),label:(e==null?void 0:e.label)??yt.label,sessionId:(e==null?void 0:e.sessionId)??yt.sessionId,awaitingUserInput:(e==null?void 0:e.awaitingUserInput)??yt.awaitingUserInput,reopenResults:(e==null?void 0:e.reopenResults)??yt.reopenResults,preview:(e==null?void 0:e.preview)??yt.preview,agentBrokerLive:(e==null?void 0:e.agentBrokerLive)??yt.agentBrokerLive,brokerDaemonReachable:e==null?void 0:e.brokerDaemonReachable,resultsShown:(e==null?void 0:e.resultsShown)??yt.resultsShown,cycleClosed:(e==null?void 0:e.cycleClosed)??yt.cycleClosed,liveBuildActivity:(e==null?void 0:e.liveBuildActivity)??yt.liveBuildActivity,sessionIdleSeconds:(e==null?void 0:e.sessionIdleSeconds)??yt.sessionIdleSeconds}}function vp(e){const n=e==null?void 0:e.pollIntervalMs,[s,r]=l.useState(null),[a,o]=l.useState(!0),i=l.useCallback(async()=>{o(!0);try{const c=await Su("/api/session-info");if(!c.ok)throw new Error(`HTTP ${c.status}`);const d=await c.json();r(k6(d))}catch{r(c=>c??yt)}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 N6=5e3;function C6(){const[e,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,N6),()=>{a.current&&clearInterval(a.current)}},[]),{prompt:e,loading:s}}function T6({currentDecision:e,sessionInfo:n,sessionLoading:s,attachedSessionId:r=null,requestAttachLive:a=!1}){return s||!n?e:e==="continue"&&n.hasSession?"continue":e==="fresh"&&n.hasSession&&(n.resumeMode==="resume"||n.resumeMode==="completed")?"fresh":n.resumeMode==="completed"?"completed":a&&n.hasSession&&n.resumeMode!=="handoff"||n.resumeMode==="resume"&&n.hasSession&&r!=null&&n.sessionId===r?"continue":n.resumeMode==="resume"||n.resumeMode==="handoff"?"pending":"fresh"}let Ya=null;const P6=1e4,xc=new Set;function Jk(){Ya=Date.now();for(const e of[...xc])e()}function O6(e){return xc.add(e),()=>{xc.delete(e)}}function pm(){if(Ya==null)return!1;const e=Date.now()-Ya;return Ya=null,e<=P6}const jp="codeyam.buildTab.attachedSessionId";function R6(e){try{window.sessionStorage.setItem(jp,e)}catch{}}function E6(){try{return window.sessionStorage.getItem(jp)}catch{return null}}function A6(){try{window.sessionStorage.removeItem(jp)}catch{}}function M6({sessionLoading:e,sessionInfo:n,requestAttachLive:s=!1}){const r=l.useRef(void 0);r.current===void 0&&(r.current=E6());const[a,o]=l.useState(()=>pm()?"fresh":"no-session");l.useEffect(()=>O6(()=>{pm(),o("fresh")}),[]),l.useEffect(()=>{o(c=>T6({currentDecision:c,sessionInfo:n,sessionLoading:e,attachedSessionId:r.current??null,requestAttachLive:s}))},[e,n,s]),l.useEffect(()=>{if(n){if(!n.hasSession){A6(),r.current=null;return}n.sessionId&&(a==="continue"||a==="fresh")&&(R6(n.sessionId),r.current=n.sessionId)}},[a,n]);const i=l.useCallback(()=>{o("continue")},[]);return{sessionDecision:a,handleContinueSession:i}}function I6(e,n){return e!=null&&e.worker?(e.state==="dispatching"||e.state==="delayed"||e.state==="launch-timeout"||e.state==="acknowledged"||e.state==="unverified")&&(n==null?void 0:n.agentBrokerLive)===!0:!1}function D6(e,n){return e?e.state==="interrupted"?"interrupted":e.worker&&n===null&&(e.state==="acknowledged"||e.state==="unverified")?"reconnecting":e.state==="dispatching"||e.state==="delayed"||e.state==="launch-timeout"?"starting":null:null}function L6(){const e=window.getSelection();return!!e&&!e.isCollapsed&&e.toString().length>0}function bc(){const e=document.activeElement;return e===null||e===document.body||e===document.documentElement||e instanceof HTMLElement&&e.dataset.navTab==="true"}function yc(e,n,s,r=0){return e>=s.left-r&&e<=s.right+r&&n>=s.top-r&&n<=s.bottom+r}function vc(e){hm(e,!0);let n=!1;const s=()=>{n||(n=!0,hm(e,!1))};typeof requestAnimationFrame=="function"?(requestAnimationFrame(s),setTimeout(s,100)):queueMicrotask(s)}function hm(e,n){const s=e;if(typeof s.inert=="boolean"){s.inert=n;return}n?e.setAttribute("inert",""):e.removeAttribute("inert")}function rl(e){Pr(),vc(e),e.blur(),Tt(),queueMicrotask(()=>{document.activeElement===e&&(vc(e),e.blur(),Tt())})}function $6(e){const n=l.useRef(!1),s=l.useRef(null);l.useEffect(()=>{if(!e)return;let r=!1;const a=()=>{r=!0},o=()=>{r=!1};function i(){if(!n.current&&!r&&bc()&&!L6()){n.current=!0;try{Pr(),window.dispatchEvent(new Event("terminal-focus"))}finally{n.current=!1}}}function c(f){const m=f.relatedTarget;m instanceof HTMLElement&&m.dataset.navTab!=="true"||queueMicrotask(i)}function d(){const f=document.activeElement;f instanceof HTMLIFrameElement&&(s.current=f)}function u(f){const m=document.activeElement;if(m instanceof HTMLIFrameElement){if(f.target===m)return;rl(m),h(m);return}const g=s.current;if(!g||f.target===g)return;const x=f;if(typeof x.clientX=="number"&&typeof x.clientY=="number"){const b=g.getBoundingClientRect();if(yc(x.clientX,x.clientY,b,1))return}rl(g),h(g)}function p(f){const m=document.activeElement;if(!(m instanceof HTMLIFrameElement))return;s.current=m;const g=m.getBoundingClientRect();yc(f.clientX,f.clientY,g,1)||(rl(m),h(m))}function h(f){requestAnimationFrame(()=>{document.activeElement!==f&&(bc()||(s.current=null))})}return document.addEventListener("pointerdown",a,!0),document.addEventListener("pointerup",o,!0),document.addEventListener("pointercancel",o,!0),window.addEventListener("blur",o),document.addEventListener("focusin",d),document.addEventListener("focusout",c),window.addEventListener("focus",c),document.addEventListener("visibilitychange",c),document.addEventListener("mouseup",c),document.addEventListener("pointerdown",u,!0),document.addEventListener("mousedown",u,!0),document.addEventListener("click",u,!0),document.addEventListener("pointermove",p,{capture:!0,passive:!0}),()=>{document.removeEventListener("pointerdown",a,!0),document.removeEventListener("pointerup",o,!0),document.removeEventListener("pointercancel",o,!0),window.removeEventListener("blur",o),document.removeEventListener("focusin",d),document.removeEventListener("focusout",c),window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",c),document.removeEventListener("mouseup",c),document.removeEventListener("pointerdown",u,!0),document.removeEventListener("mousedown",u,!0),document.removeEventListener("click",u,!0),document.removeEventListener("pointermove",p,{capture:!0})}},[e])}function F6({sessionLoading:e,sessionInfo:n,onRestorePreview:s}){const r=l.useRef(!1);l.useEffect(()=>{e||!(n!=null&&n.preview)||n.resumeMode!=="resume"&&n.resumeMode!=="handoff"||r.current||(r.current=!0,s==null||s(n.preview))},[s,n,e])}function z6(e){const n=l.useRef(e),s=l.useRef(null);l.useEffect(()=>{e&&e!==n.current&&(n.current=e,s.current??(s.current=new AbortController),Tr(e,void 0,void 0,"session-feature-rename",s.current.signal))},[e]),l.useEffect(()=>()=>{var r;(r=s.current)==null||r.abort()},[])}function B6(e,n){if(!e||!n)return null;const s=n[e]??0;return s<=1?null:s===2?"2nd pass":s===3?"3rd pass":`${s}th pass`}function W6(e,n,s){l.useEffect(()=>{if(!n)return;const r=a=>{e.current&&!e.current.contains(a.target)&&s()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,n,s])}function Xk({displayName:e,hasPrompt:n,expanded:s,onToggle:r}){return n?t.jsxs("button",{onClick:r,className:"flex items-center gap-1 cursor-pointer transition-colors min-w-0",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-medium truncate",children:e}),t.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:t.jsx("path",{d:"M2 4l3 3 3-3"})})]}):t.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-secondary)"},children:e})}const qte=Object.freeze(Object.defineProperty({__proto__:null,FeatureNameButton:Xk},Symbol.toStringTag,{value:"Module"}));function Qk({prompt:e}){return t.jsxs("div",{"data-testid":"prompt-dropdown-panel",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:12,boxShadow:"0 12px 32px rgba(0,0,0,.45)",maxHeight:"16rem",overflowY:"auto",padding:"12px 16px 14px",fontSize:12.5,lineHeight:1.6,color:"var(--text-secondary)"},children:[t.jsx("div",{style:{fontSize:10.5,letterSpacing:".08em",textTransform:"uppercase",color:"var(--text-dim)",marginBottom:4},children:"Your request"}),t.jsx(Lt,{variant:"compact",children:e})]})}const Ute=Object.freeze(Object.defineProperty({__proto__:null,PromptDropdownPanel:Qk},Symbol.toStringTag,{value:"Module"}));function Zk({label:e}){return e?t.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:e}):null}const Gte=Object.freeze(Object.defineProperty({__proto__:null,RepeatPassMarker:Zk},Symbol.toStringTag,{value:"Module"}));function e1({currentStep:e,isExpanded:n,mode:s,onToggle:r=()=>{},stepNum:a}){const o=a===e,i=a<e,{primary:c,secondary:d,phaseLabel:u,description:p}=z3(a,s);return t.jsxs("div",{onClick:r,className:"cursor-pointer",children:[t.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:h=>h.currentTarget.style.background="var(--bg-input)",onMouseLeave:h=>h.currentTarget.style.background="transparent",children:[t.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[a,"."]}),t.jsx("span",{className:"flex-1 min-w-0 truncate",children:c}),d&&t.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-dim)",opacity:.7},children:d}),p&&t.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:t.jsx("path",{d:"M2 4l3 3 3-3"})})]}),n&&p&&t.jsxs("div",{className:"px-3 pb-1.5 pl-10",children:[u&&t.jsx("p",{className:"text-[9px] m-0 mb-0.5 uppercase tracking-wide",style:{color:"var(--text-dim)",opacity:.7},children:u}),t.jsx("p",{className:"text-[10px] m-0 leading-relaxed",style:{color:"var(--text-dim)"},children:p})]})]},a)}const Yte=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorDropdownItem:e1},Symbol.toStringTag,{value:"Module"}));function jc({step:e,feature:n,mode:s,userPrompt:r,slug:a=null,slugVisits:o,inline:i=!1,hideStep:c=!1,note:d,namePrefix:u,nameSuffix:p}){const[h,f]=l.useState(!1),[m,g]=l.useState(null),[x,b]=l.useState(!1),[y,v]=l.useState(null),j=l.useRef(null),_=l.useRef(null),S=l.useRef(null),w=l.useRef(null);l.useLayoutEffect(()=>{if(!h)return;const A=()=>{var D;const B=(D=_.current)==null?void 0:D.getBoundingClientRect();B&&v({top:B.bottom+4,left:B.left,right:window.innerWidth-B.right})};return A(),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[h]),l.useEffect(()=>{if(!h)return;const A=B=>{var J,te;const D=B.target;(J=j.current)!=null&&J.contains(D)||(te=S.current)!=null&&te.contains(D)||f(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[h]),W6(w,x,l.useCallback(()=>b(!1),[]));const k=c||i&&d?0:e,N=k>0,C=n||"New Working Session",T=qt(s),P=N0(k,T),R=P.totalSteps,L=P.prefix,M=Mu(k,T),O=N?M.primary:null,z=N?M.secondary:null,I=B6(a,o),Y=i?"flex flex-col items-start gap-0.5 min-w-0 text-[13px] select-none":"h-9 flex items-center justify-between px-4 text-[13px] shrink-0 select-none",W=A=>i||!A?void 0:ra("bottom");return k===0?t.jsxs("div",{className:Y,style:W(!0),children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 max-w-full",children:[u,t.jsx("span",{className:"font-medium truncate",style:{color:i?"var(--text-primary)":"var(--text-muted)"},children:C}),p]}),i&&d&&t.jsx("span",{"data-testid":"step-indicator-note",className:"text-[11.5px] truncate max-w-full",style:{color:"var(--text-muted)"},children:d}),!i&&t.jsx("span",{style:{color:"var(--text-dim)"},children:n?"Starting…":"Waiting for session"})]}):t.jsxs("div",{className:i?"relative min-w-0":"shrink-0",ref:w,children:[t.jsxs("div",{className:Y,style:W(!x),children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 max-w-full",children:[u,t.jsx(Xk,{displayName:C,hasPrompt:!!r,expanded:x,onToggle:()=>b(A=>!A)}),p]}),N&&t.jsxs("div",{className:i?"relative min-w-0 max-w-full":"relative",ref:j,children:[t.jsxs("button",{ref:_,"data-testid":"step-indicator-step",onClick:()=>f(A=>!A),className:`flex items-center gap-1.5 cursor-pointer transition-colors ${i?"text-[11.5px] min-w-0 max-w-full":""}`,style:{color:i?"var(--text-muted)":"var(--text-secondary)"},children:[!i&&t.jsx("span",{style:{color:"var(--text-dim)"},children:"::"}),i?t.jsxs("span",{className:"truncate",children:["Step ",k,"/",R,": ",O]}):t.jsxs("span",{children:[L," ",k,t.jsxs("span",{style:{color:"var(--text-dim)"},children:[" / ",R]}),": ",O,z&&t.jsxs("span",{style:{color:"var(--text-dim)",opacity:.7},children:[" ","(",z,")"]})]}),t.jsx(Zk,{label:I}),t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`transition-transform ${h?"rotate-180":""}`,children:t.jsx("path",{d:"M2 4l3 3 3-3"})})]}),h&&y&&us.createPortal(t.jsx("div",{ref:S,className:"w-96 rounded-lg shadow-lg py-1 text-xs max-h-[70vh] overflow-y-auto",style:{position:"fixed",top:y.top,...i?{left:y.left}:{right:y.right},zIndex:60,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:Array.from({length:R},(A,B)=>B+1).map(A=>{const B=m===A;return t.jsx(e1,{currentStep:k,isExpanded:B,mode:T,onToggle:()=>g(B?null:A),stepNum:A},A)})}),document.body)]})]}),x&&r&&t.jsx("div",{className:i?"absolute left-0 top-full z-30 mt-1 w-[min(560px,80vw)]":void 0,children:t.jsx(Qk,{prompt:r})})]})}const Vte=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorBar:jc},Symbol.toStringTag,{value:"Module"}));function t1({awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,isActive:s,onAgentIdle:r,onAgentBlocked:a,onAgentActive:o,onUserInput:i,provider:c,onRestorePreview:d,pendingPlans:u,pendingPlansLoading:p,pendingPlansError:h,onLaunchPlan:f,launchingSlug:m,launchError:g,onReorderPlans:x,isAgentBuilding:b,featureCompleteActive:y,buildActivity:v,chatEscalatedToPrototype:j,onActivityDone:_,onPrototypeLaunched:S,prototypeLaunchSignal:w}){const{stepState:k}=ca(),{loading:N}=Pt(),{prompt:C}=C6(),{sessionInfo:T,loading:P}=vp(),R=si(),{sessionDecision:L,handleContinueSession:M}=M6({sessionLoading:P,sessionInfo:T,requestAttachLive:I6(R,T)}),O=D6(R,T);$6(s),F6({sessionLoading:P,sessionInfo:T,onRestorePreview:d}),z6((k==null?void 0:k.feature)??null);const[z,I]=l.useState(null),Y=(R==null?void 0:R.state)==="interrupted"&&z!==R.id&&!Nb(R.id),W={step:(k==null?void 0:k.step)??0,hideStep:v==="prototype"||v==="chat",feature:(k==null?void 0:k.feature)??null,mode:(k==null?void 0:k.mode)??"ui",userPrompt:C,slug:(k==null?void 0:k.slug)??null,slugVisits:k==null?void 0:k.slugVisits},A=!W.hideStep&&W.step>0?{step:W.step,total:N0(W.step,W.mode).totalSteps,mode:W.mode}:null;return t.jsx(FS,{workflow:A,title:B=>t.jsx(jc,{...W,inline:!0,namePrefix:B.mark,nameSuffix:B.label,note:B.note}),children:B=>t.jsx(NS,{stepIndicator:B?null:t.jsx("div",{"data-testid":"build-tab-session-header",className:"shrink-0",style:{padding:`8px ${cn}px`,...ra("bottom")},children:t.jsx(jc,{...W,inline:!0})}),sessionContent:Y&&R?t.jsx(Kt,{testId:"build-interrupted-recovery",children:t.jsx("div",{className:"mx-auto max-w-2xl px-5 py-10",children:t.jsx(Fd,{request:R,onRecovered:()=>I(R.id),onKeptForLater:()=>I(R.id)})})}):t.jsx(Kk,{awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,configLoading:N,sessionLoading:P,sessionDecision:L,sessionInfo:T,stepState:k,provider:c,onContinueSession:M,onAgentIdle:r,onAgentBlocked:a,onAgentActive:o,onUserInput:i,pendingPlans:u,pendingPlansLoading:p,pendingPlansError:h,onLaunchPlan:f,launchingSlug:m,launchError:g,onReorderPlans:x,isAgentBuilding:b,featureCompleteActive:y,buildActivity:v,chatEscalatedToPrototype:j,onActivityDone:_,onPrototypeLaunched:S,prototypeLaunchSignal:w,connectionPhase:O})})})}const Kte=Object.freeze(Object.defineProperty({__proto__:null,BuildTab:t1},Symbol.toStringTag,{value:"Module"}));function n1({refreshing:e,onRefresh:n,onClose:s,minimizeMode:r=!1}){return t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx("button",{onClick:s,className:"text-[var(--text-primary)] hover:text-[#D7FF63] text-lg leading-none px-1 -ml-1",title:"Minimize results panel",children:"▾"}),t.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Working Session Results"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:n,disabled:e,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:e?"…":"↻"}),!r&&t.jsx("button",{onClick:s,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-lg leading-none px-1",title:"Close results panel",children:"✕"})]})]})}const Jte=Object.freeze(Object.defineProperty({__proto__:null,SessionResultsPanelHeader:n1},Symbol.toStringTag,{value:"Module"}));function s1({scenarios:e,selectedSlug:n,onSelect:s}){if(e.length===0)return t.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"No screens changed in this session"});const r=e.findIndex(i=>i.slug===n),a=i=>{const c=r<0?i===1?-1:0:r,d=e[(c+i+e.length)%e.length];s(d.slug,d.url)},o=r>=0?e[r]:null;return t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"sticky -top-4 z-10 -mt-4 flex min-w-0 items-center gap-2 bg-[var(--bg-deep)] pt-4 pb-2 shadow-[0_10px_10px_-10px_rgba(0,0,0,.8)]",children:[t.jsx(wc,{label:"Previous screen",glyph:"‹",onClick:()=>a(-1)}),t.jsx("span",{"data-testid":"session-results-counter",className:"shrink-0 text-xs tabular-nums text-[var(--text-secondary)]",children:o?`${r+1} of ${e.length}`:`${e.length} screens`}),t.jsx(wc,{label:"Next screen",glyph:"›",onClick:()=>a(1)}),o&&t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--text-primary)]",children:o.name})]}),t.jsx("div",{className:"flex flex-wrap items-start gap-2.5",children:e.map(i=>t.jsx(r1,{scenario:i,selected:i.slug===n,onSelect:s},i.slug))})]})}function wc({label:e,glyph:n,onClick:s}){return t.jsx("button",{type:"button","aria-label":e,title:e,onClick:s,className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-[var(--border-default)] text-base leading-none text-[var(--text-secondary)] cursor-pointer transition-colors hover:border-[var(--accent-active)] hover:text-[var(--accent-active)]",children:t.jsx("span",{"aria-hidden":"true",children:n})})}function r1({scenario:e,selected:n,onSelect:s}){return t.jsxs("button",{type:"button","data-testid":"session-results-shot","aria-pressed":n,title:e.name,onClick:()=>s(e.slug,e.url),className:"group flex w-[150px] shrink-0 cursor-pointer flex-col gap-1 text-left",children:[t.jsx("span",{className:`flex h-[100px] w-[150px] items-center justify-center overflow-hidden rounded bg-[var(--bg-surface)] transition-colors ${n?"border-2 border-[var(--accent-active)]":"border border-[var(--border-default)] group-hover:border-[var(--text-muted)]"}`,children:e.screenshotPaths.length>0?t.jsx(Ot,{screenshotPath:e.screenshotPaths[0],cacheBuster:e.screenshotCapturedAtMs??void 0,alt:e.name,loading:"lazy"}):t.jsx("span",{className:"px-2 text-center text-[10px] leading-tight text-[var(--text-muted)]",children:H6(e)})}),t.jsx("span",{className:`w-full truncate text-[11px] ${n?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:e.name})]})}function H6(e){var n;return e.coverageStatus==="needs-isolated-scenario"?"needs isolated scenario":e.coverageStatus==="reason"?((n=e.untestabilityReason)==null?void 0:n.kind)??"test-backed":"no screenshot yet"}const Xte=Object.freeze(Object.defineProperty({__proto__:null,ArrowButton:wc,GalleryTile:r1,SessionResultsGallery:s1},Symbol.toStringTag,{value:"Module"}));function wp({fn:e,testid:n}){return t.jsxs("div",{className:"flex items-start gap-2","data-testid":n,children:[t.jsx("span",{className:"text-[10px] text-[var(--text-muted)] mt-0.5 shrink-0",children:"fn"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs font-medium text-[var(--text-primary)]",children:e.name}),e.description&&t.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:e.description}),t.jsx("div",{className:"text-[10px] text-[var(--text-muted)] font-mono mt-0.5",children:e.filePath})]})]})}const Qte=Object.freeze(Object.defineProperty({__proto__:null,FunctionChangeRow:wp},Symbol.toStringTag,{value:"Module"}));function _p(e){return e==null?"":typeof e=="string"?e:typeof e=="object"&&typeof e.name=="string"?e.name:String(e)}function q6(e){if(e!=null&&typeof e=="object"){const{description:n}=e;if(typeof n=="string"&&n.trim()!=="")return n}}function a1({userPrompt:e,functions:n,files:s}){const[r,a]=l.useState(!1);if(!e&&n.length===0&&s.length===0)return null;const o=[n.length>0&&fm(n.length,"function"),s.length>0&&fm(s.length,"file")].filter(Boolean);return t.jsxs("div",{className:"border-t border-[var(--border-subtle)] pt-3",children:[t.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(i=>!i),className:"flex items-center gap-1.5 text-[11px] text-[var(--text-muted)] cursor-pointer hover:text-[var(--text-secondary)]",children:[t.jsx("span",{"aria-hidden":"true",children:r?"▾":"▸"}),t.jsxs("span",{children:["Details",o.length>0?` · ${o.join(" · ")}`:""]})]}),r&&t.jsxs("div",{className:"mt-3 flex flex-col gap-4",children:[e&&t.jsx(o1,{text:e}),n.length>0&&t.jsx(_c,{title:"Functions",children:t.jsx(i1,{functions:n})}),s.length>0&&t.jsx(_c,{title:"Files",children:t.jsx(l1,{files:s})})]})]})}function _c({title:e,children:n}){return t.jsxs("div",{children:[t.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:e}),n]})}function fm(e,n){return`${e} ${n}${e===1?"":"s"}`}function o1({text:e}){const[n,s]=l.useState(!1),r=e.split(`
|
|
91
|
-
`)[0],a=e.includes(`
|
|
92
|
-
`)||e.length>120;return t.jsxs("div",{className:"px-1",children:[t.jsx("div",{className:"text-[10px] font-semibold text-[var(--text-muted)] uppercase tracking-wide mb-1",children:"User Request"}),n?t.jsxs("div",{children:[t.jsx(Lt,{variant:"compact",children:e}),a&&t.jsx("button",{onClick:()=>s(!1),className:"text-[#D7FF63] hover:underline text-xs mt-1",children:"Show less"})]}):t.jsxs("div",{className:"text-xs text-[var(--text-secondary)] leading-relaxed",children:[r.slice(0,120),a&&t.jsx("button",{onClick:()=>s(!0),className:"text-[#D7FF63] hover:underline ml-1 text-xs",children:"Read more..."})]})]})}function i1({functions:e}){return t.jsx("div",{className:"divide-y divide-[var(--border-subtle)]",children:e.map(n=>t.jsxs("div",{className:"px-1 py-2",children:[t.jsx(wp,{fn:n}),n.tests.length>0&&t.jsx("div",{className:"ml-5 mt-1.5 space-y-0.5",children:n.tests.map((s,r)=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-green-500 text-[10px]",children:"✓"}),t.jsx("span",{className:"text-[10px] text-[var(--text-secondary)]",children:_p(s)})]},r))}),n.testFile&&n.tests.length===0&&t.jsx("div",{className:"ml-5 mt-1 text-[10px] text-[var(--text-muted)] font-mono",children:n.testFile})]},`${n.filePath}::${n.name}`))})}function l1({files:e}){return t.jsx("div",{className:"divide-y divide-[var(--border-subtle)]",children:e.map(n=>t.jsxs("div",{className:"px-1 py-1.5 flex items-center gap-2",children:[t.jsx(Ro,{status:n.status}),t.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono truncate",children:n.path})]},n.path))})}const Zte=Object.freeze(Object.defineProperty({__proto__:null,DetailsGroup:_c,FilesList:l1,FunctionsList:i1,SessionResultsDetails:a1,UserPrompt:o1},Symbol.toStringTag,{value:"Module"}));function mr(e,n){if(e.length===0)return{selectedIndex:-1,scenario:null};if("direction"in n){const r=n.direction==="next"?1:-1,a=(n.selectedIndex+r+e.length)%e.length;return{selectedIndex:a,scenario:e[a]}}if("slug"in n){const r=e.findIndex(a=>a.slug===n.slug);return r>=0?{selectedIndex:r,scenario:e[r]}:mr(e,{defaultSelection:!0,selectedIndex:n.selectedIndex})}const s=Math.min(n.selectedIndex??0,e.length-1);return{selectedIndex:s,scenario:e[s]}}function vo(e,n){if(!n)return{headline:e,collapsed:[]};const s=[],r=[];for(const a of e)a.demonstratesNew?s.push(a):r.push(a);return{headline:s,collapsed:r}}const U6="no-isolation-harness";function c1(e){var n;return e.coverageStatus==="reason"&&((n=e.untestabilityReason)==null?void 0:n.kind)===U6}const G6="/api/editor-session-summary",Y6=3e3;function d1(e=Y6){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(G6);d.ok&&s(await d.json())}catch{}i(!1),a(!1)},[]);return l.useEffect(()=>{c()},[c]),l.useEffect(()=>{if(e<=0)return;const d=window.setInterval(c,e);return()=>window.clearInterval(d)},[c,e]),{summary:n,loading:r,refreshing:o,refresh:c}}function u1({onClose:e,onSelectScenario:n,previewSlug:s=null,minimizeMode:r=!1}){var w;const{summary:a,loading:o,refreshing:i,refresh:c}=d1(),[d,u]=l.useState(0),p=l.useMemo(()=>a?[...a.application,...a.components]:[],[a]),h=l.useMemo(()=>s&&p.some(k=>k.slug===s)?s:null,[p,s]),f=h??((w=p[d])==null?void 0:w.slug);l.useEffect(()=>{if(!h)return;const k=p.findIndex(N=>N.slug===h);k>=0&&k!==d&&u(k)},[p,h,d]);const m=l.useCallback(k=>{p.length!==0&&(document.activeElement instanceof HTMLIFrameElement||VR()||(k.key==="ArrowRight"?(k.preventDefault(),u(N=>{const C=mr(p,{direction:"next",selectedIndex:N});return C.scenario&&(n==null||n(C.scenario.slug,C.scenario.url)),C.selectedIndex})):k.key==="ArrowLeft"&&(k.preventDefault(),u(N=>{const C=mr(p,{direction:"previous",selectedIndex:N});return C.scenario&&(n==null||n(C.scenario.slug,C.scenario.url)),C.selectedIndex}))))},[p,n]);l.useEffect(()=>(window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)),[m]);const g=l.useRef(!1);if(l.useEffect(()=>{if(g.current||p.length===0)return;g.current=!0;const k=mr(p,{defaultSelection:!0,selectedIndex:d});k.scenario&&(n==null||n(k.scenario.slug,k.scenario.url))},[p,n,d]),o)return t.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:t.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!a)return t.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:t.jsx("div",{className:"text-sm text-[var(--text-muted)]",children:"No session data available."})});const x=a.hubDominated??!1,b=vo(a.application,x),y=vo(a.components,x),v=[...b.headline,...y.headline],j=[...b.collapsed,...y.collapsed],_=v.some(c1),S=(k,N)=>{var T,P;const C=mr(p,{slug:k,selectedIndex:d});C.selectedIndex>=0&&u(C.selectedIndex),n==null||n(((T=C.scenario)==null?void 0:T.slug)??k,((P=C.scenario)==null?void 0:P.url)??N)};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-[var(--bg-deep)]",style:{borderTop:"2px solid #005c75"},children:[t.jsx(n1,{refreshing:i,onRefresh:c,onClose:e,minimizeMode:r}),t.jsxs("div",{className:"flex-1 overflow-auto p-4 flex flex-col gap-4",children:[v.length===0&&j.length>0?t.jsx(bb,{sectionTitle:"screens",headlineCount:0,refreshedCount:j.length}):t.jsx(s1,{scenarios:v,selectedSlug:f,onSelect:S}),_&&t.jsx("div",{className:"text-[10px] leading-snug text-[var(--text-muted)]",children:"This stack has no component isolation harness, so leaf components are verified inside the full app scenarios rather than in isolation."}),t.jsx(Mx,{count:a.generatedGlueCount??0}),t.jsx(h1,{scenarios:j,selectedSlug:f,onSelect:S}),t.jsx(a1,{userPrompt:a.userPrompt,functions:a.functions,files:a.modifiedFiles})]})]})}function p1({scenarios:e,selectedSlug:n,onSelect:s}){return t.jsx("div",{className:"overflow-x-auto",children:t.jsx("div",{className:"flex gap-2",style:{minWidth:"min-content"},children:e.map(r=>t.jsx(f1,{scenario:r,isSelected:r.slug===n,onSelect:s},r.slug))})})}function h1({scenarios:e,selectedSlug:n,onSelect:s}){const[r,a]=l.useState(!1);return e.length===0?null:t.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]",children:[t.jsxs("button",{onClick:()=>a(o=>!o),className:"text-[11px] text-[var(--text-muted)] hover:text-[var(--text-secondary)] flex items-center gap-1",children:[t.jsx("span",{children:r?"▾":"▸"}),t.jsxs("span",{children:["Also refreshed (",e.length,") — impacted by hub-file changes, not demonstrating this work"]})]}),r&&t.jsx("div",{className:"mt-2",children:t.jsx(p1,{scenarios:e,selectedSlug:n,onSelect:s})})]})}function f1({scenario:e,isSelected:n,onSelect:s}){var o;const r=e.name.replace(/\s*\[.*\]\s*$/,"").trim(),a=c1(e);return t.jsxs("div",{className:"shrink-0 cursor-pointer group",onClick:()=>s==null?void 0:s(e.slug,e.url),title:e.name,children:[t.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:e.screenshotPaths.length>0?t.jsx(Ot,{screenshotPath:e.screenshotPaths[0],cacheBuster:e.screenshotCapturedAtMs??void 0,alt:e.name}):e.coverageStatus==="needs-isolated-scenario"?t.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:[t.jsx("span",{className:"text-amber-500 text-lg leading-none",children:"⚠"}),t.jsx("span",{className:"text-[8px] leading-tight text-amber-700",children:"needs isolated scenario"})]}):e.coverageStatus==="reason"?t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:e.untestabilityReason?`${e.untestabilityReason.kind}: ${e.untestabilityReason.justification}`:"Covered by a recorded untestability reason.",children:[t.jsx("span",{className:"text-[var(--text-muted)] text-lg leading-none",children:"🧪"}),t.jsx("span",{className:"text-[8px] leading-tight text-[var(--text-muted)]",children:((o=e.untestabilityReason)==null?void 0:o.kind)??"test-backed"})]}):t.jsx("div",{className:"w-full h-full flex items-center justify-center text-[var(--text-muted)] text-lg",children:"📷"})}),t.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&&t.jsx("div",{className:"mt-0.5 w-24 text-[9px] leading-tight text-[var(--text-muted)]",children:"Covered via app scenarios — no isolation harness"})]})}const ene=Object.freeze(Object.defineProperty({__proto__:null,CollapsedImpactedScenarios:h1,ScenarioThumbnail:f1,ScenarioThumbnailStrip:p1,SessionResultsPanel:u1},Symbol.toStringTag,{value:"Module"})),m1=62;function g1({onExpand:e}){const{summary:n}=d1(),s=(n==null?void 0:n.hubDominated)??!1,r=vo((n==null?void 0:n.application)??[],s),a=vo((n==null?void 0:n.components)??[],s),o=[...r.headline,...a.headline],i=o.length,c=r.collapsed.length+a.collapsed.length,d=o.filter(u=>u.screenshotPaths.length>0);return t.jsxs("button",{type:"button",onClick:e,onWheel:u=>{u.deltaY>0&&e()},title:"Expand working session results",className:"group shrink-0 w-full flex flex-col gap-2.5 px-4 py-3 text-left bg-[var(--bg-card)] hover:bg-[var(--bg-input)] transition-colors",style:{borderTop:"2px solid #005c75"},children:[t.jsxs("span",{className:"flex w-full items-center gap-2",children:[t.jsx("span",{"data-testid":"minimized-results-chevron",className:"text-[var(--text-primary)] group-hover:text-[#D7FF63] text-lg leading-none px-1 -ml-1 transition-colors",children:"▴"}),t.jsx("span",{className:"text-[13px] font-semibold text-[var(--text-primary)]",children:"Working Session Results"}),t.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:[i," new",c>0?` · ${c} impacted`:""]}),t.jsx("span",{"data-testid":"minimized-results-open",className:"ml-auto text-xs font-medium px-2.5 py-1 rounded border border-[var(--border-default)] text-[var(--text-primary)] group-hover:border-[#D7FF63] group-hover:text-[#D7FF63] transition-colors",children:"View results"})]}),d.length>0&&t.jsx("span",{"data-testid":"minimized-results-peek",onScroll:e,className:"flex w-full flex-wrap items-start gap-2.5 overflow-x-hidden overflow-y-auto",style:{maxHeight:m1},children:d.map(u=>t.jsxs("span",{title:u.name,className:"flex w-[150px] shrink-0 flex-col gap-1",children:[t.jsx("span",{className:"flex h-[100px] w-[150px] items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:t.jsx(Ot,{screenshotPath:u.screenshotPaths[0],cacheBuster:u.screenshotCapturedAtMs??void 0,alt:u.name})}),t.jsx("span",{className:"w-full truncate text-[11px] text-[var(--text-secondary)]",children:u.name})]},u.slug))})]})}const tne=Object.freeze(Object.defineProperty({__proto__:null,MINIMIZED_RESULTS_PEEK_HEIGHT:m1,MinimizedSessionResults:g1},Symbol.toStringTag,{value:"Module"}));function V6(e,n){return(e==null?void 0:e.mode)!=="ui"?!1:(e==null?void 0:e.slug)==="feature-complete"||!!n}const K6=new Set(["ui-present","backend-present"]);function x1(e){return!!(e!=null&&e.slug)&&K6.has(e.slug)}function J6({stepState:e,resultsShown:n,featureCompleteActive:s,userExpanded:r}){return s?"hidden":x1(e)?(e==null?void 0:e.mode)==="ui"?"full":"hidden":V6(e,n)?r?"full":"minimized":"hidden"}function b1({awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,buildActivated:s,activeTab:r,onSelectScenario:a,previewSlug:o=null,showResultsCommandKey:i,hideResultsCommandKey:c,onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:w,buildActivity:k,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}){const{stepState:R}=ca(),{sessionInfo:L}=vp({pollIntervalMs:15e3}),M=si(),O=y0(M),[z,I]=l.useState(!1),[Y,W]=l.useState(!1),[A,B]=l.useState(0),D=(L==null?void 0:L.resultsShown)??!1;l.useEffect(()=>{D||(W(!1),I(!1))},[D]),l.useEffect(()=>{i&&(W(!1),I(!0),B(le=>le+1))},[i]),l.useEffect(()=>{c&&I(!1)},[c]);const J=x1(R),te=J6({stepState:R,resultsShown:D,featureCompleteActive:w,userExpanded:z}),oe=J&&Y?"hidden":te,se=l.useCallback(()=>{J?W(!0):I(!1)},[J]),G=l.useCallback(()=>{I(!0),B(le=>le+1)},[]);return s?t.jsx(CS,{activeTab:r,resultsMode:oe,badgeGutter:k!=="prototype"&&k!=="chat",launchBanner:M&&Ad(M.state)?t.jsx(Md,{state:M.state,cause:M.failureReason??null,...O}):null,buildTab:t.jsx(t1,{awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,isActive:r==="build",onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:w,buildActivity:k,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}),resultsPanel:t.jsx(u1,{onClose:se,onSelectScenario:a,previewSlug:o,minimizeMode:!J},A),minimizedResults:t.jsx(g1,{onExpand:G})}):null}const nne=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPane:b1},Symbol.toStringTag,{value:"Module"}));function y1({name:e,size:n=13}){const s={width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},r=e.toLowerCase(),a=r.includes("landscape"),o=r.includes("iphone"),i=r.includes("ipad");return r.includes("laptop")?t.jsxs("svg",{...s,children:[t.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),t.jsx("path",{d:"M2 18h20"})]}):r.includes("desktop")||r.includes("monitor")?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),t.jsx("path",{d:"M8 21h8M12 17v4"})]}):r.includes("tablet")||r.includes("ipad")?a?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),i?t.jsx("path",{d:"M5 12h.01"}):t.jsx("path",{d:"M18 12h.01"})]}):t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),i?t.jsx("path",{d:"M12 5h.01"}):t.jsx("path",{d:"M12 18h.01"})]}):r.includes("phone")||r.includes("iphone")||r.includes("mobile")?a?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"2",y:"7",width:"20",height:"10",rx:o?3:2}),o?t.jsx("path",{d:"M5 9.5v5"}):t.jsx("path",{d:"M18 12h.01"})]}):t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:o?3:2}),o?t.jsx("path",{d:"M10 4.5h4"}):t.jsx("path",{d:"M12 18h.01"})]}):t.jsx("span",{className:"text-xs",children:e})}const sne=Object.freeze(Object.defineProperty({__proto__:null,DeviceIcon:y1},Symbol.toStringTag,{value:"Module"})),Sp=js(),kp=js(),X6=Sp.get,Q6=Sp.set,Z6=Sp.subscribe,eB=kp.get,tB=kp.set,nB=kp.subscribe,Np=js(),Cp=js(),sB=Np.get,mm=Np.set,rB=Np.subscribe,aB=Cp.get,gm=Cp.set,oB=Cp.subscribe;function Nr({testId:e="nav-build-dot-active",ariaLabel:n="Build in progress"}={}){return t.jsx("span",{role:"img","data-testid":e,"aria-label":n,className:"mr-1.5 inline-flex items-center text-[var(--working)]",children:t.jsx(Wt,{size:10})})}const rne=Object.freeze(Object.defineProperty({__proto__:null,BuildSpinner:Nr},Symbol.toStringTag,{value:"Module"}));function v1({size:e=16}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 8v3"}),t.jsx("path",{d:"M12 14v.01"}),t.jsx("path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3h-5l-5 3v-3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z"})]})}const ane=Object.freeze(Object.defineProperty({__proto__:null,FeedbackIcon:v1},Symbol.toStringTag,{value:"Module"}));function j1({size:e=16}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.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 one=Object.freeze(Object.defineProperty({__proto__:null,GearIcon:j1},Symbol.toStringTag,{value:"Module"}));function w1({onNavigateToBuild:e,onDismiss:n,providerLabel:s}){return l.useEffect(()=>(me("banner-mounted",{}),()=>{me("banner-unmounted",{})}),[]),t.jsx("div",{className:"px-4 py-1.5 flex items-center justify-center",children:t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 px-3 py-1.5 rounded-lg border border-[#FF8B43]/60 bg-[#2a1500] shadow-lg shrink-0",children:[t.jsxs("button",{type:"button",onClick:e,className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#FF8B43] shrink-0"}),t.jsxs("span",{className:"text-sm text-[#FF8B43]",children:[s," is ",no,"."," ",t.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]}),t.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:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const ine=Object.freeze(Object.defineProperty({__proto__:null,IdleBanner:w1},Symbol.toStringTag,{value:"Module"}));function _1(e){return e.sound!=="off"}function iB(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function S1({settings:e,onChange:n,needsYou:s=!1,onGoToAgent:r,agentName:a,providerLabel:o}){const[i,c]=l.useState(!1),d=l.useRef(null),u=_1(e);l.useEffect(()=>{if(!i)return;const h=f=>{d.current&&!d.current.contains(f.target)&&c(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]);const p=u?s?`Notifications: ${o} is ${no}`:"Notifications":"Turn on notification sound";return t.jsxs("div",{className:"relative",ref:d,children:[t.jsxs("button",{type:"button","aria-label":p,"aria-pressed":u,"data-testid":"nav-notifications",onClick:()=>{if(iB(),!u){n({...e,sound:hr.sound});return}c(h=>!h)},className:`relative p-1.5 rounded-md transition-colors cursor-pointer inline-flex items-center hover:text-white ${u?"text-[#8E8E8E]":"text-[#5A5A5A]"}`,children:[t.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3H4a4 4 0 0 0 2-3v-3a7 7 0 0 1 4-6"}),t.jsx("path",{d:"M9 17v1a3 3 0 0 0 6 0v-1"}),!u&&t.jsx("path",{"data-testid":"nav-notifications-slash",d:"M3 3l18 18"})]}),s&&t.jsx("span",{"data-testid":"nav-notifications-dot","aria-hidden":"true",className:"absolute top-1 right-1 h-2 w-2 rounded-full ring-2 ring-[var(--bg-deep)]",style:{background:ht}})]}),i&&t.jsxs("div",{className:"absolute top-full right-0 mt-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:[s&&t.jsxs("button",{type:"button","data-testid":"nav-notifications-waiting",onClick:()=>{c(!1),r==null||r()},className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-[12px] cursor-pointer transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-primary)",border:`1px solid ${ht}55`},children:[t.jsx("span",{"aria-hidden":"true",className:"h-2 w-2 shrink-0 rounded-full",style:{background:ht}}),t.jsxs("span",{className:"flex-1",children:[o," is ",no]}),t.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-muted)"},children:"→"})]}),t.jsx(l0,{settings:e,onChange:n,providerLabel:o,soundAsSubmenu:!0}),t.jsx("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:t.jsx(p0,{agentName:a})})]})]})}const lne=Object.freeze(Object.defineProperty({__proto__:null,NotificationBell:S1,notificationsOn:_1},Symbol.toStringTag,{value:"Module"})),Oa=ht,lB=[{key:"home",label:"Home"},{key:"chat",label:"Chat"},{key:"plan",label:"Plan"},{key:"build",label:"Build"},{key:"history",label:"History"}];function ir(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.blur()}function k1({activeTab:e,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:p=!1,showLogo:h=!0,projectTitle:f=null,notifSettings:m,onNotifSettingsChange:g,agentName:x,providerLabel:b}){const y=d&&e!=="build",v=l.useSyncExternalStore(IS,MS),j=l.useSyncExternalStore(DS,ac),_=r&&a&&!j,S=r&&!a&&!j||v&&!_,w=(o||j)&&!S&&!_,k=S||_,N=w?"green":_?"amber-pulse":S?"orange":"none",C=l.useRef(N);l.useEffect(()=>{C.current!==N&&(me("build-tab-dot-change",{from:C.current,to:N}),C.current=N)},[N]);const T=l.useSyncExternalStore(Z6,X6),P=l.useSyncExternalStore(nB,eB),R=l.useSyncExternalStore(rB,sB),L=l.useSyncExternalStore(oB,aB),M=T||i&&!P,O=(c||P)&&!M,z=O?"green":M?"orange":"none",I=l.useRef(z);return l.useEffect(()=>{I.current!==z&&(me("plan-tab-dot-change",{from:I.current,to:z}),I.current=z)},[z]),t.jsxs("div",{className:"relative shrink-0",children:[t.jsxs("div",{className:"@container h-12 flex items-center px-[22px] gap-4 @max-[440px]:px-3 @max-[440px]:gap-2",style:ra("bottom"),children:[t.jsx("div",{className:"flex-1 basis-0 flex items-center min-w-0",children:h&&t.jsxs(yr,{href:jn("home"),"data-nav-tab":"true","data-testid":"nav-home","aria-label":f?`${f}: Home`:"Home","aria-current":e==="home"?"page":void 0,onNavigate:()=>{n("home"),ir()},className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-white hover:opacity-80 transition-opacity",children:[t.jsx(ms,{markOnly:!0,className:"h-5 text-white shrink-0"}),f&&t.jsx("span",{"data-testid":"nav-project-title",className:"text-sm truncate @max-[560px]:hidden",style:{color:e==="home"?"var(--text-primary)":"var(--text-secondary)"},children:f})]})}),t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:lB.map(Y=>Y.key==="build"&&p?t.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"),ir()},className:"px-2.5 @max-[520px]:px-1.5 py-2.5 text-sm text-[#5A5A5A] cursor-not-allowed font-light whitespace-nowrap",children:Y.label},Y.key):t.jsxs(yr,{href:jn(Y.key),"data-nav-tab":"true",onNavigate:()=>{n(Y.key),ir(),Y.key==="build"&&Tt()},className:`px-2.5 @max-[520px]:px-1.5 @max-[440px]:px-1 @max-[320px]:px-0.5 py-2.5 text-sm transition-colors cursor-pointer inline-flex items-center whitespace-nowrap ${Y.key==="home"&&h?"@max-[400px]:hidden ":""}${e===Y.key?"text-white font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[Y.key==="build"&&w&&t.jsx(Nr,{}),Y.key==="build"&&_&&t.jsx(ur,{color:Oa,testId:"nav-build-dot-blocked",title:"Waiting on you — the turn stopped on a prompt and won't continue until you answer",pulse:!0}),Y.key==="build"&&S&&t.jsx(ur,{color:Oa,testId:"nav-build-dot-idle",pulse:!0}),Y.key==="plan"&&O&&t.jsx(Nr,{testId:"nav-plan-dot-active",ariaLabel:"Planning in progress"}),Y.key==="plan"&&M&&t.jsx(ur,{color:Oa,testId:"nav-plan-dot-idle",pulse:!0}),Y.key==="chat"&&R&&!L&&t.jsx(Nr,{testId:"nav-chat-dot-active",ariaLabel:"Chat in progress"}),Y.key==="chat"&&L&&t.jsx(ur,{color:Oa,testId:"nav-chat-dot-idle",pulse:!0}),Y.label]},Y.key))}),t.jsxs("div",{className:"flex-1 basis-0 flex items-center justify-end gap-1",children:[m&&g&&t.jsx(S1,{settings:m,onChange:g,needsYou:k||M,onGoToAgent:()=>{n(k?"build":"plan"),ir()},agentName:x,providerLabel:b}),t.jsxs("button",{type:"button",onClick:s,"aria-label":"Send feedback","data-testid":"nav-send-feedback",className:"group relative p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white focus-visible:text-white inline-flex items-center @max-[400px]:hidden",children:[t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute right-full top-1/2 -translate-y-1/2 mr-1 rounded-md bg-black px-2 py-1 text-xs whitespace-nowrap text-white opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100",children:"Send feedback"}),t.jsx(v1,{})]}),t.jsx(yr,{href:jn("settings"),"data-nav-tab":"true",onNavigate:()=>{n("settings"),ir()},className:`p-1.5 rounded-md transition-colors cursor-pointer inline-flex items-center ${e==="settings"?"text-white":"text-[#8E8E8E] hover:text-white"}`,title:"Settings",children:t.jsx(j1,{})})]})]}),y&&t.jsx("div",{"data-testid":"idle-banner-float",className:"pointer-events-none absolute left-0 right-0 top-full z-40",children:t.jsx(w1,{onNavigateToBuild:()=>n("build"),onDismiss:u??(()=>{}),providerLabel:b})})]})}const cne=Object.freeze(Object.defineProperty({__proto__:null,EditorNavBar:k1},Symbol.toStringTag,{value:"Module"}));function N1({projectTitle:e}){const n=typeof e=="string"&&e.trim().length>0;return t.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:[t.jsx(ms,{className:"h-5 text-white shrink-0"}),n&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),t.jsx("span",{className:"text-white text-sm truncate max-w-[60%]",children:e})]})]})}const dne=Object.freeze(Object.defineProperty({__proto__:null,DesktopTitleBar:N1},Symbol.toStringTag,{value:"Module"}));function cB(){const[e,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:e,seed:s,lastAdHocRange:a,toggle:i,close:c,accept:d}}function dB(e,n=25){const[s,r]=l.useState([]);return l.useEffect(()=>{if(!e||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}},[e,s.length,n]),s}function Tp({target:e,onStored:n,onClose:s}){return t.jsx("div",{"data-testid":"app-service-credential-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onMouseDown:r=>{r.target===r.currentTarget&&s()},children:t.jsxs("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-[#3A3A3A] bg-[#161616] p-5 space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("h2",{className:"text-base font-semibold text-white",children:["Add your ",e.serviceName," API key"]}),t.jsx("button",{"data-testid":"app-service-credential-close",onClick:s,className:"text-[#8E8E8E] hover:text-white cursor-pointer","aria-label":"Close",children:"✕"})]}),t.jsx(Id,{envVar:e.envVar}),e.docsUrl?t.jsx(Dd,{href:e.docsUrl}):null,t.jsx(Ld,{target:e,onStored:n})]})})}const une=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialModal:Tp},Symbol.toStringTag,{value:"Module"}));function uB(e,n){for(const s of e.filesByDirectory)for(const r of s.files)if(r.filePath===n)return r;return null}function C1(e){return e>=80?"#16a34a":e>=50?"#eab308":"#dc2626"}function da({coverage:e}){const n=Math.max(0,Math.min(100,e.percent)),s=C1(n);return t.jsxs("div",{className:"flex items-center gap-2 min-w-[140px]","data-testid":"coverage-bar",children:[t.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:t.jsx("div",{"data-testid":"coverage-bar-fill",className:"h-full rounded-full",style:{width:`${n}%`,backgroundColor:s}})}),t.jsxs("span",{className:"text-xs font-mono tabular-nums",style:{color:s},children:[Math.round(n),"%"]})]})}const pne=Object.freeze(Object.defineProperty({__proto__:null,CoverageBar:da},Symbol.toStringTag,{value:"Module"}));function T1({file:e,onSelectFile:n}){return t.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-directory-file-row",children:[t.jsx("button",{type:"button",onClick:()=>n(e),className:"flex-1 min-w-0 text-left text-xs text-gray-700 truncate hover:underline cursor-pointer",children:e.filePath}),t.jsx(da,{coverage:e.coverage})]})}const hne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryFileRow:T1},Symbol.toStringTag,{value:"Module"}));function P1({group:e,onSelectFile:n}){return t.jsxs("details",{"data-testid":"coverage-details-directory-group",children:[t.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-gray-800",children:[e.directory||"(root)"," ·"," ",t.jsxs("span",{className:"text-gray-500",children:[e.files.length," file",e.files.length===1?"":"s"]})]}),t.jsx("ul",{className:"divide-y divide-gray-100 mt-2",children:e.files.map(s=>t.jsx(T1,{file:s,onSelectFile:n},s.filePath))})]})}const fne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryGroup:P1},Symbol.toStringTag,{value:"Module"}));function O1({directories:e,onSelectFile:n}){return e.length===0?null:t.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-directories-section",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By directory"}),t.jsx("div",{className:"flex flex-col gap-3",children:e.map(s=>t.jsx(P1,{group:s,onSelectFile:n},s.directory||"(root)"))})]})}const mne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoriesSection:O1},Symbol.toStringTag,{value:"Module"}));function R1({entry:e,onSelectFile:n}){return t.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-entry-row",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{type:"button",onClick:()=>n(e.filePath),className:"text-sm font-medium text-gray-900 truncate text-left hover:underline cursor-pointer",children:e.name}),t.jsx("div",{className:"text-xs text-gray-500 truncate",children:e.filePath}),e.linkedTests.length>0&&t.jsxs("div",{className:"text-xs text-gray-400 truncate",children:[e.linkedTests.length," linked test",e.linkedTests.length===1?"":"s"]})]}),t.jsx(da,{coverage:{percent:e.percent,hitLines:e.hitLines,totalLines:e.totalLines}})]})}const gne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntryRow:R1},Symbol.toStringTag,{value:"Module"}));function E1({entries:e,onSelectFile:n}){return t.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-entries-section",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By glossary entry"}),e.length===0?t.jsx("p",{className:"text-xs text-gray-500","data-testid":"coverage-details-entries-empty",children:"No glossary entries have coverage data yet."}):t.jsx("ul",{className:"divide-y divide-gray-100",children:e.map(s=>t.jsx(R1,{entry:s,onSelectFile:n},`${s.filePath}::${s.name}`))})]})}const xne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntriesSection:E1},Symbol.toStringTag,{value:"Module"}));function A1({file:e}){return t.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"orphaned-file-row",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("div",{className:"text-xs text-gray-500 truncate",children:e.filePath})}),t.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"}),t.jsx(da,{coverage:e.coverage})]})}const bne=Object.freeze(Object.defineProperty({__proto__:null,OrphanedFileRow:A1},Symbol.toStringTag,{value:"Module"}));function M1({files:e,onSelectFile:n}){return e.length===0?null:t.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-orphaned-section",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"Orphaned files"}),t.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:[e.length," file",e.length===1?"":"s"," with coverage but no glossary entry."]}),t.jsx("ul",{className:"divide-y divide-gray-100",children:e.map(s=>t.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:t.jsx(A1,{file:s})},s.filePath))})]})}const yne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsOrphanedSection:M1},Symbol.toStringTag,{value:"Module"}));function I1({line:e,hits:n}){const s=n>0;return t.jsxs("li",{className:"flex items-center gap-3 py-1 font-mono text-xs","data-testid":s?"coverage-line-hit":"coverage-line-miss",children:[t.jsx("span",{className:"w-12 text-right text-gray-400",children:e}),t.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 vne=Object.freeze(Object.defineProperty({__proto__:null,CoverageLineRow:I1},Symbol.toStringTag,{value:"Module"}));function D1({file:e,onBack:n}){const s=Object.entries(e.lines).map(([r,a])=>({line:Number(r),hits:a})).sort((r,a)=>r.line-a.line);return t.jsxs("div",{"data-testid":"coverage-file-drilldown",className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.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"}),t.jsx("div",{className:"text-sm font-medium text-gray-900 truncate mt-1",children:e.filePath})]}),t.jsx(da,{coverage:e.coverage})]}),s.length===0?t.jsx("p",{className:"text-xs text-gray-500",children:"No instrumented lines in this file."}):t.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})=>t.jsx(I1,{line:r,hits:a},r))})]})}const jne=Object.freeze(Object.defineProperty({__proto__:null,CoverageFileDrilldown:D1},Symbol.toStringTag,{value:"Module"}));function L1({title:e,aggregate:n,aggregateTestId:s}){return t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-900 m-0",children:e}),n&&n.totalLines>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[n.hitLines,"/",n.totalLines," lines"]}),t.jsxs("span",{className:"text-xs font-semibold",style:{color:C1(n.percent)},"data-testid":s,children:[Math.round(n.percent),"% overall"]})]})]})}const wne=Object.freeze(Object.defineProperty({__proto__:null,CoverageSectionHeader:L1},Symbol.toStringTag,{value:"Module"}));function $1({warnings:e}){return e.length===0?null:t.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"coverage-warnings-banner",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-amber-800 m-0",children:"Coverage Warnings"}),t.jsx(mt,{variant:"subtle",text:e.join(`
|
|
93
|
-
`),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"})]}),t.jsx("ul",{className:"mt-1 space-y-1 text-sm text-amber-700 list-none p-0 m-0",children:e.map((n,s)=>t.jsx("li",{className:"break-words",children:n},s))})]})]})})}const _ne=Object.freeze(Object.defineProperty({__proto__:null,CoverageWarningsBanner:$1},Symbol.toStringTag,{value:"Module"}));function F1({onClose:e,fetchDetails:n=pB,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 h=!1;return n().then(f=>{h||a(f)}).catch(f=>{h||i(f instanceof Error?f.message:String(f))}),()=>{h=!0}},[n,s]);const u=l.useCallback(h=>{h.key==="Escape"&&(h.preventDefault(),c?d(null):e())},[e,c]);l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]);const p=h=>{if(!r)return;const f=uB(r,h);f&&d(f)};return t.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:e,children:t.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:h=>h.stopPropagation(),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:"Project coverage"}),t.jsx("button",{type:"button",onClick:e,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&&t.jsx(dt,{testId:"coverage-details-modal-error",text:`Failed to load coverage details: ${o}`,className:"text-sm text-red-700"}),!r&&!o&&t.jsx("p",{className:"text-sm text-[var(--text-muted)]","data-testid":"coverage-details-modal-loading",children:"Loading coverage details…"}),r&&c&&t.jsx(D1,{file:c,onBack:()=>d(null)}),r&&!c&&t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx(L1,{title:"Overall",aggregate:r.projectWide,aggregateTestId:"coverage-details-modal-aggregate"}),r.coverageWarnings.length>0&&t.jsx($1,{warnings:r.coverageWarnings}),t.jsx(E1,{entries:r.entries,onSelectFile:p}),t.jsx(M1,{files:r.orphanedFiles,onSelectFile:p}),t.jsx(O1,{directories:r.filesByDirectory,onSelectFile:d})]})]})})}function pB(){return fetch("/api/coverage/details").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()})}const Sne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsModal:F1},Symbol.toStringTag,{value:"Module"}));function hB({launcherUrl:e,projectCount:n=0,fallback:s}){const[r,a]=l.useState(!1),o=l.useCallback(async()=>{if(e){window.location.href=e;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)}}},[e,r]);return{goBack:!!e||n>=2?()=>{o()}:s,busy:r}}const Sc=["#ef9f27","#85b7eb","#8b85ff","#ef6f6f","#9bd35a","#b48ead"];function fB(e){const n=e.split(/[\s_\-./]+/).map(s=>{var r;return(r=s.match(/[\p{L}\p{N}]/u))==null?void 0:r[0]}).filter(s=>!!s);return n.length===0?"?":n.slice(0,2).join("").toUpperCase()}function mB(e){let n=5381;for(const s of e.trim().toLowerCase())n=(n*33^s.codePointAt(0))>>>0;return Sc[n%Sc.length]}const gB=256;function xB(e,n,s){const r=Math.min(1,s/Math.max(e,n));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(n*r))}}async function bB(e){if(typeof createImageBitmap!="function"||typeof document>"u")return e;try{const n=await createImageBitmap(e),{width:s,height:r}=xB(n.width,n.height,gB);if(s===n.width&&r===n.height&&e.size<256*1024)return n.close(),e;const a=document.createElement("canvas");a.width=s,a.height=r;const o=a.getContext("2d");return o?(o.drawImage(n,0,0,s,r),n.close(),await new Promise(c=>a.toBlob(c,"image/png"))??e):e}catch{return e}}const xm={version:0};async function yB(e){if(e.status===413)return"That image is too large. Try a smaller one.";try{return(await e.json()).error??`Request failed (${e.status})`}catch{return`Request failed (${e.status})`}}function vB(){const[e,n]=l.useState(xm),[s,r]=l.useState(null);l.useEffect(()=>{let d=!1;return Su("/api/project-icon").then(u=>u.ok?u.json():xm).then(u=>{d||n(u)}).catch(()=>{}),()=>{d=!0}},[]);const a=l.useCallback(async d=>{r(null);try{const u=await d;return u.ok?(n(await u.json()),!0):(r(await yB(u)),!1)}catch{return r("Couldn't reach the editor."),!1}},[]),o=l.useCallback(d=>a(fetch("/api/project-icon",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({color:d})})),[a]),i=l.useCallback(async d=>{const u=await bB(d);return a(fetch("/api/project-icon/image",{method:"PUT",headers:{"Content-Type":u.type||d.type},body:u}))},[a]),c=l.useCallback(()=>a(fetch("/api/project-icon",{method:"DELETE"})),[a]);return{icon:e,error:s,setColor:o,uploadImage:i,reset:c}}const jB="image/png,image/jpeg,image/webp,image/gif";function z1({name:e}){const{icon:n,error:s,setColor:r,uploadImage:a,reset:o}=vB(),[i,c]=l.useState(!1),d=l.useRef(null),u=l.useRef(null);l.useEffect(()=>{if(!i)return;const f=g=>{var x;(x=d.current)!=null&&x.contains(g.target)||c(!1)},m=g=>{g.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",m)}},[i]);const p=n.color??mB(e),h=!!n.color||!!n.image;return t.jsxs("div",{ref:d,className:"project-avatar",children:[t.jsxs("button",{type:"button",className:"pa-trigger","aria-label":"Edit project icon","aria-expanded":i,onClick:()=>c(f=>!f),children:[n.image?t.jsx("span",{"data-testid":"project-avatar",className:"pa-tile pa-image",children:t.jsx("img",{src:`/api/project-icon/image?v=${n.version}`,alt:`${e} logo`})}):t.jsx("span",{"data-testid":"project-avatar",className:"pa-tile",style:{background:p},children:fB(e)}),t.jsx("span",{className:"pa-edit","aria-hidden":"true",children:t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M4 20h4L18.5 9.5a2.8 2.8 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})})})]}),i&&t.jsxs("div",{className:"pa-menu",role:"menu",children:[t.jsx("button",{type:"button",className:"pa-item",onClick:()=>{var f;return(f=u.current)==null?void 0:f.click()},children:"Upload logo"}),t.jsx("input",{ref:u,type:"file",accept:jB,hidden:!0,"data-testid":"project-avatar-file",onChange:f=>{var g;const m=(g=f.target.files)==null?void 0:g[0];f.target.value="",m&&a(m).then(x=>x&&c(!1))}}),t.jsx("div",{className:"pa-label",children:"Color"}),t.jsx("div",{className:"pa-swatches",children:Sc.map(f=>t.jsx("button",{type:"button",className:"pa-swatch","aria-label":`Use color ${f}`,"aria-pressed":!n.image&&p===f,style:{background:f},onClick:()=>void r(f)},f))}),n.image&&t.jsx("div",{className:"pa-note",children:"A color shows when there is no logo."}),h&&t.jsx("button",{type:"button",className:"pa-item pa-muted",onClick:()=>void o().then(f=>f&&c(!1)),children:"Reset to initials"}),s&&t.jsx("div",{className:"pa-error",role:"alert",children:s})]})]})}const kne=Object.freeze(Object.defineProperty({__proto__:null,ProjectAvatar:z1},Symbol.toStringTag,{value:"Module"}));function B1({title:e,onBack:n,backBusy:s=!1}){return t.jsxs("div",{className:"home-head",children:[n?t.jsx("button",{type:"button",className:"hback",onClick:n,disabled:s,"aria-label":"All projects",title:"All projects",children:"←"}):null,t.jsx(z1,{name:e}),t.jsx("h1",{className:"htitle",children:e})]})}const Nne=Object.freeze(Object.defineProperty({__proto__:null,HomeHeader:B1},Symbol.toStringTag,{value:"Module"}));function W1({title:e,emptyTitle:n,count:s,live:r=!1,attention:a=!1,onAdd:o,addLabel:i,children:c}){const d=s===0;return t.jsxs("div",{className:"home-sechead",children:[r?t.jsx("span",{className:"home-livedot"+(a?" warn":""),"data-testid":"home-section-live-dot"}):null,t.jsxs("h2",{className:"home-sectitle"+(d?" empty":""),children:[d?n??`No ${e}`:e,s!=null&&s>0?t.jsxs("span",{className:"count",children:[" (",s,")"]}):null]}),c,o?t.jsx("button",{type:"button",className:"home-secadd"+(d?"":" spacer"),onClick:o,"aria-label":i,title:i,children:"+"}):null]})}const Cne=Object.freeze(Object.defineProperty({__proto__:null,HomeSectionHeading:W1},Symbol.toStringTag,{value:"Module"}));function H1({isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,thumbnailPath:i=null,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u,onResetBuild:p}){return t.jsxs("section",{"data-testid":"home-building-section",children:[t.jsx(W1,{title:"What's Building",live:e,attention:e&&a!=="building"}),t.jsx(Iu,{isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r,buildingStatus:a,buildingProgress:o,thumbnailPath:i,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u,onResetBuild:p})]})}const Tne=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildingSection:H1},Symbol.toStringTag,{value:"Module"})),q1=3;function U1({plans:e,loading:n,error:s,onRun:r,launchingSlug:a=null,blocked:o=!1,depAnnotationsBySlug:i,dependenciesBySlug:c,claimsBySlug:d,staleFetch:u,showAuthors:p=!1,onOpenPlans:h}){const[f,m]=l.useState(null),g=e.slice(0,q1),x=e.length>g.length;return t.jsxs("section",{className:"hsum-body","data-testid":"home-queued-plans-section",children:[t.jsx(yp,{plans:g,loading:n,error:s,expandedSlug:f,onToggle:b=>m(y=>y===b?null:b),onRun:r,launchingSlug:a,blocked:o,depAnnotationsBySlug:i,dependenciesBySlug:c,claimsBySlug:d,staleFetch:u,showAuthors:p}),t.jsxs("div",{className:"hsum-foot",children:[x?t.jsxs("button",{type:"button",className:"home-viewall",onClick:h,children:["View all ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}):null,t.jsxs("button",{type:"button",className:"hsum-action",onClick:h,"aria-label":"Plan a new change",children:[t.jsx("span",{"aria-hidden":"true",children:"+"})," Add plan"]})]})]})}const Pne=Object.freeze(Object.defineProperty({__proto__:null,HOME_QUEUED_PLAN_LIMIT:q1,HomeQueuedPlansSection:U1},Symbol.toStringTag,{value:"Module"})),wB=550;function _B(e,n,s=wB){const r=e.filter(h=>h.status!=="completed"),[a,o]=l.useState([]),i=l.useRef(r),c=l.useRef(new Map),d=r.map(h=>h.id).join(" ");if(l.useEffect(()=>{const h=i.current;i.current=r;const f=new Set(r.map(b=>b.id)),m=c.current,g=new Set;m.forEach((b,y)=>{f.has(y)&&(clearTimeout(b),m.delete(y),g.add(y))});const x=h.map((b,y)=>{var v;return{test:b,before:((v=h[y+1])==null?void 0:v.id)??null}}).filter(({test:b})=>!f.has(b.id)&&!m.has(b.id));x.length===0&&g.size===0||(x.forEach(({test:b})=>{m.set(b.id,setTimeout(()=>{m.delete(b.id),o(y=>y.filter(v=>v.test.id!==b.id))},s))}),o(b=>[...b.filter(y=>!g.has(y.test.id)),...x]))},[d,s,r]),l.useEffect(()=>{const h=c.current;return()=>{h.forEach(f=>clearTimeout(f)),h.clear()}},[]),n){const h=new Set(n);return{pending:r.filter(f=>!h.has(f.id)),rows:e.filter(f=>f.status!=="completed"||h.has(f.id)),departingIds:n,pinned:!0}}if(a.length===0)return{pending:r,rows:r,departingIds:[],pinned:!1};const u=new Map(e.map(h=>[h.id,h])),p=[...r];return[...a].reverse().forEach(({test:h,before:f})=>{const m=f===null?-1:p.findIndex(g=>g.id===f);p.splice(m===-1?p.length:m,0,u.get(h.id)??h)}),{pending:r,rows:p,departingIds:a.map(h=>h.test.id),pinned:!1}}function SB(e){const n={total:e.length,simulated:0,unsimulated:0,gaps:0,inherent:0,unclassified:0};for(const{surface:s}of e){if(s.kind==="scenario"){n.simulated+=1;continue}n.unsimulated+=1,s.kind==="no-ui-surface"&&(s.barrier===void 0?n.unclassified+=1:zd(s.barrier)?n.gaps+=1:n.inherent+=1)}return n}function G1(e){return!e||e.neverGenerated||e.lastGeneratedShaUnreachable||e.commitsSince==null?!0:e.commitsSince>0}function Y1({status:e,onGenerate:n,onAskForMore:s,disabled:r=!1,openChat:a=null,lastAdHocRange:o=null}){return t.jsxs("div",{className:"mtest-controls","data-testid":"home-testing-controls",children:[t.jsx(Xb,{status:e}),t.jsx(ay,{range:o}),t.jsxs("div",{className:"mtest-buttons",children:[t.jsx("button",{type:"button",className:"mtest-btn"+(G1(e)?" primary":"")+(a==="generate"?" open":""),onClick:n,disabled:r||!n,"aria-expanded":a==="generate",children:"Generate tests"}),t.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 One=Object.freeze(Object.defineProperty({__proto__:null,HomeTestingSectionControls:Y1,shouldEmphasizeGenerate:G1},Symbol.toStringTag,{value:"Module"})),bm=2;function V1({tests:e,status:n,loading:s=!1,error:r=null,busyIds:a=[],onToggle:o,onOpenUncovered:i,onGenerate:c,onAskForMore:d,blocked:u=!1,chatSlot:p,openChat:h=null,onAskAboutTest:f,onDeleteTest:m,askProviderLabel:g,openTestChatId:x=null,testChatSlot:b,departingIds:y,rangeSlot:v,lastAdHocRange:j=null}){const _=e.filter(M=>M.status==="completed"),S=new Set(a),[w,k]=l.useState(!1),{pending:N,rows:C,departingIds:T,pinned:P}=_B(e,y),R=new Set(T),L=w?C:C.slice(0,bm);return t.jsxs("section",{className:"hsum-body","data-testid":"home-testing-section",children:[t.jsx(Y1,{status:n,onGenerate:c,onAskForMore:d,disabled:u,openChat:h,lastAdHocRange:j}),v||null,p?t.jsx("div",{className:"mtest-chat",children:p}):null,s?t.jsx("div",{className:"mtest-placeholder","data-testid":"home-testing-loading",children:"Loading tests…"}):r?t.jsx("div",{className:"mtest-placeholder error","data-testid":"home-testing-error",children:r}):t.jsxs(t.Fragment,{children:[t.jsx(Pb,{summary:SB(e)}),C.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mtest-list",children:L.map(M=>t.jsx(Hd,{test:M,onToggle:o,onOpenUncovered:i,onAskAbout:f,onDelete:m,askProviderLabel:g,chatOpen:x===M.id,chatSlot:x===M.id?b:null,busy:S.has(M.id),departing:R.has(M.id)&&(P?"pinned":!0)},M.id))}),N.length>bm?t.jsx("button",{type:"button",className:"mtest-disclose",onClick:()=>k(M=>!M),"aria-expanded":w,"data-testid":"home-testing-show-all",children:w?"Show less":`Show all ${N.length} tests`}):null]}):t.jsx("div",{className:"mtest-placeholder","data-testid":"home-testing-empty",children:e.length>0?"Nothing left to verify.":"No manual tests yet."}),t.jsx(Jb,{tests:_,busyIds:a,onToggle:o,onOpenUncovered:i,onAskAboutTest:f,onDeleteTest:m,askProviderLabel:g,openTestChatId:x,testChatSlot:b})]})]})}const Rne=Object.freeze(Object.defineProperty({__proto__:null,HomeTestingSection:V1},Symbol.toStringTag,{value:"Module"})),ym={plans:"Queued plans",testing:"Testing",services:"External services"},vm=["plans","services","testing"];function K1(){return t.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:t.jsx("path",{d:"M4 6l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function J1({plans:e,testing:n,services:s,onAddPlan:r}){const[a,o]=l.useState(null),[i,c]=l.useState([]),d={plans:e,testing:n,services:s},u=p=>{o(h=>h===p?null:p),c(h=>h.includes(p)?h:[...h,p])};return t.jsxs("div",{className:"hsum","data-testid":"home-summary-strip",children:[t.jsx("div",{className:"hsum-tiles",children:vm.map(p=>{const{tile:h}=d[p],f=p==="plans"&&h.empty,m=p==="plans"&&!h.empty,g=a===p;return t.jsxs("div",{className:"hsum-cell",children:[t.jsxs("button",{type:"button",className:"hsum-tile"+(g?" open":"")+(h.empty?" empty":""),"data-testid":`home-summary-tile-${p}`,onClick:f?r:()=>u(p),"aria-expanded":f?void 0:g,"aria-controls":f?void 0:`home-summary-panel-${p}`,children:[t.jsx("span",{className:"hsum-label",children:ym[p]}),t.jsxs("span",{className:"hsum-headline",children:[h.attention?t.jsx("span",{className:"hsum-dot","aria-hidden":"true"}):null,h.headline]}),t.jsx("span",{className:"hsum-detail",children:h.detail}),t.jsx("span",{className:"hsum-icon","aria-hidden":"true",children:f?"+":t.jsx(K1,{})})]}),m&&t.jsxs("button",{type:"button",className:"hsum-add-plan",onClick:r,children:[t.jsx("span",{"aria-hidden":"true",children:"+"}),"Add plan"]})]},p)})}),vm.map(p=>i.includes(p)?t.jsx("div",{id:`home-summary-panel-${p}`,className:"hsum-panel",role:"region","aria-label":ym[p],hidden:a!==p,children:d[p].panel},p):null)]})}const Ene=Object.freeze(Object.defineProperty({__proto__:null,Chevron:K1,HomeSummaryStrip:J1},Symbol.toStringTag,{value:"Module"})),kB={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"},jm=["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 ua(e){return e.source==="pending"||e.confidence==="suggested"}function X1(e){var s;if(ua(e))return"suggested";if(e.confidence==="inferred")return"found in code";const n=(s=e.evidence[0])==null?void 0:s.source;return n?n==="git remote"?"from git remote":n==="config file"?"from config":`from ${n}`:"declared"}function NB(e){var s;const n=e.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 Pp(e){return e.envVars.length>0&&!e.credentialPresent}function CB(e){if(e.note)return e.note;const n=e.evidence[0];if(!n)return e.category;const s=e.evidence.length>1?` · +${e.evidence.length-1} more`:"";return`${n.value} in ${n.source}${s}`}function TB(e){const n=[{label:"Category",value:e.category}];if(ua(e))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:X1(e)}),e.envVars.length>0&&n.push({label:"Env vars",value:e.envVars.join(", "),mono:!0}),n.push({label:e.credentialPresent?"Key":"Key status",value:e.credentialPresent?"Configured":"Not set yet"});for(const s of e.evidence.slice(0,4))n.push({label:"Detected in",value:`${s.value} · ${s.source}`,mono:!0});return e.docsUrl&&n.push({label:"Docs",value:e.docsUrl}),n}function PB(e){const n=[],s=ua(e);n.push({text:X1(e),kind:"origin"}),s&&n.push({text:"not set up",kind:"miss"});const r=e.envVars[0];r&&n.push({text:r,kind:"env"}),e.envVars.length>0&&e.credentialPresent&&n.push({text:"Key set",kind:"set"});const a=Pp(e),o=s?"Set up":a?"Add key":void 0;return{monogram:NB(e.name),providerId:e.key,category:e.category,tone:kB[e.category]??"lime",name:e.name,desc:CB(e),tags:n.length?n:void 0,actionLabel:o,actionKey:o?e.key:void 0,attn:a,pending:s,detail:TB(e)}}function wm(e){const n=jm.indexOf(e);return n===-1?jm.length:n}function OB(e){const n=(e??[]).filter(s=>s.status!=="dismissed"&&!ua(s));return{total:n.length,attention:n.filter(Pp).length}}function RB(e){const n=(e??[]).filter(p=>p.status!=="dismissed");if(n.length===0)return{groups:[],summary:""};const s=new Map;for(const p of n){const h=s.get(p.category);h?h.push(p):s.set(p.category,[p])}const r=[...s.entries()].sort(([p],[h])=>wm(p)-wm(h)||p.localeCompare(h)).map(([p,h])=>({label:p,items:h.slice().sort((f,m)=>f.name.localeCompare(m.name)).map(PB)})),a=n.filter(p=>!ua(p)),o=n.length-a.length,i=a.filter(Pp).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 kc(e,n,s){return e===1?n:s}function EB(e){return e.length===0?{headline:"Nothing queued",detail:"Plan the next change",empty:!0,attention:!1}:{headline:`${e.length} queued`,detail:`Next: ${e[0].title}`,empty:!1,attention:!1}}function AB(e,n){const s=e.filter(o=>o.status!=="completed").length,r=(n==null?void 0:n.commitsSince)??0,a=r>0?`${r} ${kc(r,"commit","commits")} since last run`:null;return e.length===0?{headline:"No tests yet",detail:"Generate checks from recent commits",empty:!0,attention:!1}:s===0?{headline:"Nothing left to verify",detail:a??"Up to date",empty:!1,attention:!1}:{headline:`${s} to verify`,detail:a??"Up to date",empty:!1,attention:!1}}function MB(e){const{total:n,attention:s}=OB(e);if(n===0)return{headline:"None mapped yet",detail:"Find what your app talks to",empty:!0,attention:!1};const r=`${n} ${kc(n,"service","services")} detected`;return s>0?{headline:`${s} ${kc(s,"needs","need")} a key`,detail:r,empty:!1,attention:!0}:{headline:r,detail:"Every key is set",empty:!1,attention:!1}}function Q1({projectTitle:e,app:n,isBuilding:s,buildingLabel:r,buildingStepLabel:a,buildingStepPosition:o,buildingStatus:i,buildingProgress:c,buildingThumbnailPath:d,lastBuiltLabel:u,plans:p,plansLoading:h=!1,plansError:f=null,onRunPlan:m,launchingSlug:g,planDepAnnotationsBySlug:x,planDependenciesBySlug:b,planClaimsBySlug:y,planStaleFetch:v,showPlanAuthors:j,manualTests:_=[],manualTestsStatus:S=null,manualTestsLoading:w=!1,manualTestsError:k=null,manualTestsBusyIds:N,onCompleteManualTest:C,onOpenUncoveredSurface:T,onGenerateTests:P,onAskForTests:R,manualTestsChatSlot:L,manualTestsChatOpen:M=null,manualTestsRangeSlot:O,manualTestsLastAdHocRange:z=null,onAskAboutTest:I,onDeleteManualTest:Y,manualTestAgentLabel:W,manualTestChatId:A=null,manualTestChatSlot:B,detectedServices:D=null,servicesSlot:J,onOpenBuilding:te,onStartNewFeature:oe,onResetBuild:se,onOpenPlans:G,onBackToProjects:le,launcherUrl:ue,projectCount:ne=0,banner:E}){const{goBack:H,busy:U}=hB({launcherUrl:ue,projectCount:ne,fallback:le}),pe=(e==null?void 0:e.trim())||n.name||"Your project";return t.jsxs("div",{className:"home-landing",children:[E&&t.jsx("div",{className:"home-banner",children:E}),t.jsx(B1,{title:pe,onBack:H,backBusy:U}),t.jsx("div",{className:"home-sec",children:t.jsx(H1,{isBuilding:s,buildingLabel:r,buildingStepLabel:a,buildingStepPosition:o,buildingStatus:i,buildingProgress:c,thumbnailPath:d,lastBuiltLabel:u,onOpenBuilding:te,onStartNewFeature:oe,onResetBuild:se})}),t.jsx(J1,{onAddPlan:G,plans:{tile:EB(p),panel:t.jsx(U1,{plans:p,loading:h,error:f,onRun:m,launchingSlug:g,blocked:s,depAnnotationsBySlug:x,dependenciesBySlug:b,claimsBySlug:y,staleFetch:v,showAuthors:j,onOpenPlans:G})},testing:{tile:AB(_,S),panel:t.jsx(V1,{tests:_,status:S,loading:w,error:k,busyIds:N,onToggle:C??(()=>{}),onOpenUncovered:T,onGenerate:P,onAskForMore:R,blocked:s,chatSlot:L,openChat:M,rangeSlot:O,lastAdHocRange:z,onAskAboutTest:I,onDeleteTest:Y,askProviderLabel:W,openTestChatId:A,testChatSlot:B})},services:{tile:MB(D),panel:J}})]})}const Ane=Object.freeze(Object.defineProperty({__proto__:null,HomeLanding:Q1},Symbol.toStringTag,{value:"Module"})),Z1="/codeyam-manual-tests";function IB(e){return Ls(Z1,"")}function DB(e,n){const s=e.trim();if(!s)return IB();const r="".trim();return Ls(Z1,r?`range:${s} ${r}`:`range:${s}`)}function LB(e){const n=e==null?void 0:e.lastGeneratedSha;return n?`${n.slice(0,7)}..HEAD`:null}const $B="/codeyam-manual-test-help";function FB(e){return Ls($B,e)}function eN({id:e,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"})},[]),t.jsx("div",{ref:s,children:t.jsx(Ht,{chatName:`manual-test-${e}`,slashCommand:FB(e),height:360,onClose:n})})}const Mne=Object.freeze(Object.defineProperty({__proto__:null,ManualTestHelpChat:eN},Symbol.toStringTag,{value:"Module"}));function zB(){const[e,n]=l.useState([]),[s,r]=l.useState(null),[a,o]=l.useState(!0),[i,c]=l.useState(null),{manualTestsVersion:d}=Tn(),u=l.useRef(!1),p=l.useCallback(async()=>{u.current||o(!0),c(null);try{const[h,f]=await Promise.all([fetch("/api/manual-tests"),fetch("/api/manual-tests/status")]);if(!h.ok)throw new Error(`HTTP ${h.status}`);if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await h.json(),g=await f.json();n(Array.isArray(m)?m:[]),r(g),u.current=!0}catch(h){c(h instanceof Error?h.message:"Failed to load manual tests")}finally{o(!1)}},[]);return l.useEffect(()=>{p()},[p,d]),{tests:e,status:s,loading:a,error:i,refetch:p}}function BB(e){const[n,s]=l.useState({}),[r,a]=l.useState({}),[o,i]=l.useState(null);return{setCompleted:l.useCallback(async(d,u)=>{const p=u?"completed":"pending";i(null),s(h=>({...h,[d]:p})),a(h=>({...h,[d]:!0}));try{const h=u?"complete":"uncomplete",f=await fetch(`/api/manual-tests/${encodeURIComponent(d)}/${h}`,{method:"POST"});if(!f.ok)throw new Error(`HTTP ${f.status}`);await e(),s(m=>{const g={...m};return delete g[d],g})}catch(h){s(f=>{const m={...f};return delete m[d],m}),i(h instanceof Error?h.message:"Failed to update test")}finally{a(h=>{const f={...h};return delete f[d],f})}},[e]),overrides:n,inFlightIds:Object.keys(r),error:o}}function WB(){const[e,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:e,error:s}}function tN({title:e,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]),t.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:t.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:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(zb,{title:e}),t.jsx(Fb,{completed:s})]}),a&&t.jsx(Bt,{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}),t.jsx($b,{busy:r,onCancel:o,onConfirm:i})]})})}const Ine=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmModal:tN},Symbol.toStringTag,{value:"Module"}));function HB(e,n){return Object.keys(n).length===0?e:e.map(s=>n[s.id]&&n[s.id]!==s.status?{...s,status:n[s.id]}:s)}function qB(){const[e,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:e,refetch:s}}function UB(e){return e.credentialPresent?" (key configured)":e.envVars.length>0?" (needs a key)":""}function GB(e,n){const s=(e??[]).filter(o=>o.status!=="dismissed"),r=s.length?`
|
|
94
|
-
|
|
95
|
-
Detected in this project so far:
|
|
96
|
-
${s.map(o=>`- ${o.name} (${o.category})${UB(o)}`).join(`
|
|
97
|
-
`)}`:`
|
|
98
|
-
|
|
99
|
-
No external services have been auto-detected in this project yet.`,a=n!=null&&n.trim()?`
|
|
100
|
-
|
|
101
|
-
The user opened this chat with the following message. Respond to it directly and helpfully as your FIRST reply, before anything else:
|
|
102
|
-
"${n.trim()}"`:`
|
|
103
|
-
|
|
104
|
-
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,`
|
|
105
|
-
|
|
106
|
-
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.",`
|
|
107
|
-
|
|
108
|
-
Whenever a service gets set up, or the user tells you about one this list is missing `,"(their domain, for instance), record it right away so this page shows it: ","`codeyam-editor editor declare-service --key <id> --name <name> --category <category> --topic <topic>` ","(for a domain: `--key custom-domain --name <the domain> --category Domain --topic custom-domain`).",a].join("")}const YB=`<!--
|
|
109
|
-
The seed prompt for a broker provisioning session, and the ONE place its text
|
|
110
|
-
lives. Two consumers substitute the same four placeholders into it:
|
|
111
|
-
|
|
112
|
-
* the UI, via \`ui/src/helpers/buildStripeProjectsChatPrompt.ts\`, which imports
|
|
113
|
-
this file with Vite's \`?raw\` (the same mechanism
|
|
114
|
-
\`ui/src/helpers/errorCaptureShim.test.ts\` uses to read a Rust crate's
|
|
115
|
-
JavaScript shim);
|
|
116
|
-
* the CLI, via \`include_str!\` in \`broker_session.rs\`, so
|
|
117
|
-
\`codeyam-editor editor broker-session\` emits a byte-identical seed.
|
|
118
|
-
|
|
119
|
-
Keeping the text here rather than in either consumer is the point. A prompt
|
|
120
|
-
that tells an agent when it may spend the user's money is not something to
|
|
121
|
-
maintain in two languages: a rule tightened in the UI copy and missed in the
|
|
122
|
-
CLI copy is a rule that silently does not apply to half the entry points.
|
|
123
|
-
|
|
124
|
-
Placeholders, all four required, each substituted verbatim:
|
|
125
|
-
{{CATEGORY}} what the user is setting up, e.g. "hosting"
|
|
126
|
-
{{PROBE_STATE}} what the broker probe found on this machine
|
|
127
|
-
{{RESOURCES}} what this broker has already provisioned
|
|
128
|
-
{{OPENING}} the agent's instruction for its very first reply
|
|
129
|
-
-->
|
|
130
|
-
You are helping the user set up **{{CATEGORY}}** for this project using Stripe
|
|
131
|
-
Projects, a provisioning CLI that creates real resources on the user's Stripe
|
|
132
|
-
account and can cost them real money.
|
|
133
|
-
|
|
134
|
-
## What is already true on this machine
|
|
135
|
-
|
|
136
|
-
{{PROBE_STATE}}
|
|
137
|
-
|
|
138
|
-
{{RESOURCES}}
|
|
139
|
-
|
|
140
|
-
## Rules
|
|
141
|
-
|
|
142
|
-
These are not suggestions, and they hold for every command in this session.
|
|
143
|
-
|
|
144
|
-
- **Hand off to the local skill.** \`stripe projects init\` writes a
|
|
145
|
-
\`stripe-projects\` skill into this repository. It is the authoritative
|
|
146
|
-
reference for every subsequent Stripe Projects command — use it rather than
|
|
147
|
-
your memory of the CLI's flags. Do not install the skill globally unless the
|
|
148
|
-
user explicitly asks for it; the repo-local skill is the default because it
|
|
149
|
-
changes nothing outside this checkout.
|
|
150
|
-
- **Environment variable NAMES only, never values.** You may say that
|
|
151
|
-
\`DATABASE_URL\` is set. You may never print, echo, log, or repeat what it is
|
|
152
|
-
set to, not even partially.
|
|
153
|
-
- **Never hand-edit \`.projects/\` or \`.env\`.** The CLI owns those files. If
|
|
154
|
-
something in them is wrong, fix it with a CLI command, not an editor.
|
|
155
|
-
- **Ask before anything irreversible.** Every command that creates, links,
|
|
156
|
-
upgrades, or removes a resource spends the user's money or changes their
|
|
157
|
-
account. Show the exact command you intend to run, say plainly what it will
|
|
158
|
-
create and what it will cost, and wait for an explicit yes. One approval
|
|
159
|
-
covers exactly one command — approval to install the CLI is not approval to
|
|
160
|
-
initialize the project, and neither is approval to provision anything.
|
|
161
|
-
- **A browser window means STOP.** The Stripe CLI opens a browser to
|
|
162
|
-
authenticate. When that happens, tell the user a browser window is waiting
|
|
163
|
-
for them and run nothing further until they confirm they have finished. Do
|
|
164
|
-
not poll, do not retry, and do not work around it.
|
|
165
|
-
- **Pass \`--json\` where the CLI supports it** and read the structured output
|
|
166
|
-
rather than parsing human-formatted text.
|
|
167
|
-
- **Never re-provision.** The resources listed above already exist. Adding a
|
|
168
|
-
second one because you did not read the list is the most expensive mistake
|
|
169
|
-
available to you here.
|
|
170
|
-
|
|
171
|
-
## Start here
|
|
172
|
-
|
|
173
|
-
{{OPENING}}
|
|
174
|
-
`;function VB(e){const n=e.indexOf("-->");return e.startsWith("<!--")&&n!==-1?e.slice(n+3).trimStart():e}function KB(e){const n=[`- ${e.name} CLI: ${e.cliInstalled?`installed${e.cliVersion?` (${e.cliVersion})`:""}`:`NOT installed. The user would install it with: ${e.installHint}`}`,`- Its \`projects\` plugin: ${e.pluginInstalled?"installed":"NOT installed"}`,`- This directory: ${e.projectInitialized?`initialized${e.projectName?` as "${e.projectName}"`:""}`:"NOT initialized — `stripe projects init` has not been run here"}`];return e.note&&n.push(`- Note from the probe: ${e.note}`),n.join(`
|
|
175
|
-
`)}function JB(e){const n=(e??[]).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(`
|
|
176
|
-
`)}function XB(e,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:
|
|
177
|
-
"${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 VB(YB).replace("{{CATEGORY}}",n.toLowerCase()).replace("{{PROBE_STATE}}",KB(e)).replace("{{RESOURCES}}",JB(s)).replace("{{OPENING}}",a)}function nN({onBack:e,embedded:n=!1,onServicesChanged:s}){const{services:r,refetch:a}=ku(),{brokers:o}=qB(),[i,c]=l.useState(!1),[d,u]=l.useState(void 0),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(!1),{groups:b,summary:y}=l.useMemo(()=>RB(r),[r]),v=l.useMemo(()=>(o??[]).find(gI)??null,[o]),j=l.useMemo(()=>(o??[]).find(qb)??null,[o]),_=()=>{c(!1),m(null),x(!1)},S=w=>{var C;const k=(r??[]).find(T=>T.key===w);if(!k)return;const N=(C=k.envVars)==null?void 0:C[0];if(!N){if(v){m({broker:v,category:k.category}),x(!1),u(void 0),c(!0);return}u(`Help me set up ${k.category.toLowerCase()} for this project`),c(!0);return}h({serviceName:k.name,envVar:N,topic:k.topic,docsUrl:k.docsUrl})};return t.jsxs("div",{className:"xsvc-connected",children:[t.jsx(S_,{groups:b,loading:r===null,summary:y,onBack:e,embedded:n,onOpenChat:w=>{m(null),x(!1),u(w),c(!0)},onAction:S,onSaveDomain:async w=>{if(!(await fetch("/api/setup-services/declare",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:"custom-domain",name:w,category:"Domain",topic:"custom-domain"})})).ok)throw new Error("Couldn't save the domain. Try again.");await a(),s==null||s()},brokerStarter:j?{label:`Set up with ${j.name}`,onSelect:()=>{m({broker:j,category:"External services"}),x(!1),u(void 0),c(!0)}}:void 0,chatSlot:i?t.jsx(Gb,{title:f?`Set up ${f.category.toLowerCase()} with ${f.broker.name}`:"Chat about your external services",onClose:_,children:f&&!g?t.jsx(Ub,{broker:f.broker,category:f.category,onStart:()=>x(!0)}):t.jsx(Ht,{chatName:f?`external-services-${f.broker.id}`:"external-services",prompt:f?XB(f.broker,f.category,r,d):GB(r,d),height:380,onClose:_})}):void 0}),p?t.jsx(Tp,{target:p,onStored:()=>{h(null),a(),s==null||s()},onClose:()=>h(null)}):null]})}const Dne=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesScreenConnected:nN},Symbol.toStringTag,{value:"Module"})),QB={provider:"vercel"},sN={"dev-accounts":q_,"store-assets":U_,"store-listing":G_,"testing-distribution":Y_,"push-notifications":V_,"crash-reporting":K_,"in-app-purchases":J_,"app-privacy":X_,"app-review":Q_};function _m(e){return e in sN}function ZB(){const[e,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:e,setStatus:r,addTopic:a}}function e8(){const[e,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:e}}function t8(){const[e,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:e}}function n8(e,n){if(n(),Tg()){Ja(e);return}KR(Ah).then(s=>{s?Ja(e):console.warn(`[setup-chat] Build terminal did not attach within ${Ah}ms; prompt not sent`)})}const s8=new Set(["share-testing","store-accounts","store-assets","permissions-justification","oauth-verification","privacy-policy","single-purpose-listing","manifest-versioning","submit-review"]);function rN({notificationBanner:e,appDetailProps:n,appOverviewProps:s,selectedApp:r,projectTitle:a,admin:o,isBuilding:i,buildingLabel:c,buildingStepLabel:d,buildingStepPosition:u,buildingStatus:p,buildingProgress:h,buildingThumbnailPath:f,lastBuiltLabel:m,plans:g,plansLoading:x,plansError:b,onRunPlan:y,launchingSlug:v,planDepAnnotationsBySlug:j,planDependenciesBySlug:_,planClaimsBySlug:S,planStaleFetch:w,showPlanAuthors:k,onNavigateToPlan:N,onNavigateToBuild:C,onResetBuild:T,onBackToProjects:P,launcherUrl:R,projectCount:L,onOpenSetupBrowser:M}){const[O,z]=l.useState(!1),I=()=>z(!0),Y=()=>z(!1),{tests:W,status:A,loading:B,error:D,refetch:J}=zB(),{setCompleted:te,overrides:oe,inFlightIds:se}=BB(J),{deleteTest:G,deleting:le,error:ue}=WB(),[ne,E]=l.useState(null),H=W.find(K=>K.id===ne)??null,[U,pe]=l.useState(null),ge=cB(),Me=dB(ge.open),[Ce,De]=l.useState(null),{config:Be}=Pt(),X=st(Be==null?void 0:Be.provider),[Q,re]=l.useState("landing"),[ce,_e]=l.useState(null),[Te,Oe]=l.useState(null),{topics:he,setStatus:xe,addTopic:Fe}=ZB();he==null||he.filter(K=>K.status==="done").length;const F=K=>{var V;return((V=he==null?void 0:he.find(we=>we.key===K))==null?void 0:V.status)??"available"},{services:ee,dismiss:de,refetch:ie}=ku(),[fe,ve]=l.useState(null),be=l.useCallback(K=>{var we;const V=(we=K.envVars)==null?void 0:we[0];V&&ve({serviceName:K.name,envVar:V,topic:K.topic,docsUrl:K.docsUrl})},[]),{recipe:We}=t8(),ze=F4(nw()),{groups:Re}=e8(),Ye=(he==null?void 0:he.some(K=>K.key==="dev-accounts"))??!1,rt=(he==null?void 0:he.some(K=>K.key==="deploy-target"))??!1,je=K=>{K==="run-locally"?re("run-locally"):Ye&&_m(K)?(Oe(K),re("mobile-setup")):s8.has(K)?re(K):_m(K)?(Oe(K),re("mobile-setup")):(_e(K),re("topic"))},Ve=!!(n.selectedRouteEntity||n.selectedEntityHash);let Se,Qe=!1;if(!r)Se=t.jsx(kS,{...s,onCoverageClick:I},"app-overview");else if(Ve||Q==="detail"){const K=Q==="detail"&&!Ve;Se=t.jsxs(t.Fragment,{children:[K?t.jsx("div",{className:"home-landing",style:{padding:"20px 28px 0"},children:t.jsxs("div",{className:"crumbs",style:{marginBottom:0},children:[t.jsx("button",{type:"button",className:"back",onClick:()=>re("landing"),"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:()=>re("landing"),children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Explore your app"})]})}):null,t.jsx(aw,{app:r,...n,onCoverageClick:I})]})}else if(Q==="learn")Se=t.jsx(Wa,{topics:he,detectedServices:ee,onBack:()=>re("landing"),onOpenHosting:()=>re("hosting"),onOpenTopic:je,onOpenLibraries:()=>re("libraries"),onDismissService:de,onAddCredential:be,onCreateTopic:Fe,onOpenConcepts:()=>re("concepts")});else if(Q==="libraries")Se=t.jsx(xw,{groups:Re,onBack:()=>re("learn")});else if(Q==="concepts")Se=t.jsx(j_,{onBack:()=>re("learn")});else if(Q==="hosting")Se=t.jsx(E_,{connector:QB,onBack:()=>re("learn"),onComplete:()=>xe("hosting","done"),onOpenSharedBrowser:M});else if(Q==="run-locally")Se=t.jsx(A_,{recipe:We,onBack:()=>re("learn"),status:F("run-locally"),onMarkDone:()=>xe("run-locally","done"),onRevert:()=>xe("run-locally","available")});else if(Q==="share-testing")Se=t.jsx(H_,{onBack:()=>re("learn"),status:F("share-testing"),onComplete:()=>xe("share-testing","done"),onRevert:()=>xe("share-testing","available")});else if(Q==="store-accounts")Se=t.jsx(M_,{onBack:()=>re("learn"),status:F("store-accounts"),onComplete:()=>xe("store-accounts","done"),onRevert:()=>xe("store-accounts","available")});else if(Q==="store-assets")Se=t.jsx(I_,{onBack:()=>re("learn"),status:F("store-assets"),onComplete:()=>xe("store-assets","done"),onRevert:()=>xe("store-assets","available")});else if(Q==="permissions-justification")Se=t.jsx(L_,{onBack:()=>re("learn"),status:F("permissions-justification"),onComplete:()=>xe("permissions-justification","done"),onRevert:()=>xe("permissions-justification","available")});else if(Q==="oauth-verification")Se=t.jsx(F_,{onBack:()=>re("learn"),status:F("oauth-verification"),onComplete:()=>xe("oauth-verification","done"),onRevert:()=>xe("oauth-verification","available")});else if(Q==="privacy-policy")Se=t.jsx($_,{onBack:()=>re("learn"),status:F("privacy-policy"),onComplete:()=>xe("privacy-policy","done"),onRevert:()=>xe("privacy-policy","available")});else if(Q==="single-purpose-listing")Se=t.jsx(z_,{onBack:()=>re("learn"),status:F("single-purpose-listing"),onComplete:()=>xe("single-purpose-listing","done"),onRevert:()=>xe("single-purpose-listing","available")});else if(Q==="manifest-versioning")Se=t.jsx(B_,{onBack:()=>re("learn"),status:F("manifest-versioning"),onComplete:()=>xe("manifest-versioning","done"),onRevert:()=>xe("manifest-versioning","available")});else if(Q==="submit-review")Se=t.jsx(W_,{onBack:()=>re("learn"),status:F("submit-review"),onComplete:()=>xe("submit-review","done"),onRevert:()=>xe("submit-review","available")});else if(Q==="topic"&&ce){const K=(he==null?void 0:he.find(V=>V.key===ce))??null;Se=t.jsx(v_,{topicKey:ce,topicName:K==null?void 0:K.name,topicDesc:K==null?void 0:K.desc,isBackend:rt,onBack:()=>re("learn"),onComplete:V=>xe(V,"done"),onChatWithAI:V=>n8(V,C)})}else if(Q==="mobile-setup"&&Te){const K=sN[Te];Se=K?t.jsx(K,{platform:ze,onBack:()=>re("learn"),status:F(Te),onComplete:()=>xe(Te,"done"),onRevert:()=>xe(Te,"available")}):t.jsx(Wa,{topics:he,detectedServices:ee,onBack:()=>re("landing"),onOpenHosting:()=>re("hosting"),onOpenTopic:je,onDismissService:de,onAddCredential:be})}else Qe=!0,Se=t.jsxs(t.Fragment,{children:[t.jsx(Q1,{banner:e,app:r,projectTitle:a,isBuilding:i,buildingLabel:c,buildingStepLabel:d,buildingStepPosition:u,buildingStatus:p,buildingProgress:h,buildingThumbnailPath:f,lastBuiltLabel:m,plans:g,plansLoading:x,plansError:b,onRunPlan:y,launchingSlug:v,planDepAnnotationsBySlug:j,planDependenciesBySlug:_,planClaimsBySlug:S,planStaleFetch:w,showPlanAuthors:k,manualTests:HB(W,oe),manualTestsStatus:A,manualTestsLoading:B,manualTestsError:D,manualTestsBusyIds:se,onCompleteManualTest:(K,V)=>{te(K,V)},onGenerateTests:()=>{De(null),pe(null),ge.toggle()},onAskForTests:()=>{De(null),ge.close(),pe(K=>K==="ask"?null:"ask")},manualTestsChatOpen:ge.open?"generate":U,manualTestsLastAdHocRange:ge.lastAdHocRange,manualTestsRangeSlot:ge.open?t.jsx(ry,{defaultRange:LB(A),commitCount:(A==null?void 0:A.commitsSince)??null,recentCommits:Me,onCancel:ge.close,onGenerate:K=>{ge.accept(K),pe("generate")}}):null,manualTestsChatSlot:U?t.jsx(Yb,{slashCommand:U==="generate"?DB(ge.seed):void 0,onClose:()=>pe(null)}):null,onAskAboutTest:K=>{pe(null),De(V=>V===K?null:K)},onDeleteManualTest:K=>E(K),manualTestAgentLabel:X,manualTestChatId:Ce,manualTestChatSlot:Ce?t.jsx(eN,{id:Ce,onClose:()=>De(null)}):null,detectedServices:ee,servicesSlot:t.jsx(nN,{embedded:!0,onServicesChanged:()=>void ie()}),onOpenBuilding:C,onStartNewFeature:C,onResetBuild:T,onOpenPlans:N,onBackToProjects:P,launcherUrl:R,projectCount:L}),t.jsx(Pj,{appDetailProps:n,selectedApp:r,setupSlot:o?t.jsx(Wa,{topics:he,detectedServices:ee,onBack:()=>re("landing"),onOpenHosting:()=>re("hosting"),onOpenTopic:je,onOpenLibraries:()=>re("libraries"),onDismissService:de,onAddCredential:be,onCreateTopic:Fe,onOpenConcepts:()=>re("concepts")}):void 0})]});return t.jsxs(dw,{children:[e&&!Qe&&t.jsx("div",{style:{padding:"10px 28px 0"},children:e}),Se,O&&t.jsx(F1,{onClose:Y}),fe?t.jsx(Tp,{target:fe,onStored:()=>{ve(null),ie()},onClose:()=>ve(null)}):null,H?t.jsx(tN,{title:H.title,id:H.id,completed:H.status==="completed",busy:le,error:ue,onCancel:()=>E(null),onConfirm:()=>{G(H.id).then(()=>{E(null),J()}).catch(()=>{})}}):null]})}const Lne=Object.freeze(Object.defineProperty({__proto__:null,EditorShellHomeTabContent:rN},Symbol.toStringTag,{value:"Module"}));function aN({activeTab:e,awaitingPlanLaunchChoice:n,buildLaunchGateArmed:s,buildActivated:r,hideResultsCommandKey:a,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:w,buildActivity:k,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}){return r?t.jsx(b1,{awaitingPlanLaunchChoice:n,buildLaunchGateArmed:s,buildActivated:r,activeTab:e,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,hideResultsCommandKey:a,onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:w,buildActivity:k,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}):null}const $ne=Object.freeze(Object.defineProperty({__proto__:null,EditorShellBuildLayer:aN},Symbol.toStringTag,{value:"Module"})),Nc=24;function oN({onMouseDown:e,onReset:n,onNudge:s,isDragging:r=!1,valueNow:a,valueMax:o,valueMin:i}){const[c,d]=l.useState(!1),[u,p]=l.useState(!1),h=l.useRef(!1),f=c||u||r;return t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panels","aria-valuenow":a,"aria-valuemin":i,"aria-valuemax":o,tabIndex:0,title:"Drag to resize · double-click to reset","data-active":f?"true":"false",onMouseDown:m=>{h.current=!0,e(m)},onDoubleClick:n,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocus:()=>p(!h.current),onBlur:()=>{h.current=!1,p(!1)},onKeyDown:m=>{s&&(m.key==="ArrowLeft"?(m.preventDefault(),s(-Nc)):m.key==="ArrowRight"&&(m.preventDefault(),s(Nc)))},className:"shrink-0 flex items-center justify-center",style:{position:"relative",width:12,cursor:"col-resize",outline:"none",background:f?"rgba(215,255,99,.07)":"var(--bg-deep)",transition:"background .15s"},children:t.jsx("div",{"data-testid":"panel-divider-grip",style:{width:4,height:f?52:36,borderRadius:99,background:f?"var(--accent-active)":"var(--line-strong)",transition:"background .15s, height .15s"}})})}const Fne=Object.freeze(Object.defineProperty({__proto__:null,DIVIDER_KEYBOARD_STEP:Nc,PanelDivider:oN},Symbol.toStringTag,{value:"Module"})),r8=[{key:"editor",label:"Editor"},{key:"preview",label:"Preview"}];function iN({active:e,onChange:n,isAgentBuilding:s=!1,buildIdle:r=!1}){const a=s&&!r,o=r;return t.jsx("div",{"data-testid":"mobile-pane-switcher",className:"shrink-0 flex w-full",style:{background:"var(--bg-deep)",...ra("top"),paddingBottom:"env(safe-area-inset-bottom)"},children:r8.map(i=>{const c=e===i.key;return t.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 transition-colors cursor-pointer ${c?"text-white font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[i.key==="editor"&&a&&t.jsx(Nr,{}),i.key==="editor"&&o&&t.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 zne=Object.freeze(Object.defineProperty({__proto__:null,MobilePaneSwitcher:iN},Symbol.toStringTag,{value:"Module"}));function a8(e){return e.replace(/^https?:\/\//,"")}function Cc({url:e}){const[n,s]=l.useState(0),r="grid h-7 w-7 shrink-0 place-items-center rounded-md text-[var(--text-muted)] hover:bg-white/10 hover:text-[var(--text-primary)] cursor-pointer";return t.jsxs("section",{"aria-label":"Web page","data-testid":"web-panel",className:"flex h-full min-h-0 w-full flex-col overflow-hidden rounded-xl border border-white/10 bg-[var(--bg-card)]",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-white/[.06] px-2",children:[t.jsx("button",{type:"button","aria-label":"Reload",title:"Reload",onClick:()=>s(a=>a+1),className:r,children:t.jsx("span",{"aria-hidden":"true",children:"↻"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate rounded-md bg-white/[.04] px-2.5 py-1 text-xs text-[var(--text-secondary)]",title:e,children:a8(e)}),t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":"Open in a new tab",title:"Open in a new tab",className:r,children:t.jsx("span",{"aria-hidden":"true",children:"↗"})}),t.jsx("button",{type:"button","aria-label":"Close",title:"Close",onClick:fx,className:r,children:t.jsx("span",{"aria-hidden":"true",children:"×"})})]}),t.jsxs("div",{className:"relative min-h-0 flex-1 bg-white",children:[t.jsxs("div",{"data-testid":"web-panel-blank-hint",className:"absolute inset-0 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"max-w-[300px] text-[13px] leading-relaxed text-neutral-500",children:"Still blank? Some sites can't be shown inside the editor."}),t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"rounded-lg bg-neutral-900 px-3.5 py-2 text-[13px] font-medium text-white hover:bg-neutral-700",children:"Open it in a new tab ↗"})]}),t.jsx("iframe",{src:e,title:e,className:"absolute inset-0 h-full w-full border-0 bg-transparent",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},`${e}#${n}`)]})]})}const Bne=Object.freeze(Object.defineProperty({__proto__:null,WebPanel:Cc},Symbol.toStringTag,{value:"Module"}));function lN({isCollapsed:e,leftPane:n,onResizeStart:s,onResizeReset:r,onResizeNudge:a,isResizing:o=!1,leftWidth:i,leftWidthMin:c,previewPane:d,splitRef:u,isNarrow:p,mobilePane:h,onMobilePaneChange:f,isAgentBuilding:m=!1,buildIdle:g=!1,hidePreview:x=!1,onHomeLivePageBack:b}){const y=l.useSyncExternalStore(mM,fM);l.useEffect(()=>p?void 0:xM(),[p]);const v=j=>t.jsxs("div",{className:"relative flex min-w-0 flex-1",children:[j,y&&t.jsx("div",{className:"absolute inset-0 z-30 p-2",style:{background:"var(--bg-deep)"},children:t.jsx(Cc,{url:y})})]});return p?t.jsxs("div",{ref:u,className:"fixed inset-0 flex flex-col",style:{background:"var(--bg-deep)"},children:[t.jsxs("div",{className:"flex-1 min-h-0 relative",children:[t.jsx("div",{className:`absolute inset-0 flex ${h==="editor"?"":"hidden"}`,children:n}),t.jsx("div",{className:`absolute inset-0 flex ${h==="preview"?"":"hidden"}`,children:d})]}),t.jsx(iN,{active:h,onChange:f,isAgentBuilding:m,buildIdle:g})]}):b?t.jsx("div",{ref:u,className:"fixed inset-0 flex",style:{background:"var(--bg-deep)"},children:v(d)}):x?t.jsxs("div",{ref:u,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:[n,y&&t.jsx("div",{className:"w-[46%] min-w-[360px] shrink-0 p-2",style:{background:"var(--bg-deep)"},children:t.jsx(Cc,{url:y})})]}):t.jsxs("div",{ref:u,className:"fixed inset-0 flex",style:{background:"var(--bg-deep)"},children:[!e&&t.jsxs(t.Fragment,{children:[n,t.jsx(oN,{onMouseDown:s,onReset:r,onNudge:a,isDragging:o,valueNow:i,valueMin:c})]}),v(d)]})}const Wne=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLayout:lN},Symbol.toStringTag,{value:"Module"}));function Op(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i,claimsVersion:c}=Tn(),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 p=await u.json();n(Array.isArray(p)?p:[])}catch(u){o(u instanceof Error?u.message:"Failed to load plan claims")}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d,i,c]),{claims:e,loading:s,error:a,refetch:d}}function Rp(){const[e,n]=l.useState(null),{claimsVersion:s}=Tn(),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:e}}function o8(){const[e,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:e}}const al="codeyam-editor editor plan-claims-status",i8="git push origin HEAD";function cN(e,n){switch(e){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:i8};case"network":return{message:"Plan tracking can't reach the remote (network failure). Check connectivity, then run the command below for details.",command:al};case"git-spawn":return{message:"Plan tracking can't launch git. Run the command below for the failing invocation.",command:al};default:return{message:`Plan tracking is failing (${n} failed ticks). Teammates' in-flight plans may not appear. Run the command below for details.`,command:al}}}function dN({status:e}){const n=(e==null?void 0:e.consecutiveFailures)??0;if((e==null?void 0:e.enabled)===!1||n<3)return null;const{message:s,command:r}=cN(e==null?void 0:e.lastErrorCategory,n);return t.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3","data-testid":"plan-claim-sync-banner",role:"alert",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),t.jsxs("div",{className:"flex-1 min-w-0 text-sm text-amber-800",children:[s," ",t.jsx("code",{className:"text-xs",children:r})," ",t.jsx(mt,{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 Hne=Object.freeze(Object.defineProperty({__proto__:null,PlanClaimSyncBanner:dN,planClaimSyncBannerContent:cN},Symbol.toStringTag,{value:"Module"})),Sm="codeyam-editor editor restart-server";function Ep({staleness:e,backendOutOfDate:n=!1}){var a;const s=!!(e!=null&&e.stale);if(!s&&!n)return null;const r=((a=e==null?void 0:e.info)==null?void 0:a.minutesStale)??0;return t.jsx("div",{className:"mt-3 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:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--red-300)"},children:"!"}),t.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[s?t.jsxs(t.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."]}):t.jsx(t.Fragment,{children:"The editor is running an older version of itself, which can’t drive the Build tab. Restarting it reconnects everything."})," ","Run"," ",t.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:Sm}),"."," ",t.jsx(mt,{text:Sm,label:"Copy command",copiedLabel:"Copied",ariaLabel:"Copy the editor restart command",className:"underline disabled:opacity-50"})]})]})})}const qne=Object.freeze(Object.defineProperty({__proto__:null,ServerStalenessBanner:Ep},Symbol.toStringTag,{value:"Module"}));function Ap(e){const n=new Map;for(const s of e){const r=n.get(s.slug);(!r||r.source!=="local"&&s.source==="local")&&n.set(s.slug,s)}return n}function l8(e){var s;const n=new Set;for(const r of e){const a=(s=r==null?void 0:r.email)==null?void 0:s.trim().toLowerCase();a&&n.add(a)}return n.size}function uN(e){return l8(e)>=2}function c8(e,n){return e.filter(s=>s.source==="local"||!n.has(s.slug))}function d8(e,n,s){const r=new Map(n.map(a=>[a.slug,a]));return e.dependsOn.map(a=>{var o;return{slug:a,title:((o=r.get(a))==null?void 0:o.title)??null,satisfied:s.has(a)}})}function pN(e){return e.filter(n=>!n.satisfied)}function Mp(e){const{slugs:n}=fd();return l.useMemo(()=>{const s={},r={};for(const a of e){const o=a.dependsOn??[];if(o.length===0)continue;const i=d8({...a,dependsOn:o},e,n);r[a.slug]=i;const c=pN(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}},[e,n])}async function hN({send:e,waitForIdle:n,ceilingMs:s,payload:r,sendPayload:a=e}){const o=e("\x1B"),i=n(s);if(await o,await i,!r.endsWith("\r")){await a(r);return}await a(r.slice(0,-1)),await new Promise(c=>setTimeout(c,cd)),await a("\r")}let Is={hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null};function gi(e){Is={...Is,...e}}function u8(){return Is}function p8(){return Is.hasActiveSession||Is.isAgentBuilding||!!Is.stepStateFeature}function km(e){return Cg("build-agent-idle",e)}const h8=5e3,Nm=Rr,Cm="The session could not be started because the Build terminal never opened, so the launch commands had nowhere to go.";async function fN(){let e=!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&&(e=!0)}catch{}e&&gi({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),me("clear-editor-session",{ok:e,...n!==void 0?{status:n}:{},snapshotReset:e})}async function f8(){let e=!1,n;try{const s=await fetch("/api/stop-building",{method:"POST",headers:{"Content-Type":"application/json"}});n=s.status,s.ok&&(e=!0)}catch{}e&&gi({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),me("stop-building",{ok:e,...n!==void 0?{status:n}:{},snapshotReset:e})}async function m8(){let e=!1,n;try{const s=await fetch("/api/reset-everything",{method:"POST",headers:{"Content-Type":"application/json"}});n=s.status,s.ok&&(e=!0)}catch{}e&&gi({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),me("reset-everything",{ok:e,...n!==void 0?{status:n}:{},snapshotReset:e})}async function mN(e={}){const n=u8(),s=e.caller??"unknown",r=e.bypassLiveGuard===!0;if(p8()&&!r){me("launch-editor-skill",{caller:s,suppressed:!0,snapshot:n,bypassLiveGuard:!1});return}if(oF(),me("launch-editor-skill",{caller:s,suppressed:!1,snapshot:n,bypassLiveGuard:r}),e.provider==="gemini"||e.provider==="opencode")return;if(HS(e.renameLabel??"Editor",s,Ng),e.serverOwnsLaunch){me("launch-editor-skill",{caller:s,serverOwnsLaunch:!0});return}const a=_F()??await SF(h8);if(me("launch-editor-skill-owner",{caller:s,owner:a.owner,basis:a.basis}),a.basis==="no-answer"&&!Tg())throw me("launch-editor-skill",{caller:s,suppressed:!1,droppedNoTerminal:!0}),new Error(Cm);if(a.owner==="server")return;const o=a.launchId??_g(),i=(c,d,u)=>async p=>{await c(p),xl({launchId:o,role:"build",event:"prompt-written",kind:d,command:u})};try{let c=Promise.resolve();const d=i(Mh,"ui-clear","/clear");await hN({send:i(JR,"ui-escape"),sendPayload:u=>{const p=d(u);return c=km(Nm),p},waitForIdle:km,ceilingMs:Nm,payload:"/clear"}),await c,await i(Mh,"ui-skill","/codeyam-editor")("/codeyam-editor")}catch(c){throw c instanceof XR?(me("launch-editor-skill",{caller:s,suppressed:!1,droppedNoTerminal:!0}),new Error(Cm)):c}}async function gN(e=1500){try{const n=await fetch("/api/session-info",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(e)});if(!n.ok)return null;const s=await n.json();return typeof(s==null?void 0:s.agentBrokerLive)=="boolean"?s.agentBrokerLive:null}catch{return null}}function Ip(e,n=!1,s=n){const r=vE(e),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,"",jn("home"))},[s,r]);const u=l.useCallback(f=>{if(n&&f==="build"){window.history.pushState(null,"",jn("home"));return}window.history.pushState(null,"",jn(f)),f==="build"&&i(!0),f==="plan"&&d(!0)},[n]),p=l.useCallback(()=>{n||(window.history.pushState(null,"",jn("build")),i(!0))},[n]),h=l.useCallback(()=>{i(!1)},[]);return{activeTab:a,buildActivated:o,planActivated:c,navigateToTab:u,showBuildTab:p,deactivateBuild:h}}const g8=15e3;function x8(e,n){const s=`/api/plans/${encodeURIComponent(e)}/select`;return n?`${s}?source=${encodeURIComponent(n)}`:s}function xN(e={}){const{launchAnchored:n=!1}=e,{showBuildTab:s}=Ip(typeof window>"u"?"/":window.location.pathname),{config:r}=Pt(),[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)},[]),p=l.useCallback(()=>{u(),o(null)},[u]);l.useEffect(()=>{a!==null&&n&&p()},[a,n,p]),l.useEffect(()=>u,[u]);const h=l.useCallback(async(f,m,g)=>{if(a)return!1;c(null),o(f);let x=null;try{x=await gN();try{await fN(),Jk()}catch{}const b=await fetch(x8(f,g),{method:"POST"});if(!b.ok){let y=`HTTP ${b.status}`;try{const v=await b.json();v!=null&&v.error&&(y=v.error)}catch{}throw new Error(y)}s()}catch(b){return c(b instanceof Error?b.message:"Failed to launch plan"),p(),!1}return u(),d.current=setTimeout(()=>{d.current=null,o(null)},g8),mN({caller:"plan-launcher",renameLabel:m,provider:r==null?void 0:r.provider,bypassLiveGuard:!0,serverOwnsLaunch:x===!1}).catch(b=>{c(b instanceof Error?b.message:"Failed to launch plan")}),!0},[a,s,r==null?void 0:r.provider,p,u]);return{launchingSlug:a,error:i,launchPlan:h}}function bN({onClose:e}){const n=s=>{s.target===s.currentTarget&&e()};return t.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:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Build in progress"}),t.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:Wg}),t.jsx("div",{className:"flex flex-col gap-3",children:t.jsx("button",{onClick:e,"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 Une=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedModal:bN},Symbol.toStringTag,{value:"Module"}));function yN({deps:e,onClose:n}){const s=r=>{r.target===r.currentTarget&&n()};return t.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:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Prerequisite plans not yet built"}),t.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."}),t.jsx("ul",{className:"flex flex-col gap-1.5 mb-4",children:e.map(r=>t.jsx("li",{"data-testid":`plan-dep-${r.slug}`,className:"text-sm text-[var(--text-primary)]",children:r.title===null?t.jsxs("span",{className:"text-[var(--text-muted)]",children:["missing: ",r.slug," — was the prerequisite plan deleted?"]}):r.title},r.slug))}),t.jsx("div",{className:"flex flex-col gap-3",children:t.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 Gne=Object.freeze(Object.defineProperty({__proto__:null,PlanRunDependenciesModal:yN},Symbol.toStringTag,{value:"Module"}));function vN({claim:e,onCancel:n,onConfirm:s}){const r=xs(),a=e.claimedBy.agentProvider??"agent",o=e.claimedBy.currentStep??"unknown",i=e.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 p=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]);const u=p=>{p.target===p.currentTarget&&n()};return t.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:t.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:[t.jsx("h2",{"data-testid":"plan-foreign-claim-heading",className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:c}),t.jsxs("div",{className:"text-sm text-[var(--text-muted)] mb-4 flex flex-col gap-1",children:[t.jsxs("span",{"data-testid":"plan-foreign-claim-identity",children:["claimed by ",a,"@",e.claimedBy.machine]}),t.jsxs("span",{children:["started ",Jn(e.claimedBy.startedAt,r)]}),t.jsxs("span",{"data-testid":"plan-foreign-claim-step",children:["on step ",o," (",Jn(e.currentStepEnteredAt,r)," on step)"]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.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"}),t.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 Yne=Object.freeze(Object.defineProperty({__proto__:null,PlanRunForeignClaimModal:vN},Symbol.toStringTag,{value:"Module"}));function xi({dependenciesBySlug:e,claimsBySlug:n,isAgentBuilding:s=!1,onLaunch:r}){const[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),p=m=>{if(s){o(!0);return}const g=pN(e[m]??[]);if(g.length>0){c(g);return}const x=n.get(m);if(x&&x.source!=="local"){u(x);return}r(m)},h=()=>{const m=d;if(m){if(u(null),m.sessionAlive===!1){fetch(`/api/plan-claims/${encodeURIComponent(m.slug)}/reclaim`,{method:"POST"}).catch(()=>{}).finally(()=>r(m.slug));return}r(m.slug)}},f=t.jsxs(t.Fragment,{children:[a&&t.jsx(bN,{onClose:()=>o(!1)}),i&&t.jsx(yN,{deps:i,onClose:()=>c(null)}),d&&t.jsx(vN,{claim:d,onCancel:()=>u(null),onConfirm:h})]});return{requestRun:p,gateModals:f}}function b8(e){const n=/^(\d{1,2})-/.exec(e);return n?parseInt(n[1],10):null}function y8(e,n){if(!n)return null;const s=e?n.selectedMockup:n.filename;return typeof s=="string"&&s.length>0?s:null}function v8(e){return e?`.codeyam/design/rounds/${e}/`:".codeyam/design/project_mockups/"}function j8(e){if(e.designs.length===0)return"";const n=e.designs.map((a,o)=>`${b8(a)??o+1}: ${a}`).join(", "),s=e.roundId?`design round ${e.roundId}`:"project designs",r=e.selected??"none yet";return`(The user is looking at the ${s} in the preview. Designs by the number shown on each card: ${n}. Selected: ${r}. Files are in ${v8(e.roundId)})`}function w8(e){const n=ta(e),[s,r]=l.useState(null);return l.useEffect(()=>{if(!e||n===void 0){r(null);return}let a=!1;return(async()=>{try{const o=n?`/api/editor-mockups?round=${encodeURIComponent(n)}`:"/api/editor-mockups",i=n?"/api/editor-design-round":"/api/editor-design-selection",[c,d]=await Promise.all([fetch(o),fetch(i)]);if(!c.ok)return;const u=await c.json(),p=d.ok?await d.json():null;if(a)return;r({roundId:n,designs:Array.isArray(u)?u.map(h=>h.filename):[],selected:y8(n,p)})}catch{}})(),()=>{a=!0}},[e,n]),s}const jN="codeyam.";function _8(e){try{const n=window.sessionStorage.getItem(jN+e);if(n===null)return null;const s=Number.parseInt(n,10);return Number.isInteger(s)&&s>=0?s:null}catch{return null}}function S8(e,n){try{window.sessionStorage.setItem(jN+e,String(n))}catch{}}function Tm(e,n,s=3){const r=l.useRef(void 0);return r.current===void 0&&(r.current=_8(e)),l.useEffect(()=>{n!==null&&S8(e,n)},[e,n]),r.current??s}function wN(e){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}`)}e==null||e()},[e])}}function k8(){const[e,n]=l.useState(!1),s=ta();return l.useEffect(()=>{if(s===void 0)return;let r=!1;return(async()=>{try{const a=s?`/api/editor-mockups?round=${encodeURIComponent(s)}`:"/api/editor-mockups",o=await fetch(a);if(!o.ok)return;const i=await o.json();if(r)return;n(Array.isArray(i)&&i.length>0)}catch{}})(),()=>{r=!0}},[s]),e}function _N({onToggleDesigns:e,designsOpen:n}){return k8()?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",marginTop:"var(--spacing-md, 12px)",padding:"10px 14px",borderRadius:10,border:"1px solid var(--border-default)",background:"var(--bg-card, #1a1a1a)"},children:[t.jsx("span",{style:{flex:1,fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:n?"Your designs are open in the preview. Close them to get the app back.":"Your designs are still here. Open them to compare, customize, or pick a different one."}),t.jsx("button",{type:"button",onClick:e,style:{padding:"6px 12px",borderRadius:8,border:"1px solid var(--accent-active, #D7FF63)",background:"transparent",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",cursor:"pointer",whiteSpace:"nowrap"},children:n?"Close designs":"Open designs"})]}):null}const Vne=Object.freeze(Object.defineProperty({__proto__:null,PlanDesignsReturnRow:_N},Symbol.toStringTag,{value:"Module"}));function N8(e){return`${e} will remember your plans and suggest them once the current building session is over.`}function SN({providerLabel:e}){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:"Plan your next move"}),t.jsx("p",{className:"mt-1 text-sm text-[var(--text-dim)]",children:N8(e)})]})}const Kne=Object.freeze(Object.defineProperty({__proto__:null,PlanTabHeader:SN},Symbol.toStringTag,{value:"Module"}));function C8(e,n){const r=Mr(e)||"(no request yet, ask the user what to change)";return Mr(`Tweak: ${r} ${n}`)}const Pm="plan";function kN({onClose:e,slashCommand:n=Ob,seedText:s}){l.useEffect(()=>Bd(Pm),[]);const{plans:r}=qr();return t.jsx(aa,{label:"Plan agent",sessionName:"plan session",height:"min(620px, 68vh)",onClose:e,onNeedsYouChange:Q6,onWorkingChange:tB,startFreshOnNewRequest:!0,initialRequest:s??null,renderWrittenFile:a=>{const o=r.find(i=>i.filePath.split("/").pop()===a);return o?t.jsx(_x,{title:o.title,body:o.body}):null},renderTerminal:a=>t.jsx(Ht,{chatName:Pm,slashCommand:n,seedText:s,height:"100%",onClose:e,binding:a})})}const Jne=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthoringChat:kN},Symbol.toStringTag,{value:"Module"}));function NN({chatOpen:e,onChatToggle:n,onChatClose:s,initialDraft:r="",planCompleteSignal:a=0,designContext:o=null}){const i=ep(Ob,r),c=Bo();tp(a,()=>{i.clearDraft(),c.clear()});const d=o?j8(o):"",u=(o==null?void 0:o.designs.length)??0,[p,h]=l.useState(null),f=p!==null,m=!e&&!f,g=y=>{const v=[y,d].filter(Boolean).join(" ");i.open(v||void 0),n()},x=()=>{if(e){n();return}if(c.files.length===0){g("");return}c.save().then(y=>{y!==null&&g(y)})},b=()=>{i.close(),s()};return t.jsxs("div",{"data-testid":"describe-pane",children:[m&&t.jsx(qs,{value:i.draft,onChange:i.setDraft,testId:"plan-describe-input",onSubmit:x,files:c.files,onAddFiles:c.addFiles,onRemoveFile:c.removeFile,busy:c.saving,error:c.error}),m&&d&&t.jsx(Db,{count:u,selected:(o==null?void 0:o.selected)??null}),m&&d&&t.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:t.jsx(Ib,{onClick:()=>h(C8(i.draft,d))})}),f&&t.jsx(Ab,{seedText:p,onClose:()=>h(null)}),e&&t.jsx(kN,{onClose:b,slashCommand:i.seededCommand??void 0,seedText:i.seedText??void 0})]})}const Xne=Object.freeze(Object.defineProperty({__proto__:null,DescribePane:NN},Symbol.toStringTag,{value:"Module"}));function CN({claim:e}){const n=xs(),s=e.claimedBy.agentProvider??"agent",r=e.claimedBy.machine,a=e.claimedBy.currentStep??null,o=Jn(e.currentStepEnteredAt,n),i=Jn(e.claimedBy.startedAt,n),{dead:c}=qy(e);return t.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-${e.slug}`,"data-session-alive":c?"false":void 0,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"font-medium text-sm text-[var(--text-default)]",children:e.title}),t.jsx(Vd,{testId:`in-flight-source-${e.slug}`,children:e.source})]}),t.jsx(Wy,{slug:e.slug,identity:`${s}@${r}`,step:a?`step ${a} · ${o} on step`:null,age:i,dead:c})]})}const Qne=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRow:CN},Symbol.toStringTag,{value:"Module"}));function TN({claims:e}){const[n,s]=l.useState(!1);return e.length===0?null:t.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5","data-testid":"in-flight-section",children:[t.jsx(Kr,{title:"In Flight",count:e.length,expanded:n,onToggle:()=>s(r=>!r),testId:"in-flight-header"}),n&&t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"in-flight-list",children:e.map(r=>t.jsx(CN,{claim:r},`${r.slug}:${r.claimedBy.machine}:${r.claimedBy.sessionId}:${r.claimedBy.pid}:${r.claimedBy.startedAt}`))})]})}const Zne=Object.freeze(Object.defineProperty({__proto__:null,InFlightSection:TN},Symbol.toStringTag,{value:"Module"})),T8=5e3;function P8(){const[e,n]=l.useState([]),[s,r]=l.useState(null),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(null),p=l.useRef(!1),h=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 x=await g.json();if(p.current)return;n(Array.isArray(x.entries)?x.entries:[]),r(x.branch??null),o(x.remote??null)}catch(g){if(p.current)return;u(g instanceof Error?g.message:"Failed to load branch queue"),n([])}finally{p.current||c(!1)}},[]);l.useEffect(()=>{p.current=!1,h();const g=setInterval(()=>{document.visibilityState!=="hidden"&&h()},T8),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{p.current=!0,clearInterval(g),document.removeEventListener("visibilitychange",x)}},[h]);const f=l.useCallback(async(g,x,b)=>{const y={uuid:g,priority:x};typeof b=="number"&&(y.expectedPriority=b);const v=await fetch("/api/branch-queue/set-priority",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y)});if(!v.ok){const j=await v.text().catch(()=>"");throw new Error(`set-priority ${v.status}: ${j}`)}await h()},[h]),m=l.useCallback(async g=>{const x=await fetch("/api/branch-queue/release",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({uuid:g})});if(!x.ok){const b=await x.text().catch(()=>"");throw new Error(`release ${x.status}: ${b}`)}await h()},[h]);return{entries:e,branch:s,remote:a,loading:i,error:d,setPriority:f,release:m,refetch:h}}function O8(){const[e,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:e,dragOverUuid:s,beginDrag:a,hoverOver:o,reset:i}}function R8(e,n){const s=new Map(n.map(i=>[i.uuid,i])),r=[],a=new Set;for(const i of e.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 e.releasedUuids)s.has(i)&&o.add(i);return{order:r,releasedUuids:o}}const E8=new Set;function ol(e,n){return e??{order:[...n],releasedUuids:new Set}}function A8(){const[e,n]=l.useState(null),s=l.useCallback(p=>e?e.order:p,[e]),r=l.useCallback((p,h,f)=>{n(m=>{const g=ol(m,f),x=g.order.findIndex(y=>y.uuid===p),b=g.order.findIndex(y=>y.uuid===h);return x===-1||b===-1||x===b?g:{...g,order:Wr(g.order,x,b)}})},[]),a=l.useCallback((p,h,f)=>{n(m=>{const g=ol(m,f),x=g.order.findIndex(y=>y.uuid===p);if(x===-1)return g;const b=x-h;return b<0||b>=g.order.length?g:{...g,order:Wr(g.order,x,b)}})},[]),o=l.useCallback((p,h)=>{n(f=>{const m=ol(f,h),g=new Set(m.releasedUuids);return g.has(p)?g.delete(p):g.add(p),{...m,releasedUuids:g}})},[]),i=l.useCallback(p=>{n(h=>h?R8(h,p):null)},[]),c=l.useCallback(()=>n(null),[]),d=l.useCallback(p=>e?e.releasedUuids.size>0||e.order.length!==p.length?!0:e.order.some((h,f)=>{var m;return h.uuid!==((m=p[f])==null?void 0:m.uuid)}):!1,[e]),u=l.useCallback(p=>{var x,b;if(!e)return 0;const h=e.releasedUuids,f=p.filter(y=>!h.has(y.uuid)),m=e.order.filter(y=>!h.has(y.uuid));let g=0;for(let y=0;y<m.length;y++)((x=m[y])==null?void 0:x.uuid)!==((b=f[y])==null?void 0:b.uuid)&&g++;return g},[e]);return{isActive:e!==null,displayEntries:s,releasedUuids:(e==null?void 0:e.releasedUuids)??E8,isDirty:d,reorderedCount:u,releasedCount:(e==null?void 0:e.releasedUuids.size)??0,moveByDrag:r,nudge:a,toggleRelease:o,reconcile:i,reset:c}}const M8=10;function I8(e,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=e.filter(d=>!n.has(d.uuid)),i=o.length,c=[];return o.forEach((d,u)=>{const p=r.get(d.uuid);if(!p)return;const h=(i-u)*M8;p.meta.priority!==h&&c.push({uuid:d.uuid,priority:h,expectedPriority:p.meta.priority})}),{releases:a,priorities:c}}function PN({priority:e,uuid:n,onNudge:s}){const r=e===0?"priority 0":e>0?`priority +${e}`:`priority ${e}`;return t.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:[t.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:"−"}),t.jsx("span",{"data-testid":`commit-queue-priority-value-${n}`,children:r}),t.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 ese=Object.freeze(Object.defineProperty({__proto__:null,CommitQueuePriorityChip:PN},Symbol.toStringTag,{value:"Module"}));function ON({entry:e,isHead:n}){const s=xs(),r=e.meta.agentProvider??"agent",a=e.meta.machine,o=e.meta.currentStep??null,i=Jn(e.meta.startedAt??e.committerDate,s);return t.jsxs("div",{className:"flex-1 flex flex-col gap-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-[var(--text-default)] truncate",title:a,"data-testid":`commit-queue-machine-${e.uuid}`,children:a}),n&&t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-strong)]","data-testid":`commit-queue-head-marker-${e.uuid}`,children:"← head"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[t.jsx("span",{"data-testid":`commit-queue-agent-${e.uuid}`,children:r}),o&&t.jsxs("span",{"data-testid":`commit-queue-step-${e.uuid}`,children:["step ",o]}),t.jsxs("span",{"data-testid":`commit-queue-started-${e.uuid}`,children:["started ",i]}),t.jsxs("span",{"data-testid":`commit-queue-pid-${e.uuid}`,children:["pid ",e.meta.pid]})]})]})}const tse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowIdentity:ON},Symbol.toStringTag,{value:"Module"}));function RN({entry:e,position:n,isHead:s,markedForRelease:r,expanded:a,onToggleExpanded:o,onPriorityNudge:i,onToggleRelease:c,onDragStart:d,onDragOver:u,onDrop:p,isDragging:h,isDragOver:f}){return t.jsxs("li",{"data-testid":`commit-queue-row-${e.uuid}`,draggable:!0,onDragStart:m=>{m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",e.uuid),d()},onDragOver:m=>{m.preventDefault(),m.dataTransfer.dropEffect="move",u()},onDrop:m=>{m.preventDefault(),p()},"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)]"} ${h?"opacity-40":""} ${f?"ring-2 ring-[var(--accent-strong)]":""} ${r?"opacity-50 line-through":""}`,children:[t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-3",children:[t.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-${e.uuid}`,children:"⋮⋮"}),t.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)] w-6 text-right","data-testid":`commit-queue-position-${e.uuid}`,children:[n,"."]}),t.jsxs("button",{type:"button",onClick:o,"aria-expanded":a,"data-testid":`commit-queue-toggle-${e.uuid}`,className:"flex min-w-0 flex-1 basis-48 items-center gap-2 bg-transparent text-left cursor-pointer",children:[t.jsx(ON,{entry:e,isHead:s}),t.jsx(Ur,{expanded:a,testId:`commit-queue-chevron-${e.uuid}`})]}),t.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[t.jsx(PN,{priority:e.meta.priority,uuid:e.uuid,onNudge:i}),t.jsx(Wd,{uuid:e.uuid,markedForRelease:r,onToggle:c})]})]}),a&&t.jsx("div",{className:"w-full border-t border-[var(--border-subtle)] pt-2",children:t.jsx(Bb,{entry:e,markedForRelease:r,onToggleRelease:c})})]})}const nse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRow:RN},Symbol.toStringTag,{value:"Module"}));function EN({reorderedCount:e,releasedCount:n,saving:s,onSave:r,onCancel:a}){const o=[];e>0&&o.push(`${e} reordered`),n>0&&o.push(`${n} to remove`);const i=o.join(" · ")||"Unsaved changes";return t.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:[t.jsx("span",{className:"text-xs text-[var(--text-muted)]","data-testid":"commit-queue-save-summary",children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.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"}),t.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 sse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSaveBar:EN},Symbol.toStringTag,{value:"Module"}));function AN({entriesOverride:e,branchOverride:n}={}){const s=P8(),r=e!==void 0,a=e??s.entries,o=n??s.branch,i=O8(),c=A8(),{reconcile:d}=c,[u,p]=l.useState(null),[h,f]=l.useState(!0),[m,g]=l.useState(!1),[x,b]=l.useState(null);if(l.useEffect(()=>{r||d(a)},[a,d,r]),!r&&s.loading&&a.length===0)return null;const y=c.isDirty(a);if(a.length===0||a.length===1&&!y)return null;const v=c.displayEntries(a),j=N=>{var P;const C=i.dragSourceUuid,T=(P=v[N])==null?void 0:P.uuid;i.reset(),!(C===null||!T||C===T)&&c.moveByDrag(C,T,a)},_=(N,C)=>{c.nudge(N.uuid,C,a)},S=N=>{c.toggleRelease(N.uuid,a)},w=()=>{p(null),c.reset()},k=async()=>{const{releases:N,priorities:C}=I8(v,new Set(c.releasedUuids),a);p(null),g(!0);try{if(!r){for(const T of N)await s.release(T);for(const T of C)await s.setPriority(T.uuid,T.priority,T.expectedPriority);await s.refetch()}c.reset()}catch(T){p(T instanceof Error?T.message:"Failed to save changes")}finally{g(!1)}};return t.jsxs("div",{className:"mt-6 border-t border-[var(--border-subtle)] pt-4","data-testid":"commit-queue-section",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(Kr,{title:"Commit Queue",count:v.length,expanded:h,onToggle:()=>f(N=>!N),testId:"commit-queue-header"}),o&&t.jsx("span",{className:"text-[11px] text-[var(--text-dim)]","data-testid":"commit-queue-branch",children:o})]}),u&&t.jsx("div",{className:"mt-2","data-testid":"commit-queue-error",children:t.jsx(dt,{text:u,className:"text-xs text-[var(--accent-danger)]"})}),h&&t.jsx("ol",{className:"mt-3 flex flex-col gap-2","data-testid":"commit-queue-list",children:v.map((N,C)=>t.jsx(RN,{entry:N,position:C+1,isHead:C===0,markedForRelease:c.releasedUuids.has(N.uuid),expanded:x===N.uuid,onToggleExpanded:()=>b(T=>T===N.uuid?null:N.uuid),onPriorityNudge:T=>_(N,T),onToggleRelease:()=>S(N),onDragStart:()=>i.beginDrag(N.uuid),onDragOver:()=>i.hoverOver(N.uuid),onDrop:()=>j(C),isDragging:i.dragSourceUuid===N.uuid,isDragOver:i.dragOverUuid===N.uuid&&i.dragSourceUuid!==N.uuid},N.uuid))}),y&&t.jsx(EN,{reorderedCount:c.reorderedCount(a),releasedCount:c.releasedCount,saving:m,onSave:k,onCancel:w})]})}const rse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSection:AN},Symbol.toStringTag,{value:"Module"}));function D8(e){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(e).getTime()-1).toISOString(),u=await fetch(`/api/journal?since=${encodeURIComponent(d)}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=((await u.json()).entries??[]).find(f=>f.timestamp===e)??null;c||s(h)}catch(d){c||(s(null),i(d instanceof Error?d.message:"Failed to load journal entry"))}finally{c||a(!1)}})(),()=>{c=!0}},[e]),{entry:n,loading:r,error:o}}function MN({journalTimestamp:e}){const{entry:n,loading:s,error:r}=D8(e);return s?t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Loading journal entry…"}):r?t.jsx(dt,{text:`Failed to load journal entry: ${r}`,className:"text-sm text-[var(--accent-red)]"}):n?t.jsx(Eo,{entry:n,defaultExpanded:!0}):t.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No journal entry found for this plan yet."})}const ase=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanExpandedBody:MN},Symbol.toStringTag,{value:"Module"})),Om=160;function L8(e){if(!e)return"";let n=!1;for(const s of e.split(`
|
|
178
|
-
`)){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>Om?`${a.slice(0,Om).trimEnd()}…`:a}return""}function IN({plan:e,expanded:n,onToggle:s,author:r}){const a=L8(e.body);return t.jsxs("li",{className:"border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)]",children:[t.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&&t.jsx(Do,{author:r}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx(Jd,{title:e.title,timestamp:e.completedAt,tone:"muted"}),a&&t.jsx("span",{className:"mt-0.5 block truncate text-xs text-[var(--text-dim)]","data-testid":`completed-plan-excerpt-${e.slug}`,children:a})]}),t.jsx(Kd,{mode:e.mode}),t.jsx(Ur,{expanded:n,testId:"completed-plan-row-chevron"})]}),n&&t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]","data-testid":"completed-plan-row-body",children:t.jsx(MN,{journalTimestamp:e.journalTimestamp})})]})}const ose=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanRow:IN},Symbol.toStringTag,{value:"Module"}));function DN({plans:e,loading:n,error:s,showAuthors:r=!1,skeletonCount:a=3}){const[o,i]=l.useState(null),[c,d]=l.useState(!1),p=n&&e.length===0?a:e.length;return t.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5",children:[t.jsx(Kr,{title:"Completed Plans",count:p,expanded:c,onToggle:()=>d(h=>!h),testId:"completed-plans-header"}),c&&t.jsx(LN,{plans:e,loading:n,error:s,expandedSlug:o,onToggle:h=>i(f=>f===h?null:h),showAuthors:r,skeletonCount:a})]})}function LN({plans:e,loading:n,error:s,expandedSlug:r,onToggle:a,showAuthors:o=!1,skeletonCount:i=3}){const c=s?t.jsx(dt,{text:`Failed to load completed plans: ${s}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):null;return n&&e.length===0?t.jsx(Yd,{count:i,testId:"recent-plans-skeleton-list",label:"Loading completed plans"}):e.length===0?c:t.jsxs(t.Fragment,{children:[c,t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"recent-plans-list",children:e.map(d=>t.jsx(IN,{plan:d,expanded:r===d.slug,onToggle:()=>a(d.slug),author:o?d.author:void 0},d.slug))})]})}const ise=Object.freeze(Object.defineProperty({__proto__:null,RecentPlansBody:LN,RecentPlansSection:DN},Symbol.toStringTag,{value:"Module"}));function $N({chatOpen:e,onChatOpenChange:n,isActive:s=!0,isAgentBuilding:r=!1,launchingSlug:a,launchError:o,onLaunchPlan:i,planCompleteSignal:c=0,onToggleDesigns:d,designsOpen:u=!1}={}){const{plans:p,loading:h,error:f,refetch:m}=qr(),{claims:g}=Op(),{slugs:x}=fd(),{status:b}=Rp(),{staleness:y}=o8(),v=((b==null?void 0:b.consecutiveFailures)??0)>=3,{plans:j,loading:_,error:S}=hd(),w=Tm("plan-tab.queued-count",h?null:p.length),k=Tm("plan-tab.completed-count",_?null:j.length),{config:N}=Pt(),C=st(N==null?void 0:N.provider),T=i!==void 0,P=xN(),R=T?a??null:P.launchingSlug,L=T?o??null:P.error,[M,O]=l.useState(!1),z=l.useMemo(()=>Ap(g),[g]),I=l.useMemo(()=>c8(g,x),[g,x]),Y=l.useMemo(()=>uN([...p.map(E=>E.author),...j.map(E=>E.author)]),[p,j]),W=e!==void 0,A=W?e:M,B=E=>{W||O(E),n==null||n(E)},D=()=>{B(!1),m()},J=()=>{const E=!A;E&&Tt(),B(E)};l.useEffect(()=>{if(!(!s||!A))return Tt()},[s,A]);const{annotationsBySlug:te,dependenciesBySlug:oe}=Mp(p),se=w8(u),G=E=>{var U;const H=((U=p.find(pe=>pe.slug===E))==null?void 0:U.title)??E;if(i){i(E,H);return}P.launchPlan(E,H)},{requestRun:le,gateModals:ue}=xi({dependenciesBySlug:oe,claimsBySlug:z,isAgentBuilding:r,onLaunch:G}),{reorderPlans:ne}=wN(m);return t.jsxs(Kt,{testId:"plan-tab",children:[t.jsx(SN,{providerLabel:C}),d?t.jsx(_N,{onToggleDesigns:d,designsOpen:u}):null,t.jsx(NN,{chatOpen:A,onChatToggle:J,onChatClose:D,planCompleteSignal:c,designContext:se}),t.jsx(Ep,{staleness:y}),t.jsx(dN,{status:b}),t.jsx(mi,{plans:p,loading:h,error:f,onRun:le,launchingSlug:R,launchError:L,blocked:r,onReorder:ne,depAnnotationsBySlug:te,dependenciesBySlug:oe,claimsBySlug:z,staleFetch:v,skeletonCount:w,showAuthors:Y}),t.jsx(TN,{claims:I}),t.jsx(AN,{}),t.jsx(DN,{plans:j,loading:_,error:S,skeletonCount:k,showAuthors:Y}),ue]})}const lse=Object.freeze(Object.defineProperty({__proto__:null,PlanTab:$N},Symbol.toStringTag,{value:"Module"}));function FN({activeTab:e,planActivated:n,chatOpen:s,onChatOpenChange:r,isAgentBuilding:a=!1,launchingPlanSlug:o,planLaunchError:i,onLaunchPlan:c,planCompleteSignal:d=0,onToggleDesigns:u,designsOpen:p=!1}){return n?t.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:e==="plan"?"visible":"hidden",pointerEvents:e==="plan"?"auto":"none"},children:t.jsx($N,{chatOpen:s,onChatOpenChange:r,isActive:e==="plan",isAgentBuilding:a,launchingSlug:o,launchError:i,onLaunchPlan:c,planCompleteSignal:d,onToggleDesigns:u,designsOpen:p})}):null}const cse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPlanLayer:FN},Symbol.toStringTag,{value:"Module"}));function zN({projectTitle:e}){return t.jsxs("div",{"data-testid":"design-session-brand-row",style:{display:"flex",alignItems:"center",gap:9,padding:"14px 14px 10px",flex:"none"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:28,height:28,borderRadius:7,background:"var(--accent-active)",color:"#1B1D26",display:"grid",placeItems:"center",flex:"none"},children:t.jsx(ms,{markOnly:!0,markTone:"inherit",className:"h-4"})}),t.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:(e==null?void 0:e.trim())||"New project"}),t.jsx("span",{style:{color:"var(--text-dim)",fontSize:13,flex:"none"},children:"/"}),t.jsx("span",{style:{color:"var(--text-muted)",fontSize:13,flex:"none"},children:"Design session"})]})}const dse=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionBrandRow:zN},Symbol.toStringTag,{value:"Module"})),$8="desktop",Rm="codeyam:isDesktopApp";function F8(e=typeof window<"u"?window:void 0){var o,i,c;if(!e)return!1;try{if(((o=e.sessionStorage)==null?void 0:o.getItem(Rm))==="1")return!0}catch{}const s=new URLSearchParams(((i=e.location)==null?void 0:i.search)??"").get($8)==="1",r=typeof e.__TAURI__<"u",a=s||r;if(a)try{(c=e.sessionStorage)==null||c.setItem(Rm,"1")}catch{}return a}const Em={renamed:{},deleted:[]},BN=e=>`codeyam.chat-history-edits:${e}`;function z8(e,n){return e.filter(s=>!n.deleted.includes(s.id)).map(s=>n.renamed[s.id]?{...s,title:n.renamed[s.id]}:s)}function B8(e){try{const n=window.localStorage.getItem(BN(e));if(!n)return Em;const s=JSON.parse(n);return{renamed:s.renamed&&typeof s.renamed=="object"?s.renamed:{},deleted:Array.isArray(s.deleted)?s.deleted:[]}}catch{return Em}}function W8(e,n){try{window.localStorage.setItem(BN(e),JSON.stringify(n))}catch{}}function H8(e){if(!e||typeof e!="object")return[];const n=e.sessions;return Array.isArray(n)?n.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;return typeof r.id!="string"||typeof r.title!="string"?[]:[{id:r.id,title:r.title,updatedAt:typeof r.updatedAt=="string"?r.updatedAt:""}]}):[]}function q8(e,n){var s;return((s=e.find(r=>!n.includes(r.id)))==null?void 0:s.id)??null}const U8=3e3;function G8(e){const[n,s]=l.useState([]);return l.useEffect(()=>{let r=!1,a="";const o=async()=>{try{const c=await fetch("/api/editor-chat-sessions");if(!c.ok)return;const d=await c.text();if(r||d===a)return;a=d,s(H8(JSON.parse(d)))}catch{}};o();const i=window.setInterval(()=>void o(),U8);return()=>{r=!0,window.clearInterval(i)}},[e]),n}const Tc=22,Pc=14,Am=3;function Y8(){const e=Array.from({length:Pc},()=>Array(Tc).fill(".")),n=10.6,s=Am+5.2,r=10.4,a=5.3;for(let i=Am;i<Pc;i++)for(let c=0;c<Tc;c++){const d=(c+.5-n)/r,u=(i+.5-s)/(a*(1-.22*d));d*d+u*u<=1&&(e[i][c]="b")}return[[0,8],[0,9],[0,12],[0,13],[1,9],[1,10],[1,11],[1,12],[2,10],[2,11]].forEach(([i,c])=>{e[i][c]="g"}),[[7,7],[8,7],[7,13],[8,13]].forEach(([i,c])=>{e[i][c]="e"}),[[10,9],[10,10],[10,11]].forEach(([i,c])=>{e[i][c]="m"}),[[10,8],[10,12]].forEach(([i,c])=>{e[i][c]="c"}),e}const V8=Y8(),on=10,Ws=12,WN={g:"#a9d94a",b:"#d7ff63",e:"#1b1d24",m:"#1b1d24",c:"#1b1d24"},K8=.35;function bi(e){const n=[];return V8.forEach((s,r)=>s.forEach((a,o)=>{if(!e.includes(a))return;const i=a==="c"?K8*on:0;n.push({x:Ws+o*on,y:Ws+r*on-i,color:WN[a]})})),n}const J8=bi(["b","c","e","m"]).map(e=>({...e,y:Math.round((e.y-Ws)/on)*on+Ws,color:WN.b})),X8=bi(["g"]),Q8=bi(["e"]),Z8=bi(["m","c"]),eW=`
|
|
179
|
-
.pixel-yam-bob { transform-box: fill-box; transform-origin: 50% 100%; animation: pixel-yam-bob 2.4s ease-in-out infinite; }
|
|
180
|
-
.pixel-yam-blink { transform-box: fill-box; transform-origin: center; animation: pixel-yam-blink 4.2s infinite; }
|
|
181
|
-
.pixel-yam-look { transition: transform 180ms ease-out; }
|
|
182
|
-
@media (prefers-reduced-motion: reduce) { .pixel-yam-look { transition: none; } }
|
|
183
|
-
@keyframes pixel-yam-bob {
|
|
184
|
-
0%, 100% { transform: translateY(0) rotate(-3deg); }
|
|
185
|
-
50% { transform: translateY(-14px) rotate(3deg); }
|
|
186
|
-
}
|
|
187
|
-
@keyframes pixel-yam-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.12); } }
|
|
188
|
-
@media (prefers-reduced-motion: reduce) { .pixel-yam-bob, .pixel-yam-blink { animation: none; } }
|
|
189
|
-
`,tW=10,Mm=240;function HN(e,n){const s=Math.hypot(e,n);if(s===0)return{x:0,y:0};const r=Math.min(s,Mm)/Mm*tW;return{x:e/s*r,y:n/s*r*.6}}function qN({width:e=72}){const n=`pixel-yam-goo-${l.useId().replace(/:/g,"")}`,s=l.useRef(null),r=l.useRef(null);l.useEffect(()=>{var d;if((d=window.matchMedia)!=null&&d.call(window,"(prefers-reduced-motion: reduce)").matches)return;const c=u=>{const p=s.current,h=r.current;if(!p||!h)return;const f=p.getBoundingClientRect(),m=HN(u.clientX-(f.left+f.width/2),u.clientY-(f.top+f.height/2));h.style.transform=`translate(${m.x.toFixed(1)}px, ${m.y.toFixed(1)}px)`};return window.addEventListener("pointermove",c),()=>window.removeEventListener("pointermove",c)},[]);const a=Tc*on+Ws*2,o=Pc*on+Ws*2,i=(c,d)=>t.jsx("g",{filter:`url(#${n})`,className:d,children:c.map(u=>t.jsx("rect",{x:u.x,y:u.y,width:on+.5,height:on+.5,fill:u.color},`${u.x}-${u.y}`))});return t.jsxs("svg",{ref:s,"data-testid":"pixel-yam",viewBox:`0 0 ${a} ${o}`,width:e,height:e*o/a,"aria-hidden":"true",style:{overflow:"visible"},children:[t.jsx("defs",{children:t.jsxs("filter",{id:n,x:"-20%",y:"-20%",width:"140%",height:"140%",colorInterpolationFilters:"sRGB",children:[t.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:on*.3,result:"b"}),t.jsx("feColorMatrix",{in:"b",type:"matrix",values:"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10",result:"g"}),t.jsx("feComposite",{in:"SourceGraphic",in2:"g",operator:"atop"})]})}),t.jsx("style",{children:eW}),t.jsxs("g",{className:"pixel-yam-bob",children:[i(X8),i(J8),i(Z8),t.jsx("g",{ref:r,className:"pixel-yam-look","data-testid":"pixel-yam-eyes",children:i(Q8,"pixel-yam-blink")})]})]})}const use=Object.freeze(Object.defineProperty({__proto__:null,PixelYam:qN,lookOffset:HN},Symbol.toStringTag,{value:"Module"})),UN=["Which external services does this project need?","What is built and what is left?","What should I work on next?"];function GN({draft:e,onDraftChange:n,onSend:s,providerLabel:r,attachments:a}){return t.jsxs("div",{"data-testid":"chat-hero",className:"flex-1 min-h-0 flex flex-col",children:[t.jsx("div",{className:"flex-1 min-h-0 flex items-center justify-center overflow-y-auto px-4",children:t.jsxs("div",{className:"w-full max-w-[680px] py-10",children:[t.jsx("div",{className:"mb-5 flex justify-center",children:t.jsx(qN,{})}),t.jsx("h1",{className:"text-center text-2xl font-medium text-[var(--text-primary)]",children:"How can I help?"}),t.jsx("p",{className:"mt-2 text-center text-sm text-[var(--text-dim)]",children:"Ask about this project, what to build next, or which services to use. Nothing here changes your code."})]})}),t.jsxs("div",{"data-testid":"chat-hero-dock",className:"mx-auto w-full max-w-[760px] px-3 pb-4",children:[t.jsx("div",{className:"mb-3 flex flex-wrap justify-center gap-2",children:UN.map(o=>t.jsx("button",{type:"button",onClick:()=>n(o),"data-testid":"chat-hero-suggestion",className:"rounded-full border border-[var(--border-default)] px-3 py-1.5 text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] hover:border-[var(--text-dim)] cursor-pointer transition-colors",children:o},o))}),t.jsx(qs,{value:e,onChange:n,onSubmit:s,canSubmit:e.trim()!=="",placeholder:`Ask ${r} anything`,minHeight:40,testId:"chat-hero-input",files:a.files,onAddFiles:a.addFiles,onRemoveFile:a.removeFile,busy:a.saving,error:a.error})]})]})}const pse=Object.freeze(Object.defineProperty({__proto__:null,CHAT_HERO_SUGGESTIONS:UN,ChatHero:GN},Symbol.toStringTag,{value:"Module"})),YN="codeyam:chat-history-collapsed";function nW(){try{return window.localStorage.getItem(YN)==="1"}catch{return!1}}function sW(e){try{window.localStorage.setItem(YN,e?"1":"0")}catch{}}function VN({sessions:e,activeId:n,onSelect:s,onNewChat:r,liveId:a=null,liveStatus:o="idle",onDelete:i,onRename:c}){const[d,u]=l.useState(null),[p,h]=l.useState(null),[f,m]=l.useState(""),[g,x]=l.useState(nW),b=!!(i||c),y=()=>{x(_=>(sW(!_),!_))},v=f.trim().toLowerCase(),j=v?e.filter(_=>_.title.toLowerCase().includes(v)):e;return g?t.jsxs("aside",{"data-testid":"chat-history","data-collapsed":"true",className:"w-12 shrink-0 flex flex-col items-center gap-2 min-h-0 border-r border-[var(--border-subtle)] py-2",children:[t.jsx("button",{type:"button","aria-label":"Show chats",title:"Show chats",onClick:y,className:"grid h-8 w-8 place-items-center rounded-lg text-[var(--text-dim)] cursor-pointer hover:bg-white/[0.08] hover:text-[var(--text-primary)]",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"2"}),t.jsx("path",{d:"M6 2.5v11"})]})}),t.jsx("button",{type:"button","aria-label":"New chat",title:"New chat",onClick:r,"data-testid":"chat-new",className:"grid h-8 w-8 place-items-center rounded-lg border border-[rgba(215,255,99,.3)] bg-[rgba(215,255,99,.08)] text-[var(--accent-active)] text-lg leading-none cursor-pointer hover:bg-[rgba(215,255,99,.14)]",children:t.jsx("span",{"aria-hidden":"true",children:"+"})})]}):t.jsxs("aside",{"data-testid":"chat-history",className:"w-[240px] shrink-0 flex flex-col min-h-0 border-r border-[var(--border-subtle)] p-2",children:[t.jsxs("div",{className:"flex items-center justify-between px-2 pt-1",children:[t.jsx("span",{className:"text-[13px] font-medium text-[var(--text-secondary)]",children:"Chats"}),t.jsx("button",{type:"button","aria-label":"Hide chats",title:"Hide chats",onClick:y,className:"grid h-7 w-7 place-items-center rounded-md text-[var(--text-dim)] cursor-pointer hover:bg-white/[0.08] hover:text-[var(--text-primary)]",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"2"}),t.jsx("path",{d:"M6 2.5v11"})]})})]}),t.jsxs("button",{type:"button",onClick:r,"data-testid":"chat-new","aria-current":n===null?"true":void 0,className:"mt-2 flex items-center gap-2 rounded-lg border border-[rgba(215,255,99,.3)] bg-[rgba(215,255,99,.08)] px-3 py-1.5 text-[13px] font-medium text-[var(--accent-active)] cursor-pointer transition-colors hover:bg-[rgba(215,255,99,.14)]",children:[t.jsx("span",{"aria-hidden":"true",className:"text-[15px] leading-none",children:"+"}),"New chat"]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-dim)]",children:t.jsx(su,{})}),t.jsx("input",{type:"search",value:f,onChange:_=>m(_.target.value),placeholder:"Search chats","aria-label":"Search chats",className:`w-full rounded-lg ${qo} py-1.5 pl-8 pr-3 text-[13px] text-[var(--text-secondary)] placeholder:text-[var(--text-dim)] outline-none focus:border-[var(--lime-300)]`})]}),t.jsx("div",{className:"mt-4 px-2 text-[11px] uppercase tracking-wider text-[var(--text-dim)]",children:"Recent"}),t.jsx("div",{className:"mt-1 flex-1 min-h-0 overflow-y-auto",children:e.length===0?t.jsx("p",{className:"px-3 py-2 text-xs text-[var(--text-dim)]",children:"Your chats will show up here."}):j.length===0?t.jsxs("p",{className:"px-3 py-2 text-xs text-[var(--text-dim)]",children:["No chats match “",f.trim(),"”."]}):j.map(_=>{const S=_.id===n,w=_.id===a;return t.jsxs("div",{className:`group relative flex items-center rounded-lg transition-colors ${S?"bg-white/[0.07]":"hover:bg-white/[0.04]"}`,children:[w&&t.jsx(KN,{status:o}),p===_.id&&c?t.jsx(XN,{initial:_.title,onDone:k=>{h(null),k&&k!==_.title&&c(_.id,k)}}):t.jsx("button",{type:"button",onClick:()=>s(_.id),title:_.title,"aria-current":S?"true":void 0,"data-testid":"chat-history-row",className:`block min-w-0 flex-1 truncate py-1.5 pr-1 text-[13px] text-left cursor-pointer transition-colors ${w?"pl-1.5":"pl-2"} ${S?"text-[var(--text-primary)]":"text-[var(--text-muted)] group-hover:text-[var(--text-secondary)]"}`,children:_.title}),b&&p!==_.id&&t.jsx("button",{type:"button","aria-label":"Chat options","aria-haspopup":"menu","aria-expanded":d===_.id,onClick:()=>u(k=>k===_.id?null:_.id),className:`mr-1 grid h-6 w-6 shrink-0 place-items-center rounded-md text-[var(--text-dim)] hover:bg-white/10 hover:text-[var(--text-primary)] cursor-pointer ${S||d===_.id?"":"opacity-0 group-hover:opacity-100 focus:opacity-100"}`,children:t.jsx("span",{"aria-hidden":"true",children:"⋯"})}),d===_.id&&t.jsx(JN,{onClose:()=>u(null),onRename:c?()=>{u(null),h(_.id)}:void 0,onDelete:i?()=>{u(null),i(_.id)}:void 0})]},_.id)})})]})}function KN({status:e}){return t.jsx("span",{"data-testid":"chat-history-live-dot","data-status":e,role:"img","aria-label":e==="needs-you"?"Waiting on you":e==="working"?"Working":"In progress",className:e==="idle"?"":"animate-pulse",style:{marginLeft:10,width:7,height:7,borderRadius:"50%",flex:"none",background:e==="needs-you"?ht:"var(--working)"}})}function JN({onRename:e,onDelete:n,onClose:s}){const r=l.useRef(null);l.useEffect(()=>{const o=c=>{r.current&&!r.current.contains(c.target)&&s()},i=c=>{c.key==="Escape"&&s()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",i)}},[s]);const a="block w-full rounded-md px-3 py-1.5 text-left text-xs cursor-pointer hover:bg-white/[.06]";return t.jsxs("div",{ref:r,role:"menu",className:"absolute right-1 top-full z-20 mt-1 w-32 rounded-lg border border-white/10 bg-[#1f1f1f] p-1 shadow-2xl",children:[e&&t.jsx("button",{type:"button",role:"menuitem",onClick:e,className:`${a} text-[var(--text-primary)]`,children:"Rename"}),n&&t.jsx("button",{type:"button",role:"menuitem",onClick:n,className:`${a} text-[var(--accent-danger,#f87171)]`,children:"Delete"})]})}function XN({initial:e,onDone:n}){const[s,r]=l.useState(e),a=l.useRef(!1),o=i=>{a.current||(a.current=!0,n(i))};return t.jsx("input",{autoFocus:!0,"aria-label":"Chat name",value:s,onChange:i=>r(i.target.value),onFocus:i=>i.target.select(),onBlur:()=>o(s.trim()),onKeyDown:i=>{i.key==="Enter"?o(s.trim()):i.key==="Escape"&&o(e)},className:"mx-1 my-0.5 min-w-0 flex-1 rounded-md border border-white/20 bg-transparent px-2 py-1 text-sm text-[var(--text-primary)] outline-none focus:border-white/40"})}const hse=Object.freeze(Object.defineProperty({__proto__:null,ChatHistorySidebar:VN,LiveDot:KN,RenameField:XN,RowMenu:JN},Symbol.toStringTag,{value:"Module"})),rW=1500;function QN(e,n){const[s,r]=l.useState(Ar);return l.useEffect(()=>{if(r(Ar),!e)return;let a=!1,o="";const i=async()=>{try{const d=await fetch(`/api/editor-chat-session?id=${encodeURIComponent(e)}`);if(!d.ok)return;const u=await d.text();if(a||u===o)return;o=u,r(lx(JSON.parse(u)))}catch{}};i();const c=n?window.setInterval(()=>void i(),rW):void 0;return()=>{a=!0,c!==void 0&&window.clearInterval(c)}},[e,n]),s}const ZN=90,e2=15e3;function t2({chatKey:e,sessionId:n,question:s,onStatusChange:r}){const[a,o]=l.useState("chat"),[i,c]=l.useState(null),[d]=l.useState({chatKey:e,question:s}),[u,p]=l.useState(null),[h,f]=l.useState(s?[{id:`question-${e}`,text:s,after:0}]:[]),m=QN(n,!0),g=l.useCallback(A=>c(()=>A),[]),x=l.useRef(e);l.useEffect(()=>{e!==x.current&&(x.current=e,f([{id:`question-${e}`,text:s,after:0}]),p(Ls(oo,s)))},[e,s]),l.useEffect(()=>{!u||!i||Cr(i,u)&&p(null)},[u,i]);const[b,y]=l.useState(!1);l.useEffect(()=>{if(y(!1),m.available)return;const A=window.setTimeout(()=>y(!0),e2);return()=>window.clearTimeout(A)},[m.available,e]);const[v,j]=l.useState(null),_=async(A,B)=>{if(!i)return!1;j(null);let D=A;if(B.length>0){try{await Us(B.map((oe,se)=>({id:`chat-${Date.now()}-${se}`,file:oe,relativePath:oe.name,description:""})))}catch(oe){return j(oe instanceof Error?oe.message:"Couldn't add those files."),!1}const te=Mo(B.map(oe=>oe.name));D=A?`${te} ${A}`:te}const J=_d(D);return Cr(i,J)?(f(te=>[...te,{id:`${Date.now()}-${te.length}`,text:J.replace(/\r$/,""),after:m.messages.length}]),!0):!1},[S,w]=l.useState(null),k=l.useMemo(()=>zu(S),[S]),N=l.useMemo(()=>Gu(S),[S]),C=!!k||!!N,T=A=>{i&&A.forEach((B,D)=>{window.setTimeout(()=>i(B),D*ZN)})},P=A=>{k&&T(na(k,A))},R=(A,B)=>{k&&T(oi(k,A,B))},L=ii(m.messages,h).some(A=>A.id.startsWith("pending-")),M=!C&&(m.working||L),O=m.messages[m.messages.length-1],z=C||!M&&(O==null?void 0:O.role)==="agent",I=!M&&!C&&(O==null?void 0:O.role)==="agent"&&wd(O.text),Y=M?"working":z?"needs-you":"idle",W=l.useRef(r);return W.current=r,l.useEffect(()=>{var A;(A=W.current)==null||A.call(W,Y)},[Y]),t.jsx(Gr.Provider,{value:A=>void _(A,[]),children:t.jsxs("div",{"data-testid":"chat-live",className:"flex-1 min-h-0 flex flex-col",children:[t.jsx("div",{className:"flex items-center justify-end px-4 py-2",children:t.jsx(ri,{view:a,onChange:o})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{"data-testid":"chat-live-terminal",className:"absolute inset-0 overflow-auto px-4",style:{visibility:a==="chat"?"hidden":"visible"},children:t.jsx("div",{className:"mx-auto w-full max-w-[860px]",children:t.jsx(Ht,{chatName:"chat",slashCommand:Ls(oo,d.question),seedText:d.question||void 0,height:520,onInputChannel:g,onScreen:w})})}),a==="chat"&&t.jsxs("div",{"data-testid":"chat-live-messages",className:"absolute inset-0 z-[1] flex flex-col",style:{background:"var(--bg-deep)"},children:[t.jsx("div",{className:"flex-1 min-h-0 flex justify-center",children:t.jsx("div",{className:"w-full max-w-[760px] min-h-0 flex flex-col",children:t.jsx(sa,{messages:m.messages,working:M,waiting:C,pending:h,onOpenTerminal:()=>o("terminal")})})}),t.jsxs("div",{className:"mx-auto w-full max-w-[760px] pb-4",children:[k&&t.jsx("div",{className:"mb-2","data-testid":"chat-live-card-slot",style:{padding:`0 ${cn}px`},children:t.jsx(ci,{prompt:k,onChoose:P,onAnswer:R,onOpenTerminal:()=>o("terminal")})}),N&&!k&&t.jsx("div",{className:"mb-2","data-testid":"chat-live-card-slot",style:{padding:`0 ${cn}px`},children:t.jsx(Io,{login:N,onSubmitCode:A=>T([A,"\r"]),onOpenTerminal:()=>o("terminal")})}),b&&!C&&t.jsxs("p",{"data-testid":"chat-log-missing",className:"mb-2 text-xs text-[var(--text-dim)]",style:{padding:`0 ${cn}px`},children:["The chat can't read this conversation yet."," ",t.jsx("button",{type:"button",onClick:()=>o("terminal"),className:"underline cursor-pointer text-[var(--text-primary)]",children:"Open the terminal"})," ","to follow it there."]}),t.jsx(li,{disabled:!i,busyNote:v,awaiting:I,onSend:_},e)]})]})]})]})})}const fse=Object.freeze(Object.defineProperty({__proto__:null,CHAT_LOG_MISSING_AFTER_MS:e2,ChatLiveConversation:t2,TERMINAL_KEY_GAP_MS:ZN},Symbol.toStringTag,{value:"Module"}));function n2({sessionId:e,onNewChat:n,onContinue:s}){const r=QN(e,!1),a="rounded-lg bg-[var(--accent-active)] px-3 py-1.5 text-xs font-medium text-[var(--text-on-accent)] hover:opacity-90 cursor-pointer";return t.jsxs("div",{"data-testid":"chat-past",className:"flex-1 min-h-0 flex flex-col",children:[t.jsx("div",{className:"flex-1 min-h-0 flex justify-center",children:t.jsx("div",{className:"w-full max-w-[760px] min-h-0 flex flex-col",children:t.jsx(sa,{messages:r.messages,working:!1,emptyState:t.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"Loading this chat…"})})})}),t.jsx("div",{className:"mx-auto w-full max-w-[760px] px-3 pb-4",children:t.jsx("div",{className:"flex items-center justify-between gap-3 rounded-2xl border border-[var(--border-subtle)] px-4 py-3 text-sm text-[var(--text-dim)]",children:s?t.jsxs(t.Fragment,{children:["Pick this chat up where it left off.",t.jsx("button",{type:"button",onClick:s,"data-testid":"chat-past-continue",className:a,children:"Continue this chat"})]}):t.jsxs(t.Fragment,{children:["This chat has ended.",t.jsx("button",{type:"button",onClick:n,"data-testid":"chat-past-new",className:a,children:"New chat"})]})})})]})}const mse=Object.freeze(Object.defineProperty({__proto__:null,ChatPastConversation:n2},Symbol.toStringTag,{value:"Module"}));function s2(){var L;const[e,n]=l.useState(""),[s,r]=l.useState(null),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=G8(!0),u=Bo(),{config:p}=Pt(),h=st(p==null?void 0:p.provider),f=(p==null?void 0:p.projectTitle)??"project",[m,g]=l.useState(()=>B8(f)),x=M=>{g(M),W8(f,M)},[b,y]=l.useState("idle");l.useEffect(()=>{mm(b==="working"),gm(b==="needs-you")},[b]),l.useEffect(()=>()=>{mm(!1),gm(!1)},[]);const v=s?s.resumeId??q8(d,s.knownIds):null,j=a?v:null,_=i!==null&&i!==j,S=a&&!_,w=z8(d,m),k=((L=w[0])==null?void 0:L.id)??null,N=i!==null&&i===k&&(!s||v===i),C=()=>{i&&(s||r({key:1,question:"",knownIds:[],resumeId:i}),o(!0),c(null))},T=M=>{r(O=>({key:((O==null?void 0:O.key)??0)+1,question:M,knownIds:d.map(z=>z.id)})),o(!0),n(""),c(null)},P=()=>{const M=Mr(e);if(M){if(u.files.length===0){T(M);return}u.save().then(O=>{O!==null&&(u.clear(),T([O,M].filter(Boolean).join(" ")))})}},R=()=>{o(!1),c(null)};return t.jsxs("div",{"data-testid":"chat-tab",className:"flex-1 min-h-0 flex",style:{background:"var(--bg-deep)"},children:[t.jsx(VN,{sessions:w,activeId:_?i:j,onSelect:c,onNewChat:R,liveId:v,liveStatus:b,onRename:(M,O)=>x({...m,renamed:{...m.renamed,[M]:O}}),onDelete:M=>{x({...m,deleted:[...m.deleted,M]}),i===M&&c(null),j===M&&R()}}),t.jsxs("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[s&&t.jsx("div",{className:"flex-1 min-h-0 flex-col",style:{display:S?"flex":"none"},children:t.jsx(t2,{chatKey:s.key,sessionId:v,question:s.question,onStatusChange:y})}),_&&t.jsx(n2,{sessionId:i,onNewChat:R,onContinue:N?C:void 0},i),!S&&!_&&t.jsx(GN,{draft:e,onDraftChange:n,onSend:P,providerLabel:h,attachments:u})]})]})}const gse=Object.freeze(Object.defineProperty({__proto__:null,ChatTab:s2},Symbol.toStringTag,{value:"Module"}));function r2({activeTab:e}){const n=e==="chat",[s,r]=l.useState(n);return l.useEffect(()=>{n&&r(!0)},[n]),s?t.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx(s2,{})}):null}const xse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellChatLayer:r2},Symbol.toStringTag,{value:"Module"}));function a2({visible:e,children:n}){return t.jsx("div",{className:"absolute inset-0 flex flex-col overflow-auto",style:{visibility:e?"visible":"hidden"},children:n})}const bse=Object.freeze(Object.defineProperty({__proto__:null,TabPane:a2},Symbol.toStringTag,{value:"Module"}));function o2({activeTab:e,children:n}){const s=["home","build","plan","history","reviews","settings"];return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:s.map(r=>t.jsx(a2,{visible:e===r,children:n[r]},r))})}const yse=Object.freeze(Object.defineProperty({__proto__:null,LeftPanel:o2},Symbol.toStringTag,{value:"Module"}));function i2({label:e,description:n,checked:s,disabled:r=!1,onChange:a,children:o}){return t.jsxs("div",{className:"py-3.5",style:{borderTop:"1px solid var(--border-default)"},children:[t.jsxs("label",{className:`flex items-center gap-4 ${r?"cursor-default":"cursor-pointer"}`,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"text-[13px] block",style:{color:"var(--text-primary)"},children:e}),t.jsx("span",{className:"text-[12px] block mt-0.5",style:{color:"var(--text-muted)"},children:n})]}),t.jsx("input",{type:"checkbox",checked:s,disabled:r,onChange:i=>a(i.target.checked),className:"peer sr-only"}),t.jsx("span",{"aria-hidden":"true","data-testid":"check-in-switch",className:"relative h-5 w-9 shrink-0 rounded-full transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--accent-active)] peer-disabled:opacity-50",style:{background:s?"var(--accent-active)":"rgba(255,255,255,.14)"},children:t.jsx("span",{className:"absolute top-0.5 h-4 w-4 rounded-full transition-all",style:{left:s?18:2,background:s?"#0f0f0f":"rgba(255,255,255,.75)"}})})]}),o]})}const vse=Object.freeze(Object.defineProperty({__proto__:null,CheckInToggleRow:i2},Symbol.toStringTag,{value:"Module"}));function Dp({options:e,value:n,onChange:s,disabled:r=!1,ariaLabel:a}){return t.jsx("div",{className:`${Qr} self-start`,role:a?"radiogroup":void 0,"aria-label":a,children:e.map(o=>{const i=o.value===n;return t.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:Gs(i),children:o.label},o.value)})})}const jse=Object.freeze(Object.defineProperty({__proto__:null,SegmentedPicker:Dp},Symbol.toStringTag,{value:"Module"})),aW=[{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 l2({autoAction:e,branchState:n,disabled:s=!1,onChange:r}){return n.onPrimaryBranch?t.jsx("div",{className:"mt-2 ml-6",children:t.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."]})}):t.jsxs("div",{className:"mt-2 ml-6",children:[t.jsx("div",{className:"text-[11px] mb-1",style:{color:"var(--text-muted)"},children:"When it runs on its own"}),t.jsx(Dp,{options:aW,value:e,onChange:r,disabled:s,ariaLabel:"Autonomous commit action"})]})}const wse=Object.freeze(Object.defineProperty({__proto__:null,HardeningAutoAction:l2},Symbol.toStringTag,{value:"Module"})),c2={checkIns:{planAccepted:{pause:!0},prototypeCompleted:{pause:!0},hardeningCompleted:{pause:!0,autoAction:"commit"},push:{pause:!0}}};function Im(e){const n=(e==null?void 0:e.checkIns)??{},s=c2.checkIns;return{checkIns:{planAccepted:n.planAccepted??s.planAccepted,prototypeCompleted:n.prototypeCompleted??s.prototypeCompleted,hardeningCompleted:n.hardeningCompleted??s.hardeningCompleted,push:n.push??s.push}}}function oW(){const[e,n]=l.useState(c2),[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 h=!1;return(async()=>{var f;try{const m=await fetch("/api/config");if(!m.ok)throw new Error(`config request failed (${m.status})`);const g=await m.json();if(h)return;const x=(g==null?void 0:g.currentBranch)??null,b=((f=g==null?void 0:g.audit)==null?void 0:f.branchBaseRef)??null;n(Im(g==null?void 0:g.workflow)),r({currentBranch:x,primaryBranch:b,onPrimaryBranch:x!==null&&x===b})}catch(m){h||u(m instanceof Error?m.message:String(m))}finally{h||o(!1)}})(),()=>{h=!0}},[]);const p=l.useCallback(async(h,f)=>{const m=e;n(h),c(!0),u(null);try{const g=await fetch("/api/workflow-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:f,workflow:h})}),x=await g.json().catch(()=>({}));if(!g.ok||(x==null?void 0:x.success)===!1)throw new Error((x==null?void 0:x.message)??(x==null?void 0:x.error)??`save failed (${g.status})`);x!=null&&x.workflow&&n(Im(x.workflow))}catch(g){n(m),u(g instanceof Error?g.message:String(g))}finally{c(!1)}},[e]);return{settings:e,branchState:s,loading:a,saving:i,error:d,save:p}}const iW=[{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."}],lW=[{value:"local",label:"This machine only"},{value:"project",label:"Whole project"}];function d2(){const[e,n]=l.useState("local"),{settings:s,branchState:r,loading:a,saving:o,error:i,save:c}=oW(),d=s.checkIns.hardeningCompleted;return t.jsxs("section",{className:"mt-6 rounded-xl",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 px-5 pt-5 pb-4",children:[t.jsxs("div",{className:"min-w-0 max-w-md",children:[t.jsx("h3",{className:"text-[14px] font-medium",style:{color:"var(--text-primary)"},children:"Workflow check-ins"}),t.jsx("p",{className:"text-[12.5px] leading-relaxed mt-1",style:{color:"var(--text-muted)"},children:"Switched on, the workflow pauses and asks you at that point. Switched off, it keeps going on its own."})]}),t.jsxs("div",{className:"shrink-0",children:[t.jsx("div",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-muted)"},children:"Apply to"}),t.jsx(Dp,{options:lW,value:e,onChange:n})]})]}),t.jsx("div",{className:"px-5 pb-2",children:iW.map(u=>{const p=s.checkIns[u.key];return t.jsx(i2,{label:u.label,description:u.description,checked:p.pause,disabled:a||o,onChange:h=>void c({checkIns:{...s.checkIns,[u.key]:{...p,pause:h}}},e),children:u.key==="hardeningCompleted"&&!d.pause&&t.jsx(l2,{autoAction:d.autoAction,branchState:r,disabled:o,onChange:h=>void c({checkIns:{...s.checkIns,hardeningCompleted:{...d,autoAction:h}}},e)})},u.key)})}),i&&t.jsxs("p",{className:"text-[12px] px-5 pb-4",role:"alert",style:{color:"var(--accent-red, #ef4444)"},children:["Could not save: ",i]})]})}const _se=Object.freeze(Object.defineProperty({__proto__:null,WorkflowSettingsSection:d2},Symbol.toStringTag,{value:"Module"}));function u2(){return t.jsx("div",{className:"h-full overflow-y-auto px-6 py-8",children:t.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[t.jsx("h2",{className:"text-[18px] font-semibold",style:{color:"var(--text-primary)"},children:"Settings"}),t.jsx("p",{className:"mt-1 text-[13px]",style:{color:"var(--text-muted)"},children:"How the editor works with you on this project."}),t.jsx(d2,{})]})})}const Sse=Object.freeze(Object.defineProperty({__proto__:null,SettingsTab:u2},Symbol.toStringTag,{value:"Module"}));function p2({activeTab:e,appTabContent:n,leftWidth:s,onPreviewScreenshot:r,onRunPlan:a}){const o=e!=="build"&&e!=="plan"&&e!=="chat",[i,c]=l.useState(!1),[d,u]=l.useState(!1),[p,h]=l.useState(!1);return l.useEffect(()=>{e==="history"&&c(!0),e==="reviews"&&u(!0),e==="settings"&&h(!0)},[e]),t.jsx("div",{className:"absolute inset-0 flex flex-col",style:{visibility:o?"visible":"hidden",pointerEvents:o?"auto":"none"},children:t.jsx(o2,{activeTab:e,width:s,children:{home:n,build:null,plan:null,history:i?t.jsx(s0,{onPreviewScreenshot:r,onRunPlan:a}):null,reviews:d?t.jsx(iw,{}):null,settings:p?t.jsx(u2,{}):null}})})}const kse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellTabLayer:p2},Symbol.toStringTag,{value:"Module"}));function h2(e){const{annotationsBySlug:n,dependenciesBySlug:s}=Mp(e),{claims:r}=Op(),{status:a}=Rp(),o=l.useMemo(()=>Ap(r),[r]),i=((a==null?void 0:a.consecutiveFailures)??0)>=3;return{annotationsBySlug:n,dependenciesBySlug:s,claimsBySlug:o,staleFetch:i}}function cW(e,n){const s=new Map(n.map(r=>[r.id,r]));return e.map(r=>{const a=s.get(r.id);return a?{...r,status:a.status,planSlug:a.planSlug}:r})}const dW={write:"plan",ignore:"ignore",copied:"record the copy of"};function uW(e){const{plansVersion:n}=Tn(),[s,r]=l.useState([]),[a,o]=l.useState({}),[i,c]=l.useState({}),[d,u]=l.useState(null),p=e.length>0,h=l.useCallback(async()=>{try{const m=await fetch("/api/proposed-plans");if(!m.ok)return;const g=await m.json();r(g.proposals??[])}catch{}},[]);l.useEffect(()=>{p&&h()},[h,p,n]);const f=l.useCallback(async(m,g)=>{o(x=>({...x,[m]:g})),c(({[m]:x,...b})=>b);try{const x=await fetch(`/api/proposed-plans/${encodeURIComponent(m)}/${g}`,{method:"POST"});if(!x.ok){const y=await x.json().catch(()=>({}));throw new Error(y.error??`HTTP ${x.status}`)}const b=await x.json().catch(()=>({}));b.headReleaseFailure&&u(b.headReleaseFailure),await h()}catch(x){const b=dW[g],y=x instanceof Error?x.message:String(x);c(v=>({...v,[m]:`Could not ${b} this suggestion: ${y}`}))}finally{o(({[m]:x,...b})=>b)}},[h]);return{rows:cW(e,s),busyActions:a,errorsById:i,headReleaseFailure:d,write:m=>f(m,"write"),ignore:m=>f(m,"ignore"),markCopied:m=>f(m,"copied")}}function pW(e){const[n,s]=l.useState({}),r=e.join(`
|
|
190
|
-
`);return l.useEffect(()=>{if(r==="")return;let a=!1;for(const o of r.split(`
|
|
191
|
-
`))fetch(`/api/proposed-plans/${encodeURIComponent(o)}/report`).then(i=>i.ok?i.json():null).then(i=>{a||!(i!=null&&i.report)||s(c=>({...c,[o]:i.report}))}).catch(()=>{});return()=>{a=!0}},[r]),n}function hW(e){return!e||!(e instanceof Element)?!1:!!e.closest("[data-terminal-emulator], .xterm")}function fW(e){return!e||!(e instanceof Element)?!1:!!e.closest("[data-post-push-modal]")}function f2(e,n=!0){const s=l.useCallback(r=>{if(r.key!=="Enter"||!n||hW(r.target))return;const a=r.target===document.body||r.target===document.documentElement||r.target===document;!fW(r.target)&&!a||(r.preventDefault(),e())},[n,e]);l.useEffect(()=>(window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)),[s])}function mW(e){return[{id:"prototype",title:"Prototype",caption:`Try an idea fast with ${e}, harden it later`},{id:"plan",title:"Plan",caption:"Plan out a change, like a bug fix or a feature"},{id:"chat",title:"Chat",caption:`Ask ${e} about the project or CodeYam`}]}function m2({title:e,caption:n,icon:s,testId:r,onClick:a,disabled:o=!1}){const i=o?"":"group-hover:text-[var(--bg-deep)]";return t.jsxs("button",{type:"button",disabled:o,onClick:a,"data-testid":r,className:"group flex h-full w-full flex-col items-start rounded-md border border-[var(--border-default)] bg-[var(--bg-deep)] p-3 text-left transition "+(o?"cursor-not-allowed opacity-50":"cursor-pointer hover:border-[var(--accent-active)] hover:bg-[var(--accent-active)]"),children:[t.jsx("span",{className:"text-[var(--accent-active)] "+i,children:s}),t.jsx("span",{className:"mt-2 block text-sm font-medium text-[var(--text-primary)] "+i,children:e}),t.jsx("span",{className:"mt-0.5 block text-xs leading-snug text-[var(--text-muted)] "+i,children:n})]})}const Nse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityCard:m2},Symbol.toStringTag,{value:"Module"}));function g2({activity:e,size:n=20}){return t.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e==="prototype"&&t.jsx("path",{d:"M13 3v7h6l-8 11v-7H5l8-11"}),e==="plan"&&t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M3.5 5.5l1.5 1.5l2.5-2.5"}),t.jsx("path",{d:"M3.5 11.5l1.5 1.5l2.5-2.5"}),t.jsx("path",{d:"M3.5 17.5l1.5 1.5l2.5-2.5"}),t.jsx("path",{d:"M11 6h9M11 12h9M11 18h9"})]}),e==="chat"&&t.jsx("path",{d:"M3 20l1.3-3.9c-2.3-3.4-1.4-7.9 2.1-10.4c3.5-2.5 8.6-2.3 11.8.5c3.3 2.8 3.7 7.3 1 10.5c-2.7 3.2-7.6 4.2-11.6 2.3L3 20"})]})}const Cse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityIcon:g2},Symbol.toStringTag,{value:"Module"}));function x2({providerLabel:e,onChoose:n,disabled:s=!1}){const r=mW(e);return t.jsx("div",{className:"grid grid-cols-3 gap-2","data-testid":"build-activity-menu",children:r.map(a=>t.jsx(m2,{title:a.title,caption:a.caption,icon:t.jsx(g2,{activity:a.id}),testId:`build-activity-${a.id}`,onClick:()=>n(a.id),disabled:s},a.id))})}const Tse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityMenu:x2},Symbol.toStringTag,{value:"Module"}));function gW({mode:e,hasPlans:n}){return e==="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 b2({mode:e,hasPlans:n,featureSummary:s}){if(e==="feature-complete"&&(s!=null&&s.title))return t.jsx(xy,{summary:s});const{heading:r,subtitle:a}=gW({mode:e,hasPlans:n});return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:r}),t.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:a})]})}const Pse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityModalHeading:b2},Symbol.toStringTag,{value:"Module"}));function y2({plans:e,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i,depAnnotationsBySlug:c,dependenciesBySlug:d,claimsBySlug:u,staleFetch:p}){return e.length===0?null:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4 text-xs text-[var(--text-dim)]","aria-hidden":"true",children:[t.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"}),t.jsx("span",{children:"or"}),t.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"})]}),t.jsx("div",{className:"mb-3","data-testid":"build-activity-modal-plan-list",style:{"--plan-row-bg":"var(--bg-deep)","--plan-row-border":"var(--border-default)"},children:t.jsx(mi,{plans:e,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i,depAnnotationsBySlug:c,dependenciesBySlug:d,claimsBySlug:u,staleFetch:p})})]})}const Ose=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityPlanList:y2},Symbol.toStringTag,{value:"Module"}));function v2({onContinueInSession:e,onStopBuilding:n,onSendTranscript:s}){return!e&&!n&&!s?null:t.jsxs("div",{className:"mt-4 pt-3 border-t border-[var(--border-subtle)] flex flex-col gap-2","data-testid":"feature-complete-actions",children:[e&&t.jsx("button",{type:"button",onClick:e,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&&t.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&&t.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 Rse=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteActions:v2},Symbol.toStringTag,{value:"Module"})),xW=300;function j2({mode:e,providerLabel:n,plans:s,onPickPlan:r,launchingSlug:a,planError:o,pendingPlansLoading:i,pendingPlansError:c,isAgentBuilding:d,featureCycleComplete:u=!1,onChooseActivity:p,onSubmitPrompt:h,submittingPrompt:f=!1,featureSummary:m,onContinueInSession:g,onStopBuilding:x,onSendTranscript:b,onMinimize:y}){const{annotationsBySlug:v,dependenciesBySlug:j,claimsBySlug:_,staleFetch:S}=h2(s),w=e==="feature-complete",k=d&&!u,{requestRun:N,gateModals:C}=xi({dependenciesBySlug:j,claimsBySlug:_,isAgentBuilding:k,onLaunch:L=>{var O;const M=((O=s.find(z=>z.slug===L))==null?void 0:O.title)??L;r(L,M)}}),T=f||a!==null,P=uW(w?(m==null?void 0:m.proposedPlans)??[]:[]),R=pW(P.rows.filter(Ir).map(L=>L.id));return f2(l.useCallback(()=>p("prototype"),[p]),!T),t.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:[t.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:[t.jsx("div",{className:"mb-4",children:t.jsx(Cb,{maxHeight:xW,testId:"build-activity-narrative",children:t.jsx(b2,{mode:e,hasPlans:s.length>0,featureSummary:m})})}),t.jsx(uy,{rows:P.rows,providerLabel:n,busyActions:P.busyActions,errorsById:P.errorsById,headReleaseFailure:P.headReleaseFailure,onWrite:L=>void P.write(L),onIgnore:L=>void P.ignore(L)}),t.jsx(py,{rows:P.rows,reports:R,busyActions:P.busyActions,errorsById:P.errorsById,onCopied:L=>void P.markCopied(L),onIgnore:L=>void P.ignore(L)}),t.jsxs("div",{children:[t.jsx(x2,{providerLabel:n,onChoose:p,disabled:T}),w&&t.jsx(v2,{onContinueInSession:g,onStopBuilding:x,onSendTranscript:b})]}),t.jsx("div",{className:"border-t border-[var(--border-subtle)] pt-4 mt-4",children:t.jsx(y2,{plans:s,loading:i,error:c,onRun:N,launchingSlug:a,launchError:o,blocked:k,depAnnotationsBySlug:v,dependenciesBySlug:j,claimsBySlug:_,staleFetch:S})}),t.jsxs("div",{children:[h&&t.jsx(my,{onSubmitPrompt:h,disabled:T}),y&&t.jsx("div",{className:"mt-4 text-center",children:t.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"})})]})]}),C]})}const Ese=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityModal:j2},Symbol.toStringTag,{value:"Module"}));function w2({onReopen:e,pendingPlanCount:n=0}){return t.jsxs("button",{type:"button",onClick:e,"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:[t.jsx("span",{children:"What do you want to do?"}),t.jsxs("span",{className:"flex items-center gap-2 text-xs text-[var(--text-dim)]",children:[n>0&&t.jsxs("span",{"data-testid":"build-activity-reopen-bar-count",children:[n," queued"]}),t.jsx("span",{"aria-hidden":"true",children:"↑"})]})]})}const Ase=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityReopenBar:w2},Symbol.toStringTag,{value:"Module"}));function _2({onCreateNewPlan:e,onContinueSession:n,onViewPlans:s}){return t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Plan Saved!"}),t.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."}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("button",{onClick:e,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"}),t.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"}),t.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 Mse=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteDialog:_2},Symbol.toStringTag,{value:"Module"}));function S2({onCreateNewPlan:e,onContinueSession:n,onViewPlans:s}){return t.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:t.jsx(_2,{onCreateNewPlan:e,onContinueSession:n,onViewPlans:s})})}const Ise=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteTransition:S2},Symbol.toStringTag,{value:"Module"}));function k2({plans:e,onSelect:n,onCancel:s,launchingSlug:r,error:a}){const[o,i]=l.useState(null),c=l.useMemo(()=>{const x={};for(const b of e)x[b.slug]=b;return x},[e]),{annotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:p,staleFetch:h}=h2(e),{requestRun:f,gateModals:m}=xi({dependenciesBySlug:u,claimsBySlug:p,onLaunch:l.useCallback(x=>{const b=c[x];b&&n(b.slug,b.title)},[n,c])}),g=l.useCallback(x=>{x.key==="Escape"&&(x.preventDefault(),s())},[s]);return l.useEffect(()=>(window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)),[g]),f2(l.useCallback(()=>{e.length>0&&f(e[0].slug)},[e,f]),e.length>0&&!r),e.length===0?null:t.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","data-post-push-modal":!0,children:[t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Select A Plan"}),t.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."}),t.jsx("ul",{className:"flex flex-col gap-2 max-h-[50vh] overflow-y-auto mb-2",children:e.map((x,b)=>{var y,v;return t.jsx(bp,{plan:x,position:b+1,expanded:o===x.slug,onToggle:()=>i(j=>j===x.slug?null:x.slug),onRun:f,launching:r===x.slug,unsatisfiedDepCount:(y=d[x.slug])==null?void 0:y.count,unsatisfiedDepTooltip:(v=d[x.slug])==null?void 0:v.tooltip,dependencies:u[x.slug],claim:p.get(x.slug),staleFetch:h,expandedBodyVariant:"view"},x.slug)})}),a&&t.jsx(dt,{testId:"select-plan-error",text:a,className:"text-xs text-[var(--text-danger)]",rowClassName:"mb-3"}),t.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"}),t.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Press Enter to launch the first plan, Escape to cancel"})]}),m]})}const Dse=Object.freeze(Object.defineProperty({__proto__:null,SelectPlanModal:k2},Symbol.toStringTag,{value:"Module"}));function N2({activeTab:e,onSendTranscript:n,appTabContent:s,awaitingPlanLaunchChoice:r,buildActivated:a,planActivated:o,buildIdle:i=!1,agentBlocked:c=!1,isAgentBuilding:d=!1,planActive:u=!1,planIdle:p=!1,bannerVisible:h=!1,onDismissIdleBanner:f,hideResultsCommandKey:m,leftWidth:g,fullWidth:x=!1,navigateToTab:b,onAgentActive:y,onAgentIdle:v,onAgentBlocked:j,onUserInput:_,notifSettings:S,onSettingsChange:w,provider:k,onContinueInSession:N,onRestorePreview:C,onResultsScenarioSelect:T,previewSlug:P=null,onStopBuilding:R,featureSummary:L,featureCycleComplete:M,showResultsCommandKey:O,planChatOpen:z,onPlanChatOpenChange:I,showPlanCompleteModal:Y,onCreateNewPlan:W,onContinueSession:A,onViewPlans:B,pendingPlans:D,onSelectPlan:J,selectPlanOpen:te,onPickPlan:oe,onCancelSelectPlan:se,launchingPlanSlug:G,planLaunchError:le,prototypeLaunchSignal:ue=0,planCompleteSignal:ne=0,showBuildLaunchModal:E=!1,buildLaunchGateArmed:H=!1,buildActivity:U="menu",buildActivityMinimized:pe=!1,chatEscalatedToPrototype:ge=!1,onChooseActivity:Me,onNavigateToPlanTab:Ce,onToggleDesigns:De,designsOpen:Be=!1,onActivityDone:X,onPrototypeLaunched:Q,onMinimizeActivityModal:re,onReopenActivityModal:ce,onSubmitBuildPrompt:_e,submittingBuildPrompt:Te=!1,buildPromptError:Oe=null,pendingPlansLoading:he,pendingPlansError:xe,onReorderPlans:Fe,buildDisabled:F=!1,onPreviewScreenshot:ee,onRunHistoryPlan:de,projectTitle:ie=null,designSession:fe=!1}){const ve=F8(),be=M,We=e==="build"&&!te&&!pe&&(be||E),ze=Re=>{if(Re==="plan"){Ce==null||Ce();return}Me==null||Me(Re)};return t.jsxs("div",{className:`${x?"flex-1 w-full min-w-0":"shrink-0"} flex flex-col overflow-hidden`,style:x?{background:"var(--bg-deep)"}:{width:g,background:"var(--bg-deep)"},children:[ve&&t.jsx(N1,{projectTitle:ie}),fe?t.jsx(zN,{projectTitle:ie}):t.jsx(k1,{activeTab:e,onTabChange:b,onSendTranscript:n,buildIdle:i,agentBlocked:c,isAgentBuilding:d,planActive:u,planIdle:p,bannerVisible:h,onDismissIdleBanner:f,buildDisabled:F,showLogo:!ve,projectTitle:ie,notifSettings:S,onNotifSettingsChange:w,agentName:k,providerLabel:st(k)}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[t.jsx(aN,{awaitingPlanLaunchChoice:r,buildLaunchGateArmed:H,buildActivated:a,activeTab:e,onSelectScenario:T,previewSlug:P,showResultsCommandKey:O,hideResultsCommandKey:m,onAgentIdle:v,onAgentBlocked:j,onAgentActive:y,onUserInput:_,provider:k,onRestorePreview:C,pendingPlans:D,pendingPlansLoading:he,pendingPlansError:xe,onLaunchPlan:(Re,Ye)=>oe(Re,Ye,"build-tab"),launchingSlug:G,launchError:le,onReorderPlans:Fe,isAgentBuilding:d,featureCompleteActive:M,buildActivity:U,chatEscalatedToPrototype:ge,onActivityDone:X,onPrototypeLaunched:Q,prototypeLaunchSignal:ue}),t.jsx(FN,{activeTab:e,planActivated:o,chatOpen:z,onChatOpenChange:I,isAgentBuilding:d,launchingPlanSlug:G,planLaunchError:le,onLaunchPlan:(Re,Ye)=>oe(Re,Ye,"plan-tab"),planCompleteSignal:ne,onToggleDesigns:De,designsOpen:Be}),t.jsx(r2,{activeTab:e}),t.jsx(p2,{activeTab:e,appTabContent:s,leftWidth:g,onPreviewScreenshot:ee,onRunPlan:de}),te&&e==="build"?t.jsx(k2,{plans:D,onSelect:(Re,Ye)=>oe(Re,Ye,"select-plan-modal"),onCancel:se,launchingSlug:G,error:le}):null,We?t.jsx(j2,{mode:be?"feature-complete":"cold",providerLabel:st(k),plans:D,onPickPlan:(Re,Ye)=>oe(Re,Ye,"build-activity-modal"),launchingSlug:G,planError:le,pendingPlansLoading:he,pendingPlansError:xe,isAgentBuilding:d,featureCycleComplete:M,onChooseActivity:ze,onSubmitPrompt:_e,submittingPrompt:Te,featureSummary:L,onContinueInSession:be?N:void 0,onStopBuilding:be?R:void 0,onSendTranscript:be?n:void 0,onMinimize:re}):null,pe&&e==="build"&&ce?t.jsx(w2,{onReopen:ce,pendingPlanCount:D.length}):null,Y&&e==="plan"?t.jsx(S2,{onCreateNewPlan:W,onContinueSession:A,onViewPlans:B}):null]})]})}const Lse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLeftPane:N2},Symbol.toStringTag,{value:"Module"}));function C2({onOpenDesigns:e,onDismiss:n}){return t.jsxs("div",{role:"status",style:{position:"absolute",top:12,right:12,zIndex:20,display:"flex",alignItems:"center",gap:10,padding:"8px 10px 8px 14px",borderRadius:999,border:"1px solid var(--accent-active, #D7FF63)",background:"var(--bg-card, #1a1a1a)",boxShadow:"0 8px 20px rgba(0, 0, 0, 0.45)",fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)"},children:[t.jsx("button",{type:"button",onClick:e,style:{border:"none",background:"transparent",color:"inherit",font:"inherit",cursor:"pointer",padding:0,textDecoration:"underline",textUnderlineOffset:3},children:"Go back to Designs"}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss",style:{border:"none",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontSize:16,lineHeight:1,padding:2},children:"×"})]})}const $se=Object.freeze(Object.defineProperty({__proto__:null,DesignReturnPill:C2},Symbol.toStringTag,{value:"Module"}));async function Dm(e,n=null){try{const s={pid:e};n&&(s.url=n),await fetch("/api/editor-iframe-loaded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch{}}async function bW(e){try{await fetch("/api/editor-iframe-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({error:e})})}catch{}}async function yW(e){try{await fetch("/api/editor-iframe-banner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seedError:e})})}catch{}}async function vW(e){try{await fetch("/api/editor-inspector-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({frozen:e})})}catch{}}async function jW(e){try{await fetch("/api/editor-iframe-auth-needed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({previewOrigin:e})})}catch{}}async function wW(e){try{await fetch("/api/editor-preview-escape",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({escapedPath:e})})}catch{}}function _W(e,n,s,r,a){const o=e,i=n-a*2;return o<=0||i<=0?1:Math.min(1,o/s,i/r)}const SW=32;function kW({currentHeight:e,currentWidth:n,isFilled:s}){const[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(p=>{const h=p.getBoundingClientRect();a({width:h.width,height:h.height})},[]),d=l.useCallback(p=>{if(o.current&&(o.current.disconnect(),o.current=null),i.current=p,!p){a(null);return}c(p);const h=new ResizeObserver(()=>{const f=i.current;f&&c(f)});h.observe(p),o.current=h},[c]),u=s||!r?1:_W(r.width,r.height,n,e,SW);return{containerRef:d,containerSize:r,scale:u}}const Oc={kind:"iframe",fallbackKind:null,fallbackPort:null,nativeWebPreview:!1,loading:!1},Lm=[400,800,1500,3e3];function T2(){const[e,n]=l.useState({...Oc,loading:!0});return l.useEffect(()=>{let s=!1,r,a=0;const o=()=>{const d=Lm[Math.min(a,Lm.length-1)];a+=1,r=setTimeout(c,d)},i=()=>{n(d=>d.loading?Oc:d),o()},c=()=>{fetch("/api/project-stack").then(d=>d.ok?d.json():{}).then(d=>{s||(NW(d)?n(CW(d)):i())}).catch(()=>{s||i()})};return c(),()=>{s=!0,r&&clearTimeout(r)}},[]),e}function NW(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function CW(e){const n=e&&typeof e=="object"&&"preview"in e?e.preview:null;if(!n||typeof n!="object")return Oc;const s=n;return{kind:TW(s.kind),fallbackKind:PW(s.fallbackKind),fallbackPort:typeof s.fallbackPort=="number"?s.fallbackPort:null,nativeWebPreview:s.nativeWebPreview===!0,loading:!1}}function TW(e){return e==="simulator-ios"?"simulator-ios":e==="simulator-android"?"simulator-android":"iframe"}function PW(e){return e==="iframe"||e==="simulator-ios"||e==="simulator-android"?e:null}const OW="codeyam:client-routing-detected";function RW(e){const[n,s]=l.useState(!1);return l.useEffect(()=>{if(!e)return;function r(a){var o;a.origin===window.location.origin&&((o=a.data)==null?void 0:o.type)===OW&&s(!0)}return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[e]),n}const EW=700;function P2({pollMs:e=EW,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(p=>p+1)},e);return()=>{d=!0,window.clearInterval(u)}},[e,n]),l.useEffect(()=>{if(n)return;let d=!1;return fetch(`/api/simulator-frame?t=${r}`,{method:"HEAD"}).then(async u=>{var h;if(d)return;if(u.ok){i({kind:"ok"});return}if(u.status===503){const f=await AW(u);if(d)return;(typeof(f==null?void 0:f.error)=="string"?f.error:"").includes("xcode")?i({kind:"xcode-missing"}):i({kind:"no-device"});return}const p=`simulator frame request failed (${u.status})`;i({kind:"capture-failed",message:p}),(h=c.current)==null||h.call(c,p)}).catch(u=>{var h;if(d)return;const p=u instanceof Error?u.message:"simulator frame request errored";i({kind:"capture-failed",message:p}),(h=c.current)==null||h.call(c,p)}),()=>{d=!0}},[r,n]),{state:o,isBooted:o.kind==="ok",frameToken:r}}async function AW(e){try{return await e.json()}catch{return null}}function MW(e,n){const s=(e==null?void 0:e.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 IW(e,n,s){switch(e){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 Rc(){const e=Date.now();try{const n=await fetch("/api/editor-session-summary"),s=Date.now()-e;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()-e,error:n instanceof Error?n.message:String(n)}}}const DW=50,LW={status:"loading",lastSuccessAt:null,lastErrorAt:null,lastErrorMessage:null,fetchCount:0,errorCount:0};function $W(e,n,s){return{status:n.ok?"connected":"disconnected",lastSuccessAt:n.ok?s:e.lastSuccessAt,lastErrorAt:n.ok?e.lastErrorAt:s,lastErrorMessage:n.ok?e.lastErrorMessage:n.error,fetchCount:e.fetchCount+1,errorCount:e.errorCount+(n.ok?0:1)}}function FW(e,n){return{timestamp:n,success:e.ok,statusCode:e.statusCode,durationMs:e.durationMs,error:e.error}}function zW(e,n){return[n,...e].slice(0,DW)}function BW(){const[e,n]=l.useState(LW),[s,r]=l.useState([]),a=l.useCallback(i=>{const c=Date.now();r(d=>zW(d,FW(i,c))),n(d=>$W(d,i,c))},[]),o=l.useCallback(()=>{n(i=>({...i,status:"polling"}))},[]);return{connectionState:e,fetchLog:s,recordFetch:a,markPolling:o}}async function WW(e){try{const r=await fetch("/api/test-results");if(r.ok&&(await r.json()).running)return{kind:"busy"}}catch{}const n={tests:[e.name]};e.file&&(n.changedFiles=[e.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 HW(e,n){if(!e.narrative)return null;for(const s of e.narrative.changes)for(const r of s.tests)if(r.name===n)return{lastRunAt:r.lastRunAt,status:r.status??"unknown"};return null}async function qW(e,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 Rc();if(c.ok&&c.data){const d=HW(c.data,e.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 UW(e){return!e||e<=0?3e4:Math.max(3e4,e*2)}function GW({onSummaryUpdate:e,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 WW(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=UW(n()),p=await qW(o,c,{timeoutMs:u});p.kind==="completed"?(e(p.summary),r(null)):r({name:i,state:{phase:"timeout"}})})()},[e,n]);return{active:s,onRerun:a}}function YW(e){switch(e.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 O2({state:e}){const n=xs(),{dotClass:s,label:r,labelClass:a}=YW(e);return t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium","data-testid":"connection-status-badge",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${s}`,"data-testid":"connection-status-dot"}),t.jsx("span",{className:a,"data-testid":"connection-status-label",children:r}),e.lastSuccessAt!=null&&t.jsxs("span",{className:"text-[var(--text-muted)]","data-testid":"connection-status-updated",children:["Updated ",bl(e.lastSuccessAt,n)]})]})}const Fse=Object.freeze(Object.defineProperty({__proto__:null,BackendConnectionStatusBadge:O2},Symbol.toStringTag,{value:"Module"}));function R2({feature:e,connectionState:n,statusChip:s,userPrompt:r}){return t.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:[t.jsx("h1",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:e||"Working Session Results"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx(O2,{state:n}),s&&t.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&&t.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]","data-testid":"user-prompt-section",children:[t.jsx("div",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wide",children:"Your request"}),t.jsx("div",{className:"mt-2 bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded-md p-3",children:t.jsx(Po,{maxHeight:90,moreLabel:"View More",lessLabel:"View Less",fadeColor:"var(--bg-input)",children:r})})]})]})}const zse=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsHeader:R2},Symbol.toStringTag,{value:"Module"}));function VW(e,n,s=[]){var r;return{headline:(r=e.description)!=null&&r.trim()?e.description:e.name,name:e.name,file:e.file,status:e.status??"unknown",failureMessage:e.failureMessage,change:n.title,lastRunAt:e.lastRunAt,lastRunKind:e.lastRunKind,recentStatuses:e.recentStatuses,exercises:s.filter(a=>a.tests.some(o=>_p(o)===e.name)),example:e.example}}function E2(e,n=[]){const s=[],r=[];let a=0;for(const o of e.tests){if(o.verified===!1){a+=1;continue}const i=VW(o,e,n);i.status==="passing"?s.push(i):r.push(i)}return{worksNow:s,inProgress:r,unverifiedCount:a}}function KW(e,n=[]){const s=[],r=[];let a=0;for(const o of e.changes){const i=E2(o,n);s.push(...i.worksNow),r.push(...i.inProgress),a+=i.unverifiedCount}return{worksNow:s,inProgress:r,unverifiedCount:a}}function JW(e){if(!e||e.length<2)return!1;const n=e.some(r=>r.status==="pass"),s=e.some(r=>r.status==="fail");return n&&s}function XW(e){if(e==null||e===0)return"";const n=Math.abs(e),s=e>0?"slower":"faster";return`${n}s ${s} than the previous run`}function A2({status:e}){switch(e){case"passing":return t.jsx("span",{className:"text-green-500 text-xs mt-0.5 shrink-0",children:"✓"});case"failing":return t.jsx("span",{className:"text-red-500 text-xs mt-0.5 shrink-0",children:"✗"});case"running":return t.jsx("span",{className:"text-[#D7FF63] text-xs mt-0.5 shrink-0 animate-spin",children:"◠"});default:return t.jsx("span",{className:"text-gray-400 text-xs mt-0.5 shrink-0",children:"●"})}}const Bse=Object.freeze(Object.defineProperty({__proto__:null,NarrativeTestStatusIcon:A2},Symbol.toStringTag,{value:"Module"})),$m="font-mono text-[11px] text-[var(--text-primary)] whitespace-pre-wrap break-words min-w-0",Fm="w-0 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] align-top pr-3 py-1 whitespace-nowrap";function M2({example:e}){return t.jsxs("div",{"data-testid":"behavior-example",children:[t.jsx("table",{className:"w-full border-collapse",children:t.jsxs("tbody",{children:[t.jsxs("tr",{children:[t.jsx("td",{className:Fm,children:"Input"}),t.jsx("td",{className:`${$m} py-1`,"data-testid":"example-input",children:e.input})]}),t.jsxs("tr",{children:[t.jsx("td",{className:Fm,children:"Output"}),t.jsx("td",{className:`${$m} py-1`,"data-testid":"example-output",children:e.output})]})]})}),e.note&&t.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1 mb-0 italic","data-testid":"example-note",children:e.note})]})}const Wse=Object.freeze(Object.defineProperty({__proto__:null,BehaviorExampleTable:M2},Symbol.toStringTag,{value:"Module"})),QW="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function ZW(e){switch(e.phase){case"busy":return"Tests are already running — try again once they finish.";case"error":return e.message;case"timeout":return"Couldn't confirm — check test results.";default:return null}}function I2({rerun:e={phase:"idle"},onRerun:n,disabled:s=!1,disabledReason:r}){const a=e.phase==="verifying",o=e.phase==="error",i=s||a,c=s&&r||ZW(e);return t.jsxs("div",{"data-testid":"evidence-rerun",children:[t.jsx("div",{className:QW,children:"Re-run"}),t.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&&t.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&&t.jsx("p",{className:`text-[11px] mt-1 m-0 ${o?"text-red-600":"text-[var(--text-muted)]"}`,"data-testid":"rerun-note",children:c})]})}const Hse=Object.freeze(Object.defineProperty({__proto__:null,RerunSection:I2},Symbol.toStringTag,{value:"Module"}));function eH(e){return e==="passing"?"passed":e==="failing"?"failed":"ran"}function tH(e){switch(e){case"full":return"full run";case"changed":return"changed-files run";case"targeted":return"targeted run"}}function D2(e){var r;const n=e.status==="failing"&&!!e.failureMessage,s=(((r=e.recentStatuses)==null?void 0:r.length)??0)>0;return!!e.lastRunAt||e.exercises.length>0||n||!!e.example||s}const lr="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function L2({behavior:e,rerun:n={phase:"idle"},onRerun:s,disabled:r=!1,disabledReason:a}){const o=xs(),i=e.status==="failing"&&!!e.failureMessage;return t.jsxs("div",{className:"mt-2 ml-5 space-y-3","data-testid":"behavior-evidence-drawer",children:[e.lastRunAt&&t.jsxs("div",{"data-testid":"evidence-verified",children:[t.jsx("div",{className:lr,children:"Verified"}),t.jsxs("p",{className:"text-[11px] text-[var(--text-secondary)] m-0",children:[eH(e.status)," ",bl(Date.parse(e.lastRunAt),o),e.lastRunKind&&t.jsxs("span",{className:"text-[var(--text-muted)]",children:[" (",tH(e.lastRunKind),")"]})]})]}),e.example&&t.jsxs("div",{"data-testid":"evidence-example",children:[t.jsx("div",{className:lr,children:"Example"}),t.jsx(M2,{example:e.example})]}),e.recentStatuses&&e.recentStatuses.length>0&&t.jsxs("div",{"data-testid":"evidence-recent-runs",children:[t.jsx("div",{className:lr,children:"Recent runs"}),t.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:[...e.recentStatuses].reverse().map((c,d)=>t.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} · ${bl(Date.parse(c.at),o)}`,"data-testid":`recent-run-dot-${c.status}`},`${c.at}-${d}`))})]}),e.exercises.length>0&&t.jsxs("div",{"data-testid":"evidence-exercises",children:[t.jsx("div",{className:lr,children:"Exercises"}),t.jsx("ul",{className:"list-none p-0 m-0 space-y-1",children:e.exercises.map(c=>t.jsxs("li",{className:"text-[11px] text-[var(--text-secondary)] flex items-center gap-x-1.5",children:[t.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:c.name}),t.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),t.jsx("span",{className:"font-mono text-[var(--text-dim)] min-w-0 truncate",children:c.filePath}),c.coverage&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),t.jsxs("span",{className:"text-[var(--text-muted)]",children:[Math.round(c.coverage.percent),"% covered"]})]})]},c.name))})]}),i&&t.jsxs("div",{"data-testid":"evidence-failure",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:lr,children:"Failure"}),t.jsx(mt,{variant:"subtle",text:e.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"})]}),t.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:e.failureMessage})]}),t.jsx(I2,{rerun:n,onRerun:s,disabled:r,disabledReason:a})]})}const qse=Object.freeze(Object.defineProperty({__proto__:null,BehaviorEvidenceDrawer:L2,hasDrawerContent:D2},Symbol.toStringTag,{value:"Module"}));function $2({behavior:e,rerun:n}){var p,h;const[s,r]=l.useState(!1),a=D2(e),o=JW(e.recentStatuses),i=((p=n==null?void 0:n.active)==null?void 0:p.name)===e.name,c=i?n.active.state:{phase:"idle"},d=c.phase==="verifying",u=((h=n==null?void 0:n.active)==null?void 0:h.state.phase)==="verifying"&&!i;return t.jsx("div",{"data-testid":"behavior-item",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(A2,{status:d?"running":e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm text-[var(--text-primary)] leading-relaxed",children:[e.headline,o&&t.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?"})]}),t.jsxs("div",{className:"flex items-center gap-x-1.5 mt-1 text-[11px]",children:[t.jsx("span",{className:"text-[var(--text-muted)] font-mono min-w-0 truncate",children:e.name}),e.file&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),t.jsx("span",{className:"text-[var(--text-dim)] font-mono min-w-0 truncate",children:e.file})]}),e.change&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),t.jsx("span",{className:"text-[var(--text-muted)] opacity-70 shrink-0",children:e.change})]})]})]}),a&&t.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&&t.jsx(L2,{behavior:e,rerun:c,onRerun:n?()=>n.onRerun(e):void 0,disabled:u,disabledReason:"Verifying another behavior…"})]})]})})}const Use=Object.freeze(Object.defineProperty({__proto__:null,BehaviorItem:$2},Symbol.toStringTag,{value:"Module"}));function Ec({label:e,behaviors:n,tone:s,rerun:r}){if(n.length===0)return null;const a=s==="positive"?"text-green-500":"text-[var(--text-secondary)]";return t.jsxs("section",{className:"space-y-3","data-testid":"behavior-group",children:[t.jsxs("h2",{className:`text-xs font-semibold uppercase tracking-wide m-0 ${a}`,"data-testid":"behavior-group-heading",children:[e," (",n.length,")"]}),t.jsx("div",{className:"space-y-4",children:n.map(o=>t.jsx($2,{behavior:o,rerun:r},`${o.change}:${o.name}`))})]})}const Gse=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGroup:Ec},Symbol.toStringTag,{value:"Module"}));function Lp({ways:e}){return e.length===0?null:t.jsxs("div",{className:"space-y-1.5","data-testid":"ways-to-test",children:[t.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0",children:"Ways to test"}),t.jsx("ul",{className:"list-disc pl-4 space-y-1 m-0",children:e.map((n,s)=>t.jsx("li",{className:"text-sm leading-relaxed","data-testid":"way-to-test",children:nH(n)},s))})]})}function nH(e){return e.kind==="run-scenario"&&e.scenarioUrl?t.jsxs("a",{href:e.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:[e.text,t.jsx("span",{"aria-hidden":"true",className:"text-[10px] opacity-70",children:"↗ open in dev app"})]}):e.kind==="staging-only"?t.jsx("span",{className:"text-[var(--text-muted)] italic","data-testid":"way-to-test-staging-only",children:e.text}):t.jsx("span",{className:"text-[var(--text-primary)]",children:e.text})}const Yse=Object.freeze(Object.defineProperty({__proto__:null,WaysToTestList:Lp},Symbol.toStringTag,{value:"Module"}));function F2({change:e,functions:n=[],rerun:s}){const{worksNow:r,inProgress:a}=E2(e,n);return t.jsxs("section",{className:"space-y-3 pt-4 border-t border-[var(--border-subtle)]","data-testid":"change-card",children:[t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:e.title}),e.description&&t.jsx("p",{className:"text-sm text-[var(--text-secondary)] leading-relaxed m-0",children:e.description}),t.jsx(Lp,{ways:e.waysToTest??[]}),t.jsx(Ec,{label:"Works now",behaviors:r,tone:"positive",rerun:s}),t.jsx(Ec,{label:"In progress",behaviors:a,tone:"pending",rerun:s})]})}const Vse=Object.freeze(Object.defineProperty({__proto__:null,ChangeCard:F2},Symbol.toStringTag,{value:"Module"}));function z2({narrative:e,functions:n=[],rerun:s}){const{unverifiedCount:r}=KW(e,n);return t.jsxs("div",{className:"space-y-6","data-testid":"behavior-gallery",children:[e.summary&&t.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-relaxed m-0",children:e.summary}),e.changes.map((a,o)=>t.jsx(F2,{change:a,functions:n,rerun:s},`${a.title}:${o}`)),r>0&&t.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 Kse=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGallery:z2},Symbol.toStringTag,{value:"Module"}));function B2({step:e}){return t.jsx("div",{className:"text-sm text-[var(--text-muted)]","data-testid":"behavior-gallery-empty",children:t.jsx("span",{"data-testid":"behavior-gallery-prebuild",children:"The build will describe what it’s creating here as it works."})})}const Jse=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGalleryEmptyState:B2},Symbol.toStringTag,{value:"Module"}));function sH(e){const n=e.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||e}}function W2({path:e,status:n,testid:s}){return t.jsxs("li",{className:"flex items-center gap-2","data-testid":s,children:[t.jsx("span",{className:"font-mono text-[var(--text-primary)] truncate",children:e}),t.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:sH(n)})]})}const Xse=Object.freeze(Object.defineProperty({__proto__:null,BuildFileRow:W2},Symbol.toStringTag,{value:"Module"}));function H2({feature:e,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 p of s.flatMap(h=>h.tests)){const h=_p(p);if(!h)continue;const f=q6(p),m=u.get(h);m?m.description===void 0&&f!==void 0&&(m.description=f):u.set(h,{name:h,description:f})}return Array.from(u.values())})(),d=a>=4;return t.jsxs("div",{className:"text-sm space-y-5","data-testid":"build-progress-detail",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-[var(--accent-blue)] animate-pulse","aria-hidden":"true"}),t.jsx("span",{className:"text-[var(--text-primary)] font-medium",children:e?`Building ${e}…`:"Building…"})]}),t.jsxs("section",{"data-testid":"build-areas-changed",children:[t.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?t.jsx("div",{className:"text-[var(--text-muted)]",children:"Gathering changes…"}):t.jsxs("div",{className:"space-y-3",children:[s.length>0&&t.jsx("ul",{className:"list-none pl-0 m-0 space-y-2",children:s.map(u=>t.jsx("li",{children:t.jsx(wp,{fn:u,testid:"build-area-function"})},`${u.filePath}::${u.name}`))}),i.length>0&&t.jsxs("div",{children:[s.length>0&&t.jsx("div",{className:"text-[11px] font-medium text-[var(--text-muted)] mb-1",children:"Other files"}),t.jsx("ul",{className:"list-none pl-0 m-0 space-y-0.5",children:i.map(u=>t.jsx(W2,{path:u.path,status:u.status,testid:"build-area-file"},u.path))})]})]})]}),t.jsxs("section",{"data-testid":"build-tests",children:[t.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&&t.jsxs("span",{className:"ml-1 text-[var(--text-muted)] font-normal normal-case tracking-normal",children:["(",c.length,")"]})]}),c.length===0?t.jsx("div",{className:"text-[var(--text-muted)]",children:"Tests will appear here as they’re written."}):t.jsx("ul",{className:"list-none pl-0 m-0 space-y-1",children:c.map(u=>t.jsxs("li",{"data-testid":"build-test-name",children:[t.jsx("div",{className:"font-mono text-xs text-[var(--text-primary)]",children:u.name}),u.description&&t.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:u.description})]},u.name))})]}),t.jsxs("section",{"data-testid":"build-ways-to-test",children:[t.jsx(Lp,{ways:r??[]}),t.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 Qse=Object.freeze(Object.defineProperty({__proto__:null,BuildProgressDetail:H2},Symbol.toStringTag,{value:"Module"}));function rH(e){return e.filter(Boolean).join(" · ")}function aH(e){if(!e)return"";const n=Math.round(e.global.percent);if(e.previousGlobal==null)return`coverage ${n}%`;const s=Math.round(e.global.percent-e.previousGlobal);if(s===0)return`coverage ${n}% (±0)`;const r=s>0?"+":"−";return`coverage ${n}% (${r}${Math.abs(s)})`}function q2({stats:e,thresholds:n,trendDeltaSecs:s}){if(!e)return null;const r=e.runners.length||e.per_runner.length,a=e.per_runner.filter(i=>i.duration_ms!=null).map(i=>`${i.name} ${Math.round(i.duration_ms/1e3)}s`),o=rH([`${r} runner${r===1?"":"s"}`,`${e.passed} passed`,e.failed>0?`${e.failed} failed`:"",...a,aH(n),XW(s)]);return t.jsx("p",{className:"text-[11px] text-[var(--text-muted)] font-mono m-0","data-testid":"run-evidence-line",children:o})}const Zse=Object.freeze(Object.defineProperty({__proto__:null,RunEvidenceLine:q2},Symbol.toStringTag,{value:"Module"})),oH=5e3;function U2(){const[e,n]=l.useState(null),[s,r]=l.useState(!0),{connectionState:a,recordFetch:o,markPolling:i}=BW(),c=l.useRef(null),d=l.useRef(null);d.current=e;const u=GW({onSummaryUpdate:n,getLastDurationMs:l.useCallback(()=>{var m,g;return(g=(m=d.current)==null?void 0:m.testRunnerStats)==null?void 0:g.duration_ms},[])});if(l.useEffect(()=>{async function m(){const g=await Rc();o(g),g.ok&&g.data&&n(g.data),r(!1)}return m(),()=>{c.current&&clearInterval(c.current)}},[o]),l.useEffect(()=>(c.current&&(clearInterval(c.current),c.current=null),(e==null?void 0:e.live)===!0&&(c.current=setInterval(async()=>{i();const m=await Rc();o(m),m.ok&&m.data&&n(m.data)},oH)),()=>{c.current&&clearInterval(c.current)}),[e==null?void 0:e.live,o,i]),s)return t.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center",children:t.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!e)return t.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 p=e.step??0,h=e.functions.reduce((m,g)=>m+g.tests.length,0),f=IW(p,e.modifiedFiles.length,h);return t.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] p-6",children:t.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[t.jsx(R2,{feature:e.feature,connectionState:a,statusChip:f,userPrompt:e.userPrompt}),t.jsx(q2,{stats:e.testRunnerStats,thresholds:e.coverageThresholds,trendDeltaSecs:e.suiteTrendDeltaSecs}),t.jsx("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:e.narrative?t.jsx(z2,{narrative:e.narrative,functions:e.functions,rerun:u}):p>=3?t.jsx(H2,{feature:e.feature,modifiedFiles:e.modifiedFiles,functions:e.functions,waysToTestBaseline:e.waysToTestBaseline,step:p}):t.jsx(B2,{step:p})})]})})}const ere=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPage:U2},Symbol.toStringTag,{value:"Module"}));function G2(){return t.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:t.jsx(U2,{})})}const tre=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPanelView:G2},Symbol.toStringTag,{value:"Module"}));function Y2({onClose:e,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"&&e()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e]),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onMouseDown:o=>{o.target===o.currentTarget&&e()},children:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-1",children:"Create New State"}),t.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Describe the state you want ",n," to build."]}),t.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)"}}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:e,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"}),t.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 nre=Object.freeze(Object.defineProperty({__proto__:null,CreateStatePlaceholderModal:Y2},Symbol.toStringTag,{value:"Module"}));function V2({dragActive:e,inputRef:n,folderInputRef:s,onDragOver:r,onDragLeave:a,onDrop:o,onFilePick:i,onFolderPick:c}){return t.jsxs(t.Fragment,{children:[t.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 ${e?"var(--accent-active)":"var(--border-default)"}`,borderRadius:12,background:e?"var(--bg-elevated, rgba(255,255,255,0.03))":"var(--bg-input)",cursor:"pointer",textAlign:"center",gap:"var(--spacing-xs, 4px)"},children:[t.jsx("input",{ref:n,type:"file",multiple:!0,onChange:i,style:{display:"none"}}),t.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"}),t.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"PNG, JPG, PDF, Markdown — anything that describes your design"})]}),t.jsx($y,{fileInputRef:n,folderInputRef:s,onFolderPick:c})]})}const sre=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropLabel:V2},Symbol.toStringTag,{value:"Module"}));function K2({pending:e,onDescriptionChange:n,onRemove:s}){return t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500,overflowWrap:"anywhere"},children:e.relativePath}),t.jsx("button",{type:"button",onClick:()=>s(e.id),style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:"Remove"})]}),t.jsx("textarea",{value:e.description,onChange:r=>n(e.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 rre=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCard:K2},Symbol.toStringTag,{value:"Module"}));function J2({pending:e,onDescriptionChange:n,onRemove:s}){return e.length===0?null:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)",marginTop:"var(--spacing-md, 12px)"},children:[t.jsx(Dy,{count:e.length}),e.map(r=>t.jsx(K2,{pending:r,onDescriptionChange:n,onRemove:s},r.id))]})}const are=Object.freeze(Object.defineProperty({__proto__:null,PendingFileList:J2},Symbol.toStringTag,{value:"Module"}));function iH(e){return new Promise(n=>{e.file(s=>n(s),()=>n(null))})}function lH(e){return new Promise(n=>{const s=[],r=()=>{e.readEntries(a=>{if(a.length===0){n(s);return}s.push(...a),r()},()=>n(s))};r()})}function cH(e){return e.split("/").some(n=>n.startsWith("."))}async function X2(e,n,s){if(e.name.startsWith("."))return 0;const r=n?`${n}/${e.name}`:e.name;if(e.isFile){const a=await iH(e);return a?(s.push({file:a,relativePath:r}),0):1}if(e.isDirectory){const a=await lH(e.createReader());let o=0;for(const i of a)o+=await X2(i,r,s);return o}return 0}async function dH(e){const n=e.items;if(!(!!n&&n.length>0&&typeof n[0].webkitGetAsEntry=="function"))return{files:Array.from(e.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 X2(i,"",a);return{files:a,skipped:o,expandedViaEntryApi:!0}}function uH(e){return Array.from(e).map(n=>({file:n,relativePath:n.webkitRelativePath||n.name})).filter(({relativePath:n})=>!cH(n))}function pH(e){return e.size===0&&e.type===""}const hH="Folders can't be read in this browser — open the folder and drop the files inside it.";function fH(e,n,s){const r=[];let a=null;for(const o of e){if(!n&&pH(o.file)){a=hH;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 mH(e){const{files:n,skipped:s,expandedViaEntryApi:r}=e;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}function Q2({message:e}){return e?t.jsx("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-xs, 12px)"},children:e}):null}const ore=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveErrorMessage:Q2},Symbol.toStringTag,{value:"Module"}));function Z2({filenames:e}){return!e||e.length===0?null:t.jsxs("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--text-secondary)",fontSize:"var(--text-xs, 12px)"},children:["Added ",e.length," file",e.length===1?"":"s","."]})}const ire=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveSuccessMessage:Z2},Symbol.toStringTag,{value:"Module"}));function eC({disabled:e,submitting:n,onClick:s}){return t.jsx("button",{type:"button",onClick:s,disabled:e,style:{marginTop:"var(--spacing-md, 12px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",background:e?"var(--bg-input)":"var(--accent-active)",color:e?"var(--text-muted)":"var(--text-on-accent, white)",border:e?"1px solid var(--border-default)":"1px solid var(--accent-active)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontWeight:500,cursor:e?"not-allowed":"pointer"},children:n?"Saving…":"Save assets"})}const lre=Object.freeze(Object.defineProperty({__proto__:null,SaveAssetsButton:eC},Symbol.toStringTag,{value:"Module"})),gH=1024*1024*1024;function tC({onAssetsSaved:e,onRegisterDropReceiver:n}){const[s,r]=l.useState([]),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),[p,h]=l.useState(!1),f=l.useRef(null),m=l.useRef(null),g=l.useCallback((S,w)=>{const{valid:k,rejection:N}=fH(S,w,gH);return u(N),r(C=>[...C,...k.map(({file:T,relativePath:P})=>({id:`${P}-${T.size}-${Math.random().toString(36).slice(2)}`,file:T,relativePath:P,description:""}))]),N!==null},[]),x=l.useCallback(async S=>{const w=await dH(S);if(g(w.files,w.expandedViaEntryApi))return;const k=mH(w);k&&u(k)},[g]);l.useEffect(()=>{if(n)return n(S=>(x(S),!0)),()=>n(null)},[n,x]);const b=l.useCallback(S=>{S.target.files&&g(Array.from(S.target.files).map(w=>({file:w,relativePath:w.name})),!1),S.target.value=""},[g]),y=l.useCallback(S=>{if(S.target.files){const w=uH(S.target.files);g(w,!0),w.length===0&&u("No files found in that folder.")}S.target.value=""},[g]),v=l.useCallback((S,w)=>{r(k=>k.map(N=>N.id===S?{...N,description:w}:N))},[]),j=l.useCallback(S=>{r(w=>w.filter(k=>k.id!==S))},[]),_=l.useCallback(async()=>{if(s.length!==0){o(!0),u(null);try{const S=await Us(s);c(S),r([]),e==null||e(S)}catch(S){u(S instanceof Error?S.message:String(S))}finally{o(!1)}}},[s,e]);return t.jsxs(t.Fragment,{children:[t.jsx(V2,{dragActive:p,inputRef:f,onDragOver:S=>{S.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:S=>{S.preventDefault(),h(!1),x(S.dataTransfer)},onFilePick:b,onFolderPick:y,folderInputRef:m}),t.jsx(J2,{pending:s,onDescriptionChange:v,onRemove:j}),t.jsx(Q2,{message:d}),t.jsx(Z2,{filenames:i}),t.jsx(eC,{disabled:s.length===0||a,submitting:a,onClick:_})]})}const cre=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropZone:tC},Symbol.toStringTag,{value:"Module"}));function nC({onRegisterDropReceiver:e}={}){const[n,s]=l.useState(null),r=l.useRef(!0),a=l.useCallback(async()=>{try{const o=await fetch("/api/editor-design-assets");if(!o.ok)return;const i=await o.json();r.current&&s(Array.isArray(i.assets)?i.assets:[])}catch{}},[]);return l.useEffect(()=>(r.current=!0,a(),()=>{r.current=!1}),[a]),t.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:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"var(--text-md, 15px)",fontWeight:600,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:"Add design assets"}),t.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."})]}),t.jsx(tC,{onAssetsSaved:a,onRegisterDropReceiver:e}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:[t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Added assets"}),n===null?t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"Loading…"}):n.length===0?t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"No assets added yet."}):n.map(o=>t.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:[t.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:500,color:"var(--text-primary)"},children:o.filename}),o.description.trim().length>0&&t.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:o.description})]},o.filename))]})]})}const dre=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetsView:nC},Symbol.toStringTag,{value:"Module"}));function xH(e,n){var c;const s=[],r=Object.entries(n.vars).filter(([,d])=>d&&d.trim());if(r.length>0){const d=r.map(([u,p])=>` ${u}: ${p} !important;`).join(`
|
|
192
|
-
`);s.push(`:root, body {
|
|
193
|
-
${d}
|
|
194
|
-
}`)}if(n.primaryFont){const d=zm(n.primaryFont,n.primaryFontStack);s.push(`body, p, li, span, button, input, textarea, select, label { font-family: ${d} !important; }`)}if(n.secondaryFont){const d=zm(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">
|
|
195
|
-
${s.join(`
|
|
196
|
-
|
|
197
|
-
`)}
|
|
198
|
-
</style>`:"",o=n.fontsHref?`<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
199
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
200
|
-
<link rel="stylesheet" href="${n.fontsHref}" data-codeyam-fonts="1">`:"";if(!a&&!o)return e;const i=e.search(/<\/head\s*>/i);if(i===-1){const d=e.search(/<body[^>]*>/i);if(d===-1)return`${o}
|
|
201
|
-
${a}
|
|
202
|
-
${e}`;const u=d+(((c=e.match(/<body[^>]*>/i))==null?void 0:c[0].length)??0);return`${e.slice(0,u)}
|
|
203
|
-
${o}
|
|
204
|
-
${a}
|
|
205
|
-
${e.slice(u)}`}return`${e.slice(0,i)}
|
|
206
|
-
${o}
|
|
207
|
-
${a}
|
|
208
|
-
${e.slice(i)}`}function zm(e,n){const s=/\s/.test(e)?`"${e}"`:e,r=(n==null?void 0:n.trim())||"system-ui, sans-serif";return`${s}, ${r}`}const bH={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function pa(e){return e.replace(/^\d{1,2}-/,"").replace(/-mockup\.html$/i,"").replace(/\.html$/i,"")}function sC(e){return pa(e).replace(/-/g," ")}function yH(e,n){if(e===null||e.length!==n.length)return!1;for(let s=0;s<e.length;s++)if(e[s].filename!==n[s].filename||e[s].url!==n[s].url||e[s].name!==n[s].name)return!1;return!0}const vH="\x1B[200~",jH="\x1B[201~";function Ac(e,n=wH,s=cd){const r=e.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),a=`${vH}${r}${jH}`;return n(a),new Promise(o=>{setTimeout(()=>{n("\r"),o()},s)})}function wH(e){Sn(e,Eb()??QR)}const Hr=5;function $p(e){return e==null?0:Math.max(1,Math.min(Hr,Math.round(e/(100/Hr))))}function _H(e){return e<=0?null:Math.min(Hr,e)*(100/Hr)}const Bm='which of four things should happen to each design in the next round: Keep it unchanged, Iterate on it (refine in place), make Multiple versions of it (2-4 variations), or Replace it with a fresh redesign. Wait for their reply before writing any mockup. This is NOT a selection: the user has not picked or locked in any design, and a high rating is not a pick. Do not select a design, and do not tell them they chose one. In your question, name each design by its number and plain name and suggest a choice for each, then end the message with your suggestion as a fenced block the chat reads and hides, e.g. ```design-plan {"01-foo-mockup.html":"keep","02-bar-mockup.html":"iterate","03-baz-mockup.html":"replace"} ``` (verbs: keep, iterate, versions, replace).';function SH({feedbackByFilename:e,mockupFilenames:n,titles:s={},feedbackFile:r}){const a={};for(const d of n){const u=e[d];if(!u)continue;const p=typeof u.rating=="number",h=u.comment.trim().length>0;!p&&!h||(a[d]={rating:p?u.rating:null,comment:u.comment.trim()})}const o=Object.keys(a);if(o.length===0)return"Iterate: before regenerating anything, first ask the user in the chat "+Bm+" No per-card feedback was provided, so let their answer guide what happens to each design.";const i=JSON.stringify(a,null,2),c=o.map(d=>{const{rating:u,comment:p}=a[d],h=s[d]?` (${s[d]})`:"",f=u===null?"no stars":`${$p(u)}/5 stars`,m=p?` Note: "${p}"`:" No note.";return`- ${d}${h}: ${f}.${m}`}).join(`
|
|
209
|
-
`);return"Iterate: before regenerating anything, first ask the user in the chat "+Bm+` Base your suggestion on the ratings below.
|
|
210
|
-
|
|
211
|
-
Once they answer, follow their choice for each design exactly: Keep = leave the file untouched. Iterate = refine it in place using its specific feedback, keeping the same numeric prefix and design system. Multiple versions = make the requested number of distinct variations of its direction; the first reuses its numeric prefix, the rest take the next free numbers, never overwriting a kept slot. Replace = 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.
|
|
212
|
-
|
|
213
|
-
Every note is a must-fix for every design you change: iterating on a design never means keeping what its note complained about. Notes may be in any language. Follow Step 5 of the codeyam-design skill: write the feedback checklist before editing, and check each new file against it before you say the round is done.
|
|
214
|
-
|
|
215
|
-
Feedback, design by design:
|
|
216
|
-
`+c+`
|
|
217
|
-
|
|
218
|
-
`+(r?`The same feedback is saved in ${r}; re-read it right before you write the new designs.
|
|
219
|
-
|
|
220
|
-
`:"")+"Per-card feedback (rating is 1-100 or null; comment may be empty):\n\n```json\n"+i+"\n```"}const kH=9e4;function NH(e){return!!(e.agentRespondedAfterDispatch||CH(e.snapshotFilenames,e.latestFilenames))}function CH(e,n){if(e.length!==n.length)return!0;const s=[...e].sort(),r=[...n].sort();for(let a=0;a<s.length;a++)if(s[a]!==r[a])return!0;return!1}function TH(e){const n={},s={},r=e.split(`
|
|
221
|
-
`);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 p=u[1].replace(/`/g,"").trim(),h=u[2].replace(/`/g,"").trim();if(!/^--[A-Za-z0-9_-]+$/.test(p)||!PH(h))continue;const f=o.filter(Boolean).join(" / "),m=rC(f)?s:n;p in m||(m[p]=h)}return{light:n,dark:s}}function rC(e){return/\bdark[\s-]?mode\b|\bdark\b\s*(palette|variant|theme)?/i.test(e)}function PH(e){return!!(/^#[0-9a-fA-F]{3,8}$/.test(e)||/^rgba?\(/i.test(e)||/^hsla?\(/i.test(e)||/^oklch\(/i.test(e))}const OH=["Background","Surface","Text","Primary","Secondary","Accent"],RH={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 EH(e){const n=[],s=e.split(`
|
|
222
|
-
`);let r=!1,a="",o=0,i=null,c=[];for(let d=0;d<s.length;d++){const p=s[d].trim();if(!r){const h=/^(#{1,6})\s+(.+)$/.exec(p);if(h){const m=h[1].length;c=c.slice(0,m-1),c[m-1]=h[2].trim(),i=h[2].trim();continue}const f=/^```(\w*)/.exec(p);f&&(r=!0,a=f[1].toLowerCase(),o=d+1);continue}if(p==="```"){if(a==="css"||a===""){const h=s.slice(o,d).join(`
|
|
223
|
-
`);for(const f of MH(h)){const m=c.filter(Boolean).join(" / "),g=AH(f.selector)||rC(m);n.push({selector:f.selector,heading:i,isDark:g,vars:f.vars})}}r=!1,a=""}}return n}function AH(e){return/\[data-theme[~|*$^]?="?dark"?\]/.test(e)}function MH(e){const n=[],s=/(:root[^\{]*?)\{([\s\S]*?)\}/g;let r;for(;(r=s.exec(e))!==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],p=d[2].replace(/\/\*.*?\*\//g,"").trim();p&&(i[u]=p)}Object.keys(i).length>0&&n.push({selector:a,vars:i})}return n}function IH(e,n){const s=RH[n];for(const r of Object.keys(e))for(const a of s)if(a.test(r))return{cssVar:r,value:e[r]};return{cssVar:null,value:null}}function DH(e){const n=/\[data-palette[~|*$^]?="?([^"\]]+)"?\]/.exec(e);return n?n[1].split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null}function LH(e){if(!e)return"Default";let n=e.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 Wm(e){const n=OH.map(s=>{const{cssVar:r,value:a}=IH(e,s);return{label:s,cssVar:r,value:a}});return{vars:e,slots:n}}function Fp(e){const n=EH(e),s=new Map,r=new Map,a=[];for(const o of n){const c=DH(o.selector)??LH(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=TH(e);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:Wm(i),dark:c?Wm(c):null}}).filter(o=>o!==null)}function $H(e){const n=Object.keys(e);if(n.length===0)return{};const s=lC(e),r={};for(const a of n){const o=e[a];if(!o||!o.trim())continue;const i=s.get(a)??null;r[a]=zH(o,i)}return r}const aC="#0f1115",FH="#181b21",oC="#e8eaed";function iC(e){const n=lC(e);let s=null,r=null;for(const[a,o]of n){const i=e[a];!i||!i.trim()||(o==="Background"&&s===null&&(s=i),o==="Text"&&r===null&&(r=i))}return{bg:s??aC,text:r??oC}}function lC(e){var i;const s=["```css",":root {",Object.entries(e).map(([c,d])=>` ${c}: ${d};`).join(`
|
|
224
|
-
`),"}","```"].join(`
|
|
225
|
-
`),r=Fp(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 zH(e,n){switch(n){case"Background":return aC;case"Surface":return FH;case"Text":return oC;case"Primary":case"Secondary":case"Accent":return Hm(e);default:return Hm(e)}}function Hm(e){const n=BH(e.trim());if(!n)return e;const{h:s,s:r,l:a}=WH(n.r,n.g,n.b),{r:o,g:i,b:c}=HH(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 BH(e){const n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e);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(e);return s?{r:il(parseInt(s[1],10)),g:il(parseInt(s[2],10)),b:il(parseInt(s[3],10)),a:s[4]!=null?parseFloat(s[4]):void 0}:null}function il(e){return Math.max(0,Math.min(255,e))}function WH(e,n,s){const r=e/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,p=0;if(i!==c){const h=i-c;switch(p=d>.5?h/(2-i-c):h/(i+c),i){case r:u=(a-o)/h+(a<o?6:0);break;case a:u=(o-r)/h+2;break;default:u=(r-a)/h+4;break}u/=6}return{h:u,s:p,l:d}}function HH(e,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,e+1/3)*255),g:Math.round(r(o,a,e)*255),b:Math.round(r(o,a,e-1/3)*255)}}function qH(e){const[n,s]=l.useState({}),r=l.useRef(!0);return l.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),l.useEffect(()=>{if(!e)return;const a=new Set,o=e.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 p=await fetch(`/api/editor-design-systems/${u}`);if(!p.ok)continue;const h=await p.json().catch(()=>null);if(!(h!=null&&h.content)){r.current&&s(b=>({...b,[u]:null}));continue}const f=Fp(h.content),m=((c=(i=f[0])==null?void 0:i.dark)==null?void 0:c.vars)??null,g=((d=f[0])==null?void 0:d.light.vars)??null,x=m&&Object.keys(m).length>0?m:g&&Object.keys(g).length>0?$H(g):null;r.current&&s(b=>({...b,[u]:x}))}catch{r.current&&s(p=>({...p,[u]:null}))}})()},[e,n]),n}function UH(){const[e,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)}},[]),e}function cC({round:e,onRestore:n,restoring:s=!1}){if(!e||!e.mockups||e.mockups.length===0)return t.jsx(uu,{});const r=e.feedback??{};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-md, 14px)"},children:[n&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.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"})}),t.jsx("div",{"data-mockup-archived-round":!0,style:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:e.mockups.map((a,o)=>{const i=r[a.filename],c=o+1,d=a.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return t.jsxs("div",{style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[t.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:[t.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(c).padStart(2,"0")}),t.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{textTransform:"capitalize",fontWeight:500,color:"var(--text-primary)",textDecoration:"none"},children:d})]}),t.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)&&t.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"&&t.jsxs("div",{children:[t.jsxs("span",{style:{color:"var(--text-muted)"},children:["Rating ·"," "]}),t.jsxs("span",{style:{color:"var(--text-primary)"},children:[i.rating,"/100"]})]}),i.comment.trim().length>0&&t.jsxs("div",{style:{lineHeight:1.4},children:[t.jsxs("span",{style:{color:"var(--text-muted)"},children:["Note ·"," "]}),t.jsx("span",{style:{color:"var(--text-primary)"},children:i.comment})]})]})]},a.filename)})})]})}const ure=Object.freeze(Object.defineProperty({__proto__:null,MockupArchivedRoundView:cC},Symbol.toStringTag,{value:"Module"})),GH=`
|
|
226
|
-
.mockup-feedback-comment {
|
|
227
|
-
width: 100%;
|
|
228
|
-
padding: var(--spacing-sm, 8px) var(--spacing-sm, 10px);
|
|
229
|
-
background: var(--bg-card, #1a1a1a);
|
|
230
|
-
color: var(--text-primary);
|
|
231
|
-
border: 1px solid var(--border-default);
|
|
232
|
-
border-radius: 6px;
|
|
233
|
-
font-size: var(--text-xs, 12px);
|
|
234
|
-
line-height: 1.4;
|
|
235
|
-
resize: vertical;
|
|
236
|
-
box-sizing: border-box;
|
|
237
|
-
min-height: 56px;
|
|
238
|
-
outline: none;
|
|
239
|
-
}
|
|
240
|
-
.mockup-feedback-comment:focus,
|
|
241
|
-
.mockup-feedback-comment:focus-visible {
|
|
242
|
-
border-color: var(--text-primary, #ffffff);
|
|
243
|
-
outline: none;
|
|
244
|
-
box-shadow: 0 0 0 1px var(--text-primary, #ffffff);
|
|
245
|
-
}
|
|
246
|
-
`;function dC({comment:e,onCommentChange:n,autoFocus:s=!1}){return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:GH}),t.jsx("textarea",{autoFocus:s,"aria-label":"Feedback on this design",value:e,onChange:r=>n(r.target.value),placeholder:"What do you like or would like to change? (optional)",rows:3,className:"mockup-feedback-comment"})]})}const pre=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackCommentBox:dC},Symbol.toStringTag,{value:"Module"}));function zp({rating:e,onRatingChange:n,size:s=18}){const[r,a]=l.useState(0),o=$p(e),i=r||o;return t.jsx("div",{role:"group","aria-label":"Rate this design","data-testid":"mockup-stars",onMouseLeave:()=>a(0),style:{display:"inline-flex",gap:2},children:Array.from({length:Hr},(c,d)=>{const u=d+1,p=u<=i;return t.jsx("button",{type:"button","aria-label":`${u} star${u>1?"s":""}`,"aria-pressed":u<=o,onMouseEnter:()=>a(u),onClick:h=>{h.stopPropagation(),n(_H(u===o?0:u))},style:{background:"transparent",border:"none",padding:1,cursor:"pointer",lineHeight:0,color:p?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.25)"},children:t.jsx("svg",{width:s,height:s,viewBox:"0 0 20 20","aria-hidden":"true",children:t.jsx("path",{d:"M10 1.8l2.5 5.1 5.6.8-4 4 .9 5.6L10 14.7l-5 2.6.9-5.6-4-4 5.6-.8z",fill:p?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})})},u)})})}const hre=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackStars:zp},Symbol.toStringTag,{value:"Module"})),Bp={rating:null,comment:""};function uC({value:e,onChange:n}){const[s,r]=l.useState(!1),[a,o]=l.useState(!1),i=s||e.rating!=null||e.comment.length>0;return t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(zp,{rating:e.rating,onRatingChange:c=>{i||o(!0),r(!0),n({...e,rating:c})}}),!i&&t.jsx("button",{type:"button",onClick:()=>{r(!0),o(!0)},style:{marginLeft:"auto",background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:12.5,color:"var(--text-muted)"},children:"Add a note"})]}),i&&t.jsx(dC,{comment:e.comment,autoFocus:a,onCommentChange:c=>n({...e,comment:c})})]})}const fre=Object.freeze(Object.defineProperty({__proto__:null,EMPTY_FEEDBACK:Bp,MockupCardFeedback:uC},Symbol.toStringTag,{value:"Module"})),Wp=["Background","Surface","Text","Primary","Secondary","Accent"],YH={Background:["bg","background","canvas","page","paper","base"],Surface:["surface","card","panel","elevated","raised","sheet","cream"],Text:["text","fg","foreground","ink","copy"],Primary:["primary","accent","brand"],Secondary:["secondary"],Accent:["highlight","tertiary"]},VH=new Set(["black","white","transparent","currentcolor"]);function Hp(e){const n=e.trim().toLowerCase();return n?/^#[0-9a-f]{3,8}$/.test(n)||/^(rgb|rgba|hsl|hsla|oklch|oklab|lab|lch|color)\(/.test(n)?!0:VH.has(n):!1}function qp(e){const n={};for(const[s,r]of KH(e)){if(/dark/i.test(s))continue;const a=/(--[A-Za-z0-9_-]+)\s*:\s*([^;\n}]+?)\s*(?:;|$)/g;let o;for(;(o=a.exec(r))!==null;){const i=o[2].replace(/\/\*.*?\*\//g,"").replace(/\s*!important\s*$/i,"").trim();i&&(o[1]in n||(n[o[1]]=i))}}return n}function KH(e){const n=[];let s=0;for(let r=e.indexOf(":root",s);r>=0;r=e.indexOf(":root",s)){const a=e.indexOf("{",r+5),o=a<0?-1:e.indexOf("}",a+1);if(o<0)break;const i=Math.max(s,e.lastIndexOf("{",r)+1,e.lastIndexOf("}",r)+1);n.push([e.slice(i,a),e.slice(a+1,o)]),s=o+1}return n}function JH(e,n){const s=e.replace(/^--/,"").split("-").filter(Boolean),r=YH[n];let a=null;for(let o=0;o<r.length;o++){const i=s.lastIndexOf(r[o]);if(i===-1)continue;const c=o*10+(s.length-1-i);(a===null||c<a)&&(a=c)}return a}function XH(e){let n=null;for(const s of Wp){const r=JH(e,s);r!==null&&(!n||r<n.score)&&(n={role:s,score:r})}return n}function QH(e){const n=e.trim().toLowerCase();if(n==="transparent")return!0;const s=/^#([0-9a-f]{4}|[0-9a-f]{8})$/.exec(n);if(s)return s[1].length===4?!s[1].endsWith("f"):!s[1].endsWith("ff");const r=/^(?:rgba?|hsla?)\([^)]*[,/]\s*([\d.]+)(%?)\s*\)$/.exec(n);return r&&(n.match(/[\d.]+%?/g)??[]).length===4?(r[2]?parseFloat(r[1])/100:Number(r[1]))<1:!1}function ZH(e){const n=e7(e);if(!n)return 0;const s=Math.max(n[0],n[1],n[2]),r=Math.min(n[0],n[1],n[2]);return s===0?0:(s-r)/s}function e7(e){const n=e.trim(),s=/^#([0-9a-fA-F]{3,8})$/.exec(n);if(s){const a=s[1];return a.length===3||a.length===4?[parseInt(a[0]+a[0],16),parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16)]:a.length===6||a.length===8?[parseInt(a.slice(0,2),16),parseInt(a.slice(2,4),16),parseInt(a.slice(4,6),16)]:null}const r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(n);return r?[Number(r[1]),Number(r[2]),Number(r[3])]:null}function Up(e,n=[]){const s=qp(e),r=Object.keys(s).filter(d=>Hp(s[d])&&!QH(s[d])),a=new Map,o=new Set,i=new Map;for(const d of r){const u=XH(d);if(!u)continue;const p=i.get(u.role);(!p||u.score<p.score)&&i.set(u.role,{name:d,score:u.score})}for(const[d,{name:u}]of i)a.set(d,u),o.add(u);for(const d of n)a.has(d.label)||!d.cssVar||o.has(d.cssVar)||d.cssVar in s&&(a.set(d.label,d.cssVar),o.add(d.cssVar));const c=r.filter(d=>!o.has(d)).map(d=>({name:d,sat:ZH(s[d])})).filter(d=>d.sat>.3).sort((d,u)=>u.sat-d.sat);for(const d of["Primary","Secondary","Accent"]){if(a.has(d))continue;const u=c.find(p=>!o.has(p.name));if(!u)break;a.set(d,u.name),o.add(u.name)}return Wp.map(d=>{const u=a.get(d)??null;return{label:d,cssVar:u,value:u?s[u]:null}})}function t7(e){const n=qp(e);return Object.entries(n).flatMap(([s,r])=>{const a=/^(\d+(?:\.\d+)?)px$/.exec(r.trim());return/radius/i.test(s)&&a?[{name:s,px:parseFloat(a[1])}]:[]})}function n7(e,n){const s=Math.max(...e.map(r=>r.px));return Object.fromEntries(e.map(r=>[r.name,`${s>0?Math.round(r.px/s*n):n}px`]))}const Gp=[{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]}],mre={sans:"Sans-serif",serif:"Serif",display:"Display",mono:"Monospace"};function pC(e){const n=new Set,s=[];for(const r of e){if(!r||n.has(r))continue;n.add(r);const a=Gp.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`}const s7=new Set(["Background","Surface","Text"]),r7=.3;function Mc(e,n,s){const r=qp(e),a=n.filter(c=>!!c.cssVar&&!!c.value).map(c=>({cssVar:c.cssVar,neutral:c.label?s7.has(c.label):!1,rgba:Ds(c.value)})).filter(c=>c.rgba!==null),o=new Set(a.map(c=>c.cssVar)),i={};for(const[c,d]of Object.entries(r)){if(o.has(c)||!Hp(d))continue;const u=Ds(d);if(!u)continue;const p=Nn(u).s<r7,h=p&&a.some(x=>x.neutral)?a.filter(x=>x.neutral):a;let f=null,m=1/0;for(const x of h){const b=p?Math.abs(Nn(u).l-Nn(x.rgba).l):o7(u,x.rgba);b<m&&(m=b,f=x)}if(!f||!(f.cssVar in s))continue;const g=Ds(s[f.cssVar]);g&&(i[c]=Ic(a7(u,f.rgba,g)))}return i}function a7(e,n,s){const r=Nn(e),a=Nn(n),o=Nn(s),c=a.s>.12&&r.s>.12?(o.h+(r.h-a.h)+360)%360:o.h,d=qm(o.s+(r.s-a.s)),u=a.l>.5!=o.l>.5?-1:1,p=qm(o.l+u*(r.l-a.l));return{...Dc(c,d,p),a:e.a}}function o7(e,n){return Math.hypot(e.r-n.r,e.g-n.g,e.b-n.b)}function qm(e){return Math.min(1,Math.max(0,e))}function Ds(e){const n=e.trim().toLowerCase();if(n==="white")return{r:255,g:255,b:255,a:1};if(n==="black")return{r:0,g:0,b:0,a:1};const s=/^#([0-9a-f]{3,8})$/.exec(n);if(s){const a=s[1];if(a.length===3||a.length===4){const o=i=>parseInt(a[i]+a[i],16);return{r:o(0),g:o(1),b:o(2),a:a.length===4?o(3)/255:1}}if(a.length===6||a.length===8){const o=i=>parseInt(a.slice(i,i+2),16);return{r:o(0),g:o(2),b:o(4),a:a.length===8?o(6)/255:1}}return null}const r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(n);if(r){const a=r[4]===void 0?1:r[4].endsWith("%")?parseFloat(r[4])/100:Number(r[4]);return{r:Number(r[1]),g:Number(r[2]),b:Number(r[3]),a}}return null}function Ic(e){const n=Math.round(e.r),s=Math.round(e.g),r=Math.round(e.b);return e.a>=1?`#${[n,s,r].map(a=>a.toString(16).padStart(2,"0")).join("")}`:`rgba(${n}, ${s}, ${r}, ${Math.round(e.a*1e3)/1e3})`}function Nn({r:e,g:n,b:s}){const r=e/255,a=n/255,o=s/255,i=Math.max(r,a,o),c=Math.min(r,a,o),d=(i+c)/2;if(i===c)return{h:0,s:0,l:d};const u=i-c,p=d>.5?u/(2-i-c):u/(i+c);let h;return i===r?h=(a-o)/u+(a<o?6:0):i===a?h=(o-r)/u+2:h=(r-a)/u+4,{h:h*60,s:p,l:d}}function Dc(e,n,s){if(n===0)return{r:s*255,g:s*255,b:s*255};const r=s<.5?s*(1+n):s+n-s*n,a=2*s-r,o=e/360,i=c=>{let d=c;return d<0&&(d+=1),d>1&&(d-=1),d<1/6?a+(r-a)*6*d:d<1/2?r:d<2/3?a+(r-a)*(2/3-d)*6:a};return{r:i(o+1/3)*255,g:i(o)*255,b:i(o-1/3)*255}}function hC(e,n,s){const r={},a=Um(e,s),o=Um(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 Um(e,n){return e?n==="dark"&&e.dark?e.dark.slots:e.light.slots:[]}function i7(e){if(!e.some(r=>r.cssVar))return;const n={};for(const r of e)r.cssVar&&r.value&&(n[r.cssVar]=r.value);const s={vars:n,slots:e};return{name:"Mockup",light:s,dark:s}}function l7(e,n,s){const r=i7(e);if(!r)return{};const a=hC(r,n,s),o=new Set(e.map(i=>i.cssVar).filter(i=>!!i));return Object.fromEntries(Object.entries(a).filter(([i])=>o.has(i)))}function fC(e){var g,x,b,y,v,j;const n=c7(e);if(Object.keys(n).filter(_=>Hp(n[_])).length>=2)return{vars:n,...iC(n),source:"own"};const s=Up(e),r=_=>s.find(S=>S.label===_),a=r("Background"),o=a!=null&&a.value?Ds(a.value):null;if(!(a!=null&&a.cssVar)||!o||Nn(o).l<.45)return null;const c=(_,S,w)=>{const k=_?Ds(_):null;if(!k)return null;const N=Nn(k);return Ic({...Dc(N.h,Math.min(N.s,w),S),a:k.a})},d=_=>{const S=_?Ds(_):null;if(!S)return null;const w=Nn(S);return Ic({...Dc(w.h,w.s,Math.max(w.l,.62)),a:S.a})},u={},p=(_,S)=>{const w=r(_);w!=null&&w.cssVar&&S&&(u[w.cssVar]=S)};p("Background",c(a.value,.08,.22)),p("Surface",c(((g=r("Surface"))==null?void 0:g.value)??a.value,.125,.2)),p("Text",c(((x=r("Text"))==null?void 0:x.value)??"#111111",.92,.1)),p("Primary",d(((b=r("Primary"))==null?void 0:b.value)??null)),p("Secondary",d(((y=r("Secondary"))==null?void 0:y.value)??null)),p("Accent",d(((v=r("Accent"))==null?void 0:v.value)??null));const h={...Mc(e,s,u),...u},f=a.cssVar,m=(j=r("Text"))==null?void 0:j.cssVar;return{vars:h,bg:h[f]??"#141414",text:m&&h[m]||"#ececec",source:"derived"}}function c7(e){const n={},s=a=>{const o=/(--[A-Za-z0-9_-]+)\s*:\s*([^;}]+?)\s*(?:;|$)/g;let i;for(;(i=o.exec(a))!==null;){const c=i[2].replace(/\/\*.*?\*\//g,"").replace(/\s*!important\s*$/i,"").trim();c&&!(i[1]in n)&&(n[i[1]]=c)}};for(const[a,o]of Gm(e))/data-theme\s*=\s*["']?dark|\.dark\b/i.test(a)&&s(o);const r=/@media[^{]*prefers-color-scheme\s*:\s*dark[^{]*\{/gi;for(;r.exec(e)!==null;){let a=1,o=r.lastIndex;const i=o;for(;o<e.length&&a>0;)e[o]==="{"?a++:e[o]==="}"&&a--,o++;const c=e.slice(i,o-1);for(const[d,u]of Gm(c))/:root|html|body/i.test(d)&&s(u)}return n}function Gm(e){const n=[];let s=0,r=-1;for(let a=0;a<e.length;a++){const o=e[a];o==="{"?(r>=0&&(s=r+1),r=a):o==="}"&&(r>=0&&n.push([e.slice(s,r),e.slice(r+1,a)]),s=a+1,r=-1)}return n}function Yp(e){const n=/<meta\b[^>]*>/gi;let s;for(;(s=n.exec(e))!==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 mC(e,n){const{vars:s,bg:r,text:a}=d7(n),o=Object.entries(s).filter(([,h])=>h&&h.trim());if(o.length===0)return e;const i=[`:root {
|
|
247
|
-
`+o.map(([h,f])=>` ${h}: ${f};`).join(`
|
|
248
|
-
`)+`
|
|
249
|
-
}`,":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(`
|
|
250
|
-
`)}</style>`;if(e.search(/<\/head\s*>/i)===-1)return`${c}
|
|
251
|
-
${e}`;const u=u7(e),p=u.search(/<\/head\s*>/i);return`${u.slice(0,p)}
|
|
252
|
-
${c}
|
|
253
|
-
${u.slice(p)}`}function d7(e){return e&&typeof e=="object"&&"vars"in e&&typeof e.vars=="object"?e:{vars:e}}function u7(e){const n=/<html\b([^>]*)>/i,s=n.exec(e);if(!s)return e;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 e.replace(n,`<html${r}>`)}function p7(e,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(e),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:Fp(d)})}catch(o){a||r({kind:"error",message:o instanceof Error?o.message:String(o)})}})(),()=>{a=!0}},[e,n]),s}const h7={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function f7(e,n,s){const r=p7(e,n),[a,o]=l.useState(s),[i,c]=l.useState(null),[d,u]=l.useState("light"),p=l.useMemo(()=>{const w=[];return a.primaryFont&&w.push(a.primaryFont),a.secondaryFont&&w.push(a.secondaryFont),w.length===0?null:pC(w)},[a.primaryFont,a.secondaryFont]),h=l.useMemo(()=>r.kind==="ready"?fC(r.html):null,[r]),f=l.useMemo(()=>d==="dark"&&h?{...h.vars,...a.vars}:a.vars,[d,h,a.vars]),m=l.useMemo(()=>{if(r.kind!=="ready")return"";const w=d==="dark"&&h?mC(r.html,h):r.html;return xH(w,{...a,fontsHref:p})},[r,a,d,h,p]),g=l.useMemo(()=>{var k,N;if(r.kind!=="ready")return[];const w=d==="dark"&&((k=r.palettes[0])!=null&&k.dark)?r.palettes[0].dark.slots:((N=r.palettes[0])==null?void 0:N.light.slots)??[];return Up(r.html,w)},[r,d]),x=g.some(w=>w.cssVar),b=l.useCallback(w=>{c(w.name);const k=x?l7(g,w,d):hC(r.kind==="ready"?r.palettes[0]:void 0,w,d),N=x&&r.kind==="ready"?Mc(r.html,g,k):{};o(C=>({...C,vars:{...C.vars,...N,...k}}))},[x,r,g,d]),y=l.useCallback((w,k)=>{c(null);const N=r.kind==="ready"?Mc(r.html,g,{[w]:k}):{};o(C=>({...C,vars:{...C.vars,...N,[w]:k}}))},[r,g]),v=l.useCallback(()=>{o(h7),c(null)},[]),j=l.useMemo(()=>x?d!=="dark"||!h?g:g.map(w=>w.cssVar&&h.vars[w.cssVar]?{...w,value:h.vars[w.cssVar]}:w):Wp.map(w=>({label:w,cssVar:null,value:null})),[x,g,d,h]),_=!!h,S=Object.keys(a.vars).length>0||!!a.primaryFont||!!a.secondaryFont;return{state:r,overrides:a,setOverrides:o,theme:d,setTheme:u,hasDark:_,srcDoc:m,stackedVars:f,slots:j,activePaletteName:i,applyPalette:b,changeColor:y,reset:v,isEdited:S}}const m7=3;function g7(e){const[n,s]=l.useState([]),r=e.map(a=>a.url).join("|");return l.useEffect(()=>{let a=!1;return Promise.all(e.map(async o=>{try{const i=await fetch(o.url);if(!i.ok)return null;const c=Up(await i.text());return c.filter(d=>d.value).length<m7?null:{name:o.name,light:{vars:{},slots:c},dark:null}}catch{return null}})).then(o=>{a||s(o.filter(i=>i!==null))}),()=>{a=!0}},[r]),n}function gC({message:e}){return t.jsx("div",{style:{padding:"var(--spacing-md, 12px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:e})}const gre=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeErrorBanner:gC},Symbol.toStringTag,{value:"Module"})),kt={bezel:14,outerRadius:56,screenRadius:44,bodyColor:"#0d0d0f",ringColor:"rgba(255, 255, 255, 0.14)",notchWidth:120,notchHeight:30,notchTopInset:10,notchColor:"#0d0d0f",homeIndicatorWidth:134,homeIndicatorHeight:5,homeIndicatorBottomInset:8,homeIndicatorColor:"rgba(0, 0, 0, 0.35)"};function xC(e){return e==="mobile"}function x7(e){return xC(e)?kt.bezel:0}const yi={desktop:{w:1440,h:900},tablet:{w:834,h:1112},mobile:{w:390,h:844}},Ym="desktop",Lc=1280,$c=1280;function bC(e){const n=yi[e],s=x7(e);return{w:n.w+s*2,h:n.h+s*2}}function b7(e){const[n,...s]=e;return n?s.some(r=>r!==n)?{w:Lc,h:$c}:bC(n):{w:Lc,h:$c}}const yC=Hs.backgroundColor,vC=Hs.backgroundImage,jC=Hs.backgroundSize;function y7(e,n,s,r){if(e<=0||n<=0||s<=0||r<=0)return{scale:0,offsetX:0,offsetY:0};const a=Math.min(e/s,n/r),o=s*a,i=r*a;return{scale:a,offsetX:Math.max(0,(e-o)/2),offsetY:Math.max(0,(n-i)/2)}}function v7(e,n,s){if(e<=0||n<=0)return{scale:0,frameW:s,frameH:0,boxW:0};const r=Math.min(1,e/s);return{scale:r,frameW:s,frameH:Math.round(n/r),boxW:Math.round(s*r)}}function wC({html:e,srcDoc:n,theme:s,mockupUrl:r,mockupName:a}){const o=Yp(e)??"desktop",i=o==="mobile"||o==="tablet",c=yi[o].w,d=l.useRef(null),[u,p]=l.useState({w:0,h:0});l.useEffect(()=>{const m=d.current;if(!m)return;const g=()=>p({w:m.clientWidth,h:m.clientHeight});if(g(),typeof ResizeObserver>"u")return;const x=new ResizeObserver(g);return x.observe(m),()=>x.disconnect()},[]);const f=u.w>0&&u.h>0?v7(u.w,u.h,c):{scale:1,frameW:c,frameH:800,boxW:c};return t.jsx("div",{ref:d,"data-testid":"customize-preview-pane",style:{flex:1,minHeight:0,overflow:"hidden",position:"relative",background:i?yC:"white",backgroundImage:i?vC:void 0,backgroundSize:i?jC:void 0,display:"flex",justifyContent:"center"},children:t.jsx("div",{style:{position:"relative",width:f.boxW,height:"100%",flexShrink:0},children:t.jsx("iframe",{title:`Customize preview: ${a}`,srcDoc:n,sandbox:"","data-viewport":o,style:{position:"absolute",top:0,left:0,width:f.frameW,height:f.frameH,transform:f.scale===1?void 0:`scale(${f.scale})`,transformOrigin:"top left",border:"none",background:"white"}},`${r}-${s}`)})})}const xre=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePreviewArea:wC},Symbol.toStringTag,{value:"Module"}));function j7(e){const n=e.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 Vp=["Fraunces","Source Serif 4","Playfair Display","Inter","DM Sans","Nunito","Space Grotesk","Bricolage Grotesque","IBM Plex Mono"],Vm=/^#[0-9a-f]{6}$/i,Fc={display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,fontWeight:500,letterSpacing:".08em",textTransform:"uppercase",color:"rgba(255,255,255,.4)",marginBottom:10};function Va({title:e,aside:n,children:s}){return t.jsxs("section",{children:[t.jsxs("div",{style:Fc,children:[e,t.jsx("span",{style:{flex:1}}),n]}),s]})}function _C({slot:e,value:n,onChange:s}){const[r,a]=l.useState(null),o=r??n,i=r!==null&&r.length>=7&&!Vm.test(r);return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"28px 1fr 92px",alignItems:"center",gap:10,padding:"3px 0"},children:[t.jsx("label",{style:{position:"relative",width:28,height:28,borderRadius:8,border:"1px solid rgba(255,255,255,.2)",overflow:"hidden",cursor:"pointer",background:n},children:t.jsx("input",{type:"color","aria-label":`${e.label} color`,value:j7(n),onChange:c=>s(c.target.value),style:{position:"absolute",inset:-8,width:44,height:44,opacity:0,cursor:"pointer"}})}),t.jsx("span",{style:{fontSize:13,color:"var(--text-secondary)"},children:e.label}),t.jsx("input",{"aria-label":`${e.label} hex`,value:o,spellCheck:!1,maxLength:7,onChange:c=>{let d=c.target.value.trim();d&&d[0]!=="#"&&(d=`#${d}`),a(d),Vm.test(d)&&s(d)},onBlur:()=>a(null),style:{width:"100%",height:28,background:"rgba(255,255,255,.04)",border:`1px solid ${i?"#E5484D":"rgba(255,255,255,.1)"}`,borderRadius:7,color:"var(--text-primary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,padding:"0 8px",textTransform:"uppercase",outline:"none"}})]})}function zc({label:e,value:n,onChange:s,showAll:r}){const a=r?Gp.map(i=>i.family):Vp,o=(i,c)=>{const d=n===i;return t.jsx("button",{type:"button","aria-pressed":d,"aria-label":`${e}: ${c}`,onClick:()=>s(i),style:{padding:"6px 11px",borderRadius:8,border:`1px solid ${d?"rgba(215,255,99,.6)":"rgba(255,255,255,.12)"}`,background:d?"rgba(215,255,99,.12)":"transparent",color:d?"var(--text-primary)":"var(--text-secondary)",fontFamily:i?`'${i}', inherit`:"inherit",fontSize:14,cursor:"pointer"},children:c},c)};return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:16},children:[o(null,"Design's own"),a.map(i=>o(i,i))]})}function SC({slots:e,vars:n,onColorChange:s,palettes:r,activePaletteName:a,theme:o,onApplyPalette:i,headingFont:c,bodyFont:d,onHeadingFont:u,onBodyFont:p,radius:h,onRadius:f,isEdited:m,onReset:g}){const[x,b]=l.useState(!1),y=e.filter(j=>j.cssVar),v=x?Gp.map(j=>j.family):Vp;return t.jsxs("aside",{"aria-label":"Customize","data-testid":"mockup-detail-sidebar",style:{borderLeft:"1px solid rgba(255,255,255,.08)",overflow:"auto",padding:18,display:"flex",flexDirection:"column",gap:24,background:"#111",minHeight:0},children:[t.jsx("link",{rel:"stylesheet",href:pC(v)}),t.jsxs(Va,{title:"Colors",aside:m?t.jsx("button",{type:"button",onClick:g,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontSize:11,letterSpacing:0,textTransform:"none"},children:"Reset all"}):null,children:[y.length>0?y.map(j=>t.jsx(_C,{slot:j,value:n[j.cssVar]??j.value??"",onChange:_=>s(j.cssVar,_)},j.label)):t.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)"},children:"This design doesn't expose its colors as tokens, so they can't be changed here. Ask for color changes in the chat."}),y.length>0&&r.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{...Fc,marginTop:14},children:"Borrow a palette"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(58px, 1fr))",gap:6},children:r.map(j=>{const S=(o==="dark"&&j.dark?j.dark:j.light).slots.map(k=>k.value).filter(k=>!!k),w=j.name===a;return t.jsx("button",{type:"button",title:`Use the colors from ${j.name}`,"aria-label":`Use the colors from ${j.name}`,"aria-pressed":w,onClick:()=>i(j),style:{display:"flex",height:26,borderRadius:7,overflow:"hidden",padding:0,cursor:"pointer",border:`1px solid ${w?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.14)"}`},children:S.map((k,N)=>t.jsx("i",{style:{flex:1,background:k}},N))},j.name)})})]})]}),t.jsxs(Va,{title:"Headings",aside:t.jsx("button",{type:"button",onClick:()=>b(j=>!j),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontSize:11,letterSpacing:0,textTransform:"none"},children:x?"Fewer fonts":"More fonts"}),children:[t.jsx(zc,{label:"Headings",value:c,onChange:u,showAll:x}),t.jsx("div",{style:Fc,children:"Body text"}),t.jsx(zc,{label:"Body text",value:d,onChange:p,showAll:x})]}),h!==null&&t.jsx(Va,{title:"Corners",aside:t.jsxs("span",{style:{color:"var(--text-secondary)",letterSpacing:0},children:[h,"px"]}),children:t.jsx("input",{type:"range",min:0,max:32,value:h,"aria-label":"Corner radius",onChange:j=>f(Number(j.target.value)),style:{width:"100%",accentColor:"var(--accent-active, #D7FF63)"}})})]})}const bre=Object.freeze(Object.defineProperty({__proto__:null,ColorRow:_C,FEATURED_FONTS:Vp,FontChips:zc,MockupDetailSidebar:SC,Section:Va},Symbol.toStringTag,{value:"Module"})),kC=600;function NC({value:e,placeholder:n,onChange:s}){const[r,a]=l.useState("idle"),o=l.useRef(null),i=l.useRef(void 0);l.useEffect(()=>()=>window.clearTimeout(i.current),[]);const c=()=>{var d;window.clearTimeout(i.current),a("saved"),(d=o.current)==null||d.blur()};return t.jsxs("div",{style:{position:"relative",flex:1,minWidth:200,maxWidth:560,display:"flex"},children:[t.jsx("input",{ref:o,value:e,placeholder:n,"aria-label":"Feedback on this design",onChange:d=>{s(d.target.value),a("typing"),window.clearTimeout(i.current),i.current=window.setTimeout(()=>a("saved"),kC)},onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),c())},style:{flex:1,minWidth:0,height:34,background:"rgba(255,255,255,.04)",border:`1px solid ${r==="saved"?"rgba(215,255,99,.45)":"rgba(255,255,255,.12)"}`,borderRadius:9,padding:"0 86px 0 12px",color:"var(--text-primary)",fontSize:13,outline:"none",transition:"border-color .2s"}}),t.jsxs("span",{style:{position:"absolute",right:5,top:0,bottom:0,display:"flex",alignItems:"center"},children:[r==="typing"&&t.jsx("button",{type:"button","aria-label":"Save note",title:"Save note (Enter)",onMouseDown:d=>d.preventDefault(),onClick:c,style:{width:24,height:24,borderRadius:7,border:"none",display:"grid",placeItems:"center",cursor:"pointer",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)"},children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M8 13V3M3.5 7.5L8 3l4.5 4.5"})})}),r==="saved"&&e.trim()!==""&&t.jsxs("span",{role:"status","data-testid":"note-saved",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"0 6px",fontSize:12,fontWeight:500,color:"var(--accent-active, #D7FF63)"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 8.5l3.2 3L13 4.5"})}),"Saved"]})]})]})}const yre=Object.freeze(Object.defineProperty({__proto__:null,MockupNoteField:NC,NOTE_SAVED_AFTER_MS:kC},Symbol.toStringTag,{value:"Module"})),CC=["Rate it","Not for me","Meh","Okay","Good","Love it"];function w7(e){return e>0&&e<=2?"What isn't working for you?":e>=4?"What do you like most? Anything to change?":"Feedback on this design"}const ll={height:34,padding:"0 14px",borderRadius:9,fontSize:13,fontWeight:600,cursor:"pointer"};function TC({mockup:e,systemName:n,initial:s,siblings:r,feedback:a,onFeedbackChange:o,onEditsChange:i,onSave:c,onSelect:d,saving:u=!1}){const p=f7(e.url,n,s),h=g7(r),f=l.useMemo(()=>[...p.state.kind==="ready"?p.state.palettes:[],...h],[p.state,h]),m=l.useMemo(()=>p.state.kind==="ready"?t7(p.state.html):[],[p.state]),g=m.reduce((y,v)=>v.px>y.px?v:y,m[0]??{name:"",px:0}),x=m.length===0?null:parseFloat(p.overrides.vars[g.name]??`${g.px}`)||0;l.useEffect(()=>{i(p.overrides)},[p.overrides]);const b=$p(a.rating);return t.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{flex:1,minHeight:0,display:"grid",gridTemplateColumns:"minmax(0, 1fr) 320px"},children:[t.jsxs("div",{style:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:"#0b0b0c"},children:[p.state.kind==="error"&&t.jsx(gC,{message:p.state.message}),p.state.kind==="loading"&&t.jsx("div",{style:{padding:16,color:"var(--text-secondary)"},children:"Loading the design…"}),p.state.kind==="ready"&&t.jsx(wC,{html:p.state.html,srcDoc:p.srcDoc,theme:p.theme,mockupUrl:e.url,mockupName:e.name})]}),t.jsx(SC,{slots:p.slots,vars:p.stackedVars,onColorChange:p.changeColor,palettes:f,activePaletteName:p.activePaletteName,theme:p.theme,onApplyPalette:p.applyPalette,headingFont:p.overrides.secondaryFont,bodyFont:p.overrides.primaryFont,onHeadingFont:y=>p.setOverrides(v=>({...v,secondaryFont:y})),onBodyFont:y=>p.setOverrides(v=>({...v,primaryFont:y})),radius:x,onRadius:y=>p.setOverrides(v=>({...v,vars:{...v.vars,...n7(m,y)}})),isEdited:p.isEdited,onReset:p.reset})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px 12px 18px",borderTop:"1px solid rgba(255,255,255,.08)",flexWrap:"wrap"},children:[t.jsx(zp,{rating:a.rating,onRatingChange:y=>o({...a,rating:y})}),t.jsx("span",{"data-testid":"mockup-rating-label",style:{fontSize:12,color:"var(--text-muted)",minWidth:64},children:CC[b]}),t.jsx(NC,{value:a.comment,placeholder:w7(b),onChange:y=>o({...a,comment:y})}),t.jsx("span",{style:{flex:1}}),p.hasDark&&t.jsx("button",{type:"button","aria-pressed":p.theme==="dark",onClick:()=>p.setTheme(y=>y==="light"?"dark":"light"),style:{...ll,fontWeight:500,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-secondary)"},children:p.theme==="dark"?"Light mode":"Dark mode"}),p.isEdited&&t.jsx("button",{type:"button",disabled:u,onClick:()=>c(p.overrides),style:{...ll,border:"1px solid rgba(255,255,255,.2)",background:"transparent",color:"var(--text-primary)"},children:u?"Saving…":"Save changes"}),t.jsx("button",{type:"button",onClick:d,style:{...ll,border:"none",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)"},children:"Select this design"})]})]})}const vre=Object.freeze(Object.defineProperty({__proto__:null,MockupDetailBody:TC,RATING_LABELS:CC},Symbol.toStringTag,{value:"Module"})),Km={width:24,height:24,borderRadius:6,border:"1px solid rgba(255,255,255,.12)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer"};function PC({number:e,name:n,index:s,total:r,onPrev:a,onNext:o,onClose:i,children:c}){return l.useEffect(()=>{const d=u=>{if(u.key==="Escape")return i();const p=u.target;p&&(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable)||r<2||(u.key==="ArrowLeft"&&a(),u.key==="ArrowRight"&&o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i,a,o,r]),t.jsx("div",{"data-testid":"mockup-detail-backdrop",onClick:d=>{d.target===d.currentTarget&&i()},style:{position:"fixed",inset:0,zIndex:50,background:"rgba(0,0,0,.72)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"grid",placeItems:"center",padding:24},children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":n,style:{width:"min(1320px, 100%)",height:"min(860px, 100%)",display:"flex",flexDirection:"column",borderRadius:16,overflow:"hidden",border:"1px solid rgba(255,255,255,.12)",background:"#141415",boxShadow:"0 30px 80px rgba(0,0,0,.6)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px 12px 18px",borderBottom:"1px solid rgba(255,255,255,.08)"},children:[e!==null&&t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,padding:"3px 8px",borderRadius:99,background:"rgba(255,255,255,.08)",color:"var(--text-secondary)"},children:String(e).padStart(2,"0")}),t.jsx("span",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary)",textTransform:"capitalize"},children:n}),t.jsx("span",{style:{flex:1}}),r>1&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,color:"var(--text-muted)"},children:[t.jsx("button",{type:"button","aria-label":"Previous design",onClick:a,style:Km,children:"‹"}),s+1," of ",r,t.jsx("button",{type:"button","aria-label":"Next design",onClick:o,style:Km,children:"›"})]}),t.jsx("button",{type:"button","aria-label":"Close",onClick:i,style:{width:32,height:32,borderRadius:8,border:"none",background:"transparent",color:"var(--text-muted)",fontSize:20,lineHeight:1,cursor:"pointer"},children:"×"})]}),c]})})}const jre=Object.freeze(Object.defineProperty({__proto__:null,MockupDetailModal:PC},Symbol.toStringTag,{value:"Module"})),_7=["Feedback sent","Choose what to keep","New designs"];function OC({round:e,stage:n,agentWorking:s}){const r=n==="planning"&&!s,a=n==="designing"?2:1,o=n==="designing"?`Designing round ${e}. Each design comes back here as soon as it's redone.`:r?"Your turn: answer in the chat which designs to keep. The rest get redesigned.":"Reading your feedback. Next you'll be asked which designs to keep.";return t.jsxs("div",{role:"status","data-testid":"design-iterate-banner","data-stage":n,style:{display:"flex",flexDirection:"column",gap:10,padding:"12px 14px",borderRadius:12,border:`1px solid ${r?"rgba(215,255,99,.45)":"rgba(255,255,255,.12)"}`,background:r?"rgba(215,255,99,.06)":"rgba(255,255,255,.03)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsxs("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10.5,letterSpacing:".08em",textTransform:"uppercase",color:"var(--accent-active, #D7FF63)"},children:["Round ",e]}),t.jsx("ol",{style:{display:"flex",gap:6,listStyle:"none",margin:0,padding:0,flexWrap:"wrap"},children:_7.map((i,c)=>{const d=c<a,u=c===a;return t.jsxs("li",{"aria-current":u?"step":void 0,style:{display:"flex",alignItems:"center",gap:5,fontSize:11.5,padding:"2px 9px",borderRadius:999,border:`1px solid ${u?"rgba(215,255,99,.45)":"rgba(255,255,255,.1)"}`,color:d||u?"var(--text-primary)":"var(--text-muted)"},children:[d?t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)"},children:"✓"}):t.jsx("span",{"aria-hidden":"true",style:{opacity:.6},children:c+1}),i]},i)})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:13,color:"var(--text-secondary)"},children:[!r&&t.jsx(Wt,{size:13}),r&&t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",fontSize:14},children:"←"}),t.jsx("span",{children:o})]})]})}const wre=Object.freeze(Object.defineProperty({__proto__:null,DesignIterateBanner:OC},Symbol.toStringTag,{value:"Module"}));function RC({columns:e,onChange:n}){return t.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:[t.jsx(Bc,{count:1,active:e===1,onClick:()=>n(1)}),t.jsx(Bc,{count:2,active:e===2,onClick:()=>n(2)})]})}function Bc({count:e,active:n,onClick:s}){return t.jsx("button",{type:"button",onClick:s,"aria-pressed":n,"aria-label":e===1?"One column":"Two columns",title:e===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:t.jsx("svg",{width:"13",height:"11",viewBox:"0 0 13 11","aria-hidden":"true",children:e===1?t.jsx("rect",{x:"1",y:"1",width:"11",height:"9",rx:"1.5",fill:"currentColor"}):t.jsxs(t.Fragment,{children:[t.jsx("rect",{x:"1",y:"1",width:"4.5",height:"9",rx:"1.5",fill:"currentColor"}),t.jsx("rect",{x:"7.5",y:"1",width:"4.5",height:"9",rx:"1.5",fill:"currentColor"})]})})})}const _re=Object.freeze(Object.defineProperty({__proto__:null,ColumnsButton:Bc,MockupColumnsToggle:RC},Symbol.toStringTag,{value:"Module"}));function EC({theme:e,onToggle:n,size:s=28}){return t.jsx("button",{type:"button",onClick:n,"aria-label":e==="light"?"Switch to dark mode":"Switch to light mode","aria-pressed":e==="dark",title:e==="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:e==="light"?"☾":"☀"})}const Sre=Object.freeze(Object.defineProperty({__proto__:null,MockupCardThemeToggleButton:EC},Symbol.toStringTag,{value:"Module"}));function AC(){return t.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:[t.jsx("path",{d:"M4.5 2.5h-2v7h7v-2"}),t.jsx("path",{d:"M7 2.5h2.5V5"}),t.jsx("path",{d:"M9.5 2.5L5.5 6.5"})]})}function MC({displayNumber:e,formattedName:n,theme:s,showThemeToggle:r,busy:a,openInNewTabUrl:o,onToggleTheme:i,onChoose:c,onCustomize:d}){return t.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[t.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(e).padStart(2,"0")}),o?t.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:[t.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),t.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:"var(--text-muted)",lineHeight:1,flexShrink:0},children:t.jsx(AC,{})})]}):t.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-xs, 8px)",flexShrink:0},children:[r&&t.jsx(EC,{theme:s,onToggle:i}),t.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"}),t.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 kre=Object.freeze(Object.defineProperty({__proto__:null,MockupCardFooter:MC,OpenInNewTabIcon:AC},Symbol.toStringTag,{value:"Module"})),S7=700;function k7({srcDoc:e,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 m=window.setTimeout(()=>d(!0),S7);return()=>window.clearTimeout(m)},[e,n,s]);const p=()=>{const m=window.requestAnimationFrame(()=>{const g=window.requestAnimationFrame(()=>i(!0));u.current.push(g)});u.current.push(m)};l.useEffect(()=>()=>{u.current.forEach(m=>window.cancelAnimationFrame(m)),u.current=[]},[]);const h=o&&r>0;return{handleIframeLoad:p,visible:h,showSkeleton:!a||!h||!c}}function IC(){return t.jsx("div",{"data-testid":"mockup-device-notch",style:{position:"absolute",top:kt.notchTopInset,left:"50%",transform:"translateX(-50%)",width:kt.notchWidth,height:kt.notchHeight,borderRadius:kt.notchHeight/2,background:kt.notchColor,pointerEvents:"none"}})}const Nre=Object.freeze(Object.defineProperty({__proto__:null,MockupDeviceNotch:IC},Symbol.toStringTag,{value:"Module"}));function DC(){return t.jsx("div",{"data-testid":"mockup-device-home-indicator",style:{position:"absolute",bottom:kt.homeIndicatorBottomInset,left:"50%",transform:"translateX(-50%)",width:kt.homeIndicatorWidth,height:kt.homeIndicatorHeight,borderRadius:kt.homeIndicatorHeight/2,background:kt.homeIndicatorColor,pointerEvents:"none"}})}const Cre=Object.freeze(Object.defineProperty({__proto__:null,MockupDeviceHomeIndicator:DC},Symbol.toStringTag,{value:"Module"}));function LC({width:e,height:n,children:s}){const{bezel:r}=kt;return t.jsx("div",{"data-testid":"mockup-device-frame",style:{position:"relative",width:e+r*2,height:n+r*2,borderRadius:kt.outerRadius,background:kt.bodyColor,boxShadow:`0 18px 48px rgba(0, 0, 0, 0.55), inset 0 0 0 1px ${kt.ringColor}`,boxSizing:"border-box"},children:t.jsxs("div",{"data-testid":"mockup-device-screen",style:{position:"absolute",top:r,left:r,width:e,height:n,borderRadius:kt.screenRadius,overflow:"hidden",background:"white"},children:[s,t.jsx(IC,{}),t.jsx(DC,{})]})})}const Tre=Object.freeze(Object.defineProperty({__proto__:null,MockupDeviceFrame:LC},Symbol.toStringTag,{value:"Module"}));function $C(){return t.jsxs("div",{"aria-label":"Loading mockup",style:{position:"absolute",inset:0,padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[t.jsx(Fo,{}),t.jsx(vt,{widthPct:45,heightPx:14,variant:"overlay"}),t.jsx(vt,{widthPct:70,heightPx:10,variant:"overlay"}),t.jsx("div",{style:{height:"6%"}}),t.jsx(vt,{widthPct:100,heightPx:32,variant:"overlay"}),t.jsxs("div",{style:{display:"flex",gap:"4%"},children:[t.jsx(vt,{widthPct:48,heightPx:48,variant:"overlay"}),t.jsx(vt,{widthPct:48,heightPx:48,variant:"overlay"})]}),t.jsx(vt,{widthPct:88,heightPx:10,variant:"overlay"}),t.jsx(vt,{widthPct:60,heightPx:10,variant:"overlay"})]})}const Pre=Object.freeze(Object.defineProperty({__proto__:null,MockupSkeletonOverlay:$C},Symbol.toStringTag,{value:"Module"}));function Kp({html:e,url:n,title:s,viewport:r,theme:a,darkVars:o,darkBgText:i,slotAspect:c={w:Lc,h:$c},onOpen:d}){const u=l.useRef(null),[p,h]=l.useState(0),[f,m]=l.useState(0),g=yi[r],x=bC(r),b=xC(r);l.useEffect(()=>{const T=u.current;if(!T)return;const P=()=>{const L=T.clientWidth,M=T.clientHeight;L>0&&h(L),M>0&&m(M)};if(P(),typeof ResizeObserver>"u")return;const R=new ResizeObserver(P);return R.observe(T),()=>R.disconnect()},[]);const{scale:y,offsetX:v,offsetY:j}=y7(p,f,x.w,x.h),_=e&&a==="dark"&&o?mC(e,{vars:o,...i??iC(o)}):e,{handleIframeLoad:S,visible:w,showSkeleton:k}=k7({srcDoc:_,url:n,theme:a,scale:y,hasContent:e!==null}),N=()=>window.open(n,"_blank","noopener,noreferrer"),C=t.jsx("iframe",{src:_?void 0:n,srcDoc:_??void 0,title:s,sandbox:"",onLoad:S,style:{width:g.w,height:g.h,border:"none",background:"white",display:"block"}},a);return t.jsxs("div",{ref:u,onClick:d??N,"data-testid":"mockup-preview-slot",style:{position:"relative",width:"100%",aspectRatio:`${c.w} / ${c.h}`,overflow:"hidden",cursor:"pointer",backgroundColor:yC,backgroundImage:vC,backgroundSize:jC},children:[e!==null&&t.jsx("div",{style:{position:"absolute",top:j,left:v,transform:y>0?`scale(${y})`:"scale(0)",transformOrigin:"top left",pointerEvents:"none",visibility:w?"visible":"hidden"},children:b?t.jsx(LC,{width:g.w,height:g.h,children:C}):C}),k&&t.jsx($C,{})]})}const Ore=Object.freeze(Object.defineProperty({__proto__:null,MockupCardPreviewSlot:Kp},Symbol.toStringTag,{value:"Module"}));function FC({mockup:e,displayNumber:n,onChoose:s,onCustomize:r,busy:a=!1,darkVars:o=null,feedback:i,onFeedbackChange:c,slotAspect:d,onViewportResolved:u}){const[p,h]=l.useState(null),[f,m]=l.useState(Ym),[g,x]=l.useState("light"),b=l.useMemo(()=>p?fC(p):null,[p]);if(l.useEffect(()=>{if(!e)return;let v=!1;return(async()=>{try{const j=await fetch(e.url);if(!j.ok)return;const _=await j.text();if(v)return;const S=Yp(_)??Ym;h(_),m(S),u==null||u(S)}catch{}})(),()=>{v=!0}},[e==null?void 0:e.url]),!e)return t.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 y=gr(e);return t.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[t.jsx(MC,{displayNumber:n,formattedName:y,theme:g,showThemeToggle:!!b,busy:a,openInNewTabUrl:e.url,onToggleTheme:()=>x(v=>v==="light"?"dark":"light"),onChoose:()=>s==null?void 0:s(e),onCustomize:()=>r==null?void 0:r(e)}),t.jsx(Kp,{html:p,url:e.url,title:e.name,viewport:f,theme:g,darkVars:(b==null?void 0:b.vars)??null,darkBgText:b?{bg:b.bg,text:b.text}:void 0,slotAspect:d,onOpen:r?()=>r(e):void 0}),c&&t.jsx(uC,{value:i??Bp,onChange:c})]})}const Rre=Object.freeze(Object.defineProperty({__proto__:null,MockupCard:FC},Symbol.toStringTag,{value:"Module"}));function zC({displayNumber:e,slotAspect:n}){return t.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:[t.jsx(Fo,{}),t.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:[t.jsx(vt,{widthPct:45,heightPx:14}),t.jsx(vt,{widthPct:70,heightPx:10}),t.jsx("div",{style:{height:"6%"}}),t.jsx(vt,{widthPct:100,heightPx:32}),t.jsxs("div",{style:{display:"flex",gap:"4%"},children:[t.jsx(vt,{widthPct:48,heightPx:48}),t.jsx(vt,{widthPct:48,heightPx:48})]}),t.jsx(vt,{widthPct:88,heightPx:10}),t.jsx(vt,{widthPct:60,heightPx:10})]}),t.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",display:"flex",alignItems:"center",gap:"var(--spacing-sm, 8px)"},children:t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[t.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(e).padStart(2,"0")}),t.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},"data-testid":"mockup-placeholder-label",children:"The AI is designing this mockup…"})]})})]})}const Ere=Object.freeze(Object.defineProperty({__proto__:null,MockupPlaceholderCard:zC},Symbol.toStringTag,{value:"Module"}));function BC({slots:e,darkVarsBySystem:n,busyFilename:s,feedbackByFilename:r,onFeedbackChange:a,onChoose:o,onCustomize:i,columns:c=2}){const[d,u]=l.useState({}),p=l.useCallback((f,m)=>{u(g=>g[f]===m?g:{...g,[f]:m})},[]),h=l.useMemo(()=>b7(Object.values(d)),[d]);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:c===1?"1fr":"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:e.map(f=>f.mockup?t.jsx(FC,{mockup:f.mockup,displayNumber:f.number,onChoose:o,onCustomize:i,busy:s===f.mockup.filename,darkVars:n[pa(f.mockup.filename)]??null,feedback:r==null?void 0:r[f.mockup.filename],onFeedbackChange:a?m=>a(f.mockup.filename,m):void 0,slotAspect:h,onViewportResolved:m=>p(f.mockup.filename,m)},`mockup-${f.mockup.filename}`):t.jsx(zC,{displayNumber:f.number,slotAspect:h},`placeholder-${f.number}`))})}const Are=Object.freeze(Object.defineProperty({__proto__:null,MockupGrid:BC},Symbol.toStringTag,{value:"Module"}));function WC(){return t.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:[t.jsx("div",{className:"relative",children:t.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}),t.jsx("div",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:500},children:"Generating new designs…"})]})}const Mre=Object.freeze(Object.defineProperty({__proto__:null,MockupGridGeneratingOverlay:WC},Symbol.toStringTag,{value:"Module"}));function HC(){return t.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:[t.jsx("path",{d:"M9 18h6"}),t.jsx("path",{d:"M10 22h4"}),t.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 qC(){return t.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:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})}function UC({onDismiss:e}){return t.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:[t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0,paddingTop:1},children:t.jsx(HC,{})}),t.jsxs("p",{style:{flex:1,margin:0,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5},children:[t.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."]}),t.jsx("button",{type:"button",onClick:e,"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:t.jsx(qC,{})})]})}const Ire=Object.freeze(Object.defineProperty({__proto__:null,CloseIcon:qC,LightbulbIcon:HC,MockupGridInfoBanner:UC},Symbol.toStringTag,{value:"Module"}));function GC({filename:e,onDismiss:n}){const s=sC(e);return t.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:"var(--spacing-sm, 8px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderRadius:8,border:"1px solid var(--accent-active, #D7FF63)",background:"var(--bg-elevated, rgba(215,255,99,0.08))",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)"},children:[t.jsxs("span",{style:{flex:1},children:["Saved your changes to ",t.jsx("strong",{children:s}),". It stays in the lineup, so you can keep comparing. Press Select on a design when you're ready to build with it."]}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss saved notice",style:{border:"none",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontSize:16,lineHeight:1,padding:2},children:"×"})]})}const Dre=Object.freeze(Object.defineProperty({__proto__:null,MockupSavedNotice:GC},Symbol.toStringTag,{value:"Module"}));function YC({filename:e}){const n=sC(e);return t.jsxs("div",{role:"status","data-testid":"design-switch-queued-notice",style:{padding:"10px 14px",borderRadius:10,border:"1px solid var(--accent-active, #D7FF63)",background:"var(--bg-card, #1a1a1a)",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)"},children:["Queued a plan to switch the app to the"," ",t.jsx("strong",{style:{textTransform:"capitalize"},children:n})," design. Nothing in the app has changed yet. Find it in the Plan tab and run it when you are ready."]})}const Lre=Object.freeze(Object.defineProperty({__proto__:null,DesignSwitchQueuedNotice:YC},Symbol.toStringTag,{value:"Module"}));function N7(e){const[n,s]=l.useState(!1);return l.useEffect(()=>{if(!e)return;let r=!1;return fetch("/api/editor-design-state").then(a=>a.ok?a.json():null).then(a=>{!r&&a&&s(a.projectBuilt===!0)}).catch(()=>{}),()=>{r=!0}},[e]),n}function C7(e){if(!e||typeof e!="object")return null;const n=e.queuedPlan;return typeof n=="string"&&n.length>0?n:null}function VC(){return t.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:[t.jsx("path",{d:"M21 12a9 9 0 1 1-3.36-7"}),t.jsx("polyline",{points:"21 4 21 10 15 10"})]})}const KC="Rate each design or leave it a note first, so the next round knows what to keep and what to change.";function JC({feedbackCount:e,busy:n,onIterate:s}){const[r,a]=l.useState(!1),o=e===0,i=e===0?"Add a rating or note above, then iterate.":e===1?"1 card has feedback — iterate to refresh the round.":`${e} cards have feedback — iterate to refresh the round.`;return t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 14px)",minWidth:0},children:[t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0},children:t.jsx(VC,{})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("span",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:600,lineHeight:1.3},children:"Ready for the next round?"}),t.jsx("span",{style:{color:"var(--text-muted)",fontSize:"var(--text-xs, 12px)",lineHeight:1.4,marginTop:2},children:i})]})]}),t.jsxs("span",{style:{position:"relative",flexShrink:0,display:"inline-flex"},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[t.jsx("button",{type:"button",onClick:()=>{o||s()},onFocus:()=>a(!0),onBlur:()=>a(!1),disabled:n,"aria-disabled":o?"true":void 0,"aria-describedby":o?"iterate-needs-feedback":void 0,"data-mockup-iterate":!0,style:{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":o?"not-allowed":"pointer",opacity:n?.6:o?.35:1},children:n?"Sending…":"Iterate"}),o&&t.jsx("span",{id:"iterate-needs-feedback",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 10px)",right:0,width:240,padding:"8px 10px",borderRadius:8,background:"#2a2a2c",border:"1px solid rgba(255,255,255,.12)",boxShadow:"0 8px 24px rgba(0,0,0,.45)",color:"var(--text-primary)",fontSize:12.5,lineHeight:1.4,textAlign:"left",pointerEvents:"none",opacity:r?1:0,transform:r?"none":"translateY(4px)",transition:"opacity .15s, transform .15s",zIndex:5},children:KC})]})]})}const $re=Object.freeze(Object.defineProperty({__proto__:null,ITERATE_NEEDS_FEEDBACK:KC,MockupGridIterateButton:JC,RefreshCycleIcon:VC},Symbol.toStringTag,{value:"Module"}));function XC(){return t.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:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}function QC(){return t.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:t.jsx("polyline",{points:"9 18 15 12 9 6"})})}function ZC({archivedRoundsNewestFirst:e,selected:n,onSelect:s}){if(!e||e.length===0)return null;const a=[...[...e].reverse(),"current"],o=a.length,i=a.indexOf(n),c=i===-1?o-1:i,d=n==="current",u=c>0,p=c<o-1,h=d?`Round ${o} of ${o} · Current`:`Round ${c+1} of ${o} · Archived`;return t.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:[t.jsx(Wc,{ariaLabel:"Previous round",disabled:!u,onClick:()=>u&&s(a[c-1]),icon:t.jsx(XC,{})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[t.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)"},children:h}),!d&&t.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"})]}),t.jsx(Wc,{ariaLabel:"Next round",disabled:!p,onClick:()=>p&&s(a[c+1]),icon:t.jsx(QC,{})})]})}function Wc({ariaLabel:e,disabled:n,onClick:s,icon:r}){return t.jsx("button",{type:"button",onClick:s,disabled:n,"aria-label":e,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 Fre=Object.freeze(Object.defineProperty({__proto__:null,ChevronLeftIcon:XC,ChevronRightIcon:QC,MockupRoundPager:ZC,PagerArrowButton:Wc},Symbol.toStringTag,{value:"Module"}));function T7(e){return e?{title:"Plan the switch to this design?",action:"Queue the plan",busyAction:"Queuing…"}:{title:"Ready to start building?",action:"Start building",busyAction:"Starting…"}}function eT({mockup:e,busy:n,onCancel:s,onConfirm:r,planSwitch:a=!1}){const o=T7(a);l.useEffect(()=>{const c=d=>{d.key==="Escape"&&!n&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,s]);const i=e.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return t.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:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":o.title,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:[t.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"hidden",aspectRatio:"16 / 9",background:"#1a1a1a",position:"relative"},children:t.jsx("iframe",{src:e.url,title:`${i} 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}})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:o.title}),t.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13,textTransform:"capitalize"},children:["Using ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:i})]}),a&&t.jsx(Mb,{})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.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"}),t.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?o.busyAction:o.action})]})]})})}const zre=Object.freeze(Object.defineProperty({__proto__:null,StartBuildingConfirmModal:eT},Symbol.toStringTag,{value:"Module"}));function P7(e){return e===void 0?"/api/editor-mockup-customize":`/api/editor-mockup-customize?round=${encodeURIComponent(e)}`}function jo({onDesignConfirmed:e,round:n,hideInfoBanner:s=!1,pickInChat:r=!1}={}){const[a,o]=l.useState(null),[i,c]=l.useState(null),[d,u]=l.useState(null),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(null),[b,y]=l.useState(null),[v,j]=l.useState(null),_=N7(n===void 0),[S,w]=l.useState({}),[k,N]=l.useState({}),[C,T]=l.useState(!1),[P,R]=l.useState(!1),L=l.useRef([]),M=l.useRef(!1),O=l.useRef(!1),[z,I]=l.useState(null),[Y,W]=l.useState(()=>typeof window>"u"?!1:window.sessionStorage.getItem("mockup-grid-tip-dismissed")==="1"),[A,B]=l.useState(()=>typeof window>"u"?2:window.localStorage.getItem("mockup-grid-columns")==="1"?1:2),D=F=>{B(F),typeof window<"u"&&window.localStorage.setItem("mockup-grid-columns",String(F))},[J,te]=l.useState("current"),oe=UH(),se=l.useRef(null),G=qH(a),le=l.useRef(!0),ue=l.useCallback(async()=>{try{const[F,ee]=await Promise.all([fetch(xn("/api/editor-mockups",n)),fetch(xn("/api/editor-mockups-target",n))]),de=await F.json(),ie=await ee.json();le.current&&(o(fe=>yH(fe,de)||M.current&&de.length<L.current.length?fe:de),c(fe=>fe===ie.count?fe:ie.count))}catch(F){le.current&&u(F instanceof Error?F.message:String(F))}},[n]);l.useEffect(()=>{le.current=!0,ue();const F=window.setInterval(ue,4e3);return()=>{le.current=!1,window.clearInterval(F)}},[ue]),l.useEffect(()=>{let F=!1;return(async()=>{try{const ee=await fetch(xn("/api/editor-mockups-feedback",n));if(!ee.ok)return;const de=await ee.json();if(F||!de||typeof de!="object"||Array.isArray(de))return;const ie={};for(const[fe,ve]of Object.entries(de)){if(!ve||typeof ve!="object")continue;const be=ve;be.rating!=null&&typeof be.rating!="number"||be.comment!=null&&typeof be.comment!="string"||(ie[fe]={rating:typeof be.rating=="number"?be.rating:null,comment:typeof be.comment=="string"?be.comment:""})}N(ie)}catch{}})(),()=>{F=!0}},[]);const ne=l.useCallback((F,ee)=>{N(de=>{const ie={...de,[F]:ee};return se.current!=null&&window.clearTimeout(se.current),se.current=window.setTimeout(()=>{fetch(xn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)}).catch(()=>{})},400),ie})},[n]);l.useEffect(()=>()=>{se.current!=null&&window.clearTimeout(se.current)},[]);const E=l.useCallback(()=>{if(!a)return;const F=a.map(de=>de.filename);L.current=F,O.current=!1,R(!1),T(!0),x(null),te("current"),se.current!=null&&(window.clearTimeout(se.current),se.current=null);const ee={};for(const de of a)ee[de.filename]=gr(de);(async()=>{try{await fetch(xn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})}catch{}let de=null;try{const ve=await(await fetch("/api/editor-mockups-archive",{method:"POST"})).json().catch(()=>null);de=(ve==null?void 0:ve.round)??null}catch{}const ie=SH({feedbackByFilename:k,mockupFilenames:F,titles:ee,feedbackFile:de&&n===void 0?`.codeyam/design/project_mockups/history/${de}/feedback.json`:void 0});le.current&&(r&&i$({round:oe.length+2,prompt:ie,feedbackCount:Jm(k),snapshot:Tf(a),designs:a.map(({filename:fe,name:ve,title:be})=>({filename:fe,name:ve,title:be}))}),await Ac(ie,void 0,tT),le.current&&(O.current=!0,N({}),fetch(xn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).catch(()=>{})))})()},[k,a,n,r,oe.length]),H=Fu(),U=G0();l.useEffect(()=>{(H==null?void 0:H.stage)!=="planning"||!a||Tf(a)!==H.snapshot&&$u()},[H,a]);const pe=r&&H!==null,ge=l.useRef(null),Me=H==null?void 0:H.id;l.useEffect(()=>{if(!Me)return;const F=window.requestAnimationFrame(()=>{var ee,de;(de=(ee=ge.current)==null?void 0:ee.scrollIntoView)==null||de.call(ee,{behavior:"smooth",block:"start"})});return()=>window.cancelAnimationFrame(F)},[Me]),l.useEffect(()=>{M.current=C},[C]),l.useEffect(()=>{if(!C)return;const F=()=>{O.current&&R(!0)};return window.addEventListener("miniagent-output",F),()=>window.removeEventListener("miniagent-output",F)},[C]),l.useEffect(()=>{if(!C)return;const F=window.setTimeout(()=>{le.current&&T(!1)},kH);return()=>window.clearTimeout(F)},[C]),l.useEffect(()=>{C&&NH({snapshotFilenames:L.current,latestFilenames:(a??[]).map(F=>F.filename),agentRespondedAfterDispatch:P})&&T(!1)},[C,a,P]);const Ce=l.useCallback(async F=>{I(F);try{const ee=await fetch("/api/editor-mockups-restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({round:F})});if(!ee.ok){const de=await ee.text().catch(()=>`${ee.status}`);throw new Error(de||`restore failed: ${ee.status}`)}le.current&&(te("current"),ue())}catch(ee){le.current&&u(ee instanceof Error?ee.message:String(ee))}finally{le.current&&I(null)}},[ue]),De=l.useCallback(F=>{x(F)},[]),Be=l.useCallback(async()=>{if(!g)return;const F=g;h(F.filename);try{if(n===void 0){const ee=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:F.filename})});if(!ee.ok){const ie=await ee.text().catch(()=>"");let fe=ie;try{fe=JSON.parse(ie).error??ie}catch{}throw new Error(`Couldn't use this design: ${fe||`status ${ee.status}`}`)}if(C7(await ee.json().catch(()=>null))){le.current&&(x(null),j(F.filename));return}}le.current&&(x(null),e==null||e({kind:"use",filename:F.filename}))}catch(ee){u(ee instanceof Error?ee.message:String(ee))}finally{le.current&&h(null)}},[g,e,n]),X=l.useCallback(F=>{const ee=pa(F.filename);y(null),m({mockup:F,systemName:ee})},[]);l.useEffect(()=>{const F=new Map;for(const ee of a??[]){const de=/^(\d{1,2})-/.exec(ee.filename);de&&F.set(parseInt(de[1],10),ee)}return Gh([...F.keys()],ee=>{const de=F.get(ee);de&&X(de)}),()=>Gh([],null)},[a,X]);const Q=l.useCallback(async F=>{if(f){h(f.mockup.filename);try{const ee=JSON.stringify({filename:f.mockup.filename,overrides:{vars:F.vars,primaryFont:F.primaryFont,secondaryFont:F.secondaryFont}}),de=await fetch(P7(n),{method:"POST",headers:{"Content-Type":"application/json"},body:ee});if(!de.ok){const ie=await de.text().catch(()=>`${de.status}`);throw new Error(ie||`save failed: ${de.status}`)}w(ie=>({...ie,[f.mockup.filename]:F})),m(null),y(f.mockup.filename),ue()}catch(ee){u(ee instanceof Error?ee.message:String(ee))}finally{le.current&&h(null)}}},[f,ue,n]);l.useEffect(()=>{if(!r||!g)return;const F=/^(\d{1,2})-/.exec(g.filename);return If({filename:g.filename,name:gr(g),number:F?parseInt(F[1],10):null,busy:p===g.filename,confirm:()=>void Be(),cancel:()=>x(null)}),()=>If(null)},[r,g,p,Be]);const re=f&&a?a.findIndex(F=>F.filename===f.mockup.filename):-1,ce=F=>{!a||re<0||X(a[(re+F+a.length)%a.length])},_e=f?t.jsx(PC,{number:(()=>{const F=/^(\d{1,2})-/.exec(f.mockup.filename);return F?parseInt(F[1],10):null})(),name:gr(f.mockup),index:Math.max(0,re),total:(a==null?void 0:a.length)??1,onPrev:()=>ce(-1),onNext:()=>ce(1),onClose:()=>m(null),children:t.jsx(TC,{mockup:f.mockup,systemName:f.systemName,initial:S[f.mockup.filename]??bH,siblings:(a??[]).filter(F=>F.filename!==f.mockup.filename),feedback:k[f.mockup.filename]??Bp,onFeedbackChange:F=>ne(f.mockup.filename,F),onEditsChange:F=>w(ee=>({...ee,[f.mockup.filename]:F})),onSave:F=>void Q(F),onSelect:()=>{const F=f.mockup;m(null),De(F)},saving:p===f.mockup.filename},f.mockup.filename)}):null;if(!a)return t.jsx("div",{style:{padding:"var(--spacing-lg, 16px)"},children:t.jsx("div",{style:{color:"var(--text-secondary)"},children:"Loading design mockups…"})});const Te=a.reduce((F,ee)=>{const de=/^(\d{1,2})-/.exec(ee.filename);return de?Math.max(F,parseInt(de[1],10)):F},0),Oe=Math.max(i??0,Te);if(Oe===0)return t.jsx(uu,{});const he=Array.from({length:Oe},(F,ee)=>{const de=ee+1,ie=String(de).padStart(2,"0"),fe=a.find(ve=>ve.filename.startsWith(`${ie}-`))??null;return{number:de,mockup:fe}}),xe=pe&&(H==null?void 0:H.stage)==="designing"?new Set(H.snapshot.split(`
|
|
254
|
-
`)):null,Fe=xe?he.map(F=>F.mockup&&xe.has(`${F.mockup.filename}|${F.mockup.url}`)?{...F,mockup:null}:F):he;return t.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:[!Y&&!s&&t.jsx(UC,{onDismiss:()=>{W(!0),typeof window<"u"&&window.sessionStorage.setItem("mockup-grid-tip-dismissed","1")}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)"},children:[t.jsx(ZC,{archivedRoundsNewestFirst:oe.map(F=>F.round),selected:J,onSelect:te}),t.jsx("div",{style:{marginLeft:"auto"},children:t.jsx(RC,{columns:A,onChange:D})})]}),d&&t.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:d}),pe&&H&&t.jsx("div",{ref:ge,children:t.jsx(OC,{round:H.round,stage:H.stage,agentWorking:U})}),v&&t.jsx(YC,{filename:v}),b&&t.jsx(GC,{filename:b,onDismiss:()=>y(null)}),J==="current"?t.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[t.jsxs("div",{style:C&&!r?{opacity:.4,pointerEvents:"none"}:pe&&(H==null?void 0:H.stage)==="planning"?{opacity:.55,transition:"opacity .2s"}:void 0,children:[t.jsx(BC,{slots:Fe,darkVarsBySystem:G,busyFilename:p,feedbackByFilename:k,onFeedbackChange:ne,onChoose:De,onCustomize:X,columns:A}),a.length>0&&!pe&&t.jsx("div",{style:{marginTop:"var(--spacing-md, 12px)"},children:t.jsx(JC,{feedbackCount:Jm(k),busy:C,onIterate:E})})]}),C&&!r&&t.jsx(WC,{})]}):(()=>{const F=oe.find(ee=>ee.round===J);return F?t.jsx(cC,{round:F,onRestore:()=>Ce(F.round),restoring:z===F.round}):t.jsx("div",{style:{padding:"var(--spacing-md, 14px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:"Loading archived round…"})})(),_e,g&&!r&&t.jsx(eT,{mockup:g,busy:p===g.filename,onCancel:()=>x(null),onConfirm:Be,planSwitch:n===void 0&&_})]})}const tT=600;function Jm(e){return Object.values(e).filter(n=>typeof n.rating=="number"||n.comment.trim().length>0).length}const Bre=Object.freeze(Object.defineProperty({__proto__:null,DesignExplorationView:jo,ITERATE_SUBMIT_DELAY_MS:tT,systemNameFromFilename:pa,withRoundParam:xn},Symbol.toStringTag,{value:"Module"})),O7=3e3;function R7(e){const[n,s]=l.useState(null),[r,a]=l.useState(!1),o=l.useRef(!1);l.useEffect(()=>{let c=!1;const d=async()=>{if(!o.current)try{const p=await fetch("/api/editor-design-questions");if(!p.ok)return;const h=await p.json();if(c)return;s(kA(h.questions)),h.answered===!0&&(o.current=!0,a(!0))}catch{}};d();const u=window.setInterval(()=>void d(),O7);return()=>{c=!0,window.clearInterval(u)}},[e]);const i=l.useCallback(async c=>{try{return(await fetch("/api/editor-design-answers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})).ok?(o.current=!0,a(!0),!0):!1}catch{return!1}},[]);return{doc:n,answered:r,submit:i}}const E7=2e4;function A7(e){const[n,s]=l.useState(null),[r,a]=l.useState(!1),o=Lu(n!==null),i=e||o.working||WA(o.messages);l.useEffect(()=>{if(n===null)return;if(i){s(null),a(!1);return}const d=window.setTimeout(()=>a(!0),E7);return()=>window.clearTimeout(d)},[n,i]);const c=l.useCallback(()=>{a(!1),s(Date.now())},[]);return{undelivered:n!==null&&r&&!i,markSent:c}}function M7({hasQuestions:e,answered:n,ready:s,target:r}){return e&&!n?"questions":r===null?s>0?"gallery":n?"generating":"preparing":s>=r&&s>0?"gallery":"generating"}function vi({options:e,selected:n,onToggle:s,emphasized:r=!1}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7},children:e.map(a=>{const o=n.includes(a.label);return t.jsx("button",{type:"button","aria-pressed":o,onClick:()=>s(a.label),title:a.detail,style:{padding:"6px 12px",borderRadius:999,border:`1px solid ${o?"var(--text-primary)":r?"rgba(255,255,255,.22)":"rgba(255,255,255,.12)"}`,background:o?"var(--text-primary)":r?"rgba(0,0,0,.18)":"transparent",color:o?"#0a0a0a":"var(--text-secondary)",fontSize:13,cursor:"pointer"},children:a.label},a.label)})})}const Wre=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionChips:vi},Symbol.toStringTag,{value:"Module"}));function Hc({selected:e,onToggle:n}){return t.jsxs("button",{type:"button","aria-pressed":e,onClick:n,style:{display:"inline-flex",alignItems:"center",gap:8,marginTop:10,padding:"6px 12px 6px 7px",borderRadius:999,border:`1px solid ${e?"rgba(215,255,99,.6)":"rgba(255,255,255,.1)"}`,background:e?"rgba(199,240,74,.15)":"transparent",color:e?"var(--text-primary)":"var(--text-secondary)",fontSize:12.5,cursor:"pointer"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:18,height:18,borderRadius:"50%",display:"grid",placeItems:"center",background:e?"var(--accent-active)":"rgba(255,255,255,.08)",color:e?"var(--text-on-accent)":"var(--text-primary)",fontSize:11,fontWeight:600,fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:"?"}),"I don't know",t.jsx("span",{style:{color:"#858585",fontSize:11.5},children:"CodeYam will pick for you"})]})}const Hre=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionIdkPill:Hc},Symbol.toStringTag,{value:"Module"}));function I7(e){const n=e.replace("#",""),s=n.length===3?n.split("").map(i=>i+i).join(""):n,[r,a,o]=[0,2,4].map(i=>parseInt(s.slice(i,i+2),16));return r*.3+a*.59+o*.11>150}function nT({options:e,selected:n,onPick:s,emphasized:r=!1}){return t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))",gap:8},children:e.map(a=>{const o=n.includes(a.label);return t.jsxs("button",{type:"button","aria-pressed":o,onClick:()=>s(a.label),style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:10,textAlign:"left",padding:"13px 14px",borderRadius:12,border:`1px solid ${o?"rgba(215,255,99,.6)":r?"rgba(255,255,255,.22)":"rgba(255,255,255,.09)"}`,background:o?"rgba(199,240,74,.15)":r?"rgba(0,0,0,.18)":"transparent",color:"var(--text-primary)",fontSize:13.5,fontWeight:500,cursor:"pointer"},children:[a.hex?t.jsxs("span",{"aria-hidden":"true","data-swatch":a.hex,style:{alignSelf:"stretch",height:64,borderRadius:8,background:a.hex,boxShadow:"inset 0 0 0 1px rgba(255,255,255,.08)",display:"flex",alignItems:"flex-end",justifyContent:"space-between",padding:"8px 10px",color:I7(a.hex)?"rgba(0,0,0,.75)":"rgba(255,255,255,.9)"},children:[t.jsx("span",{style:{fontSize:20,fontWeight:600,lineHeight:1},children:"Aa"}),t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11},children:a.hex.toUpperCase()})]}):null,t.jsx("span",{"aria-hidden":"true",style:{width:15,height:15,borderRadius:4,border:`1.5px solid ${o?"var(--accent-active)":"#858585"}`,background:o?"var(--accent-active)":"transparent",boxShadow:o?"inset 0 0 0 3px #1f1f21":"none"}}),t.jsxs("span",{children:[a.label,a.detail?t.jsx("small",{style:{display:"block",color:"#858585",fontSize:12,fontWeight:400,marginTop:2,lineHeight:1.35},children:a.detail}):null]})]},a.label)})})}const qre=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionOptions:nT},Symbol.toStringTag,{value:"Module"}));function sT({value:e,selected:n,placeholder:s,label:r,onChange:a}){const[o,i]=l.useState(!1),c=n||o;return t.jsx("label",{"data-testid":"design-question-own-row","data-selected":n?"true":"false",style:{display:"flex",alignItems:"center",gap:10,padding:"2px 6px 2px 12px",marginTop:8,borderRadius:10,border:`1px solid ${c?"rgba(215,255,99,.6)":"rgba(255,255,255,.2)"}`,background:n?"rgba(199,240,74,.12)":"rgba(0,0,0,.28)",boxShadow:"inset 0 1px 2px rgba(0,0,0,.35)",transition:"border-color .15s",cursor:"text"},children:t.jsx("input",{type:"text",value:e,placeholder:s,"aria-label":r,onChange:d=>a(d.target.value),onFocus:()=>i(!0),onBlur:()=>i(!1),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),d.target.blur())},style:{flex:1,minWidth:0,height:36,background:"none",border:0,outline:"none",color:"var(--text-primary)",fontSize:13.5,fontFamily:"inherit"}})})}const Ure=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionOwnRow:sT},Symbol.toStringTag,{value:"Module"})),Xm=3,Qm={fontSize:12,fontWeight:500,color:"var(--text-primary)"},D7=`
|
|
255
|
-
.cy-personality-range {
|
|
256
|
-
-webkit-appearance: none;
|
|
257
|
-
appearance: none;
|
|
258
|
-
width: 100%;
|
|
259
|
-
height: 16px;
|
|
260
|
-
margin: 0;
|
|
261
|
-
background: transparent;
|
|
262
|
-
cursor: pointer;
|
|
263
|
-
--thumb: #8a8a8a;
|
|
264
|
-
}
|
|
265
|
-
.cy-personality-range[data-moved="true"] { --thumb: var(--accent-active, #D7FF63); }
|
|
266
|
-
.cy-personality-range::-webkit-slider-runnable-track {
|
|
267
|
-
height: 4px;
|
|
268
|
-
border-radius: 999px;
|
|
269
|
-
background:
|
|
270
|
-
linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)) center / 1px 100% no-repeat,
|
|
271
|
-
rgba(255,255,255,.12);
|
|
272
|
-
}
|
|
273
|
-
.cy-personality-range::-moz-range-track {
|
|
274
|
-
height: 4px;
|
|
275
|
-
border-radius: 999px;
|
|
276
|
-
background:
|
|
277
|
-
linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)) center / 1px 100% no-repeat,
|
|
278
|
-
rgba(255,255,255,.12);
|
|
279
|
-
}
|
|
280
|
-
.cy-personality-range::-webkit-slider-thumb {
|
|
281
|
-
-webkit-appearance: none;
|
|
282
|
-
appearance: none;
|
|
283
|
-
width: 14px;
|
|
284
|
-
height: 14px;
|
|
285
|
-
margin-top: -5px;
|
|
286
|
-
border-radius: 50%;
|
|
287
|
-
border: 2px solid #1f1f21;
|
|
288
|
-
background: var(--thumb);
|
|
289
|
-
box-shadow: 0 0 0 1px var(--thumb);
|
|
290
|
-
}
|
|
291
|
-
.cy-personality-range::-moz-range-thumb {
|
|
292
|
-
width: 10px;
|
|
293
|
-
height: 10px;
|
|
294
|
-
border-radius: 50%;
|
|
295
|
-
border: 2px solid #1f1f21;
|
|
296
|
-
background: var(--thumb);
|
|
297
|
-
box-shadow: 0 0 0 1px var(--thumb);
|
|
298
|
-
}
|
|
299
|
-
.cy-personality-range:focus-visible { outline: none; }
|
|
300
|
-
.cy-personality-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(215,255,99,.35); }
|
|
301
|
-
.cy-personality-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px rgba(215,255,99,.35); }
|
|
302
|
-
`,Zm={alignSelf:"flex-start",background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:12.5,color:"var(--text-secondary)"};function rT({sliders:e,moreSliders:n,words:s,moreWords:r,maxWords:a,textPlaceholder:o,value:i,onChange:c,emphasized:d=!1}){const[u,p]=l.useState(0),[h,f]=l.useState(!1),[m,g]=l.useState(""),x=[...e,...n.slice(0,u)],b=n.length-u,y=[...s,...h?r:[]],v=i.words.filter(S=>!y.includes(S)&&!r.includes(S)),j=[...y,...v],_=()=>{m.trim()&&(i.words.includes(m.trim())||c(Hh(i,m,a)),g(""))};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx("style",{children:D7}),t.jsx("div",{style:{fontSize:12,color:"#858585"},children:"Drag toward the side that fits. Skip any that don't matter."}),t.jsx("div",{"data-testid":"personality-sliders",style:{display:"grid",gridTemplateColumns:"max-content 1fr max-content",alignItems:"center",columnGap:14,rowGap:14},children:x.map(S=>{const w=i.sliders[Er(S)],k=w??S.value,N=w!==void 0&&w<Xa,C=w!==void 0&&w>100-Xa,T=P=>({fontSize:12.5,whiteSpace:"nowrap",fontWeight:P?500:400,color:P?"var(--accent-active)":"#9a9a9a"});return t.jsxs("div",{"data-moved":w!==void 0?"true":"false",style:{display:"contents"},children:[t.jsx("span",{style:{...T(N),textAlign:"right"},children:S.left}),t.jsx("input",{type:"range",min:0,max:100,value:k,"aria-label":`${S.left} to ${S.right}`,className:"cy-personality-range","data-moved":w!==void 0?"true":"false",onChange:P=>c(iA(i,S,Number(P.target.value)))}),t.jsx("span",{style:T(C),children:S.right})]},Er(S))})}),b>0&&t.jsxs("button",{type:"button",style:Zm,onClick:()=>p(S=>S+Xm),children:["+ More sliders ",t.jsxs("span",{style:{color:"#6b6b6b"},children:[Math.min(Xm,b)," more"]})]}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",marginTop:4},children:[t.jsx("span",{style:Qm,children:"Vibe words"}),t.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,color:"#858585",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:[i.words.length," of ",a]})]}),t.jsx(vi,{options:j.map(S=>({label:S})),selected:i.words,onToggle:S=>c(Hh(i,S,a)),emphasized:d})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",border:"1px solid rgba(255,255,255,.2)",background:"rgba(0,0,0,.28)",borderRadius:999,padding:"2px 4px 2px 12px"},children:[t.jsx("input",{value:m,placeholder:"Add your own word","aria-label":"Add your own word",onChange:S=>g(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),_())},style:{background:"none",border:0,outline:"none",color:"var(--text-primary)",fontSize:12.5,width:130}}),t.jsx("button",{type:"button","aria-label":"Add word",onClick:_,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:15,padding:"0 6px"},children:"+"})]}),!h&&r.length>0&&t.jsx("button",{type:"button",style:Zm,onClick:()=>f(!0),children:"+ More words"})]}),t.jsxs("div",{style:{marginTop:4},children:[t.jsx("span",{style:Qm,children:"In your own words"})," ",t.jsx("span",{style:{fontSize:11.5,color:"#858585"},children:"optional"})]}),t.jsx("textarea",{value:i.text,placeholder:o??"e.g. Like a journal I actually want to open.","aria-label":"How it should feel, in your own words",onChange:S=>c(lA(i,S.target.value)),style:{width:"100%",height:56,resize:"vertical",background:"rgba(255,255,255,.03)",border:"1px solid rgba(255,255,255,.08)",borderRadius:10,padding:"9px 12px",color:"var(--text-primary)",fontSize:13,fontFamily:"inherit",outline:"none"}}),sx(i)&&t.jsxs("div",{"data-testid":"personality-reads",style:{fontSize:12.5,color:"#9a9a9a"},children:["Reads as ",t.jsx("b",{style:{color:"var(--text-primary)",fontWeight:500},children:rx([...e,...n],i)||"your own words"}),"."]})]})}const Gre=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionPersonality:rT},Symbol.toStringTag,{value:"Module"}));function aT({images:e,parts:n,value:s,onChange:r,emphasized:a=!1}){return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:e.map(o=>t.jsxs("div",{"data-ref-file":o.file,style:{display:"grid",gridTemplateColumns:"minmax(96px, 140px) 1fr",gap:14,padding:12,borderRadius:12,border:"1px solid rgba(255,255,255,.09)",background:a?"rgba(0,0,0,.18)":"transparent"},children:[t.jsx("img",{src:mA(o.file),alt:`${o.label} reference`,width:140,height:96,style:{width:"100%",height:96,objectFit:"cover",borderRadius:8,background:"rgba(255,255,255,.04)",boxShadow:"0 0 0 1px rgba(255,255,255,.1)"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,minWidth:0},children:[t.jsx("div",{style:{fontSize:13.5,fontWeight:500,color:"var(--text-primary)"},children:o.label}),o.sees?t.jsxs("div",{style:{fontSize:12,color:"#9a9a9a"},children:[t.jsx("em",{style:{fontStyle:"normal",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".06em",color:"var(--accent-active)",marginRight:6},children:"I SEE"}),o.sees]}):null,t.jsx(vi,{options:[...new Set([...n,Ma])].map(i=>({label:i})),selected:s.picks[o.file]??[],onToggle:i=>r(uA(s,o.file,i)),emphasized:a}),t.jsx("input",{value:s.notes[o.file]??"",placeholder:o.placeholder??"Or write it, e.g. only the big numbers","aria-label":`What to take from ${o.label}, in your words`,onChange:i=>r(pA(s,o.file,i.target.value)),style:{background:"rgba(255,255,255,.03)",border:"1px solid rgba(255,255,255,.08)",borderRadius:8,padding:"7px 10px",color:"var(--text-primary)",fontSize:12.5,outline:"none"}})]})]},o.file))})}const Yre=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionRefs:aT},Symbol.toStringTag,{value:"Module"}));function oT({question:e,index:n,total:s,status:r,isFirst:a,state:o,onToggleOption:i,onOwnText:c,onToggleIdk:d,onFreeText:u,onSetAnswer:p,onLeave:h}){const f=e,[m,g]=l.useState(!1),[x,b]=l.useState(!1),y=r==="later"&&!x,[v,j]=l.useState(!1),_=r==="current",S=o.answers[f.id],w=o.own[f.id]??"",k=_?a?"Start here":"Up next":r==="answered"?"Answered":"";return t.jsxs("div",{"data-question-id":f.id,"data-status":r,onMouseEnter:()=>g(!0),onMouseLeave:N=>{g(!1),N.buttons===0&&(h==null||h())},onFocus:()=>g(!0),onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||(g(!1),N.relatedTarget&&(h==null||h()))},style:{padding:_?"22px 20px 20px":y?"16px 0 0":"30px 0 4px",margin:_?`${a?12:26}px -20px 4px`:0,borderRadius:16,border:`1px solid ${_?"rgba(215,255,99,.5)":"transparent"}`,background:_?"linear-gradient(180deg, rgba(215,255,99,.07), rgba(215,255,99,.025))":"transparent",boxShadow:_?"0 0 0 4px rgba(215,255,99,.06), 0 12px 32px rgba(0,0,0,.35)":"none",opacity:r==="later"&&!m?.42:1,transition:"opacity .2s, background .25s, border-color .25s, box-shadow .25s, padding .25s, margin .25s"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".06em",color:_?"var(--accent-active)":"#858585"},children:[t.jsx("span",{children:f.type==="free"?"OPTIONAL":`${n} / ${s}`}),k?t.jsx("span",{style:{fontSize:10.5,letterSpacing:".08em",textTransform:"uppercase",padding:"2px 7px",borderRadius:5,background:_?"var(--accent-active)":"transparent",color:_?"var(--text-on-accent)":"var(--text-muted)",border:_?"none":"1px solid rgba(255,255,255,.08)",fontWeight:_?600:400},children:k}):null]}),t.jsxs("h3",{style:{margin:0,fontSize:_?17:16,fontWeight:600,color:"var(--text-primary)"},children:[y?t.jsx("button",{type:"button","aria-expanded":!1,onClick:()=>b(!0),style:{background:"none",border:"none",padding:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:f.title}):f.title,f.why&&!y?t.jsx("button",{type:"button","aria-expanded":v,onClick:()=>j(!v),style:{marginLeft:10,background:"none",border:"none",padding:0,cursor:"pointer",fontSize:12,fontWeight:400,color:"var(--text-muted)",textDecoration:"underline",textUnderlineOffset:2,whiteSpace:"nowrap"},children:"Why?"}):null]}),y?null:t.jsxs(t.Fragment,{children:[f.why&&v?t.jsxs("p",{style:{fontSize:12.5,color:"#858585",margin:"4px 0 14px",maxWidth:"60ch"},children:[t.jsx("em",{style:{fontStyle:"normal",color:"var(--accent-active)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".04em",marginRight:6},children:"WHY"}),f.why]}):f.type==="single"||f.type==="multi"||f.type==="palette"?t.jsx("p",{style:{fontSize:12.5,color:"#858585",margin:"4px 0 12px"},children:"Pick as many as you'd like."}):t.jsx("div",{style:{height:14}}),(f.type==="single"||f.type==="palette")&&t.jsx(nT,{options:f.options,selected:Array.isArray(S)?S:[],onPick:i,emphasized:_}),f.type==="multi"&&t.jsx(vi,{options:f.options,selected:Array.isArray(S)?S:[],onToggle:i,emphasized:_}),f.type==="personality"&&t.jsx(rT,{sliders:f.sliders,moreSliders:f.moreSliders,words:f.words,moreWords:f.moreWords,maxWords:f.maxWords,textPlaceholder:f.textPlaceholder,value:nx(S),onChange:p,emphasized:_}),f.type==="refs"&&t.jsx(aT,{images:f.images,parts:f.parts,value:ox(S),onChange:p,emphasized:_}),(f.type==="personality"||f.type==="refs")&&t.jsx(Hc,{selected:S===Cn,onToggle:d}),(f.type==="single"||f.type==="multi"||f.type==="palette")&&t.jsxs(t.Fragment,{children:[t.jsx(sT,{value:w,selected:w.trim().length>0,placeholder:f.ownPlaceholder??"Something else? Write your own",label:`Your own answer: ${f.title}`,onChange:c}),t.jsx(Hc,{selected:S===Cn,onToggle:d})]}),f.type==="free"&&t.jsx("textarea",{value:typeof S=="string"?S:"",placeholder:f.placeholder??"","aria-label":f.title,onChange:N=>u(N.target.value),style:{width:"100%",height:70,resize:"vertical",background:"rgba(255,255,255,.03)",border:"1px solid rgba(255,255,255,.08)",borderRadius:10,padding:"10px 12px",color:"var(--text-primary)",fontSize:13.5,lineHeight:1.45,fontFamily:"inherit",outline:"none"}})]})]})}const Vre=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionCard:oT},Symbol.toStringTag,{value:"Module"})),L7=6e3;function iT({doc:e,onSend:n,onAskFollowUp:s,onProgress:r,sending:a=!1,error:o=null}){var k;const[i,c]=l.useState(gA),d=l.useMemo(()=>Ao(e),[e]),[u,p]=l.useState(null),h=NA(e,i),f=u??h,m=(k=d[0])==null?void 0:k.id,g=ix(e,i),x=l.useRef(null),b=l.useRef(!1);l.useEffect(()=>{r==null||r(g,d.length)},[g,d.length,r]),l.useEffect(()=>{var T,P;if(!b.current||!f)return;b.current=!1;const N=(T=x.current)==null?void 0:T.querySelector(`[data-question-id="${f}"]`),C=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;(P=N==null?void 0:N.scrollIntoView)==null||P.call(N,{behavior:C?"auto":"smooth",block:"center"})},[f]);const y=CA(e,i),v=Math.max(1,Math.min(2,d.length)-g),[j,_]=l.useState(!1);l.useEffect(()=>{if(!j)return;const N=window.setTimeout(()=>_(!1),L7);return()=>window.clearTimeout(N)},[j]);const S=N=>{N.type!=="free"&&p(N.id)},w=(N,C)=>{if(C==="free")return"idle";if(N===f)return"current";const T=e.questions.find(P=>P.id===N);return Yr(T,i)?"answered":f?"later":"idle"};return t.jsxs("div",{ref:x,"data-testid":"design-questions-form",style:{width:"100%",maxWidth:640,background:"#1f1f21",border:"1px solid rgba(255,255,255,.1)",borderRadius:18,padding:"0 32px 0",boxShadow:"0 24px 60px rgba(0,0,0,.45)"},children:[e.questions.map(N=>t.jsx(oT,{question:N,index:d.findIndex(C=>C.id===N.id)+1,total:d.length,status:w(N.id,N.type),isFirst:N.id===m,state:i,onToggleOption:C=>{S(N),c(T=>OA(T,N.id,C,PA(N)))},onOwnText:C=>{S(N),c(T=>RA(T,N,C))},onToggleIdk:()=>{p(null),b.current=!0,c(C=>EA(C,N.id))},onFreeText:C=>c(T=>MA(T,N.id,C)),onSetAnswer:C=>{S(N),c(T=>AA(T,N.id,C))},onLeave:()=>p(C=>C===N.id?null:C)},N.id)),t.jsxs("div",{style:{position:"sticky",bottom:0,zIndex:4,display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,padding:"16px 32px 20px",margin:"28px -32px 0",borderRadius:"0 0 18px 18px",background:"#1f1f21",borderTop:"1px solid rgba(255,255,255,.08)",boxShadow:"0 -14px 20px -6px #1f1f21"},children:[t.jsx("button",{type:"button",onClick:()=>c(N=>IA(e,N)),style:cl("ghost"),children:"Decide for me"}),t.jsx("span",{style:{flex:1}}),o?t.jsx("span",{role:"alert",style:{fontSize:12.5,color:"var(--accent-danger, #f87171)"},children:o}):null,t.jsx("button",{type:"button",onClick:()=>{s==null||s(),_(!0)},disabled:!s||j,style:cl("secondary",!s||j),children:j?"Asked. Look in the chat":"Ask me follow-up questions"}),!y&&!a?t.jsxs("span",{"data-testid":"design-questions-send-hint",style:{fontSize:12,color:"var(--text-muted)"},children:["Answer ",v," more to send"]}):null,t.jsxs("button",{type:"button",onClick:()=>n(i),disabled:!y||a,style:cl("primary",!y||a),children:[a?"Sending…":"Send answers",!a&&t.jsx("span",{"aria-hidden":"true",style:{marginLeft:8},children:"→"})]})]})]})}function cl(e,n=!1){const s=e==="primary";return{height:s?40:32,padding:s?"0 22px":"0 14px",borderRadius:s?10:8,fontSize:s?14.5:13,whiteSpace:"nowrap",cursor:n?"not-allowed":"pointer",opacity:n?.4:1,boxShadow:s&&!n?"0 0 0 4px rgba(215,255,99,.16), 0 6px 18px rgba(215,255,99,.18)":"none",border:e==="primary"?"1px solid var(--accent-active)":e==="secondary"?"1px solid rgba(255,255,255,.12)":"1px solid transparent",background:e==="primary"?"var(--accent-active)":"transparent",color:e==="primary"?"var(--text-on-accent)":e==="ghost"?"var(--text-muted)":"var(--text-primary)",fontWeight:e==="primary"?600:400}}const Kre=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionsForm:iT},Symbol.toStringTag,{value:"Module"}));function ds({title:e,subtitle:n,status:s,onSkip:r}){return t.jsxs("div",{"data-testid":"design-session-canvas-header",style:{position:"sticky",top:0,zIndex:3,display:"flex",alignItems:"center",gap:10,padding:"14px 18px",background:"#242424",borderBottom:"1px solid rgba(255,255,255,.08)",flex:"none"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[t.jsx("span",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:e}),n?t.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)"},children:n}):null]}),t.jsx("span",{style:{flex:1}}),s?t.jsx("span",{"data-testid":"design-session-canvas-status",style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,color:"var(--text-muted)",whiteSpace:"nowrap"},children:s}):null,r?t.jsxs("button",{type:"button",onClick:r,style:{display:"inline-flex",alignItems:"center",gap:6,height:30,padding:"0 10px 0 12px",borderRadius:8,border:"1px solid var(--line-strong)",background:"rgba(255,255,255,.05)",color:"var(--text-primary)",fontSize:12.5,fontWeight:500,whiteSpace:"nowrap",cursor:"pointer"},children:["Skip to build",t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 6h7M6.5 3l3 3-3 3"})})]}):null]})}const Jre=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionCanvasHeader:ds},Symbol.toStringTag,{value:"Module"})),Jp=7e3,eg=350;function lT({tips:e,size:n=20}){const[s,r]=l.useState(0),[a,o]=l.useState(!0);return l.useEffect(()=>{if(e.length<2)return;let i;const c=window.setInterval(()=>{o(!1),i=window.setTimeout(()=>{r(d=>(d+1)%e.length),o(!0)},eg)},Jp);return()=>{window.clearInterval(c),i!==void 0&&window.clearTimeout(i)}},[e.length]),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10,textAlign:"center"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".12em",textTransform:"uppercase",color:"var(--accent-active, #D7FF63)"},children:"Tip"}),t.jsx("p",{"data-testid":"session-tip",style:{margin:0,fontSize:n,lineHeight:1.35,maxWidth:"32ch",minHeight:"2.7em",textWrap:"balance",color:"var(--text-primary)",opacity:a?1:0,transition:`opacity ${eg}ms`},children:e[s%e.length]})]})}const Xre=Object.freeze(Object.defineProperty({__proto__:null,SessionTip:lT,TIP_ROTATE_MS:Jp},Symbol.toStringTag,{value:"Module"})),cT=["Rate each design and leave a note. The next round follows your feedback.","Customize colors and fonts on any design before you choose it.","Say “mix 2 and 5” in the chat to combine two directions.","Every round is saved. Page back to earlier ones anytime.","Switch to Terminal to see exactly what the agent is doing."];function dT({ready:e,target:n,onShowReady:s}){const r=n===null||n===0?"Getting started":`${Math.min(e,n)} of ${n} designs ready`;return t.jsxs("div",{"data-testid":"design-session-generating",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:22,padding:"40px 16px",textAlign:"center"},children:[t.jsx(Wt,{size:28}),t.jsx(lT,{tips:cT}),n!==null&&n>0&&t.jsx("div",{"data-testid":"design-session-progress",style:{display:"flex",gap:6},children:Array.from({length:n},(a,o)=>t.jsx("i",{"data-on":o<e?"true":"false",style:{width:28,height:4,borderRadius:99,background:o<e?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.1)",transition:"background .3s"}},o))}),t.jsx("span",{"aria-live":"polite","data-testid":"design-session-progress-label",style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,color:"var(--text-tertiary, rgba(255,255,255,.45))"},children:r}),e>0&&s&&t.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:13,color:"var(--text-secondary)",textDecoration:"underline",textUnderlineOffset:3},children:"Show the ready ones"})]})}const Qre=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionGenerating:dT,GENERATING_TIPS:cT},Symbol.toStringTag,{value:"Module"}));function uT(){return t.jsx("div",{"data-testid":"design-session-preparing",style:{flex:1,minHeight:0,overflow:"auto",display:"flex",justifyContent:"center",padding:"32px 16px 48px"},children:t.jsxs("div",{style:{width:"100%",maxWidth:640,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,fontSize:13,color:"var(--text-secondary)",marginBottom:6},children:[t.jsx(Wt,{}),"Reading your project and writing a few questions…"]}),[0,1,2].map(e=>t.jsxs("div",{"aria-hidden":"true",className:"animate-pulse",style:{borderRadius:12,border:"1px solid rgba(255,255,255,.08)",background:"rgba(255,255,255,.03)",padding:18,display:"flex",flexDirection:"column",gap:12,opacity:1-e*.25},children:[t.jsx("span",{style:{width:"45%",height:12,borderRadius:6,background:"rgba(255,255,255,.1)"}}),t.jsx("span",{style:{width:"70%",height:9,borderRadius:6,background:"rgba(255,255,255,.06)"}}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:8},children:[0,1,2].map(n=>t.jsx("span",{style:{height:44,borderRadius:8,background:"rgba(255,255,255,.05)"}},n))})]},e))]})})}const Zre=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionPreparing:uT},Symbol.toStringTag,{value:"Module"})),pT=5e3,hT=1200*1e3;function fT({grid:e,round:n,onSkip:s}){const{doc:r,answered:a,submit:o}=R7(!0),{ready:i,target:c}=Q0(n,!0),[d,u]=l.useState(!1);l.useEffect(()=>{i===0&&u(!1)},[i]);const{sendToAgent:p,agentReady:h}=q0(),[f,m]=l.useState(null),[g,x]=l.useState(!1),[b,y]=l.useState(null),v=M7({hasQuestions:r!==null,answered:a,ready:i??0,target:c}),j=v==="questions"?"questions":i===null?"pending":v==="generating"&&d?"gallery":v,_=Fu(),S=G0(),w=_==null?void 0:_.stage;l.useEffect(()=>{w==="planning"&&j==="generating"&&$u()},[w,j]),l.useEffect(()=>{if(w!=="designing"||S||j!=="gallery")return;const O=window.setTimeout(Of,pT);return()=>window.clearTimeout(O)},[w,S,j]);const k=_==null?void 0:_.id;l.useEffect(()=>{if(!k)return;const O=window.setTimeout(Of,hT);return()=>window.clearTimeout(O)},[k]);const N=l.useCallback((O,z)=>{m({n:O,total:z})},[]),C=l.useRef([]);l.useEffect(()=>()=>{C.current.forEach(O=>O()),C.current=[]},[]);const T=O=>{const z=Cr(p,O);z&&C.current.push(z)},P=A7((c??0)>0||(i??0)>0),{markSent:R}=P,L=()=>{T(jd),R()},M=async O=>{if(!r)return;x(!0),y(null);const z=await o(LA(r,O));if(x(!1),!z){y("Couldn't save your answers. Try again.");return}L()};return t.jsxs("div",{"data-testid":"design-session-canvas",className:"flex-1 flex flex-col min-w-0",children:[j==="questions"&&r&&t.jsxs(t.Fragment,{children:[t.jsx(ds,{title:"Before I design",subtitle:"Answer a few quick questions so the designs fit your project, not a template.",status:f?`${f.n} of ${f.total} answered`:void 0,onSkip:s}),t.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",display:"flex",justifyContent:"center",alignItems:"flex-start",padding:"32px 16px 0"},children:t.jsx(iT,{doc:r,onSend:O=>void M(O),onAskFollowUp:h?()=>T($A):void 0,onProgress:N,sending:g,error:b})})]}),j==="preparing"&&t.jsxs(t.Fragment,{children:[t.jsx(ds,{title:"Before I design",subtitle:"Reading what you shared so the questions are about your project.",status:"preparing questions",onSkip:s}),t.jsx(uT,{})]}),j==="generating"&&t.jsxs(t.Fragment,{children:[t.jsx(ds,{title:_?`Designing round ${_.round}`:"Designing your directions",subtitle:_?"Redoing the designs from your feedback. They'll appear here as soon as they're ready.":"They'll appear here as soon as they're ready.",onSkip:s}),P.undelivered&&t.jsxs("div",{role:"alert","data-testid":"design-answers-undelivered",style:{margin:"14px 16px 0",padding:"10px 12px",borderRadius:10,border:`1px solid ${ht}`,background:"rgba(255,139,67,.08)",display:"flex",alignItems:"center",gap:12,fontSize:13,color:"var(--text-primary)"},children:[t.jsx("span",{style:{flex:1},children:"Your answers are saved, but the agent doesn't seem to have received them."}),t.jsx("button",{type:"button",onClick:L,disabled:!h,style:{flex:"none",height:30,padding:"0 12px",borderRadius:8,border:"1px solid var(--accent-active)",background:"var(--accent-active)",color:"var(--text-on-accent)",fontSize:12.5,fontWeight:600,cursor:h?"pointer":"not-allowed",opacity:h?1:.4},children:"Send again"})]}),t.jsx(dT,{ready:i??0,target:c,onShowReady:()=>u(!0)})]}),j==="gallery"&&t.jsxs(t.Fragment,{children:[t.jsx(ds,{title:_?_.stage==="planning"?`Planning round ${_.round}`:`Designing round ${_.round}`:"Rate these designs",subtitle:_?_.stage==="planning"?"Your feedback is in. Choose in the chat which designs to keep; the rest get redesigned.":"Updated designs replace the old ones here as they're ready.":"Add feedback and keep iterating until you're happy with the results.",status:_?_.stage==="planning"&&!S?no:"working":void 0,onSkip:s}),e]}),j==="pending"&&t.jsx(ds,{title:"Design session",onSkip:s})]})}const eae=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionCanvas:fT,ITERATE_DONE_AFTER_IDLE_MS:pT,ITERATE_GIVE_UP_MS:hT},Symbol.toStringTag,{value:"Module"}));function mT({onDesignConfirmed:e,onExit:n,round:s,sessionMode:r=!1,onSkip:a}){const[o,i]=l.useState("assets"),c=ta(s===void 0),d=s!==void 0?s:c,u=d!==void 0,p=l.useRef(!0),h=l.useRef(0),f=l.useRef(null),m=l.useCallback(x=>{f.current=x},[]),g=l.useCallback(x=>{const b=f.current;return b?(i("assets"),b(x)):!1},[]);return jE(g,"design assets"),l.useEffect(()=>{p.current=!0;const x=async()=>{try{const v=await(await fetch("/api/editor-design-active-tab")).json();if(!p.current)return;v.tab!==null&&v.nonce!==null&&v.nonce>h.current&&(h.current=v.nonce,i(v.tab))}catch{}};x();const b=window.setInterval(x,4e3);return()=>{p.current=!1,window.clearInterval(b)}},[]),r?t.jsx(fT,{onSkip:a,round:d??void 0,grid:u?t.jsx(jo,{onDesignConfirmed:e,round:d??void 0,hideInfoBanner:!0,pickInChat:!0}):null}):t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("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:x,label:b})=>{const y=o===x;return t.jsx("button",{type:"button",role:"tab","aria-selected":y,onClick:()=>i(x),style:{padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,border:"none",cursor:"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:500,background:y?"var(--accent-active)":"transparent",color:y?"var(--text-on-accent, white)":"var(--text-secondary)"},children:b},x)}),n?t.jsx("button",{type:"button",onClick:n,style:{marginLeft:"auto",padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,border:"1px solid var(--border-default)",cursor:"pointer",fontSize:"var(--text-sm, 14px)",background:"transparent",color:"var(--text-secondary)"},children:"Close"}):null]}),t.jsx("div",{className:"flex-1 flex-col min-w-0",style:{display:o==="assets"?"flex":"none"},children:t.jsx(nC,{onRegisterDropReceiver:m})}),o==="assets"?null:u?t.jsx(jo,{onDesignConfirmed:e,round:d??void 0}):null]})}const tae=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPreviewPane:mT},Symbol.toStringTag,{value:"Module"}));function gT({roundId:e,onUse:n,onDiscard:s}={}){const[r,a]=l.useState(null),o=ta(e===void 0),i=e??o,c=l.useCallback(u=>{u.kind==="use"&&(a("use"),n?n(u.filename):Ac(`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():Ac("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 t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{overflow:"hidden"},children:[t.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:[t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Design round"}),t.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."})]}),t.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"?t.jsx(jo,{round:i,onDesignConfirmed:c}):t.jsx(Wb,{state:i===void 0?"resolving":"none"})]})}const nae=Object.freeze(Object.defineProperty({__proto__:null,DesignRoundPreviewPane:gT},Symbol.toStringTag,{value:"Module"}));function xT({target:e,onStored:n,onClose:s}){const[r,a]=l.useState(null);if(!e)return t.jsxs("div",{"data-testid":"credential-request-pane",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-[#0F0F0F] text-sm text-[#8E8E8E]",children:[t.jsx("p",{children:"No key has been requested."}),t.jsx("button",{onClick:s,className:"px-3 py-1.5 rounded-md border border-[#3A3A3A] text-white cursor-pointer",children:"Back to preview"})]});const o=r===e.envVar;return t.jsxs("div",{"data-testid":"credential-request-pane",className:"flex-1 flex flex-col min-w-0 min-h-0 bg-[#0F0F0F]",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[#2A2A2A]",children:[t.jsxs("h2",{className:"text-base font-semibold text-white",children:["Add your ",e.serviceName," key"]}),t.jsx("button",{"data-testid":"credential-request-close",onClick:s,className:"text-[#8E8E8E] hover:text-white cursor-pointer","aria-label":"Close",children:"✕"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsx("div",{className:"max-w-xl space-y-4",children:o?t.jsx(gb,{serviceName:e.serviceName,envVar:e.envVar,onBack:s}):t.jsxs(t.Fragment,{children:[e.instructions?t.jsx("div",{"data-testid":"credential-request-instructions",className:"text-sm text-[#CFCFCF] whitespace-pre-wrap leading-relaxed",children:e.instructions}):null,e.docsUrl?t.jsx(Dd,{href:e.docsUrl}):null,t.jsx(Id,{envVar:e.envVar}),t.jsx(Ld,{target:e,onStored:()=>{a(e.envVar),n(e)}})]})})})]})}const sae=Object.freeze(Object.defineProperty({__proto__:null,CredentialRequestPreviewPane:xT},Symbol.toStringTag,{value:"Module"}));function bT({deviceLabel:e,actions:n}){return t.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:[t.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:[t.jsx("rect",{x:"3",y:"4",width:"7",height:"16",rx:"1"}),t.jsx("rect",{x:"14",y:"4",width:"7",height:"16",rx:"1"}),t.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22",strokeDasharray:"2 2"})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-semibold",children:"Live mirror — not interactive."})," ",t.jsxs("span",{style:{color:"var(--text-dim)"},children:["Tap and type directly in the ",e," window."]})]}),n?t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:n}):null]})}const rae=Object.freeze(Object.defineProperty({__proto__:null,NativeMirrorNotice:bT},Symbol.toStringTag,{value:"Module"}));function yT(){return t.jsx("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:t.jsxs("span",{children:[t.jsx("strong",{children:"Web preview"})," — this machine can't run the device simulator, so you're seeing the app's web build. Layout and logic match; fonts, native controls and status bars may differ from the phone. Saved scenario screenshots still come from the simulator."]})})}const aae=Object.freeze(Object.defineProperty({__proto__:null,NativeWebPreviewNotice:yT},Symbol.toStringTag,{value:"Module"}));function vT({isCollapsed:e,onToggle:n}){return t.jsx("button",{onClick:n,className:`p-1.5 rounded transition-colors cursor-pointer ${e?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:e?"Show editor":"Hide editor",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M13 17l5-5-5-5"}),t.jsx("path",{d:"M6 17l5-5-5-5"})]}):t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M11 17l-5-5 5-5"}),t.jsx("path",{d:"M18 17l-5-5 5-5"})]})})})}const oae=Object.freeze(Object.defineProperty({__proto__:null,CollapseToggleButton:vT},Symbol.toStringTag,{value:"Module"}));function qc({label:e,value:n,disabled:s,onCommit:r,bare:a=!1}){const[o,i]=l.useState(String(n));l.useEffect(()=>{i(String(n))},[n]);const c=()=>{const d=Number.parseInt(o,10);if(!Number.isFinite(d)||d<=0){i(String(n));return}d!==n&&r(d)};return t.jsxs("label",{className:`flex items-center gap-0.5 text-xs ${a?"":"px-1 py-0.5 rounded bg-[#2A2929]"} ${s?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("span",{className:a?"sr-only":"text-[10px] font-semibold text-gray-500 select-none",children:e}),t.jsx("input",{type:"text",inputMode:"numeric",value:o,disabled:s,"aria-label":e==="H"?"Height":"Width",onChange:d=>i(d.target.value.replace(/[^0-9]/g,"")),onBlur:c,onKeyDown:d=>{d.key==="Enter"?(c(),d.target.blur()):d.key==="Escape"&&(i(String(n)),d.target.blur())},className:"w-[4.5ch] 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 iae=Object.freeze(Object.defineProperty({__proto__:null,DimensionInput:qc},Symbol.toStringTag,{value:"Module"}));function jT({isFilled:e,onToggle:n}){return t.jsx("button",{onClick:n,className:`p-1.5 rounded transition-colors cursor-pointer ${e?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:e?"Exit fullscreen":"Fill page with preview",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e?t.jsxs(t.Fragment,{children:[t.jsx("polyline",{points:"4 14 10 14 10 20"}),t.jsx("polyline",{points:"20 10 14 10 14 4"}),t.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),t.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):t.jsxs(t.Fragment,{children:[t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("polyline",{points:"9 21 3 21 3 15"}),t.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),t.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})}const lae=Object.freeze(Object.defineProperty({__proto__:null,FillPreviewButton:jT},Symbol.toStringTag,{value:"Module"}));function wT({previewUrl:e}){return t.jsx("button",{onClick:()=>{e&&window.open(e,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})}const cae=Object.freeze(Object.defineProperty({__proto__:null,OpenInNewTabButton:wT},Symbol.toStringTag,{value:"Module"})),Uc=new Set;function $7(e){return Uc.add(e),()=>{Uc.delete(e)}}function F7(){for(const e of Uc)e()}function _T(){return t.jsx("button",{onClick:()=>F7(),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Refresh preview","aria-label":"Refresh preview",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("polyline",{points:"1 20 1 14 7 14"}),t.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 dae=Object.freeze(Object.defineProperty({__proto__:null,RefreshPreviewButton:_T},Symbol.toStringTag,{value:"Module"}));function tg(e){var s;return e.route==="Uncategorized"?2:e.route.startsWith("/isolated-components/")||((s=e.scenarios[0])==null?void 0:s.scenarioType)==="component"?1:0}function ST(e){const n=new Map;for(const s of e){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=tg(s)-tg(r);return a!==0?a:s.route.localeCompare(r.route)})}function z7(e,n){const s=n.trim().toLowerCase();return s?e.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)}):e}function kT({tab:e,hasQuery:n}){return n?t.jsx("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:"No matches for your search."}):t.jsxs("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:["No ",e==="pages"?"pages":"components"," yet."]})}const uae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerEmptyMessage:kT},Symbol.toStringTag,{value:"Module"}));function NT({scenario:e,active:n,onClick:s}){const r=e.screenshotPaths[0],a=Uo(e);return t.jsxs("button",{onClick:s,"aria-current":n?"true":void 0,className:"group w-28 text-left cursor-pointer",title:e.name,children:[t.jsx("div",{className:`aspect-[4/5] w-full overflow-hidden rounded-md bg-[#141414] flex items-center justify-center transition-shadow ${n?"ring-2 ring-[var(--accent-active)]":"ring-1 ring-white/10 group-hover:ring-white/25"}`,children:r?t.jsx("img",{src:gs(r),alt:e.name,loading:"lazy",className:"w-full h-full object-contain"}):t.jsx("span",{className:"text-[10px] text-gray-600",children:"No screenshot"})}),t.jsx("div",{className:`pt-1.5 px-0.5 text-[11.5px] truncate ${n?"text-white":"text-gray-400 group-hover:text-gray-200"}`,children:a})]})}const pae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerScenarioThumbnail:NT},Symbol.toStringTag,{value:"Module"}));function CT({group:e,currentSlug:n,onSelect:s}){const r=e.scenarios[0]?Cv(e.scenarios[0]):null;return t.jsxs("div",{className:"min-w-0 max-w-full",children:[t.jsx("div",{className:"mb-2 px-0.5 max-w-[16rem]",title:e.route,children:t.jsx("span",{className:"block text-xs font-medium text-gray-200 truncate",children:r??e.route})}),t.jsx("div",{className:"flex flex-wrap gap-3",children:e.scenarios.map(a=>t.jsx(NT,{scenario:a,active:a.slug===n,onClick:()=>s(a.slug)},a.slug))})]})}const hae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerRouteSection:CT},Symbol.toStringTag,{value:"Module"}));function Gc({label:e,active:n,count:s,onClick:r}){return t.jsxs("button",{onClick:r,"aria-pressed":n,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs cursor-pointer transition-colors ${n?"text-white bg-white/10":"text-gray-500 hover:text-gray-300"}`,children:[e,t.jsx("span",{className:`text-[11px] tabular-nums ${n?"text-gray-400":"text-gray-600"}`,children:s})]})}const fae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerTabButton:Gc},Symbol.toStringTag,{value:"Module"}));function TT({scenarioGroups:e,currentSlug:n,onSelect:s,onClose:r,triggerRef:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(""),u=l.useRef(null),p=l.useRef(null);l.useEffect(()=>{var y;(y=p.current)==null||y.focus()},[]),zo(u,r,a);const h=l.useMemo(()=>e.flatMap(y=>y.scenarios),[e]),f=l.useMemo(()=>z7(h,c),[h,c]),m=l.useMemo(()=>f.filter(ko),[f]),g=l.useMemo(()=>f.filter(td),[f]),x=o==="pages"?m:g,b=l.useMemo(()=>ST(x),[x]);return t.jsxs("div",{ref:u,className:"absolute top-full left-0 mt-1.5 bg-[#1f1f1f] border border-white/10 rounded-xl shadow-2xl z-50 w-[560px] max-w-[calc(100vw-2rem)] max-h-[480px] flex flex-col",role:"dialog",children:[t.jsxs("div",{className:"flex items-center border-b border-white/[.06] px-2.5 py-2 gap-1",children:[t.jsx(Gc,{label:"Pages",active:o==="pages",count:m.length,onClick:()=>i("pages")}),t.jsx(Gc,{label:"Components",active:o==="components",count:g.length,onClick:()=>i("components")}),t.jsx("div",{className:"flex-1"}),t.jsx("input",{ref:p,value:c,onChange:y=>d(y.target.value),placeholder:"Search…",className:"w-44 h-7 px-2.5 text-xs bg-white/[.04] border border-white/10 rounded-md text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-white/25"}),t.jsx("button",{onClick:r,"aria-label":"Close",className:"p-1 text-gray-500 hover:text-gray-200 cursor-pointer",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),t.jsx("div",{className:"overflow-y-auto p-4 flex-1 min-h-0 flex flex-wrap content-start items-start gap-x-6 gap-y-5",children:b.length===0?t.jsx(kT,{tab:o,hasQuery:c.trim().length>0}):b.map(y=>t.jsx(CT,{group:y,currentSlug:n,onSelect:v=>{s(v),r()}},y.route))})]})}const mae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerDropdown:TT},Symbol.toStringTag,{value:"Module"}));function PT(){return t.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:[t.jsx("path",{d:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),t.jsx("path",{d:"M14 3v6h6"})]})}function OT(){return t.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:[t.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),t.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),t.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),t.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]})}function RT({className:e}){return t.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:e??"opacity-70 shrink-0 text-gray-400",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})}const gae=Object.freeze(Object.defineProperty({__proto__:null,ComponentGlyph:OT,DropdownChevron:RT,PageGlyph:PT},Symbol.toStringTag,{value:"Module"}));function ET({currentScenario:e,isOpen:n,onClick:s,buttonRef:r}){const a=e?td(e):!1,o=(e==null?void 0:e.screenshotPaths[0])??null,i=e?a?e.componentName??e.name:Cv(e)??e.url??e.name:"Select a page";return t.jsxs("button",{ref:r,onClick:s,className:`flex items-center gap-2 h-7 max-w-[260px] px-1.5 rounded-md transition-colors cursor-pointer text-xs ${e?"text-white":"text-gray-500"} ${n?"bg-white/10":"hover:bg-white/5"}`,title:i,"aria-haspopup":"menu","aria-expanded":n,children:[t.jsx("span",{className:"flex items-center",children:t.jsx("span",{className:"w-6 h-4 overflow-hidden rounded-sm bg-[#0f0f0f] ring-1 ring-white/10 flex items-center justify-center text-gray-500",children:o?t.jsx("img",{src:gs(o),alt:"",className:"w-full h-full object-cover"}):a?t.jsx(OT,{}):t.jsx(PT,{})})}),t.jsx("span",{className:"truncate",children:i})]})}const xae=Object.freeze(Object.defineProperty({__proto__:null,PagePill:ET},Symbol.toStringTag,{value:"Module"}));function AT({scenario:e,active:n,onClick:s}){const r=e.screenshotPaths[0];return t.jsxs("button",{onClick:s,"aria-current":n?"true":void 0,className:`flex items-center gap-2.5 w-full px-2 py-1.5 rounded-md text-left transition-colors cursor-pointer ${n?"bg-white/[.08]":"hover:bg-white/5"}`,children:[t.jsx("div",{className:`w-10 h-7 shrink-0 rounded overflow-hidden bg-[#0f0f0f] flex items-center justify-center ${n?"ring-2 ring-[var(--accent-active)]":"ring-1 ring-white/10"}`,children:r?t.jsx("img",{src:gs(r),alt:"",className:"w-full h-full object-cover"}):null}),t.jsx("div",{className:`text-xs truncate flex-1 min-w-0 ${n?"text-white":"text-gray-200"}`,children:Uo(e)})]})}const bae=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdownRow:AT},Symbol.toStringTag,{value:"Module"}));function MT({currentScenario:e,scenarioGroups:n,onSelect:s,onCreateNew:r,onClose:a,triggerRef:o}){const i=l.useRef(null);zo(i,a,o);const c=l.useMemo(()=>ru(e,n),[e,n]);return t.jsxs("div",{ref:i,className:"absolute top-full left-0 mt-1.5 bg-[#1f1f1f] border border-white/10 rounded-xl shadow-2xl z-50 w-72 max-w-[calc(100vw-2rem)] max-h-[400px] flex flex-col overflow-hidden",role:"menu",children:[t.jsx("div",{className:"overflow-y-auto p-1 flex-1 min-h-0",children:c.map(d=>t.jsx(AT,{scenario:d,active:d.slug===e.slug,onClick:()=>{s(d.slug),a()}},d.slug))}),t.jsx("button",{onClick:()=>{r(),a()},className:"border-t border-white/[.06] px-3 py-2.5 text-left text-xs text-[var(--accent-active)] hover:bg-[var(--accent-active)]/10 cursor-pointer",children:"+ New state"})]})}const yae=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdown:MT},Symbol.toStringTag,{value:"Module"}));function IT({label:e,disabled:n,isOpen:s,onClick:r,buttonRef:a}){return t.jsxs("button",{ref:a,onClick:()=>{n||r()},disabled:n,className:`flex items-center gap-1.5 max-w-[200px] h-7 px-2 rounded-md transition-colors text-xs ${n?"text-gray-600 cursor-not-allowed":s?"bg-white/10 text-gray-200 cursor-pointer":"text-gray-400 hover:bg-white/5 hover:text-gray-200 cursor-pointer"}`,title:n?"No active state":e,"aria-haspopup":"menu","aria-expanded":s,children:[t.jsx("span",{className:"truncate",children:e}),t.jsx(RT,{className:"opacity-70 shrink-0"})]})}const vae=Object.freeze(Object.defineProperty({__proto__:null,StatesPillButton:IT},Symbol.toStringTag,{value:"Module"}));function DT({viewport:e,isActive:n,onSelect:s}){return t.jsx("button",{onClick:s,"aria-pressed":n,className:`p-1 rounded-md transition-colors cursor-pointer ${n?"text-white bg-white/10":"text-gray-500 hover:text-gray-300"}`,title:`${e.name} (${e.width}×${e.height})`,children:t.jsx(y1,{name:e.name})})}const jae=Object.freeze(Object.defineProperty({__proto__:null,ViewportPresetButton:DT},Symbol.toStringTag,{value:"Module"}));function LT({viewports:e,active:n,onChange:s,currentWidth:r,currentHeight:a,previewUrl:o,isCollapsed:i,onToggleCollapsed:c,isFilled:d,onToggleFilled:u,containerWidth:p,containerHeight:h,onCustomSizeChange:f,currentScenario:m,scenarioGroups:g,onShowScenarioPreview:x,onCreateStateRequest:b,isNarrow:y=!1,onBack:v,onPlanChange:j,onToggleStatesModal:_,statesModalOpen:S=!1}){const[w,k]=l.useState(!1),[N,C]=l.useState(!1),T=l.useRef(null),P=l.useRef(null),R=d&&p?Math.round(p):r,L=d&&h?Math.round(h):a,M=m?Uo(m):"No state",O=!m;return t.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 h-10 flex items-center gap-2 px-2",children:[t.jsx("div",{className:"shrink-0",children:v?t.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:[t.jsx("span",{"aria-hidden":"true",children:"←"})," Home"]}):y?null:t.jsx(vT,{isCollapsed:i,onToggle:c})}),t.jsxs("div",{"data-testid":"preview-bar-groups",className:`flex flex-1 items-center justify-between gap-2 min-w-0 ${y?"overflow-x-auto":""}`,children:[t.jsxs("div",{"data-testid":"preview-subject-group",className:"relative flex items-center h-7 gap-0.5 shrink-0",children:[t.jsx(ET,{currentScenario:m,isOpen:w,onClick:()=>{k(z=>!z),C(!1)},buttonRef:T}),w&&t.jsx(TT,{scenarioGroups:g,currentSlug:(m==null?void 0:m.slug)??null,onSelect:x,onClose:()=>k(!1),triggerRef:T}),t.jsx("div",{className:"relative flex items-center",children:_?S?null:t.jsx("button",{type:"button",onClick:_,className:"px-2 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"}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-xs text-[#666] shrink-0 select-none","aria-hidden":"true",children:"/"}),t.jsx(IT,{label:M,disabled:O,isOpen:N,onClick:()=>{C(z=>!z),k(!1)},buttonRef:P}),N&&m&&t.jsx(MT,{currentScenario:m,scenarioGroups:g,onSelect:x,onCreateNew:b,onClose:()=>C(!1),triggerRef:P})]})})]}),t.jsxs("div",{"data-testid":"preview-device-group",className:"relative flex items-center h-7 gap-2 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg border border-white/10",children:[e.map(z=>t.jsx(DT,{viewport:z,isActive:!d&&n===z.name,onSelect:()=>{d&&u(),s(z.name)}},z.name)),t.jsx(jT,{isFilled:d,onToggle:u})]}),t.jsxs("div",{"data-testid":"preview-size-field",className:"flex items-center text-[11px] font-mono text-gray-500",children:[t.jsx(qc,{bare:!0,label:"W",value:R,disabled:d,onCommit:z=>f(z,a)}),t.jsx("span",{"aria-hidden":"true",children:"×"}),t.jsx(qc,{bare:!0,label:"H",value:L,disabled:d,onCommit:z=>f(r,z)})]}),t.jsx("span",{className:"w-px h-4 bg-white/10 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"flex items-center",children:[t.jsx(_T,{}),t.jsx(wT,{previewUrl:o})]})]})]}),t.jsx("div",{className:"shrink-0 flex items-center gap-2",children:j?t.jsx("button",{type:"button",onClick:j,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 wae=Object.freeze(Object.defineProperty({__proto__:null,NavigationBar:LT},Symbol.toStringTag,{value:"Module"}));function $T(){return t.jsxs("div",{style:{padding:"3rem 1rem",textAlign:"center",color:"var(--text-muted)"},children:[t.jsx("h2",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-secondary)",margin:"0 0 0.5rem 0"},children:"No plan loaded"}),t.jsx("p",{style:{margin:0,fontSize:"0.875rem"},children:"Ask the AI to draft a plan, or pick one from the Plan tab."})]})}const _ae=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewEmptyState:$T},Symbol.toStringTag,{value:"Module"}));function FT({title:e}){return t.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:e})}const Sae=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewHeader:FT},Symbol.toStringTag,{value:"Module"})),ng={prompt:null,title:null};function zT(){const[e,n]=l.useState(ng),[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(ng)}finally{a||r(!1)}})(),()=>{a=!0}},[]),{...e,loading:s}}function BT(){const{prompt:e,title:n,loading:s}=zT();return t.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:t.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:s?null:e?t.jsxs(t.Fragment,{children:[n?t.jsx(FT,{title:n}):null,t.jsx(Lt,{children:e})]}):t.jsx($T,{})})})}const kae=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewPanelView:BT},Symbol.toStringTag,{value:"Module"}));function WT({message:e}){return t.jsx("span",{style:{color:"var(--text-dim)"},children:e})}const Nae=Object.freeze(Object.defineProperty({__proto__:null,PreviewEmptyState:WT},Symbol.toStringTag,{value:"Module"}));function HT({hasDevServerConfigured:e}){const n=e?"Starting your app…":"Your app will display here once set up";return t.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:t.jsx("span",{children:n})})}const Cae=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingPlaceholder:HT},Symbol.toStringTag,{value:"Module"}));function qT(e,n,s){const r=[e];return n&&r.push(`reload:${n}`),s&&r.push(`command:${s}`),r.join("::")}function UT({currentWidth:e,currentHeight:n,isFilled:s,scale:r}){const a=t.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:t.jsxs("div",{className:"text-sm leading-relaxed",children:[t.jsx("div",{className:"font-medium",children:"Live Preview unavailable"}),t.jsxs("div",{className:"opacity-70 mt-1",children:[e,"×",n]})]})});return s?a:t.jsx(Vr,{width:e,height:n,scale:r,children:a})}const GT=l.forwardRef(function({currentHeight:n,currentWidth:s,isFilled:r,previewUrl:a,scale:o,reloadNonce:i,commandNonce:c,iframeKey:d,onLoad:u,onError:p},h){if(Zt())return t.jsx(UT,{currentWidth:s,currentHeight:n,isFilled:r,scale:o});const f=d??qT(a,i,c),m=()=>{p&&p("iframe error event")};return t.jsx(Vr,{width:s,height:n,scale:o,filled:r,children:t.jsx("iframe",{ref:h,src:a,name:dR,title:"Live Preview",style:{width:"100%",height:"100%",border:"none",background:"var(--bg-deep)"},onLoad:u,onError:m},f)})}),Tae=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedPreviewPlaceholder:UT,PreviewFrame:GT},Symbol.toStringTag,{value:"Module"}));function YT({label:e="Loading preview..."}={}){return t.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:[t.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),t.jsx("span",{className:"text-sm",children:e})]})}const Pae=Object.freeze(Object.defineProperty({__proto__:null,PreviewLoadingSpinner:YT},Symbol.toStringTag,{value:"Module"}));function B7(e){var n,s;try{const r=(s=(n=e==null?void 0:e.contentWindow)==null?void 0:n.location)==null?void 0:s.href;return typeof r=="string"?r:null}catch{return null}}function W7(e,n){if(!n||!e||e==="about:blank")return null;let s;try{s=new URL(e,window.location.origin).pathname}catch{return null}return s===ps||s.startsWith(`${ps}/`)?null:s}function H7(e){return{type:"error",message:`The app navigated to "${e}", which is outside the Live Preview (everything the preview serves lives under ${ps}). 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:e,lineno:null,colno:null,stack:[`Frame navigated to: ${e}`,`Expected to stay under: ${ps}`,"",`Why this happens: the Live Preview is served from the same-origin ${ps} 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(`
|
|
303
|
-
`),timestampMs:Date.now(),dedupeKey:`preview-escape:${e}`,count:1}}function q7({previewUrl:e,resetKey:n,capturedErrors:s}){const[r,a]=l.useState(null),o=e.startsWith(ps);l.useEffect(()=>{a(null)},[n,e]);const i=l.useCallback(u=>{const p=B7(u),h=W7(p,o);return a(h),h!==null&&wW(h),p},[o]),c=l.useCallback(()=>a(null),[]),d=l.useMemo(()=>r?[...s,H7(r)]:s,[s,r]);return{escaped:r!==null,overlayErrors:d,noteFrameLoad:i,clearEscape:c}}function U7(e){return!(e instanceof HTMLElement)||e===document.body||e===document.documentElement||!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e.isContentEditable)?!1:e.disabled!==!0}function G7(e,n){if(n!==null&&document.activeElement===n)return;const s=e!==null&&document.activeElement===e;if(!(!s&&!bc())){if(n===null){if(s)return;Pr(),Tt();return}if(Pr(),s&&vc(e),!document.contains(n)){Tt();return}requestAnimationFrame(()=>{n.focus({preventScroll:!0})})}}function Y7(e){const n=l.useRef(null),s=l.useRef(null),r=l.useRef(null);return l.useEffect(()=>{function o(){const c=document.activeElement;if(!U7(c))return;const d=e.current;d!==null&&(c===d||d.contains(c))||(n.current=c)}function i(c){const d=e.current;if(d===null)return;if(c.target===d){n.current=null;return}const u=d.getBoundingClientRect();yc(c.clientX,c.clientY,u,1)&&(n.current=null)}return document.addEventListener("focusin",o),document.addEventListener("pointerdown",i,!0),()=>{document.removeEventListener("focusin",o),document.removeEventListener("pointerdown",i,!0)}},[e]),l.useEffect(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current),r.current!==null&&clearTimeout(r.current)},[]),{notePreviewLoaded:l.useCallback(()=>{s.current!==null&&cancelAnimationFrame(s.current),r.current!==null&&clearTimeout(r.current);const o=()=>{G7(e.current,n.current)};s.current=requestAnimationFrame(()=>{s.current=null,o()}),r.current=setTimeout(()=>{r.current=null,o()},50)},[e])}}function V7(e,n){const s=l.useRef(!1);l.useEffect(()=>{s.current||e&&e.startCommand&&(e.intendedRunning||e.status==="stopped"&&(s.current=!0,n()))},[e,n])}function K7(e,n){const[s,r]=l.useState(!1),a=l.useCallback(()=>{s?(r(!1),e.deactivate(),e.clearSelection()):(r(!0),e.activate())},[s,e]);return l.useEffect(()=>{s&&(r(!1),e.clearSelection())},[n]),{isActive:s,toggle:a}}function J7(e,n=!0,s="running"){const r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(0),c=l.useRef(null);l.useEffect(()=>{e!=null&&(r.current!=null&&e!==r.current?(a.current=!1,i(p=>p+1)):r.current==null&&(a.current?n&&Dm(e,c.current):i(p=>p+1)),r.current=e)},[e,n]);const d=l.useCallback(p=>{a.current=!0,p&&(c.current=p),n&&e!=null&&Dm(e,p??c.current)},[e,n]),u=l.useCallback(p=>{n&&bW(p)},[n]);return{reloadNonce:o,handleIframeLoad:d,handleIframeError:u}}const X7=1500,Q7=2e3,Z7=3e3,e9=2;function t9(){return typeof window>"u"?!1:window.location.pathname.startsWith("/scenario/")?!0:Zt()}function n9(e,n=!1){const s=t9(),[r,a]=l.useState(s?!0:null),[o,i]=l.useState(null),[c,d]=l.useState(0),[u,p]=l.useState(0),h=l.useRef(null),f=l.useRef(null),m=l.useRef(null),g=l.useRef(!1),x=l.useRef(e),b=l.useRef(n);l.useEffect(()=>{x.current=e},[e]),l.useEffect(()=>{b.current=n},[n]);const y=l.useCallback(()=>{f.current!=null&&(clearTimeout(f.current),f.current=null)},[]),v=l.useCallback(async()=>{if(g.current||b.current)return;const w=x.current;if(!w)return;m.current&&m.current.abort();const k=new AbortController;m.current=k;const N=setTimeout(()=>k.abort(),Z7);let C=!1;try{await fetch(w,{mode:"no-cors",cache:"no-store",signal:k.signal}),C=!0}catch{C=!1}finally{clearTimeout(N)}if(!g.current){if(i(Date.now()),C){if(d(0),h.current!==!0){const T=h.current===!1;h.current=!0,a(!0),T&&p(P=>P+1)}}else d(T=>{const P=T+1;return P>=e9&&h.current!==!1&&(h.current=!1,a(!1)),P});j()}},[]),j=l.useCallback(()=>{if(g.current)return;y();const w=h.current===!0?Q7:X7;f.current=setTimeout(()=>{f.current=null,v()},w)},[y,v]),_=l.useCallback(()=>{y(),v()},[y,v]);l.useEffect(()=>{if(!s)return g.current=!1,v(),()=>{g.current=!0,y(),m.current&&(m.current.abort(),m.current=null)}},[v,y,s]),l.useEffect(()=>{s||v()},[e,v,s]);const S=l.useRef(n);return l.useEffect(()=>{if(s)return;const w=S.current;S.current=n,w&&!n&&v()},[n,v,s]),{healthy:r,lastProbeAt:o,failedProbeCount:c,reloadNonce:u,invalidate:_}}const sg={loaded:!1,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:null};function s9(e){const{active:n,trigger:s}=e,[r,a]=l.useState(sg),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 h=(u.stalls??[]).reduce((f,m)=>Math.max(f,m.durationMs??0),0);a({loaded:!0,stalledRequests:u.stalledRequests??0,fastRequests:u.fastRequests??0,longestStallMs:h,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(sg),(c=o.current)==null||c.abort();return}return i(),()=>{var d;(d=o.current)==null||d.abort()}},[n,s,i]),r}function r9(e){return!e||!e.loaded||e.tailReadFailedReason?null:e.stalledRequests>0?`Recent requests took up to ${Math.max(1,Math.round(e.longestStallMs/1e3))}s — the dev server is responding, just slowly. Check the dev-server log for what's blocking the render.`:e.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 a9({liveIframeHealthy:e,previewReachable:n}){return e===!0||n===!0}function o9({hasDevServerConfigured:e,hasServed:n}){return!e||n}const i9=2e3;function l9(e,n){const[s,r]=l.useState(0),a=l.useRef(e),o=l.useRef(n),i=l.useRef(0);return l.useEffect(()=>{const c=a.current,d=o.current;if(a.current=e,o.current=n,!(n===!1)||!(e===!0)||!(c===!1&&e===!0)&&!(d===!0&&n===!1))return;const m=Date.now();m-i.current<i9||(i.current=m,r(g=>g+1))},[e,n]),s}const Ra={windowMs:1e4,threshold:4,ringBufferSize:16};function c9({pidNonce:e,probeNonce:n,draftNonce:s,windowMs:r=Ra.windowMs,threshold:a=Ra.threshold}){const[o,i]=l.useState(!1),[c,d]=l.useState([]),[u,p]=l.useState(0),h=l.useRef(!1),f=l.useRef(e),m=l.useRef(n),g=l.useRef(s),x=l.useCallback(y=>{const v=Date.now(),j=v-r;let _=[];d(w=>{const k=w.filter(N=>N.timestampMs>=j);return k.push({reason:y,timestampMs:v}),k.length>Ra.ringBufferSize&&k.splice(0,k.length-Ra.ringBufferSize),_=k,k});const S=_.filter(w=>w.timestampMs>=j).length;if(!h.current&&S>=a){h.current=!0,i(!0);return}h.current||p(w=>w+1)},[r,a]);l.useEffect(()=>{e!==f.current&&(f.current=e,x("pid"))},[e,x]),l.useEffect(()=>{n!==m.current&&(m.current=n,x("probe"))},[n,x]),l.useEffect(()=>{s!==g.current&&(g.current=s,x("draft"))},[s,x]);const b=l.useCallback(()=>{h.current=!1,i(!1),d([]),p(y=>y+1)},[]);return{tripped:o,recentReloads:c,gatedNonce:u,reset:b}}function d9(e,n,s=dd){const r=l.useRef(void 0);l.useEffect(()=>{if(!n){r.current=e;return}if(typeof e=="number"){if(r.current===void 0){r.current=e;return}e>r.current&&(r.current=e,s())}},[e,n,s])}const rg=20,u9="codeyam-error-capture";function p9(e,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!==u9)return;const d=e.current;if(d&&i.source!==d.contentWindow)return;const u=c.payload;!u||typeof u!="object"||!u.dedupeKey||r(p=>{const h=p.findIndex(m=>m.dedupeKey===u.dedupeKey);if(h>=0){const m=p.slice();return m[h]={...m[h],count:m[h].count+1,timestampMs:u.timestampMs},m}const f=[...p,{...u,count:1}];return f.length>rg?f.slice(f.length-rg):f})}return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[e]),{errors:s,clear:a}}const dl=[500,1e3,2e3];async function h9(e){try{const s=await(await fetch(`/api/probe-url?url=${encodeURIComponent(e)}`)).json();return{status:typeof(s==null?void 0:s.status)=="number"?s.status:null}}catch{return{status:null}}}async function f9(){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 m9(e,n){const[s,r]=l.useState({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return l.useEffect(()=>{if(!e){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+dl.length;let i=null;for(let d=0;d<o;d++){if(a)return;const{status:u}=await h9(e);if(a)return;if(i=u,u===null||u<500){r({status:u,clickThroughBroken:!1,logLines:[],loading:!1});return}d<dl.length&&await new Promise(p=>setTimeout(p,dl[d]))}const c=await f9();a||r({status:i,clickThroughBroken:!0,logLines:c,loading:!1})})(),()=>{a=!0}},[e,n]),s}function VT({url:e,status:n,logLines:s,onRetry:r}){return t.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:t.jsxs("div",{className:"max-w-2xl w-full rounded-md border border-red-700 bg-zinc-900 text-zinc-100 shadow-xl",children:[t.jsxs("div",{className:"px-5 py-4 border-b border-red-800 flex justify-between items-start",children:[t.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[t.jsxs("div",{className:"text-sm font-semibold text-red-300",children:["Scenario render failed (HTTP ",n,")"]}),t.jsx("div",{className:"mt-1 text-xs text-zinc-400 break-all",children:e}),t.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."})]}),t.jsxs("div",{className:"flex-shrink-0 flex items-start gap-2",children:[t.jsx(mt,{variant:"subtle",text:`Scenario render failed (HTTP ${n})
|
|
304
|
-
${e}
|
|
305
|
-
|
|
306
|
-
${s.join(`
|
|
307
|
-
`)}`,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"}),t.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"})]})]}),t.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(`
|
|
308
|
-
`):t.jsxs("span",{className:"text-zinc-500 italic",children:["No dev-server log lines available — see"," ",t.jsx("code",{children:".codeyam/logs/dev-server.log"}),"."]})})]})})}const Oae=Object.freeze(Object.defineProperty({__proto__:null,IframeClickThroughErrorCard:VT},Symbol.toStringTag,{value:"Module"}));function g9(e){if(e===null||!e.startCommand)return{isRestarting:!1,isFailed:!1,isStarting:!1,isStopped:!1};const n=e.status==="failed",s=!n&&e.status!=="running"&&e.intendedRunning&&(e.restartCount??0)>0,r=!n&&e.intendedRunning&&e.status!=="running"&&(e.restartCount??0)===0,a=e.status==="stopped"&&!e.intendedRunning;return{isRestarting:s,isFailed:n,isStarting:r,isStopped:a}}const x9=20;function b9(e){const{hasDevServerConfigured:n,probeHealthy:s,backendIframeHealthy:r,isStarting:a,isRestarting:o,isFailed:i,isStopped:c,isPrePrototype:d,withinStartupGrace:u,previewReachable:p,hasEverServed:h}=e;return n?i?"crashed":r===!0||p===!0||s===!0&&r!==!1?null:d?"scaffolding":c?h?"stopped":null:o?"restarting":a||u||!h?null:s===!1?"reconnecting":r===!1&&s===!0?"disconnected":s===null?"probing":"reconnecting":null}function y9(e){return e===null||e.status!=="running"?!1:e.liveIframeHealthy!==!1}const v9=5,j9=3;function w9(e,n){return e===null||e<=0?!1:e<=(n==="backend"?j9:v9)}const ag="Setting up your project",og="Preparing your project — the preview will appear once it's ready.",_9={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."},S9={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Preparing the project environment."};function k9(e,n){return e===null?{title:ag,body:og}:{title:ag,body:(n==="backend"?S9:_9)[e]??og}}const N9={probing:{title:"Checking the Live Preview",body:"Making sure your app is responding before showing it.",spinner:!0,stuckTitle:"Your app isn't responding",stuckBody:"The preview couldn't reach it. Trying again usually brings it back.",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,stuckTitle:"Your app hasn't started",stuckBody:"Its server never came up. Trying again usually gets it going.",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,stuckTitle:"Your app didn't come back",stuckBody:"It stopped and hasn't restarted yet. Trying again usually brings it back.",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,stuckTitle:"Your app isn't responding",stuckBody:"Its server stopped answering. Trying again usually brings it back.",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,stuckBody:"It didn't start on its own. Trying again usually gets it going.",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 KT({variant:e,restartCount:n=0,showRetry:s=!1,onRetry:r,bodyOverride:a}){const{title:o,body:i,spinner:c,nextAction:d,stuckTitle:u,stuckBody:p}=N9[e],h=a??i,f=e==="disconnected",m=f||e==="crashed"||s,g=f?"Reload preview":"Try again",{phase:x,attempts:b,retry:y}=Pg(r??(()=>{}));return m?t.jsx(wx,{variant:e,title:u??o,body:a??p??h,nextAction:d,actionLabel:g,onAction:r?y:void 0,pending:x==="pending",feedback:x==="unchanged"?t.jsxs("span",{"data-testid":"preview-unhealthy-overlay-unchanged",children:["Checked just now, the preview still isn’t back",b>1?` (${b} tries)`:"","."]}):null}):t.jsx(My,{title:o,body:h,spinner:c,restartCount:n,variant:e})}const Rae=Object.freeze(Object.defineProperty({__proto__:null,PreviewUnhealthyOverlay:KT},Symbol.toStringTag,{value:"Module"}));function C9(e){return e.slice().reverse().map(n=>{const s=n.filename!=null?`
|
|
309
|
-
at ${n.filename}${n.lineno!=null?`:${n.lineno}`:""}${n.colno!=null?`:${n.colno}`:""}`:"",r=n.stack?`
|
|
310
|
-
${n.stack}`:"",a=n.count>1?` (×${n.count})`:"";return`[${n.type}]${a} ${n.message}${s}${r}`}).join(`
|
|
311
|
-
|
|
312
|
-
`)}function T9(e){if(e.length===0)return"no reloads recorded";const n={};for(const s of e)n[s.reason]=(n[s.reason]??0)+1;return Object.entries(n).map(([s,r])=>`${s}×${r}`).join(", ")}function JT({count:e,onExpand:n,onClear:s}){const r=`${e} ${e===1?"Error":"Errors"}`;return t.jsx("div",{"data-testid":"preview-error-badge",className:"absolute bottom-3 right-3 z-50 pointer-events-auto",children:t.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:[t.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:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full bg-red-600"}),t.jsx("span",{children:r}),t.jsx("span",{"aria-hidden":"true",className:"text-gray-400",children:"›"})]}),t.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 Eae=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorBadge:JT},Symbol.toStringTag,{value:"Module"}));function XT({headline:e,tripped:n,onClear:s,closeAriaLabel:r="Dismiss errors",providerLabel:a}){return t.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3 border-b border-red-200 dark:border-red-900",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:e}),t.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}.`})]}),t.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 Aae=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayHeader:XT},Symbol.toStringTag,{value:"Module"}));function P9(e){const n=e.filename?`${e.filename}${e.lineno!=null?`:${e.lineno}`:""}${e.colno!=null?`:${e.colno}`:""}`:"";return[`${e.type}: ${e.message}`,n,e.stack??""].filter(Boolean).join(`
|
|
313
|
-
`)}function QT({error:e,expanded:n,onToggle:s}){return t.jsxs("li",{className:"rounded border border-red-200 dark:border-red-900 bg-red-50/60 dark:bg-red-950/30",children:[t.jsxs("div",{className:"flex items-start",children:[t.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:[t.jsx("span",{className:"mt-0.5 text-red-500","aria-hidden":"true",children:n?"▾":"▸"}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-red-500 dark:text-red-400 mr-2",children:e.type}),t.jsx("span",{className:"text-gray-900 dark:text-gray-100 break-words",children:e.message}),e.count>1&&t.jsxs("span",{className:"ml-2 text-gray-500",children:["×",e.count]}),e.filename&&t.jsxs("span",{className:"block text-[11px] text-gray-500 mt-0.5 truncate",children:[e.filename,e.lineno!=null?`:${e.lineno}`:"",e.colno!=null?`:${e.colno}`:""]})]})]}),t.jsx("div",{className:"shrink-0 px-1.5 py-1.5",children:t.jsx(mt,{variant:"icon",text:P9(e)})})]}),n&&e.stack&&t.jsx("pre",{className:"px-3 pb-2 text-[11px] font-mono text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",children:e.stack})]})}const Mae=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorRow:QT},Symbol.toStringTag,{value:"Module"}));function ZT({errors:e,emptyHint:n}){const[s,r]=l.useState(null);return e.length===0?t.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:t.jsx("li",{className:"text-gray-500 px-2 py-3",children:n??"No runtime errors captured yet."})}):t.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:e.slice().reverse().map(a=>t.jsx(QT,{error:a,expanded:s===a.dedupeKey,onToggle:()=>r(s===a.dedupeKey?null:a.dedupeKey)},a.dedupeKey))})}const Iae=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorList:ZT},Symbol.toStringTag,{value:"Module"}));function e5({canCopy:e,reasonsSummary:n,copyState:s,onCopy:r,onCopyForAgent:a,onRetry:o,providerLabel:i}){return t.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:[t.jsx("button",{type:"button",onClick:r,disabled:!e,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"}),t.jsxs("button",{type:"button",onClick:a,disabled:!e,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]}),t.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"}),t.jsxs("span",{className:"ml-auto text-[11px] text-gray-500",children:["Reloads in last 10s: ",n,s==="copied"&&t.jsx("span",{className:"ml-2 text-emerald-600",children:"copied ✓"}),s==="failed"&&t.jsx("span",{className:"ml-2 text-red-500",children:"copy blocked"})]})]})}const Dae=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayFooter:e5},Symbol.toStringTag,{value:"Module"})),O9=`Fix this error in the live preview. Here is what the captured runtime error reported:
|
|
314
|
-
|
|
315
|
-
`;function t5({tripped:e,errors:n,recentReloads:s,serverHealthy:r,onRetry:a,onClear:o,providerLabel:i}){const[c,d]=l.useState("idle"),[u,p]=l.useState(!0),h=l.useMemo(()=>C9(n),[n]),f=l.useMemo(()=>T9(s),[s]);if(l.useEffect(()=>{n.length===0&&p(!0)},[n.length]),!e&&n.length===0)return null;const m=r&&!e,g=m&&u&&n.length>0,x=e?`Live Preview paused — ${n.length} error${n.length===1?"":"s"} captured`:`${n.length} runtime error${n.length===1?"":"s"} captured`;async function b(y){const v=await NE(y+h);d(v?"copied":"failed"),setTimeout(()=>d("idle"),1500)}return g?t.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":"false","data-collapsed":"true",className:"absolute inset-0 z-50 pointer-events-none",children:t.jsx(JT,{count:n.length,onExpand:()=>p(!1),onClear:o})}):t.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":e?"true":"false","data-collapsed":"false",className:"absolute inset-0 z-50 flex flex-col items-stretch p-4 pointer-events-none",children:t.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:[t.jsx(XT,{headline:x,tripped:e,onClear:m?()=>p(!0):o,closeAriaLabel:m?"Minimize errors":"Dismiss errors",providerLabel:i}),t.jsx(ZT,{errors:n,emptyHint:e?`Breaker tripped before any runtime error was reported. Reasons in window: ${f}.`:null}),t.jsx(e5,{canCopy:n.length>0,reasonsSummary:f,copyState:c,onCopy:()=>b(""),onCopyForAgent:()=>b(O9),onRetry:a,providerLabel:i})]})})}const Lae=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlay:t5},Symbol.toStringTag,{value:"Module"}));function R9(e){if(!e)return null;const n=Object.entries(e).map(([s,r])=>`${s}=${typeof r=="string"?r:JSON.stringify(r)}`);return n.length>0?n.join(", "):null}function n5({previewUrl:e,description:n,demonstratesState:s}){const r=l.useMemo(()=>{try{return new URL(e,window.location.origin).searchParams.get("_codeyam_scenario")}catch{return null}},[e]),a=l.useMemo(()=>R9(s),[s]);if(!r)return null;const o=n!=null&&n.trim()?n.trim():null;return!o&&!a?null:t.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:[o?t.jsx("span",{className:"text-[10px] text-white/70 leading-snug whitespace-pre-line",children:o}):null,a?t.jsx("span",{className:"text-[9px] font-mono text-white/50 tracking-wide",children:a}):null]})}const $ae=Object.freeze(Object.defineProperty({__proto__:null,ActiveScenarioOverlay:n5},Symbol.toStringTag,{value:"Module"}));function s5(){return t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),t.jsx("h3",{className:"text-sm font-bold text-gray-900 dark:text-gray-100 uppercase tracking-tight",children:"Dev Server Crash Recovery Failed"})]}),t.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 font-medium",children:"LAST 50 LOG LINES"})]})}const Fae=Object.freeze(Object.defineProperty({__proto__:null,CrashLogHeader:s5},Symbol.toStringTag,{value:"Module"}));function r5({logs:e}){return t.jsx("div",{className:"flex-1 bg-black p-4 font-mono text-[11px] leading-relaxed overflow-y-auto text-gray-300",children:e.length>0?e.map((n,s)=>t.jsx("div",{className:"whitespace-pre-wrap break-all border-l-2 border-gray-800 pl-3 mb-1",children:n},s)):t.jsx("div",{className:"italic text-gray-600",children:"No logs captured..."})})}const zae=Object.freeze(Object.defineProperty({__proto__:null,CrashLogViewer:r5},Symbol.toStringTag,{value:"Module"}));function a5({providerLabel:e}){return t.jsxs("div",{className:"flex-1",children:[t.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."}),t.jsxs("p",{className:"text-xs text-red-700/80 dark:text-red-400/80",children:["Copy the logs and share them with ",e," to investigate the underlying bug."]})]})}const Bae=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooterMessage:a5},Symbol.toStringTag,{value:"Module"}));function o5({logs:e,copyWriter:n,providerLabel:s}){return t.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-950/30 border-t border-red-100 dark:border-red-900/50",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsx(a5,{providerLabel:s}),t.jsx(mt,{text:e.join(`
|
|
316
|
-
`),label:"Copy logs",writer:n})]})})}const Wae=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooter:o5},Symbol.toStringTag,{value:"Module"}));function i5({logs:e,providerLabel:n}){return t.jsxs("div",{className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[t.jsx(s5,{}),t.jsx(r5,{logs:e}),t.jsx(o5,{logs:e,providerLabel:n})]})}const Hae=Object.freeze(Object.defineProperty({__proto__:null,DevServerCrashLog:i5},Symbol.toStringTag,{value:"Module"})),ig=20;function E9(e){if(!e)return null;try{return new Date(e).toLocaleTimeString()}catch{return null}}function l5({lastError:e,failureCount:n,failedAtMs:s,holder:r,onRetry:a,onReap:o}){const[i,c]=l.useState(!1),d=e.split(`
|
|
317
|
-
`),u=d.length>ig,p=i||!u?d:d.slice(d.length-ig),h=E9(s);return t.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:[t.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[t.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"]}),h&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["Last attempt: ",h]}),r&&t.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:[t.jsxs("div",{children:["Port ",t.jsx("span",{className:"font-semibold",children:r.port})," is held by:"]}),t.jsxs("div",{className:"mt-1 font-mono",children:["PID ",r.pid," — ",r.command]})]})]}),t.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:p.join(`
|
|
318
|
-
`)}),t.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?t.jsx("button",{type:"button",onClick:()=>c(f=>!f),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`}):t.jsx("span",{}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(mt,{variant:"subtle",text:e,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&&t.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"}),t.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 qae=Object.freeze(Object.defineProperty({__proto__:null,DevServerFailedPanel:l5},Symbol.toStringTag,{value:"Module"}));function c5({diagnostic:e,onRetry:n}){const{expectedPort:s,actualPort:r,appName:a,currentStartCommand:o,remediation:i}=e;return t.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:[t.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Dev server port conflict"}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[a," bound port"," ",t.jsx("span",{className:"font-semibold",children:r}),", but the editor needs the app on port"," ",t.jsx("span",{className:"font-semibold",children:s})," so its reverse proxy (mocking, capture) can sit in front."]})]}),t.jsxs("div",{className:"flex-1 px-6 py-4 text-sm text-gray-800 dark:text-gray-200 space-y-3",children:[t.jsx("p",{children:i}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Current start command"}),t.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)"})]})]}),t.jsx("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-end",children:t.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 Uae=Object.freeze(Object.defineProperty({__proto__:null,PreviewPortMismatchCard:c5},Symbol.toStringTag,{value:"Module"})),lg=48,A9=100,M9=320,I9=192;function D9({containerHeight:e,containerWidth:n,viewportHeight:s,viewportWidth:r}){if(!(r!=null&&s!=null&&n!=null&&e!=null&&r>0&&s>0&&n>0&&e>0))return{width:M9,height:I9,hasViewport:!1};const o=n-lg*2,i=e-lg*2-A9,c=Math.min(1,o/r,i/s);return{width:Math.round(r*c),height:Math.round(s*c),hasViewport:!0}}function Yc({containerHeight:e,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:p,hasViewport:h}=D9({containerWidth:n,containerHeight:e,viewportWidth:d,viewportHeight:c}),f={width:u,height:p,...h?{overflowY:"auto"}:{}};return t.jsxs("div",{"data-testid":"building-preview-overlay",className:"absolute inset-0 z-50 flex flex-col overflow-y-auto animate-in fade-in duration-300",style:{background:"rgba(20,20,20,.94)"},children:[t.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",title:"Close preview",className:"sticky top-3 z-10 ml-auto mr-3 mt-3 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-white/[0.14] bg-[#1e1e1e] text-[var(--text-secondary)] transition-colors hover:border-white/[0.3] hover:text-[var(--text-primary)]",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})}),t.jsxs("div",{className:"my-auto flex flex-col items-center space-y-4 text-center p-6",children:[t.jsx("div",{className:"rounded-lg overflow-hidden border border-white/[0.1] shadow-md",style:f,children:t.jsx(Ot,{screenshotPath:o??void 0,alt:a??"Scenario preview",className:h?"w-full h-auto":"max-w-full max-h-full object-contain"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-[15px] font-semibold text-[var(--text-primary)]",children:s}),t.jsx("p",{className:"text-[13px] text-[var(--text-muted)]",children:i})]}),t.jsx("button",{type:"button",onClick:r,className:"rounded-lg border border-white/[0.14] px-4 py-1.5 text-[12.5px] text-[var(--text-secondary)] transition-colors hover:border-white/[0.3] hover:text-[var(--text-primary)]",children:"Dismiss"})]})]})}const Gae=Object.freeze(Object.defineProperty({__proto__:null,BuildingPreviewOverlay:Yc},Symbol.toStringTag,{value:"Module"}));function d5({isActive:e,onToggle:n,interactionAvailable:s=!0}){return t.jsx("button",{onClick:s?n:void 0,disabled:!s,title:s?e?"Exit Debug Mode (resumes paused animations)":"Debug Mode — pauses animations while you inspect":"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:e?"2px solid var(--accent-blue)":"1px solid var(--border-default)",background:e?"var(--accent-blue)":"var(--bg-surface)",color:e?"#000":"var(--text-secondary)",cursor:s?"pointer":"not-allowed",display:"none",alignItems:"center",justifyContent:"center",opacity:s?e?1:.6:.35,transition:"all 0.15s ease",fontSize:18},onMouseEnter:r=>{s&&(r.currentTarget.style.opacity="1")},onMouseLeave:r=>{s&&(e||(r.currentTarget.style.opacity="0.6"))},children:e?"✕":"🔍"})}const Yae=Object.freeze(Object.defineProperty({__proto__:null,DebugModeButton:d5},Symbol.toStringTag,{value:"Module"}));function L9(){const[e,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:e,clearError:r}}function u5({tag:e,id:n,className:s,text:r,detectionMethod:a,previewUrl:o}){return t.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[t.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:t.jsxs("div",{style:{color:"var(--text-secondary)",fontSize:12},children:[t.jsxs("div",{className:"text-center",style:{color:"var(--text-secondary)"},children:["Preview: ",o.split("/").pop()]}),t.jsxs("div",{className:"mt-2 p-3 rounded",style:{background:"var(--bg-surface)",border:"1px dashed var(--border-default)",fontSize:11,fontFamily:"monospace"},children:["<",e,n?` id="${n}"`:"",s?` class="${s.slice(0,40)}"`:"",">",t.jsx("br",{}),r.slice(0,60),r.length>60?"...":""]})]})}),t.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)"},children:["Detected via: ",a]})]})}const Vae=Object.freeze(Object.defineProperty({__proto__:null,DebugModalElementPreview:u5},Symbol.toStringTag,{value:"Module"}));function p5({ancestors:e,onOpenInEditor:n}){return e.length===0?t.jsx("div",{style:{color:"var(--text-secondary)",fontSize:12,fontStyle:"italic"},children:"No component ancestry available."}):t.jsx("ul",{className:"flex flex-col gap-1",style:{listStyle:"none",padding:0,margin:0},children:e.map((s,r)=>{const a=s.sourceFile&&s.lineNumber?`${s.sourceFile}:${s.lineNumber}`:s.sourceFile??"(unknown source)",o=!!s.sourceFile;return t.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{background:"var(--bg-deep)"},children:[t.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontSize:12},children:s.componentName??"<anonymous>"}),t.jsx("span",{style:{color:"var(--text-secondary)",fontFamily:"monospace",fontSize:11,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),o&&t.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 Kae=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestryList:p5},Symbol.toStringTag,{value:"Module"}));function h5({ancestors:e,onOpenInEditor:n}){const[s,r]=l.useState(e.length>1);return e.length===0?null:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.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 (",e.length,")"]}),s&&t.jsx(p5,{ancestors:e,onOpenInEditor:n})]})}const Jae=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestrySection:h5},Symbol.toStringTag,{value:"Module"}));function f5({propsNames:e}){if(e.length===0)return null;const n=()=>{var s;(s=navigator.clipboard)==null||s.writeText(e.join(", "))};return t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:12},children:"props:"}),e.map(s=>t.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 Xae=Object.freeze(Object.defineProperty({__proto__:null,DebugPropsChips:f5},Symbol.toStringTag,{value:"Module"}));function m5({componentDisplay:e,sourceDisplay:n,tag:s,id:r,boundingBox:a,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:d,ancestors:u,propsNames:p,onOpenInEditor:h,onGoToIsolated:f,onCreatePlan:m,onClose:g}){const x=c||!o.trim();return t.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[t.jsx("h3",{style:{color:"var(--text-primary)",fontSize:16,fontWeight:600,margin:0},children:e}),n&&t.jsx("div",{className:"px-2 py-1 rounded",style:{background:"var(--bg-deep)",fontSize:12,fontFamily:"monospace",color:"var(--accent-blue)"},children:n}),t.jsxs("div",{className:"flex flex-col gap-1",style:{color:"var(--text-secondary)",fontSize:12},children:[t.jsxs("div",{children:["Element: <",s,">",r?` #${r}`:""]}),t.jsxs("div",{children:["Position: ",Math.round(a.x),", ",Math.round(a.y)," (",Math.round(a.width),"x",Math.round(a.height),")"]})]}),t.jsx(f5,{propsNames:p}),t.jsx(h5,{ancestors:u,onOpenInEditor:h}),t.jsx("textarea",{value:o,onChange:b=>i(b.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"}}),t.jsxs("div",{className:"flex gap-2",children:[d&&t.jsx("button",{onClick:f,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"}),t.jsx("button",{onClick:m,disabled:x,className:"px-3 py-1.5 rounded text-sm flex-1",style:{background:x?"var(--bg-deep)":"var(--accent-blue)",border:"none",color:x?"var(--text-secondary)":"#000",cursor:x?"not-allowed":"pointer",fontWeight:600},children:c?"Creating...":"Create Fix Plan"}),t.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 Qae=Object.freeze(Object.defineProperty({__proto__:null,DebugModalInfoPanel:m5},Symbol.toStringTag,{value:"Module"}));function g5({error:e,onDismiss:n}){return t.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:[t.jsxs("div",{children:["Open in editor failed: ",e.message]}),e.command&&t.jsx("div",{style:{fontFamily:"monospace",fontSize:11,marginTop:4},children:e.command}),t.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 Zae=Object.freeze(Object.defineProperty({__proto__:null,OpenInEditorErrorToast:g5},Symbol.toStringTag,{value:"Module"}));function x5({element:e,previewUrl:n,onClose:s,onGoToIsolated:r,onCreatePlan:a}){const[o,i]=l.useState(""),[c,d]=l.useState(!1),{openInEditor:u,lastError:p,clearError:h}=L9(),f=async()=>{d(!0);try{await a(o,e)}finally{d(!1)}},m=e.componentName??`<${e.element.tag}>`,g=e.sourceFile?`${e.sourceFile}${e.lineNumber?`:${e.lineNumber}`:""}`:null;return t.jsxs("div",{className:"absolute inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.7)"},onClick:s,children:[t.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:x=>x.stopPropagation(),children:[t.jsx(u5,{tag:e.element.tag,id:e.element.id,className:e.element.className,text:e.element.text,detectionMethod:e.detectionMethod,previewUrl:n}),t.jsx(m5,{componentDisplay:m,sourceDisplay:g,tag:e.element.tag,id:e.element.id,boundingBox:e.element.boundingBox,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:!!e.componentName,ancestors:e.ancestors,propsNames:e.propsNames,onOpenInEditor:u,onGoToIsolated:()=>r(e.componentName),onCreatePlan:f,onClose:s})]}),p&&t.jsx(g5,{error:p,onDismiss:h})]})}const eoe=Object.freeze(Object.defineProperty({__proto__:null,DebugModal:x5},Symbol.toStringTag,{value:"Module"}));function b5(){return t.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:"Animations paused while inspecting"})}const toe=Object.freeze(Object.defineProperty({__proto__:null,DebugFreezePill:b5},Symbol.toStringTag,{value:"Module"}));function y5({hoveredElement:e,frozen:n}){return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute inset-0 z-40",style:{border:"3px solid var(--accent-blue)",cursor:"crosshair",pointerEvents:"none"}}),e&&t.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:e.componentName??`<${e.element.tag}>`}),n&&t.jsx(b5,{})]})}const noe=Object.freeze(Object.defineProperty({__proto__:null,DebugOverlay:y5},Symbol.toStringTag,{value:"Module"}));function v5(){return t.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:t.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 soe=Object.freeze(Object.defineProperty({__proto__:null,InspectModeRibbon:v5},Symbol.toStringTag,{value:"Module"}));function $9(e,n,s){const{width:r,maxHeight:a,gap:o}=s,i=e.y+e.height+o,c=i+a>n.height,d=c?Math.max(o,e.y-a-o):i,u=Math.max(o,Math.min(e.x,n.width-r-o));return{top:d,left:u,placedAbove:c}}function j5({onDismiss:e}){return t.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:999998,background:"transparent"}})}const roe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBackdrop:j5},Symbol.toStringTag,{value:"Module"}));function w5({match:e,onOpen:n}){return t.jsxs("button",{onClick:()=>n(e),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:[t.jsx("div",{style:{fontWeight:600},children:e.endpoint}),t.jsx("div",{style:{opacity:.85},children:e.jsonPath})]})}const aoe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchButton:w5},Symbol.toStringTag,{value:"Module"}));function _5({matches:e,onOpen:n}){return t.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},children:e.map((s,r)=>t.jsx("li",{children:t.jsx(w5,{match:s,onOpen:n})},`${s.endpoint}${s.jsonPath}${r}`))})}const ooe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchList:_5},Symbol.toStringTag,{value:"Module"}));function S5({clickedText:e,matches:n,corpusEmpty:s,onOpenInPanel:r}){return t.jsxs("div",{style:{padding:"8px 12px"},children:[t.jsxs("div",{style:{opacity:.7,marginBottom:6,wordBreak:"break-all"},children:["Clicked: ",t.jsx("code",{children:k5(e,120)||"(empty)"})]}),s?t.jsx("div",{style:{opacity:.85},children:"No mocks were consumed on this page load yet."}):n.length===0?t.jsx("div",{style:{opacity:.85},children:"No direct mock value matches — this value may be computed or concatenated."}):t.jsx(_5,{matches:n,onOpen:r})]})}function k5(e,n){return e.length<=n?e:e.slice(0,n-1)+"…"}const ioe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBody:S5,truncate:k5},Symbol.toStringTag,{value:"Module"}));function N5({onDismiss:e}){return t.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--border-muted, #374151)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontWeight:600},children:"Data source"}),t.jsx("button",{onClick:e,"aria-label":"Dismiss",style:{background:"transparent",color:"inherit",border:"none",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}const loe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardHeader:N5},Symbol.toStringTag,{value:"Module"})),cg=320,dg=320,F9=8;function C5({clickedText:e,matches:n,anchor:s,onOpenInPanel:r,onDismiss:a,corpusEmpty:o}){l.useEffect(()=>{function p(h){h.key==="Escape"&&a()}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[a]);const i=typeof window<"u"?window.innerHeight:800,c=typeof window<"u"?window.innerWidth:1200,{top:d,left:u}=$9(s,{width:c,height:i},{width:cg,maxHeight:dg,gap:F9});return t.jsxs(t.Fragment,{children:[t.jsx(j5,{onDismiss:a}),t.jsxs("div",{style:{position:"fixed",top:d,left:u,width:cg,maxHeight:dg,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:[t.jsx(N5,{onDismiss:a}),t.jsx(S5,{clickedText:e,matches:n,corpusEmpty:o,onOpenInPanel:r})]})]})}const coe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCard:C5},Symbol.toStringTag,{value:"Module"}));function T5({healthy:e,reason:n,authNeeded:s}){const r=s?"auth-needed":e===!0?"healthy":e===!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 t.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:[t.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:o.dot,boxShadow:r==="healthy"?`0 0 6px ${o.dot}`:void 0}}),t.jsx("span",{children:o.label})]})}const doe=Object.freeze(Object.defineProperty({__proto__:null,LiveIframeHealthPill:T5},Symbol.toStringTag,{value:"Module"})),z9=new Set(["localhost","127.0.0.1","[::1]","::1"]);function ug(e){if(!e)return!1;try{return!z9.has(new URL(e).hostname)}catch{return!1}}function P5(e,n,s){if(e===!1)return"local";const r=typeof window<"u"?window.location.origin:null;return ug(n)||ug(r)?"hosted":"tunnel"}function B9(e,n,s,r){return/^https?:\/\//i.test(s??"")?!0:P5(e,n)==="local"}function O5(e,n){switch(e){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 R5({hint:e,onRecheck:n}){const{inContainer:s,reachableUrl:r}=Co(),a=P5(s,r),{heading:o,showForwardFlag:i}=O5(a,e.port),{phase:c,attempts:d,retry:u}=Pg(n),p=a==="local"?`This app does its own page routing, so its preview is served on its own address — port ${e.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 ${e.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 ${e.port}. Your connection to this machine only carries the editor's port, so your browser can't reach that one.`,h=Gd(r,a==="hosted"),f=h?`A preview address for this machine already exists and is answering: ${h}. Point the preview at it with: ${io(h)} — 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.",m=a==="local"?"Start your app's server, then reload the preview.":a==="hosted"?f:`Add ${e.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 t.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center p-8",style:{background:"var(--bg-surface)"},children:t.jsx(Bt,{severity:"blocked",testId:"preview-forward-port-notice",headline:o,explanation:p,nextAction:m,diagnostics:i?e.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"?t.jsxs("span",{"data-testid":"preview-forward-port-notice-unchanged",children:["Checked just now — port ",e.port," still isn’t reachable",d>1?` (${d} tries)`:"","."]}):null})})}const uoe=Object.freeze(Object.defineProperty({__proto__:null,PreviewForwardPortNotice:R5,forwardPortNoticeCopy:O5},Symbol.toStringTag,{value:"Module"}));function E5(e){if(!e)return null;let n;try{n=new URL(e)}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}`}}async function W9(e,n,s){if(lu(e))return"unknown";const r=e,a=q9(r,s);try{await fetch(a,{credentials:"include",mode:"no-cors",redirect:"follow"})}catch{return E5(r)?"unreachable":"unknown"}try{return(await fetch(a,{credentials:"include",mode:"cors",redirect:"manual"})).type==="opaqueredirect"?"needs-signin":"authed"}catch{return"unknown"}}const H9="_cb";function q9(e,n){if(!n)return e;try{const s=new URL(n,e);return s.origin!==new URL(e).origin?e:(s.searchParams.delete(H9),s.href)}catch{return e}}const U9=Symbol("unsent");function G9(e,n){const[s,r]=l.useState("unknown"),[a,o]=l.useState(0),[i,c]=l.useState("idle"),[d,u]=l.useState(0),p=l.useRef(U9),h=l.useCallback(async()=>{const m=await W9(e,void 0,n);if(r(x=>(x==="needs-signin"&&m==="authed"&&o(b=>b+1),m)),lu(e))return;const g=m==="needs-signin"?e??null:null;g!==p.current&&!Zt()&&(p.current=g,jW(g))},[e,n]);l.useEffect(()=>{h()},[h]);const f=l.useCallback(()=>{c("pending"),u(m=>m+1),h().finally(()=>c("unchanged"))},[h]);return{authState:s,recheck:f,remountNonce:a,recheckPhase:i,recheckAttempts:d}}function pg(e,n){if(!n||!/^https?:\/\//i.test(e))return null;try{const s=new URL(e).origin;return s===new URL(n).origin?s:null}catch{return null}}function Y9(e,n,s){return new Promise(r=>{const a=new Image,o=setTimeout(()=>i(!1),s);function i(c){clearTimeout(o),a.onload=null,a.onerror=null,r(c)}a.onload=()=>i(!0),a.onerror=()=>i(!1),a.src=`${e}${n}?_=${Date.now()}`})}function V9(e,n,s){const r=new URL(e),a=`${r.pathname}${r.search}${r.hash}`;return`${r.origin}${n}?t=${encodeURIComponent(s)}&next=${encodeURIComponent(a)}`}const wo=new Map,A5="codeyam.previewHandoffRouted:",K9=3e3;function Vc(e){const n=wo.get(e);if(n!==void 0)return n;try{if(sessionStorage.getItem(A5+e)==="1")return!0}catch{}}function J9(e,n){if(wo.set(e,n),!!n)try{sessionStorage.setItem(A5+e,"1")}catch{}}function X9(e){wo.get(e)===!1&&wo.delete(e)}function Q9(e,n,s){const r=Vc(e);return r!==void 0?Promise.resolve(r):(s??((o,i)=>Y9(o,i,K9)))(e,n).catch(()=>!1).then(o=>(J9(e,o),o))}const M5="codeyam:preview-session-request",I5="codeyam:preview-session-result",Z9=1e4;function eq(e){if(typeof e!="object"||e===null)return null;const n=e;return n.type!==I5?null:n.outcome==="handed-off"||n.outcome==="route-unwired"||n.outcome==="failed"?n.outcome:null}function tq(e){return typeof e=="object"&&e!==null&&e.type===M5}function D5(e=window){try{return e.self!==e.top}catch{return!0}}let _o="idle";const Kc=new Set;function ul(e){if(_o!==e){_o=e;for(const n of Kc)n()}}const hg={get:()=>_o,subscribe:e=>(Kc.add(e),()=>{Kc.delete(e)})};let fg=!1,os=null;function nq(e=window){D5(e)&&(fg||(fg=!0,e.addEventListener("message",n=>{if(n.source!==e.parent)return;const s=eq(n.data);s!==null&&(os&&clearTimeout(os),os=null,ul(s))})),ul("pending"),os&&clearTimeout(os),os=setTimeout(()=>{os=null,_o==="pending"&&ul("failed")},Z9),e.parent.postMessage({type:M5},"*"))}function sq(e){const n=/^vm-(\d+)\./.exec(e);return n?Number(n[1]):null}const pl=new Set,rq="/api/preview-session-handoff";function aq(e,n,s,r={}){const{probePath:a,probe:o}=r,i=!!(o||a),c=s?pg(e,n):null,d=c!==null&&!pl.has(c)&&!(i&&Vc(c)===!1),[u,p]=l.useState(null),[h,f]=l.useState(!1),[m,g]=l.useState(0),x=l.useRef(e);x.current=e;const b=l.useRef(o);b.current=o;const y=l.useRef(null),v=_=>{const S=y.current;if(y.current=null,!!S)try{S.source.postMessage({type:I5,outcome:_},S.origin)}catch{}},j=l.useRef(v);return j.current=v,l.useEffect(()=>{if(!c||!s)return;const _=S=>{S.origin!==c||!S.source||tq(S.data)&&(y.current={source:S.source,origin:c},pl.delete(c),X9(c),p(null),f(!1),g(w=>w+1))};return window.addEventListener("message",_),()=>window.removeEventListener("message",_)},[c,s]),l.useEffect(()=>{if(!c||!s)return;if(!d){y.current&&Vc(c)===!1&&j.current("route-unwired");return}let _=!1;return(i?Q9(c,a??"",b.current):Promise.resolve(!0)).then(w=>{if(!_){if(!w){f(!0),j.current("route-unwired");return}return fetch(rq,{method:"POST"}).then(k=>k.ok?k.json():Promise.reject(k.status)).then(k=>{if(_)return;const N=x.current;if(!k.token||pg(N,n)!==c){f(!0),j.current("failed");return}pl.add(c),p({url:N,src:V9(N,s,k.token)}),j.current("handed-off")})}}).catch(()=>{_||(f(!0),j.current("failed"))}),()=>{_=!0}},[d,c,s,n,i,a,m]),u&&u.url===e?u.src:!d||h?e:"about:blank"}function mg(e){if(!e||typeof e!="object")return null;const n=e;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 oq(e){const[n,s]=l.useState(!1),[r,a]=l.useState(!1),[o,i]=l.useState(null),[c,d]=l.useState(null),u=l.useCallback(g=>{const x=e.current;x!=null&&x.contentWindow&&x.contentWindow.postMessage({type:g},"*")},[e]),p=l.useCallback(()=>{s(!0),i(null),d(null),u("codeyam:debug:activate")},[u]),h=l.useCallback(()=>{s(!1),i(null),d(null),u("codeyam:debug:deactivate")},[u]),f=l.useCallback(()=>{d(null)},[]);l.useEffect(()=>{function g(x){var b;!x.data||typeof x.data.type!="string"||(x.data.type==="codeyam:debug:hover"?i(mg(x.data.payload)):x.data.type==="codeyam:debug:selected"?d(mg(x.data.payload)):x.data.type==="codeyam:debug:state"&&a(((b=x.data.payload)==null?void 0:b.frozen)===!0))}return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[]);const m=l.useCallback(()=>{s(!1),a(!1),i(null),d(null)},[]);return l.useEffect(()=>{vW(r)},[r]),{isActive:n,frozen:r,hoveredElement:o,selectedElement:c,activate:p,deactivate:h,clearSelection:f,notifyIframeLoaded:m}}const iq=/^\/api\/mock-panel(\/.*)?$/;function lq(e,n){return e.toUpperCase()!=="GET"?!1:iq.test(n)}function cq(e){return Array.isArray(e)?e.filter(n=>n.consumedThisPageLoad&&!lq(n.method,n.pathPattern)).map(n=>({endpoint:`${n.method} ${n.pathPattern}`,body:n.body})):[]}async function dq(e,n,s){return(await fetch("/api/debug/create-plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:e,componentName:n.componentName,sourceFile:n.sourceFile,lineNumber:n.lineNumber,detectionMethod:n.detectionMethod,element:n.element,previewUrl:s})})).json()}const uq=12;function pq(e,n,s){if(n.length===0)return[];const r=[];return Jc(e,n,s,"$",0,new Set,r),r}function hq(e,n){const s=[];for(const o of e)for(const i of pq(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 Jc(e,n,s,r,a,o,i){if(e==null)return;const c=typeof e;if(c==="string"||c==="number"||c==="boolean"){String(e)===n&&i.push({endpoint:s,jsonPath:r,matchedValue:String(e),pathDepth:a});return}if(!(a>=uq)&&!o.has(e)){if(o.add(e),Array.isArray(e))for(let d=0;d<e.length;d++)Jc(e[d],n,s,`${r}[${d}]`,a+1,o,i);else if(c==="object")for(const[d,u]of Object.entries(e))Jc(u,n,s,`${r}.${d}`,a+1,o,i);o.delete(e)}}function L5({providerLabel:e,buildingScenarioName:n,buildingScenarioSlug:s,buildingScenarioDescription:r,buildingScreenshotPath:a,containerHeight:o,containerRef:i,containerWidth:c,currentHeight:d,currentWidth:u,emptyStateMessage:p,isFilled:h,onDismissBuildingOverlay:f,historicalScreenshotPath:m,historicalScenarioName:g,historicalHeading:x,historicalSubtext:b,onDismissHistoricalPreview:y,previewSlug:v,previewUrl:j,previewOrigin:_,previewSessionHandoff:S,previewSessionHandoffProbe:w,scale:k,commandNonce:N}){var En,pn;const C=!!g&&!s,T=!!s||C,P=l.useRef(null),R=i??P,L=l.useRef(null),{notePreviewLoaded:M}=Y7(L),{status:O,restart:z}=ZR();V7(O,z);const{isRestarting:I,isFailed:Y,isStarting:W,isStopped:A}=g9(O),{stepState:B}=ca(),D=w9((B==null?void 0:B.step)??null,(B==null?void 0:B.mode)??"ui"),J=(O==null?void 0:O.liveIframeHealthy)!==void 0,{reloadNonce:te,handleIframeLoad:oe,handleIframeError:se}=J7((O==null?void 0:O.pid)??null,J,O==null?void 0:O.status),G=(O==null?void 0:O.status)==="failed",{healthy:le,failedProbeCount:ue,reloadNonce:ne,invalidate:E}=n9(j,G),H=ic(O==null?void 0:O.liveIframeHealthy,750),U=l9(le,H),[pe,ge]=l.useState(0);l.useEffect(()=>eE(()=>{ge(qe=>qe+1)}),[]),d9(O==null?void 0:O.sourceVersion,O==null?void 0:O.liveReloadEnabled);const{authState:Me,recheck:Ce,remountNonce:De}=G9(_,j),Be=l.useMemo(()=>E5(_),[_]),X=c9({pidNonce:te,probeNonce:ne+U,draftNonce:pe+De}),Q=X.gatedNonce,{errors:re,clear:ce}=p9(L,Q),{escaped:_e,overlayErrors:Te,noteFrameLoad:Oe,clearEscape:he}=q7({previewUrl:j,resetKey:Q,capturedErrors:re}),xe=m9(j,Q),Fe=l.useCallback(()=>{X.reset(),ce(),he(),E()},[X,ce,he,E]),F=l.useCallback(()=>{ce(),he()},[ce,he]),ee=l.useCallback(()=>dd(),[]),de=(O==null?void 0:O.devServerStartedSecsAgo)??null,ie=de!==null&&de<x9,fe=!!(O!=null&&O.startCommand),ve=a9({liveIframeHealthy:H,previewReachable:(En=O==null?void 0:O.previewProbe)==null?void 0:En.reachable}),[be,We]=l.useState(!1);l.useEffect(()=>{ve&&!be&&We(!0)},[ve,be]);const ze=ve||be,Re=o9({hasDevServerConfigured:fe,hasServed:ze}),Ye=Re?j:"about:blank",rt=aq(Ye,_,S,{probePath:w}),je=qT(Ye,Q,N),[Ve,Se]=l.useState(null),Qe=Re&&Ve!==je;l.useEffect(()=>{Re&&M()},[je,Re,M]);const K=b9({hasDevServerConfigured:fe,probeHealthy:le,backendRunning:(O==null?void 0:O.status)==="running",backendIframeHealthy:H,isStarting:W,isRestarting:I,isFailed:Y,isStopped:A,isPrePrototype:D,withinStartupGrace:ie,previewReachable:((pn=O==null?void 0:O.previewProbe)==null?void 0:pn.reachable)===!0,hasEverServed:ze}),V=l.useRef(void 0);l.useEffect(()=>{var lt;if(V.current===K)return;const qe=V.current;V.current=K,console.debug(`[preview-overlay] ${qe===void 0?"(init)":qe??"none"} → ${K??"none"}`,{status:O==null?void 0:O.status,intendedRunning:O==null?void 0:O.intendedRunning,restartCount:O==null?void 0:O.restartCount,pid:O==null?void 0:O.pid,liveIframeHealthy:O==null?void 0:O.liveIframeHealthy,previewProbeReachable:(lt=O==null?void 0:O.previewProbe)==null?void 0:lt.reachable,devServerStartedSecsAgo:de,withinStartupGrace:ie,probeHealthy:le,isStarting:W,isRestarting:I,isFailed:Y,isStopped:A})},[K,O,de,ie,le,W,I,Y,A]);const we=O==null?void 0:O.portDiagnostic,Ue=(we==null?void 0:we.conflict)===!0,Ge=K==="scaffolding"?k9((B==null?void 0:B.step)??null,(B==null?void 0:B.mode)??"ui").body:void 0,gt=s9({active:K==="reconnecting",trigger:ue}),at=K==="reconnecting"?r9(gt):null,it=Ge??at??void 0,Je=ue>=10,{isActive:xt,frozen:He,hoveredElement:jt,selectedElement:q,activate:Ft,deactivate:Et,clearSelection:wt,notifyIframeLoaded:es}=oq(L),Pn=l.useCallback(()=>{xt?Et():Ft()},[xt,Ft,Et]),{entries:en}=tE(v??null),{isActive:Ct,toggle:ts}=K7({activate:Ft,deactivate:Et,clearSelection:wt},te);l.useEffect(()=>(Ih({isActive:Ct,previewSlug:v??null}),()=>{Ih({isActive:!1,previewSlug:null})}),[Ct,v]),l.useEffect(()=>nE(()=>{ts()}),[ts]);const On=Ct&&q?q.element.text.trim():"",Rn=l.useMemo(()=>cq(en),[en]),tn=l.useMemo(()=>!Ct||!On?[]:hq(Rn,On),[Ct,On,Rn]),nn=l.useCallback(async qe=>{wt(),Et();try{const Xe=await(await fetch("/api/scenarios")).json(),hn=Array.isArray(Xe)?Xe.find(fn=>fn.componentName===qe):null;if(hn!=null&&hn.slug){const fn=Lo(window.location),ns=vy(hn.slug,fn,null,0,_);window.history.pushState(null,"",ns);return}}catch{}window.history.pushState(null,"",`${ud()}/entities`)},[wt,Et,_]),At=l.useCallback(async(qe,lt)=>{try{await dq(qe,lt,j),wt(),Et()}catch(Xe){console.error("Failed to create debug plan:",Xe)}},[j,wt,Et]);return t.jsx("div",{ref:R,className:`relative flex-1 flex overflow-clip ${h?"":"items-center justify-center p-8"}`,style:h?{backgroundColor:"#fff"}:Hs,children:j?t.jsxs(t.Fragment,{children:[t.jsx(GT,{ref:L,currentHeight:d,currentWidth:u,isFilled:h,previewUrl:rt,scale:k,iframeKey:je,onLoad:()=>{if(Re){const qe=Oe(L.current);oe(qe??j),es(),Se(je),M()}},onError:se}),!Re&&t.jsx(HT,{hasDevServerConfigured:fe}),Qe&&t.jsx(YT,{}),!h&&t.jsx(n5,{previewUrl:j,description:r}),!h&&t.jsx(T5,{healthy:H,reason:(O==null?void 0:O.iframeLastError)??null,authNeeded:Me==="needs-signin"}),Me==="needs-signin"&&_&&t.jsx(Bj,{previewOrigin:_,onRecheck:Ce}),Me==="unreachable"&&Be&&t.jsx(R5,{hint:Be,onRecheck:Ce}),xt&&t.jsx(y5,{hoveredElement:jt,frozen:He}),Ct&&t.jsx(v5,{}),q&&!Ct&&t.jsx(x5,{element:q,previewUrl:j,onClose:wt,onGoToIsolated:nn,onCreatePlan:At}),q&&Ct&&t.jsx(C5,{clickedText:On,matches:tn,anchor:q.element.boundingBox,corpusEmpty:Rn.length===0,onOpenInPanel:qe=>{sE({routeKey:qe.endpoint,jsonPath:qe.jsonPath}),wt()},onDismiss:wt}),!T&&t.jsx(d5,{isActive:xt,onToggle:Pn,interactionAvailable:lu(_)}),G?t.jsx(l5,{lastError:(O==null?void 0:O.lastError)??(O==null?void 0:O.lastExit)??"(no error message captured)",failureCount:(O==null?void 0:O.failureCount)??0,failedAtMs:O==null?void 0:O.failedAtMs,holder:O==null?void 0:O.holder,onRetry:z,onReap:async()=>{await fetch("/api/editor-dev-server/reap",{method:"POST",headers:{"Content-Type":"application/json"}})}}):Ue&&we?t.jsx(c5,{diagnostic:we,onRetry:z}):K&&(K==="crashed"?t.jsx(i5,{logs:(O==null?void 0:O.logs)??[],providerLabel:e}):t.jsx(KT,{variant:K,restartCount:(O==null?void 0:O.restartCount)??0,showRetry:Je,onRetry:K==="disconnected"?ee:E,bodyOverride:it})),t.jsx(t5,{tripped:X.tripped||_e,errors:Te,recentReloads:X.recentReloads,serverHealthy:y9(O),onRetry:Fe,onClear:F,providerLabel:e}),xe.clickThroughBroken&&xe.status!==null&&t.jsx(VT,{url:j,status:xe.status,logLines:xe.logLines,onRetry:Fe}),s&&f&&t.jsx(Yc,{containerHeight:o,containerWidth:c,onDismiss:f,scenarioName:n??null,screenshotPath:a??null,viewportHeight:d,viewportWidth:u}),C&&y&&t.jsx(Yc,{containerHeight:o,containerWidth:c,heading:x??void 0,subtext:b??void 0,onDismiss:y,scenarioName:g??null,screenshotPath:m??null,viewportHeight:d,viewportWidth:u})]}):t.jsx(WT,{message:p})})}const poe=Object.freeze(Object.defineProperty({__proto__:null,PreviewCanvas:L5},Symbol.toStringTag,{value:"Module"}));function $5({status:e}){return t.jsx(ds,{title:"Setting up your project…",subtitle:"This usually takes a few minutes. The agent explains each step in the terminal on the left.",status:e})}const hoe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupHeader:$5},Symbol.toStringTag,{value:"Module"}));function F5({prompt:e,defaultExpanded:n=!1}){const[s,r]=l.useState(n);return t.jsxs("section",{"aria-label":"What you asked for",style:{borderTop:"1px solid rgba(255,255,255,.08)",paddingTop:14},children:[t.jsxs("button",{type:"button",onClick:()=>r(a=>!a),"aria-expanded":s,style:{width:"100%",background:"transparent",border:"none",padding:0,margin:0,color:"rgba(255,255,255,.45)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".08em",textTransform:"uppercase",textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{children:"What you asked for"}),t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",transition:"transform 150ms ease",transform:s?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),s?t.jsx("div",{style:{marginTop:10,color:"var(--text-secondary)",fontSize:13,lineHeight:1.55},children:t.jsx(Lt,{children:e})}):null]})}const foe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDescriptionCard:F5},Symbol.toStringTag,{value:"Module"}));function z5({html:e,viewport:n}){return t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".08em",textTransform:"uppercase",color:"rgba(255,255,255,.45)",marginBottom:10},children:"Your chosen design"}),t.jsx("div",{style:{borderRadius:10,overflow:"hidden",boxShadow:"0 0 0 1px rgba(255,255,255,.08)"},children:t.jsx(Kp,{html:e,url:"",title:"Chosen design",viewport:n,theme:"light",darkVars:null,slotAspect:yi[n]})})]})}const moe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupChosenMockup:z5},Symbol.toStringTag,{value:"Module"}));function B5({assets:e}){return t.jsxs("div",{children:[t.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Design assets you added"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},children:e.map(n=>t.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:[t.jsx("span",{style:{fontSize:"0.8125rem",fontWeight:500,color:"var(--text-primary)"},children:n.filename}),n.description.trim().length>0&&t.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:n.description})]},n.filename))})]})}const goe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignAssetList:B5},Symbol.toStringTag,{value:"Module"}));function W5({mockupHtml:e,mockupViewport:n,assets:s}){const r=e!==null,a=s.length>0;return!r&&!a?null:t.jsxs("section",{"aria-label":"Your chosen design",style:{border:"1px solid rgba(255,255,255,.1)",borderRadius:14,padding:14,background:"rgba(255,255,255,.03)",display:"flex",flexDirection:"column",gap:16,minWidth:0},children:[r&&t.jsx(z5,{html:e,viewport:n}),a&&t.jsx(B5,{assets:s})]})}const xoe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignCard:W5},Symbol.toStringTag,{value:"Module"}));function H5(e,n){if(e.phaseSteps.length===0)return"pending";const s=e.phaseSteps[0],r=e.phaseSteps[e.phaseSteps.length-1];return n>r?"complete":n>=s?"active":"pending"}const fq="var(--accent-active, #D7FF63)";function q5({status:e}){return e==="complete"?t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:[t.jsx("circle",{cx:"9",cy:"9",r:"8",fill:"#D7FF63"}),t.jsx("path",{d:"M5.5 9.2 L8 11.5 L12.5 6.5",fill:"none",stroke:"#111",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]}):e==="active"?t.jsx("span",{role:"img","aria-label":"In progress",style:{display:"inline-flex"},children:t.jsx(Wt,{size:18})}):t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:t.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:"rgba(255,255,255,.22)",strokeWidth:"1.5"})})}function U5({phase:e,status:n}){const s=n==="active";return t.jsxs("li",{"data-phase-id":e.phaseId,"data-phase-status":n,style:{display:"flex",alignItems:"center",gap:12,padding:s?"12px 14px":"8px 14px",borderRadius:12,border:`1px solid ${s?"rgba(215,255,99,.45)":"transparent"}`,background:s?"linear-gradient(180deg, rgba(215,255,99,.07), rgba(215,255,99,.02))":"transparent"},children:[t.jsx(q5,{status:n}),t.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[t.jsx("span",{style:{color:s?fq:n==="complete"?"var(--text-primary)":"rgba(255,255,255,.4)",fontSize:14,fontWeight:s?600:400},children:e.phaseLabel}),s?t.jsx("span",{style:{fontSize:12,color:"var(--text-muted)"},children:"Working on it…"}):null]})]})}const boe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressRow:U5,StatusIndicator:q5},Symbol.toStringTag,{value:"Module"}));function G5({currentStep:e,mode:n}){const s=Au(n),r=s.map(o=>H5(o,e)),a=r.filter(o=>o==="complete").length;return t.jsxs("section",{"aria-label":"Progress",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:10,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".08em",textTransform:"uppercase",color:"rgba(255,255,255,.4)"},children:["Progress",t.jsxs("span",{style:{marginLeft:"auto",letterSpacing:0,textTransform:"none"},children:[a," of ",s.length," done"]})]}),t.jsx("div",{"data-testid":"project-setup-pills",style:{display:"flex",gap:6,marginBottom:18},children:r.map((o,i)=>t.jsx("i",{"data-status":o,className:o==="active"?"animate-pulse":void 0,style:{flex:1,height:4,borderRadius:99,background:o==="pending"?"rgba(255,255,255,.1)":"var(--accent-active, #D7FF63)",transition:"background .3s"}},s[i].phaseId))}),t.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},children:s.map((o,i)=>t.jsx(U5,{phase:o,status:r[i]},o.phaseId))})]})}const yoe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressList:G5},Symbol.toStringTag,{value:"Module"})),gg=300;function Y5({tips:e}){const[n,s]=l.useState(0),[r,a]=l.useState(!0),o=i=>{a(!1),window.setTimeout(()=>{s((i%e.length+e.length)%e.length),a(!0)},gg)};return l.useEffect(()=>{if(e.length<2)return;const i=window.setInterval(()=>o(n+1),Jp);return()=>window.clearInterval(i)},[n,e.length]),t.jsxs("aside",{"aria-label":"Tip","data-testid":"session-tip-card",style:{display:"flex",flexDirection:"column",gap:8,padding:"14px 16px",borderRadius:12,border:"1px solid rgba(255,255,255,.09)",background:"rgba(255,255,255,.03)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".12em",textTransform:"uppercase",color:"var(--accent-active, #D7FF63)"},children:"Tip"}),e.length>1&&t.jsx("span",{style:{marginLeft:"auto",display:"flex",gap:4},children:e.map((i,c)=>t.jsx("button",{type:"button","aria-label":`Tip ${c+1} of ${e.length}`,"aria-current":c===n?"true":void 0,onClick:()=>c!==n&&o(c),style:{width:c===n?14:5,height:5,padding:0,border:"none",borderRadius:99,cursor:"pointer",background:c===n?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.18)",transition:"width .2s, background .2s"}},c))})]}),t.jsx("p",{"data-testid":"session-tip","aria-live":"polite",style:{margin:0,fontSize:14,lineHeight:1.5,minHeight:"3em",color:"var(--text-primary)",opacity:r?1:0,transition:`opacity ${gg}ms`},children:e[n%e.length]})]})}const voe=Object.freeze(Object.defineProperty({__proto__:null,SessionTipCard:Y5},Symbol.toStringTag,{value:"Module"}));function mq(e){let n=e;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(`
|
|
319
|
-
`)&&(n=n.slice(0,-1)),n}const V5=["The agent writes real code for your app, step by step, and checks its work as it goes.","You can type in the terminal on the left to ask the agent something while it works.","Every step is saved in History, so nothing gets lost.","Your chosen design becomes the app's colors, fonts and first screen."];function K5({prompt:e,currentStep:n,mode:s,mockupHtml:r=null,mockupViewport:a="desktop",assets:o=[]}){const i=r!==null||o.length>0,c=mq(e).trim(),d=t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,minWidth:0},children:[t.jsx(G5,{currentStep:n,mode:s}),t.jsx(Y5,{tips:V5}),c?t.jsx(F5,{prompt:c,defaultExpanded:!i}):null]});return t.jsxs("div",{"data-testid":"project-setup-view",style:{margin:"0 auto",maxWidth:i?1040:560,display:"grid",gridTemplateColumns:i?"repeat(auto-fit, minmax(300px, 1fr))":"1fr",gap:32,alignItems:"start"},children:[i?t.jsx(W5,{mockupHtml:r,mockupViewport:a,assets:o}):null,d]})}const joe=Object.freeze(Object.defineProperty({__proto__:null,BUILD_TIPS:V5,ProjectSetupPreviewView:K5},Symbol.toStringTag,{value:"Module"}));function gq(){const[e,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 p=await u.json();if(!p||typeof p.filename!="string"||!p.filename)return;const h=await fetch("/api/editor-design-selected-mockup");if(!h.ok)return;const f=await h.text();if(i||!f)return;n(f),r(Yp(f)??"desktop")}catch{}}async function d(){try{const u=await fetch("/api/editor-design-assets");if(!u.ok)return;const p=await u.json();!i&&Array.isArray(p.assets)&&o(p.assets)}catch{}}return c(),d(),()=>{i=!0}},[]),{mockupHtml:e,mockupViewport:s,assets:a}}function J5(){const{prompt:e}=zT(),{stepState:n}=ca(),{mockupHtml:s,mockupViewport:r,assets:a}=gq(),o=(n==null?void 0:n.step)??1,i=(n==null?void 0:n.mode)??"ui",c=Au(i),d=c.findIndex(u=>H5(u,o)==="active");return t.jsxs("div",{"data-testid":"project-setup-canvas",className:"flex-1 flex flex-col min-w-0",children:[t.jsx($5,{status:d>=0?`phase ${d+1} of ${c.length}`:void 0}),t.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"32px 24px 48px"},children:t.jsx(K5,{prompt:e??"",currentStep:o,mode:i,mockupHtml:s,mockupViewport:r,assets:a})})]})}const woe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewPane:J5},Symbol.toStringTag,{value:"Module"}));function xq(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-terminal`}function bq(e,n,s=1500){if(e<=0)return!1;const r=n-e;return r>=0&&r<=s}function X5({assistantTyping:e}){return t.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:[t.jsx("span",{children:"Shared terminal — you and the assistant both drive this shell."}),e&&t.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 _oe=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalHeader:X5},Symbol.toStringTag,{value:"Module"})),yq=1200,vq=1e3,jq=["\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
|
|
320
|
-
`);function Q5(){const e=Zt(),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),[p,h]=Zu(1200);function f(m){const g=a.current;(g==null?void 0:g.readyState)===WebSocket.OPEN&&g.send(new TextEncoder().encode(m))}return rd(n,()=>{if(r.current&&s.current){if(!Or(s.current,n.current))return;r.current.fit();const m=a.current;(m==null?void 0:m.readyState)===WebSocket.OPEN&&m.send(JSON.stringify({type:"resize",cols:s.current.cols,rows:s.current.rows}))}}),l.useEffect(()=>{if(e)return;let m=!1;const g=async()=>{try{const b=await fetch("/api/setup-terminal/activity");if(!b.ok)return;const y=await b.json();if(m)return;u(bq(y.lastInjectMs??0,Date.now()))}catch{}};g();const x=window.setInterval(g,vq);return()=>{m=!0,window.clearInterval(x)}},[e]),l.useEffect(()=>{if(!n.current||o.current)return;o.current=!0,i.current=!1;const m=new ad.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),g=new od.FitAddon;m.loadAddon(g),m.open(n.current),s.current=m,r.current=g;const x=id(m,n.current,{onCopy:()=>h()}),b=ld(m,{sendInput:f});if(requestAnimationFrame(()=>{Or(m,n.current)&&g.fit(),m.focus()}),e)return m.write(jq),u(!0),()=>{b(),x(),m.dispose(),o.current=!1};const y=()=>{if(i.current)return;const v=new WebSocket(xq());a.current=v,v.binaryType="arraybuffer",v.onmessage=j=>{j.data instanceof ArrayBuffer&&m.write(new Uint8Array(j.data))},v.onopen=()=>{v.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},v.onclose=()=>{i.current||(c.current=window.setTimeout(y,yq))}};return y(),m.onData(f),()=>{var v;i.current=!0,c.current!==null&&window.clearTimeout(c.current),(v=a.current)==null||v.close(),b(),x(),m.dispose(),o.current=!1}},[e]),t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[t.jsx(X5,{assistantTyping:d}),t.jsx("div",{ref:n,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var m;return(m=s.current)==null?void 0:m.focus()}}),p&&t.jsx(di,{})]})}const Soe=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalPane:Q5},Symbol.toStringTag,{value:"Module"}));function wq(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-browser`}function _q(e){let n;try{n=JSON.parse(e)}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 Sq(e){const n=e.paneWidth>0&&e.frameWidth>0?e.frameWidth/e.paneWidth:1,s=e.paneHeight>0&&e.frameHeight>0?e.frameHeight/e.paneHeight:1;return JSON.stringify({kind:"mouse",event:e.event,x:Math.round(e.paneX*n),y:Math.round(e.paneY*s),button:"left",clickCount:1})}function kq(e,n,s=1500){if(e<=0)return!1;const r=n-e;return r>=0&&r<=s}function cr(e,n){const s=`<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800" viewBox="0 0 1280 800">
|
|
321
|
-
<rect width="1280" height="800" fill="#0b0d12"/>
|
|
322
|
-
<rect width="1280" height="56" fill="#11141b"/>
|
|
323
|
-
<text x="28" y="35" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="20" font-weight="700">${n}</text>
|
|
324
|
-
${e}
|
|
325
|
-
</svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(s)}`}function Yt(e,n,s,r,a){return`
|
|
326
|
-
<text x="${e}" y="${n}" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">${r}</text>
|
|
327
|
-
<rect x="${e}" y="${n+10}" width="${s}" height="40" rx="6" fill="#171b24" stroke="#2a303c"/>
|
|
328
|
-
<text x="${e+14}" y="${n+36}" fill="#e7e9ee" font-family="ui-monospace, monospace" font-size="15">${a}</text>`}const Nq={hosting:cr(`
|
|
329
|
-
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="28" font-weight="700">Production Deployment</text>
|
|
330
|
-
<rect x="28" y="160" width="1224" height="120" rx="10" fill="#12161f" stroke="#232a36"/>
|
|
331
|
-
<circle cx="60" cy="220" r="8" fill="#3ecf8e"/>
|
|
332
|
-
<text x="82" y="212" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="17">my-app.vercel.app</text>
|
|
333
|
-
<text x="82" y="238" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">Ready · deployed 2m ago · main@a1b2c3d</text>
|
|
334
|
-
<rect x="28" y="320" width="360" height="44" rx="8" fill="#D7FF63"/>
|
|
335
|
-
<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:cr(`
|
|
336
|
-
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">DNS Records — codeyam.com</text>
|
|
337
|
-
${Yt(28,180,300,"Type","CNAME")}
|
|
338
|
-
${Yt(360,180,420,"Name","www")}
|
|
339
|
-
${Yt(812,180,440,"Value","cname.vercel-dns.com")}
|
|
340
|
-
${Yt(28,280,300,"Type","A")}
|
|
341
|
-
${Yt(360,280,420,"Name","@")}
|
|
342
|
-
${Yt(812,280,440,"Value","76.76.21.21")}
|
|
343
|
-
<rect x="28" y="380" width="220" height="44" rx="8" fill="#D7FF63"/>
|
|
344
|
-
<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:cr(`
|
|
345
|
-
<rect x="440" y="200" width="400" height="380" rx="14" fill="#12161f" stroke="#232a36"/>
|
|
346
|
-
<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>
|
|
347
|
-
${Yt(472,300,336,"Email","you@example.com")}
|
|
348
|
-
${Yt(472,380,336,"Password","••••••••••")}
|
|
349
|
-
<rect x="472" y="470" width="336" height="44" rx="8" fill="#4c7fff"/>
|
|
350
|
-
<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:cr(`
|
|
351
|
-
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">App Information</text>
|
|
352
|
-
${Yt(28,180,560,"Name","CodeYam")}
|
|
353
|
-
${Yt(620,180,632,"Subtitle","Build code and data scenarios together")}
|
|
354
|
-
${Yt(28,280,1224,"Promotional Text","See your app in every state, before you ship it.")}
|
|
355
|
-
<rect x="28" y="400" width="200" height="44" rx="8" fill="#4c7fff"/>
|
|
356
|
-
<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:cr(`
|
|
357
|
-
<rect x="0" y="56" width="1280" height="3" fill="#D7FF63"/>
|
|
358
|
-
<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")},Cq={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 Tq(e){return Nq[e]}function Pq(e){return Cq[e]}function Z5({address:e,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 t.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:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{children:"Shared setup browser — you and the assistant both control this window."}),n&&t.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…"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",style:i,onClick:s,title:"Back","aria-label":"Back",children:"‹"}),t.jsx("button",{type:"button",style:i,onClick:r,title:"Forward","aria-label":"Forward",children:"›"}),t.jsx("button",{type:"button",style:i,onClick:a,title:"Reload","aria-label":"Reload",children:"↻"}),t.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:e,children:e||"about:blank"}),t.jsx("button",{type:"button",style:i,onClick:o,title:"Stop","aria-label":"Stop",children:"✕"})]})]})}const koe=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserHeader:Z5},Symbol.toStringTag,{value:"Module"})),Oq=1200,Rq=1e3;function eP({demo:e="hosting",address:n,assistantNavigating:s,disconnected:r=!1}={}){const o=Zt()||s!==void 0||r,i=l.useRef(null),c=l.useRef(null),d=l.useRef(!1),u=l.useRef(null),p=l.useRef({width:0,height:0}),[h,f]=l.useState(o?Tq(e):null),[m,g]=l.useState(n??(o?Pq(e):"")),[x,b]=l.useState(s??!1),[y,v]=l.useState(!1);l.useEffect(()=>{if(o)return;let _=!1;const S=async()=>{try{const k=await fetch("/api/setup-browser/activity");if(!k.ok)return;const N=await k.json();if(_)return;b(kq(N.lastActMs??0,Date.now()))}catch{}};S();const w=window.setInterval(S,Rq);return()=>{_=!0,window.clearInterval(w)}},[o]),l.useEffect(()=>{if(o)return;d.current=!1;const _=()=>{if(d.current)return;const S=new WebSocket(wq());c.current=S,S.onopen=()=>v(!0),S.onmessage=w=>{if(typeof w.data!="string")return;const k=_q(w.data);k&&(p.current={width:k.width,height:k.height},f(k.src))},S.onclose=()=>{v(!1),!d.current&&(u.current=window.setTimeout(_,Oq))}};return _(),()=>{var S;d.current=!0,u.current!==null&&window.clearTimeout(u.current),(S=c.current)==null||S.close()}},[o]);function j(_,S){const w=c.current;if(!w||w.readyState!==WebSocket.OPEN)return;const k=S.currentTarget.getBoundingClientRect();w.send(Sq({event:_,paneX:S.clientX-k.left,paneY:S.clientY-k.top,paneWidth:k.width,paneHeight:k.height,frameWidth:p.current.width,frameHeight:p.current.height}))}return t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[t.jsx(Z5,{address:m,assistantNavigating:x,onReload:()=>g(m)}),t.jsx("div",{ref:i,className:"flex-1 flex items-center justify-center overflow-hidden",style:{background:"#0b0d12",minHeight:0},children:r?t.jsxs("div",{className:"flex flex-col items-center gap-3 text-center px-6",children:[t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:"The shared browser session was stopped."}),t.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"})]}):h?t.jsx("img",{src:h,alt:"Shared setup browser viewport",className:"max-w-full max-h-full",style:{objectFit:"contain"},draggable:!1,onMouseDown:_=>j("mousePressed",_),onMouseUp:_=>j("mouseReleased",_)}):t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:y?"Waiting for the first frame…":"Connecting to the shared browser…"})})]})}const Noe=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserPane:eP},Symbol.toStringTag,{value:"Module"}));function tP({onDismiss:e,previewOrigin:n}){const{inContainer:s,reachableUrl:r}=Co(),a=B9(s,r,n),o=Gd(r,!a),i=o?`A preview address for this machine already exists and is answering: ${o}. Point the preview at it with: ${io(o)} — it takes effect immediately, no restart needed.`:null;return t.jsx(Bt,{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?t.jsxs(t.Fragment,{children:["Set ",t.jsx("code",{children:"sameOriginSafe: false"})," in"," ",t.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?t.jsx(t.Fragment,{children:i}):t.jsx(t.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:e,variant:"secondary",ariaLabel:"Dismiss client-routing advisory",testId:"client-routing-advisory-dismiss"}]})}const Coe=Object.freeze(Object.defineProperty({__proto__:null,ClientRoutingAdvisory:tP},Symbol.toStringTag,{value:"Module"})),Eq="Seed failed — DB state is unknown",Aq="Preview capture failed — the app's data was seeded";function nP({error:e,kind:n,onRetry:s}){const r=n==="device"?Aq:Eq;return t.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:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-semibold",children:r}),t.jsx("div",{className:"truncate text-xs opacity-90",children:e})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(mt,{variant:"subtle",text:`${r}
|
|
359
|
-
${e}`,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?t.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 Toe=Object.freeze(Object.defineProperty({__proto__:null,SeedErrorBanner:nP},Symbol.toStringTag,{value:"Module"}));function sP({label:e="Loading scenario..."}={}){return t.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:e})}const Poe=Object.freeze(Object.defineProperty({__proto__:null,SeedLoadingOverlay:sP},Symbol.toStringTag,{value:"Module"}));function rP(e){return e.state==="preflight-running"||e.state==="booting-simulator"||e.state==="simulator-booted"||e.state==="building-app"}const Mq=1500;function aP({stackId:e,pollMs:n=Mq,onStateChange:s}={}){const[r,a]=l.useState({state:"idle"}),[o,i]=l.useState(!1),c=l.useRef(s);c.current=s,l.useEffect(()=>{let p=!1,h=!0;const f=async()=>{var g;try{const x=await fetch("/api/simulator-status");if(!x.ok)return;const b=await x.json();if(p||!h)return;const{history:y,...v}=b;a(v),(g=c.current)==null||g.call(c,v)}catch{}};f();const m=window.setInterval(f,n);return()=>{p=!0,h=!1,window.clearInterval(m)}},[n]);const d=l.useCallback(async()=>{if(!o){i(!0);try{const p=e?JSON.stringify({stack_id:e}):"{}";await fetch("/api/start-simulator",{method:"POST",headers:{"content-type":"application/json"},body:p})}finally{i(!1)}}},[e,o]),u=o||rP(r);return{status:r,posting:o,buttonDisabled:u,start:d}}function oP({stderrTail:e,onClose:n}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},onClick:n,children:t.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:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("strong",{children:"Build logs (stderr tail)"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(mt,{variant:"subtle",text:e,label:"Copy"}),t.jsx("button",{type:"button",onClick:n,className:"opacity-70 hover:opacity-100",children:"✕"})]})]}),t.jsx("pre",{className:"whitespace-pre-wrap",children:e||"(no stderr captured)"})]})})}const Ooe=Object.freeze(Object.defineProperty({__proto__:null,BuildLogsModal:oP},Symbol.toStringTag,{value:"Module"}));function Xc({stackId:e,pollMs:n,onStateChange:s}){const[r,a]=l.useState(!1),{status:o,start:i,buttonDisabled:c}=aP({stackId:e,pollMs:n,onStateChange:s}),d=o.state==="app-launched";return t.jsxs("div",{className:"flex items-center gap-3 text-sm",style:{color:"var(--text-primary)"},children:[t.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"}),t.jsx(iP,{status:o}),o.state==="build-failed"?t.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"?t.jsx(oP,{stderrTail:o.stderrTail,onClose:()=>a(!1)}):null]})}function iP({status:e}){const n=Xp(e);return t.jsx("span",{className:"text-xs opacity-80","data-testid":"simulator-status-pill",children:n})}function Xp(e){switch(e.state){case"idle":return"No simulator running";case"preflight-running":return"Pre-flight checks…";case"preflight-failed":return`Pre-flight failed: ${e.check} — ${e.message}`;case"booting-simulator":return`Booting ${e.device}…`;case"simulator-booted":return`Simulator booted (${e.name})`;case"building-app":return`Building (${lP(e.elapsedSec)})…`;case"build-failed":return"Build failed";case"app-launched":return`App running ▸${e.appBundleId!=="com.codeyam.android"?" (host proxy active)":""}`;case"stopped":return e.reason.kind==="user-requested"?"Stopped":e.reason.kind==="editor-server-shutdown"?"Editor server shut down":e.reason.code!=null?`Stopped (exit ${e.reason.code})`:"Stopped"}}function lP(e){if(e<60)return`${e}s`;const n=Math.floor(e/60),s=e%60;return`${n}m ${s.toString().padStart(2,"0")}s`}const Roe=Object.freeze(Object.defineProperty({__proto__:null,SimulatorLauncherControls:Xc,StatusPill:iP,formatElapsed:lP,pillText:Xp},Symbol.toStringTag,{value:"Module"}));function cP({stackId:e,pollMs:n,onStateChange:s}){const{status:r,start:a,buttonDisabled:o}=aP({stackId:e,pollMs:n,onStateChange:s}),i=rP(r);return t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full px-6 text-center",style:{color:"var(--text-primary)"},children:[t.jsx("div",{className:"text-3xl","aria-hidden":"true",children:"📱"}),t.jsx("div",{className:"text-sm font-medium",children:"No simulator running yet"}),t.jsx("div",{className:"text-xs opacity-70",children:i?Xp(r):"Start it to preview this scenario on device."}),t.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 Eoe=Object.freeze(Object.defineProperty({__proto__:null,SimulatorNotBootedPrompt:cP},Symbol.toStringTag,{value:"Module"}));function Ka({src:e,currentHeight:n,currentWidth:s,isFilled:r,scale:a}){return r?t.jsx("img",{src:e,alt:"Simulator / Emulator preview",className:"w-full h-full object-contain",style:{background:"var(--bg-deep)"}}):t.jsx(Vr,{width:s,height:n,scale:a,children:t.jsx("img",{src:e,alt:"Simulator / Emulator preview",style:{width:"100%",height:"100%",background:"var(--bg-deep)",objectFit:"contain"}})})}const Aoe=Object.freeze(Object.defineProperty({__proto__:null,DeviceFrameImage:Ka},Symbol.toStringTag,{value:"Module"}));function So({currentWidth:e,currentHeight:n,isFilled:s,scale:r,title:a,hint:o}){const i=t.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:t.jsxs("div",{className:"text-sm leading-relaxed",children:[t.jsx("div",{className:"font-medium",children:a}),t.jsx("div",{className:"opacity-70 mt-1",children:o})]})});return s?i:t.jsx(Vr,{width:e,height:n,scale:r,children:i})}const Moe=Object.freeze(Object.defineProperty({__proto__:null,SimulatorFrameNotice:So},Symbol.toStringTag,{value:"Module"}));function dP({currentWidth:e,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 t.jsx(So,{currentWidth:e,currentHeight:n,isFilled:s,scale:r,title:o,hint:i})}const Ioe=Object.freeze(Object.defineProperty({__proto__:null,NoBootedSimulatorPlaceholder:dP},Symbol.toStringTag,{value:"Module"})),Iq=1500;function uP(e=Iq){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,e);return()=>{r=!0,window.clearInterval(o)}},[e]),n}const Dq=700;function pP({currentHeight:e,currentWidth:n,isFilled:s,scale:r,pollMs:a=Dq,onError:o,deviceLabel:i="iOS Simulator",scenarioScreenshotSrc:c=null,bootState:d}){const u=P2({pollMs:a,paused:!!c||!!d,onError:o}),{state:p,frameToken:h}=d??u,f=uP();if(c)return t.jsx(Ka,{src:c,currentWidth:n,currentHeight:e,isFilled:s,scale:r});if(p.kind==="no-device"||p.kind==="xcode-missing"){if(!f.loading&&f.available){const g=f.capturedAtMs!=null?`/api/preview-capture?cb=${f.capturedAtMs}`:"/api/preview-capture";return t.jsx(Ka,{src:g,currentWidth:n,currentHeight:e,isFilled:s,scale:r})}return t.jsx(dP,{currentWidth:n,currentHeight:e,isFilled:s,scale:r,variant:p.kind})}if(p.kind==="loading")return t.jsx(So,{currentWidth:n,currentHeight:e,isFilled:s,scale:r,title:`Connecting to the ${i}…`,hint:"Waiting for the first live frame."});if(p.kind==="capture-failed")return t.jsx(So,{currentWidth:n,currentHeight:e,isFilled:s,scale:r,title:"Live preview frame unavailable",hint:`Your app is still running — interact with it directly in the ${i} window.`});const m=`/api/simulator-frame?t=${h}`;return t.jsx(Ka,{src:m,currentWidth:n,currentHeight:e,isFilled:s,scale:r})}const Doe=Object.freeze(Object.defineProperty({__proto__:null,SimulatorPreviewFrame:pP},Symbol.toStringTag,{value:"Module"}));function hP({emptyStateMessage:e,projectSetupInProgress:n,previewSlug:s,previewUrl:r,viewports:a,activeViewport:o,onViewportChange:i,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:p,currentWidth:h,currentHeight:f,onCustomSizeChange:m,buildingScenarioSlug:g,buildingScreenshotPath:x,buildingScenarioName:b,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:j,historicalScenarioName:_,historicalHeading:S,historicalSubtext:w,onDismissHistoricalPreview:k,previewSeeding:N,previewSeedError:C,previewSeedErrorKind:T,onRetrySeed:P,currentScenario:R,scenarioGroups:L,onShowScenarioPreview:M,commandNonce:O,previewOrigin:z,isNarrow:I=!1,onBack:Y,onPlanChange:W,onDesignConfirmed:A,onExitDesigns:B,designSession:D=!1,onSkipDesign:J,credentialTarget:te=null,onCredentialStored:oe,onCloseCredentialRequest:se}){const{config:G}=Pt(),le=st(G==null?void 0:G.provider),[ue,ne]=l.useState(!1),E=!!Y,U=(R?ru(R,L??[]):[]).length>1,[pe,ge]=l.useState(!0),[Me,Ce]=l.useState(!1),De=E?pe:Me,Be=E?ge:Ce,X=E||U,Q=De&&!!R&&(E||U),[re,ce]=l.useState({state:"idle"}),{containerRef:_e,containerSize:Te,scale:Oe}=kW({currentHeight:f,currentWidth:h,isFilled:u}),he=T2(),Fe=RW(z===ps),[F,ee]=l.useState(!1),de=!!(G!=null&&G.previewDedicatedOriginUnavailable),[ie,fe]=l.useState(!1);l.useEffect(()=>{Zt()||yW(C??null)},[C]);const ve=MW(R,o),be=ve?gs(ve,R==null?void 0:R.screenshotCapturedAtMs):null,We=$i(he.kind),ze=!!be,Re=P2({paused:!We||ze}),Ye=Re.state.kind==="no-device"||Re.state.kind==="xcode-missing",rt=he.fallbackKind==="iframe"&&he.fallbackPort!==null,je=We&&!ze&&rt&&Ye,Ve=he.fallbackPort??0,Qe=(R?wy(R,Ve,z):"")||$o("/",{appPort:Ve,currentPort:typeof window<"u"?Lo(window.location):0,previewOrigin:z}),K=r?$s(r):"",V=K==="/results"||K.startsWith("/results/"),we=K==="/plan-preview",Ue=K==="/design-exploration",Ge=K==="/design-round",gt=K===_y,at=K===Sy,it=Ud(K);if(K===br)return t.jsx(xT,{target:te,onStored:He=>oe==null?void 0:oe(He),onClose:()=>se==null?void 0:se()});if(gt)return t.jsx(Q5,{});if(at)return t.jsx(eP,{});if(we)return t.jsx(BT,{});if(V)return t.jsx(G2,{});if(Ue)return t.jsx(mT,{onDesignConfirmed:A,onExit:B,sessionMode:D,onSkip:J});if(Ge)return t.jsx(gT,{});if(it)return t.jsx(Cy,{previewPath:K,commandNonce:O});if(n&&!r&&!he.loading&&!$i(he.kind))return t.jsx(J5,{});const xt=re.state==="app-launched";return t.jsxs("div",{"data-preview-pane":"true",className:"flex-1 flex flex-col min-w-0",children:[t.jsx(LT,{viewports:a,active:o,onChange:i,currentWidth:h,currentHeight:f,previewUrl:r,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:p,containerWidth:(Te==null?void 0:Te.width)??null,containerHeight:(Te==null?void 0:Te.height)??null,onCustomSizeChange:m,currentScenario:R??null,scenarioGroups:L??[],onShowScenarioPreview:M??(()=>{}),onCreateStateRequest:()=>ne(!0),isNarrow:I,onBack:Y,onPlanChange:W,onToggleStatesModal:X?()=>Be(He=>!He):void 0,statesModalOpen:De}),C?t.jsx(nP,{error:C,kind:T,onRetry:P}):null,he.nativeWebPreview?t.jsx(yT,{}):null,de&&!ie?t.jsx(Ay,{onDismiss:()=>fe(!0),hint:(G==null?void 0:G.previewDedicatedOriginHint)??null,onManagedFleetVm:!!(G!=null&&G.onManagedFleetVm)}):Fe&&!F?t.jsx(tP,{previewOrigin:z,onDismiss:()=>ee(!0)}):null,Q&&R?t.jsx(Tv,{currentScenario:R,scenarioGroups:L??[],onSelect:He=>(M??(()=>{}))(He),onCreateNew:()=>ne(!0),onClose:()=>Be(!1)}):null,t.jsxs("div",{className:"relative flex-1 flex flex-col min-h-0",children:[We&&!je?t.jsxs(t.Fragment,{children:[t.jsx(bT,{deviceLabel:Fi(he.kind),actions:t.jsx(Xc,{onStateChange:ce})}),t.jsx("div",{ref:_e,className:"relative flex-1 flex overflow-hidden items-center justify-center p-8",style:{backgroundColor:"#1e1e1e"},children:xt?t.jsx(pP,{currentHeight:f,currentWidth:h,isFilled:u,scale:Oe,deviceLabel:Fi(he.kind),scenarioScreenshotSrc:be,bootState:Re}):t.jsx(cP,{onStateChange:ce})})]}):t.jsxs(t.Fragment,{children:[je?t.jsx(zj,{deviceLabel:Fi(he.kind),actions:t.jsx(Xc,{})}):null,t.jsx(L5,{providerLabel:le,containerRef:_e,containerHeight:Te==null?void 0:Te.height,containerWidth:Te==null?void 0:Te.width,currentHeight:f,currentWidth:h,emptyStateMessage:e??"Select a scenario to preview",isFilled:u,previewSlug:je?(R==null?void 0:R.slug)??s:s,previewUrl:je?Qe:r,previewOrigin:z,previewSessionHandoff:(G==null?void 0:G.previewSessionHandoff)??null,previewSessionHandoffProbe:(G==null?void 0:G.previewSessionHandoffProbe)??null,scale:Oe,buildingScenarioSlug:g,buildingScreenshotPath:x,buildingScenarioName:b,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:j,historicalScenarioName:_,historicalHeading:S,historicalSubtext:w,onDismissHistoricalPreview:k,commandNonce:O})]}),N?t.jsx(sP,{label:$i(he.kind)?"Loading scenario on device…":void 0}):null]}),ue?t.jsx(Y2,{onClose:()=>ne(!1),providerLabel:le}):null]})}const Loe=Object.freeze(Object.defineProperty({__proto__:null,PreviewPanel:hP},Symbol.toStringTag,{value:"Module"}));function fP({designReturnVisible:e=!1,onOpenDesigns:n,onDismissDesignReturn:s,...r}){return t.jsxs("div",{className:"flex-1 flex min-w-0 relative",children:[t.jsx("div",{"data-testid":"preview-canvas-card",className:"flex-1 flex min-w-0",style:SI,children:t.jsx(hP,{...r})}),e&&n&&s?t.jsx(C2,{onOpenDesigns:n,onDismiss:s}):null]})}const $oe=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPreviewPane:fP},Symbol.toStringTag,{value:"Module"})),Qc="reset";function mP({busy:e,onCancel:n,onConfirm:s,planSessionActive:r=!1}){const[a,o]=l.useState(""),i=a.trim().toLowerCase()===Qc;return l.useEffect(()=>{const c=d=>{d.key==="Escape"&&!e&&n()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e,n]),t.jsx("div",{role:"presentation",onClick:()=>{e||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:t.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:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Cancel build & reset everything?"}),t.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:["This stops the current build, clears the editor session, and"," ",t.jsx("strong",{style:{color:"var(--accent-red)"},children:"permanently discards uncommitted code changes"})," ","(back to the current commit). This cannot be undone."]}),t.jsx("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"Plans in the Plan tab are kept."}),r?t.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]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:6,color:"var(--text-secondary)",fontSize:12},children:["Type ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:Qc})," to confirm",t.jsx("input",{type:"text",value:a,disabled:e,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"}})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,disabled:e,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:s,disabled:e||!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:e?"wait":i?"pointer":"not-allowed",opacity:e||!i?.5:1,fontFamily:"inherit"},children:e?"Resetting…":"Reset everything"})]})]})})}const Foe=Object.freeze(Object.defineProperty({__proto__:null,RESET_CONFIRM_WORD:Qc,ResetBuildConfirmModal:mP},Symbol.toStringTag,{value:"Module"}));function Lq(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=l.useRef(!1),{scenariosVersion:u}=Tn(),p=l.useCallback(async()=>{o(!0),d.current||r(!0),c(null);try{const f=await fetch("/api/scenarios");if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=(await f.json()).map(nd);n(ST(m))}catch(f){c(f instanceof Error?f.message:"Failed to load scenarios")}finally{d.current=!0,o(!1),r(!1)}},[]);l.useEffect(()=>{p()},[p,u]);const h=e.reduce((f,m)=>f+m.scenarios.length,0);return{groups:e,loading:s,refreshing:a,error:i,totalScenarios:h,reload:p}}function $q(e){if(Array.isArray(e))return{entities:e,unsurfacedPages:[],componentSurfaceReason:null};if(e&&typeof e=="object"){const n=e;return{entities:Array.isArray(n.entities)?n.entities:[],unsurfacedPages:Array.isArray(n.unsurfacedPages)?n.unsurfacedPages:[],componentSurfaceReason:Fq(n.componentSurfaceReason)}}return{entities:[],unsurfacedPages:[],componentSurfaceReason:null}}function Fq(e){if(!e||typeof e!="object")return null;const n=e.kind;return n==="no-component-scenarios"||n==="missing-from-glossary"||n==="not-visual-components"?e:null}function zq(){const[e,n]=l.useState([]),[s,r]=l.useState([]),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[p,h]=l.useState(null),f=l.useRef(!1),{scenariosVersion:m}=Tn(),g=l.useCallback(async()=>{u(!0),f.current||c(!0),h(null);try{const x=await fetch("/api/app-route-entities");if(!x.ok)throw new Error(`HTTP ${x.status}`);const b=$q(await x.json());n(b.entities.map(y=>({...y,scenarios:Array.isArray(y==null?void 0:y.scenarios)?y.scenarios.map(nd):[]}))),r(b.unsurfacedPages),o(b.componentSurfaceReason)}catch(x){h(x instanceof Error?x.message:"Failed to load app routes"),n([]),r([]),o(null)}finally{f.current=!0,u(!1),c(!1)}},[]);return l.useEffect(()=>{g()},[g,m]),{routeEntities:e,unsurfacedPages:s,componentSurfaceReason:a,loading:i,refreshing:d,error:p,reload:g}}const Bq=8e3;function Wq(e,n=Bq){const[s,r]=l.useState(null),[a,o]=l.useState(null);l.useEffect(()=>{if(e===null)return;const d=setTimeout(()=>o(e),n);return()=>clearTimeout(d)},[e,n]);const i=l.useCallback(()=>r(e),[e]);return{visible:e!==null&&s!==e&&a!==e,dismiss:i}}function Hq({isDesignViewShowing:e,onOpen:n}){const s=l.useRef(e);s.current=e;const r=l.useRef(n);r.current=n,l.useEffect(()=>{let a=!0,o=null;const i=async()=>{try{const d=await fetch("/api/editor-design-active-tab");if(!d.ok)return;const u=await d.json();if(!a)return;const p=u.nonce??0;if(o===null){o=p;return}if(p<=o)return;o=p,u.tab==="mockups"&&!s.current&&r.current()}catch{}};i();const c=window.setInterval(i,4e3);return()=>{a=!1,window.clearInterval(c)}},[])}const qq={prototype:"Prototype session",chat:"Chat"};function Uq({building:e,build:n,activity:s,chatNeedsYou:r}){if(e)return{active:!0,label:n.label,status:n.status};const a=qq[s];return a?{active:!0,label:a,status:r?"waiting":"building"}:{active:!1,label:n.label,status:n.status}}function xg(e){const n=new Map;for(const s of e){const r=Gq(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 Gq(e){const s=e.replace(/\\/g,"/").replace(/^\.\//,"").split("/").filter(r=>r.length>0);return s.length===0?"Other":s[0]==="crates"&&s.length>=2?`crates/${s[1]}`:e==="(no-file)"?"(no-file)":s[0]}function gP(e,n){if(n===".")return e;const s=n.endsWith("/")?n:`${n}/`;return e.map(r=>({feature:r.feature,tests:r.tests.filter(a=>a.file.startsWith(s))})).filter(r=>r.tests.length>0)}function xP(e,n,s){return s==="backend"?[]:e.map(r=>({...r,scenarios:r.scenarios.filter(ko)})).filter(r=>r.scenarios.length>0)}function bP(e){let n=0,s=0,r=0,a=0,o=0;for(const i of e)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 Yq(e){return e.reduce((n,s)=>n+s.scenarios.length,0)}const Vq=3e3;function Kq(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(!1),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(null),b=l.useRef(null),y=l.useRef(null),v=l.useRef(!1),j=l.useRef(null),{testsVersion:_}=Tn(),S=l.useCallback(async(R=!1)=>{var z;(z=b.current)==null||z.abort();const L=new AbortController;b.current=L;const{signal:M}=L;R&&(v.current=!0,o(!0));const O=!R&&j.current!==null;O||(r(!0),c(null));try{if(!R&&!O)try{const A=await fetch("/api/test-results/summary",{signal:M});if(A.ok){const B=await A.json();B.running?h(B.currentRunner??null):B.stats&&(m(B.stats),x(B.coverage??null))}}catch{}let I,Y;if(O){I=j.current;const A=await fetch("/api/test-results",{signal:M});if(!A.ok)throw new Error(`test-results: HTTP ${A.status}`);Y=await A.json()}else if(R){const A=await fetch("/api/test-results/refresh",{method:"POST",signal:M});if(!A.ok)throw new Error(`test-results: HTTP ${A.status}`);Y=await A.json(),I=j.current??[]}else{const[A,B]=await Promise.all([fetch("/api/tests",{signal:M}),fetch("/api/test-results",{signal:M})]);if(!A.ok)throw new Error(`tests: HTTP ${A.status}`);if(!B.ok)throw new Error(`test-results: HTTP ${B.status}`);I=xg(await A.json()),Y=await B.json(),j.current=I}if(h(Y.currentRunner??null),Y.running&&v.current){y.current=setTimeout(()=>S(!1),Vq);return}const W=v.current;if(v.current=!1,W){const A=await fetch("/api/tests",{signal:M});A.ok&&(I=xg(await A.json()),j.current=I)}n(I),u(Y.cached??!1),x(Y.coverage??null),m(null),r(!1),o(!1)}catch(I){if(I instanceof DOMException&&I.name==="AbortError")return;v.current=!1,c(I instanceof Error?I.message:"Failed to load tests"),r(!1),o(!1)}},[]);l.useEffect(()=>(j.current=null,S(),()=>{var R;(R=b.current)==null||R.abort(),y.current&&clearTimeout(y.current)}),[S,_]);const{total:w,passed:k,failed:N,ignored:C,discovered:T}=l.useMemo(()=>bP(e),[e]),P=l.useCallback(()=>{v.current||S(!0)},[S]);return{groups:e,loading:s,refreshing:a,error:i,cached:d,currentRunner:p,summaryStats:f,coverage:g,totalTests:w,passedTests:k,failedTests:N,ignoredTests:C,discoveredTests:T,reload:S,refresh:P}}function Qp(e,n){return e.filter(s=>s.appDir===n)}function yP(e,n){return n?e.find(s=>s.route===n)??null:null}function vP(e,n,s,r=null){const a=xP(e,n,s);return Qq(a,r)}function Jq(e){const n=e.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=>Zc(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 Xq(e){return(e==null?void 0:e.defaultScenarioSlug)??null}function jP(e,n,s=null){const r=e.find(a=>a.type==="web");return r?vP(n,r.dir,r.type,s):null}function Qq(e,n){const s=e.flatMap(d=>d.scenarios.filter(u=>ko(u)).map(u=>({route:d.route,scenario:u})));if(s.length===0)return null;const r=Ea(s.filter(({route:d,scenario:u})=>d==="/"&&Zc(u)),n);if(r)return r.scenario.slug;const a=Ea(s.filter(({route:d})=>d==="/"),n);if(a)return a.scenario.slug;const o=Ea(s.filter(({scenario:d})=>Zc(d)),n);if(o)return o.scenario.slug;const i=Math.min(...s.map(({route:d})=>d.length)),c=Ea(s.filter(({route:d})=>d.length===i),n);return(c==null?void 0:c.scenario.slug)??null}function Ea(e,n){return e.find(({scenario:s})=>Zq(s,n))??e[0]??null}function Zq(e,n){return n?e.dimensions.length===0||e.dimensions.includes(n):!0}function Zc(e){return/\bhome\b/i.test(e.name)}function bg(e){return new Set(e.flatMap(n=>n.scenarios.map(s=>s.slug)))}function hl({selectedApp:e,appRouteEntities:n,scenarioGroups:s,defaultScreenSize:r=null}){return e?Jq(n)??vP(s,e.dir,e.type,r):null}function eU({apps:e,hasExplicitAppSelection:n,scenarioGroups:s,defaultScreenSize:r=null}){return n||e.length===0||s.length===0?null:jP(e,s,r)}function yg(e){return Xq(e)}function tU({apps:e,routeEntities:n,selectedApp:s,appRouteEntities:r}){if(s)return r;const a=e.find(o=>o.type==="web");return a?Qp(n,a.dir):[]}function nU({previewRouteEntities:e,selectedRouteEntity:n}){var r;if(n!=null&&n.route)return n.route;if(e.length===0)return null;const s=e.find(a=>a.route==="/");return s?s.route:((r=[...e].sort((a,o)=>a.route.length-o.route.length||a.route.localeCompare(o.route))[0])==null?void 0:r.route)??null}function sU({previewRouteEntities:e,path:n}){var r;const s=$s(n);return((r=yP(e,s))==null?void 0:r.defaultScenarioSlug)??null}function rU(e){return e.startsWith("/scenario/")||Og(e)}function aU(e){const n=wE(e);return rU(n)?!1:n==="/"||n==="/apps"||n==="/apps/"}function oU(e,n,s=""){const r=Wi(s),[a,o]=l.useState(r.selectedAppDir),[i,c]=l.useState(r.selectedEntityHash);l.useEffect(()=>{const v=Wi(s);o(j=>j===v.selectedAppDir?j:v.selectedAppDir),c(j=>j===v.selectedEntityHash?j:v.selectedEntityHash)},[s]),l.useEffect(()=>{if(typeof window>"u"||e.length!==1)return;const v=Wi(s);if(v.selectedAppDir||v.selectedEntityHash||!aU(s))return;const j=`${Hi(e[0].dir)}${window.location.search}`;`${window.location.pathname}${window.location.search}`!==j&&(window.history.replaceState({},"",j),o(e[0].dir))},[e,s]);const d=l.useMemo(()=>i?n.find(v=>Ll(v)===i)??null:null,[n,i]),u=l.useMemo(()=>a?e.find(v=>v.dir===a)??null:d?e.find(v=>v.dir===d.appDir)??null:i?e.find(v=>v.type==="web")??e[0]??null:null,[e,a,d,i]),p=l.useMemo(()=>u?Qp(n,u.dir):[],[n,u]),h=l.useMemo(()=>i?d:null,[i,d]);function f(v){if(typeof window>"u")return;const j=`${window.location.pathname}${window.location.search}`;v!==j&&window.history.pushState({},"",v)}function m(v){o(v),c(null),f(Hi(v))}function g(){o(null),c(null),f(jn("home"))}function x(v){const j=p.find(w=>w.route===v);if(!j)return;const _=Ll(j),S=gv(j);!_||!S||(c(_),f(S))}function b(v){c(v),f(mv(v))}function y(){c(null),f(a?Hi(a):jn("home"))}return{selectedApp:u,appRouteEntities:p,selectedEntityHash:i,selectedRouteEntity:h,selectApp:m,deselectApp:g,selectRoute:x,selectEntity:b,deselectRoute:y}}function iU(e,n,s,r,a="",o=null,i=!0,c){const[d,u]=l.useState(null),p=l.useRef(!1),h=l.useRef(!1),{selectedApp:f,appRouteEntities:m,selectedEntityHash:g,selectedRouteEntity:x,selectApp:b,deselectApp:y,selectRoute:v,selectEntity:j,deselectRoute:_}=oU(e,n,a),S=l.useMemo(()=>bg(m),[m]),w=l.useMemo(()=>bg(x?[x]:[]),[x]),k=l.useMemo(()=>hl({selectedApp:f,appRouteEntities:m,scenarioGroups:s,defaultScreenSize:o}),[m,o,s,f]),N=l.useMemo(()=>yg(x),[x]),C=l.useMemo(()=>f?gP(r,f.dir):[],[r,f]);l.useEffect(()=>{if(p.current)return;if(c!=null&&c.current){p.current=!0;return}if(!i)return;const z=eU({apps:e,scenarioGroups:s,hasExplicitAppSelection:!!f,defaultScreenSize:o});z&&(u(z),p.current=!0)},[e,o,s,f,i,c]),l.useEffect(()=>{if(f){if(h.current){h.current=!1;return}if(x){if(!N||d&&w.has(d))return;u(N);return}k&&(d&&S.has(d)||u(k))}},[k,N,d,f,S,x,w]);function T(z){b(z);const I=e.find(W=>W.dir===z);if(!I)return;const Y=hl({selectedApp:I,appRouteEntities:Qp(n,I.dir),scenarioGroups:s,defaultScreenSize:o});u(Y)}function P(){y(),u(jP(e,s,o))}function R(z){v(z);const I=yg(yP(m,z));u(I)}const L=l.useCallback(z=>{h.current=!0,u(z)},[]);function M(){if(_(),!f)return;const z=hl({selectedApp:f,appRouteEntities:m,scenarioGroups:s,defaultScreenSize:o});z&&u(z)}function O(z){j(z)}return{selectedApp:f,appRouteEntities:m,appTestGroups:C,selectedEntityHash:g,selectedRouteEntity:x,previewSlug:d,setPreviewSlug:u,setPreviewSlugExplicit:L,selectApp:T,deselectApp:P,selectRoute:R,selectEntity:O,deselectRoute:M}}const lU=1e3;function cU(e,n){const s=l.useRef(e);s.current=e;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,p=u===null?"/api/editor-commands":`/api/editor-commands?since=${u}`,h=await fetch(p);if(h.ok){const f=await h.json();typeof f.seq=="number"&&(a.current=f.seq),f.bootId&&(o.current===null?o.current=f.bootId:o.current!==f.bootId&&(o.current=f.bootId,(d=r.current)==null||d.call(r)));for(const m of f.commands??[])s.current(m)}}catch{}i&&setTimeout(c,lU)}}return c(),()=>{i=!1}},[])}function dU(){const[e,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(()=>RD(e),[e]);return{graph:e,entityLookup:i,loading:s,error:a}}function ed(e,n){if(!e)return null;for(const s of n)for(const r of s.scenarios)if(r.slug===e)return r;return null}function uU({apps:e,appRouteEntities:n,directPreviewPath:s,fallbackPort:r,previewKind:a,previewOrigin:o,previewSlug:i,routeEntities:c,scenarioGroups:d,selectedApp:u,selectedRouteEntity:p}){const h=Ny(d,i),f=tU({apps:e,routeEntities:c,selectedApp:u,appRouteEntities:n}),m=nU({previewRouteEntities:f,selectedRouteEntity:p}),g=e.length>0;let x="blank";a==="plan-preview"&&s?x="plan-preview":a==="results"&&s?x="results":a==="application"&&s?x=g||qd(s)?"application":"blank":h?g&&(x=ko(h)?"application":"component"):m&&g&&(x="application");const b=PI({directPreviewPath:s,fallbackPreviewPath:m,previewKind:x,selectedScenario:h,port:r,previewOrigin:o});return{selectedScenario:h,previewRouteEntities:f,fallbackPreviewPath:m,resolvedPreviewKind:x,basePreviewUrl:b}}function pU({allowEditorRoutePreview:e,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 x=n.scenarioSlug??n.scenarioId,b=Ny(a,x);return b?{clearCustomSize:c,scenarioSlug:b.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:x,type:"show-scenario",viewportName:i,commandNonce:d}}if(!n.path)return{clearCustomSize:c,type:"refresh",viewportName:i,commandNonce:d};const u=n.path,p=u.startsWith("http")?new URL(u).pathname:u.split("?")[0]??u,h=p==="/results"||p.startsWith("/results/"),f=p==="/plan-preview",m=jy(u);if(Ud(p))return{clearCustomSize:c,path:u,previewKind:"agent-html",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(f)return{clearCustomSize:c,path:u,previewKind:"plan-preview",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(h)return{clearCustomSize:c,path:u,previewKind:"results",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(m&&!e)return{clearCustomSize:c,type:s?"ignore":"defer",viewportName:i,commandNonce:d};if(m&&e)return{clearCustomSize:c,path:u,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d};const g=sU({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 hU(e,n,s,r,a){const o=r.dimensions;return o.length===0||o.includes(e)&&n===null&&s===null?null:o.find(i=>a.some(c=>c.name===i))??o[0]}const fU=[{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 mU(e,n){const s=Object.entries(e);if(s.length===0)return fU;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 gU=1500;function xU({enabled:e,pollMs:n=gU}){const[s,r]=l.useState(0),a=l.useRef(void 0);return l.useEffect(()=>{if(!e)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 p=u.state,h=a.current;a.current=p,p==="app-launched"&&h!==void 0&&h!=="app-launched"&&r(f=>f+1)}catch{}};i();const c=window.setInterval(i,n);return()=>{o=!0,window.clearInterval(c)}},[e,n]),s}function bU({isInIframe:e,hydrated:n=!0,persistedPath:s,previewKind:r,resolvedViewport:a,selectedScenario:o}){l.useEffect(()=>{e||!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,e,s,r,a.height,a.name,a.width,o==null?void 0:o.id,o==null?void 0:o.slug])}function yU({deviceLaunchGeneration:e=0,isInIframe:n,onActivated:s,previewKind:r,previewMedium:a,scenariosLoaded:o,selectedScenario:i,seedRetryToken:c=0}){const[d,u]=l.useState(!1),[p,h]=l.useState(null),[f,m]=l.useState(null);return l.useEffect(()=>{if(!o||n)return;if(uR({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),h(null),m(null),fetch("/api/editor-activate-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:i.slug})}).then(async x=>{const b=await x.json().catch(()=>null);if(!g){if(!b||b.success===!1||b.seedError||b.deviceSeedError){h(b&&(b.seedError||b.deviceSeedError||b.error)||"scenario activation failed"),b!=null&&b.seedError?m("seed"):b!=null&&b.deviceSeedError||b!=null&&b.error?m("device"):m(null);return}s()}}).catch(x=>{g||(h(x instanceof Error?x.message:String(x)),m(null))}).finally(()=>{g||u(!1)}),()=>{g=!0}},[e,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:p,seedErrorKind:f}}const vU=3;function jU({apps:e,appRouteEntities:n,configLoaded:s,defaultScreenSize:r,hydrated:a=!0,port:o,previewMedium:i,previewOrigin:c,projectTitle:d,previewSlug:u,routeEntities:p,scenarioGroups:h,scenariosLoaded:f,screenSizes:m,selectedApp:g,selectedRouteEntity:x,setPreviewSlug:b}){const[y,v]=l.useState(r??"Desktop"),j=l.useRef(!1),[_,S]=l.useState(null),[w,k]=l.useState(null),[N,C]=l.useState(null),[T,P]=l.useState(null),[R,L]=l.useState(()=>Date.now()),[M,O]=l.useState(0),z=l.useRef(null),I=l.useRef(!1),Y=l.useMemo(()=>mU(m,r),[r,m]);l.useEffect(()=>{j.current||r&&(v(r),j.current=!0)},[r]);const W=l.useMemo(()=>_!==null&&w!==null?{name:"Custom",width:_,height:w}:Y.find(ce=>ce.name===y)??Y[0]??{name:"Desktop",width:1440,height:900},[y,w,_,Y]),A=Zt(),B=d==="CodeYam Editor",{basePreviewUrl:D,fallbackPreviewPath:J,previewRouteEntities:te,resolvedPreviewKind:oe,selectedScenario:se}=l.useMemo(()=>uU({apps:e,appRouteEntities:n,directPreviewPath:N,fallbackPort:o,previewKind:T,previewOrigin:c,previewSlug:u,routeEntities:p,scenarioGroups:h,selectedApp:g,selectedRouteEntity:x}),[e,n,N,o,T,c,u,p,h,g,x]),G=l.useMemo(()=>D?OI(D,R):"",[D,R]),le=l.useCallback(ce=>{v(ce),S(null),k(null)},[]),ue=l.useCallback((ce,_e)=>{S(ce),k(_e)},[]),ne=l.useCallback(ce=>{b(ce),C(null),P(null),L(Date.now());const _e=ed(ce,h);if(!_e)return;const Te=hU(y,_,w,_e,Y);Te!==null&&(v(Te),S(null),k(null))},[y,w,_,h,b,Y]),E=l.useCallback((ce,_e)=>{const Te=(_e==null?void 0:_e.retriesLeft)??vU,Oe=pU({allowEditorRoutePreview:B,command:ce,configLoaded:s,previewRouteEntities:te,scenarioGroups:h,scenarioDeferAvailable:Te>0});if(Oe.viewportName&&v(Oe.viewportName),Oe.clearCustomSize&&(S(null),k(null)),Oe.type==="show-scenario"){ne(Oe.scenarioSlug),O(he=>he+1);return}if(Oe.type==="defer"){z.current={command:ce,retriesLeft:Te};return}if(Oe.type==="refresh"){L(Date.now()),O(he=>he+1);return}Oe.type!=="ignore"&&(Oe.type==="show-path"&&(P(Oe.previewKind),C(Oe.path),I.current=Oe.preserveDirectPreviewPathOnSlugChange,typeof Oe.previewSlug=="string"?b(Oe.previewSlug):Oe.previewSlug===null&&b(null)),L(Date.now()),O(he=>he+1))},[s,B,te,h,b,ne]);l.useEffect(()=>{if(!s)return;const ce=z.current;ce&&(z.current=null,E(ce.command,{retriesLeft:ce.retriesLeft-1}))},[s,h,E]),l.useEffect(()=>{if(!(!u||N===null)){if(I.current){I.current=!1;return}C(null),P(null),L(Date.now())}},[N,u]);const H=l.useMemo(()=>oe==="results"||oe==="plan-preview"?N:oe==="application"?N??(se==null?void 0:se.url)??J:null,[N,J,oe,se==null?void 0:se.url]),U=l.useCallback(()=>{L(Date.now())},[]),[pe,ge]=l.useState(0),Me=l.useCallback(()=>{ge(ce=>ce+1)},[]);bU({isInIframe:A,hydrated:a,persistedPath:H,previewKind:oe,resolvedViewport:W,selectedScenario:se?{id:se.id??null,slug:se.slug}:null});const De=xU({enabled:i==="simulator-ios"||i==="simulator-android"}),{seeding:Be,seedError:X,seedErrorKind:Q}=yU({deviceLaunchGeneration:De,seedRetryToken:pe,isInIframe:A,onActivated:U,previewKind:oe,previewMedium:i,scenariosLoaded:f,selectedScenario:se?{slug:se.slug,scenarioType:se.scenarioType,componentName:se.componentName??null}:null}),re=l.useCallback(ce=>{ce!==null&&(I.current=!0,qd(ce)&&b(null)),C(ce),P(ce?"application":null),L(Date.now())},[b]);return{viewports:Y,resolvedViewport:W,previewUrl:G,handleViewportChange:le,handleCustomSizeChange:ue,showScenarioPreview:ne,handlePreviewCommand:E,setPreviewPath:re,previewSeeding:Be,previewSeedError:X,previewSeedErrorKind:Q,retrySeed:Me,commandNonce:M}}function wU({isInIframe:e,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 p=l.useRef(r),h=l.useRef(a),f=l.useRef(o);p.current=r,h.current=a,f.current=o;const m=l.useCallback(()=>{if(c.current||!u.current||s.current)return;const g=d.current;g&&(c.current=!0,s.current=!0,p.current(g))},[s]);l.useEffect(()=>{e||i.current||(i.current=!0,fetch("/api/editor-preview-state").then(g=>g.json()).then(g=>{g&&(g.scenarioSlug||g.path)&&(d.current=g,m())}).catch(()=>{}).finally(()=>{var g;h.current(),!c.current&&!d.current&&((g=f.current)==null||g.call(f))}))},[e,m]),l.useEffect(()=>{m()},[n,m])}function _U({isInIframe:e,onConverge:n}){const s=l.useRef(n);s.current=n,l.useEffect(()=>{if(!e)return $7(()=>{fetch("/api/editor-preview-state").then(r=>r.json()).then(r=>{r&&(r.scenarioSlug||r.path)&&s.current(r)}).catch(()=>{}).finally(()=>{dd()})})},[e])}const SU=15e3;function fl(){fetch("/api/editor-tab-heartbeat",{method:"POST"}).catch(()=>{})}function kU(e){l.useEffect(()=>{if(e)return;fl();const n=setInterval(fl,SU),s=()=>{document.visibilityState==="visible"&&fl()};return document.addEventListener("visibilitychange",s),()=>{clearInterval(n),document.removeEventListener("visibilitychange",s)}},[e])}function NU({restoredRef:e,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=>{e.current||(u.scenarioSlug||u.path)&&(e.current=!0,o.current(u))},[e]),c=l.useCallback(u=>{if(!e.current){if(!r.current){a.current=u;return}i(u)}},[i,e]),d=l.useCallback(()=>{r.current=!0;const u=a.current;a.current=null,u&&i(u)},[i]);return{requestRestore:c,onAdoptSettledEmpty:d}}function CU({scenariosLoaded:e,restoredRef:n,apply:s,onSettled:r}){const a=l.useRef(typeof window>"u"?null:_E(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||!e)return;const u=a.current;u&&(o.current=!0,c.current(u))},[e])}function TU(e,{handlePreviewCommand:n,handleCustomSizeChange:s}){!e.scenarioSlug&&!e.path||(n({...e.scenarioSlug?{scenarioSlug:e.scenarioSlug}:{},...e.path?{path:e.path}:{},...e.dimension?{dimension:e.dimension}:{}}),e.dimension==="Custom"&&typeof e.width=="number"&&typeof e.height=="number"&&s(e.width,e.height))}function PU(){const[e,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:e,featureSummary:s,onFeatureCompleteCommand:a,onAgentIdle:o,onAgentActive:i,dismissModal:c}}function Zp(e){return e===null||e.slug===null||e.slug==="feature-complete"}function OU({showPostPushModal:e,stepState:n,dismissModal:s}){const r=l.useRef(!1);l.useEffect(()=>{if(!e){r.current=!1;return}if(Zp(n)){r.current=!0;return}r.current&&(n==null?void 0:n.slug)!=null&&(s(),r.current=!1)},[e,n,s])}function RU({sessionInfo:e,stepState:n,showPostPushModal:s,onFeatureCompleteCommand:r}){const a=l.useRef(null);l.useEffect(()=>{const o=(e==null?void 0:e.cycleClosed)??null;if(!o)return;const i=`${o.closedAt??"unknown"}|${o.reshownAt??""}`;if(a.current!==i){if(s){a.current=i;return}Zp(n)&&(a.current=i,r(o.summary??void 0))}},[e,n,s,r])}function EU(e,n){return e&&Zp(n)}function AU(){const[e,n]=l.useState(!1),s=l.useCallback(()=>{n(!0)},[]),r=l.useCallback(()=>{n(!1)},[]);return{showPlanCompleteModal:e,onPlanCompleteCommand:s,dismissPlanCompleteModal:r}}function MU({plans:e,completedPlans:n,isAgentBuilding:s,onLaunch:r}){const{claims:a}=Op(),{status:o}=Rp(),i=((o==null?void 0:o.consecutiveFailures)??0)>=3,c=l.useMemo(()=>Ap(a),[a]),{annotationsBySlug:d,dependenciesBySlug:u}=Mp(e),p=l.useMemo(()=>uN([...e.map(m=>m.author),...n.map(m=>m.author)]),[e,n]),{requestRun:h,gateModals:f}=xi({dependenciesBySlug:u,claimsBySlug:c,isAgentBuilding:s,onLaunch:r});return{claimsBySlug:c,staleFetch:i,annotationsBySlug:d,dependenciesBySlug:u,showAuthors:p,requestRun:h,gateModals:f}}function IU(){const{showBuildTab:e}=Ip(typeof window>"u"?"/":window.location.pathname),{config:n}=Pt(),[s,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useCallback(async c=>{if(s)return!1;o(null),r(!0);try{const d=await gN();try{await fN(),Jk()}catch{}const u=await fetch("/api/build/start-from-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:c})});if(!u.ok){let p=`HTTP ${u.status}`;try{const h=await u.json();h!=null&&h.error&&(p=h.error)}catch{}throw new Error(p)}return e(),await mN({provider:n==null?void 0:n.provider,serverOwnsLaunch:d===!1}),!0}catch(d){return o(d instanceof Error?d.message:"Failed to launch build"),!1}finally{r(!1)}},[s,e,n==null?void 0:n.provider]);return{launching:s,error:a,launchPrompt:i}}function DU({onTransitionToLive:e}){const[n,s]=l.useState(!1),[r,a]=l.useState(null),o=l.useRef(!1),i=l.useRef(null),c=l.useRef(e);c.current=e;const d=l.useCallback(()=>{o.current=!0,s(!0)},[]),u=l.useCallback(()=>{o.current=!1,s(!1);const m=i.current;m&&(i.current=null,a(null),c.current(m))},[]),p=l.useCallback(m=>o.current?(i.current=m,a(m),!0):!1,[]),h=l.useCallback(()=>{i.current=null,a(null)},[]),f=l.useCallback(()=>{o.current=!1,s(!1),i.current=null,a(null)},[]);return{isAgentBuilding:n,isAgentBuildingRef:o,buildingScenarioSlug:r,onAgentIdle:u,onAgentActive:d,guardScenarioSelect:p,clearBuildingOverlay:h,forceIdle:f}}function LU({chatOpen:e}){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(()=>{e||(s(!1),a(!1))},[e]),{planActive:n,planIdle:r}}function $U(e,n,s){return e.map(r=>{const a=gP(n,r.dir),o=xP(s,r.dir,r.type),{total:i,passed:c,failed:d,ignored:u,discovered:p}=bP(a),h=Yq(o);return{app:r,tests:{total:i,passed:c,failed:d,ignored:u,discovered:p},scenarios:{total:h,thumbnails:FU(o)}}})}function FU(e){const n=[];for(const s of e)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 zU(e,n){return e==null?null:Math.min(1,Math.max(.04,e/Eu(n)))}function BU(e,n){return e==null||e===0?null:`${e}/${Eu(n)}`}function WU(e,n){var r;if(n==null||!Number.isFinite(n))return null;let s=null;for(const a of e??[]){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 HU="Your app will display here once set up.",qU="Loading your app…",UU="Setting up your project…",GU="Select a scenario to preview",YU="No preview is available for this project.";function VU({configLoading:e,hasNoApps:n,hasStepState:s,hasPreviewableApp:r,setupInProgress:a,hasCaptureFrame:o}){return e?qU:a&&!o?UU:n&&!s?HU:r?GU:YU}const KU=["web","mobile"];function JU(e){return KU.includes(e)}function XU(e,n){return n?{scenarioSlug:e,path:n}:{scenarioSlug:e}}function QU(e,n){return e==="needs-login"&&!n}function ZU(e,n){if(!e)return null;for(const s of n)for(const r of s.scenarios)if(r.name===e)return r;return null}const eG="The app is being edited",tG="Live preview will load when the build agent is idle",nG="Showing a saved version",sG="This is a past version of this scenario";function rG({shot:e,isLatest:n,liveScenario:s,isAgentBuilding:r}){if(n&&s&&!r)return{kind:"live",slug:s.slug};const[a,o]=r?[eG,tG]:[nG,sG];return{kind:"historical",screenshotPath:e.screenshotPath??null,scenarioName:e.name,heading:a,subtext:o}}function wP(e){return!e.hasActiveSession&&!e.isAgentBuilding&&!e.showPostPushModal&&e.launchingPlanSlug===null&&!e.submittingBuildPrompt&&!e.stepStateFeature&&!e.buildLaunchModalDismissed}function _P(e){return e.activeTab==="build"&&!e.buildActivityInFlight&&!e.buildActivityMinimized&&!e.buildHandoffPending&&wP(e)}function aG(e){return e.buildActivityMinimized&&_P({...e,buildActivityMinimized:!1})}function oG(e){const[n,s]=l.useState("menu"),[r,a]=l.useState(!1),o=l.useCallback(f=>{s(f),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),[]),p=l.useCallback(f=>{if(f==="plan"){e==null||e();return}s(m=>f==="prototype"&&m==="chat"?m:f),a(f!=="menu")},[e]),h=l.useCallback(f=>{s(f),a(!0)},[]);return{activity:n,minimized:r,hasLiveActivity:n==="prototype"||n==="chat",chooseActivity:o,startSession:i,finishActivity:c,minimize:d,reopen:u,applyCommand:p,restore:h}}function iG({currentActivity:e,alreadyHydrated:n,buildSessionOwnsTab:s,liveBuildActivity:r}){return n||s||e!=="menu"?null:r}function lG(e,n){fetch("/api/build-activity-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({activity:e,escalated:n})}).catch(()=>{})}function cG({buildActivity:e,sessionInfo:n,buildSessionOwnsTab:s,chatEscalatedToPrototype:r,setChatEscalatedToPrototype:a}){const[o,i]=l.useState(!1),c=l.useRef(null),{activity:d,restore:u}=e;l.useEffect(()=>{if(o||!n)return;const p=iG({currentActivity:d,alreadyHydrated:o,buildSessionOwnsTab:s,liveBuildActivity:n.liveBuildActivity??null});if(p){const h=p.activity==="chat"&&p.escalated;u(p.activity),a(h),c.current=ml(p.activity,h)}else c.current=ml("menu",!1);i(!0)},[o,n,d,s,u,a]),l.useEffect(()=>{if(!o)return;const p=ml(d,r);p!==c.current&&(c.current=p,lG(d,r))},[o,d,r])}function ml(e,n){return`${e}:${n}`}const dG=900*1e3;function uG(){const[e,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(),dG);return()=>clearInterval(r)},[s]),{update:e}}function pG(e,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&&(e||(a(!1),s==null||s(),n("build")))},[r,e,n,s]),{arm:o,navigateToTabUser:i,pendingBuildNav:r}}function hG(e){return e.agentActivelyBuilding||e.buildSessionLive&&e.hasCurrentStep?"building":e.buildRequestState==="failed"?"failed":e.buildRequestState==="interrupted"?"interrupted":e.buildRequestState==="unverified"?"unconfirmed":e.buildRequestState==="waiting-for-auth"?"waiting-for-auth":e.buildRequestState==="launch-timeout"?"launch-timeout":e.buildRequestState==="delayed"?"launch-delayed":e.buildRequestState==="dispatching"||e.pendingBuildNavArmed?"preparing":e.brokerReachable===!1?"unconfirmed":e.hasSavedSession&&!e.buildSessionLive?"interrupted":"not-started"}const fG=4e3,mG=2;function SP({state:e,provider:n,credsPresent:s=!0,cliInstalled:r=!0,scannedDirs:a=[],reason:o=null,expiresAt:i=null,shellShare:c=null,probeInFlight:d=!1,probeAttempts:u=0,backendOutOfDate:p=!1,sessionOngoing:h=!1,onAuthenticated:f,onAuthorized:m}){const[g,x]=l.useState(!1),[b,y]=l.useState(!1),v=st(n),[j,_]=l.useState(!1);l.useEffect(()=>{if(e!=="unknown"){_(!1);return}const N=window.setTimeout(()=>_(!0),fG);return()=>window.clearTimeout(N)},[e]);const S=l.useCallback(()=>{x(!1),f(),m==null||m()},[f,m]),w=l.useCallback(async()=>{y(!0);try{await fetch("/api/auth/refresh-cache",{method:"POST"}),f()}catch{}finally{y(!1)}},[f]);if(e==="authenticated")return null;const k=g?t.jsx(Sg,{provider:n,onAuthenticated:S,onClose:()=>x(!1)}):null;if(e==="unknown"){const N=o==="probe-timeout"&&u>=mG,C=r===!1||o==="cli-not-found";return!N&&!C&&(d||!j)||p?null:C?t.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:[t.jsxs("p",{className:"text-sm text-white font-medium",children:[v," CLI not found"]}),t.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["We couldn't find the ",v," CLI on this machine — we searched your PATH and the standard install locations",a.length>0?t.jsxs(t.Fragment,{children:[" (",a.join(", "),")"]}):t.jsx(t.Fragment,{children:" (~/.local/bin, ~/.cargo/bin, /opt/homebrew/bin, /usr/local/bin)"}),". Install the ",v," 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."]}),t.jsx("div",{className:"flex flex-wrap items-center gap-3",children:t.jsx("button",{onClick:()=>void w(),"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"})})]}):t.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:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.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"}),t.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["Checking your ",v," account… If this takes more than a few seconds, your token may need refresh."]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("button",{onClick:()=>x(!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"}),t.jsx("button",{onClick:()=>void w(),"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"})]}),k]})}return t.jsx(rE,{provider:n,credsPresent:s,reason:o,expiresAt:i,shellShare:c,sessionOngoing:h,onAuthenticated:f,onAuthorized:m})}const zoe=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthGate:SP},Symbol.toStringTag,{value:"Module"}));function kP(){const e=l.useSyncExternalStore($h.subscribe,$h.get),n=l.useSyncExternalStore(hg.subscribe,hg.get);return t.jsx(Wj,{visible:e!==null,reason:(e==null?void 0:e.reason)??"lost",framed:D5(),reconnect:n,vmNumber:sq(window.location.hostname),onReload:()=>window.location.reload(),onReconnect:()=>nq()})}const Boe=Object.freeze(Object.defineProperty({__proto__:null,ConnectedSessionLostBanner:kP},Symbol.toStringTag,{value:"Module"}));function NP({update:e}){const{copied:n,copy:s}=To();if(!e||!e.available)return null;const r=e.channel==="desktop";return t.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:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"text-xl leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--blue-300)"},children:"↑"}),t.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[t.jsx("div",{className:"font-semibold mb-1",style:{color:"var(--blue-300)"},children:r?"Update ready":"Update available"}),r?t.jsx(t.Fragment,{children:"It will install automatically after your current session ends. To install now, use the Check for Updates menu."}):t.jsxs(t.Fragment,{children:["A new version of CodeYam Editor is available (",t.jsxs("span",{style:{color:"var(--text-strong)",fontWeight:600},children:[e.currentVersion," → ",e.latestVersion]}),"). Run"," ",t.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:e.upgradeCommand})," ","to upgrade."," ",e.preflightCommand&&t.jsxs(t.Fragment,{children:["Upgrading can restart the editor, so first run"," ",t.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:e.preflightCommand})," ","to see which agent sessions are mid-task."," "]}),t.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(e.upgradeCommand??""),children:n?"Copied":"Copy command"})]})]})]})})}const Woe=Object.freeze(Object.defineProperty({__proto__:null,UpdateAvailableBanner:NP},Symbol.toStringTag,{value:"Module"})),Ps=300,vg=150;function gG(e,n=.5){const[s,r]=l.useState(null),a=l.useRef(!1),[o,i]=l.useState(!1),c=l.useCallback(()=>{var m;return((m=e.current)==null?void 0:m.clientWidth)??1200},[e]),d=l.useCallback(m=>Math.max(Ps,Math.floor(m*n)),[n]),u=s??d(c()),p=l.useCallback(m=>{m.preventDefault(),a.current=!0,i(!0)},[]);l.useEffect(()=>{const m=x=>{var j;if(!a.current)return;const b=((j=e.current)==null?void 0:j.getBoundingClientRect().left)??0,y=x.clientX-b,v=c();y<vg?r(0):y>v-vg?r(v):r(Math.max(Ps,y))},g=()=>{a.current&&(a.current=!1,i(!1))};return document.addEventListener("mousemove",m),document.addEventListener("mouseup",g),()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",g)}},[e,c]);const h=l.useCallback(()=>r(null),[]),f=l.useCallback(m=>{const g=c();r(x=>{const b=x??d(g),y=Math.max(Ps,g-Ps);return Math.min(y,Math.max(Ps,b+m))})},[c,d]);return{leftWidth:u,isDragging:o,handleMouseDown:p,resetWidth:h,nudgeWidth:f,minWidth:Ps}}const xG=3e3;function bG({hot:e,isInIframe:n,reload:s=()=>window.location.reload(),sustainedDisconnectMs:r=xG}){return()=>{}}function yG(){l.useEffect(()=>bG({hot:void 0,isInIframe:Zt()}),[])}const dr="plan";async function jg(){await aE(oE),await hN({send:e=>Sn(e,dr),waitForIdle:e=>Dh(e,dr),ceilingMs:Rr,payload:"/clear\r"}),await Dh(Rr,dr),Sn("/codeyam-plan",dr),await new Promise(e=>setTimeout(e,cd)),Sn("\r",dr)}function vG(){fetch("/api/clear-build-agent-session",{method:"POST"}).catch(()=>{})}function jG(e){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){me("favicon-redraw",{idle:e,hasIcon:!1});return}if(n.current||(n.current=r.href),!e){r.href=n.current,me("favicon-restore",{});return}me("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,p=64-u-1,h=u+1;i.beginPath(),i.arc(p,h,u,0,2*Math.PI),i.fillStyle=ht,i.fill(),r.href=o.toDataURL("image/png")},a.src=n.current},[e]),l.useEffect(()=>()=>{if(typeof document>"u")return;const r=document.querySelector('link[rel="icon"]');r&&n.current&&(r.href=n.current)},[])}function wG(e,n){return new uF({playSound:Ou,showSystemNotification:()=>{if(typeof Notification>"u"||Notification.permission!=="granted")return;n.current&&n.current.close();const s=e.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 _G(e,n){return e==="hook-stop"?n.idleOnStop:n.idleOnNotification}const SG=600*1e3,kG=3e3;function NG({agentName:e,isBuildTabActive:n,isAgentBuilding:s,buildSessionLive:r,featureCompleteKey:a,navigateToTab:o,onAgentIdleImmediate:i,onAgentActiveImmediate:c}){const d=l.useRef(e);d.current=e;const u=l.useRef(n);u.current=n;const p=l.useRef(i);p.current=i;const h=l.useRef(c);h.current=c;const[f,m]=l.useState(o0),[g,x]=l.useState(!1),b=l.useRef(!1);b.current=g;const[y,v]=l.useState(!1),j=l.useRef(!1),_=l.useRef(null),S=l.useRef(null),w=l.useRef(null),k=l.useRef(typeof document<"u"&&document.hidden?Date.now():null),N=l.useRef(null),C=l.useRef(r??!1);C.current=r??!1,jG(g),w.current||(w.current=wG(d,S));const T=l.useCallback(D=>{m(D),i0(D)},[]),P=l.useCallback(D=>{_.current!==null&&(clearTimeout(_.current),_.current=null,me("debounce-cancelled",{trigger:D}))},[]),R=l.useCallback(D=>{b.current&&me("idle-cleared",{trigger:D}),x(!1),b.current=!1,v(!1),N.current=null,S.current&&(S.current.close(),S.current=null)},[]);l.useEffect(()=>DS(()=>{ac()&&b.current&&R("chat-working")}),[R]);const L=l.useCallback((D,J)=>{var te;if(!_G(D,f)){me("idle-suppressed-by-pref",{source:D,blocked:J});return}me("ws-idle-received",{buildTabActive:u.current,source:D,blocked:J}),(te=p.current)==null||te.call(p),P("re-arm-on-idle"),_.current=setTimeout(()=>{var le;if(_.current=null,ac()){me("idle-suppressed-chat-working",{source:D,blocked:J});return}const oe=k.current,se=oe===null?null:Date.now()-oe,G=oe!==null&&Date.now()-oe>SG;me("debounce-resolved",{suppressedForOvernight:G,msHidden:se,buildTabActive:u.current}),G||(le=w.current)==null||le.onIdle(f,u.current),x(!0),b.current=!0,v(J),N.current=Date.now(),j.current=!1,me("agent-currently-idle-set",{suppressedForOvernight:G,blocked:J}),u.current&&Tt()},wr)},[f,P]),M=l.useCallback(D=>L(D,!1),[L]),O=l.useCallback(D=>L(D,!0),[L]),z=l.useCallback(()=>{var D,J,te;(D=h.current)==null||D.call(h),P("agent-active"),(J=w.current)==null||J.onActive(),(te=w.current)==null||te.resetActivityFlag(),b.current&&C.current&&N.current!==null&&Date.now()-N.current>kG&&R("remote-resume")},[P,R]),I=l.useCallback(()=>{var D,J;P("user-input"),b.current&&((D=w.current)==null||D.onUserEngagement(),(J=w.current)==null||J.reportUserActivity("terminal-input"),j.current=!0,R("user-input"))},[P,R]),Y=l.useCallback(D=>{var J;D==="build"&&(P("navigate-build"),b.current&&((J=w.current)==null||J.onUserEngagement(),j.current=!0,R("navigate-build"))),o(D)},[o,P,R]),W=l.useCallback(()=>{var D;P("dismiss-banner"),(D=w.current)==null||D.onUserEngagement(),j.current=!0,R("dismiss-banner")},[P,R]),A=l.useCallback(()=>{var D;P("stop-building"),(D=w.current)==null||D.onUserEngagement(),j.current=!0,R("stop-building")},[P,R]);l.useEffect(()=>{function D(){var ne;b.current&&(j.current||(P("ack-notification"),(ne=w.current)==null||ne.onUserEngagement(),j.current=!0,me("notification-acknowledged",{trigger:"user-return"})))}function J(ne){var E;b.current&&u.current&&document.hasFocus()&&(document.hidden||((E=w.current)==null||E.onUserEngagement(),j.current=!0,R(ne)))}function te(ne){var E;document.hasFocus()&&D(),(E=w.current)==null||E.reportUserActivity(ne)}const oe=()=>te("mousemove"),se=()=>te("mousedown"),G=()=>te("keydown");function le(){document.hidden?k.current===null&&(k.current=Date.now()):(k.current=null,D(),J("tab-visible-on-build"))}function ue(){var ne;D(),J("window-focus-on-build"),(ne=w.current)==null||ne.reportUserActivity("focus")}return window.addEventListener("focus",ue),document.addEventListener("visibilitychange",le),document.addEventListener("mousemove",oe),document.addEventListener("mousedown",se),document.addEventListener("keydown",G),()=>{P("unmount"),window.removeEventListener("focus",ue),document.removeEventListener("visibilitychange",le),document.removeEventListener("mousemove",oe),document.removeEventListener("mousedown",se),document.removeEventListener("keydown",G)}},[P,R]);const B=l.useRef(a??0);return l.useEffect(()=>{var te;const D=a??0;if(D===B.current)return;B.current=D;const J=u.current&&document.hasFocus();me("feature-complete-fast-path",{skipBecauseWatching:J}),!J&&((te=w.current)==null||te.onIdle(f,!1),x(!0),b.current=!0,N.current=Date.now(),j.current=!1)},[a,f]),l.useEffect(()=>{var D,J;if((D=w.current)==null||D.onBuildTabChange(n,f),n)return b.current&&typeof document<"u"&&document.hasFocus()&&!document.hidden&&((J=w.current)==null||J.onUserEngagement(),j.current=!0,R("build-tab-active-on-focus")),Tt()},[n,f,R]),{buildIdle:g,agentBlocked:y,bannerVisible:g,notifSettings:f,handleSettingsChange:T,handleAgentIdle:M,handleAgentBlocked:O,handleAgentActive:z,handleUserInput:I,handleNavigateToTab:Y,dismissIdleBanner:W,clearIdleForStopBuilding:A}}const CG=1e4;function TG(e){const{isAgentBuilding:n,submittingBuildPrompt:s,launchingPlanSlug:r,sessionInfo:a,stepFeature:o,refetchSessionInfo:i}=e,[c,d]=l.useState(!1),u=l.useRef(!1),p=l.useCallback((f,m)=>{u.current!==f&&(me("build-session-live-change",{from:u.current,to:f,trigger:m}),u.current=f,d(f))},[]);return l.useEffect(()=>{n&&p(!0,"agent-active")},[n,p]),l.useEffect(()=>{s&&p(!0,"launch-prompt")},[s,p]),l.useEffect(()=>{r!==null&&p(!0,"launch-plan")},[r,p]),l.useEffect(()=>{((a==null?void 0:a.resumeMode)==="resume"||(a==null?void 0:a.resumeMode)==="handoff")&&p(!0,"resumable-session-detected")},[a,p]),l.useEffect(()=>{(a==null?void 0:a.agentBrokerLive)===!0&&p(!0,"broker-live-detected")},[a,p]),l.useEffect(()=>{a&&!a.hasSession&&!a.agentBrokerLive&&p(!1,"session-ended")},[a,p]),l.useEffect(()=>{if(!c)return;const f=setInterval(()=>{i()},CG);return()=>clearInterval(f)},[c,i]),{buildSessionLive:c,agentActivelyBuilding:c&&(!!o||n||s||r!==null),transitionBuildSessionLive:p}}function wg(e){const{isAgentBuilding:n,trigger:s,transitionBuildSessionLive:r}=e;if(n){me("build-session-live-suppress-clear",{trigger:s,reason:"agent-still-active"});return}r(!1,s)}const PG=new Set(["ui-confirm-plan","backend-confirm-plan","present-live","backend-confirm","ui-present","backend-review"]);function OG(e,n,s=!1){return s&&!n?"building":e&&PG.has(e)?"needs-input":n?"waiting":"building"}function RG(){const[e,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
|
|
360
|
-
|
|
361
|
-
${a.trim()}
|
|
362
|
-
|
|
363
|
-
${c}`);const d=new Blob([c],{type:"text/markdown"}),u=URL.createObjectURL(d),p=document.createElement("a");p.href=u,p.download=i.filename,document.body.appendChild(p),p.click(),document.body.removeChild(p),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{...e,sendTranscript:s,reset:r}}function EG(e,n){var o;const s="feedback@codeyam.com",r=encodeURIComponent(`CodeYam Session Feedback: ${e||"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(`
|
|
364
|
-
|
|
365
|
-
`));return`mailto:${s}?subject=${r}&body=${a}`}const AG=["bug","suggestion","question","praise"];function CP({featureName:e,onClose:n}){const[s,r]=l.useState(""),[a,o]=l.useState(null),[i,c]=l.useState(!1),{loading:d,error:u,downloaded:p,sendTranscript:h}=RG(),f=l.useCallback(()=>{h(s)},[h,s]),m=l.useCallback(()=>{navigator.clipboard.writeText("feedback@codeyam.com").then(()=>{c(!0),setTimeout(()=>c(!1),2e3)})},[]),g=l.useCallback(x=>{o(b=>b===x?null:x)},[]);return t.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-xl",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",boxShadow:"0 24px 64px rgba(0,0,0,.5)"},children:[t.jsx("h2",{className:"text-[17px] font-semibold text-[var(--text-primary)] mb-1.5",children:"Send feedback"}),t.jsx("p",{className:"text-[13px] leading-relaxed text-[var(--text-muted)] mb-5",children:"Tell the CodeYam team what happened. Your session transcript downloads so you can attach it, which helps us see exactly what went on."}),t.jsxs("div",{className:"mb-4",children:[t.jsx("span",{className:"block text-[12px] font-medium text-[var(--text-secondary)] mb-2",children:"What kind of feedback?"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:AG.map(x=>{const b=a===x;return t.jsx("button",{type:"button","aria-pressed":b,onClick:()=>g(x),className:`px-3 py-1.5 rounded-full text-[12.5px] font-medium capitalize transition cursor-pointer ${b?"":"hover:bg-white/[0.1] hover:text-[var(--text-primary)]"}`,style:{background:b?"var(--accent-active)":"rgba(255,255,255,.06)",color:b?"var(--bg-deep)":"var(--text-secondary)",border:`1px solid ${b?"var(--accent-active)":"rgba(255,255,255,.14)"}`},children:x},x)})})]}),t.jsxs("label",{className:"block mb-5",children:[t.jsx("span",{className:"block text-[12px] font-medium text-[var(--text-secondary)] mb-2",children:"Your feedback"}),t.jsx("textarea",{value:s,onChange:x=>r(x.target.value),placeholder:"What happened, what you expected, or what you'd like to see",className:"w-full h-28 px-3 py-2.5 text-[13px] leading-relaxed rounded-lg resize-none outline-none transition border border-white/[0.18] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:shadow-[0_0_0_3px_rgba(215,255,99,.12)]",style:{background:"#161616",color:"var(--text-primary)"}})]}),u&&t.jsx(dt,{text:u,className:"text-sm text-red-400",rowClassName:"mb-3"}),t.jsxs("div",{className:"flex flex-col gap-3",children:[p?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-green-400 text-center",children:"Transcript downloaded"}),t.jsx("a",{href:EG(e,{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"}),t.jsx("button",{onClick:m,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"}),t.jsx("p",{className:"text-xs text-[var(--text-dim)] text-center",children:"Attach the downloaded file to your email"})]}):t.jsx("button",{onClick:f,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"}),t.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:p?"none":"1px solid var(--border-default)"},type:"button",children:p?"Done":"Cancel"})]})]})}const Hoe=Object.freeze(Object.defineProperty({__proto__:null,SendTranscriptModal:CP},Symbol.toStringTag,{value:"Module"}));function TP({sha:e,onClick:n}){if(!e)return null;const s=e.slice(0,6),r="font-mono text-[11px] leading-none py-0.5 text-[var(--text-dim)] hover:text-[var(--text-secondary)] transition-colors";return t.jsx("div",{className:`fixed z-30 ${n?"":"pointer-events-none"}`,style:{left:8+cn,bottom:9,paddingBottom:"env(safe-area-inset-bottom)"},children:n?t.jsx("button",{type:"button",onClick:n,"data-testid":"build-sha-badge",title:e,"aria-label":`Build commit ${e}`,className:`cursor-pointer ${r}`,children:s}):t.jsx("span",{"data-testid":"build-sha-badge",title:e,"aria-label":`Build commit ${e}`,className:r,children:s})})}const qoe=Object.freeze(Object.defineProperty({__proto__:null,BuildShaBadge:TP},Symbol.toStringTag,{value:"Module"}));function MG(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/raw-terminal`}function PP(){if(Zt())return t.jsx(Td,{});const e=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]=Zu(1200);function u(p){const h=r.current;(h==null?void 0:h.readyState)===WebSocket.OPEN&&h.send(new TextEncoder().encode(p))}return rd(e,()=>{if(s.current&&n.current){if(!Or(n.current,e.current))return;s.current.fit();const p=r.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&p.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))}}),l.useEffect(()=>{if(!e.current||a.current)return;a.current=!0;const p=new ad.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),h=new od.FitAddon;p.loadAddon(h),p.open(e.current),n.current=p,s.current=h;const f=id(p,e.current,{onCopy:()=>d()}),m=ld(p,{sendInput:u});requestAnimationFrame(()=>{Or(p,e.current)&&h.fit(),p.focus()});const g=new WebSocket(MG());return r.current=g,g.binaryType="arraybuffer",g.onmessage=x=>{x.data instanceof ArrayBuffer&&p.write(new Uint8Array(x.data))},g.onopen=()=>{g.send(JSON.stringify({type:"resize",cols:p.cols,rows:p.rows}))},g.onclose=()=>{i(!0),p.writeln(`\r
|
|
366
|
-
\x1B[90m[Shell session ended]\x1B[0m`)},p.onData(u),()=>{var x;(x=r.current)==null||x.close(),m(),f(),p.dispose(),a.current=!1}},[]),t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[t.jsx("div",{ref:e,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var p;return(p=n.current)==null?void 0:p.focus()}}),o&&t.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&&t.jsx(di,{})]})}const Uoe=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalEmulator:PP},Symbol.toStringTag,{value:"Module"}));function OP({isOpen:e,onClose:n}){return l.useEffect(()=>{if(!e)return;const s=r=>{r.key==="Escape"&&n()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,n]),e?t.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:t.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:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border-default)]",children:[t.jsx("h2",{id:"raw-terminal-modal-title",className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Terminal"}),t.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:"✕"})]}),t.jsx("div",{className:"flex-1 flex flex-col",style:{minHeight:0},children:t.jsx(PP,{})})]})}):null}const Goe=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalModal:OP},Symbol.toStringTag,{value:"Module"}));function IG(){const[e,n]=l.useState(!1),[s,r]=l.useState(null),[a,o]=l.useState(null),i=l.useRef(0),{claimDesignDrop:c,designDropLabel:d}=SE(),u=l.useRef(c);u.current=c,l.useEffect(()=>{if(a===null)return;const f=window.setTimeout(()=>o(null),iE);return()=>window.clearTimeout(f)},[a]);const p=l.useCallback(()=>r(null),[]),h=l.useCallback(async f=>{if(f.length!==0){for(const m of f)if(m.size>Lh){o(`${m.name} is larger than the ${Lh/(1024*1024)} MB cap`);return}try{const m=await Promise.all(f.map(async y=>({filename:y.name||"unnamed",contentBase64:await lE(y)}))),g=await fetch("/api/editor-upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:m})});if(!g.ok){const y=await g.json().then(v=>v.error).catch(()=>null);throw new Error(y??`Upload failed: ${g.status}`)}const b=(await g.json()).written??[];if(b.length===0)throw new Error("Upload returned no saved files");r(b)}catch(m){o(m instanceof Error?m.message:String(m))}}},[]);return l.useEffect(()=>{const f=y=>{var v,j;return!!((j=(v=y.dataTransfer)==null?void 0:v.types)!=null&&j.includes("Files"))},m=y=>{f(y)&&(y.preventDefault(),i.current+=1,n(!0))},g=y=>{f(y)&&y.preventDefault()},x=y=>{f(y)&&(i.current=Math.max(0,i.current-1),i.current===0&&n(!1))},b=y=>{var j;if(!f(y))return;if(y.defaultPrevented){i.current=0,n(!1);return}if(y.preventDefault(),i.current=0,n(!1),y.dataTransfer&&u.current(y.dataTransfer))return;if(y.dataTransfer&&cE(y.dataTransfer)){o("Folder drops are not supported — drag individual files instead");return}const v=Array.from(((j=y.dataTransfer)==null?void 0:j.files)??[]).filter(_=>_.size>0);h(v)};return window.addEventListener("dragenter",m),window.addEventListener("dragover",g),window.addEventListener("dragleave",x),window.addEventListener("drop",b),()=>{window.removeEventListener("dragenter",m),window.removeEventListener("dragover",g),window.removeEventListener("dragleave",x),window.removeEventListener("drop",b)}},[h]),{dragActive:e,pendingPaths:s,error:a,clearPending:p,uploadFiles:h,designDropLabel:d}}function RP({visible:e,destinationLabel:n=null}){if(!e)return null;const s=n!==null;return t.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:t.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:[t.jsx("span",{className:"text-2xl font-semibold text-[var(--text-primary)]",children:s?`Drop to add ${n}`:"Drop files to add them to this session"}),t.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:s?"Saved to your project's design assets":"Saved to .codeyam/uploads/ — then hand them to the agent"})]})})}const Yoe=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropOverlay:RP},Symbol.toStringTag,{value:"Module"}));function EP({message:e}){return t.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:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:e}),t.jsx(mt,{variant:"icon",text:e})]})})}const Voe=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropToast:EP},Symbol.toStringTag,{value:"Module"}));function AP({paths:e,onClose:n}){const{sendToAgent:s,agentReady:r}=No(),[a,o]=l.useState(!1),i=l.useCallback(p=>{p.key==="Escape"&&(p.preventDefault(),n())},[n]);l.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]);const c=e.map(dE).join(" "),d=l.useCallback(()=>{s(c+" ")&&n()},[s,c,n]),u=l.useCallback(()=>{var p;(p=navigator.clipboard)==null||p.writeText(c).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{})},[c]);return t.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",onMouseDown:p=>{p.target===p.currentTarget&&n()},children:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:e.length===1?"File added":`${e.length} files added`}),t.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Saved to your project, but the agent hasn't been told about"," ",e.length===1?"it":"them"," yet. Hand the path",e.length===1?"":"s"," over so it can read"," ",e.length===1?"it":"them","."]}),t.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:e.map(p=>t.jsx("li",{className:"truncate py-0.5",children:p},p))}),!r&&t.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."}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.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"}),t.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"}),t.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"})]}),t.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Escape closes · files stay in .codeyam/uploads/"})]})})}const Koe=Object.freeze(Object.defineProperty({__proto__:null,FileDropConfirmModal:AP},Symbol.toStringTag,{value:"Module"}));let gl=null;function DG(e){if(typeof e!="object"||e===null)return null;const n=e.buildCommitSha;return typeof n!="string"||n===""||n==="unknown"?null:n}async function LG(){try{const e=await fetch("/api/health");return e.ok?DG(await e.json()):null}catch{return null}}function $G(){const[e,n]=l.useState(null);return l.useEffect(()=>{let s=!0;return gl||(gl=LG()),gl.then(r=>{s&&n(r)}),()=>{s=!1}},[]),{sha:e}}function FG({previewSlug:e,previewUrl:n,setPreviewPath:s,showScenarioPreview:r,showPreviewPane:a,releasePreviewPane:o}){const[i,c]=l.useState(null),d=l.useRef({slug:null,path:""});d.current={slug:e,path:n};const u=l.useRef(null),p=l.useCallback(m=>{$s(d.current.path)!==br&&(u.current=d.current),c(m),s(br),a()},[s,a]),h=l.useCallback(m=>{Ja(`The ${m.envVar} value has been saved (available to the app as ${m.envVar}).`)},[]),f=l.useCallback(()=>{const m=u.current;if(u.current=null,c(null),o(),m!=null&&m.slug){r(m.slug);return}const g=m?$s(m.path):"";s(g&&g!==br?g:null)},[o,s,r]);return{credentialTarget:i,openCredentialRequest:p,handleCredentialStored:h,handleCloseCredentialRequest:f}}const zG=1/3;function BG(){var Ch,Th,Ph;yG();const{sha:e}=$G(),n=kE(),{state:s,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,shellShare:u,probeInFlight:p,probeAttempts:h,backendFieldAbsent:f,refresh:m}=sd(),{update:g}=uG(),{sessionInfo:x,refetch:b}=vp({pollIntervalMs:15e3}),y=(x==null?void 0:x.agentBrokerLive)??!1,v=QU(s,y),{activeTab:j,buildActivated:_,planActivated:S,navigateToTab:w,deactivateBuild:k}=Ip(n,v,s==="needs-login"&&!y),[N,C]=l.useState(!1),[T,P]=l.useState(!1),R=l.useCallback(()=>{C(!0),P(!1)},[]),{arm:L,navigateToTabUser:M,pendingBuildNav:O}=pG(v,w,R),[z,I]=l.useState(null),{visible:Y,dismiss:W}=Wq(z),A=l.useCallback(()=>{P(!0),I(Date.now()),w("build")},[w]);l.useEffect(()=>{if(!T)return;const Z=setTimeout(()=>P(!1),6e4);return()=>clearTimeout(Z)},[T]);const B=l.useCallback(()=>M("build"),[M]),[D,J]=l.useState(!1),[te,oe]=l.useState(!1),se=Zt(),[G,le]=l.useState(se),ue=l.useRef(!1),ne=l.useCallback(()=>le(!0),[]),[E,H]=l.useState(se),[U,pe]=l.useState(0),[ge,Me]=l.useState(0),[Ce,De]=l.useState(0),[Be,X]=l.useState(0),[Q,re]=l.useState(0),{showPostPushModal:ce,featureSummary:_e,onFeatureCompleteCommand:Te,onAgentIdle:Oe,onAgentActive:he,dismissModal:xe}=PU(),Fe=l.useCallback(()=>{xe(),fetch("/api/cycle-closed-ack",{method:"POST"}).catch(()=>{})},[xe]),{showPlanCompleteModal:F,onPlanCompleteCommand:ee,dismissPlanCompleteModal:de}=AU(),[ie,fe]=l.useState(!1),[ve,be]=l.useState(!1),[We,ze]=l.useState(!1),[Re,Ye]=l.useState(!1),[rt,je]=l.useState(!1);l.useEffect(()=>{const Z=()=>je(!0);return window.addEventListener(mc,Z),()=>window.removeEventListener(mc,Z)},[]);const[Ve,Se]=l.useState(!1),Qe=l.useCallback(()=>{ze(!0)},[]),K=l.useCallback(()=>{ze(!1)},[]),{plans:V,loading:we,error:Ue,refetch:Ge}=qr(),{plans:gt}=hd(),{reorderPlans:at}=wN(Ge),{launchPrompt:it,launching:Je,error:xt}=IU(),[He,jt]=l.useState(null),{stepState:q,refetch:Ft}=ca();OU({showPostPushModal:ce,stepState:q,dismissModal:Fe}),RU({sessionInfo:x,stepState:q,showPostPushModal:ce,onFeatureCompleteCommand:Te});const Et=l.useMemo(()=>EU(ce,q),[ce,q]),wt=l.useRef(null),[es,Pn]=l.useState(!1),{leftWidth:en,handleMouseDown:Ct,isDragging:ts,resetWidth:On,nudgeWidth:Rn,minWidth:tn}=gG(wt,es?zG:.5),nn=YS(768),[At,En]=l.useState("editor"),pn=l.useCallback(Z=>{En(Z),Z==="editor"&&(Tt(),typeof window<"u"&&window.dispatchEvent(new Event("resize")))},[]),[qe,lt]=l.useState(!1),Xe=j==="home";l.useEffect(()=>{!Xe&&qe&<(!1)},[Xe,qe]);const{entityLookup:hn}=dU(),{groups:fn,loading:ns,refreshing:sn,currentRunner:Zs,coverage:er,refresh:ae}=Kq(),{groups:ke,loading:Ze,reload:_t}=Lq(),{routeEntities:ws,unsurfacedPages:MP,componentSurfaceReason:IP,loading:DP,refreshing:LP,error:$P}=zq(),{config:ye,apps:mn,loading:ha,refetch:_s}=Pt(),FP=T2(),ss=l.useMemo(()=>$U(mn,fn,ke),[mn,ke,fn]),{saved:zP}=h0(),eh=f0({appStatsLength:ss.length,configLoading:ha,scenariosLoading:Ze,setupAnswersSaved:zP,hasStepState:!!q}),ji=Xe&&!qe&&!eh||j==="chat",BP=nn||ji?((Ch=wt.current)==null?void 0:Ch.clientWidth)??(typeof window<"u"?window.innerWidth:en):en,WP=l.useCallback(()=>{J(Z=>!Z)},[]),HP=l.useCallback(()=>{oe(Z=>!Z)},[]),{selectedApp:rs,appRouteEntities:th,appTestGroups:qP,selectedEntityHash:UP,selectedRouteEntity:nh,previewSlug:Ss,setPreviewSlugExplicit:GP,selectApp:wi,deselectApp:_i,selectRoute:Si,selectEntity:YP,deselectRoute:VP}=iU(mn,ws,ke,fn,n,(ye==null?void 0:ye.defaultScreenSize)??null,E,ue),{viewports:KP,resolvedViewport:tr,previewUrl:ki,handleViewportChange:JP,handleCustomSizeChange:Ni,showScenarioPreview:ks,handlePreviewCommand:St,setPreviewPath:An,previewSeeding:XP,previewSeedError:QP,previewSeedErrorKind:ZP,retrySeed:eO,commandNonce:tO}=jU({apps:mn,appRouteEntities:th,configLoaded:!ha,hydrated:G,port:(ye==null?void 0:ye.port)??5173,previewMedium:FP.kind,previewOrigin:Wl(ye,rs),projectTitle:(ye==null?void 0:ye.projectTitle)??null,routeEntities:ws,screenSizes:(ye==null?void 0:ye.screenSizes)??{},defaultScreenSize:(ye==null?void 0:ye.defaultScreenSize)??null,scenarioGroups:ke,scenariosLoaded:!Ze,selectedApp:rs,selectedRouteEntity:nh,previewSlug:Ss,setPreviewSlug:GP}),Ci=l.useRef(!1),nO=l.useCallback(()=>{En("preview"),J(!1),Xe&&!qe&&(Ci.current=!0,lt(!0))},[Xe,qe]),sO=l.useCallback(()=>{Ci.current&&(Ci.current=!1,lt(!1))},[]),{credentialTarget:rO,openCredentialRequest:sh,handleCredentialStored:aO,handleCloseCredentialRequest:oO}=FG({previewSlug:Ss,previewUrl:ki,setPreviewPath:An,showScenarioPreview:ks,showPreviewPane:nO,releasePreviewPane:sO});l.useEffect(()=>{Xe&&qe&&tr.name==="Desktop"&&oe(!0)},[Xe,qe,tr.name]);const{isAgentBuilding:Ut,isAgentBuildingRef:Ti,buildingScenarioSlug:Pi,onAgentIdle:rh,onAgentActive:ah,guardScenarioSelect:oh,clearBuildingOverlay:rn,forceIdle:ih}=DU({onTransitionToLive:ks}),{planActive:lh,planIdle:ch}=LU({chatOpen:ie}),nr=(x==null?void 0:x.resumeMode)==="resume"||(x==null?void 0:x.resumeMode)==="handoff",{launchPlan:sr,launchingSlug:fa,error:iO}=xN({launchAnchored:nr||!!(q!=null&&q.feature)}),{buildSessionLive:dh,agentActivelyBuilding:rr,transitionBuildSessionLive:as}=TG({isAgentBuilding:Ut,submittingBuildPrompt:Je,launchingPlanSlug:fa,sessionInfo:x,stepFeature:(q==null?void 0:q.feature)??null,refetchSessionInfo:b}),Oi=si(),lO=hG({buildRequestState:(Oi==null?void 0:Oi.state)??null,buildSessionLive:dh,agentActivelyBuilding:rr,hasCurrentStep:(x==null?void 0:x.step)!=null,hasSavedSession:!!(x!=null&&x.hasSession)&&(x==null?void 0:x.resumeMode)!=="completed",brokerReachable:(x==null?void 0:x.brokerDaemonReachable)??null,pendingBuildNavArmed:O||T});l.useEffect(()=>{Ut&&x&&!x.hasSession&&!x.agentBrokerLive&&ih()},[Ut,x,ih]),l.useEffect(()=>{gi({hasActiveSession:nr,isAgentBuilding:Ut,stepStateFeature:(q==null?void 0:q.feature)??null})},[nr,Ut,q==null?void 0:q.feature]),l.useEffect(()=>{const Z=ye==null?void 0:ye.projectTitle;document.title=typeof Z=="string"&&Z.length>0?`CodeYam: ${Z}`:"CodeYam"},[ye==null?void 0:ye.projectTitle]);const cO=l.useCallback(()=>{Oe(),rh()},[Oe,rh]),dO=l.useCallback(()=>{he(),ah()},[he,ah]),uh=(ye==null?void 0:ye.provider)??uE,ph=st(uh),{buildIdle:ma,agentBlocked:uO,bannerVisible:pO,notifSettings:hh,handleSettingsChange:fh,handleAgentIdle:hO,handleAgentBlocked:fO,handleAgentActive:mO,handleUserInput:gO,handleNavigateToTab:mh,dismissIdleBanner:xO,clearIdleForStopBuilding:ga}=NG({agentName:ph,isBuildTabActive:j==="build",isAgentBuilding:Ut,buildSessionLive:dh,featureCompleteKey:Ce,navigateToTab:M,onAgentIdleImmediate:cO,onAgentActiveImmediate:dO}),bO=l.useMemo(()=>OG(q==null?void 0:q.slug,ma,Ut),[q==null?void 0:q.slug,ma,Ut]),gh=q?C0(q.step,q.mode):null,xh=l.useMemo(()=>zU(q==null?void 0:q.step,q==null?void 0:q.mode),[q==null?void 0:q.step,q==null?void 0:q.mode]),bh=q?BU(q.step,q.mode):null,yO=((Th=gt[0])==null?void 0:Th.title)??null,yh=l.useMemo(()=>{const Z=Date.parse((q==null?void 0:q.featureStartedAt)||(q==null?void 0:q.startedAt)||"");return Number.isNaN(Z)?null:Z},[q==null?void 0:q.featureStartedAt,q==null?void 0:q.startedAt]),vO=l.useMemo(()=>WU(ke.flatMap(Z=>Z.scenarios),yh),[ke,yh]),{claimsBySlug:jO,staleFetch:wO,annotationsBySlug:_O,dependenciesBySlug:SO,showAuthors:kO,requestRun:vh,gateModals:NO}=MU({plans:V,completedPlans:gt,isAgentBuilding:rr,onLaunch:Z=>{var Gt;const tt=((Gt=V.find(Oh=>Oh.slug===Z))==null?void 0:Gt.title)??Z;sr(Z,tt,"home-queue")}}),xa=l.useCallback(Z=>{jt(null),!oh(Z)&&(ks(Z),Xe&<(!0))},[oh,ks,Xe]);l.useEffect(()=>{KA(ke.flatMap(Z=>Z.scenarios.map(tt=>tt.slug)))},[ke]),l.useEffect(()=>(Uh(xa),()=>Uh(null)),[xa]);const CO=l.useCallback(Z=>{const tt=ZU(Z.name,ke),Gt=rG({shot:{name:Z.name,screenshotPath:Z.screenshotPath},isLatest:Z.isLatest,liveScenario:tt,isAgentBuilding:Ut});if(Gt.kind==="live"){jt(null),ks(Gt.slug);return}jt({screenshotPath:Gt.screenshotPath,scenarioName:Gt.scenarioName,heading:Gt.heading,subtext:Gt.subtext})},[Ut,ke,ks]),TO=l.useCallback(()=>{jt(null)},[]),gn=l.useMemo(()=>ed(Pi,ke),[Pi,ke]),PO=((Ph=gn==null?void 0:gn.screenshotPaths)==null?void 0:Ph[0])??null,OO=(gn==null?void 0:gn.name)??null,RO=(gn==null?void 0:gn.description)??null,jh=l.useCallback(()=>w("plan"),[w]),bt=oG(jh),EO=l.useSyncExternalStore(IS,MS),Ns=Uq({building:rr,build:{label:(q==null?void 0:q.feature)??null,status:bO},activity:bt.activity,chatNeedsYou:EO}),[wh,ba]=l.useState(!1);cG({buildActivity:bt,sessionInfo:x,buildSessionOwnsTab:nr||!!(q!=null&&q.feature),chatEscalatedToPrototype:wh,setChatEscalatedToPrototype:ba});const AO=l.useCallback(Z=>{switch(Z.type){case"preview":("scenarioSlug"in Z||"scenarioId"in Z)&&_t(),St(Z);break;case"showResults":rn(),_t(),pe(tt=>tt+1),(q==null?void 0:q.mode)==="backend"&&St({path:"/results",dimension:"Desktop"});break;case"hideResults":Me(tt=>tt+1);break;case"featureComplete":rn(),Te({title:Z.title,summary:Z.summary,severeWarnings:Z.severeWarnings,proposedPlans:Z.proposedPlans}),De(tt=>tt+1),_s(),Ft(),wg({isAgentBuilding:Ti.current,trigger:"feature-complete",transitionBuildSessionLive:as});break;case"planComplete":ee(),re(tt=>tt+1),_s(),wg({isAgentBuilding:Ti.current,trigger:"plan-complete",transitionBuildSessionLive:as});break;case"launchPlan":sr(Z.slug,Z.title,"launch-plan-command"),X(tt=>tt+1),ba(!1);break;case"buildActivity":Z.activity==="prototype"?ba(!0):Z.activity==="menu"&&ba(!1),bt.applyCommand(Z.activity);break;case"requestCredential":sh({serviceName:Z.serviceName,envVar:Z.envVar,topic:Z.topic,docsUrl:Z.docsUrl,instructions:Z.instructions});break}},[rn,St,Ti,sr,Te,ee,_s,Ft,sh,_t,q,as]);cU(AO,l.useCallback(()=>{window.location.reload()},[]));const ya=(q==null?void 0:q.slug)==="ui-confirm-plan"||(q==null?void 0:q.slug)==="backend-confirm-plan",Ri=l.useRef(null);l.useEffect(()=>{if(!q||!ya){Ri.current=null;return}Ri.current!==q.step&&(Ri.current=q.step,St({path:"/plan-preview",dimension:"Desktop"}))},[q,ya,St]);const Ei=l.useRef(null);l.useEffect(()=>{if(!q||q.mode!=="backend"||q.step<2||ya){Ei.current=null;return}Ei.current!==q.step&&(Ei.current=q.step,St({path:"/results",dimension:"Desktop"}))},[q,ya,St]);const Ai=l.useRef(!1);l.useEffect(()=>{(q==null?void 0:q.slug)==="ui-confirm-plan"?Ai.current=!0:Ai.current&&(Ai.current=!1,An(null))},[q,An]);const Mi=$s(ki),va=Mi==="/design-exploration",ja=eh&&va;l.useEffect(()=>{Pn(ja)},[ja]);const[MO,IO]=l.useState(0),DO=l.useCallback(()=>IO(Z=>Z+1),[]),wa=l.useCallback(()=>{fetch("/api/editor-design-active-tab",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tab:"mockups"})}).catch(()=>{}),W(),An("/design-exploration")},[W,An]);Hq({isDesignViewShowing:Mi==="/design-exploration"||Mi==="/design-round",onOpen:wa});const Ii=l.useCallback(()=>An(null),[An]),LO=l.useCallback(()=>va?Ii():wa(),[va,Ii,wa]),$O=l.useCallback(()=>{C(!0),bt.startSession(),Fe(),Tt()},[Fe,bt]),Di=l.useCallback(async()=>{window.dispatchEvent(new CustomEvent("build-session-stopped")),await f8(),Fe(),w("home"),k(),as(!1,"stop-building"),rn(),ga(),C(!1),b()},[Fe,w,k,as,rn,ga,b]);l.useEffect(()=>{const Z=()=>{Di().then(()=>{window.setTimeout(()=>w("build"),0)})};return window.addEventListener(gc,Z),()=>window.removeEventListener(gc,Z)},[Di,w]);const FO=l.useCallback(async()=>{Se(!0),window.dispatchEvent(new CustomEvent("build-session-stopped")),await m8(),Se(!1),je(!1),w("home"),k(),as(!1,"reset-everything"),rn(),ga(),C(!1),b()},[w,k,as,rn,ga,b]),zO=l.useCallback(()=>{fe(!0),jg(),de(),Tt()},[de]),BO=l.useCallback(()=>{fe(!0),de(),Tt()},[de]),WO=l.useCallback(()=>{de(),jg().finally(()=>{fe(!1),vG()})},[de]),HO=l.useCallback(()=>{be(!0)},[]),qO=l.useCallback(()=>{be(!1)},[]),UO=l.useCallback(async(Z,tt,Gt)=>{await sr(Z,tt,Gt)&&(be(!1),C(!0),bt.startSession(),Fe(),b())},[sr,Fe,b,bt]),GO=l.useCallback(async Z=>{await it(Z)&&(C(!0),Fe(),b())},[it,b,Fe]),Li={hasActiveSession:nr,isAgentBuilding:Ut,showPostPushModal:ce,launchingPlanSlug:fa,submittingBuildPrompt:Je,stepStateFeature:(q==null?void 0:q.feature)??null,buildLaunchModalDismissed:N,buildActivityInFlight:bt.activity!=="menu",buildActivityMinimized:bt.minimized,buildHandoffPending:T},YO=wP(Li),_h=_P({activeTab:j,...Li}),VO=aG({activeTab:j,...Li}),KO=_h||ve;l.useEffect(()=>{j==="build"&&b()},[j,b]),l.useEffect(()=>{j==="home"&&(_s(),m())},[j,_s,m]);const JO=l.useCallback(async(Z,tt)=>{rn(),St(XU(Z,tt))},[rn,St]),XO=l.useCallback(Z=>{St({...Z.scenarioSlug?{scenarioSlug:Z.scenarioSlug}:{},...Z.path?{path:Z.path}:{},...Z.dimension?{dimension:Z.dimension}:{}})},[St]),{requestRestore:QO,onAdoptSettledEmpty:Sh}=NU({restoredRef:ue,initiallySettled:se,apply:XO}),kh=l.useCallback(Z=>{TU(Z,{handlePreviewCommand:St,handleCustomSizeChange:Ni})},[Ni,St]),ZO=l.useCallback(()=>{Sh(),H(!0)},[Sh]);wU({isInIframe:se,scenariosLoaded:!Ze,restoredRef:ue,onAdopt:kh,onHydrated:ne,onSettledEmpty:ZO});const eR=l.useCallback(Z=>{St({scenarioSlug:Z}),lt(!0)},[St]);CU({scenariosLoaded:!Ze,restoredRef:ue,apply:eR,onSettled:()=>H(!0)}),_U({isInIframe:se,onConverge:kh}),kU(se);const tR=l.useMemo(()=>({apps:mn,isSingleApp:mn.length===1,onSelectApps:_i,onSelectApp:wi,onSelectRoute:Si}),[mn,_i,wi,Si]),nR=l.useMemo(()=>rs?ss.find(Z=>Z.app.dir===rs.dir)??null:null,[ss,rs]),sR=t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"12px 28px 0"},children:t.jsx(Ep,{staleness:null,backendOutOfDate:f})}),t.jsx("div",{style:{padding:"12px 28px 0"},children:t.jsx(NP,{update:g})}),t.jsx(SP,{state:s,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,shellShare:u,probeInFlight:p,probeAttempts:h,backendOutOfDate:f,sessionOngoing:y,onAuthenticated:m,onAuthorized:B}),t.jsx(rN,{notificationBanner:ss.length>0?t.jsx(u0,{settings:hh,onChange:fh,providerLabel:ph}):null,selectedApp:rs,projectTitle:(ye==null?void 0:ye.projectTitle)??null,admin:(ye==null?void 0:ye.admin)??!1,isBuilding:Ns.active,buildingLabel:Ns.label,buildingStepLabel:gh,buildingStepPosition:bh,buildingStatus:Ns.status,buildingProgress:xh,lastBuiltLabel:yO,buildingThumbnailPath:vO,plans:V,plansLoading:we,plansError:Ue,onRunPlan:vh,launchingSlug:fa,planDepAnnotationsBySlug:_O,planDependenciesBySlug:SO,planClaimsBySlug:jO,planStaleFetch:wO,showPlanAuthors:kO,onNavigateToPlan:()=>w("plan"),onNavigateToBuild:()=>M("build"),onResetBuild:()=>je(!0),onBackToProjects:mn.length>1?_i:void 0,launcherUrl:(ye==null?void 0:ye.launcherUrl)??null,projectCount:(ye==null?void 0:ye.projectCount)??0,onOpenSetupBrowser:ye!=null&&ye.setupBrowserEnabled?()=>St({path:"/setup-browser",dimension:"Desktop"}):void 0,appDetailProps:{navContext:tR,routeEntities:th,unsurfacedPages:MP,componentSurfaceReason:IP,routesLoading:DP,routesRefreshing:LP,routesError:$P,selectedEntityHash:UP,selectedRouteEntity:nh,testGroups:qP,selectedSlug:Ss,entityLookup:hn,allScenarios:ke.flatMap(Z=>Z.scenarios),onSelectScenario:xa,onSelectRoute:Si,onSelectEntity:YP,onBackToRoutes:VP,onScenariosChanged:_t,coverage:er,showProjectBand:mn.length===1,stats:nR,testsLoading:ns,testsRefreshing:sn,onRunTests:ae,currentRunner:Zs},appOverviewProps:{projectTitle:(ye==null?void 0:ye.projectTitle)??"Project",projectDescription:(ye==null?void 0:ye.projectDescription)??null,stats:ss,coverage:er,onSelectApp:wi,configLoading:ha,scenariosLoading:Ze,testsLoading:ns,testsRefreshing:sn,onRunTests:ae,currentRunner:Zs,stepState:q,onPreviewUrl:An,onComplete:async()=>{await _s(),console.info("[EditorShell] questionnaire complete; arming pending build-nav",{providerAuthState:s,buildBlocked:v}),L()},onOpenBuildTab:()=>M("build"),isBuilding:Ns.active,buildingLabel:Ns.label,buildingStepLabel:gh,buildingStepPosition:bh,buildingStatus:Ns.status,buildingProgress:xh,onResetBuild:()=>je(!0),emptyStateBuildStatus:lO,skipDesignSignal:MO}})]}),rR=ss.some(Z=>JU(Z.app.type)),aR=ke.reduce((Z,tt)=>Z+tt.scenarios.length,0),Nh=!!q&&!Ze&&aR===0,oR=uP(),Mn=IG();return t.jsx(pE,{children:t.jsxs(hE,{fallbackUpload:Mn.uploadFiles,children:[t.jsx(kP,{}),t.jsx(lN,{splitRef:wt,isCollapsed:D,hidePreview:ji,onHomeLivePageBack:Xe&&qe?()=>lt(!1):void 0,onResizeStart:Ct,onResizeReset:On,onResizeNudge:Rn,isResizing:ts,leftWidth:en,leftWidthMin:tn,isNarrow:nn,mobilePane:At,onMobilePaneChange:pn,isAgentBuilding:rr,buildIdle:ma,leftPane:t.jsx(N2,{activeTab:j,onSendTranscript:Qe,appTabContent:sR,awaitingPlanLaunchChoice:KO,buildActivated:_,planActivated:S,buildIdle:ma,agentBlocked:uO,isAgentBuilding:rr,planActive:lh,planIdle:ch,bannerVisible:pO,onDismissIdleBanner:xO,hideResultsCommandKey:ge,leftWidth:BP,fullWidth:nn||ji,navigateToTab:mh,onAgentActive:mO,onAgentIdle:hO,onAgentBlocked:fO,onUserInput:gO,notifSettings:hh,onSettingsChange:fh,provider:uh,onRestorePreview:QO,onResultsScenarioSelect:JO,previewSlug:Ss,featureCycleComplete:Et,featureSummary:_e,onContinueInSession:$O,onStopBuilding:Di,showResultsCommandKey:U,planChatOpen:ie,onPlanChatOpenChange:fe,showPlanCompleteModal:F,onCreateNewPlan:zO,onContinueSession:BO,onViewPlans:WO,pendingPlans:V,onSelectPlan:HO,selectPlanOpen:ve,onPickPlan:UO,onCancelSelectPlan:qO,launchingPlanSlug:fa,planLaunchError:iO,prototypeLaunchSignal:Be,planCompleteSignal:Q,showBuildLaunchModal:_h,buildLaunchGateArmed:YO,buildActivity:bt.activity,buildActivityMinimized:bt.minimized,chatEscalatedToPrototype:wh,onChooseActivity:bt.chooseActivity,onNavigateToPlanTab:jh,onToggleDesigns:LO,designsOpen:va,onActivityDone:bt.finishActivity,onPrototypeLaunched:bt.startSession,onMinimizeActivityModal:bt.hasLiveActivity?bt.minimize:void 0,onReopenActivityModal:VO?bt.reopen:void 0,onSubmitBuildPrompt:GO,submittingBuildPrompt:Je,buildPromptError:xt,pendingPlansLoading:we,pendingPlansError:Ue,onReorderPlans:at,buildDisabled:v,onPreviewScreenshot:CO,onRunHistoryPlan:vh,projectTitle:(ye==null?void 0:ye.projectTitle)??null,designSession:ja}),previewPane:t.jsx(fP,{emptyStateMessage:VU({configLoading:ha,hasNoApps:ss.length===0,hasStepState:!!q,hasPreviewableApp:rR,setupInProgress:Nh,hasCaptureFrame:oR.available}),projectSetupInProgress:Nh,previewSlug:Ss,previewUrl:ki,viewports:KP,activeViewport:tr.name,onViewportChange:JP,isCollapsed:D,onToggleCollapsed:WP,isNarrow:nn,onBack:Xe&&qe?()=>lt(!1):void 0,onPlanChange:Xe&&qe?()=>mh("plan"):void 0,isFilled:te,onToggleFilled:HP,currentWidth:tr.width,currentHeight:tr.height,onCustomSizeChange:Ni,buildingScenarioSlug:Pi,buildingScreenshotPath:PO,buildingScenarioName:OO,buildingScenarioDescription:RO,onDismissBuildingOverlay:rn,historicalScreenshotPath:(He==null?void 0:He.screenshotPath)??null,historicalScenarioName:(He==null?void 0:He.scenarioName)??null,historicalHeading:(He==null?void 0:He.heading)??null,historicalSubtext:(He==null?void 0:He.subtext)??null,onDismissHistoricalPreview:TO,previewSeeding:XP,previewSeedError:QP,previewSeedErrorKind:ZP,onRetrySeed:eO,currentScenario:ed(Ss,ke),scenarioGroups:ke,onShowScenarioPreview:xa,commandNonce:tO,previewOrigin:Wl(ye,rs),onDesignConfirmed:A,onExitDesigns:Ii,designSession:ja,onSkipDesign:DO,designReturnVisible:Y,onOpenDesigns:wa,onDismissDesignReturn:W,credentialTarget:rO,onCredentialStored:aO,onCloseCredentialRequest:oO})}),We?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:t.jsx(CP,{featureName:(q==null?void 0:q.feature)??null,onClose:K})}):null,t.jsx(OP,{isOpen:Re,onClose:()=>Ye(!1)}),t.jsx(TP,{sha:e,onClick:()=>Ye(!0)}),t.jsx(RP,{visible:Mn.dragActive,destinationLabel:Mn.designDropLabel}),Mn.error?t.jsx(EP,{message:Mn.error}):null,Mn.pendingPaths?t.jsx(AP,{paths:Mn.pendingPaths,onClose:Mn.clearPending}):null,rt?t.jsx(mP,{busy:Ve,onCancel:()=>je(!1),onConfirm:()=>void FO(),planSessionActive:lh||ch}):null,NO]})})}const Joe=Object.freeze(Object.defineProperty({__proto__:null,EditorShell:BG},Symbol.toStringTag,{value:"Module"}));export{Ee as $,mre as A,EC as B,Po as C,tC as D,pL as E,AP as F,f7 as G,gC as H,wC as I,Zr as J,fs as K,zn as L,Mj as M,yr as N,B0 as O,Bj as P,OL as Q,fb as R,ow as S,Oo as T,RL as U,EL as V,AL as W,ML as X,ot as Y,ju as Z,zs as _,Vo as a,Id as a$,vw as a0,yu as a1,vu as a2,Rj as a3,Ae as a4,Yg as a5,_l as a6,xx as a7,bx as a8,zg as a9,Ux as aA,Td as aB,Yx as aC,Kx as aD,Xx as aE,Qx as aF,Pd as aG,Zx as aH,Jx as aI,Vx as aJ,Gx as aK,tb as aL,nb as aM,sb as aN,rb as aO,Rd as aP,Od as aQ,ab as aR,ob as aS,ib as aT,lb as aU,eb as aV,db as aW,ub as aX,cb as aY,Nl as aZ,pb as a_,yx as aa,jx as ab,wx as ac,_x as ad,Ug as ae,$g as af,Lg as ag,ro as ah,kx as ai,Io as aj,Nx as ak,Fg as al,Px as am,Ox as an,Rx as ao,Ix as ap,Ex as aq,Ax as ar,Mx as as,Dx as at,Fx as au,Wx as av,kl as aw,qx as ax,Vr as ay,Cd as az,Wa as b,Ry as b$,Dd as b0,gb as b1,Ld as b2,mb as b3,bb as b4,$d as b5,xb as b6,Ab as b7,Mb as b8,Ib as b9,uy as bA,Yb as bB,Jb as bC,Xb as bD,Vb as bE,ay as bF,sy as bG,ny as bH,ty as bI,ey as bJ,Zb as bK,Qb as bL,Da as bM,ry as bN,El as bO,hy as bP,my as bQ,gy as bR,xy as bS,Al as bT,by as bU,yy as bV,Cy as bW,ur as bX,Ty as bY,Py as bZ,Oy as b_,Db as ba,vb as bb,wb as bc,jb as bd,_b as be,Fd as bf,Sb as bg,yb as bh,Cb as bi,Pb as bj,Tb as bk,Lb as bl,$b as bm,Fb as bn,zb as bo,Bb as bp,Wb as bq,Hb as br,Rl as bs,Gb as bt,oy as bu,zx as bv,Hx as bw,dy as bx,iy as by,py as bz,XG as c,Ie as c$,Ey as c0,Ml as c1,Md as c2,My as c3,Ay as c4,Fy as c5,zy as c6,Kd as c7,Ur as c8,Jd as c9,du as cA,Hl as cB,In as cC,za as cD,cs as cE,ls as cF,is as cG,Ln as cH,Jt as cI,Fj as cJ,Lj as cK,zl as cL,Gv as cM,zj as cN,Wj as cO,uu as cP,o1 as cQ,$t as cR,iP as cS,q5 as cT,zw as cU,Fw as cV,$w as cW,y_ as cX,qn as cY,wn as cZ,Pe as c_,By as ca,Do as cb,Kr as cc,Wy as cd,Hy as ce,Gy as cf,Il as cg,Vd as ch,qs as ci,Zy as cj,sv as ck,eu as cl,av as cm,Yd as cn,Iy as co,Dy as cp,Ly as cq,$y as cr,hb as cs,ov as ct,iv as cu,Nv as cv,Tv as cw,Pj as cx,kv as cy,Sv as cz,j_ as d,hv as d$,Vn as d0,NP as d1,Ep as d2,p1 as d3,f1 as d4,vr as d5,$ as d6,LN as d7,yp as d8,c5 as d9,Wo as dA,Fs as dB,di as dC,Rt as dD,Ho as dE,ea as dF,Lw as dG,mu as dH,pt as dI,Ne as dJ,_T as dK,VC as dL,dv as dM,Yo as dN,hL as dO,AC as dP,Ys as dQ,HC as dR,cv as dS,k_ as dT,R_ as dU,O_ as dV,T_ as dW,C_ as dX,N_ as dY,Pu as dZ,Yn as d_,dN as da,Wc as db,BC as dc,Bc as dd,RC as de,_N as df,C2 as dg,GC as dh,MC as di,Q1 as dj,i1 as dk,Bs as dl,l1 as dm,l5 as dn,mT as dp,nC as dq,Qn as dr,h1 as ds,Zn as dt,tu as du,Nt as dv,cu as dw,Xn as dx,Oj as dy,n5 as dz,Ag as e,P0 as e$,pr as e0,UT as e1,nt as e2,hs as e3,qC as e4,uv as e5,QC as e6,XC as e7,ft as e8,Xt as e9,kj as eA,Sj as eB,Tj as eC,Cj as eD,jj as eE,tN as eF,Hd as eG,Y1 as eH,V1 as eI,U1 as eJ,H1 as eK,W1 as eL,z1 as eM,B1 as eN,su as eO,rv as eP,w_ as eQ,__ as eR,yv as eS,bv as eT,jv as eU,vv as eV,vj as eW,R0 as eX,T0 as eY,_0 as eZ,O0 as e_,kn as ea,It as eb,gu as ec,fv as ed,pv as ee,HT as ef,vt as eg,_5 as eh,w5 as ei,N5 as ej,S5 as ek,j5 as el,C5 as em,VT as en,v5 as eo,YT as ep,sP as eq,nP as er,v1 as es,Mv as et,Iv as eu,Av as ev,Ov as ew,Ev as ex,Ot as ey,Nj as ez,gd as f,R2 as f$,w0 as f0,Hg as f1,Iu as f2,Lv as f3,uj as f4,Bl as f5,dj as f6,nu as f7,TP as f8,Nr as f9,T1 as fA,P1 as fB,O1 as fC,M1 as fD,R1 as fE,E1 as fF,D1 as fG,F1 as fH,A1 as fI,L1 as fJ,$1 as fK,da as fL,A2 as fM,q2 as fN,B2 as fO,M2 as fP,I2 as fQ,L2 as fR,$2 as fS,Ec as fT,Lp as fU,F2 as fV,z2 as fW,O2 as fX,wp as fY,W2 as fZ,H2 as f_,JT as fa,QT as fb,ZT as fc,e5 as fd,XT as fe,t5 as ff,tP as fg,KT as fh,i5 as fi,r5 as fj,s5 as fk,a5 as fl,o5 as fm,A0 as fn,j0 as fo,v0 as fp,x0 as fq,g0 as fr,m0 as fs,b0 as ft,Yj as fu,Uj as fv,Hj as fw,Ul as fx,qj as fy,I1 as fz,Ba as g,vN as g$,U2 as g0,g1,n1 as g2,a1 as g3,s1 as g4,u1 as g5,PT as g6,RT as g7,OT as g8,AT as g9,lk as gA,w2 as gB,nk as gC,rk as gD,sk as gE,v2 as gF,y2 as gG,b2 as gH,g2 as gI,m2 as gJ,x2 as gK,j2 as gL,Kt as gM,MN as gN,IN as gO,DN as gP,Vk as gQ,ON as gR,EN as gS,Wd as gT,PN as gU,RN as gV,AN as gW,CN as gX,TN as gY,mi as gZ,yN as g_,CT as ga,NT as gb,kT as gc,Gc as gd,DT as ge,IT as gf,Y2 as gg,MT as gh,TT as gi,ET as gj,LT as gk,JS as gl,KS as gm,Z5 as gn,eP as go,X5 as gp,Q5 as gq,PP as gr,OP as gs,ZS as gt,S2 as gu,_2 as gv,k2 as gw,EP as gx,RP as gy,rp as gz,Hi as h,JN as h$,bN as h0,bd as h1,Gk as h2,zk as h3,xp as h4,Fk as h5,Yk as h6,qk as h7,Hk as h8,Uk as h9,Bv as hA,BG as hB,qc as hC,vT as hD,Gj as hE,nj as hF,_c as hG,r1 as hH,wc as hI,Cc as hJ,Wk as hK,qN as hL,Wu as hM,S1 as hN,Xd as hO,r2 as hP,wv as hQ,_v as hR,gx as hS,K1 as hT,J1 as hU,ri as hV,s2 as hW,n2 as hX,t2 as hY,mx as hZ,XN as h_,Uy as ha,bp as hb,gp as hc,mp as hd,hk as he,uk as hf,ap as hg,cc as hh,ck as hi,fk as hj,YC as hk,NN as hl,kN as hm,SN as hn,$N as ho,Dp as hp,l2 as hq,d2 as hr,i2 as hs,u2 as ht,wT as hu,jT as hv,$a as hw,Pv as hx,zv as hy,$v as hz,XS as i,$5 as i$,KN as i0,VN as i1,GN as i2,E0 as i3,sp as i4,np as i5,qv as i6,Uv as i7,Hv as i8,a2 as i9,Zv as iA,Vv as iB,Yv as iC,pu as iD,Yl as iE,ew as iF,tw as iG,Jj as iH,rw as iI,Zj as iJ,Kj as iK,Fl as iL,La as iM,iu as iN,bT as iO,So as iP,dP as iQ,Xc as iR,oP as iS,hP as iT,T5 as iU,U5 as iV,G5 as iW,B5 as iX,z5 as iY,W5 as iZ,F5 as i_,e1 as ia,jc as ib,Zk as ic,Dv as id,au as ie,xv as ig,pj as ih,hj as ii,mj as ij,gj as ik,xj as il,bj as im,yj as io,ou as ip,lj as iq,oj as ir,aj as is,rj as it,ij as iu,cj as iv,Qv as iw,tj as ix,ej as iy,Xv as iz,ek as j,wl as j$,mP as j0,eT as j1,J5 as j2,K5 as j3,FT as j4,$T as j5,BT as j6,G2 as j7,GT as j8,WT as j9,zc as jA,_C as jB,Hc as jC,sT as jD,vi as jE,nT as jF,oT as jG,iT as jH,Uu as jI,aa as jJ,ci as jK,Y5 as jL,Kn as jM,OC as jN,NC as jO,lT as jP,Va as jQ,SC as jR,TC as jS,PC as jT,zp as jU,aT as jV,rT as jW,iS as jX,sS as jY,eS as jZ,li as j_,L5 as ja,Qk as jb,oN as jc,Yu as jd,gT as je,jo as jf,ZC as jg,zC as jh,JC as ji,UC as jj,WC as jk,dC as jl,uC as jm,DC as jn,IC as jo,LC as jp,Kp as jq,FC as jr,cC as js,rc as jt,wS as ju,jS as jv,gS as jw,mS as jx,xS as jy,nS as jz,l0 as k,b_ as k$,tS as k0,sa as k1,uS as k2,Wt as k3,uT as k4,dT as k5,fT as k6,ds as k7,zN as k8,Jr as k9,e_ as kA,Zw as kB,Qw as kC,Xw as kD,Jw as kE,Vw as kF,Yw as kG,Gw as kH,Uw as kI,qw as kJ,Ww as kK,Bw as kL,Hw as kM,Dw as kN,Iw as kO,Mw as kP,Rw as kQ,Pw as kR,x_ as kS,g_ as kT,m_ as kU,f_ as kV,h_ as kW,d_ as kX,c_ as kY,bw as kZ,Jl as k_,fS as ka,yS as kb,vS as kc,pS as kd,W0 as ke,H0 as kf,SS as kg,_S as kh,o2 as ki,Q_ as kj,X_ as kk,J_ as kl,K_ as km,V_ as kn,Y_ as ko,G_ as kp,U_ as kq,q_ as kr,l_ as ks,i_ as kt,o_ as ku,a_ as kv,r_ as kw,s_ as kx,n_ as ky,t_ as kz,sj as l,p5 as l$,Kl as l0,H_ as l1,W_ as l2,B_ as l3,z_ as l4,F_ as l5,$_ as l6,Xl as l7,L_ as l8,I_ as l9,s0 as lA,Ro as lB,Xk as lC,j1 as lD,iN as lE,p2 as lF,fP as lG,FN as lH,N2 as lI,lN as lJ,aN as lK,rN as lL,RS as lM,Rs as lN,ES as lO,OS as lP,PS as lQ,TS as lR,US as lS,w1 as lT,N1 as lU,k1 as lV,y1 as lW,g5 as lX,b5 as lY,f5 as lZ,h5 as l_,M_ as la,ni as lb,A_ as lc,E_ as ld,Ub as le,S_ as lf,v_ as lg,cw as lh,lw as li,mw as lj,gw as lk,xw as ll,Ij as lm,ql as ln,Dj as lo,$j as lp,iw as lq,ec as lr,p0 as ls,u0 as lt,Mg as lu,Ql as lv,Z_ as lw,e0 as lx,t0 as ly,Eo as lz,Wv as m,RQ as m$,y5 as m0,m5 as m1,u5 as m2,x5 as m3,d5 as m4,Yc as m5,Go as m6,Fv as m7,hu as m8,tk as m9,Jo as mA,Cu as mB,Ew as mC,Aw as mD,Ow as mE,Nu as mF,ti as mG,ei as mH,Zo as mI,_w as mJ,Qo as mK,ww as mL,wu as mM,ln as mN,Xo as mO,kw as mP,lo as mQ,_u as mR,Vl as mS,Tw as mT,Nw as mU,Sw as mV,Cw as mW,Ka as mX,cP as mY,pP as mZ,_Q as m_,GS as ma,Kk as mb,AS as mc,CS as md,b1 as me,NS as mf,t1 as mg,kS as mh,aw as mi,Vj as mj,R5 as mk,nN as ml,Ke as mm,tv as mn,Qd as mo,Zd as mp,fw as mq,xT as mr,Tp as ms,SP as mt,Z2 as mu,Q2 as mv,eC as mw,J2 as mx,K2 as my,V2 as mz,dH as n,GY as n$,RX as n0,NQ as n1,QK as n2,_se as n3,EQ as n4,Bne as n5,WX as n6,Yse as n7,jae as n8,QQ as n9,bse as nA,sZ as nB,BZ as nC,ute as nD,GZ as nE,UZ as nF,MZ as nG,Yte as nH,Vte as nI,vae as nJ,bae as nK,yae as nL,kte as nM,gte as nN,zre as nO,xZ as nP,bZ as nQ,Hee as nR,Wee as nS,Bte as nT,AK as nU,EK as nV,tV as nW,sV as nX,UY as nY,nV as nZ,NX as n_,Woe as na,bX as nb,yX as nc,mX as nd,gX as ne,fX as nf,xX as ng,DV as nh,gV as ni,fte as nj,pK as nk,DY as nl,fV as nm,QX as nn,YZ as no,sX as np,eY as nq,rX as nr,YJ as ns,VJ as nt,GJ as nu,YX as nv,hte as nw,pte as nx,LQ as ny,dQ as nz,o0 as o,UJ as o$,TX as o0,CX as o1,HY as o2,kX as o3,eV as o4,QY as o5,KY as o6,VY as o7,aV as o8,SX as o9,pJ as oA,OX as oB,Noe as oC,koe as oD,fQ as oE,Sse as oF,voe as oG,Xre as oH,Jte as oI,ene as oJ,Xte as oK,Zte as oL,OY as oM,qX as oN,ote as oO,sJ as oP,fY as oQ,qne as oR,Hoe as oS,iZ as oT,Dse as oU,jse as oV,Poe as oW,Toe as oX,pZ as oY,yJ as oZ,RV as o_,rV as oa,qY as ob,oV as oc,iV as od,XY as oe,JY as of,YY as og,FZ as oh,Doe as oi,Eoe as oj,Roe as ok,Moe as ol,WQ as om,zQ as on,BQ as oo,tZ as op,vZ as oq,EX as or,Soe as os,_oe as ot,OQ as ou,PQ as ov,MX as ow,AX as ox,TQ as oy,CQ as oz,d0 as p,uV as p$,cQ as p0,EJ as p1,OJ as p2,RJ as p3,AJ as p4,IJ as p5,MJ as p6,FX as p7,lJ as p8,$X as p9,cX as pA,lX as pB,dX as pC,jJ as pD,ZJ as pE,nX as pF,tX as pG,QJ as pH,eX as pI,uQ as pJ,LX as pK,zX as pL,BX as pM,mY as pN,Foe as pO,Hse as pP,Gte as pQ,eZ as pR,dae as pS,VQ as pT,ise as pU,IQ as pV,SQ as pW,lZ as pX,Goe as pY,Uoe as pZ,Wte as p_,qJ as pa,$Y as pb,lre as pc,nY as pd,GX as pe,AZ as pf,yQ as pg,Zse as ph,mV as pi,vJ as pj,LJ as pk,DJ as pl,SJ as pm,pX as pn,hX as po,uX as pp,fJ as pq,mJ as pr,xJ as ps,vX as pt,bJ as pu,gJ as pv,iX as pw,oX as px,aX as py,WJ as pz,Y7 as q,Lte as q$,See as q0,_ee as q1,Fee as q2,jV as q3,$ee as q4,VZ as q5,HQ as q6,XQ as q7,GV as q8,tJ as q9,Tae as qA,uoe as qB,Mae as qC,Aae as qD,Dae as qE,Lae as qF,Iae as qG,Eae as qH,Nae as qI,OK as qJ,poe as qK,yZ as qL,Kne as qM,lse as qN,KK as qO,qK as qP,Yne as qQ,Gne as qR,lY as qS,iY as qT,Une as qU,WK as qV,zK as qW,MK as qX,GK as qY,$te as qZ,Ete as q_,zoe as qa,Cte as qb,Ste as qc,_te as qd,MY as qe,dK as qf,RY as qg,Ute as qh,boe as qi,yoe as qj,joe as qk,woe as ql,hoe as qm,xoe as qn,goe as qo,foe as qp,moe as qq,kne as qr,Cae as qs,RK as qt,Rae as qu,gY as qv,HX as qw,Uae as qx,Loe as qy,Pae as qz,fu as r,aee as r$,Rte as r0,Fte as r1,Ite as r2,Mte as r3,HK as r4,Dte as r5,PK as r6,VK as r7,YK as r8,FK as r9,IK as rA,rre as rB,DQ as rC,Fne as rD,gae as rE,xae as rF,fae as rG,pae as rH,hae as rI,uae as rJ,mae as rK,Eee as rL,bne as rM,cae as rN,Zae as rO,cee as rP,_V as rQ,Uee as rR,qee as rS,zee as rT,Gee as rU,Bee as rV,Vee as rW,wee as rX,JK as rY,$Z as rZ,Yee as r_,zte as ra,kae as rb,Sae as rc,_ae as rd,xY as re,BK as rf,cY as rg,Ote as rh,Pte as ri,Ate as rj,oY as rk,Vne as rl,NK as rm,TK as rn,CK as ro,kK as rp,Ise as rq,Mse as rr,Hne as rs,Nte as rt,Jne as ru,XV as rv,use as rw,DZ as rx,KQ as ry,are as rz,i0 as s,eK as s$,ree as s0,lne as s1,gK as s2,KJ as s3,Ioe as s4,Kee as s5,wae as s6,_K as s7,hJ as s8,aae as s9,kre as sA,fre as sB,Rre as sC,ure as sD,dte as sE,HZ as sF,zne as sG,tne as sH,VV as sI,JV as sJ,KV as sK,QV as sL,nK as sM,tK as sN,oK as sO,aK as sP,lK as sQ,sK as sR,rK as sS,iK as sT,Mne as sU,AV as sV,zV as sW,Ine as sX,BV as sY,FV as sZ,$V as s_,rae as sa,Bse as sb,DX as sc,Pre as sd,Dre as se,Fre as sf,Ere as sg,yre as sh,$re as si,Ire as sj,Mre as sk,UX as sl,Are as sm,hre as sn,pre as so,Nre as sp,Cre as sq,Tre as sr,bre as ss,jre as st,vre as su,xre as sv,gre as sw,_re as sx,Sre as sy,Ore as sz,gs as t,sY as t$,ZV as t0,EV as t1,UV as t2,cK as t3,zZ as t4,gZ as t5,yY as t6,kJ as t7,doe as t8,vQ as t9,Oae as tA,see as tB,ine as tC,uJ as tD,kZ as tE,EZ as tF,PZ as tG,NZ as tH,RZ as tI,OZ as tJ,TZ as tK,CZ as tL,One as tM,Rne as tN,Ene as tO,Cne as tP,pQ as tQ,Pne as tR,Ane as tS,Nne as tT,_X as tU,PX as tV,Tne as tW,jee as tX,nee as tY,ZZ as tZ,dY as t_,jQ as ta,wQ as tb,FQ as tc,yse as td,bQ as te,XJ as tf,JJ as tg,IX as th,TV as ti,OV as tj,PV as tk,CV as tl,NV as tm,kV as tn,ZQ as to,ooe as tp,aoe as tq,loe as tr,ioe as ts,roe as tt,coe as tu,soe as tv,Zne as tw,UK as tx,Qne as ty,JZ as tz,s$ as u,$ne as u$,rY as u0,eee as u1,tee as u2,aY as u3,FY as u4,wse as u5,_J as u6,wJ as u7,Voe as u8,Yoe as u9,SZ as uA,_Z as uB,eJ as uC,ZK as uD,YV as uE,iJ as uF,rJ as uG,LZ as uH,WZ as uI,IZ as uJ,wX as uK,rZ as uL,PJ as uM,TJ as uN,BJ as uO,$J as uP,HJ as uQ,zJ as uR,BY as uS,MQ as uT,kse as uU,$oe as uV,cse as uW,Lse as uX,Wne as uY,Lne as uZ,xse as u_,PY as ua,one as ub,Qte as uc,hV as ud,GQ as ue,Tte as uf,vY as ug,jte as uh,lae as ui,tY as uj,Koe as uk,ane as ul,qte as um,NY as un,bK as uo,hK as up,uK as uq,fK as ur,mK as us,xK as ut,Rse as uu,dJ as uv,wZ as uw,oJ as ux,aJ as uy,Dne as uz,Jv as v,oee as v$,Joe as v0,nte as v1,ste as v2,tte as v3,ete as v4,Zee as v5,rte as v6,cne as v7,jY as v8,iae as v9,Wre as vA,Vre as vB,wre as vC,Bre as vD,zY as vE,LV as vF,Iee as vG,wY as vH,Dee as vI,Mee as vJ,tae as vK,Ree as vL,Oee as vM,Tee as vN,Cee as vO,pY as vP,hY as vQ,Pee as vR,dre as vS,cre as vT,sre as vU,lV as vV,Xne as vW,dZ as vX,TY as vY,Xae as vZ,noe as v_,sne as va,Aoe as vb,qae as vc,Hae as vd,qZ as ve,xQ as vf,dne as vg,MV as vh,Lre as vi,IV as vj,bY as vk,Zre as vl,Qre as vm,Lee as vn,Jre as vo,eae as vp,dse as vq,nae as vr,qV as vs,$se as vt,Kre as vu,Yre as vv,Gre as vw,Ure as vx,qre as vy,Hre as vz,CP as w,vse as w$,Yae as w0,Qae as w1,Vae as w2,eoe as w3,toe as w4,Jae as w5,Kae as w6,uZ as w7,UQ as w8,qQ as w9,jZ as wA,mQ as wB,gQ as wC,Nee as wD,cJ as wE,ose as wF,ase as wG,rse as wH,sse as wI,tse as wJ,HV as wK,nse as wL,WV as wM,ese as wN,QG as wO,JQ as wP,ZG as wQ,oae as wR,pV as wS,AY as wT,EY as wU,IY as wV,CY as wW,_Y as wX,Coe as wY,nZ as wZ,LK as w_,xV as wa,yV as wb,sae as wc,bV as wd,nre as we,KZ as wf,zae as wg,Fae as wh,Bae as wi,Wae as wj,_ne as wk,wne as wl,vne as wm,jne as wn,yne as wo,Sne as wp,gne as wq,xne as wr,fne as ws,hne as wt,mne as wu,pne as wv,tQ as ww,fZ as wx,$K as wy,Boe as wz,j7 as x,ore as x$,kee as x0,gse as x1,mse as x2,fse as x3,uY as x4,hse as x5,pse as x6,cZ as x7,XK as x8,Vse as x9,xte as xA,bte as xB,yee as xC,Ase as xD,Ose as xE,Pse as xF,Ese as xG,Tse as xH,Cse as xI,Nse as xJ,FJ as xK,lte as xL,Use as xM,Gse as xN,Jse as xO,Kse as xP,Wse as xQ,qse as xR,SY as xS,mZ as xT,tre as xU,ere as xV,zse as xW,Fse as xX,oZ as xY,wV as xZ,ire as x_,mee as xa,Gae as xb,vee as xc,fee as xd,xee as xe,gee as xf,mte as xg,cte as xh,Hte as xi,ate as xj,Qee as xk,nne as xl,Xee as xm,SV as xn,ZY as xo,Kte as xp,rne as xq,qoe as xr,bee as xs,cV as xt,Qse as xu,Ooe as xv,dV as xw,WY as xx,Xse as xy,wte as xz,pC as y,SK as y0,DK as y1,JX as y2,VX as y3,sQ as y4,oQ as y5,iQ as y6,aQ as y7,une as y8,vV as y9,jK as yA,vK as yB,yK as yC,kY as yD,ite as yE,LY as yF,hQ as yG,yte as yH,vte as yI,$ae as yJ,AQ as yK,kQ as yL,Ko as yM,QZ as ya,XZ as yb,pee as yc,uee as yd,lee as ye,iee as yf,dee as yg,Jee as yh,nQ as yi,CJ as yj,NJ as yk,jX as yl,lQ as ym,ZX as yn,XX as yo,KX as yp,eQ as yq,rQ as yr,nJ as ys,aZ as yt,hZ as yu,Aee as yv,hee as yw,YQ as yx,$Q as yy,wK as yz,Gp as z};
|