@codeyam-editor/codeyam-editor 0.1.6 → 0.1.8

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.
Files changed (37) hide show
  1. package/npm/cloud.js +308 -52
  2. package/npm/compose-conflict.js +59 -0
  3. package/npm/fleet-add-failure.js +174 -18
  4. package/npm/fleet-cleanup.js +129 -0
  5. package/npm/fleet-job-badge.js +28 -12
  6. package/npm/fleet-memory.js +73 -4
  7. package/npm/fleet-probe-transport.js +155 -0
  8. package/npm/fleet-queue.js +141 -0
  9. package/npm/fleet-revision.js +104 -0
  10. package/npm/fleet-running-plan.js +37 -7
  11. package/npm/fleet-vm-access.js +162 -0
  12. package/npm/ingress-invoke.js +46 -2
  13. package/npm/launch-config.js +163 -4
  14. package/npm/scenario-check.js +63 -19
  15. package/npm/scenario-handlers.js +18 -0
  16. package/npm/scenario-issues.js +11 -0
  17. package/npm/scenario-mocks.js +245 -39
  18. package/npm/scenario-playwright.js +114 -22
  19. package/package.json +5 -5
  20. package/ui/dist/assets/{ContainerInspector-DgM0pTAx.js → ContainerInspector-DSVZvEkB.js} +1 -1
  21. package/ui/dist/assets/EditorShell-DnXdHrar.js +256 -0
  22. package/ui/dist/assets/EditorShell-FvbXyqqD.css +1 -0
  23. package/ui/dist/assets/ProjectLauncherScreen-E0NYYiwy.js +1 -0
  24. package/ui/dist/assets/ScenarioDataPanel-6qJE-0lA.js +15 -0
  25. package/ui/dist/assets/{ScenarioDataPanelFullPage-BLqRCxQX.js → ScenarioDataPanelFullPage-Cyk6efiI.js} +1 -1
  26. package/ui/dist/assets/ScenarioRenderer-Uyt54vHI.js +21 -0
  27. package/ui/dist/assets/{index-DCHqRrwO.js → index-BPLKgwon.js} +9 -9
  28. package/ui/dist/assets/index-DKpgJLo3.css +1 -0
  29. package/ui/dist/assets/useServerIdentity-CVuHTzjg.js +1 -0
  30. package/ui/dist/index.html +2 -2
  31. package/ui/dist/assets/EditorShell-B7Q06uJ_.js +0 -252
  32. package/ui/dist/assets/EditorShell-DP5UY20G.css +0 -1
  33. package/ui/dist/assets/ProjectLauncherScreen-BRrEr8Ng.js +0 -1
  34. package/ui/dist/assets/ScenarioDataPanel-BeQfa28g.js +0 -9
  35. package/ui/dist/assets/ScenarioRenderer-CIAxfHPh.js +0 -21
  36. package/ui/dist/assets/index-BygCiJSb.css +0 -1
  37. package/ui/dist/assets/useServerIdentity-B7rI0u3O.js +0 -1
@@ -1,252 +0,0 @@
1
- var Kj=Object.defineProperty;var Jj=(t,s,n)=>s in t?Kj(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var wt=(t,s,n)=>Jj(t,typeof s!="symbol"?s+"":s,n);import{j as e}from"./markdown-C9tbsVHX.js";import{b as l,c as gs,R as nt}from"./react-nrLBr15I.js";import{i as wo,n as _o,a as bt,r as Xj,b as yr,c as ia,d as la,s as Qj}from"./useEvents-S3Qk1Y_d.js";import{S as Zj,b3 as St,b4 as zt,aa as vs,b5 as gn,b6 as ew,b7 as ar,b8 as Bc,b9 as Pa,ba as Ta,u as tw,bb as ko,bc as So,bd as No,be as Co,bf as sw,bg as gl,a5 as nw,bh as rw,bi as aw,bj as ow,bk as iw,bl as Po,bm as lw,a6 as cw,bn as dw,bo as uw,bp as bl,bq as hw,f as Aa,br as pw,e as To,bs as mw,bt as fw,bu as gw,i as bw,bv as xl,bw as xw,bx as yw,ab as vw,a9 as jw,by as ww,bz as _w,bA as kw,bB as Sw,A as Nw,bC as Cw}from"./ScenarioDataPanel-BeQfa28g.js";import{e as Pw,a as Tw,i as tn,g as Ao,d as Aw,l as X,p as Os,t as Ow,P as bs,u as Rw}from"./index-DCHqRrwO.js";import{u as qc}from"./useServerIdentity-B7rI0u3O.js";import{M as $t}from"./Markdown-Chgdf3PW.js";function Hc(){const t="M2 2 h4.5 v1.6 h-2.9 v2.9 h-1.6 z";return e.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:[0,90,180,270].map(s=>e.jsx("path",{d:t,transform:`rotate(${s} 8 8)`},s))})}const NT=Object.freeze(Object.defineProperty({__proto__:null,FullScreenIcon:Hc},Symbol.toStringTag,{value:"Module"}));function ns(t,s){if(t.startsWith("http"))return t;const n=`/api/screenshots/${t}`;return typeof s=="number"?`${n}?cb=${s}`:n}function Nt({screenshotPath:t,cacheBuster:s,alt:n,className:r="",title:a}){const[o,i]=l.useState("loading"),[c,d]=l.useState(!1),u=l.useRef(null),h=t?ns(t,s):"",p=()=>{i("success"),d(!0)},f=()=>{i("error"),d(!1)};return l.useEffect(()=>{i("loading"),d(!1);const m=u.current;m!=null&&m.complete&&(m.naturalHeight!==0?(i("success"),d(!0)):(i("error"),d(!1)))},[h]),t?e.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",title:a,children:[e.jsx("img",{ref:u,src:h,alt:n,onLoad:p,onError:f,className:r||"max-w-full max-h-full object-contain",style:{opacity:c?1:0,position:c?"relative":"absolute"}}),o==="loading"&&e.jsx("div",{className:"absolute inset-0 bg-[var(--bg-card)] animate-pulse rounded flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-[var(--text-dim)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),o==="error"&&e.jsxs("div",{className:"absolute inset-0 border border-[var(--border-subtle)] bg-[var(--bg-card)] rounded flex flex-col items-center justify-center text-xs gap-1",children:[e.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"}),e.jsx("span",{className:"text-[var(--text-dim)] whitespace-nowrap",children:"No Screenshot"})]})]}):e.jsx("div",{className:"w-full h-full border border-[var(--border-subtle)] bg-[var(--bg-card)] rounded flex flex-col items-center justify-center text-xs gap-1",title:a,children:e.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"})})}const CT=Object.freeze(Object.defineProperty({__proto__:null,SafeScreenshot:Nt},Symbol.toStringTag,{value:"Module"}));function Wc({shots:t,initialIndex:s=0,onSelect:n,onClose:r}){const a=t.length-1,o=l.useCallback(b=>Math.max(0,Math.min(a,b)),[a]),[i,c]=l.useState(()=>o(s)),d=l.useCallback(b=>c(g=>o(g+b)),[o]),u=l.useCallback(b=>{b.key==="Escape"?(b.preventDefault(),r()):b.key==="ArrowLeft"?(b.preventDefault(),d(-1)):b.key==="ArrowRight"&&(b.preventDefault(),d(1))},[r,d]);if(l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]),t.length===0)return null;const h=t[i],p=i===0,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 e.jsx("div",{className:"fixed inset-0 z-[70] flex flex-col",style:{background:"rgba(30, 30, 30, 0.90)"},role:"dialog","aria-label":"Scenario gallery","data-testid":"scenario-gallery-modal",onClick:r,children:e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col px-6 py-4",onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[11px] font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:h.routeLabel}),e.jsx("p",{className:"truncate text-lg font-semibold text-[var(--text-primary)]",children:h.name})]}),e.jsxs("span",{className:"flex-none text-xs font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:[i+1," / ",t.length]}),e.jsx("button",{type:"button",onClick:r,"aria-label":"Close gallery",className:"flex-none text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"✕"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-4",children:[e.jsx("button",{type:"button",onClick:()=>d(-1),disabled:p,"aria-label":"Previous scenario",className:m,children:"‹"}),e.jsx("button",{type:"button",onClick:()=>{n(h.slug),r()},"aria-label":`Open ${h.name} live`,className:"flex min-h-0 flex-1 cursor-pointer items-center justify-center self-stretch",children:e.jsx("div",{className:"flex max-h-[80vh] max-w-[90vw] items-center justify-center",children:e.jsx(Nt,{screenshotPath:h.screenshotPath??void 0,cacheBuster:h.screenshotCapturedAtMs??void 0,alt:h.name,className:"max-h-[80vh] max-w-[90vw] object-contain"})})}),e.jsx("button",{type:"button",onClick:()=>d(1),disabled:f,"aria-label":"Next scenario",className:m,children:"›"})]}),e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>{n(h.slug),r()},className:"rounded bg-[var(--lime-300)] px-4 py-2 font-semibold text-black transition hover:brightness-110",children:"Open Live Preview"})})]})})}const PT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioGalleryModal:Wc},Symbol.toStringTag,{value:"Module"}));function Gc({reason:t}){const{headline:s,detail:n}=Uc(t);return e.jsxs("div",{className:"py-4 text-sm text-[var(--text-dim)]",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:s}),n?e.jsx("p",{className:"mt-1",children:n}):null]})}function Uc(t){switch(t.kind){case"no-component-scenarios":return{headline:"No components yet.",detail:"Capture a component scenario and it will appear here — a scenario is what marks a component as browsable."};case"missing-from-glossary":return{headline:`${t.count} component ${Ps(t.count,"scenario")} name ${Ps(t.count,"a component","components")} not in the glossary${yl(t.examples)}.`,detail:"Deconstruct or register those components so they can be surfaced here."};case"not-visual-components":return{headline:`${t.count} ${Ps(t.count,"component")} matched glossary ${Ps(t.count,"entry","entries")} but ${Ps(t.count,"is","are")} not recognized as visual ${Ps(t.count,"component","components")}${yl(t.examples)}.`,detail:"Check `components.fileExtensions` in .codeyam/stack.json — a stack whose components are not .tsx/.jsx must list its own extensions."}}}function Ps(t,s,n){return t===1?s:n??`${s}s`}function yl(t){return t.length===0?"":` (e.g. ${t.join(", ")})`}const TT=Object.freeze(Object.defineProperty({__proto__:null,ComponentSurfaceReasonNote:Gc,describeReason:Uc},Symbol.toStringTag,{value:"Module"})),Ew="Good question. We'll explain this plainly as we go, and you can ask anything at any step. Nothing happens until you say go.",Mw=[{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 Iw(t){const s=t.toLowerCase();for(const n of Mw)if(n.keywords.some(r=>s.includes(r)))return n.answer;return Ew}const Dw={"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 ce(t){return Dw[t]}const Lw=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Fw(t){const s=/^(\d{4})-(\d{2})$/.exec(t);if(!s)return t;const n=Number(s[2])-1;return n<0||n>11?t:`${Lw[n]} ${s[1]}`}function zw(t,s){const n=/^(\d{4})-(\d{2})$/.exec(t);if(!n)return 0;const r=Number(n[1]),a=Number(n[2])-1,o=(s.getFullYear()-r)*12+(s.getMonth()-a);return o<0?0:o}const $w=12;function Bw(t,s){return t.staleness==="low"?!1:zw(t.verified,s)>$w}function es({fact:t,asOf:s=new Date}){if(t.staleness==="low")return null;const n=Bw(t,s);return e.jsxs("span",{className:"fact-fresh"+(n?" stale":""),title:`Source: ${t.source}`,children:[n?"needs re-check · ":"verified ",Fw(t.verified)]})}const AT=Object.freeze(Object.defineProperty({__proto__:null,FactFreshness:es},Symbol.toStringTag,{value:"Module"}));function $e({size:t=15,color:s="var(--green-300)"}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:s,strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M3 8.4l3 3 7-7.4"})})}function vr(){return e.jsx("div",{className:"pv-logo",children:e.jsx("svg",{width:"26",height:"22",viewBox:"0 0 26 22",fill:"#0a0a0a","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})})})}function Yc(){return e.jsx("div",{className:"journey",children:e.jsxs("div",{className:"jrow",children:[e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile",children:"💻"}),e.jsx("div",{className:"jlbl",children:"Your computer"}),e.jsx("div",{className:"jsub",children:"Only you can see it"})]}),e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket"}),e.jsx("span",{children:"→"})]}),e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile lime",children:"☁️"}),e.jsx("div",{className:"jlbl",children:"Hosting"}),e.jsx("div",{className:"jsub",children:"A home on the internet"})]}),e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket",style:{animationDelay:"1.8s"}}),e.jsx("span",{children:"→"})]}),e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile",children:"🌍"}),e.jsx("div",{className:"jlbl",children:"Anyone, anywhere"}),e.jsx("div",{className:"jsub",children:"Opens with a link"})]})]})})}function Vc(){const t=ce("vercel.hobby");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"reasons",children:[e.jsxs("div",{className:"reason",children:[e.jsx($e,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Free to start."})," No credit card, no surprise bills for an app this size."]})]}),e.jsxs("div",{className:"reason",children:[e.jsx($e,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Built for how your app is made."})," It deploys the way your app already works, so it just runs."]})]}),e.jsxs("div",{className:"reason",children:[e.jsx($e,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Your own web address later."})," Launch on a free link today, add a custom domain whenever you like."]})]})]}),e.jsxs("p",{className:"reason-foot",children:["One catch worth knowing: ",t.value,". So the free link is perfect for trying it out and sharing, but once your app is charging money you'll want the paid tier.",e.jsx(es,{fact:t})]})]})}function Kc(){return e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Free tier"}),e.jsx("span",{className:"chip",children:"Custom domain later"}),e.jsx("span",{className:"chip",children:"~5 min to set up"})]})}function Jc(){const[t,s]=l.useState(!1);return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>s(n=>!n),children:[t?"Hide other options":"Vercel not for you? See other options",e.jsx("span",{className:"chev",style:{transform:t?"rotate(180deg)":"none"},children:"⌄"})]}),t?e.jsxs("div",{className:"alts",children:[e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#16a3a3,#0d6e6e)"},children:"N"}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:"Netlify"}),e.jsx("div",{className:"altdesc",children:"Also free to start and very similar to set up. A solid pick if you'd rather use it."})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]}),e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#f6821f,#c25e0a)"},children:"C"}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:"Cloudflare Pages"}),e.jsx("div",{className:"altdesc",children:"Best if you expect heavy worldwide traffic. A little more to learn up front."})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]})]}):null]})}const qw=[{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 Xc(){const[t,s]=l.useState(-1);return e.jsx("div",{className:"faq",children:qw.map((n,r)=>e.jsxs("div",{className:"faqitem",children:[e.jsxs("button",{type:"button",className:"faqq"+(t===r?" open":""),onClick:()=>s(t===r?-1:r),children:[n.t,e.jsx("span",{className:"chev",children:"⌄"})]}),t===r?e.jsx("div",{className:"faqa",children:n.a}):null]},n.t))})}function Qc(){const[t,s]=l.useState(""),[n,r]=l.useState(null),a=o=>{r(Iw(o)),s("")};return e.jsxs("div",{className:"ask",children:[e.jsxs("div",{className:"askrow",children:[e.jsx("input",{value:t,onChange:o=>s(o.target.value),onKeyDown:o=>{o.key==="Enter"&&t.trim()&&a(t)},placeholder:'Ask anything, e.g. "Is it really free?" or "Can I use my own domain?"'}),e.jsx("button",{type:"button",onClick:()=>t.trim()&&a(t),"aria-label":"Ask",children:"↑"})]}),e.jsx("div",{className:"asknote",children:"Ask before you commit to anything."}),n?e.jsxs("div",{className:"askans",children:[e.jsx("span",{className:"askav",children:"‹Y"}),e.jsx("div",{className:"at",children:n})]}):null]})}const OT=Object.freeze(Object.defineProperty({__proto__:null,Alts:Jc,AskBox:Qc,Check:$e,Chips:Kc,Faq:Xc,Journey:Yc,Reasons:Vc,VercelMark:vr},Symbol.toStringTag,{value:"Module"})),Hw={"chrome.devConsole":{url:"https://chrome.google.com/webstore/devconsole",label:"Open the Chrome Web Store developer dashboard"},"chrome.register":{url:ce("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 Ww(t){return Hw[t]}function mt({linkKey:t,label:s}){const n=Ww(t);return e.jsxs("a",{className:"setup-extlink",href:n.url,target:"_blank",rel:"noreferrer noopener",children:[e.jsx("span",{className:"setup-extlink-label",children:s??n.label}),e.jsx("span",{className:"setup-extlink-glyph","aria-hidden":"true",children:"↗"})]})}function ne({children:t}){return e.jsx("div",{className:"reasons",children:t})}function R({lead:t,children:s}){return e.jsxs("div",{className:"reason",children:[e.jsx($e,{}),e.jsxs("span",{children:[e.jsx("b",{children:t})," ",s]})]})}function Oo({spaced:t=!1,children:s}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",style:t?{marginTop:24}:void 0,children:"Keep a changelog"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"One CHANGELOG.md, grouped by version.",children:["Follow the ",e.jsx("b",{children:"Keep a Changelog"})," convention: Added / Changed / Fixed / Removed under each release, newest first. Write it for the person deciding whether to upgrade."]}),e.jsxs(R,{lead:"Or generate it from your commits.",children:["If you write ",e.jsx("b",{children:"Conventional Commits"})," (",e.jsx("code",{children:"feat:"}),","," ",e.jsx("code",{children:"fix:"}),", ",e.jsx("code",{children:"feat!:"})," for breaking), tools like release-please or git-cliff assemble the changelog — and even the next version number — for you."]}),s]})]})}function jr(){return e.jsxs("div",{className:"setup-note",style:{marginTop:14},children:[e.jsxs("p",{children:["Publishing to ",e.jsx("b",{children:"Firefox Add-ons (AMO)"})," or ",e.jsx("b",{children:"Edge Add-ons"})," ","follows an analogous path — a developer account, store assets, and a review — with its own console. The steps below are written for the Chrome Web Store."]}),e.jsxs("p",{children:[e.jsx("b",{children:"Fees differ:"})," the"," ",e.jsx("b",{children:ce("chromeStore.fee").value})," registration fee is Chrome-only and one-time — Firefox AMO and Edge Add-ons charge no developer fee."]}),e.jsxs("div",{className:"setup-note-links",children:[e.jsx(mt,{linkKey:"firefox.amoDevHub"}),e.jsx(mt,{linkKey:"edge.partnerDashboard"})]})]})}const RT=Object.freeze(Object.defineProperty({__proto__:null,ChangelogSection:Oo,ReqItem:R,ReqList:ne,SetupExternalLink:mt,StoreAlternativesNote:jr},Symbol.toStringTag,{value:"Module"}));function ca(t){const s=Pw(t);if(s)return{selectedAppDir:s,selectedEntityHash:null};const n=Tw(t);return n?{selectedAppDir:null,selectedEntityHash:n}:{selectedAppDir:null,selectedEntityHash:null}}function da(t){return`/apps/${t}`}function Gw(t){return`/entities/${t}`}function bn(t,s){const n=`${t}:${s}`;let r=2166136261;for(let a=0;a<n.length;a++)r^=n.charCodeAt(a),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}function js(t){return(t.split("/").pop()??t).replace(/\.[^.]+$/,"")}function Oa(t){if(!t.pageFilePath)return null;const s=t.entityName??js(t.pageFilePath);return bn(t.pageFilePath,s)}function Zc(t){const s=Oa(t);return s===null?null:Gw(s)}function or({href:t,onNavigate:s,children:n,...r}){return e.jsx("a",{...r,href:t,onClick:a=>{a.button===0&&!a.metaKey&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&(a.preventDefault(),s())},children:n})}const ET=Object.freeze(Object.defineProperty({__proto__:null,NavLink:or},Symbol.toStringTag,{value:"Module"}));function ed({scenario:t,onSelect:s}){const n=t.screenshotPaths[0]??null;return e.jsxs("button",{type:"button",onClick:s,className:`relative text-left w-full${s?" cursor-pointer group/thumb":""}`,children:[e.jsx("div",{className:"aspect-[16/10] w-full flex items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] transition group-hover/thumb:border-[var(--text-dim)]",children:e.jsx(Nt,{screenshotPath:n??void 0,alt:t.name})}),t.dimensions.length>0?e.jsx("span",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1 py-0.5 text-[8px] text-white",children:t.dimensions[0]}):null,e.jsx("p",{className:"mt-1.5 truncate text-[13px] text-[var(--text-dim)]",children:t.name})]})}const MT=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardThumbnail:ed},Symbol.toStringTag,{value:"Module"})),td=l.createContext(null),vl={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5"};function Ro({routeEntity:t,onSelectRoute:s,onSelectScenario:n,columns:r=4,defaultCollapsed:a=!1}){const o=t.scenarios.length,i=l.useContext(td),[c,d]=l.useState(a);l.useEffect(()=>{i&&d(i.collapsed)},[i]);const u=Zc(t),h="group flex flex-1 min-w-0 cursor-pointer items-center gap-2 text-left",p=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] transition",children:t.displayName}),e.jsx("span",{className:"font-mono text-xs text-[var(--text-dim)]",children:t.route}),o>0?e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["[",o,"]"]}):null,e.jsx("span",{className:"ml-auto text-xs text-[var(--text-dim)] group-hover:text-[var(--text-muted)] transition",children:"›"})]});return e.jsxs("div",{className:"mb-10 border-b border-[var(--border-subtle)] pb-8",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[o>0?e.jsx("button",{type:"button",onClick:()=>d(f=>!f),"aria-label":c?"Expand group":"Collapse group",className:"shrink-0 w-5 text-[var(--text-dim)] hover:text-[var(--text-primary)] transition text-xs",children:c?"▸":"▾"}):e.jsx("span",{className:"shrink-0 w-5"}),u?e.jsx(or,{href:u,onNavigate:()=>s(t.route),className:h,children:p}):e.jsx("button",{onClick:()=>s(t.route),className:h,type:"button",children:p})]}),o>0&&!c?e.jsx("div",{className:`mt-4 grid gap-x-5 gap-y-9 ${vl[r]??vl[4]}`,children:t.scenarios.map(f=>e.jsx(ed,{scenario:f,onSelect:n?()=>n(f.slug):void 0},f.slug))}):o===0?e.jsx("p",{className:"mt-1 text-[10px] text-[var(--text-dim)] pl-7",children:"No scenarios yet"}):null]})}const IT=Object.freeze(Object.defineProperty({__proto__:null,RouteListCard:Ro},Symbol.toStringTag,{value:"Module"}));function sd({columns:t}){const a=(12-(t-1)*1.6)/t;return e.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:Array.from({length:t},(o,i)=>e.jsx("rect",{x:2+i*(a+1.6),y:3,width:a,height:10,rx:.7},i))})}const DT=Object.freeze(Object.defineProperty({__proto__:null,GridColumnsIcon:sd},Symbol.toStringTag,{value:"Module"}));function nd({columns:t,onChange:s,options:n=[2,3,4,5]}){return e.jsxs("div",{className:"flex items-center gap-1.5",title:"Thumbnails per row",children:[e.jsx("span",{className:"text-[11px] font-semibold tracking-widest uppercase text-[var(--text-dim)] mr-0.5",children:"Grid"}),n.map(r=>e.jsx("button",{type:"button",onClick:()=>s(r),"aria-label":`${r} per row`,"aria-pressed":t===r,className:`w-7 h-6 rounded flex items-center justify-center transition ${t===r?"bg-[var(--lime-300)] text-black":"text-[var(--text-dim)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card)]"}`,children:e.jsx(sd,{columns:r})},r))]})}const LT=Object.freeze(Object.defineProperty({__proto__:null,GridDensityControl:nd},Symbol.toStringTag,{value:"Module"}));function Uw(t){const s=[];for(const n of t)for(const r of n.scenarios)s.push({slug:r.slug,name:r.name,routeLabel:n.route||n.displayName,screenshotPath:r.screenshotPaths[0]??null,screenshotCapturedAtMs:r.screenshotCapturedAtMs??null});return s}function rd({pages:t,components:s,componentSurfaceReason:n=null,onSelectRoute:r,onSelectScenario:a,headerAccessory:o}){const[i,c]=l.useState("pages"),[d,u]=l.useState(4),[h,p]=l.useState(""),[f,m]=l.useState(!1),b=i==="components",g=b?s:t,x=l.useMemo(()=>Uw(g),[g]),y=x.length>0&&!!a,v=l.useMemo(()=>{const _=h.trim().toLowerCase();return _?g.filter(S=>S.displayName.toLowerCase().includes(_)):g},[g,h]),j=_=>`text-xs font-semibold tracking-widest uppercase pb-2 -mb-px border-b-2 transition ${_?"text-[var(--text-primary)] border-[var(--lime-300)]":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-secondary)]"}`,w=(_,S)=>S>0?`${_} · ${S}`:_;return e.jsxs("div",{children:[f&&y?e.jsx(Wc,{shots:x,onSelect:_=>a==null?void 0:a(_),onClose:()=>m(!1)}):null,e.jsxs("div",{className:"flex items-center gap-6 border-b border-[var(--border-subtle)] mb-7",children:[e.jsx("button",{type:"button",onClick:()=>c("pages"),className:j(i==="pages"),children:w("Pages",t.length)}),e.jsx("button",{type:"button",onClick:()=>c("components"),className:j(b),children:w("Components",s.length)}),o?e.jsx("div",{className:"pb-2",children:o}):null,e.jsxs("div",{className:"ml-auto flex items-center gap-3 pb-2",children:[y?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Full screen",title:"Full screen",className:"w-7 h-6 rounded flex items-center justify-center transition text-[var(--text-dim)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card)]",children:e.jsx(Hc,{})}),e.jsx("div",{className:"h-5 w-px bg-[var(--border-subtle)]"})]}):null,e.jsx(nd,{columns:d,onChange:u})]})]}),g.length>0?e.jsx("input",{type:"text",value:h,onChange:_=>p(_.target.value),placeholder:`Filter ${b?"components":"pages"}…`,className:"mb-6 w-full max-w-xs rounded border border-[var(--border-subtle)] bg-transparent px-2 py-1 text-xs text-[var(--text-secondary)] placeholder:text-[var(--text-dim)] focus:border-[var(--lime-300)] focus:outline-none"}):null,v.length>0?v.map((_,S)=>e.jsx(Ro,{routeEntity:_,onSelectRoute:r,onSelectScenario:a,columns:d,defaultCollapsed:b},_.route??_.displayName??S)):g.length>0?e.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",b?"components":"pages"," match “",h.trim(),"”."]}):b&&n?e.jsx(Gc,{reason:n}):e.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",b?"components":"pages"," yet."]})]})}const FT=Object.freeze(Object.defineProperty({__proto__:null,RouteListTabs:rd},Symbol.toStringTag,{value:"Module"}));function Eo(t,s){const n=t.url??"Uncategorized",r=s.find(o=>o.route===n),a=(r==null?void 0:r.scenarios)??[t];if(!t.url&&t.componentName){const o=a.filter(i=>i.componentName===t.componentName);return o.length?o:[t]}return a}function Ra(t){const s=t.replace(/\s*\[[^\]]*\]\s*$/,""),n=s.indexOf(" - ");return n===-1?{pageName:null,stateName:s}:{pageName:s.slice(0,n),stateName:s.slice(n+3)}}function ad(t){return wo(t)?t.componentName??Ra(t.name).pageName:Ra(t.name).pageName}function wr(t){return Ra(t.name).stateName}function od({currentScenario:t,scenarioGroups:s,onSelect:n,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)},h=m=>{d.current&&c({x:m.clientX-d.current.dx,y:m.clientY-d.current.dy})},p=m=>{d.current=null,m.currentTarget.releasePointerCapture(m.pointerId)},f=l.useMemo(()=>Eo(t,s),[t,s]);return e.jsxs("div",{className:"fixed z-50 flex flex-col rounded-xl border border-[#3d3d3d] bg-[#1b1b1b] shadow-2xl",style:{left:i.x,top:i.y,width:320,maxHeight:"70vh"},role:"dialog","aria-label":"Scenarios",children:[e.jsxs("div",{onPointerDown:u,onPointerMove:h,onPointerUp:p,className:"flex items-center justify-between px-3 py-2 border-b border-[#3d3d3d] cursor-move select-none",children:[e.jsx("span",{className:"text-[11px] font-mono font-semibold tracking-widest text-gray-300",children:"SCENARIOS"}),e.jsx("button",{type:"button",onClick:a,onPointerDown:m=>m.stopPropagation(),"aria-label":"Close scenarios",className:"text-gray-400 hover:text-white text-lg leading-none px-1 cursor-pointer",children:"×"})]}),e.jsx("div",{className:"overflow-y-auto p-2 flex flex-col gap-2 flex-1 min-h-0",children:f.map(m=>{const b=m.slug===t.slug,g=m.screenshotPaths[0];return e.jsxs("button",{type:"button",onClick:()=>n(m.slug),className:`flex items-center gap-3 w-full p-2 rounded-lg text-left transition-colors cursor-pointer border ${b?"border-[var(--lime-300)] bg-[#1a2a30]":"border-[#333] hover:bg-[#242424]"}`,children:[e.jsx("div",{className:"w-24 h-16 shrink-0 rounded-md overflow-hidden border border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:g?e.jsx("img",{src:ns(g),alt:"",className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-[10px] text-gray-600",children:"No preview"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[11px] text-gray-500 truncate",children:m.url??"component"}),e.jsx("div",{className:`text-sm font-medium truncate ${b?"text-white":"text-gray-200"}`,children:wr(m)})]})]},m.slug)})}),e.jsx("button",{type:"button",onClick:r,className:"border-t border-[#3d3d3d] px-3 py-2.5 text-left text-[11px] font-mono tracking-wide text-[var(--accent-active)] hover:bg-[var(--accent-active)]/10 cursor-pointer",children:"+ CREATE NEW STATE"})]})}const zT=Object.freeze(Object.defineProperty({__proto__:null,LivePageScenariosModal:od},Symbol.toStringTag,{value:"Module"})),ws={apps:[],isSingleApp:!1,onSelectApps:()=>{},onSelectApp:()=>{},onSelectRoute:()=>{}};function _s(){const[t,s]=l.useState({}),n=l.useRef({});return l.useEffect(()=>{let r=!1;const a=async()=>{try{const i=await fetch("/api/editor-dev-server");if(!i.ok)return;const c=await i.json();if(r)return;const d=typeof c.scenariosVersion=="number"?c.scenariosVersion:void 0,u=typeof c.plansVersion=="number"?c.plansVersion:void 0,h=typeof c.testsVersion=="number"?c.testsVersion:void 0,p=typeof c.claimsVersion=="number"?c.claimsVersion:void 0,f=typeof c.sourceVersion=="number"?c.sourceVersion:void 0,m=typeof c.liveReloadEnabled=="boolean"?c.liveReloadEnabled:void 0;(d!==n.current.scenariosVersion||u!==n.current.plansVersion||h!==n.current.testsVersion||p!==n.current.claimsVersion||f!==n.current.sourceVersion||m!==n.current.liveReloadEnabled)&&(n.current={scenariosVersion:d,plansVersion:u,testsVersion:h,claimsVersion:p,sourceVersion:f,liveReloadEnabled:m},s(n.current))}catch{}};a();const o=setInterval(a,500);return()=>{r=!0,clearInterval(o)}},[]),t}function Yw(t){const[s,n]=l.useState({status:"idle"}),{scenariosVersion:r}=_s();return l.useEffect(()=>{if(!t){n({status:"idle"});return}let a=!1;return n({status:"loading"}),(async()=>{try{const o=await fetch(`/api/entities/${t}`);if(a)return;if(o.status===404){n({status:"not-found"});return}if(!o.ok){n({status:"error",message:`HTTP ${o.status}`});return}const i=await o.json(),c={...i,scenarios:Array.isArray(i.scenarios)?i.scenarios.map(_o):[]};n({status:"loaded",entity:c})}catch(o){if(a)return;n({status:"error",message:o instanceof Error?o.message:"Failed to load entity"})}})(),()=>{a=!0}},[t,r]),s}function Yn({message:t}){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--accent-red)]",children:t})}const $T=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentError:Yn},Symbol.toStringTag,{value:"Module"}));function Ea(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"Loading routes..."})}const BT=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentLoading:Ea},Symbol.toStringTag,{value:"Module"}));function Vw(t){return t.kind==="function"?"Functions don't have visual scenarios. Coverage for this function lives in its unit tests.":t.kind==="component"?`No component scenarios for ${t.displayName}. Create one with \`codeyam-editor editor register\` or capture from the live preview.`:"No scenarios for this entity yet."}function id({entityRef:t,onNavigate:s}){return e.jsxs("button",{type:"button",onClick:()=>s(t.hash),className:"w-full rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 text-left transition hover:border-[var(--border-default)]",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"rounded-md border border-[var(--border-subtle)] bg-[var(--bg-page)] px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[var(--text-dim)]",children:t.kind}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.name})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath})]})}const qT=Object.freeze(Object.defineProperty({__proto__:null,EntityRefCard:id},Symbol.toStringTag,{value:"Module"}));function Vn({refs:t,onNavigate:s}){return e.jsx("ul",{className:"grid grid-cols-1 gap-1",children:t.map(n=>e.jsx("li",{children:e.jsx(id,{entityRef:n,onNavigate:s})},n.hash))})}const HT=Object.freeze(Object.defineProperty({__proto__:null,EntityRefList:Vn},Symbol.toStringTag,{value:"Module"}));function Kw(t,s,n){const[r,a]=l.useState(!1),[o,i]=l.useState(""),[c,d]=l.useState(!1),u=l.useCallback(()=>{a(!0),i(s)},[s]),h=l.useCallback(()=>{a(!1)},[]),p=l.useCallback(async()=>{if(!(!o.trim()||c)){d(!0);try{const f=await fetch(`/api/scenarios/${encodeURIComponent(t)}`);if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await f.json();m.name=o.trim(),await fetch(`/api/scenarios/${encodeURIComponent(t)}`,{method:"DELETE"}),await fetch("/api/scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),a(!1),n()}catch{}finally{d(!1)}}},[o,c,t,n]);return{renaming:r,renameName:o,renameSaving:c,setRenameName:i,startRename:u,cancelRename:h,submitRename:p}}function Jw(t,s,n){const[r,a]=l.useState(!1),o=l.useCallback(async i=>{if(i.stopPropagation(),!!confirm(`Delete scenario "${s}"?`)){a(!0);try{await fetch(`/api/scenarios/${encodeURIComponent(t)}`,{method:"DELETE"}),n()}catch{}finally{a(!1)}}},[s,t,n]);return{deleting:r,handleDelete:o}}function Xw({mocks:t,seeds:s}){const n=[];return t>0&&n.push(`${t} ${t===1?"mock":"mocks"} overridden`),s>0&&n.push(`${s} ${s===1?"seed":"seeds"} overridden`),n.length===0?null:n.join(" · ")}function ld({overrideCounts:t}){const s=t?Xw(t):null;return s?e.jsx("div",{className:"text-xs text-[var(--text-dim)] mt-1",children:s}):null}const WT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowOverrideBadge:ld},Symbol.toStringTag,{value:"Module"})),Qw=new Set(["Desktop"]);function cd(t){var s,n;return(s=t.componentName)!=null&&s.trim()?`Isolated ${t.componentName.trim()} component`:(n=t.url)!=null&&n.trim()?`Renders ${t.url.trim()}`:t.scenarioType==="component"?"Component scenario":"Application scenario"}function dd({scenario:t,isSelected:s}){var r;const n=t.dimensions.length>0&&!(t.dimensions.length===1&&Qw.has(t.dimensions[0]));return e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-base font-medium truncate ${s?"text-[var(--accent-active)]":"text-[var(--text-primary)]"}`,children:t.name}),(r=t.description)!=null&&r.trim()?e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1 whitespace-pre-line",children:t.description}):e.jsx("div",{className:"text-sm text-[var(--text-dim)] italic mt-1",children:cd(t)}),e.jsx(ld,{overrideCounts:t.overrideCounts}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[n?e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:t.dimensions.join(", ")}):null,t.componentName?e.jsx("span",{className:"text-xs text-[var(--accent-purple)]",children:t.componentName}):null]})]})}const GT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowMeta:dd,deriveRowLabel:cd},Symbol.toStringTag,{value:"Module"}));function ud({screenshotPath:t,cacheBuster:s}){return e.jsx("div",{className:"h-[180px] w-[288px] shrink-0 flex items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-surface)]",children:e.jsx(Nt,{screenshotPath:t??void 0,cacheBuster:s??void 0,alt:""})})}const UT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowThumbnail:ud},Symbol.toStringTag,{value:"Module"}));function hd({onViewData:t,onRename:s,onDelete:n,deleting:r}){return e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("button",{onClick:t,className:"text-xs text-[var(--accent-active)] hover:opacity-70 cursor-pointer bg-transparent border-none p-0",children:"View / Edit Data"}),e.jsx("button",{onClick:s,className:"text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer bg-transparent border-none p-0",children:"Rename"}),e.jsx("button",{onClick:n,disabled:r,className:"text-xs text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none p-0",children:"Delete"})]})}const YT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowActions:hd},Symbol.toStringTag,{value:"Module"}));function pd({name:t,saving:s,onChange:n,onSubmit:r,onCancel:a}){return e.jsxs("form",{className:"flex items-center gap-2",onSubmit:r,onClick:o=>o.stopPropagation(),children:[e.jsx("input",{type:"text",value:t,onChange:o=>n(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:s}),e.jsx("button",{type:"submit",disabled:s||!t.trim(),className:"px-3 py-1.5 text-xs bg-[var(--accent-active)] text-[var(--bg-base)] rounded hover:opacity-90 disabled:opacity-40 cursor-pointer border-none",children:s?"...":"Save"}),e.jsx("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer bg-transparent border-none",children:"Cancel"})]})}const VT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRenameForm:pd},Symbol.toStringTag,{value:"Module"}));function md({scenario:t,isSelected:s,onSelect:n,onViewData:r,onScenariosChanged:a,children:o}){const i=Kw(t.slug,t.name,a),{deleting:c,handleDelete:d}=Jw(t.slug,t.name,a);return e.jsxs("div",{onClick:i.renaming?void 0:n,className:`rounded-lg p-3 text-left transition cursor-pointer ${s?"bg-[#1a2e1a] border border-[var(--accent-active)]/40":"bg-[var(--bg-card)] border border-transparent hover:bg-[var(--bg-input)]"}`,style:{opacity:c?.4:1},children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ud,{screenshotPath:t.screenshotPaths[0]??null,cacheBuster:t.screenshotCapturedAtMs}),e.jsx("div",{className:"flex-1 min-w-0",children:i.renaming?e.jsx(pd,{name:i.renameName,saving:i.renameSaving,onChange:i.setRenameName,onSubmit:u=>{u.preventDefault(),i.submitRename()},onCancel:i.cancelRename}):e.jsxs(e.Fragment,{children:[e.jsx(dd,{scenario:t,isSelected:s}),s&&e.jsx(hd,{onViewData:u=>{u.stopPropagation(),r()},onRename:u=>{u.stopPropagation(),i.startRename()},onDelete:d,deleting:c})]})})]}),o&&e.jsx("div",{className:"mt-3 cursor-default",onClick:u=>u.stopPropagation(),children:o})]})}const KT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRow:md},Symbol.toStringTag,{value:"Module"}));function fd(){return e.jsx("div",{className:"rounded-xl border border-dashed border-[var(--border-default)] px-4 py-5 text-sm text-[var(--text-dim)]",children:"No scenarios registered for this route yet."})}const JT=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioEmptyState:fd},Symbol.toStringTag,{value:"Module"}));function Mo({scenarios:t,selectedSlug:s,onSelectScenario:n,onScenariosChanged:r}){const[a,o]=l.useState(null);return t.length===0?e.jsx(fd,{}):e.jsx("div",{className:"grid grid-cols-1 gap-2",children:t.map(i=>e.jsx(md,{scenario:i,isSelected:i.slug===s,onSelect:()=>{a&&a!==i.slug&&o(null),n(i.slug)},onViewData:()=>o(a===i.slug?null:i.slug),onScenariosChanged:r,children:a===i.slug&&e.jsx(Zj,{variant:"inline",slug:i.slug,scenarioName:i.name,onClose:()=>o(null)})},i.slug))})}const XT=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioList:Mo},Symbol.toStringTag,{value:"Module"})),Zw="This component renders no other tracked components.",e0="This component imports no tracked functions.",t0="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 gd({activeTab:t,entity:s,componentRefs:n,functionRefs:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){return e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[t==="scenarios"&&(s.scenarios.length===0?e.jsx(Qs,{copy:Vw(s)}):e.jsx(Mo,{scenarios:s.scenarios,selectedSlug:a,onSelectScenario:o,onScenariosChanged:c})),t==="components"&&(n.length===0?e.jsx(Qs,{copy:Zw}):e.jsx(Vn,{refs:n,onNavigate:i})),t==="functions"&&(r.length===0?e.jsx(Qs,{copy:e0}):e.jsx(Vn,{refs:r,onNavigate:i})),t==="callers"&&(s.callers.length===0?e.jsx(Qs,{copy:t0}):e.jsx(Vn,{refs:s.callers,onNavigate:i}))]})}function Qs({copy:t}){return e.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:t})}const QT=Object.freeze(Object.defineProperty({__proto__:null,EmptyTabCopy:Qs,EntityDetailContent:gd},Symbol.toStringTag,{value:"Module"}));function s0(t){return typeof t!="string"&&typeof t.onClick=="function"}function n0(t){return typeof t=="string"?t:t.label}function r0(t,s){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s())}function bd({segments:t}){if(t.length===0)return null;const s=t.length-1;return e.jsx("span",{className:"text-sm",style:{color:"var(--text-muted)"},children:t.map((n,r)=>{const a=n0(n),o=r===s,i=!o&&s0(n);return e.jsxs("span",{children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:" / "}),i?e.jsx("button",{type:"button",onClick:n.onClick,onKeyDown:c=>r0(c,n.onClick),className:"cursor-pointer hover:text-[var(--text-primary)] transition",style:{color:"inherit",background:"none",padding:0},children:a}):e.jsx("span",{style:o?{color:"var(--text-primary)"}:void 0,children:a})]},r)})})}const ZT=Object.freeze(Object.defineProperty({__proto__:null,BreadcrumbNav:bd},Symbol.toStringTag,{value:"Module"}));function _r({apps:t,selectedApp:s,selectedRouteEntity:n,currentEntity:r,isSingleApp:a,onSelectApps:o,onSelectApp:i,onSelectRoute:c}){const d=[];if(!a&&t.length>0&&d.push({label:"Apps",onClick:o}),s){const h=n!==null||r!=null;a&&!h||d.push({label:s.name,onClick:()=>i(s.dir)})}return n!==null&&r!=null&&n?d.push({label:n.displayName,onClick:()=>c(n.route)}):n&&d.push({label:n.displayName}),r&&d.push({label:r.displayName}),e.jsx(bd,{segments:d})}const eA=Object.freeze(Object.defineProperty({__proto__:null,EntityBreadcrumb:_r},Symbol.toStringTag,{value:"Module"}));function xd({entity:t,app:s=null,routeEntity:n=null,navContext:r=ws}){var o;const a=t.kind==="component"?"Component":"Function";return e.jsxs("header",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[e.jsx("div",{className:"mb-1",children:e.jsx(_r,{apps:r.apps,selectedApp:s,selectedRouteEntity:n,currentEntity:t,isSingleApp:r.isSingleApp,onSelectApps:r.onSelectApps,onSelectApp:r.onSelectApp,onSelectRoute:r.onSelectRoute})}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"rounded-md border border-[var(--border-subtle)] bg-[var(--bg-card)] px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[var(--text-dim)]",children:a}),e.jsx("h2",{className:"text-base font-semibold text-[var(--text-primary)]",children:t.displayName})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath}),((o=t.glossaryEntry)==null?void 0:o.description)&&e.jsx("p",{className:"mt-2 text-xs text-[var(--text-secondary)]",children:t.glossaryEntry.description})]})}const tA=Object.freeze(Object.defineProperty({__proto__:null,EntityDetailHeader:xd},Symbol.toStringTag,{value:"Module"})),a0=["scenarios","components","functions"];function Io({activeTab:t,onTabChange:s,scenarioCount:n,componentCount:r=0,functionCount:a=0,callersCount:o=0,tabs:i=a0}){const c={scenarios:"Scenarios",components:"Components",functions:"Functions",callers:"Callers"},d={scenarios:n,components:r,functions:a,callers:o};return e.jsx("div",{className:"flex w-full border-t border-b border-[var(--border-default)]",children:i.map(u=>e.jsxs("button",{onClick:()=>s(u),className:`cursor-pointer px-4 py-2 font-mono text-xs font-medium uppercase tracking-wider transition border-b-2 ${t===u?"text-[var(--accent-active)] border-[var(--accent-active)]":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-muted)]"}`,type:"button",children:[c[u]," (",d[u],")"]},u))})}const sA=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityTabs:Io},Symbol.toStringTag,{value:"Module"})),o0=["scenarios","components","functions"],i0=["scenarios","callers"];function yd({app:t=null,navContext:s=ws,routeEntity:n=null,entity:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){const[d,u]=l.useState("scenarios"),{componentRefs:h,functionRefs:p}=l.useMemo(()=>{const m=[],b=[];for(const g of r.directImports)g.kind==="function"?b.push(g):m.push(g);return{componentRefs:m,functionRefs:b}},[r.directImports]),f=r.kind==="function"?i0:o0;return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(xd,{app:t,navContext:s,routeEntity:n,entity:r}),e.jsx(Io,{activeTab:d,onTabChange:u,scenarioCount:r.scenarios.length,componentCount:h.length,functionCount:p.length,callersCount:r.callers.length,tabs:f}),e.jsx(gd,{activeTab:d,entity:r,componentRefs:h,functionRefs:p,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c})]})}const nA=Object.freeze(Object.defineProperty({__proto__:null,EntityDetail:yd},Symbol.toStringTag,{value:"Module"}));function l0(t){const s=[],n=[];for(const r of t)tn(r.url)||(r.scenarioType==="component"?n.push(r):s.push(r));return{application:s,component:n}}function vd({scenario:t,onPreview:s}){const n=t.screenshotPaths.length>0,[r,a]=l.useState(!1),o=n&&!r;return e.jsxs("div",{className:`rounded-lg border border-[var(--border-default)] bg-[var(--bg-surface)] p-3 ${s?"cursor-pointer hover:border-[var(--border-subtle)]":""}`,onClick:s,children:[o?e.jsx("img",{src:ns(t.screenshotPaths[0],t.screenshotCapturedAtMs),alt:t.name,className:"mb-2 w-full rounded border border-[var(--border-default)]",onError:()=>a(!0)}):e.jsx("div",{className:"mb-2 flex h-32 items-center justify-center rounded border border-dashed border-[var(--border-default)] text-sm text-[var(--text-dim)]",children:"No screenshot"}),e.jsx("p",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t.name}),e.jsxs("div",{className:"mt-1 flex gap-1",children:[t.hasMocks&&e.jsx("span",{className:"rounded bg-[var(--accent-blue)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-blue)]",children:"mocks"}),t.hasSeed&&e.jsx("span",{className:"rounded bg-[var(--accent-purple)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-purple)]",children:"seed"}),t.dimensions.map(i=>e.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 text-xs text-[var(--text-muted)]",children:i},i))]})]})}const rA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioCard:vd},Symbol.toStringTag,{value:"Module"}));function Ma({label:t,scenarios:s,onSelectScenario:n,className:r}){return e.jsxs("section",{className:r,children:[e.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:t}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:s.map(a=>e.jsx(vd,{scenario:a,onPreview:()=>n(a.slug)},a.slug))})]})}const aA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioTypeSection:Ma},Symbol.toStringTag,{value:"Module"}));function jd({feature:t,passed:s,failed:n,total:r}){return e.jsxs("div",{className:"px-5 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t}),e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[r," test",r!==1?"s":""]}),r>0&&e.jsxs("span",{className:`text-xs font-medium ${n>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]"}`,children:[s,"/",r]})]})}const oA=Object.freeze(Object.defineProperty({__proto__:null,TestGroupHeader:jd},Symbol.toStringTag,{value:"Module"}));function wd({test:t}){const s=(t.description??"").length>0,n=t.status==="passed"?"text-[var(--accent-green)]":t.status==="failed"?"text-[var(--accent-red)]":"text-[var(--text-dim)]",r=t.status==="passed"?"✓":t.status==="failed"?"✗":"○";return e.jsxs("div",{className:"flex items-start gap-2 py-1 px-3",children:[e.jsx("span",{className:`text-xs leading-5 ${n}`,children:r}),e.jsx("div",{className:"min-w-0",children:s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:t.description}),e.jsx("p",{className:"font-mono text-[10px] text-[var(--text-dim)] truncate",children:t.key})]}):e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:t.key})})]})}const iA=Object.freeze(Object.defineProperty({__proto__:null,TestGroupRow:wd},Symbol.toStringTag,{value:"Module"}));function _d({groups:t}){return t.length===0?e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No tests found."}):e.jsx("div",{className:"py-3",children:t.map(s=>{const n=s.tests.filter(o=>o.status==="passed").length,r=s.tests.filter(o=>o.status==="failed").length,a=s.tests.length;return e.jsxs("div",{className:"mb-1",children:[e.jsx(jd,{feature:s.feature,passed:n,failed:r,total:a}),e.jsx("div",{className:"px-5 pb-2",children:s.tests.map((o,i)=>e.jsx(wd,{test:o},`${o.file}-${o.key??o.line??i}`))})]},s.feature)})})}const lA=Object.freeze(Object.defineProperty({__proto__:null,TestGroupList:_d},Symbol.toStringTag,{value:"Module"}));function kd({allScenarios:t,testGroups:s,onSelectScenario:n}){const{application:r,component:a}=l0(t),o=r.length>0||a.length>0;return e.jsxs("div",{className:"px-5 py-5",children:[o?e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx(Ma,{label:"Application",scenarios:r,onSelectScenario:n}),a.length>0&&e.jsx(Ma,{label:"Component",scenarios:a,onSelectScenario:n,className:r.length>0?"mt-8":void 0})]}):e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No scenarios yet"}),e.jsx("div",{className:"mt-8",children:e.jsx(_d,{groups:s})})]})}const cA=Object.freeze(Object.defineProperty({__proto__:null,NonWebAppDetail:kd},Symbol.toStringTag,{value:"Module"}));function c0(t,s){const n=[],r=[];for(const a of t){const o=js(a);/^[A-Z]/.test(o)&&!o.startsWith("use")?n.push(a):r.push(a)}return{componentImports:n,functionImports:r}}function Sd({ancestor:t,onNavigateToEntity:s}){const n=s?()=>s(bn(t.filePath,js(t.filePath))):void 0;return e.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:r=>{n&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n())},className:"cursor-pointer rounded-md border border-[var(--border-subtle)] bg-[var(--bg-card)] px-3 py-2 transition hover:border-[var(--border-default)]",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.displayName}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath})]})}const dA=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainCard:Sd},Symbol.toStringTag,{value:"Module"}));function Nd({layoutChain:t,onNavigateToEntity:s}){return t.length===0?null:e.jsxs("section",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[e.jsx("h3",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:"Layout chain"}),e.jsx("div",{className:"flex flex-col gap-1",children:t.map(n=>e.jsx(Sd,{ancestor:n,onNavigateToEntity:s},`${n.kind}:${n.filePath}`))})]})}const uA=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainSection:Nd},Symbol.toStringTag,{value:"Module"}));function d0({importPath:t,derivedName:s,allScenarios:n,routeEntities:r}){const a=n.filter(i=>i.scenarioType==="component"&&(i.pageFilePath===t||i.componentName===s)),o=r.filter(i=>i.directImports.length===1&&i.directImports[0]===t&&js(i.directImports[0])===s);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 Kn(t){const s=[];for(const n of t.split("/"))n===""||n==="."||(n===".."?s.pop():s.push(n));return s.join("/")}function u0(t){const s=new Map;for(const[n,r]of Object.entries(t)){const a=Kn(n),o=js(a),i=bn(a,o);s.has(i)||s.set(i,{hash:i,filePath:a,entityName:o,imports:r.imports.map(Kn),importedBy:r.importedBy.map(Kn)})}return s}function h0(t,s){if(!t)return null;const n=Kn(s);for(const r of t.values())if(r.filePath===n)return r;return null}function Cd(t,s){if(!t)return[];const n=[];for(const r of s){const a=h0(t,r);a&&n.push(a)}return n}function p0(t,s){return t.find(n=>n.pageFilePath===s)??null}function Pd(t){const s=t.split("/"),n=s.pop()??t,r=s.join("/");return{fileName:n,dirPath:r}}function Td({displayName:t,entity:s,isNavigable:n}){return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-lg font-semibold text-[var(--text-secondary)]",children:t}),s?e.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 font-mono text-[9px] text-[var(--text-dim)]",children:s.hash.slice(0,8)}):null,n?e.jsx("span",{className:"ml-auto text-[10px] text-[var(--text-dim)]",children:"→"}):null]})}const hA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCardHeader:Td},Symbol.toStringTag,{value:"Module"}));function Ad({scenarios:t,onSelectScenario:s}){return t.length===0?e.jsx("p",{className:"mt-1 text-[10px] text-[var(--text-dim)]",children:"No scenarios"}):e.jsxs("div",{className:"mt-2 flex flex-row gap-1.5",children:[t.slice(0,4).map(n=>{const r=n.screenshotPaths[0]??null;return e.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),s(n.slug)},className:"flex w-[192px] shrink-0 flex-col gap-1 transition",children:[e.jsx("div",{className:"flex h-[120px] w-[192px] items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] transition hover:border-[var(--border-default)]",children:e.jsx(Nt,{screenshotPath:r??void 0,alt:n.name})}),e.jsx("span",{className:"w-full truncate text-center text-[10px] text-[var(--text-secondary)]",children:n.name})]},n.slug)}),t.length>4&&e.jsx("div",{className:"flex h-[120px] items-center px-1",children:e.jsxs("span",{className:"text-[10px] text-[var(--text-dim)]",children:["+",t.length-4]})})]})}const pA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyScenarioStrip:Ad},Symbol.toStringTag,{value:"Module"}));function Od({importPath:t,entity:s,scenarios:n,onNavigate:r,onSelectScenario:a}){const{fileName:o,dirPath:i}=Pd(t),c=(s==null?void 0:s.entityName)??o.replace(/\.[^.]+$/,"");return e.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r??void 0,onKeyDown:r?d=>{(d.key==="Enter"||d.key===" ")&&r()}:void 0,className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 transition hover:border-[var(--border-default)] ${r?"cursor-pointer":""}`,children:[e.jsx(Td,{displayName:c,entity:s,isNavigable:r!==null}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[i,"/"]}),e.jsx(Ad,{scenarios:n,onSelectScenario:a})]})}const mA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCard:Od},Symbol.toStringTag,{value:"Module"}));function Rd(){return e.jsx("p",{className:"py-4 text-center text-xs text-[var(--text-dim)]",children:"No dependencies found"})}const fA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyEmptyState:Rd},Symbol.toStringTag,{value:"Module"}));function Ed({directImports:t,entityLookup:s,allScenarios:n,routeEntities:r,onNavigateToRoute:a,onNavigateToEntity:o,onSelectScenario:i}){const c=l.useMemo(()=>Cd(s,t),[s,t]);return t.length===0?e.jsx(Rd,{}):e.jsx("div",{className:"grid grid-cols-1 gap-1",children:t.map(d=>{const u=c.find(g=>g.filePath===d)??null,h=(u==null?void 0:u.entityName)??js(d),p=d0({importPath:d,derivedName:h,allScenarios:n??[],routeEntities:r??[]}),f=p0(r??[],d),m=bn(d,h),b=f?()=>a(f.route):o?()=>o(m):null;return e.jsx(Od,{importPath:d,entity:u,scenarios:p,onNavigate:b,onSelectScenario:i},d)})})}const gA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyList:Ed},Symbol.toStringTag,{value:"Module"}));function m0(t,s,n){const r=new Set,a=t.replace(/\.(ts|tsx)$/,"");r.add(`${a}.test.ts`),r.add(`${a}.test.tsx`);const o=s.get(t);if(o!=null&&o.importedBy)for(const c of o.importedBy)/\.test\.(ts|tsx)$/.test(c)&&r.add(c);return n.flatMap(c=>c.tests).filter(c=>r.has(c.file))}function Md({status:t}){return t==="passed"?e.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-green)]",children:"✓"}):t==="failed"?e.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-red)]",children:"✗"}):e.jsx("span",{className:"mt-0.5 text-xs text-[var(--text-dim)]",children:"○"})}const bA=Object.freeze(Object.defineProperty({__proto__:null,TestStatusIcon:Md},Symbol.toStringTag,{value:"Module"}));function Id({test:t}){const s=t.description.length>0;return e.jsxs("div",{className:"flex items-start gap-2 py-1",children:[e.jsx(Md,{status:t.status}),e.jsx("div",{children:s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.description}),e.jsx("p",{className:"font-mono text-xs text-[var(--text-dim)]",children:t.key})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.key}),e.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:"no description"})]})})]})}const xA=Object.freeze(Object.defineProperty({__proto__:null,TestItem:Id},Symbol.toStringTag,{value:"Module"}));function Dd({importPath:t,entityName:s,tests:n,onNavigate:r}){const{dirPath:a}=Pd(t);return e.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r??void 0,onKeyDown:r?o=>{(o.key==="Enter"||o.key===" ")&&r()}:void 0,className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 transition hover:border-[var(--border-default)] ${r?"cursor-pointer":""}`,children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:s}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[a,"/"]}),e.jsx("div",{className:"mt-2",children:n.length>0?e.jsx("div",{className:"space-y-0.5",children:n.map((o,i)=>e.jsx(Id,{test:o},`${o.file}:${o.key??o.line??i}`))}):e.jsx("p",{className:"text-xs text-[var(--text-dim)] italic",children:"No tests"})})]})}const yA=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionCard:Dd},Symbol.toStringTag,{value:"Module"}));function Ld(){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No function imports found"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-dim)]",children:"This component only imports other components"})]})}const vA=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionEmptyState:Ld},Symbol.toStringTag,{value:"Module"}));function Fd({functionImports:t,entityLookup:s,testGroups:n,onNavigateToEntity:r}){const a=l.useMemo(()=>Cd(s,t),[s,t]);return t.length===0?e.jsx(Ld,{}):e.jsx("div",{className:"grid grid-cols-1 gap-1",children:t.map(o=>{const i=a.find(h=>h.filePath===o)??null,c=(i==null?void 0:i.entityName)??js(o),d=m0(o,s,n),u=r?()=>r(bn(o,c)):null;return e.jsx(Dd,{importPath:o,entityName:c,tests:d,onNavigate:u},o)})})}const jA=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionList:Fd},Symbol.toStringTag,{value:"Module"}));function zd({activeTab:t,routeEntity:s,componentImports:n,functionImports:r,testGroups:a,selectedSlug:o,entityLookup:i,allScenarios:c,routeEntities:d,onSelectScenario:u,onNavigateToRoute:h,onNavigateToEntity:p,onScenariosChanged:f}){return e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[t==="scenarios"&&e.jsx(Mo,{scenarios:s.scenarios,selectedSlug:o,onSelectScenario:u,onScenariosChanged:f}),t==="components"&&e.jsx(Ed,{directImports:n,entityLookup:i,allScenarios:c,routeEntities:d,onNavigateToRoute:h,onNavigateToEntity:p,onSelectScenario:u}),t==="functions"&&e.jsx(Fd,{functionImports:r,entityLookup:i,testGroups:a,onNavigateToEntity:p})]})}const wA=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailContent:zd},Symbol.toStringTag,{value:"Module"}));function $d({displayName:t,pageFilePath:s,app:n=null,routeEntity:r=null,navContext:a=ws}){return e.jsxs("div",{className:"px-5 py-4",children:[e.jsx("div",{className:"mb-2",children:e.jsx(_r,{apps:a.apps,selectedApp:n,selectedRouteEntity:r,isSingleApp:a.isSingleApp,onSelectApps:a.onSelectApps,onSelectApp:a.onSelectApp,onSelectRoute:a.onSelectRoute})}),e.jsx("h2",{className:"text-xl font-medium text-[var(--text-primary)]",children:t}),s?e.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--text-dim)]",children:s}):null]})}const _A=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailHeader:$d},Symbol.toStringTag,{value:"Module"}));function Bd({app:t=null,navContext:s=ws,routeEntity:n,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,testGroups:c,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:h,onScenariosChanged:p}){const[f,m]=l.useState("scenarios"),{componentImports:b,functionImports:g}=l.useMemo(()=>c0(n.directImports),[n.directImports]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx($d,{app:t,navContext:s,routeEntity:n,displayName:n.displayName,pageFilePath:n.pageFilePath}),e.jsx(Nd,{layoutChain:n.layoutChain??[],onNavigateToEntity:h}),e.jsx(Io,{activeTab:f,onTabChange:m,scenarioCount:n.scenarios.length,componentCount:b.length,functionCount:g.length}),e.jsx(zd,{activeTab:f,routeEntity:n,componentImports:b,functionImports:g,testGroups:c,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:h,onScenariosChanged:p})]})}const kA=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetail:Bd},Symbol.toStringTag,{value:"Module"}));function qd(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No routes discovered yet."})}const SA=Object.freeze(Object.defineProperty({__proto__:null,RouteListEmptyState:qd},Symbol.toStringTag,{value:"Module"}));function Hd({label:t="Pages"}={}){return e.jsx("div",{className:"mb-3",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)]",children:t})})}const NA=Object.freeze(Object.defineProperty({__proto__:null,RouteListSectionHeader:Hd},Symbol.toStringTag,{value:"Module"}));function Ia({label:t,routeEntities:s,onSelectRoute:n,onSelectScenario:r,className:a}){return e.jsxs("div",{className:a,children:[e.jsx(Hd,{label:t}),e.jsx("div",{children:s.map(o=>e.jsx(Ro,{routeEntity:o,onSelectRoute:n,onSelectScenario:r},o.route))})]})}const CA=Object.freeze(Object.defineProperty({__proto__:null,RouteListSection:Ia},Symbol.toStringTag,{value:"Module"}));function Wd({providerLabel:t,chatOpen:s,onToggleChat:n}){const r=s?"border-[var(--accent-active)] bg-[var(--accent-active)]/15 text-[var(--accent-active)]":"border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40";return e.jsxs("button",{type:"button",onClick:n,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors ${r}`,title:`Open a chat with ${t} to investigate why this page is not shown`,children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),s?"Close":`Investigate with ${t}`]})}const PA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageInvestigateButton:Wd},Symbol.toStringTag,{value:"Module"}));function Gd({displayName:t,path:s}){return e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--text-primary)] truncate",children:t}),e.jsx("p",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:s})]})}const TA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRowSummary:Gd},Symbol.toStringTag,{value:"Module"}));function f0(t,s){return s==="scaffold"?[`The page \`${t}\` is marked \`untestabilityReason.kind = scaffold\` in the glossary, so it is intentionally excluded from the App tab's product route list.`,"Confirm that marking is correct: read the file and decide whether it is genuinely a scaffold / dev-only shim rather than product surface.","If it IS a real product route, remove the scaffold marking and register it properly (deconstruct it into the glossary and capture at least one scenario for it). If the marking is correct, say so and explain in one line why — no changes needed."].join(`
2
-
3
- `):[`The page \`${t}\` is discovered on disk but has NO glossary entry, so codeyam cannot tell whether it is product surface — it is excluded from the App tab's route list until it is registered.`,"Investigate whether it is a real product route.","If it IS product surface, deconstruct and register it in the glossary and capture at least one scenario for it so it appears in the route list. If it is instead a scaffold or dev-only shim, add it to the glossary marked `untestabilityReason.kind = scaffold` with a justification."].join(`
4
-
5
- `)}function g0({path:t,reason:s}){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.",f0(t,s),"Propose the concrete change and, once the user agrees, make it. Prefer real edits and commands over generic advice."].join(`
6
-
7
- `)}function Ud(t){return t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}function Yd({page:t}){const[s,n]=l.useState(!1),{config:r}=St(),a=zt(r==null?void 0:r.provider);return e.jsxs("div",{className:"border border-[var(--border-subtle)] rounded mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsx(Gd,{displayName:t.displayName,path:t.path}),e.jsx(Wd,{providerLabel:a,chatOpen:s,onToggleChat:()=>n(o=>!o)})]}),s&&e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:e.jsx(vs,{chatName:`fix-unsurfaced-${Ud(t.path)}`,prompt:g0({path:t.path,reason:t.reason}),height:360,onClose:()=>n(!1)})})]})}const AA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRow:Yd,chatSlug:Ud},Symbol.toStringTag,{value:"Module"}));function Vd({label:t,pages:s}){return s.length===0?null:e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-2 text-xs text-[var(--text-dim)]",children:t}),s.map(n=>e.jsx(Yd,{page:n},n.path))]})}const OA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageGroup:Vd},Symbol.toStringTag,{value:"Module"}));function Kd({count:t,collapsed:s,onToggle:n}){return e.jsxs("button",{type:"button",onClick:n,className:"mb-3 flex items-center gap-2 cursor-pointer group","aria-expanded":!s,children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`text-[var(--text-dim)] transition-transform ${s?"":"rotate-90"}`,children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)] group-hover:text-[var(--text-primary)]",children:["Not shown (",t,")"]})]})}const RA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSectionHeader:Kd},Symbol.toStringTag,{value:"Module"})),b0=[{reason:"missing-from-glossary",label:"Missing from glossary"},{reason:"scaffold",label:"Marked as scaffold"}];function Jd({pages:t}){const[s,n]=l.useState(!0);return t.length===0?null:e.jsxs("div",{className:"mt-8",children:[e.jsx(Kd,{count:t.length,collapsed:s,onToggle:()=>n(r=>!r)}),!s&&e.jsx("div",{children:b0.map(({reason:r,label:a})=>e.jsx(Vd,{label:a,pages:t.filter(o=>o.reason===r)},r))})]})}const EA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSection:Jd},Symbol.toStringTag,{value:"Module"}));function Xd({routeEntities:t,unsurfacedPages:s=[],componentSurfaceReason:n=null,onSelectRoute:r,onSelectScenario:a,tabbed:o=!1,headerAccessory:i}){if(t.length===0&&s.length===0)return e.jsx(qd,{});const c=t.filter(u=>(u.kind??"application")==="application"),d=t.filter(u=>u.kind==="component");return o?e.jsx("div",{className:"px-5 py-5",children:e.jsx(rd,{pages:c,components:d,componentSurfaceReason:n,onSelectRoute:r,onSelectScenario:a,headerAccessory:i})}):e.jsxs("div",{className:"px-5 py-5",children:[t.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No routes are being shown — every discovered page was excluded. See below."}),c.length>0&&e.jsx(Ia,{label:"Pages",routeEntities:c,onSelectRoute:r,onSelectScenario:a}),d.length>0&&e.jsx(Ia,{label:"Components",routeEntities:d,onSelectRoute:r,onSelectScenario:a,className:c.length>0?"mt-8":void 0}),e.jsx(Jd,{pages:s})]})}const MA=Object.freeze(Object.defineProperty({__proto__:null,RouteList:Xd},Symbol.toStringTag,{value:"Module"}));function Do({app:t=null,navContext:s=ws,isWeb:n,routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,routesLoading:i,routesError:c,selectedEntityHash:d,selectedRouteEntity:u,testGroups:h,selectedSlug:p,entityLookup:f,allScenarios:m,onSelectScenario:b,onSelectRoute:g,onSelectEntity:x,onBackToRoutes:y,onScenariosChanged:v,routeListTabbed:j=!1,routeListHeaderAccessory:w}){const _=Yw(d&&!u?d:null);return n?i?e.jsx(Ea,{}):c?e.jsx(Yn,{message:c}):u?e.jsx(Bd,{app:t,navContext:s,routeEntity:u,selectedSlug:p,entityLookup:f,allScenarios:m,routeEntities:r,testGroups:h,onSelectScenario:b,onNavigateToRoute:g,onNavigateToEntity:x,onScenariosChanged:v}):d?_.status==="loading"||_.status==="idle"?e.jsx(Ea,{}):_.status==="not-found"?e.jsx(Yn,{message:"Entity not found. The dependency graph may need to be refreshed."}):_.status==="error"?e.jsx(Yn,{message:_.message}):e.jsx(yd,{app:t,navContext:s,routeEntity:u,entity:_.entity,selectedSlug:p,onSelectScenario:b,onNavigateToEntity:x??(()=>{}),onScenariosChanged:v}):e.jsx(Xd,{routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,onSelectRoute:g,onSelectScenario:b,tabbed:j,headerAccessory:w}):e.jsx(kd,{allScenarios:m,testGroups:h,onSelectScenario:b})}const IA=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContent:Do},Symbol.toStringTag,{value:"Module"}));function Qd({appDetailProps:t,selectedApp:s}){const[n,r]=l.useState({signal:0,collapsed:!1}),a=()=>r(o=>({signal:o.signal+1,collapsed:!o.collapsed}));return e.jsx("div",{style:{padding:"8px 10% 50px"},children:e.jsxs("div",{style:{width:"100%",maxWidth:2200,marginInline:"auto"},children:[e.jsx("h2",{style:{fontSize:27,fontWeight:700,letterSpacing:"-0.02em",color:"var(--text-strong)",margin:"0 0 20px"},children:"Explore your app"}),e.jsx(td.Provider,{value:n,children:e.jsx("div",{className:"-mx-5",children:e.jsx(Do,{...t,app:s,isWeb:(s==null?void 0:s.type)==="web",selectedEntityHash:t.selectedEntityHash??null,routeListTabbed:!0,routeListHeaderAccessory:e.jsx("button",{type:"button",onClick:a,className:"text-[11px] font-semibold tracking-widest uppercase text-[var(--text-dim)] hover:text-[var(--text-primary)] border border-[var(--border-subtle)] rounded px-3 py-1.5 transition",children:n.collapsed?"Expand all":"Collapse all"})})})})]})})}const DA=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreSection:Qd},Symbol.toStringTag,{value:"Module"}));function oe({icon:t,title:s,meta:n,onBack:r,crumbLabel:a,assistKey:o}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:r,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:r,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:r,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:a??s})]}),e.jsxs("div",{className:"htitle",children:[e.jsx("div",{className:"hic",children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"h",children:s}),e.jsx("div",{className:"hmeta",children:n})]})]})]})}function Jt({topic:t,step:s,onBack:n}){return e.jsxs("div",{className:"crumbs",children:[n?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:n,children:t})]}):e.jsx("span",{children:t}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:s})]})}function Mt({steps:t,currentKey:s}){const n=t.findIndex(r=>r.key===s);return e.jsx("div",{className:"flowbar",children:t.map((r,a)=>e.jsxs("span",{style:{display:"contents"},children:[a>0?e.jsx("span",{className:"fsep"}):null,e.jsxs("span",{className:"fstep"+(a<n?" done":a===n?" active":""),children:[e.jsx("span",{className:"fn",children:a<n?"✓":a+1}),r.label]})]},r.key))})}function he({label:t,note:s,status:n,onComplete:r,onRevert:a,onBack:o,doneLabel:i="Completed"}){const[c,d]=l.useState(!1);return n==="done"||c?e.jsx("div",{className:"cta-wrap",children:e.jsxs("div",{className:"cta-done",children:[e.jsxs("span",{className:"cta-done-check",children:[e.jsx("span",{className:"ce",children:"✓"})," ",i]}),e.jsxs("div",{className:"cta-done-actions",children:[o?e.jsx("button",{type:"button",className:"lf-back",onClick:o,children:"Back to Setup"}):null,a?e.jsx("button",{type:"button",className:"cta-revert",onClick:()=>{a(),d(!1)},children:"Mark as not complete"}):null]})]})}):e.jsxs("div",{className:"cta-wrap",children:[e.jsxs("button",{type:"button",className:"cta",onClick:()=>{r(),d(!0)},children:[e.jsx("span",{className:"ce",children:"✓"})," ",t]}),e.jsx("div",{className:"cta-note",children:s})]})}const LA=Object.freeze(Object.defineProperty({__proto__:null,SetupCompleteCta:he,SetupDetailHeader:oe,SetupFlowBar:Mt,SetupSubCrumb:Jt},Symbol.toStringTag,{value:"Module"}));function kr({initial:t,color:s}){return e.jsx("div",{className:"altmark",style:{background:s,width:46,height:46},children:t})}function Lo({provider:t}){return e.jsxs("div",{className:"provcard"+(t.bestFit?" best":""),children:[e.jsx(kr,{initial:t.initial,color:t.color}),e.jsxs("div",{className:"provbody",children:[e.jsxs("div",{className:"provtop",children:[e.jsx("span",{className:"provname",children:t.name}),t.bestFit?e.jsx("span",{className:"bestfit",children:"Best fit"}):null]}),e.jsx("div",{className:"provdesc",children:t.description}),e.jsx("div",{className:"reasons",children:t.reasons.map(s=>e.jsxs("div",{className:"reason",children:[e.jsx($e,{}),e.jsxs("span",{children:[e.jsx("b",{children:s.lead})," ",s.rest]})]},s.lead))}),e.jsx("div",{className:"chips",children:t.chips.map(s=>e.jsx("span",{className:"chip",children:s},s))})]})]})}function Zd({alts:t}){const[s,n]=l.useState(!1);return t.length===0?null:e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>n(r=>!r),children:[s?"Hide other options":"Not for you? See other options",e.jsx("span",{className:"chev",style:{transform:s?"rotate(180deg)":"none"},children:"⌄"})]}),s?e.jsx("div",{className:"alts",children:t.map(r=>e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:r.color},children:r.initial}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:r.name}),e.jsx("div",{className:"altdesc",children:r.description})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]},r.name))}):null]})}function Ye({items:t}){return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),e.jsx(eu,{items:t})]})}function eu({items:t}){const[s,n]=l.useState(-1);return t.length===0?null:e.jsx("div",{className:"faq",children:t.map((r,a)=>e.jsxs("div",{className:"faqitem",children:[e.jsxs("button",{type:"button",className:"faqq"+(s===a?" open":""),onClick:()=>n(s===a?-1:a),children:[r.q,e.jsx("span",{className:"chev",children:"⌄"})]}),s===a?e.jsx("div",{className:"faqa",children:r.a}):null]},r.q))})}const FA=Object.freeze(Object.defineProperty({__proto__:null,Alternatives:Zd,FaqSection:Ye,ProviderCard:Lo,ProviderMark:kr,TopicFaq:eu},Symbol.toStringTag,{value:"Module"}));function Fo({icon:t,title:s,meta:n,crumbLabel:r,assistKey:a,onBack:o,lead:i,illustration:c,chatPrompt:d,onChatWithAI:u,faqs:h}){return e.jsxs("div",{className:"hosting-screen setup-topic",children:[e.jsx(oe,{icon:t,title:s,meta:n,crumbLabel:r,onBack:o,assistKey:a}),e.jsx("div",{className:"lead",children:i}),c,e.jsx("div",{className:"cta-wrap",children:e.jsx("button",{type:"button",className:"cta",onClick:()=>u==null?void 0:u(d),children:"Chat with the AI about this"})}),e.jsx(Ye,{items:h})]})}const zA=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPage:Fo},Symbol.toStringTag,{value:"Module"}));function ps({before:t,after:s}){return e.jsxs("div",{className:"setup-ill ill-split",children:[e.jsxs("div",{className:"isplit",children:[e.jsx("div",{className:"isplit-tag",children:t.tag}),t.items.map(n=>e.jsxs("div",{className:"isplit-row",children:[e.jsx("span",{className:"mk",children:"✕"}),e.jsx("span",{children:n})]},n))]}),e.jsx("div",{className:"isplit-arrow",children:"→"}),e.jsxs("div",{className:"isplit after",children:[e.jsx("div",{className:"isplit-tag",children:s.tag}),s.items.map(n=>e.jsxs("div",{className:"isplit-row",children:[e.jsx("span",{className:"mk",children:"✓"}),e.jsx("span",{children:n})]},n))]})]})}function ms({rows:t}){return e.jsx("div",{className:"setup-ill",children:e.jsx("div",{className:"ill-stack",children:t.map(s=>e.jsxs("div",{className:s.lime?"istack-row lime":"istack-row",children:[e.jsx("span",{className:"istack-emoji",children:s.emoji}),e.jsx("span",{className:"istack-lbl",children:s.label}),s.sub?e.jsx("span",{className:"istack-sub",children:s.sub}):null]},s.label))})})}function fs({center:t,satellites:s}){return e.jsx("div",{className:"setup-ill",children:e.jsxs("div",{className:"ill-orbit",children:[e.jsxs("div",{className:"iorbit-center",children:[e.jsx("div",{className:"iorbit-tile",children:t.emoji}),e.jsx("div",{className:"iorbit-lbl",children:t.label})]}),e.jsx("div",{className:"iorbit-sats",children:s.map(n=>e.jsx("div",{className:"iorbit-sat",children:n},n))})]})})}function Jn({bars:t}){return e.jsx("div",{className:"setup-ill",children:e.jsx("div",{className:"ill-bars",children:t.map(s=>e.jsxs("div",{className:s.lime?"ibar lime":"ibar",children:[e.jsx("div",{className:"ibar-fill",style:{height:`${s.pct}%`}}),e.jsx("div",{className:"ibar-lbl",children:s.label})]},s.label))})})}function Wt({emoji:t,caption:s,chips:n}){return e.jsxs("div",{className:"setup-ill",children:[e.jsxs("div",{className:"ill-emblem",children:[e.jsx("div",{className:"iemblem-tile",children:t}),e.jsx("div",{className:"iemblem-chips",children:n.map(r=>e.jsx("span",{className:"iemblem-chip",children:r},r))})]}),e.jsx("div",{className:"ill-cap",children:s})]})}function Da({channels:t}){return e.jsx("div",{className:"setup-ill",children:e.jsx("div",{className:"ill-channels",children:t.map(s=>e.jsxs("div",{className:s.on?"ichan on":"ichan",children:[e.jsx("div",{className:"ichan-lbl",children:s.label}),e.jsx("div",{className:"ichan-track",children:Array.from({length:s.dots}).map((n,r)=>e.jsxs(l.Fragment,{children:[r>0?e.jsx("span",{className:"ichan-line"}):null,e.jsx("span",{className:"ichan-dot"})]},r))})]},s.label))})})}const $A=Object.freeze(Object.defineProperty({__proto__:null,SetupBars:Jn,SetupChannels:Da,SetupEmblem:Wt,SetupOrbit:fs,SetupSplit:ps,SetupStack:ms},Symbol.toStringTag,{value:"Module"}));function Gt({nodes:t}){return e.jsx("div",{className:"journey",children:e.jsx("div",{className:"jrow",children:t.map((s,n)=>e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:s.lime?"jtile lime":"jtile",children:s.emoji}),e.jsx("div",{className:"jlbl",children:s.label}),e.jsx("div",{className:"jsub",children:s.sub})]}),n===t.length-1?null:e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket"}),e.jsx("span",{children:"→"})]})]},s.label))})})}const BA=Object.freeze(Object.defineProperty({__proto__:null,SetupJourney:Gt},Symbol.toStringTag,{value:"Module"}));function tu(t){var a;const s=Object.values(((a=t.tests)==null?void 0:a.byRunner)??{}),n=s.reduce((o,i)=>o+(i.passed??0),0),r=s.reduce((o,i)=>o+(i.failed??0),0);return{total:n+r,passed:n,failed:r}}function su(t){const s=t??[];return{changed:s.filter(n=>n.status==="changed"),created:s.filter(n=>n.status==="new"),unchanged:s.filter(n=>n.status!=="changed"&&n.status!=="new")}}const x0=5e3,jl={headSha:null,branch:null};function y0(){const[t,s]=l.useState([]),[n,r]=l.useState(jl),[a,o]=l.useState(!0),[i,c]=l.useState(null),d=l.useRef(!1),u=l.useCallback(async p=>{if(!d.current){d.current=!0,p&&o(!0);try{const f=await fetch("/api/reviews");if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await f.json();s(m.reviews??[]),r(m.repoState??jl),c(m.error??null)}catch(f){c(f instanceof Error?f.message:"Failed to load reviews")}finally{p&&o(!1),d.current=!1}}},[]),h=l.useCallback(()=>u(!0),[u]);return l.useEffect(()=>{u(!0);const p=setInterval(()=>{u(!1)},x0);return()=>clearInterval(p)},[u]),{reviews:t,repoState:n,loading:a,error:i,reload:h}}function v0(t,s){var r;const n=(r=t.pr)==null?void 0:r.headRef;return!!n&&!!s.branch&&s.branch===n}const j0=192;function Sr({children:t,variant:s="compact",maxHeight:n=j0,moreLabel:r="Show more",lessLabel:a="Show less",fadeColor:o="var(--bg-card)"}){const i=l.useRef(null),[c,d]=l.useState(!1),[u,h]=l.useState(!1);return l.useEffect(()=>{const p=i.current;if(!p)return;const f=()=>h(p.scrollHeight>n);f();const m=new ResizeObserver(f);return m.observe(p),()=>m.disconnect()},[t,n]),e.jsxs("div",{children:[e.jsxs("div",{ref:i,style:{maxHeight:c?"none":`${n}px`,overflow:"hidden",position:"relative"},children:[e.jsx($t,{variant:s,children:t}),!c&&u&&e.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2rem",background:`linear-gradient(transparent, ${o})`,pointerEvents:"none"}})]}),u&&e.jsx("button",{onClick:()=>d(p=>!p),className:"text-xs cursor-pointer mt-1",style:{color:"var(--accent-blue)",background:"none",border:"none",padding:0},children:c?a:r})]})}const qA=Object.freeze(Object.defineProperty({__proto__:null,CollapsibleMarkdown:Sr},Symbol.toStringTag,{value:"Module"}));function Vt({label:t,children:s}){return e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:t}),e.jsx("div",{className:"mt-0.5",children:s})]})}const HA=Object.freeze(Object.defineProperty({__proto__:null,LabeledSection:Vt},Symbol.toStringTag,{value:"Module"}));function Nr({status:t}){const s=t==="added"?"var(--accent-green)":t==="deleted"?"var(--accent-red)":"var(--accent-blue)",n=t==="added"?"+":t==="deleted"?"-":"~";return e.jsx("span",{className:"font-mono text-xs font-semibold",style:{color:s,minWidth:"0.75rem",textAlign:"center"},children:n})}const WA=Object.freeze(Object.defineProperty({__proto__:null,FileStatusIndicator:Nr},Symbol.toStringTag,{value:"Module"}));function nu({files:t}){return t.length===0?null:e.jsx("div",{className:"max-h-32 overflow-y-auto",children:t.map(s=>e.jsxs("p",{className:"font-mono text-xs text-[var(--text-muted)]",children:[e.jsx(Nr,{status:s.status})," ",s.path]},s.path))})}const GA=Object.freeze(Object.defineProperty({__proto__:null,ModifiedFilesList:nu},Symbol.toStringTag,{value:"Module"}));function w0(t){switch(t){case"blocker":return{bg:"var(--accent-red)",fg:"#fff"};case"concern":return{bg:"var(--accent-orange)",fg:"#111"};case"praise":return{bg:"var(--accent-green)",fg:"#111"};case"nit":default:return{bg:"var(--bg-subtle)",fg:"var(--text-muted)"}}}function ru({finding:t}){const s=w0(t.severity),n=t.file&&(t.line!=null?`${t.file}:${t.line}`:t.file);return e.jsxs("div",{className:"flex flex-col gap-1 rounded border px-3 py-2",style:{borderColor:"var(--border-subtle)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",style:{background:s.bg,color:s.fg},children:t.severity}),n&&e.jsx("span",{className:"font-mono text-xs truncate",style:{color:"var(--text-secondary)"},children:n})]}),e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.comment})]})}const UA=Object.freeze(Object.defineProperty({__proto__:null,ReviewFindingRow:ru},Symbol.toStringTag,{value:"Module"}));function _0(t){switch(t){case"changed":return{bg:"var(--accent-orange)",fg:"#111",label:"changed"};case"new":return{bg:"var(--accent-green)",fg:"#111",label:"new"};case"unchanged":default:return{bg:"var(--bg-subtle)",fg:"var(--text-muted)",label:t}}}function La({label:t,path:s,onPreview:n}){const r=`${t} capture`,a=!!s&&!!n;return e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide",style:{color:"var(--text-dim)"},children:t}),e.jsx("button",{type:"button",disabled:!a,onClick:a?()=>n(s,r):void 0,className:"relative h-32 w-full overflow-hidden rounded border p-0",style:{borderColor:"var(--border-subtle)",background:"var(--bg-subtle)",cursor:a?"zoom-in":"default"},title:a?"Click to view full size":void 0,children:e.jsx(Nt,{screenshotPath:s,alt:r})})]})}function au({pair:t,walkable:s,headRef:n,prNumber:r,onPreviewImage:a}){const o=_0(t.status),i=t.status==="new",c=t.diffRatio!=null?`${(t.diffRatio*100).toFixed(1)}% changed`:null;return e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border p-3",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-medium",style:{color:"var(--text-primary)"},children:t.slug}),e.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",style:{background:o.bg,color:o.fg},children:o.label}),t.beforeStale&&e.jsx("span",{"data-testid":"before-stale-badge",className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{background:"var(--bg-subtle)",color:"var(--accent-orange)"},title:"The before capture was already stale at the merge base — treat the comparison with caution.",children:"before stale"}),c&&e.jsx("span",{className:"text-[10px]",style:{color:"var(--text-dim)"},children:c})]}),e.jsxs("div",{className:"flex gap-2",children:[!i&&e.jsx(La,{label:"Before",path:t.beforePath,onPreview:a}),e.jsx(La,{label:"After",path:t.afterPath,onPreview:a})]}),t.note&&e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.note}),s?e.jsx("a",{href:`/scenario/${encodeURIComponent(t.slug)}`,"data-testid":"view-live-link",className:"self-start rounded border px-2 py-1 text-xs",style:{borderColor:"var(--border-default)",color:"var(--accent-blue)"},children:"View live →"}):e.jsxs("p",{"data-testid":"walk-hint",className:"text-[11px]",style:{color:"var(--text-dim)"},children:["Check out the PR to walk this scenario live",r!=null?e.jsxs(e.Fragment,{children:[" — ",e.jsxs("span",{className:"font-mono",children:["gh pr checkout ",r]})]}):n?e.jsxs(e.Fragment,{children:[" — ",e.jsxs("span",{className:"font-mono",children:["git checkout ",n]})]}):null]})]})}const YA=Object.freeze(Object.defineProperty({__proto__:null,CapturePane:La,ScenarioComparisonRow:au},Symbol.toStringTag,{value:"Module"}));function ou({scenarios:t,walkable:s,headRef:n,prNumber:r,onPreviewImage:a}){const[o,i]=l.useState(!1),{changed:c,created:d,unchanged:u}=su(t);if((t??[]).length===0)return e.jsx(Vt,{label:"Impacted scenarios",children:e.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No UI-impacting scenarios — this digest leads with tests and blast radius below."})});const h=p=>e.jsx(au,{pair:p,walkable:s,headRef:n,prNumber:r,onPreviewImage:a},p.slug);return e.jsx(Vt,{label:"Impacted scenarios",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[c.map(h),d.map(h),u.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i(p=>!p),"data-testid":"toggle-unchanged",className:"self-start text-xs",style:{color:"var(--accent-blue)"},children:[o?"Hide":"Show"," ",u.length," unchanged downstream scenario",u.length===1?"":"s"]}),o&&u.map(h)]})]})})}const VA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioImpactSection:ou},Symbol.toStringTag,{value:"Module"}));function Cr({total:t,passed:s,failed:n}){if(t===0)return null;const r=n>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]";return e.jsxs("span",{className:`text-xs ${r}`,children:[s,"/",t," passed"]})}const KA=Object.freeze(Object.defineProperty({__proto__:null,TestResultsBadge:Cr},Symbol.toStringTag,{value:"Module"}));function iu({review:t,repoState:s,onPreviewImage:n}){var d,u,h,p,f,m,b,g,x;const r=tu(t),a=v0(t,s),o=t.findings??[],i=((d=t.tests)==null?void 0:d.added)??[],c=(((u=t.blastRadius)==null?void 0:u.changedFiles)??[]).map(y=>({path:y,status:"modified"}));return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((h=t.pr)==null?void 0:h.number)!=null&&e.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",t.pr.number]}),((p=t.pr)==null?void 0:p.author)&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",t.pr.author]}),((f=t.pr)==null?void 0:f.url)&&e.jsx("a",{href:t.pr.url,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"View PR ↗"}),t.postedCommentUrl&&e.jsx("a",{href:t.postedCommentUrl,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"Posted comment ↗"})]}),((m=t.pr)==null?void 0:m.title)&&e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:t.pr.title})]}),e.jsx(ou,{scenarios:t.scenarios??[],walkable:a,headRef:(b=t.pr)==null?void 0:b.headRef,prNumber:(g=t.pr)==null?void 0:g.number,onPreviewImage:n}),t.narrative&&e.jsx(Vt,{label:"What this PR does",children:e.jsx(Sr,{children:t.narrative})}),e.jsx(Vt,{label:"Tests",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Cr,{total:r.total,passed:r.passed,failed:r.failed}),i.length>0?e.jsx("ul",{className:"flex flex-col gap-1.5",children:i.map((y,v)=>e.jsxs("li",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:y.name??y.file??"test"}),y.description&&e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:y.description})]},y.file??y.name??v))}):e.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No new tests added."})]})}),o.length>0&&e.jsx(Vt,{label:`Findings (${o.length})`,children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((y,v)=>e.jsx(ru,{finding:y},`${y.file??"f"}-${v}`))})}),((x=t.alignment)==null?void 0:x.summary)&&e.jsx(Vt,{label:"Codeyam alignment",children:e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.alignment.summary})}),c.length>0&&e.jsx(Vt,{label:"Changed files",children:e.jsx(nu,{files:c})})]})}const JA=Object.freeze(Object.defineProperty({__proto__:null,ReviewDetailCard:iu},Symbol.toStringTag,{value:"Module"}));function k0(t){const s=t.findings??[];return{blocker:s.filter(n=>n.severity==="blocker").length,concern:s.filter(n=>n.severity==="concern").length,total:s.length}}function S0(t){return t==null?null:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function lu({review:t,repoState:s,expanded:n,onToggle:r}){var d,u,h;if(t.parseError)return e.jsxs("div",{className:"rounded-lg border p-4",style:{borderColor:"var(--accent-red)",background:"var(--bg-card)"},children:[e.jsxs("p",{className:"text-sm font-medium",style:{color:"var(--accent-red)"},children:[t.id,": could not read digest"]}),e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--text-dim)"},children:t.parseError})]});const a=su(t.scenarios),o=k0(t),i=tu(t),c=S0(t.createdAtMs);return e.jsxs("div",{className:"rounded-lg border",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("button",{type:"button",onClick:r,className:"flex w-full flex-col gap-2 px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((d=t.pr)==null?void 0:d.number)!=null&&e.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",t.pr.number]}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:((u=t.pr)==null?void 0:u.title)??t.id}),((h=t.pr)==null?void 0:h.author)&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",t.pr.author]}),c&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["· ",c]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[e.jsxs("span",{style:{color:"var(--accent-orange)"},children:[a.changed.length," changed"]}),e.jsxs("span",{style:{color:"var(--accent-green)"},children:[a.created.length," new"]}),e.jsxs("span",{style:{color:"var(--text-dim)"},children:[a.unchanged.length," unchanged"]}),o.total>0&&e.jsxs("span",{style:{color:"var(--text-muted)"},children:[o.blocker>0&&`${o.blocker} blocker · `,o.concern>0&&`${o.concern} concern · `,o.total," finding",o.total===1?"":"s"]}),i.total>0&&e.jsxs("span",{style:{color:i.failed>0?"var(--accent-red)":"var(--accent-green)"},children:[i.passed,"/",i.total," passed"]})]})]}),n&&e.jsx("div",{className:"px-4 pb-4 pt-1",style:{borderTop:"1px solid var(--border-subtle)"},children:e.jsx(iu,{review:t,repoState:s})})]})}const XA=Object.freeze(Object.defineProperty({__proto__:null,ReviewCard:lu},Symbol.toStringTag,{value:"Module"}));function cu({deviceLabel:t,actions:s}){return e.jsxs("div",{role:"note",className:"flex items-center gap-2 border-b border-l-4 px-3 py-2 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9"}),e.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"}),e.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"font-semibold",children:["Web preview — no ",t," running."]})," ",e.jsx("span",{style:{color:"var(--text-dim)"},children:"Boot a simulator for native fidelity (gestures, haptics, native storage)."})]}),s?e.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:s}):null]})}const QA=Object.freeze(Object.defineProperty({__proto__:null,WebFallbackNotice:cu},Symbol.toStringTag,{value:"Module"}));function du({previewOrigin:t,onRecheck:s}){const n=()=>{window.open(t,"_blank","noopener")};return e.jsx("div",{role:"dialog","aria-label":"Preview sign-in required",className:"absolute inset-0 z-40 flex items-center justify-center p-8",style:{background:"var(--bg-surface)"},children:e.jsxs("div",{className:"flex max-w-md flex-col items-start gap-4 rounded-lg border border-l-4 p-6",style:{background:"var(--bg-base)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),e.jsx("span",{className:"text-base font-semibold",children:"Sign in to see the Live Preview"})]}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-dim)"},children:"This preview runs on a separate secured host that needs its own sign-in. Sign-in can’t happen inside this frame, so open the preview host in a new tab, sign in, then reload."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",onClick:n,className:"rounded px-3 py-2 text-sm font-medium",style:{background:"var(--accent-primary)",color:"var(--bg-base)"},children:"Open preview to sign in"}),e.jsx("button",{type:"button",onClick:s,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 ZA=Object.freeze(Object.defineProperty({__proto__:null,PreviewSignInNotice:du},Symbol.toStringTag,{value:"Module"}));function zo(){return e.jsxs("div",{style:{padding:"var(--spacing-lg, 16px)"},children:[e.jsx("h3",{style:{margin:0,color:"var(--text-primary)"},children:"Design exploration"}),e.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5,marginTop:"var(--spacing-sm, 8px)"},children:"Generating mockups — they'll appear here as the agent writes them."})]})}const eO=Object.freeze(Object.defineProperty({__proto__:null,MockupGridEmptyState:zo},Symbol.toStringTag,{value:"Module"}));function Fa({onRunTests:t,disabled:s,currentRunner:n}){return s?e.jsxs("span",{className:"text-xs font-medium text-[var(--text-dim)] inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-current border-r-transparent"}),n?`Running ${n}…`:"Running…"]}):e.jsx("span",{role:"button",tabIndex:0,onClick:r=>{r.stopPropagation(),t()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.stopPropagation(),t())},className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer",children:"Run Tests"})}const tO=Object.freeze(Object.defineProperty({__proto__:null,RunTestsButton:Fa},Symbol.toStringTag,{value:"Module"}));function uu({passed:t,failed:s,notRun:n}){const r=t+s+n;if(r===0)return null;const a=2,o=[{count:t,color:"var(--accent-green)"},{count:s,color:"var(--accent-red)"},{count:n,color:"var(--text-dim)"}].filter(u=>u.count>0),i=o.map(u=>Math.max(u.count/r*100,a)),c=i.reduce((u,h)=>u+h,0),d=i.map(u=>u/c*100);return e.jsx("div",{className:"h-1.5 flex-1 rounded-full bg-[var(--bg-input)] overflow-hidden max-w-32",children:e.jsx("div",{className:"h-full flex",children:o.map((u,h)=>e.jsx("div",{className:"h-full transition-all",style:{width:`${d[h]}%`,background:u.color}},u.color))})})}const sO=Object.freeze(Object.defineProperty({__proto__:null,TestBar:uu},Symbol.toStringTag,{value:"Module"}));function $o({tests:t,loading:s,refreshing:n,onRunTests:r,currentRunner:a}){const o=t.total>0,i=t.discovered>0,c=t.discovered>t.total?t.discovered-t.total:0;return s?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"h-1.5 w-16 rounded-full bg-[var(--bg-input)] animate-pulse"}),e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:n?"Running tests…":"Loading tests…"})]}):o?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx(uu,{passed:t.passed,failed:t.failed,notRun:c}),e.jsxs("span",{className:"text-xs font-medium text-[var(--accent-green)]",children:[t.passed," passed"]}),t.failed>0&&e.jsxs("span",{className:"text-xs font-medium text-[var(--accent-red)]",children:["· ",t.failed," failed"]}),t.ignored>0&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",t.ignored," skipped"]}),c>0&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",c," not run"]}),r&&e.jsx(Fa,{onRunTests:r,disabled:n,currentRunner:a})]}):i?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[t.discovered," ",t.discovered===1?"test":"tests"," (not run)"]}),r&&e.jsx(Fa,{onRunTests:r})]}):e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"No tests"})}const nO=Object.freeze(Object.defineProperty({__proto__:null,AppTestSummary:$o},Symbol.toStringTag,{value:"Module"}));function hu({tests:t,loading:s,refreshing:n,onRunTests:r,currentRunner:a}){return e.jsxs("div",{className:"px-5 pb-5 pt-2 flex items-center gap-5 border-t border-[var(--border-default)]",children:[e.jsx($o,{tests:t,loading:s,refreshing:n,onRunTests:r,currentRunner:a}),e.jsx("span",{className:"text-[var(--text-dim)] group-hover:text-[var(--accent-active)] transition ml-auto text-sm",children:"→"})]})}const rO=Object.freeze(Object.defineProperty({__proto__:null,AppCardFooter:hu},Symbol.toStringTag,{value:"Module"}));function Bo({type:t}){const s=t==="web";return e.jsx("span",{className:`rounded px-1.5 py-0.5 text-xs font-medium ${s?"bg-[var(--accent-blue)]/20 text-[var(--accent-blue)]":"bg-[var(--accent-purple)]/20 text-[var(--accent-purple)]"}`,children:s?"web":"backend"})}const aO=Object.freeze(Object.defineProperty({__proto__:null,AppTypeBadge:Bo},Symbol.toStringTag,{value:"Module"}));function pu({app:t}){return e.jsxs("div",{className:"px-5 pt-5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t.name}),e.jsx(Bo,{type:t.type})]}),t.description?e.jsx("p",{className:"text-sm text-[var(--text-muted)] leading-relaxed",children:t.description}):null]})}const oO=Object.freeze(Object.defineProperty({__proto__:null,AppCardHeader:pu},Symbol.toStringTag,{value:"Module"}));function mu({thumbnails:t}){return e.jsx("div",{className:"flex gap-2 overflow-hidden",children:t.map((s,n)=>e.jsx("div",{className:"h-20 w-32 shrink-0 flex items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:e.jsx(Nt,{screenshotPath:s.path,cacheBuster:s.cacheBuster??void 0,alt:""})},`${s.path}:${n}`))})}const iO=Object.freeze(Object.defineProperty({__proto__:null,ThumbnailStrip:mu},Symbol.toStringTag,{value:"Module"}));function fu({thumbnails:t}){return e.jsx("div",{className:"px-5 py-3 flex-1",children:t.length>0?e.jsx(mu,{thumbnails:t.slice(0,4)}):e.jsx("div",{className:"h-20"})})}const lO=Object.freeze(Object.defineProperty({__proto__:null,AppCardScenarioStrip:fu},Symbol.toStringTag,{value:"Module"}));function gu({stats:t,onClick:s,testsLoading:n,testsRefreshing:r,onRunTests:a,currentRunner:o}){const{app:i,tests:c,scenarios:d}=t;return e.jsxs("button",{onClick:s,className:"group flex w-full cursor-pointer flex-col rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] text-left transition hover:border-[var(--accent-active)]/40 hover:bg-[var(--bg-surface)]",children:[e.jsx(pu,{app:i}),e.jsx(fu,{thumbnails:d.thumbnails}),e.jsx(hu,{tests:c,loading:n,refreshing:r,onRunTests:a,currentRunner:o})]})}const cO=Object.freeze(Object.defineProperty({__proto__:null,AppCard:gu},Symbol.toStringTag,{value:"Module"}));function qo({coverage:t,prefix:s,testId:n,className:r,onClick:a}){if(!t||t.totalLines===0)return null;const o=`${Math.round(t.percent)}% coverage`,i=e.jsxs(e.Fragment,{children:[s??"",o]}),c=`${t.hitLines}/${t.totalLines} lines covered`;return a?e.jsx("span",{role:"button",tabIndex:0,className:r??"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":n??"coverage-badge",title:c,onClick:d=>{d.stopPropagation(),a()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.stopPropagation(),d.preventDefault(),a())},children:i}):e.jsx("span",{className:r??"text-xs font-medium text-[var(--text-secondary)]","data-testid":n??"coverage-badge",title:c,children:i})}const dO=Object.freeze(Object.defineProperty({__proto__:null,CoverageBadge:qo},Symbol.toStringTag,{value:"Module"}));function bu({app:t,showDetail:s,navContext:n=ws,stats:r,testsLoading:a,testsRefreshing:o,onRunTests:i,currentRunner:c,coverage:d,onCoverageClick:u}){if(s)return null;const h=!!(d&&d.totalLines>0);return e.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-default)]",children:[e.jsx("div",{className:"mb-2",children:e.jsx(_r,{apps:n.apps,selectedApp:t,selectedRouteEntity:null,isSingleApp:n.isSingleApp,onSelectApps:n.onSelectApps,onSelectApp:n.onSelectApp,onSelectRoute:n.onSelectRoute})}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:t.name}),e.jsx(Bo,{type:t.type})]}),h?e.jsx(qo,{coverage:d,testId:"app-detail-coverage",onClick:u}):null]}),t.description?e.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:t.description}):null,r?e.jsx("div",{className:"mt-3",children:e.jsx($o,{tests:r.tests,loading:a,refreshing:o,onRunTests:i,currentRunner:c})}):null]})}const uO=Object.freeze(Object.defineProperty({__proto__:null,AppDetailHeader:bu},Symbol.toStringTag,{value:"Module"}));function xu({name:t,id:s,capabilitiesTally:n,expanded:r,onToggle:a}){const o=t??s;return e.jsxs("button",{type:"button",onClick:a,className:"flex w-full items-center gap-2 text-left text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)]","data-testid":"stack-summary","aria-expanded":r,children:[e.jsx("span",{className:`inline-block transition-transform ${r?"rotate-90":""}`,children:"▶"}),e.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["Stack",o?` — ${o}`:""]}),t&&s?e.jsxs("span",{className:"text-[var(--text-dim)]",children:["(",s,")"]}):null,e.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",n]})]})}const hO=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelSummary:xu},Symbol.toStringTag,{value:"Module"})),za=["layout-web","interactions-click","interactions-touch-gestures","native-haptics","native-geolocation","native-clipboard","native-network","native-storage","routing","http-mocks","real-device"],yu={"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"}},vu={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 N0(t){var s;return((s=yu[t])==null?void 0:s.label)??t}function C0(t,s){var a,o;const n=(a=yu[t])==null?void 0:a.description,r=((o=vu[s])==null?void 0:o.meaning)??"";return n?`${n}. ${r}`:r}function ju({capabilities:t,defaultExpanded:s=!1}){const[n,r]=l.useState(s),a=za.filter(c=>c in t),o=Object.keys(t).filter(c=>!za.includes(c)),i={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const c of a){const d=t[c];d in i&&(i[d]+=1)}return e.jsxs("div",{className:"px-5 py-2","data-testid":"capabilities-panel",children:[e.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:"flex w-full items-center gap-2 text-left text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)]","data-testid":"capabilities-summary","aria-expanded":n,children:[e.jsx("span",{className:`inline-block transition-transform ${n?"rotate-90":""}`,children:"▶"}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Stack capabilities"}),e.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",i.verified," verified · ",i.stubbed," stubbed ·"," ",i.manual," manual · ",i["not-applicable"]," n/a"]})]}),n?e.jsxs("div",{className:"mt-2 space-y-1","data-testid":"capabilities-rows",children:[a.map(c=>e.jsx($a,{token:c,state:t[c]},c)),o.length>0?e.jsxs("div",{className:"mt-3","data-testid":"capabilities-unknown-group",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-[var(--accent-warn)]",children:[e.jsx("span",{title:"These tokens aren't recognized — likely typos",children:"⚠"}),"Unknown capabilities"]}),o.map(c=>e.jsx($a,{token:c,state:t[c],unknown:!0},c))]}):null]}):null]})}function $a({token:t,state:s,unknown:n}){const r=vu[s],a=n?"This token isn't recognized — may be a typo.":C0(t,s);return e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs","data-testid":`capability-row-${t}`,children:[e.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-secondary)]",children:[N0(t),e.jsx("span",{className:"cursor-help text-[var(--text-dim)]",title:a,"aria-label":a,children:"ⓘ"})]}),e.jsx("span",{className:`rounded px-1.5 py-0.5 ${(r==null?void 0:r.badgeClass)??"bg-[var(--bg-subtle)] text-[var(--text-dim)]"}`,children:(r==null?void 0:r.label)??s})]})}const pO=Object.freeze(Object.defineProperty({__proto__:null,AppCapabilitiesPanel:ju,CapabilityRow:$a},Symbol.toStringTag,{value:"Module"}));function wu({capabilities:t}){return t&&Object.keys(t).length>0?e.jsx(ju,{capabilities:t,defaultExpanded:!1}):e.jsxs("div",{className:"text-xs text-[var(--text-dim)]","data-testid":"stack-capabilities-empty-hint",children:["Capabilities not declared. Run"," ",e.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5 text-[var(--text-secondary)]",children:"codeyam-editor editor capabilities-list"})," ","to learn more."]})}const mO=Object.freeze(Object.defineProperty({__proto__:null,AppStackCapabilitiesSlot:wu},Symbol.toStringTag,{value:"Module"}));function _u({fields:t,capabilities:s}){return e.jsxs("div",{className:"mt-2 space-y-2","data-testid":"stack-body",children:[t.description?e.jsx("p",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-description",children:t.description}):null,t.technologies.length>0?e.jsx("ul",{className:"flex flex-wrap gap-1","data-testid":"stack-technologies",children:t.technologies.map(n=>e.jsx("li",{className:"rounded bg-[var(--bg-subtle)] px-1.5 py-0.5 text-[10px] text-[var(--text-secondary)]",children:n},n))}):null,t.commands.length>0?e.jsx("dl",{className:"space-y-0.5 text-xs","data-testid":"stack-commands",children:t.commands.map(({key:n,value:r})=>e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("dt",{className:"w-10 text-[var(--text-dim)]",children:n}),e.jsx("dd",{className:"text-[var(--text-secondary)]",children:e.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5",children:r})})]},n))}):null,t.routingSummary?e.jsxs("div",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-routing",children:[e.jsx("span",{className:"text-[var(--text-dim)]",children:"routing"})," ",t.routingSummary]}):null,e.jsx("div",{className:"border-t border-[var(--border-subtle)] pt-2",children:e.jsx(wu,{capabilities:s})})]})}const fO=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelBody:_u},Symbol.toStringTag,{value:"Module"}));function ku({skip:t=!1}={}){const[s,n]=l.useState(null);return l.useEffect(()=>{if(t)return;let r=!1;return fetch("/api/project-stack").then(a=>a.ok?a.json():{}).then(a=>{r||n(a&&typeof a=="object"&&!Array.isArray(a)?a:{})}).catch(()=>{r||n({})}),()=>{r=!0}},[t]),s}const P0=["dev","test","build"];function Xt(t){return typeof t=="string"&&t.length>0?t:null}function Su(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function T0(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function A0(t){const s=Su(t);if(!s)return[];const n=[];for(const r of P0){const a=Xt(s[r]);a&&n.push({key:r,value:a})}return n}function O0(t){const s=Su(t);if(!s)return null;const n=Xt(s.type);if(!n)return null;const r=Xt(s.pagesDir)??Xt(s.isolationRoute)??Xt(s.componentManifest);return r?`${n} (${r})`:n}function R0(t){const s=t.capabilities;return!s||typeof s!="object"||Array.isArray(s)?null:s}function E0(t){if(!t||Object.keys(t).length===0)return"capabilities not declared";const s={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const n of za){const r=t[n];r&&r in s&&(s[r]+=1)}return`${s.verified} verified · ${s.stubbed} stubbed · ${s.manual} manual · ${s["not-applicable"]} n/a`}function M0(t){return t?{id:Xt(t.id),name:Xt(t.name),description:Xt(t.description),technologies:T0(t.technologies),commands:A0(t.commands),routingSummary:O0(t.routing)}:{id:null,name:null,description:null,technologies:[],commands:[],routingSummary:null}}function Nu({stack:t,defaultExpanded:s=!1}){const n=t!==void 0,[r,a]=l.useState(s),o=ku({skip:n}),i=n?t:o;if(!i||Object.keys(i).length===0)return null;const c=M0(i),d=R0(i);return e.jsxs("div",{className:"px-5 py-2","data-testid":"stack-panel",children:[e.jsx(xu,{name:c.name,id:c.id,capabilitiesTally:E0(d),expanded:r,onToggle:()=>a(u=>!u)}),r?e.jsx(_u,{fields:c,capabilities:d}):null]})}const gO=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanel:Nu},Symbol.toStringTag,{value:"Module"}));function Cu({app:t,navContext:s=ws,routeEntities:n,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesError:i,selectedEntityHash:c,selectedRouteEntity:d,testGroups:u,selectedSlug:h,entityLookup:p,allScenarios:f,onSelectScenario:m,onSelectRoute:b,onSelectEntity:g,onBackToRoutes:x,onScenariosChanged:y,coverage:v,showProjectBand:j,onCoverageClick:w,stats:_,testsLoading:S,testsRefreshing:C,onRunTests:N,currentRunner:T}){const O=t.type==="web",k=!!j&&!d;return e.jsxs("div",{children:[k?e.jsx(Nu,{}):null,e.jsx(bu,{app:t,showDetail:!!(d||c),navContext:s,stats:_,testsLoading:S,testsRefreshing:C,onRunTests:N,currentRunner:T,coverage:k?v:void 0,onCoverageClick:w}),e.jsx(Do,{app:t,navContext:s,isWeb:O,routeEntities:n,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesError:i,selectedEntityHash:c??null,selectedRouteEntity:d,testGroups:u,selectedSlug:h,entityLookup:p,allScenarios:f,onSelectScenario:m,onSelectRoute:b,onSelectEntity:g,onBackToRoutes:x,onScenariosChanged:y})]})}const bO=Object.freeze(Object.defineProperty({__proto__:null,AppDetail:Cu},Symbol.toStringTag,{value:"Module"}));function Pu(t){const s=new Date(t);if(isNaN(s.getTime()))return t;const n=new Date,r=n.getTime()-s.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`:s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:s.getFullYear()!==n.getFullYear()?"numeric":void 0})}function Tu(t){switch(t){case"feature":return"text-[#D7FF63]";case"fix":return"text-red-400";case"refactor":return"text-purple-400";case"milestone":return"text-yellow-400";default:return"text-gray-400"}}function xO(t){let s=0,n=0,r=0;for(const a of t)a.status==="added"?s++:a.status==="deleted"?r++:n++;return{added:s,modified:n,deleted:r}}function Ho({screenshots:t,onSelect:s}){return t.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map((n,r)=>{const a=!!s&&!!n.screenshotPath,o=e.jsx("div",{className:"flex h-16 w-24 items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:e.jsx(Nt,{screenshotPath:n.screenshotPath,cacheBuster:n.screenshotCapturedAtMs??void 0,alt:n.name})});return e.jsxs("div",{className:"text-center",children:[a?e.jsx("button",{type:"button",onClick:()=>s==null?void 0:s(n),"aria-label":`Preview ${n.name}`,className:"block cursor-pointer rounded transition hover:ring-2 hover:ring-[var(--accent-primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-primary)]",children:o}):o,e.jsx("p",{className:"mt-0.5 text-xs text-[var(--text-dim)] truncate w-24",children:n.name})]},`${n.screenshotPath??"missing"}:${n.name}:${r}`)})})}const yO=Object.freeze(Object.defineProperty({__proto__:null,ScenarioThumbnailGrid:Ho},Symbol.toStringTag,{value:"Module"}));function Qt({children:t,testId:s}){return e.jsx("div",{className:"overflow-y-auto px-4 py-4",style:{maxHeight:"calc(100vh - 110px)"},"data-testid":s,children:t})}const vO=Object.freeze(Object.defineProperty({__proto__:null,TabScrollPanel:Qt},Symbol.toStringTag,{value:"Module"}));function Au(){const{reviews:t,repoState:s,loading:n,error:r}=y0(),[a,o]=l.useState(null);return n?e.jsx(Qt,{children:e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading reviews..."})}):r&&t.length===0?e.jsx(Qt,{children:e.jsxs("div",{className:"py-12 text-center text-[var(--accent-red)]",children:["Failed to load reviews: ",r]})}):t.length===0?e.jsx(Qt,{children:e.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No PR digests yet."}),e.jsxs("p",{className:"mt-2 text-sm",children:["Run"," ",e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:"/codeyam-review-pr"})," ","to digest an incoming pull request."]})]})}):e.jsx(Qt,{children:e.jsx("div",{className:"flex flex-col gap-3",children:t.map(i=>e.jsx(lu,{review:i,repoState:s,expanded:a===i.id,onToggle:()=>o(c=>c===i.id?null:i.id)},i.id))})})}const jO=Object.freeze(Object.defineProperty({__proto__:null,ReviewsTab:Au},Symbol.toStringTag,{value:"Module"}));function Ou({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]})}function Ru({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),e.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M9 12h6"}),e.jsx("path",{d:"M9 16h6"})]})}function xs({size:t=20}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"})})}function xn({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function Re({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function Fs({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}function Le({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),e.jsx("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),e.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),e.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function Pr({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),e.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),e.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),e.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),e.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),e.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),e.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]})}function Is({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Dt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]})}function ft({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),e.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),e.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function Ae({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),e.jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]})}function Lt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function rt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),e.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),e.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})}function Wo({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),e.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}const wO=Object.freeze(Object.defineProperty({__proto__:null,BellIcon:Wo,BoxIcon:rt,CardIcon:Dt,ChartIcon:ft,CloudIcon:xs,DatabaseIcon:xn,DocIcon:Ae,ExploreIcon:Ou,GlobeIcon:Lt,LockIcon:Re,MailIcon:Fs,PlansIcon:Ru,RocketIcon:Le,SetupIcon:Pr,TerminalIcon:Is},Symbol.toStringTag,{value:"Module"})),I0=[{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"}],D0={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 Eu({intent:t="add",onSubmit:s,onCancel:n}){const r=D0[t],[a,o]=l.useState(""),[i,c]=l.useState(""),[d,u]=l.useState("box"),[h,p]=l.useState(!1),[f,m]=l.useState(null),b=a.trim(),g=b.length>0&&!h,x=async y=>{if(y.preventDefault(),!g){b.length===0&&m("Please enter a name.");return}p(!0),m(null);try{await s({name:b,desc:i.trim(),icon:d})}catch(v){m(v instanceof Error?v.message:"Something went wrong."),p(!1)}};return e.jsxs("div",{className:"learn-screen",children:[e.jsx("div",{className:"atf-backdrop",role:"presentation",onClick:n}),e.jsxs("div",{className:"atf-modal",role:"dialog","aria-modal":"true","aria-label":r.title,children:[e.jsx("div",{className:"atf-title",children:r.title}),e.jsx("p",{className:"atf-lead",children:r.lead}),e.jsxs("form",{onSubmit:x,children:[e.jsxs("label",{className:"atf-field",children:[e.jsx("span",{className:"atf-label",children:"Name"}),e.jsx("input",{className:"atf-input",type:"text",value:a,autoFocus:!0,placeholder:t==="ask"?"e.g. Cloudflare, a regional payment processor…":"e.g. Error monitoring, a custom step…",onChange:y=>o(y.target.value)})]}),e.jsxs("label",{className:"atf-field",children:[e.jsxs("span",{className:"atf-label",children:["What is it for? ",e.jsx("span",{className:"atf-optional",children:"(optional)"})]}),e.jsx("textarea",{className:"atf-input atf-textarea",value:i,rows:2,placeholder:"One line on what this is for.",onChange:y=>c(y.target.value)})]}),e.jsxs("label",{className:"atf-field",children:[e.jsx("span",{className:"atf-label",children:"Icon"}),e.jsx("select",{className:"atf-input",value:d,onChange:y=>u(y.target.value),children:I0.map(y=>e.jsx("option",{value:y.key,children:y.label},y.key))})]}),f?e.jsx("div",{className:"atf-error",role:"alert",children:f}):null,e.jsxs("div",{className:"atf-actions",children:[e.jsx("button",{type:"button",className:"atf-btn atf-btn-ghost",onClick:n,disabled:h,children:"Cancel"}),e.jsx("button",{type:"submit",className:"atf-btn atf-btn-primary",disabled:!g,children:h?r.submitting:r.submit})]})]})]})]})}const _O=Object.freeze(Object.defineProperty({__proto__:null,AddTopicForm:Eu},Symbol.toStringTag,{value:"Module"}));function Mu({onAdd:t,onAsk:s}){return e.jsxs("div",{className:"setup-addrow",children:[e.jsx("div",{className:"setup-addrow-copy",children:"Don't see what you need? Add an off-list service or topic — or ask the assistant about one."}),e.jsxs("div",{className:"setup-addrow-btns",children:[e.jsx("button",{type:"button",className:"setup-addbtn",onClick:t,children:"+ Add a topic"}),e.jsx("button",{type:"button",className:"setup-addbtn setup-addbtn-ask",onClick:s,children:"Ask the AI about a service"})]})]})}const kO=Object.freeze(Object.defineProperty({__proto__:null,SetupAddTopicRow:Mu},Symbol.toStringTag,{value:"Module"}));function L0(){const[t,s]=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||s(Array.isArray(o)?o:[])}catch{r||s([])}})(),()=>{r=!0}},[]);const n=l.useMemo(()=>{const r=new Map;for(const a of t??[])r.set(a.key,a);return r},[t]);return{concepts:t,byKey:r=>n.get(r)}}const F0={concepts:[],byKey:()=>{}},Tr=l.createContext(F0);function Iu({children:t}){const s=L0();return e.jsx(Tr.Provider,{value:s,children:t})}function Du(){return l.useContext(Tr)}function Lu(t){return l.useContext(Tr).byKey(t)}const SO=Object.freeze(Object.defineProperty({__proto__:null,ConceptsContext:Tr,ConceptsProvider:Iu,useConcept:Lu,useConceptIndex:Du},Symbol.toStringTag,{value:"Module"}));function Xn({k:t,children:s}){const n=Lu(t),[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useId(),d=r!==null,u=()=>{var p;const h=(p=o.current)==null?void 0:p.getBoundingClientRect();h&&a({top:h.bottom+6,left:h.left})};return l.useEffect(()=>{if(!d)return;const h=f=>{var b,g;const m=f.target;!((b=o.current)!=null&&b.contains(m))&&!((g=i.current)!=null&&g.contains(m))&&a(null)},p=f=>{f.key==="Escape"&&a(null)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",p)}},[d]),n?e.jsxs("span",{className:"concept-term-wrap",children:[e.jsx("button",{type:"button",ref:o,className:"concept-term","aria-expanded":d,"aria-controls":d?c:void 0,onClick:()=>d?a(null):u(),children:s}),d&&r?gs.createPortal(e.jsxs("div",{ref:i,className:"concept-popover",id:c,role:"dialog",style:{top:r.top,left:r.left},children:[e.jsx("span",{className:"concept-popover-term",children:n.term}),n.category?e.jsx("span",{className:"concept-popover-cat",children:n.category}):null,e.jsx("div",{className:"concept-popover-body",children:e.jsx($t,{variant:"compact",children:n.body})})]}),document.body):null]}):e.jsx(e.Fragment,{children:s})}const NO=Object.freeze(Object.defineProperty({__proto__:null,ConceptTerm:Xn},Symbol.toStringTag,{value:"Module"}));function Fu(t){const s=t.evidence[0];return s?`found ${s.value} in ${s.source}`:t.source==="declared"?"declared by the agent":"detected in this project"}function zu({service:t,onDismiss:s,onAddCredential:n}){var i;const r=(((i=t.envVars)==null?void 0:i.length)??0)>0,a=r&&!t.credentialPresent,o=r&&t.credentialPresent;return e.jsxs("div",{className:"detected-service",children:[e.jsx("span",{className:"ds-tag",children:t.source}),e.jsx("span",{className:"ds-name",children:t.name}),e.jsx("span",{className:"ds-why",children:Fu(t)}),o?e.jsx("span",{className:"ds-key-set","data-testid":`ds-key-set-${t.key}`,children:"Key set"}):null,a&&n?e.jsx("button",{type:"button",className:"ds-add-key",onClick:()=>n(t),"aria-label":`Add key for ${t.name}`,children:"Add key"}):null,s?e.jsx("button",{type:"button",className:"ds-dismiss",onClick:()=>s(t.key),"aria-label":`Dismiss ${t.name}`,children:"Dismiss"}):null]})}const CO=Object.freeze(Object.defineProperty({__proto__:null,DetectedServiceRow:zu,evidenceSummary:Fu},Symbol.toStringTag,{value:"Module"})),z0={terminal:Is,cloud:xs,database:xn,lock:Re,mail:Fs,card:Dt,chart:ft,doc:Ae,globe:Lt,box:rt,bell:Wo,rocket:Le};function $0(t){return z0[t]??Pr}function B0(t){return t==="done"?"trow done":t==="next"||t==="in-progress"?"trow next":"trow soon"}function q0(t){return t==="done"?"set up":t==="in-progress"?"in progress":t==="next"?"next":"explore"}function Ba({topics:t,detectedServices:s,onBack:n,onOpenHosting:r,onOpenTopic:a,onOpenLibraries:o,onDismissService:i,onAddCredential:c,onCreateTopic:d,onOpenConcepts:u}){const h=g=>{g.key==="hosting"?r():a==null||a(g.key)},p=new Map;for(const g of s??[]){if(g.status==="dismissed")continue;const x=p.get(g.topic)??[];x.push(g),p.set(g.topic,x)}const[f,m]=l.useState(null),b=async g=>{if(!d)return;const x=await d(g);m(null),a==null||a(x.key)};return e.jsxs("div",{className:"learn-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:n,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Setup"})]}),e.jsx("div",{className:"h",children:"Setup"}),e.jsx("div",{className:"hsub",children:"The things this kind of app eventually needs, explained simply. Learn about each, set it up here, and see what's already configured. No rush."}),u?e.jsxs("div",{className:"concepts-nudge",children:["New to terms like ",e.jsx(Xn,{k:"hosting",children:"hosting"}),", a"," ",e.jsx(Xn,{k:"domain",children:"domain"}),", or"," ",e.jsx(Xn,{k:"ssl-https",children:"HTTPS"}),"? Tap any underlined word for a plain-language explainer, or"," ",e.jsx("button",{type:"button",className:"concepts-nudge-link",onClick:u,children:"browse what these words mean"}),"."]}):null,e.jsx("div",{className:"tlist",children:t===null?Array.from({length:5}).map((g,x)=>e.jsxs("div",{className:"trow soon","aria-hidden":"true",children:[e.jsx("div",{className:"tic"}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:" "}),e.jsx("div",{className:"td",children:" "})]})]},x)):t.map(g=>{const x=$0(g.icon),y=p.get(g.key)??[];return e.jsxs("div",{className:"trow-group",children:[e.jsxs("button",{type:"button",className:B0(g.status),onClick:()=>h(g),children:[e.jsx("div",{className:"tic",children:e.jsx(x,{size:20})}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:g.name}),e.jsx("div",{className:"td",children:g.desc})]}),e.jsx("span",{className:"tt",children:q0(g.status)}),e.jsx("span",{className:"arrow",children:"→"})]}),y.length>0?e.jsx("div",{className:"detected-services",children:y.map(v=>e.jsx(zu,{service:v,onDismiss:i,onAddCredential:c},v.key))}):null]},g.key)})}),o&&e.jsxs("div",{className:"setup-libraries-section",children:[e.jsx("div",{className:"seclabel",children:"Libraries"}),e.jsxs("button",{type:"button",className:"trow",onClick:o,children:[e.jsx("div",{className:"tic",children:e.jsx(rt,{size:20})}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:"Libraries you depend on"}),e.jsx("div",{className:"td",children:"Every third-party library your app pulls in — what it is, its version, and how to update it."})]}),e.jsx("span",{className:"tt",children:"auto"}),e.jsx("span",{className:"arrow",children:"→"})]})]}),d?e.jsx(Mu,{onAdd:()=>m("add"),onAsk:()=>m("ask")}):null,f&&d?e.jsx(Eu,{intent:f,onSubmit:b,onCancel:()=>m(null)}):null]})}const PO=Object.freeze(Object.defineProperty({__proto__:null,LearnSetupScreen:Ba},Symbol.toStringTag,{value:"Module"}));function sn({command:t,writer:s}){const{copied:n,copy:r}=gn({writer:s});return e.jsxs("div",{className:"rl-cmd",children:[e.jsx("code",{className:"rl-cmd-text",children:t}),e.jsx("button",{type:"button",className:"rl-copy",onClick:()=>{r(t).catch(()=>{})},"aria-label":`Copy command: ${t}`,children:n?"Copied!":"Copy"})]})}const TO=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyCommandRow:sn},Symbol.toStringTag,{value:"Module"}));function H0(t){return t==="dev"?"dev":t==="transitive"?"transitive":"direct"}function $u({lib:t,copyWriter:s}){return e.jsxs("div",{className:"lib-row",children:[e.jsxs("div",{className:"lib-head",children:[e.jsx("span",{className:"lib-name",children:t.name}),e.jsx("span",{className:"lib-version",children:t.version||"—"}),e.jsx("span",{className:`lib-kind ${t.kind}`,children:H0(t.kind)}),t.outdated&&e.jsx("span",{className:"lib-outdated",title:"A newer version is available",children:"outdated"})]}),t.description?e.jsx("div",{className:"lib-desc",children:t.description}):e.jsx("div",{className:"lib-desc muted",children:"A library this project depends on. No description on file yet."}),e.jsxs("div",{className:"lib-meta",children:[t.category&&e.jsx("span",{className:"lib-tag",children:t.category}),t.license&&e.jsxs("span",{className:"lib-license",children:["License: ",t.license]}),t.homepage&&e.jsx("a",{className:"lib-docs",href:t.homepage,target:"_blank",rel:"noreferrer",children:"Docs ↗"})]}),e.jsx(sn,{command:t.updateCommand,writer:s})]})}const AO=Object.freeze(Object.defineProperty({__proto__:null,LibraryRow:$u},Symbol.toStringTag,{value:"Module"}));function W0(t,s){return s?`${t.name} ${t.description??""} ${t.category??""}`.toLowerCase().includes(s):!0}function Bu({group:t,query:s,forceOpen:n,copyWriter:r}){const[a,o]=l.useState(t.libraries.length<=8),i=t.libraries.filter(d=>W0(d,s));if(s&&i.length===0)return null;const c=n||a;return e.jsxs("section",{className:"lib-group",children:[e.jsxs("button",{type:"button",className:"lib-group-head","aria-expanded":c,onClick:()=>o(d=>!d),children:[e.jsx("span",{className:"lib-group-icon",children:e.jsx(rt,{size:18})}),e.jsx("span",{className:"lib-group-title",children:t.ecosystem}),e.jsxs("span",{className:"lib-group-count",children:[i.length," ",i.length===1?"library":"libraries"]}),e.jsx("span",{className:"lib-group-path",children:t.manifestPath}),e.jsx("span",{className:"lib-group-chevron",children:c?"▾":"▸"})]}),c&&e.jsx("div",{className:"lib-rows",children:i.map(d=>e.jsx($u,{lib:d,copyWriter:r},d.name))})]})}const OO=Object.freeze(Object.defineProperty({__proto__:null,LibraryGroupSection:Bu},Symbol.toStringTag,{value:"Module"}));function qu({groups:t,onBack:s,copyWriter:n}){const[r,a]=l.useState(""),o=r.trim().toLowerCase(),i=l.useMemo(()=>(t??[]).reduce((c,d)=>c+d.libraries.length,0),[t]);return e.jsxs("div",{className:"learn-screen libraries-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:s,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:s,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Libraries"})]}),e.jsx("div",{className:"h",children:"Libraries"}),e.jsx("div",{className:"hsub",children:"These are the third-party libraries your app uses — code other people wrote that you depend on instead of building it yourself. You didn't configure most of these; they came along with the tools you're using. This list is read straight from your project's manifests, so it's always up to date."}),t===null?e.jsx("div",{className:"lib-loading","aria-hidden":"true",children:"Reading your project's libraries…"}):t.length===0?e.jsxs("div",{className:"lib-empty",children:[e.jsx("div",{className:"lib-empty-title",children:"No libraries yet"}),e.jsx("div",{className:"lib-empty-body",children:"This project doesn't declare any third-party libraries in a manifest we recognize (package.json, Cargo.toml, requirements.txt, Podfile). When it does, they'll show up here automatically."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"lib-searchbar",children:e.jsx("input",{type:"search",className:"lib-search",placeholder:`Search ${i} libraries…`,value:r,onChange:c=>a(c.target.value),"aria-label":"Search libraries"})}),e.jsx("div",{className:"lib-groups",children:t.map(c=>e.jsx(Bu,{group:c,query:o,forceOpen:o.length>0,copyWriter:n},c.manifestPath))})]})]})}const RO=Object.freeze(Object.defineProperty({__proto__:null,LibrariesCatalogScreen:qu},Symbol.toStringTag,{value:"Module"}));function Go(t){switch(t){case"real-data":return e.jsx(ps,{before:{tag:"Now · in the code",items:["Resets on refresh","A developer must edit"]},after:{tag:"After · in a database",items:["Saved for good","You edit it yourself"]}});case"performance-images":return e.jsx(ps,{before:{tag:"Heavy",items:["Full-size images","Slow first paint"]},after:{tag:"Optimized",items:["Right-sized & lazy","Fast on any device"]}});case"cli-ux":return e.jsx(ps,{before:{tag:"Cryptic",items:["Confusing errors","Guess the flags"]},after:{tag:"Polished",items:["Clear help & output","Helpful messages"]}});case"forms":return e.jsx(ps,{before:{tag:"Without setup",items:["Submissions lost","Spam gets through"]},after:{tag:"With setup",items:["Reliably delivered","Spam filtered out"]}});case"custom-domain":return e.jsx(ps,{before:{tag:"Default link",items:["Generic address","Hard to remember"]},after:{tag:"Your domain",items:["yourname.com","Secure & trusted"]}});case"accounts":return e.jsx(fs,{center:{emoji:"🔑",label:"Sign-in"},satellites:["✉️ Email link","🔵 Google","🍎 Apple","🔒 Password"]});case"emails":return e.jsx(fs,{center:{emoji:"✉️",label:"Your app sends"},satellites:["👋 Welcome","🔑 Password reset","🧾 Receipt","🔔 Notification"]});case"api-auth":return e.jsx(fs,{center:{emoji:"🛡️",label:"Your API"},satellites:["🎟️ API key","🪪 Token","⛔ Revoke anytime"]});case"cors-origins":return e.jsx(fs,{center:{emoji:"🚦",label:"Your API"},satellites:["✅ your-site.com","✅ app.your-site.com","⛔ everyone else"]});case"comments-search":return e.jsx(fs,{center:{emoji:"📚",label:"Your content"},satellites:["🔍 Fast search","💬 Comments","🛡️ Moderation"]});case"analytics-monitoring":return e.jsx(Jn,{bars:[{label:"Visits",pct:62},{label:"Signups",pct:40},{label:"Active",pct:78,lime:!0},{label:"Errors",pct:16}]});case"analytics-seo":return e.jsx(Jn,{bars:[{label:"Search",pct:70,lime:!0},{label:"Direct",pct:45},{label:"Social",pct:30},{label:"Referral",pct:22}]});case"logging-monitoring":return e.jsx(Jn,{bars:[{label:"Mon",pct:30},{label:"Tue",pct:44},{label:"Wed",pct:88,lime:!0},{label:"Thu",pct:36},{label:"Fri",pct:52}]});case"database-backups":return e.jsx(ms,{rows:[{emoji:"🗄️",label:"Live data",sub:"The real thing"},{emoji:"💾",label:"Daily backup",sub:"Safe copy",lime:!0},{emoji:"💾",label:"Yesterday",sub:"Restore point"},{emoji:"💾",label:"Last week",sub:"Restore point"}]});case"release-builds":return e.jsx(ms,{rows:[{emoji:"🧾",label:"Your source",sub:"One codebase"},{emoji:"🍎",label:"macOS build",sub:"Ready to run",lime:!0},{emoji:"🪟",label:"Windows build",sub:"Ready to run"},{emoji:"🐧",label:"Linux build",sub:"Ready to run"}]});case"staging-environment":return e.jsx(ms,{rows:[{emoji:"🏭",label:"Production",sub:"Real users"},{emoji:"🏗️",label:"Staging",sub:"Rehearse here",lime:!0},{emoji:"💻",label:"Local",sub:"Your machine"}]});case"publish-registry":return e.jsx(ms,{rows:[{emoji:"📦",label:"your-package",sub:"v1.2.0",lime:!0},{emoji:"🏷️",label:"Registry",sub:"Public listing"},{emoji:"⬇️",label:"npm install",sub:"One command"}]});case"semver-policy":return e.jsx(ms,{rows:[{emoji:"🟥",label:"Major · 2.0.0",sub:"May break"},{emoji:"🟨",label:"Minor · 1.3.0",sub:"New features"},{emoji:"🟩",label:"Patch · 1.2.1",sub:"Safe fix",lime:!0}]});case"versioning-changelog":return e.jsx(ms,{rows:[{emoji:"🆕",label:"v1.3.0",sub:"Added, fixed",lime:!0},{emoji:"📝",label:"v1.2.0",sub:"Changed"},{emoji:"📝",label:"v1.1.0",sub:"Fixed"}]});case"pre-release-channel":return e.jsx(Da,{channels:[{label:"Stable",dots:5},{label:"Beta",dots:5,on:!0}]});case"pre-release-versions":return e.jsx(Da,{channels:[{label:"latest",dots:4},{label:"next",dots:4,on:!0}]});case"legal":return e.jsx(Wt,{emoji:"⚖️",caption:"Clear, honest, above board",chips:["Privacy policy","Terms of service","Plain language"]});case"data-safety":return e.jsx(Wt,{emoji:"🛡️",caption:"Collect less, protect the rest",chips:["Minimize","Encrypt","Declare clearly"]});case"supply-chain":return e.jsx(Wt,{emoji:"🔗",caption:"Trust the code you depend on",chips:["Scan for risk","Pin versions","Verify builds"]});case"secrets":return e.jsx(Wt,{emoji:"🔑",caption:"Out of the code, in a safe store",chips:["Never committed","Easy to rotate","Per-environment"]});case"readme-license":return e.jsx(Wt,{emoji:"📖",caption:"The first things visitors read",chips:["What it is","How to use it","What's allowed"]});case"install-docs":return e.jsx(Wt,{emoji:"📘",caption:"From zero to running, fast",chips:["Install","First example","Common task"]});case"examples":return e.jsx(Wt,{emoji:"🧩",caption:"Show it solving real tasks",chips:["Runnable","Real use cases","Copy & tweak"]});case"publish":return e.jsx(Gt,{nodes:[{emoji:"💻",label:"Your computer",sub:"Only you see it"},{emoji:"☁️",label:"Published",sub:"A home online",lime:!0},{emoji:"🌍",label:"Anyone, anywhere",sub:"Opens with a link"}]});case"deploy-target":return e.jsx(Gt,{nodes:[{emoji:"📦",label:"Your app",sub:"Ready to ship"},{emoji:"🎯",label:"Deploy target",sub:"Where it runs",lime:!0},{emoji:"🔁",label:"Ship anytime",sub:"One repeatable step"}]});case"deploy-previews":return e.jsx(Gt,{nodes:[{emoji:"✏️",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"See it live",lime:!0},{emoji:"🚀",label:"Publish",sub:"Once it's right"}]});case"staging-preview":return e.jsx(Gt,{nodes:[{emoji:"🧪",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"Share & try it",lime:!0},{emoji:"🚀",label:"Ship it",sub:"Only once it's right"}]});case"background-jobs":return e.jsx(Gt,{nodes:[{emoji:"⏳",label:"Slow work",sub:"Blocks the user"},{emoji:"📮",label:"Queued",sub:"Runs in the background",lime:!0},{emoji:"✅",label:"Done later",sub:"App stays fast"}]});case"changelog-ci":return e.jsx(Gt,{nodes:[{emoji:"🧑‍💻",label:"You merge",sub:"That's the trigger"},{emoji:"🤖",label:"CI runs",sub:"Build · test · notes",lime:!0},{emoji:"🚀",label:"Released",sub:"Every time"}]});case"payments":return e.jsx(fs,{center:{emoji:"💳",label:"Secure checkout"},satellites:["💳 One-off","🔁 Subscriptions","🧾 Receipts","↩️ Refunds"]});case"shell-completions":return e.jsx(ps,{before:{tag:"Without",items:["Memorize flags","Typos & retries"]},after:{tag:"With completions",items:["Tab to complete","Commands & options"]}});default:return null}}const EO=Object.freeze(Object.defineProperty({__proto__:null,illustrationForTopic:Go},Symbol.toStringTag,{value:"Module"})),G0="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.",U0=[{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."}],Y0=["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(`
8
- `);function Hu({onBack:t,onChatWithAI:s}){return e.jsx(Fo,{icon:e.jsx(xn,{size:26}),title:"Use real data",crumbLabel:"Real data",meta:"Foundation · about 10 minutes",assistKey:"real-data",onBack:t,lead:G0,illustration:Go("real-data"),chatPrompt:Y0,onChatWithAI:s,faqs:U0})}const MO=Object.freeze(Object.defineProperty({__proto__:null,RealDataScreen:Hu},Symbol.toStringTag,{value:"Module"})),Ar={entitySingular:"item",entityPlural:"items",savedThings:"saved items",purchaseNoun:"purchase"},V0=800;function wl(t){switch(t){case"ready":return"ready";case"error":return"error";case"connected":case"provisioning":return"provisioning";default:return"provisioning"}}function Uo(t,s){const[n,r]=l.useState("idle"),[a,o]=l.useState(null),[i,c]=l.useState(null),d=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&(clearInterval(d.current),d.current=null)},[]),h=l.useCallback(b=>{var x,y;const g=wl(b.status);g==="ready"?(u(),o({label:((x=b.result)==null?void 0:x.label)??"",value:((y=b.result)==null?void 0:y.value)??""}),r("ready")):g==="error"?(u(),c(b.message??"Connection failed."),r("error")):r("provisioning")},[u]),p=l.useCallback(async()=>{try{const b=await fetch(`/api/setup/connection-status?topic=${encodeURIComponent(t)}`);if(!b.ok)return;h(await b.json())}catch{}},[t,h]),f=l.useCallback(b=>{u(),c(null),o(null),r("connecting"),(async()=>{try{const x=await(await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t,provider:s,credential:b})})).json().catch(()=>({}));h(x),wl(x.status)==="provisioning"&&(d.current=setInterval(()=>void p(),V0))}catch(g){u(),c(g instanceof Error?g.message:"Connection failed."),r("error")}})()},[t,s,h,p,u]),m=l.useCallback(()=>{u(),r("idle"),o(null),c(null)},[u]);return l.useEffect(()=>u,[u]),{stage:n,result:a,error:i,connect:f,reset:m}}const K0="accounts";function J0(t){switch(t){case"clerk":return"Clerk";case"supabase_auth":return"Supabase Auth";default:return t}}function Wu({provider:t,app:s=Ar,startedOn:n="recently",onComplete:r}){const{stage:a,result:o,error:i,connect:c,reset:d}=Uo(K0,t),[u,h]=l.useState(""),p=J0(t);return a==="ready"?e.jsxs(e.Fragment,{children:[o&&(o.label||o.value)&&e.jsxs("div",{className:"url-card",role:"status",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:o.label||"Connected"}),e.jsx("div",{className:"uc-u",children:o.value})]})]}),e.jsx(Zo,{app:s,startedOn:n,onComplete:r})]}):a==="error"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsxs("div",{className:"real-error-title",children:["Couldn’t connect ",p]}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{h(""),d()},children:"Try again"})]}):a==="connecting"||a==="provisioning"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsxs("div",{className:"deploy-t",children:["Setting up ",p]}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?`Connecting to ${p}…`:"Provisioning your sign-in keys…"})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]}):e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"ph",children:["Connect ",p]}),e.jsxs("div",{className:"psub",children:["Paste your ",p," secret key to wire real accounts into your app. CodeYam holds the key and injects it into the running app — you never touch a server."]}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("label",{className:"real-token-label",htmlFor:"accounts-secret-key",children:[p," secret key"]}),e.jsx("input",{id:"accounts-secret-key",type:"password",className:"real-token-input",placeholder:`Paste your ${p} secret key`,value:u,onChange:f=>h(f.target.value)}),e.jsxs("button",{type:"button",className:"auth-btn",disabled:u.trim().length===0,onClick:()=>c(u.trim()),children:["Connect ",p]})]}),e.jsx("div",{className:"reassure",children:"🔒 Your key is stored locally and never shown."})]})}const IO=Object.freeze(Object.defineProperty({__proto__:null,AccountsRealConnect:Wu},Symbol.toStringTag,{value:"Module"}));function Ct(t,s,n){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round",children:n})}function Ds({size:t=16}){return Ct(t,1.9,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2 4 5v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V5z"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}))}function Yo({size:t=16}){return Ct(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1.5 1.5"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1.5-1.5"})]}))}function Vo({size:t=16}){return Ct(t,1.8,e.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}))}function Ko({size:t=16}){return Ct(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),e.jsx("path",{d:"M3 9h18"})]}))}function X0({size:t=16}){return Ct(t,2,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 16v-4M12 8h.01"})]}))}function Q0({size:t=16}){return Ct(t,2,e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-4 4V5a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2z"}))}function Z0({size:t=16}){return Ct(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2 3 7v10l9 5 9-5V7z"}),e.jsx("path",{d:"M3 7l9 5 9-5M12 12v10"})]}))}function e_({size:t=16}){return Ct(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 7v5l3 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"9"})]}))}function t_({size:t=13}){return Ct(t,2,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"m15 9-6 6M9 9l6 6"})]}))}function ys({size:t=13}){return Ct(t,2.5,e.jsx("path",{d:"m5 12 5 5L20 6"}))}function Gu({size:t=16}){return e.jsxs("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:2,className:"rd-spin",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeOpacity:".3"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",strokeLinecap:"round"})]})}const DO=Object.freeze(Object.defineProperty({__proto__:null,ChatIcon:Q0,CheckGlyph:ys,ClockIcon:e_,CubeIcon:Z0,InfoCircleIcon:X0,LinkIcon:Yo,ListLinesIcon:Vo,ScreenIcon:Ko,ShieldCheckIcon:Ds,SpinnerIcon:Gu,XCircleIcon:t_},Symbol.toStringTag,{value:"Module"})),s_={"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."}]},n_={"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."}]},r_={"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."}]},a_={"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."}]},o_={"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."}]},i_={"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."}]},l_={"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.`}]},c_={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."}]},d_={"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)."}]},u_={...s_,...n_,...r_,...a_,...o_,...i_,...l_,...c_,...d_};function Uu(t){return u_[t]??[]}function h_({topicName:t,goal:s}){const n=[];return n.push("You are helping inside the user's actual codeyam project — this is real work in a real repository, not a hypothetical."),n.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."),n.push(""),n.push(`You're helping with **${t}** — specifically: **${s.label}**.`),n.push(""),n.push(s.body),n.push(""),n.push("Walk me through it and make the changes you safely can in my project, asking before anything destructive."),n.join(`
9
- `)}function Zt({assistKey:t,topicName:s,goalId:n,buttonLabel:r}){const a=Uu(t).find(c=>c.id===n),[o,i]=l.useState(!1);return a?e.jsxs("div",{className:"setup-goal-assist mt-4",children:[e.jsx("button",{type:"button",className:"w-full rounded-lg bg-[var(--blue-300)] px-4 py-2.5 text-sm font-semibold text-[var(--text-on-accent)] transition-opacity hover:opacity-90","aria-pressed":o,onClick:()=>i(c=>!c),children:r}),o&&e.jsx("div",{className:"mt-3 rounded-md border border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:e.jsx(vs,{chatName:`setup-${t}-${a.id}`,prompt:h_({topicName:s,goal:a}),height:360,onClose:()=>i(!1)})})]}):null}const LO=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssist:Zt},Symbol.toStringTag,{value:"Module"}));function de({assistKey:t,topicName:s}){const n=Uu(t);return n.length===0?null:e.jsx(e.Fragment,{children:n.map(r=>e.jsx(Zt,{assistKey:t,topicName:s,goalId:r.id,buttonLabel:`Ask AI to help: ${r.label}`},r.id))})}const FO=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssistList:de},Symbol.toStringTag,{value:"Module"})),p_=1800;function Or({config:t,onConnect:s}){const[n,r]=l.useState(!1),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=()=>{n||(r(!0),window.setTimeout(s,p_))},u=t.connectColor==="green"?{"--connect":"var(--green)"}:void 0;return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:t.badge}),e.jsxs("div",{children:[e.jsxs("h1",{className:"su-title",children:[t.title," ",e.jsx("span",{className:"su-chip notset",children:"Not set up"})]}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:t.providerName})]}),e.jsx("p",{className:"su-lead",children:t.lead})]})]}),e.jsxs("div",{className:"su-explain",children:[e.jsxs("div",{className:"su-eh",children:[e.jsx("span",{className:"su-q",children:"?"}),t.explainerHeading]}),e.jsx("div",{className:"su-lede",children:t.lede}),e.jsx("div",{className:"su-erows",children:t.explainerRows.map(h=>e.jsxs("div",{className:"su-erow",children:[e.jsx("div",{className:"su-en",children:h.icon}),e.jsxs("div",{className:"su-et",children:[e.jsx("b",{children:h.title}),e.jsx("span",{children:h.desc})]})]},h.title))}),e.jsxs("div",{className:"su-why",children:[e.jsxs("div",{className:"su-wh",children:[e.jsx(Ds,{size:15}),t.whyHeading]}),t.whyRows.map(h=>e.jsxs("div",{className:"su-whyrow",children:[e.jsx("span",{className:"su-wc",children:e.jsx(ys,{size:11})}),e.jsxs("p",{children:[e.jsx("b",{children:h.lead})," ",h.rest]})]},h.lead))]})]}),e.jsxs("div",{className:"su-connect",style:u,children:[e.jsx("div",{className:"su-ct",children:t.connectTitle}),e.jsx("div",{className:"su-cd",children:t.connectDesc}),e.jsx("button",{type:"button",className:"su-cbtn",onClick:d,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Gu,{size:16}),"Opening ",t.providerName,"…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Yo,{size:16}),t.connectButtonLabel]})}),e.jsx("div",{className:"su-reassure",children:t.reassure.map(h=>e.jsxs("span",{children:[e.jsx(ys,{size:13}),h]},h))})]}),t.alternatives&&t.alternatives.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"su-alt-toggle",onClick:()=>o(h=>!h),children:[a?"Hide other options":t.altToggleLabel," ",e.jsx("span",{className:"su-chev"+(a?" open":""),children:"⌄"})]}),a?e.jsx("div",{className:"su-alts",children:t.alternatives.map(h=>e.jsxs("div",{className:"su-altrow",children:[e.jsx("div",{className:"su-altmark",style:{background:h.color},children:h.monogram}),e.jsxs("div",{className:"su-altbody",children:[e.jsx("div",{className:"su-altname",children:h.name}),e.jsx("div",{className:"su-altdesc",children:h.desc}),h.factKey?e.jsxs("div",{className:"su-altfact",children:[ce(h.factKey).value,e.jsx(es,{fact:ce(h.factKey)})]}):null]}),e.jsx("button",{type:"button",className:"su-altpick"+(i===h.name?" picked":""),onClick:()=>c(h.name),children:i===h.name?"Selected ✓":"Use this"})]},h.name))}):null]}):null,e.jsx("div",{className:"su-uplabel",children:t.lockedLabel}),e.jsx("div",{className:"su-locked",children:t.lockedSteps.map(h=>e.jsxs("div",{className:"su-lrow",children:[e.jsx("div",{className:"su-ln",children:h.icon}),e.jsxs("div",{className:"su-lt",children:[e.jsx("b",{children:h.title}),e.jsx("span",{children:h.desc})]}),e.jsx("span",{className:"su-lk",children:e.jsx(Re,{size:15})})]},h.title))}),t.faq&&t.faq.length>0?e.jsx(Ye,{items:t.faq}):null,t.assistKey?e.jsx(de,{assistKey:t.assistKey,topicName:t.title}):null]})}const zO=Object.freeze(Object.defineProperty({__proto__:null,SetupNotConnected:Or},Symbol.toStringTag,{value:"Module"}));function Rr({children:t}){return e.jsx("div",{className:"su-steps",children:t})}function _t({state:t,num:s,title:n,pill:r,desc:a,children:o}){return e.jsxs("div",{className:"su-step",children:[e.jsxs("div",{className:"su-rail",children:[e.jsx("div",{className:"su-node "+t,children:t==="done"?e.jsx(ys,{size:15}):s}),e.jsx("div",{className:"su-line"})]}),e.jsxs("div",{className:"su-scon",children:[e.jsxs("div",{className:"su-stitle",children:[n,r?e.jsx("span",{className:"su-pill",children:r}):null]}),e.jsx("div",{className:"su-sdesc",children:a}),o]})]})}function Jo({monogram:t,name:s,detail:n,monogramStyle:r}){return e.jsxs("div",{className:"su-acct",children:[e.jsx("div",{className:"su-av",style:r,children:t}),e.jsxs("div",{className:"su-ainfo",children:[e.jsx("b",{children:s}),e.jsx("span",{children:n})]}),e.jsx("button",{type:"button",className:"su-chg",children:"Change"})]})}function Yu({methods:t,initialSelected:s}){const[n,r]=l.useState(()=>new Set(s)),a=o=>r(i=>{const c=new Set(i);return c.has(o)?c.delete(o):c.add(o),c});return e.jsx("div",{className:"su-methods",children:t.map(o=>e.jsxs("button",{type:"button",className:"su-mchip"+(n.has(o.key)?" on":""),onClick:()=>a(o.key),"aria-pressed":n.has(o.key),children:[e.jsx("span",{className:"su-ck",children:e.jsx(ys,{size:11})}),o.icon,o.label]},o.key))})}function Er({children:t}){return e.jsxs("div",{className:"su-field",children:[e.jsx("span",{className:"su-edit",children:"Edit"}),t]})}function Vu({examples:t}){const[s,n]=l.useState(new Set),r=a=>n(o=>{const i=new Set(o);return i.has(a)?i.delete(a):i.add(a),i});return e.jsx("div",{className:"su-examples",children:t.map((a,o)=>e.jsxs("button",{type:"button",className:"su-ex"+(s.has(o)?" added":""),onClick:()=>r(o),children:[e.jsx("span",{className:"su-plus",children:s.has(o)?"✓":"+"}),a]},a))})}function Mr({items:t}){return e.jsx("div",{className:"su-builds",children:t.map(s=>e.jsxs("div",{className:"su-bitem",children:[e.jsx("div",{className:"su-bx",children:e.jsx(ys,{size:13})}),e.jsxs("div",{className:"su-bmain",children:[e.jsx("b",{children:s.title}),e.jsx("span",{children:s.caption})]}),e.jsx("span",{className:"su-where",children:s.where})]},s.title))})}function Ir({accent:t,icon:s,children:n}){const r={"--note-accent":t==="amber"?"var(--amber)":"var(--blue)"};return e.jsxs("div",{className:"su-note",style:r,children:[s,e.jsx("p",{children:n})]})}function Dr({label:t,note:s,onPlan:n}){const[r,a]=l.useState(!1),o=()=>{r||(a(!0),n==null||n())};return e.jsxs("div",{className:"su-foot",children:[e.jsx("button",{type:"button",className:"su-cta",onClick:o,disabled:r,children:r?"Added to your plans ✓":e.jsxs(e.Fragment,{children:[t," ",e.jsx("span",{className:"su-ar",children:"→"})]})}),e.jsx("div",{className:"su-fnote",children:s})]})}const $O=Object.freeze(Object.defineProperty({__proto__:null,BuildList:Mr,ControlNote:Ir,EditableField:Er,ExampleChips:Vu,MethodChips:Yu,SetupAccountRow:Jo,SetupPlanFooter:Dr,SetupStep:_t,SetupStepper:Rr},Symbol.toStringTag,{value:"Module"}));function zs(t,s,n){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round",children:n})}function ir({size:t=16}){return zs(t,1.7,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),e.jsx("path",{d:"M5 20a7 7 0 0 1 14 0"})]}))}function Ku({size:t=16}){return zs(t,1.8,e.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"}))}function Xo({size:t=16}){return zs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 2 11 13"}),e.jsx("path",{d:"M22 2 15 22l-4-9-9-4z"})]}))}function Ju({size:t=16}){return zs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 9v4M12 17h.01"}),e.jsx("path",{d:"M10.3 4.3 2.6 18a1.5 1.5 0 0 0 1.3 2.2h16.2a1.5 1.5 0 0 0 1.3-2.2L13.7 4.3a1.5 1.5 0 0 0-2.6 0z"})]}))}function qa({size:t=16}){return zs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m22 7-10 6L2 7"}),e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"})]}))}function Xu({size:t=16}){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"currentColor",children:e.jsx("path",{d:"M21.35 11.1H12v2.9h5.35c-.25 1.45-1.7 4.25-5.35 4.25-3.2 0-5.85-2.65-5.85-5.9s2.65-5.9 5.85-5.9c1.85 0 3.05.8 3.75 1.45l2.55-2.45C16.6 3.6 14.55 2.7 12 2.7 6.95 2.7 2.9 6.75 2.9 12s4.05 9.3 9.1 9.3c5.25 0 8.7-3.7 8.7-8.9 0-.6-.05-1.05-.35-1.3z"})})}function Qu({size:t=16}){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"currentColor",children:e.jsx("path",{d:"M16.4 12.8c0-2.2 1.8-3.3 1.9-3.3-1-1.5-2.6-1.7-3.2-1.7-1.4-.1-2.6.8-3.3.8-.7 0-1.7-.8-2.8-.8-1.4 0-2.8.8-3.5 2.1-1.5 2.6-.4 6.5 1.1 8.6.7 1 1.6 2.2 2.7 2.1 1.1 0 1.5-.7 2.8-.7s1.6.7 2.8.7c1.1 0 1.9-1 2.6-2.1.8-1.2 1.2-2.3 1.2-2.4-.1 0-2.3-.9-2.3-3.4zM14.2 6.3c.6-.7 1-1.7.9-2.7-.9 0-2 .6-2.6 1.3-.6.6-1.1 1.6-.9 2.6 1 .1 2-.5 2.6-1.2z"})})}function Zu({size:t=16}){return zs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3 3 8l9 5 9-5-9-5z"}),e.jsx("path",{d:"M3 8v5l9 5 9-5V8"})]}))}const BO=Object.freeze(Object.defineProperty({__proto__:null,AppleGlyph:Qu,ArrowRightIcon:Ku,GoogleGlyph:Xu,GraduationIcon:Zu,MagicLinkIcon:qa,PaperPlaneIcon:Xo,PersonIcon:ir,WarningTriangleIcon:Ju},Symbol.toStringTag,{value:"Module"}));function Qo(){const[t,s]=l.useState(null),n=l.useCallback(async()=>{try{const a=await fetch("/api/setup-services");if(!a.ok)throw new Error(`HTTP ${a.status}`);const o=await a.json();s(Array.isArray(o)?o:[])}catch{s([])}},[]);l.useEffect(()=>{n()},[n]);const r=l.useCallback(a=>{s(o=>o&&o.map(i=>i.key===a?{...i,status:"dismissed"}:i)),fetch(`/api/setup-services/${encodeURIComponent(a)}/dismiss`,{method:"POST"}).catch(()=>{n()})},[n]);return{services:t,dismiss:r,refetch:n}}function Lr({topic:t}){const{services:s}=Qo();if(!s)return null;const n=s.find(a=>a.topic===t&&a.status!=="dismissed");if(!n)return null;const r=n.evidence.map(a=>a.value).join(", ");return e.jsxs("div",{className:"wired-provider",role:"note",children:[e.jsxs("div",{className:"wired-provider-title",children:[e.jsx("b",{children:n.name})," is already wired in this project"]}),e.jsx("div",{className:"wired-provider-detail",children:r?`We found ${r} in your project — here's how to finish setting it up.`:"Here's how to finish setting it up."})]})}const qO=Object.freeze(Object.defineProperty({__proto__:null,WiredProviderBanner:Lr},Symbol.toStringTag,{value:"Module"}));function m_(t){return{accent:"blue",assistKey:"accounts",badge:e.jsx(ir,{size:25}),title:"Let people sign in",providerName:"Supabase",connectColor:"lime",lead:`Right now everyone using your app is anonymous, so a ${t.entitySingular} they save vanishes the moment they close the tab. Give people their own account and their ${t.savedThings} and settings follow them on any device. CodeYam uses Supabase.`,explainerHeading:"New to accounts? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"An account is how your app knows who someone is."})," Instead of every visitor being a stranger, each person gets a private space — their"," ",t.savedThings,", their profile — that they can reach from any phone or laptop by signing in. Supabase is the secure tech that handles the signing-in part for you."]}),explainerRows:[{icon:e.jsx(ir,{size:16}),title:"Everything stays tied to them",desc:e.jsxs(e.Fragment,{children:["Their ",t.savedThings," and profile are remembered"," ",e.jsx("em",{children:"even after they close the app"}),", instead of resetting."]})},{icon:e.jsx(Ku,{size:16}),title:"It follows them across devices",desc:e.jsxs(e.Fragment,{children:["Sign in on a phone, see the same ",t.savedThings," on a laptop,"," ",e.jsx("em",{children:"anywhere they sign in"}),"."]})},{icon:e.jsx(Re,{size:16}),title:"It keeps private things private",desc:e.jsxs(e.Fragment,{children:["Accounts let you say ",e.jsx("em",{children:'"only this person can see their data,"'})," ","which you'll want before real money or personal info is involved."]})}],whyHeading:"Why CodeYam picks Supabase for you",whyRows:[{lead:"Free to start, no card needed.",rest:"A generous free tier covers a new app comfortably. You only pay once you have a lot of users, and you'll see it coming."},{lead:"Security handled for you.",rest:"Passwords, Google and Apple sign-in, and resets are managed by Supabase, so the risky parts aren't yours to get right. Social logins do need a one-time developer setup with each provider — see the FAQ below."},{lead:"Nothing for you to manage.",rest:"No servers, no security patches. CodeYam handles the wiring, you just decide who gets to sign in."}],connectTitle:"Connect or create your Supabase project",connectDesc:"A new window opens on Supabase. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it and holds the keys, so you never touch a server.",connectButtonLabel:"Connect Supabase",reassure:["Free to start, no card needed","Takes about 3 minutes","Disconnect any time"],altToggleLabel:"Supabase not for you? See other options",alternatives:[{monogram:"C",color:"linear-gradient(140deg,#6c47ff,#4b2fcc)",name:"Clerk",desc:"Polished sign-in screens and user management out of the box. A great pick if you want the slickest ready-made experience.",factKey:"clerk.freeTier"},{monogram:"A",color:"linear-gradient(140deg,#eb5424,#b53a13)",name:"Auth0",desc:"A long-established choice with deep enterprise controls. Worth it if you'll need that later, a little more to set up.",factKey:"auth0.freeTier"}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Vo,{size:15}),title:"Choose how people sign in",desc:`Google, Apple, email, magic link — pick as many as you like. Then say when to ask, like "only when someone saves an ${t.entitySingular}."`},{icon:e.jsx(Ko,{size:15}),title:"CodeYam builds your sign-in screens",desc:`A sign-in screen, a "sign in to save" prompt, per-person ${t.savedThings}, and a profile menu — each a plan you preview before it ships.`}],faq:[{q:"Do Google and Apple sign-in need extra setup?",a:`Yes — each social login is registered with that provider, so Google and Apple sign-in need OAuth credentials created in the provider's developer console (a one-time setup CodeYam walks you through). "Sign in with Apple" also requires a paid Apple Developer account (${ce("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 f_=[{key:"google",label:"Google",icon:e.jsx(Xu,{size:15})},{key:"apple",label:"Apple",icon:e.jsx(Qu,{size:15})},{key:"email",label:"Email",icon:e.jsx(qa,{size:15})},{key:"magic",label:"Magic link",icon:e.jsx(qa,{size:15})}];function Zo({app:t,startedOn:s,onComplete:n}){const r=[{title:"A sign-in & sign-up screen",caption:"Google, Apple, and email, matched to your app's look.",where:"/signin"},{title:'A "sign in to save" prompt',caption:"Shown the first time someone taps save or buy, never before.",where:`/${t.entitySingular}`},{title:`Each person's own ${t.savedThings}`,caption:"Their list follows them on phone, laptop, anywhere they sign in.",where:"/saved"},{title:"A profile & sign-out menu",caption:"So people can manage their account and leave safely.",where:"/profile"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(ir,{size:25})}),e.jsxs("div",{children:[e.jsx("h1",{className:"su-title",children:"Let people sign in"}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Supabase"})," · the sign-in tech behind modern apps"]}),e.jsxs("p",{className:"su-lead",children:["Give people their own account so their ",t.savedThings," and settings follow them on any device. CodeYam builds the screens and handles the security, you just decide who gets in."]})]})]}),e.jsxs("div",{className:"su-remember",children:[e.jsx("span",{className:"su-rdot"}),e.jsxs("div",{className:"su-widget-body",children:[e.jsxs("b",{children:["You started this on ",s,"."]}),e.jsx("span",{children:"Sign-in methods are chosen — one step left before you can plan it."})]}),e.jsx("span",{className:"su-ago",children:"resumed today"})]}),e.jsxs("div",{className:"su-learn",children:[e.jsxs("div",{className:"su-lhd",children:[e.jsx(Zu,{size:15}),'What "accounts" actually means']}),e.jsxs("p",{children:["Right now everyone using your app is ",e.jsx("b",{children:"anonymous"})," — nothing they do is tied to them, so a saved ",t.entitySingular," disappears when they close the tab."]}),e.jsxs("p",{children:["Accounts give each person a ",e.jsx("b",{children:"private space"}),": their own"," ",t.savedThings,`, their profile. It also lets you say "only this person can see their data," which you'll want before real money or personal info is involved.`]})]}),e.jsx("div",{className:"su-seclabel",children:"Set it up"}),e.jsxs(Rr,{children:[e.jsx(_t,{state:"done",num:1,title:"How should people sign in?",pill:"Chosen",desc:"Pick as many as you like. Most apps offer one tap with Google or Apple, plus email as a fallback.",children:e.jsx(Yu,{methods:f_,initialSelected:["google","apple","email"]})}),e.jsx(_t,{state:"done",num:2,title:"When should people be asked to sign in?",desc:"Plain language is fine — this is the instruction CodeYam follows.",children:e.jsxs(Er,{children:["Let people ",e.jsx("b",{children:"browse freely"})," without an account. Only ask them to sign in when they ",e.jsxs("b",{children:["save an ",t.entitySingular]})," or"," ",e.jsxs("b",{children:["buy a ",t.purchaseNoun]}),"."]})}),e.jsx(_t,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four changes. Each becomes a plan you can preview, reorder, or drop before it ships.",children:e.jsx(Mr,{items:r})})]}),e.jsxs(Ir,{accent:"blue",icon:e.jsx(Re,{size:17}),children:[e.jsx("b",{children:"Nothing is locked down yet."})," People keep using your app exactly as they do now until you plan and build these. You can preview every screen first."]}),e.jsx(Dr,{label:"Plan these 4 changes",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, ready to build after your current session."]}),onPlan:n})]})}function eh({onBack:t,onComplete:s,app:n=Ar,initialConnected:r=!1,startedOn:a="recently",connector:o}){const[i,c]=l.useState(r),d=!!o&&!i;return e.jsxs("div",{className:"setup-screen accent-blue",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Accounts & sign-in"})]}),e.jsx(Lr,{topic:"accounts"}),i?e.jsx(Zo,{app:n,startedOn:a,onComplete:s}):d?e.jsx(Wu,{provider:o.provider,app:n,startedOn:a,onComplete:s}):e.jsx(Or,{config:m_(n),onConnect:()=>c(!0)})]})}const HO=Object.freeze(Object.defineProperty({__proto__:null,AccountsConnected:Zo,AccountsScreen:eh},Symbol.toStringTag,{value:"Module"})),g_="hello@your-app.com",b_={monogram:"R",name:"Your app",detail:"you@your-app.com · re_live_…"};function x_(t){return{accent:"amber",assistKey:"emails",badge:e.jsx(Fs,{size:25}),title:"Send emails from your app",providerName:"Resend",connectColor:"green",lead:"Right now your app can't email anyone. To send things like receipts, sign-in links, and welcome notes, it needs an email service — the part that actually delivers messages. CodeYam uses Resend.",explainerHeading:"New to Resend? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Resend is the part that actually sends your email."})," When your app needs to email someone, Resend takes the message and makes sure it lands in their inbox, not the spam folder, from an address that looks like you."]}),explainerRows:[{icon:e.jsx(Xo,{size:16}),title:"It sends reliably",desc:e.jsxs(e.Fragment,{children:["Receipts, password resets, and welcome notes go out"," ",e.jsx("em",{children:"the instant your app asks"}),", from your own address."]})},{icon:e.jsx(Ds,{size:16}),title:"It stays out of spam",desc:e.jsxs(e.Fragment,{children:["Resend handles the technical reputation work behind the scenes, so your emails ",e.jsx("em",{children:"actually arrive"})," instead of vanishing."]})},{icon:e.jsx(ft,{size:16}),title:"It shows you what happened",desc:e.jsxs(e.Fragment,{children:["See what was sent, delivered, or opened ",e.jsx("em",{children:"in one simple log"}),", so you're never guessing if a message went through."]})}],whyHeading:"Why CodeYam picks Resend for you",whyRows:[{lead:"Free to start, no card needed.",rest:`Resend's free tier gives you ${ce("resend.free").value} — plenty for a new app, and the daily cap is the one to watch on launch day. You only pay once you send more.`},{lead:"Use your own address.",rest:"Send from your own domain so it looks like you, not a robot or a no-reply. This needs a one-time domain verification (a few DNS records) — see the steps below."},{lead:"Nothing to wire up.",rest:"CodeYam connects it and writes the emails for you. You just say what each one should say."}],connectTitle:"Connect or create your Resend account",connectDesc:"A new window opens on Resend. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it and holds the keys, so you never touch a server.",connectButtonLabel:"Connect Resend",reassure:["Free to start, no card needed","Connecting takes minutes — verifying your domain in DNS can take longer","Disconnect any time"],altToggleLabel:"Resend not for you? See other options",alternatives:[{monogram:"P",color:"#ffd400",name:"Postmark",desc:"Built for receipts and sign-in links, with a reputation for landing in the inbox fast. A great pick if reliable delivery matters most."},{monogram:"SG",color:"#1a82e2",name:"SendGrid",desc:"A long-established service that scales to very high volume. Handy if you already have an account you'd rather reuse."},{monogram:"SES",color:"#ff9900",name:"Amazon SES",desc:"The cheapest once you're sending a lot, with a little more setup. Best for high volume when you want to trim cost."}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Ds,{size:15}),title:"Verify your sending domain",desc:"Add a few DNS records (SPF, DKIM, DMARC) so providers trust your mail. This can take from a few minutes to a few hours to take effect — until it does, you can only send from Resend's test address, not your own domain."},{icon:e.jsx(Vo,{size:15}),title:"Tell us which emails to send",desc:`Plain language, like "a receipt after each ${t.purchaseNoun}, and a welcome note on sign-up."`},{icon:e.jsx(Ko,{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 th({app:t,verifiedAddress:s,account:n,onComplete:r}){const a=[{title:"A welcome email",caption:"Sent the moment someone signs up, in your voice.",where:"on sign-up"},{title:`A receipt & ${t.purchaseNoun} email`,caption:`With the ${t.entitySingular} details and a ${t.purchaseNoun}, after each purchase.`,where:"on purchase"},{title:"A password reset link",caption:"A secure, single-use link when someone asks to reset.",where:"on request"},{title:"A simple sent log",caption:"See what was sent, delivered, or opened, in one screen.",where:"/emails"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(Fs,{size:25})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"su-title",children:["Send emails from your app"," ",e.jsxs("span",{className:"su-chip connected",children:[e.jsx(ys,{size:11}),"Connected"]})]}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Resend"})]}),e.jsx("p",{className:"su-lead",children:"Your app can send email now. Tell CodeYam which emails to send, in plain language, and it writes and wires each one. You preview every message before a single one goes out."})]})]}),e.jsxs("div",{className:"su-statusbar",children:[e.jsx("div",{className:"su-widget-ic",children:e.jsx(Ds,{size:16})}),e.jsxs("div",{className:"su-widget-body",children:[e.jsx("b",{children:"Your sending address is verified"}),e.jsxs("span",{children:["Emails go out from ",e.jsx("code",{children:s}),", so they look like you, not a robot."]})]}),e.jsx("button",{type:"button",className:"su-chg",children:"Manage"})]}),e.jsxs(Rr,{children:[e.jsx(_t,{state:"done",num:1,title:"Connect your Resend account",pill:"Connected",desc:"CodeYam holds the keys and does the wiring — you never touch a server or a config file.",children:e.jsx(Jo,{monogram:n.monogram,name:n.name,detail:n.detail,monogramStyle:{background:"#ffd400",color:"#1a1a1a"}})}),e.jsxs(_t,{state:"done",num:2,title:"Which emails should your app send?",desc:"Plain language is fine — this is what shapes the emails below.",children:[e.jsxs(Er,{children:["A ",e.jsx("b",{children:"welcome note"})," when someone signs up, a"," ",e.jsxs("b",{children:["receipt with their ",t.purchaseNoun]})," after a purchase, and a"," ",e.jsx("b",{children:"password reset link"})," when they ask for one."]}),e.jsx(Vu,{examples:[`A reminder the day before an ${t.entitySingular}`,`A note when an ${t.entitySingular} is cancelled`,`A monthly "what's on" roundup`]})]}),e.jsx(_t,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four emails, each a plan you can preview, reword, or drop before it ever sends.",children:e.jsx(Mr,{items:a})})]}),e.jsxs(Ir,{accent:"amber",icon:e.jsx(Xo,{size:17}),children:[e.jsx("b",{children:"No email sends yet."})," These four are built as drafts so you can read every word and see how each looks. When it feels right, turn them on and your app starts emailing."]}),e.jsx(Dr,{label:"Plan these 4 emails",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, previewable before anything sends, and easy to reword anytime."]}),onPlan:r})]})}function sh({onBack:t,onComplete:s,app:n=Ar,initialConnected:r=!1,verifiedAddress:a=g_,account:o=b_}){const[i,c]=l.useState(r);return e.jsxs("div",{className:"setup-screen accent-amber",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Sending emails"})]}),e.jsx(Lr,{topic:"emails"}),i?e.jsx(th,{app:n,verifiedAddress:a,account:o,onComplete:s}):e.jsx(Or,{config:x_(n),onConnect:()=>c(!0)})]})}const WO=Object.freeze(Object.defineProperty({__proto__:null,EmailsConnected:th,EmailsScreen:sh},Symbol.toStringTag,{value:"Module"}));function Ln(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function ei({config:t,provider:s,onBack:n,onComplete:r,onRevert:a}){const{stage:o,result:i,error:c,connect:d,reset:u}=Uo(t.key,s),[h,p]=l.useState("");return o==="idle"?e.jsxs(e.Fragment,{children:[e.jsx(Jt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:n}),e.jsx(Mt,{steps:Ln(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:t.connect.heading}),e.jsx("div",{className:"psub",children:t.connect.sub}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(kr,{initial:t.recommended.initial,color:t.recommended.color}),e.jsxs("div",{children:[e.jsxs("div",{className:"cbt",children:["Connect ",t.recommended.name]}),e.jsxs("div",{className:"cbd",children:["Paste a ",t.recommended.name," API token to connect your real account."]})]})]}),e.jsx("label",{className:"real-token-label",htmlFor:"real-token",children:"API token"}),e.jsx("input",{id:"real-token",type:"password",className:"real-token-input",placeholder:`Paste your ${t.recommended.name} token`,value:h,onChange:f=>p(f.target.value)}),e.jsx("button",{type:"button",className:"auth-btn",disabled:h.trim().length===0,onClick:()=>d(h.trim()),children:t.connect.continueLabel})]}),e.jsxs("div",{className:"reassure",children:["🔒 ",t.connect.reassure]})]})]}):o==="error"?e.jsxs(e.Fragment,{children:[e.jsx(Jt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:n}),e.jsx(Mt,{steps:Ln(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t connect"}),e.jsx("div",{className:"real-error-msg",children:c})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{p(""),u()},children:"Try again"})]})]}):o==="ready"?e.jsxs(e.Fragment,{children:[e.jsx(Jt,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(Mt,{steps:Ln(t),currentKey:"ready"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:t.ready.title}),e.jsx("div",{className:"lh-d",children:t.ready.desc})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:(i==null?void 0:i.label)||t.ready.resultLabel}),e.jsx("div",{className:"uc-u",children:(i==null?void 0:i.value)||t.ready.resultValue})]})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx($e,{})," ",t.ready.donePill]}),e.jsx("button",{type:"button",className:"lf-back",onClick:()=>r==null?void 0:r(),children:"Back to Setup"}),a?e.jsx("button",{type:"button",className:"lf-revert",onClick:a,children:"Mark as not complete"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Jt,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(Mt,{steps:Ln(t),currentKey:"provision"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:t.provisionTitle}),e.jsx("div",{className:"deploy-d",children:o==="connecting"?`Connecting to ${t.recommended.name}…`:t.provisionDesc})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const GO=Object.freeze(Object.defineProperty({__proto__:null,RealSetupFlow:ei},Symbol.toStringTag,{value:"Module"})),y_={monogram:"AC",name:"Your app",detail:"you@your-app.com · acct_…"};function v_(t){return{accent:"indigo",assistKey:"payments",badge:e.jsx(Dt,{size:25}),title:"Accept payments",providerName:"Stripe",connectColor:"lime",lead:"You'd like people to be able to pay inside your app. To move money safely, apps don't handle cards themselves — they hand that part to a trusted service. CodeYam uses Stripe.",explainerHeading:"New to Stripe? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Stripe is the part that actually moves the money."})," Think of it as the card machine and the bank, run by someone else, so you never have to touch a customer's card details yourself."]}),explainerRows:[{icon:e.jsx(Re,{size:16}),title:"It takes the payment safely",desc:e.jsxs(e.Fragment,{children:["The buyer types their card into ",e.jsx("em",{children:"Stripe's"})," secure screen, not yours. Sensitive numbers never sit in your app."]})},{icon:e.jsx(Dt,{size:16}),title:"It charges the card",desc:e.jsxs(e.Fragment,{children:["Stripe talks to the banks and approves the payment in"," ",e.jsx("em",{children:"a few seconds"}),", then tells your app it went through."]})},{icon:e.jsx(ft,{size:16}),title:"It pays you",desc:e.jsxs(e.Fragment,{children:["The money lands in ",e.jsx("em",{children:"your bank account"}),", usually within a couple of days. You can watch every sale from your dashboard."]})}],whyHeading:"What it costs",whyRows:[{lead:"It's free to start.",rest:`No monthly fee. Stripe keeps a small cut of each sale (${ce("stripe.usCardFee").value} for US cards; international cards and currency conversion cost more, and a disputed charge carries a fee), so you only pay when you actually get paid. It's trusted by millions of businesses, from corner shops to Amazon.`}],connectTitle:"Connect or create your Stripe account",connectDesc:"A new window opens on Stripe. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it; we never see card numbers.",connectButtonLabel:"Connect Stripe",reassure:["Start in test mode, no real card or bank details needed yet","Connecting takes minutes — activating live payments takes longer","Disconnect any time"],altToggleLabel:"Selling internationally or digital goods? See tax-handling options",alternatives:[{monogram:"LS",color:"linear-gradient(140deg,#ffc233,#e0a000)",name:"Lemon Squeezy",desc:"Acts as the merchant of record, so it collects and remits sales tax/VAT for you worldwide. A strong pick for digital goods or selling outside the US, in exchange for a higher per-sale fee."},{monogram:"P",color:"linear-gradient(140deg,#1b6dff,#0b46c4)",name:"Paddle",desc:"Also a merchant of record handling global tax compliance and invoicing. Built for software and subscriptions where you'd rather not track tax rules in dozens of countries."}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Ds,{size:15}),title:"Activate live payments",desc:"Test mode works right away, but before you can charge a real card Stripe has to verify your business: legal entity, a bank account to pay out to, and sometimes tax info. That review can take a day or two, so it's worth starting early — going live is not just flipping a switch."},{icon:e.jsx(Yo,{size:15}),title:"Tell us what you're selling",desc:`A sentence in plain language, like "${t.entitySingular} ${t.purchaseNoun}s, $10 to $45."`},{icon:e.jsx(Dt,{size:15}),title:"CodeYam builds your checkout",desc:`A "Get ${t.purchaseNoun}s" button, a payment screen, and an emailed receipt — each one a plan you preview before it ships.`}]}}function j_(t){return{key:"payments",connector:{provider:"stripe"},Icon:Dt,title:"Accept payments",crumbLabel:"Payments",meta:"Foundation · about 10 minutes",leads:[{text:"Connect a real Stripe Sandbox so you can run the whole purchase flow against test cards."}],recommendLabel:"Recommended for your app",recommended:{...{initial:"S",color:"linear-gradient(140deg,#635bff,#4b45c6)",name:"Stripe"},bestFit:!0,description:"The payments tech behind millions of apps. Start in a Sandbox with test cards, go live once your business is activated.",reasons:[],chips:["Test cards","Sample products","No real money in Sandbox"]},alternatives:[],ctaLabel:"Set up payments with Stripe",ctaNote:"Nothing charges a real card in a Sandbox.",faq:[],flowLabels:["Connect","Provision","Ready"],connect:{heading:"Connect your Stripe Sandbox",sub:"Create or open a Sandbox in your Stripe Dashboard, then paste that Sandbox's restricted test key (rk_test_…).",grants:["Create sample test products and prices in the Sandbox","Read back the Sandbox so we can link you to it"],continueLabel:"Connect Stripe Sandbox",reassure:"We only accept a test key (rk_test_…). Live keys are rejected — live needs Stripe business activation first."},provisionTitle:"Setting up your Sandbox store",provisionDesc:`Creating sample ${t.purchaseNoun} products and prices in your Stripe Sandbox…`,provisionSteps:["Validating your Sandbox key","Creating sample products","Adding test prices"],ready:{title:"Your Stripe Sandbox is ready",desc:"Sample products and prices are set up. Open the Sandbox to see them and run a test purchase.",resultLabel:"Stripe sandbox",resultValue:"dashboard.stripe.com/test/products",donePill:"Payments connected in test mode"}}}function nh(){const[t,s]=l.useState("test");return e.jsxs("div",{className:"su-modebar",children:[e.jsx("div",{className:"su-widget-ic",children:e.jsx(Ju,{size:16})}),e.jsxs("div",{className:"su-widget-body",children:[e.jsx("b",{children:t==="test"?"You're in test mode":"You're live"}),e.jsx("span",{children:t==="test"?"Use test cards to try the whole flow. No real money moves until you switch to live — and live needs Stripe to verify your business first (legal entity, bank account, sometimes tax info), which can take a day or two.":"Real cards are charged now. Every sale moves real money to your account."})]}),e.jsxs("div",{className:"su-seg",children:[e.jsx("button",{type:"button",className:t==="test"?"on":"",onClick:()=>s("test"),children:"Test"}),e.jsx("button",{type:"button",className:"live"+(t==="live"?" on":""),onClick:()=>s("live"),children:"Live"})]})]})}function rh({app:t,account:s,onComplete:n}){const r=[{title:`A "Get ${t.purchaseNoun}s" button`,caption:`Added to each ${t.entitySingular} so people can buy in one tap.`,where:`/${t.entitySingular}`},{title:"A checkout screen",caption:"Card payment, Apple Pay, and Google Pay, hosted by Stripe.",where:"/checkout"},{title:`An emailed receipt & ${t.purchaseNoun}`,caption:`Stripe sends the card payment receipt automatically; CodeYam adds your own branded confirmation with the ${t.purchaseNoun} (this is the Sending-emails topic, not Stripe).`,where:"email"},{title:"A simple sales view",caption:"See what sold and refund with one click, in your dashboard.",where:"/sales"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(Dt,{size:25})}),e.jsxs("div",{children:[e.jsx("h1",{className:"su-title",children:"Accept payments"}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Stripe"})," · the payments tech behind millions of apps"]}),e.jsxs("p",{className:"su-lead",children:["Let people pay inside your app — buy a ",t.purchaseNoun,", leave a tip, subscribe. CodeYam handles the wiring; you just describe what you're selling and preview every screen before it goes live."]})]})]}),e.jsx(nh,{}),e.jsxs(Rr,{children:[e.jsx(_t,{state:"done",num:1,title:"Connect your Stripe account",pill:"Connected",desc:"CodeYam never sees your customers' card numbers — Stripe handles that part.",children:e.jsx(Jo,{monogram:s.monogram,name:s.name,detail:s.detail})}),e.jsx(_t,{state:"done",num:2,title:"What are you selling?",desc:"Plain language is fine — this is what shapes the screens below.",children:e.jsxs(Er,{children:[t.entitySingular," ",t.purchaseNoun,"s, one-off purchases from"," ",e.jsx("b",{children:"$10 to $45"}),". Buyers get a ",t.purchaseNoun," by email."]})}),e.jsx(_t,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four small changes. Each becomes a plan you can preview, reorder, or drop before it ships.",children:e.jsx(Mr,{items:r})})]}),e.jsxs(Ir,{accent:"amber",icon:e.jsx(Re,{size:17}),children:[e.jsx("b",{children:"Nothing charges a real card yet."})," These four changes build in test mode so you can click through the whole purchase. When it feels right, switch to live and your store is open."]}),e.jsx(Dr,{label:"Plan these 4 changes",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, ready to build after your current session, and previewable before anything ships."]}),onPlan:n})]})}function ah({onBack:t,onComplete:s,onRevert:n,app:r=Ar,initialConnected:a=!1,account:o=y_,connector:i}){const[c,d]=l.useState(a);let u;return i&&c?u=e.jsx(ei,{config:j_(r),provider:i.provider,onBack:()=>d(!1),onComplete:s,onRevert:n}):c?u=e.jsx(rh,{app:r,account:o,onComplete:s}):u=e.jsx(Or,{config:v_(r),onConnect:()=>d(!0)}),e.jsxs("div",{className:"setup-screen accent-indigo",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Payments"})]}),e.jsx(Lr,{topic:"payments"}),u]})}const UO=Object.freeze(Object.defineProperty({__proto__:null,ModeBar:nh,PaymentsConnected:rh,PaymentsScreen:ah},Symbol.toStringTag,{value:"Module"}));function Ze({config:t,onBack:s,onComplete:n,status:r,onRevert:a}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(t.Icon,{size:26}),title:t.title,crumbLabel:t.crumbLabel,meta:t.meta,onBack:s,assistKey:t.key}),t.leads.map(o=>e.jsx("p",{className:"lead"+(o.dim?" dim":""),children:o.text},o.text)),t.sections.map(o=>e.jsxs("div",{children:[e.jsx("div",{className:"seclabel",children:o.heading}),o.body?e.jsx("p",{className:"lead dim",children:o.body}):null,o.bullets?e.jsx("div",{className:"reasons",children:o.bullets.map(i=>e.jsxs("div",{className:"reason",children:[e.jsx($e,{}),e.jsxs("span",{children:[i.lead?e.jsxs("b",{children:[i.lead," "]}):null,i.text]})]},i.text))}):null]},o.heading)),t.options&&t.options.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:t.optionsLabel??"Your options"}),t.options.map(o=>e.jsx(Lo,{provider:o},o.name))]}):null,e.jsx(Ye,{items:t.faq}),e.jsx(de,{assistKey:t.key,topicName:t.title}),e.jsx(he,{label:t.doneLabel,note:t.doneNote??"You can revisit this anytime.",status:r,onComplete:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const YO=Object.freeze(Object.defineProperty({__proto__:null,TeachSetupScreen:Ze},Symbol.toStringTag,{value:"Module"})),w_={key:"analytics-monitoring",Icon:ft,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 oh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:w_,onBack:t,onComplete:s,status:n,onRevert:r})}const VO=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsMonitoringScreen:oh},Symbol.toStringTag,{value:"Module"})),__={key:"legal",Icon:Ae,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 ih({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:__,onBack:t,onComplete:s,status:n,onRevert:r})}const KO=Object.freeze(Object.defineProperty({__proto__:null,LegalScreen:ih},Symbol.toStringTag,{value:"Module"}));function lh({config:t,onBack:s,onSetup:n}){return e.jsxs(e.Fragment,{children:[e.jsx(oe,{icon:e.jsx(t.Icon,{size:26}),title:t.title,crumbLabel:t.crumbLabel,meta:t.meta,onBack:s,assistKey:t.key}),t.leads.map(r=>e.jsx("p",{className:"lead"+(r.dim?" dim":""),children:r.text},r.text)),e.jsx("div",{className:"seclabel",children:t.recommendLabel}),e.jsx(Lo,{provider:t.recommended}),e.jsx(Zd,{alts:t.alternatives}),e.jsxs("div",{className:"cta-wrap",children:[e.jsx("button",{type:"button",className:"cta",onClick:n,children:t.ctaLabel}),e.jsx("div",{className:"cta-note",children:t.ctaNote})]}),e.jsx(Ye,{items:t.faq}),e.jsx(de,{assistKey:t.key,topicName:t.title})]})}const JO=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupOverview:lh},Symbol.toStringTag,{value:"Module"})),_l=1100,k_=700;function ti(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function ch({config:t,onBack:s,onContinue:n}){return e.jsxs(e.Fragment,{children:[e.jsx(Jt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:s}),e.jsx(Mt,{steps:ti(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:t.connect.heading}),e.jsx("div",{className:"psub",children:t.connect.sub}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(kr,{initial:t.recommended.initial,color:t.recommended.color}),e.jsxs("div",{children:[e.jsxs("div",{className:"cbt",children:["Sign in with ",t.recommended.name]}),e.jsxs("div",{className:"cbd",children:["We'll open ",t.recommended.name," in a new tab and bring you right back."]})]})]}),e.jsx("div",{className:"grant",children:t.connect.grants.map(r=>e.jsxs("div",{className:"grantrow",children:[e.jsx($e,{color:"var(--blue-300)"}),e.jsx("span",{children:r})]},r))}),e.jsx("button",{type:"button",className:"auth-btn",onClick:n,children:t.connect.continueLabel}),e.jsxs("div",{className:"auth-row",children:[e.jsx("button",{type:"button",className:"auth-ghost",onClick:n,children:"I already have an account"}),e.jsx("button",{type:"button",className:"auth-ghost",onClick:n,children:"Create one for me"})]})]}),e.jsxs("div",{className:"reassure",children:["🔒 ",t.connect.reassure]})]})]})}function dh({config:t,onDone:s}){const n=t.provisionSteps,[r,a]=l.useState(0),o=l.useRef(s);o.current=s,l.useEffect(()=>{const c=[];for(let d=1;d<=n.length;d++)c.push(setTimeout(()=>a(d),d*_l));return c.push(setTimeout(()=>o.current(),n.length*_l+k_)),()=>c.forEach(clearTimeout)},[n.length]);const i=Math.round(r/n.length*100);return e.jsxs(e.Fragment,{children:[e.jsx(Jt,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(Mt,{steps:ti(t),currentKey:"provision"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:t.provisionTitle}),e.jsx("div",{className:"deploy-d",children:t.provisionDesc})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{style:{width:i+"%"}})}),e.jsx("div",{className:"dep-steps",children:n.map((c,d)=>e.jsxs("div",{className:"dep-step "+(d<r?"done":d===r?"active":"todo"),children:[e.jsx("div",{className:"dot",children:d<r?e.jsx($e,{size:12,color:"#0a0a0a"}):null}),e.jsx("div",{className:"sl",children:c})]},c))})]})]})}function uh({config:t,onFinish:s,onRevert:n}){return e.jsxs(e.Fragment,{children:[e.jsx(Jt,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(Mt,{steps:ti(t),currentKey:"ready"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:t.ready.title}),e.jsx("div",{className:"lh-d",children:t.ready.desc})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:t.ready.resultLabel}),e.jsx("div",{className:"uc-u",children:t.ready.resultValue})]})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx($e,{})," ",t.ready.donePill]}),e.jsx("button",{type:"button",className:"lf-back",onClick:s,children:"Back to Setup"}),n?e.jsx("button",{type:"button",className:"lf-revert",onClick:n,children:"Mark as not complete"}):null]})]})]})}const XO=Object.freeze(Object.defineProperty({__proto__:null,SimulatedConnect:ch,SimulatedProvision:dh,SimulatedReady:uh},Symbol.toStringTag,{value:"Module"}));function yn({config:t,onBack:s,onComplete:n,onRevert:r}){const[a,o]=l.useState("overview");let i;return a==="overview"?i=e.jsx(lh,{config:t,onBack:s,onSetup:()=>o("connect")}):t.connector?i=e.jsx(ei,{config:t,provider:t.connector.provider,onBack:()=>o("overview"),onComplete:()=>{n==null||n(),s()},onRevert:r?()=>{r(),s()}:void 0}):a==="connect"?i=e.jsx(ch,{config:t,onBack:()=>o("overview"),onContinue:()=>o("provision")}):a==="provision"?i=e.jsx(dh,{config:t,onDone:()=>o("ready")}):i=e.jsx(uh,{config:t,onFinish:()=>{n==null||n(),s()},onRevert:r?()=>{r(),s()}:void 0}),e.jsx("div",{className:"hosting-screen",children:i})}const QO=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupScreen:yn},Symbol.toStringTag,{value:"Module"})),S_={key:"publish",Icon:xs,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:`${ce("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. ${ce("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: ${ce("cloudflarePages.free").value.toLowerCase()}, so traffic spikes won't cost you. Netlify's free tier: ${ce("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 hh({onBack:t,onComplete:s,onRevert:n}){return e.jsx(yn,{config:S_,onBack:t,onComplete:s,onRevert:n})}const ZO=Object.freeze(Object.defineProperty({__proto__:null,PublishScreen:hh},Symbol.toStringTag,{value:"Module"})),N_={key:"custom-domain",Icon:Lt,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 ph({onBack:t,onComplete:s,onRevert:n}){return e.jsx(yn,{config:N_,onBack:t,onComplete:s,onRevert:n})}const e6=Object.freeze(Object.defineProperty({__proto__:null,CustomDomainScreen:ph},Symbol.toStringTag,{value:"Module"})),C_={key:"data-safety",Icon:xn,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 mh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:C_,onBack:t,onComplete:s,status:n,onRevert:r})}const t6=Object.freeze(Object.defineProperty({__proto__:null,DataSafetyScreen:mh},Symbol.toStringTag,{value:"Module"})),P_={key:"forms",Icon:Fs,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 ${ce("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 fh({onBack:t,onComplete:s,onRevert:n}){return e.jsx(yn,{config:P_,onBack:t,onComplete:s,onRevert:n})}const s6=Object.freeze(Object.defineProperty({__proto__:null,FormsScreen:fh},Symbol.toStringTag,{value:"Module"})),T_={key:"analytics-seo",Icon:ft,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 gh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:T_,onBack:t,onComplete:s,status:n,onRevert:r})}const n6=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsSeoScreen:gh},Symbol.toStringTag,{value:"Module"})),A_={key:"redirects-404",Icon:Lt,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 bh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:A_,onBack:t,onComplete:s,status:n,onRevert:r})}const r6=Object.freeze(Object.defineProperty({__proto__:null,RedirectsNotFoundScreen:bh},Symbol.toStringTag,{value:"Module"})),O_={key:"performance-images",Icon:Le,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 xh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:O_,onBack:t,onComplete:s,status:n,onRevert:r})}const a6=Object.freeze(Object.defineProperty({__proto__:null,PerformanceImagesScreen:xh},Symbol.toStringTag,{value:"Module"})),R_={key:"comments-search",Icon:Ae,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 yh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:R_,onBack:t,onComplete:s,status:n,onRevert:r})}const o6=Object.freeze(Object.defineProperty({__proto__:null,CommentsSearchScreen:yh},Symbol.toStringTag,{value:"Module"})),Ts={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."}},E_=[Ts.crates,Ts.npm,Ts.pypi,Ts.rubygems,Ts.homebrew];function vh(t){return Ts[t]}function jh({registry:t,onBack:s,onComplete:n,status:r,onRevert:a}){const o=t?vh(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(rt,{size:26}),title:"Publish to a registry",meta:"Foundation · about 20 minutes",onBack:s,assistKey:"publish-registry"}),e.jsxs("p",{className:"lead",children:["This kind of project doesn't go live at a web address — it ships to a"," ",e.jsx("b",{children:"package registry"}),", where people install it with a single command or add it as a dependency. Publishing is how your work reaches its users."]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"seclabel",children:["Your registry: ",o.name," (",o.ecosystem,")"]}),e.jsxs(ne,{children:[e.jsxs(R,{lead:`Publish with \`${o.publishCommand}\`.`,children:["From a clean, committed working tree, this packages the release and uploads it to ",o.name,". Get an account and an API token first.",o.note?e.jsxs(e.Fragment,{children:[" ",o.note]}):null]}),e.jsx(R,{lead:`Users then run \`${o.installCommand}\`.`,children:"Once published, anyone can install your package with one command — no clone, no build from source."}),e.jsxs(R,{lead:"Your package gets a public page.",children:[o.name," hosts a page at"," ",e.jsx("code",{children:o.packagePage})," — the link you share so people can find, install, and trust the package."]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Before your first publish"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Claim the name before someone else does.",children:["The package name is first-come, first-served and is your public identity — squatting is common on crates.io and PyPI. If the bare name is taken (or to protect a brand), publish under a namespace: an npm scope (",e.jsx("code",{children:"@you/tool"}),") or an org account."]}),e.jsxs(R,{lead:"Turn on two-factor auth — registries expect it.",children:[ce("registry.twoFactor").value,"."," ",e.jsx(es,{fact:ce("registry.twoFactor")})," A token alone often isn't enough; set up 2FA before the release deadline, not during it."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:o.publishCommand}),e.jsx("span",{className:"chip",children:"Tokened account"}),e.jsx("span",{className:"chip",children:"Public package page"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:"Pick your registry"}),e.jsx(ne,{children:E_.map(i=>e.jsxs(R,{lead:`${i.name} — ${i.ecosystem}.`,children:["Publish with ",e.jsx("code",{children:i.publishCommand}),"; users install with"," ",e.jsx("code",{children:i.installCommand}),".",i.note?e.jsxs(e.Fragment,{children:[" ",i.note]}):null]},i.kind))}),e.jsx("div",{className:"asknote",style:{marginTop:14},children:"Every registry follows the same shape: an account with an API token, one publish command, and a public package page you share. Match the registry to your toolchain."})]}),e.jsx(de,{assistKey:"publish-registry",topicName:"Publish to a registry"}),e.jsx(he,{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:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const i6=Object.freeze(Object.defineProperty({__proto__:null,PublishRegistryScreen:jh},Symbol.toStringTag,{value:"Module"}));function wh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"Versioning & changelog",meta:"About 20 minutes",onBack:t,assistKey:"versioning-changelog"}),e.jsxs("p",{className:"lead",children:["A version number is a promise. ",e.jsx("b",{children:"Semantic versioning"})," (MAJOR.MINOR.PATCH) lets people upgrade with confidence: a patch is safe, a minor adds features, a major may break them."]}),e.jsx("div",{className:"seclabel",children:"The three numbers"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"PATCH (1.2.x) — bug fixes only.",children:"Nothing user-visible changes except that something broken now works. Always safe to take."}),e.jsx(R,{lead:"MINOR (1.x.0) — new, backward-compatible features.",children:"Existing usage keeps working; there's just more available."}),e.jsx(R,{lead:"MAJOR (x.0.0) — breaking changes.",children:"You removed or changed something people relied on. Bumping major is how you warn them."}),e.jsxs(R,{lead:"Before 1.0.0 (0.x) — anything may break.",children:["The most-missed rule for new tools: while you're on a"," ",e.jsx("code",{children:"0.x"})," version, semver lets a ",e.jsx("i",{children:"minor"})," bump break things. Releasing 1.0.0 is the moment you commit to the stability promise above — don't ship it until you're ready to keep it."]})]}),e.jsx(Oo,{spaced:!0,children:e.jsxs(R,{lead:"Tag each release in git.",children:["A ",e.jsx("code",{children:"v1.2.0"}),' tag ties the version to the exact commit, so a report against "1.2.0" is reproducible. Make the tag the trigger: pushing it kicks off the CI release job that publishes that same version to the registry and attaches the binaries — so the git tag, the published version, and the release artifacts can never disagree.']})}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"MAJOR.MINOR.PATCH"}),e.jsx("span",{className:"chip",children:"CHANGELOG.md"}),e.jsx("span",{className:"chip",children:"git tag vX.Y.Z"})]}),e.jsx(de,{assistKey:"versioning-changelog",topicName:"Versioning & changelog"}),e.jsx(he,{label:"My versioning scheme is set",note:"Pick the scheme once; every future release just follows the same rules.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const l6=Object.freeze(Object.defineProperty({__proto__:null,VersioningChangelogScreen:wh},Symbol.toStringTag,{value:"Module"}));function _h({registry:t,onBack:s,onComplete:n,status:r,onRevert:a}){const o=t?vh(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"Install docs",meta:"About 30 minutes · writing time",onBack:s,assistKey:"install-docs"}),e.jsxs("p",{className:"lead",children:["Your README is the front page of the package. A new user decides whether to try it in the first few lines, so lead with the"," ",e.jsx("b",{children:"install command"})," and a tiny working example."]}),e.jsx("div",{className:"seclabel",children:"A good README opens with"}),e.jsxs(ne,{children:[e.jsx(R,{lead:o?`The install command — \`${o.installCommand}\`.`:"The exact install command.",children:"One copy-pasteable line. Don't make people guess the package name or the registry it lives on."}),e.jsxs(R,{lead:"A real first command to run.",children:["For a CLI, show an actual invocation — a quickstart like"," ",e.jsx("code",{children:"yourtool init"})," and the always-works"," ",e.jsx("code",{children:"yourtool --help"})," — not a library-style code snippet. The smallest thing that does something real; people skim, so show, don't describe."]}),e.jsx(R,{lead:"Supported platforms or versions.",children:"Which OSes, language versions, or runtimes you support, so users know before they install whether it'll work for them."}),e.jsxs(R,{lead:"Badges and a link to the package page.",children:["A version / build / license badge row at the top signals the package is current and maintained, and a link to its"," ",o?o.name:"registry"," page (",e.jsx("code",{children:o?o.packagePage:"the registry listing"}),") gives readers the canonical source."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Install line first"}),e.jsx("span",{className:"chip",children:"Real command, not a snippet"}),e.jsx("span",{className:"chip",children:"Badges + package link"}),e.jsx("span",{className:"chip",children:o?o.name:"Any registry"})]}),e.jsx(de,{assistKey:"install-docs",topicName:"Install docs"}),e.jsx(he,{label:"My install docs are ready",note:"Docs evolve with the project — update the README whenever the install or usage changes.",status:r,onComplete:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const c6=Object.freeze(Object.defineProperty({__proto__:null,InstallDocsScreen:_h},Symbol.toStringTag,{value:"Module"}));function kh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Le,{size:26}),title:"Release builds",meta:"About 45 minutes · CI setup",onBack:t,assistKey:"release-builds"}),e.jsxs("p",{className:"lead",children:["Not everyone installs from a registry — many people just want a binary they can run. ",e.jsx("b",{children:"Cross-platform release builds"})," produce that binary for each operating system, so users download one file and go."]}),e.jsx("div",{className:"seclabel",children:"What to produce"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"One binary per target platform.",children:"Typically macOS (Intel + Apple Silicon), Linux (x86_64 + arm64), and Windows. Build each in its own job rather than cross-compiling blindly."}),e.jsx(R,{lead:"Sign and notarize the binaries.",children:"The biggest real-world gap: an unsigned download is quarantined by macOS Gatekeeper and flagged by Windows SmartScreen, so users see a scary warning instead of your tool. Sign (and notarize on macOS) as part of the release job, or distribute via Homebrew/winget where the channel handles trust."}),e.jsxs(R,{lead:"Build on a git tag, in CI.",children:["A push of ",e.jsx("code",{children:"v1.2.0"})," triggers the release workflow, so binaries always match a real, tagged version — no laptop builds. A tool like ",e.jsx("code",{children:"cargo-dist"}),", ",e.jsx("code",{children:"goreleaser"}),", or electron-builder wires up the whole matrix-build-sign-publish flow instead of you hand-writing it."]}),e.jsxs(R,{lead:"Attach them to a GitHub Release.",children:["Upload the binaries (and their checksums) to the tagged"," ",e.jsx("b",{children:"GitHub Release"})," — the common path — so the download links live next to the changelog. A package channel (Homebrew tap, winget) is the usual alternative."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"macOS · Linux · Windows"}),e.jsx("span",{className:"chip",children:"Signed + notarized"}),e.jsx("span",{className:"chip",children:"Tag-triggered CI"}),e.jsx("span",{className:"chip",children:"GitHub Releases"}),e.jsx("span",{className:"chip",children:"Checksums"})]}),e.jsx(de,{assistKey:"release-builds",topicName:"Release builds"}),e.jsx(he,{label:"My release builds are set up",note:"Once the workflow exists, every future tag produces binaries automatically.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const d6=Object.freeze(Object.defineProperty({__proto__:null,ReleaseBuildsScreen:kh},Symbol.toStringTag,{value:"Module"}));function Sh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Is,{size:26}),title:"Shell completions",meta:"About 30 minutes · polish",onBack:t,assistKey:"shell-completions"}),e.jsx("p",{className:"lead",children:"Tab completion is the difference between a tool people tolerate and one they enjoy. Press Tab and the shell offers your subcommands and flags — no need to remember exact spellings."}),e.jsx("div",{className:"seclabel",children:"How it works"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Generate a completion script per shell.",children:["Most CLI frameworks emit completion scripts for ",e.jsx("code",{children:"bash"}),","," ",e.jsx("code",{children:"zsh"}),", ",e.jsx("code",{children:"fish"}),", and PowerShell from your command definitions — you don't hand-write them."]}),e.jsxs(R,{lead:"Ship a `completions` subcommand.",children:["A ",e.jsx("code",{children:"yourtool completions zsh"})," command lets users (and your install docs) print the script for their shell on demand."]}),e.jsx(R,{lead:"Document where each shell loads them.",children:"Each shell reads completions from its own directory. A short table in your README saves users the lookup."}),e.jsxs(R,{lead:"Generate a man page from the same source.",children:["The sibling polish step: most CLI frameworks also emit a"," ",e.jsx("code",{children:"man"})," page from your command definitions, so"," ",e.jsx("code",{children:"man yourtool"})," works the way completions do — generated, not hand-written."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"bash · zsh · fish"}),e.jsx("span",{className:"chip",children:"Generated, not hand-written"}),e.jsx("span",{className:"chip",children:"completions subcommand"})]}),e.jsx(de,{assistKey:"shell-completions",topicName:"Shell completions"}),e.jsx(he,{label:"My shell completions are ready",note:"Completions regenerate from your commands — they stay in sync as the CLI grows.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const u6=Object.freeze(Object.defineProperty({__proto__:null,ShellCompletionsScreen:Sh},Symbol.toStringTag,{value:"Module"}));function Nh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Is,{size:26}),title:"Command-line UX",meta:"About 30 minutes · the interface contract",onBack:t,assistKey:"cli-ux"}),e.jsx("p",{className:"lead",children:"A CLI's interface isn't its code — it's how it behaves at the prompt. The same four conventions show up in every tool people trust, because both a human and a shell script read your tool through them."}),e.jsx("div",{className:"seclabel",children:"The conventions every CLI follows"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"`--help` and `-h` always work, on every subcommand.",children:"The first thing anyone types at an unfamiliar tool. Each subcommand gets its own help with a one-line summary, usage, and examples — not just the top-level command."}),e.jsx(R,{lead:"`--version` prints a single line and exits 0.",children:"Scripts and bug reports parse it; keep it to just the version string so it stays machine-readable."}),e.jsxs(R,{lead:"Exit codes mean something.",children:[e.jsx("code",{children:"0"})," for success, non-zero for failure — and ideally distinct codes for distinct failures. This is how"," ",e.jsx("code",{children:"cmd && next"})," and CI know whether to continue, so an error that exits 0 silently breaks every script wrapping you."]}),e.jsx(R,{lead:"Results on stdout, diagnostics on stderr.",children:`Stdout is the data a user pipes into the next command; progress, warnings, and errors go to stderr so they don't corrupt that pipe. Getting this backwards is the most common reason a tool "doesn't work in a pipeline."`})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"--help · --version"}),e.jsx("span",{className:"chip",children:"Meaningful exit codes"}),e.jsx("span",{className:"chip",children:"stdout = data, stderr = noise"})]}),e.jsx(de,{assistKey:"cli-ux",topicName:"Command-line UX"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const h6=Object.freeze(Object.defineProperty({__proto__:null,CliUxScreen:Nh},Symbol.toStringTag,{value:"Module"}));function Ch({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Re,{size:26}),title:"Security & supply chain",meta:"About 45 minutes · trust",onBack:t,assistKey:"supply-chain"}),e.jsx("p",{className:"lead",children:"The moment you publish, your code becomes a dependency in someone else's build — and your security becomes part of theirs. A few habits make what you ship trustworthy: audit what you depend on, catch known vulnerabilities before release, and sign the release so users can verify it's really yours."}),e.jsx("div",{className:"seclabel",children:"What a published artifact owes its users"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Audit your own dependencies.",children:["Run ",e.jsx("code",{children:"cargo audit"})," (Rust) or ",e.jsx("code",{children:"npm audit"})," /"," ",e.jsx("code",{children:"pip-audit"})," in CI so a known-vulnerable transitive dependency fails the build instead of shipping. Wire it into the same workflow that runs your tests."]}),e.jsx(R,{lead:"Scan continuously, not just once.",children:"New CVEs are disclosed against dependencies you already shipped. A scanner like Dependabot or Renovate opens update PRs as advisories land, so you're patching on the advisory's clock, not discovering it from a user's bug report."}),e.jsxs(R,{lead:"Publish an SBOM.",children:["A Software Bill of Materials lists every component and version in your release. Downstream users — especially in regulated shops — scan it to decide whether your release is safe to adopt. Most toolchains generate one (",e.jsx("code",{children:"cargo sbom"}),", ",e.jsx("code",{children:"npm sbom"}),","," ",e.jsx("code",{children:"syft"}),")."]}),e.jsxs(R,{lead:"Sign your releases so they can be verified.",children:[ce("supplyChain.signedReleases").value,"."," ",e.jsx(es,{fact:ce("supplyChain.signedReleases")})," ","Pair that with published checksums (and a ",e.jsx("code",{children:"cosign"})," signature for binaries) so an install can prove it got exactly what you built."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"audit in CI"}),e.jsx("span",{className:"chip",children:"SBOM per release"}),e.jsx("span",{className:"chip",children:"Signed & verifiable"})]}),e.jsx(de,{assistKey:"supply-chain",topicName:"Security & supply chain"}),e.jsx(he,{label:"My supply chain is covered",note:"Wire audit + signing into CI once; every future release inherits it automatically.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const p6=Object.freeze(Object.defineProperty({__proto__:null,SupplyChainScreen:Ch},Symbol.toStringTag,{value:"Module"}));function Ph({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"Examples & doctests",meta:"About 40 minutes · adoption",onBack:t,assistKey:"examples"}),e.jsxs("p",{className:"lead",children:["Reference docs say what each function does; ",e.jsx("b",{children:"examples"})," show how the pieces fit together to do something real. Most people copy a working example before they ever read the API reference — it's the single biggest thing you can add to make a library easy to adopt."]}),e.jsx("div",{className:"seclabel",children:"What to ship"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Runnable examples, not snippets in a README.",children:["Put complete programs in an ",e.jsx("code",{children:"examples/"})," directory that build and run as-is (",e.jsx("code",{children:"cargo run --example quickstart"}),"). A snippet a user has to assemble themselves is a snippet that's subtly wrong."]}),e.jsx(R,{lead:"Start with the one-minute quickstart.",children:"The first example should be the shortest path from install to a result. Show the 80% use case end to end before any advanced configuration — that's the example most people will actually run."}),e.jsxs(R,{lead:"Make the docs themselves runnable with doctests.",children:["A doctest is an example embedded in a doc comment that the test runner actually executes (",e.jsx("code",{children:"cargo test --doc"}),", Python's"," ",e.jsx("code",{children:"doctest"}),"). It means the snippet in your reference can't silently rot — if the API changes, the doctest fails CI."]}),e.jsxs(R,{lead:"Run examples and doctests in CI.",children:["An example that no longer compiles is worse than none — it tells users the library is unmaintained. Build the ",e.jsx("code",{children:"examples/"})," and run the doctests on every commit so a broken one fails the build."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"examples/ directory"}),e.jsx("span",{className:"chip",children:"One-minute quickstart"}),e.jsx("span",{className:"chip",children:"Doctests run in CI"})]}),e.jsx(de,{assistKey:"examples",topicName:"Examples & doctests"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const m6=Object.freeze(Object.defineProperty({__proto__:null,ExamplesScreen:Ph},Symbol.toStringTag,{value:"Module"}));function Th({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"API docs",meta:"Foundation · about 30 minutes",onBack:t,assistKey:"api-docs"}),e.jsxs("p",{className:"lead",children:["For a library, the public API ",e.jsx("i",{children:"is"})," the product — so its reference docs matter as much as the code. The trick is to"," ",e.jsx("b",{children:"generate docs from the source"}),", so they can't drift out of date."]}),e.jsx("div",{className:"seclabel",children:"Generate, don't hand-write"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Doc comments on every public item.",children:"Document each exported function, type, and field where it's defined. The generator turns those comments into the reference site."}),e.jsxs(R,{lead:"A generator for your language.",children:[e.jsx("code",{children:"docs.rs"})," for Rust, ",e.jsx("code",{children:"TypeDoc"})," for TypeScript,"," ",e.jsx("code",{children:"Sphinx"})," (or the more modern"," ",e.jsx("code",{children:"MkDocs + mkdocstrings"}),") for Python — each reads your source and produces a browsable site."]}),e.jsx(R,{lead:"Publish on every release.",children:"Many registries (docs.rs) build docs automatically on publish; for others, a CI step deploys them. Either way, the live docs track the released version."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"docs.rs · TypeDoc · Sphinx"}),e.jsx("span",{className:"chip",children:"From doc comments"}),e.jsx("span",{className:"chip",children:"Auto-built on publish"})]}),e.jsx(de,{assistKey:"api-docs",topicName:"API docs"}),e.jsx(he,{label:"My API docs are published",note:"Because they're generated from source, the docs refresh themselves on every release.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const f6=Object.freeze(Object.defineProperty({__proto__:null,ApiDocsScreen:Th},Symbol.toStringTag,{value:"Module"})),M_={key:"api-docs",Icon:Ae,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 Ah({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:M_,onBack:t,onComplete:s,status:n,onRevert:r})}const g6=Object.freeze(Object.defineProperty({__proto__:null,BackendApiDocsScreen:Ah},Symbol.toStringTag,{value:"Module"}));function Oh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"Versioning policy",meta:"About 20 minutes · a decision",onBack:t,assistKey:"semver-policy"}),e.jsxs("p",{className:"lead",children:["Other people's code depends on yours. A breaking change you ship quietly breaks their builds. A written ",e.jsx("b",{children:"versioning policy"})," is the promise that makes your library safe to depend on."]}),e.jsx("div",{className:"seclabel",children:"Decide and write down"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"What counts as a breaking change.",children:"Removing or renaming a public item, changing a signature, tightening accepted input. Anything a user's code could rely on is part of the contract."}),e.jsx(R,{lead:"How you signal it.",children:"Breaking changes mean a MAJOR bump. Spell out that the public API is covered and what's explicitly *not* (internal modules, anything marked unstable)."}),e.jsx(R,{lead:"Your deprecation path.",children:"Mark an item deprecated for at least one minor release before removing it, so users get a warning and time to migrate — not a surprise."}),e.jsxs(R,{lead:"Let a tool catch breaks for you.",children:["You don't have to spot every breaking change by eye:"," ",e.jsx("code",{children:"cargo-semver-checks"})," (Rust) and"," ",e.jsx("code",{children:"api-extractor"})," (TypeScript) diff your public API against the last release and fail CI when a change needs a MAJOR bump."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Public API = the contract"}),e.jsx("span",{className:"chip",children:"Breaking → MAJOR"}),e.jsx("span",{className:"chip",children:"Deprecate before removing"})]}),e.jsx(de,{assistKey:"semver-policy",topicName:"Versioning policy"}),e.jsx(he,{label:"My versioning policy is set",note:"Write it in the README once; it guides every release decision afterward.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const b6=Object.freeze(Object.defineProperty({__proto__:null,SemverPolicyScreen:Oh},Symbol.toStringTag,{value:"Module"}));function Rh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"Readme & license",meta:"About 30 minutes",onBack:t,assistKey:"readme-license"}),e.jsxs("p",{className:"lead",children:["Two files decide whether someone adopts your library: the"," ",e.jsx("b",{children:"README"})," tells them what it does, and the ",e.jsx("b",{children:"license"}),` tells them whether they're allowed to use it. Skip the license and the legal default is "all rights reserved" — nobody can.`]}),e.jsx("div",{className:"seclabel",children:"A README that earns trust"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"One sentence: what it is and who it's for.",children:"The first line should let a reader decide in seconds whether to keep reading."}),e.jsx(R,{lead:"Install + a minimal example.",children:'The fastest path from "interested" to "it works on my machine".'})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Pick a license"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Permissive (MIT, Apache-2.0) — easiest to adopt.",children:"Lets people use your library in almost any project. Apache-2.0 also grants patent rights, which some companies require."}),e.jsxs(R,{lead:"Library copyleft (LGPL, MPL-2.0) — share changes, not callers.",children:["For a library, the relevant copyleft is ",e.jsx("b",{children:"LGPL"})," or"," ",e.jsx("b",{children:"MPL-2.0"}),": changes to your code stay open, but code that merely links to or imports it doesn't have to be. Full ",e.jsx("b",{children:"GPL"})," forces every consumer to be GPL too, which usually kills adoption for a library — reach for it only on purpose."]})]}),e.jsx(ne,{children:e.jsxs(R,{lead:"Declare the license in your package manifest, too.",children:["A LICENSE file alone isn't enough — set the ",e.jsx("code",{children:"license"})," field in your manifest (",e.jsx("code",{children:"Cargo.toml"}),", ",e.jsx("code",{children:"package.json"}),","," ",e.jsx("code",{children:"pyproject.toml"}),") so the registry detects and displays it on the package page."]})}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"README first line"}),e.jsx("span",{className:"chip",children:"LICENSE file + manifest field"}),e.jsx("span",{className:"chip",children:"MIT · Apache-2.0 · LGPL/MPL"})]}),e.jsx(de,{assistKey:"readme-license",topicName:"Readme & license"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const x6=Object.freeze(Object.defineProperty({__proto__:null,ReadmeLicenseScreen:Rh},Symbol.toStringTag,{value:"Module"}));function Eh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(ft,{size:26}),title:"Changelog & CI",meta:"About 40 minutes · automation",onBack:t,assistKey:"changelog-ci"}),e.jsx("p",{className:"lead",children:"A changelog tells people what changed before they upgrade; CI makes sure every release is tested and published the same way. Together they turn releasing from a careful manual ritual into a tagged, repeatable step."}),e.jsx(Oo,{}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Automate the release"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"CI runs tests on every change.",children:"A green pipeline is the precondition for any release — no publishing from an untested commit."}),e.jsxs(R,{lead:"A tag triggers publish.",children:["Pushing ",e.jsx("code",{children:"v1.2.0"})," runs the release job: test, build, and publish to the registry. The version published always matches the tag."]}),e.jsxs(R,{lead:"Give CI a way to authenticate.",children:["The release job needs publish credentials. The classic path is a registry token in a CI secret (",e.jsx("code",{children:"CARGO_REGISTRY_TOKEN"}),","," ",e.jsx("code",{children:"NPM_TOKEN"}),"). The current best practice is"," ",e.jsx("b",{children:"OIDC trusted publishing"}),": ",ce("registry.oidc").value,"."," ",e.jsx(es,{fact:ce("registry.oidc")})]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"CHANGELOG.md"}),e.jsx("span",{className:"chip",children:"Tests on every push"}),e.jsx("span",{className:"chip",children:"Tag → publish"}),e.jsx("span",{className:"chip",children:"OIDC or token"})]}),e.jsx(de,{assistKey:"changelog-ci",topicName:"Changelog & CI"}),e.jsx(he,{label:"My changelog & CI are set up",note:"Once the pipeline exists, releasing is just pushing a tag — the rest runs itself.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const y6=Object.freeze(Object.defineProperty({__proto__:null,ChangelogCiScreen:Eh},Symbol.toStringTag,{value:"Module"})),I_=ce("flyio.pricing"),D_={key:"deploy-target",connector:{provider:"render"},Icon:xs,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:I_.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 Mh({onBack:t,onComplete:s,onRevert:n}){return e.jsx(yn,{config:D_,onBack:t,onComplete:s,onRevert:n})}const v6=Object.freeze(Object.defineProperty({__proto__:null,DeployTargetScreen:Mh},Symbol.toStringTag,{value:"Module"})),L_={key:"database-backups",Icon:xn,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 Ih({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:L_,onBack:t,onComplete:s,status:n,onRevert:r})}const j6=Object.freeze(Object.defineProperty({__proto__:null,DatabaseBackupsScreen:Ih},Symbol.toStringTag,{value:"Module"}));function F_(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!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();n||s(a)}catch{n||s(null)}})(),()=>{n=!0}},[]),{env:t}}const z_={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 Dh(t,s){const n=[...t,...s];return n.length===0?z_:{heading:"This project's secrets",bullets:n.map(r=>({lead:`${r} —`,text:s.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 Lh(t,s){return{key:"secrets",Icon:Re,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:[Dh(t,s),{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 Fh({onBack:t,onComplete:s,status:n,onRevert:r}){const{env:a}=F_(),o=Lh((a==null?void 0:a.envKeys)??[],(a==null?void 0:a.serviceEnvVars)??[]);return e.jsx(Ze,{config:o,onBack:t,onComplete:s,status:n,onRevert:r})}const w6=Object.freeze(Object.defineProperty({__proto__:null,SecretsScreen:Fh,buildConfig:Lh,secretsSection:Dh},Symbol.toStringTag,{value:"Module"})),$_={key:"api-auth",Icon:Re,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 zh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:$_,onBack:t,onComplete:s,status:n,onRevert:r})}const _6=Object.freeze(Object.defineProperty({__proto__:null,ApiAuthScreen:zh},Symbol.toStringTag,{value:"Module"})),B_={key:"cors-origins",Icon:Lt,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 $h({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:B_,onBack:t,onComplete:s,status:n,onRevert:r})}const k6=Object.freeze(Object.defineProperty({__proto__:null,CorsOriginsScreen:$h},Symbol.toStringTag,{value:"Module"})),q_={key:"background-jobs",Icon:Le,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 Bh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:q_,onBack:t,onComplete:s,status:n,onRevert:r})}const S6=Object.freeze(Object.defineProperty({__proto__:null,BackgroundJobsScreen:Bh},Symbol.toStringTag,{value:"Module"})),H_={key:"logging-monitoring",Icon:ft,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 qh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Ze,{config:H_,onBack:t,onComplete:s,status:n,onRevert:r})}const N6=Object.freeze(Object.defineProperty({__proto__:null,LoggingMonitoringScreen:qh},Symbol.toStringTag,{value:"Module"}));function Ha({onBack:t,onComplete:s,status:n,onRevert:r}){const a=[{q:"Is a preview the same build as production?",a:"If you wire it up right, yes — a preview deploy runs the same build command and the same framework output as production, just on a throwaway URL. That's the whole point: what you click on the preview is what ships. Where it can differ is data and secrets — a preview usually points at a staging database, not prod — so test behavior on the preview, but don't trust preview data as if it were live."},{q:"Can I share it without making it public?",a:"Yes. Most hosts let you password-protect a preview or restrict it to your team's accounts, so you can hand a reviewer or a client a working link before the production domain points anywhere. Protect previews by default if the build exposes anything you wouldn't want indexed — search engines and link unfurlers will otherwise crawl an open preview URL."},{q:"Do I need a separate staging environment too?",a:"Per-branch previews are throwaway and rebuilt on every push. A longer-lived staging environment is the complement: one stable URL, its own data, that behaves like prod and stays up between deploys — useful for QA sign-off, demos, and integrations that need a fixed address. Many teams use preview deploys for review and one staging environment as the final gate before production."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Le,{size:26}),title:"Staging & preview deploys",meta:"About 15 minutes · then automatic on every push",onBack:t,assistKey:"staging-preview"}),e.jsx("p",{className:"lead",children:"Before you point your real domain at anything, give yourself a prod-like URL to test on and share. Most hosts can build one for you on every push, so you and your reviewers see the exact build that will go live — without anyone touching production."}),e.jsx("div",{className:"seclabel",children:"Per-branch preview deploys"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Get a URL for every branch or pull request.",children:["Hosts like ",e.jsx("b",{children:"Vercel"})," and ",e.jsx("b",{children:"Netlify"})," build a fresh deploy each time you push and give it its own URL. The preview runs the same build as production, so it's the real thing on a throwaway address — not a local approximation."]}),e.jsx(R,{lead:"Review the change on the preview, not on prod.",children:"Open the preview URL for the branch, click through the actual change, and only merge once it looks right. This is where you catch a broken build or a layout regression before it can reach a visitor."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"A shared staging environment"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Keep one stable, prod-like URL with its own data.",children:"A longer-lived staging environment behaves like production — same build, its own database and config — but stays up between deploys. It's the fixed address QA, demos, and integrations point at while per-branch previews come and go."}),e.jsx(R,{lead:"Promote the same build to production.",children:"When staging looks right, promote that build to production rather than rebuilding from scratch. What you signed off on is what ships, so going live is a flip of the switch, not a fresh roll of the dice."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Share it privately"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Password-protect or restrict the preview.",children:"So you can hand a working link to a client or teammate before going public, protect the preview with a password or limit it to your team's accounts. Most hosts offer this as a one-click setting per deploy."}),e.jsx(R,{lead:"Keep previews out of search.",children:"A protected preview won't get indexed or unfurled. Turn protection on by default if the build shows anything you wouldn't want a crawler to find before launch day."})]}),e.jsx(Ye,{items:a}),e.jsx(de,{assistKey:"staging-preview",topicName:"Staging & preview deploys"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const C6=Object.freeze(Object.defineProperty({__proto__:null,StagingPreviewScreen:Ha},Symbol.toStringTag,{value:"Module"}));function Hh({onBack:t,onComplete:s,status:n,onRevert:r}){const a=[{q:"Why not just point staging at the production database?",a:"Because a staging environment exists to let you break things safely, and the fastest way to lose that is to share prod's data. A bad migration, a destructive test, or a runaway job on staging would then corrupt or leak real customer data. Staging gets its own database — ideally seeded from a sanitized copy of prod so it's realistic — and its own secrets, so nothing you do there can touch production."},{q:"What does staging actually catch that local doesn't?",a:"The things that only exist once you deploy: the real migration running against a populated database, environment variables and secrets resolved the production way, the actual platform's networking and timeouts, and the deploy pipeline itself. Local runs against a tiny dev database and your own machine's config — staging runs the same pipeline you'll run for prod, so a green deploy there is real evidence prod will be green too."},{q:"How do I get a build from staging to production?",a:"Promote the exact artifact you validated rather than rebuilding for prod. Run the migration on staging first, confirm the service is healthy, then promote that same build to production and run the same migration there. Because staging already rehearsed every step, the production deploy is a repeat of something that just worked — not a first attempt under pressure."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Le,{size:26}),title:"Staging environment",meta:"About 30 minutes · a one-time environment to stand up",onBack:t,assistKey:"staging-environment"}),e.jsx("p",{className:"lead",children:"A staging environment is a full, prod-like copy of your service you can deploy to and exercise before anything reaches real users. It runs the same pipeline as production but has its own data and secrets — so a deploy there is a rehearsal, not a gamble."}),e.jsx("div",{className:"seclabel",children:"Make it prod-like, but isolated"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Give staging its own database and secrets.",children:"Never point staging at production data. Stand up a separate database — ideally seeded from a sanitized copy of prod so it's realistic — and a separate set of secrets, so anything you break on staging can't touch a real customer."}),e.jsx(R,{lead:"Run the same deploy pipeline as production.",children:"Deploy to staging with the exact build and release steps you'll use for prod. The value is in the sameness: if the pipeline is green on staging, that's real evidence it'll be green on production."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Rehearse the risky parts"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Run schema migrations on staging first.",children:"A migration against a populated database is where deploys most often go wrong. Run it on staging — with prod-like data volume — and you find the slow lock or the bad backfill before it's holding up real traffic."}),e.jsx(R,{lead:"Spin up a per-branch environment when you need one.",children:"For a risky change, an ephemeral environment built just for that branch lets you test it in isolation and tear it down afterward — the backend analog of a per-branch preview deploy."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to production"}),e.jsx(ne,{children:e.jsx(R,{lead:"Ship the build you already validated.",children:"When staging is healthy, promote that same build to production rather than rebuilding. Run the migration on prod just as you rehearsed on staging — going live becomes a repeat of something that just worked."})}),e.jsx(Ye,{items:a}),e.jsx(de,{assistKey:"staging-environment",topicName:"Staging environment"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const P6=Object.freeze(Object.defineProperty({__proto__:null,StagingEnvironmentScreen:Hh},Symbol.toStringTag,{value:"Module"}));function Wa({onBack:t,onComplete:s,status:n,onRevert:r}){const a=[{q:"Will a pre-release accidentally become what everyone installs?",a:"Not if you publish it correctly. A plain install (`install pkg`) resolves the `latest` tag, and a pre-release is published under a different tag — `next` or `beta` — so it never moves `latest`. On top of that, a semver pre-release version like `1.2.0-rc.1` is excluded from normal version ranges by default, so a dependent on `^1.1.0` won't auto-adopt it. You have to opt in twice to get a pre-release, which is the whole point."},{q:"How does a tester actually get the pre-release?",a:"They opt in explicitly. For a package, that's installing the tag — `install pkg@next` — or pinning the exact pre-release version. For a binary, it's downloading the build attached to a GitHub pre-release rather than the latest stable release. Either way it's a deliberate choice, so the people on the pre-release channel are exactly the people who asked to test it."},{q:"How do I promote a pre-release to stable?",a:"When the pre-release has held up, cut the stable version (drop the `-rc.1` suffix, e.g. `1.2.0`) and publish it to `latest` — or mark the GitHub release as the latest, not a pre-release. Everyone on a normal install picks it up from there. The pre-release channel keeps running for the next round; promoting one build to stable doesn't shut it down."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Le,{size:26}),title:"Pre-release channel",meta:"About 15 minutes · then one extra command per pre-release",onBack:t,assistKey:"pre-release-channel"}),e.jsxs("p",{className:"lead",children:["A pre-release lets people test the next version before it's stable — without changing what everyone gets by default. You publish it on a separate channel, testers opt in, and your ",e.jsx("code",{children:"latest"})," stays exactly where it is until you're ready to promote."]}),e.jsx("div",{className:"seclabel",children:"Publish on a separate channel"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Use a next / beta tag instead of latest.",children:["Publish the pre-release under a dist-tag like ",e.jsx("code",{children:"next"})," or"," ",e.jsx("code",{children:"beta"})," (npm), a ",e.jsx("code",{children:"--pre"})," flag on other registries, or a GitHub ",e.jsx("b",{children:"pre-release"})," for binaries. A normal install still resolves ",e.jsx("code",{children:"latest"}),", so the default install is untouched."]}),e.jsxs(R,{lead:"Tag a semver pre-release version.",children:["Version it with a pre-release identifier — ",e.jsx("code",{children:"1.2.0-rc.1"}),","," ",e.jsx("code",{children:"1.2.0-beta.2"}),". Semver excludes these from ordinary version ranges, so a dependent on ",e.jsx("code",{children:"^1.1.0"})," won't pull it in by accident. It takes a deliberate opt-in to land on a pre-release."]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Let testers opt in"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Tell testers the one install command.",children:["A tester installs the channel explicitly — ",e.jsx("code",{children:"install pkg@next"})," ","— or downloads the build attached to the GitHub pre-release. The people on the channel are exactly the ones who asked to be there."]}),e.jsx(R,{lead:"Gather feedback before it's everyone's problem.",children:"Because the pre-release reaches only opt-in testers, a rough edge gets caught by people who expect a rough edge — not by your whole user base on a normal install."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to stable"}),e.jsx(ne,{children:e.jsxs(R,{lead:"Cut the stable version when it holds up.",children:["Drop the pre-release suffix (",e.jsx("code",{children:"1.2.0-rc.1"})," →"," ",e.jsx("code",{children:"1.2.0"}),") and publish it to ",e.jsx("code",{children:"latest"}),", or mark the GitHub release as latest. Everyone on a normal install picks it up — and the channel stays open for the next round."]})}),e.jsx(Ye,{items:a}),e.jsx(de,{assistKey:"pre-release-channel",topicName:"Pre-release channel"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const T6=Object.freeze(Object.defineProperty({__proto__:null,PreReleaseScreen:Wa},Symbol.toStringTag,{value:"Module"}));function me(t,s){return["You are helping inside my actual codeyam project — this is real work in a real repository, not a hypothetical.","Before doing anything, read `.codeyam/stack.json` and the relevant source and config files so your help fits this project's stack. Prefer concrete edits and commands over generic advice.","",`I want to set up **${t}**. ${s}`,"","Walk me through it and make the changes you safely can in my project, asking me before anything destructive."].join(`
10
- `)}const W_={"staging-preview":{Icon:Le,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:me("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:Lt,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:me("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:Re,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:me("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:Fs,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:me("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:Dt,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:me("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:ft,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:me("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:rt,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:me("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:Ae,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:me("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:Ae,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:me("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:Re,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:me("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:Re,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:me("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:Le,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:me("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:Lt,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:me("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:rt,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:me("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:Le,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:me("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:rt,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:me("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:ft,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:me("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:Lt,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:me("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:Re,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:me("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:xs,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:me("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:Le,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:me("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:xs,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:me("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:rt,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:me("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:Ae,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:me("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:rt,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:me("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:Ae,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:me("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:Ae,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:me("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:Ae,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:me("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:rt,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:me("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:Le,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:me("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:Is,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:me("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:Is,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:me("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:Re,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:me("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:Le,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:me("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:Le,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:me("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."}]}},G_={"real-data":Hu,accounts:eh,emails:sh,payments:ah,"analytics-monitoring":oh,legal:ih,"data-safety":mh,publish:hh,"custom-domain":ph,forms:fh,"analytics-seo":gh,"redirects-404":bh,"performance-images":xh,"comments-search":yh,"publish-registry":jh,"versioning-changelog":wh,"install-docs":_h,"release-builds":kh,"shell-completions":Sh,"cli-ux":Nh,"api-docs":Th,examples:Ph,"semver-policy":Oh,"readme-license":Rh,"supply-chain":Ch,"changelog-ci":Eh,"deploy-target":Mh,"database-backups":Ih,secrets:Fh,"api-auth":zh,"cors-origins":$h,"background-jobs":Bh,"logging-monitoring":qh,"staging-preview":Ha,"deploy-previews":Ha,"staging-environment":Hh,"pre-release-channel":Wa,"pre-release-versions":Wa};function Wh({onBack:t,topicKey:s,topicName:n,topicDesc:r}){const a=(n==null?void 0:n.trim())||"This setup step",o=(r==null?void 0:r.trim())||"There isn't a guided screen for this step here yet. You can still set it up — check the project's setup notes — and we'll add a walkthrough soon.";return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Pr,{size:26}),title:a,meta:"Guided screen coming soon",onBack:t,assistKey:s??""}),e.jsx("p",{className:"lead",children:o}),e.jsx("div",{className:"cta-wrap",children:e.jsx("button",{type:"button",className:"cta",onClick:t,children:"Back to Setup"})})]})}function Gh({topicKey:t,topicName:s,topicDesc:n,isBackend:r=!1,onBack:a,onComplete:o,onChatWithAI:i}){const c=W_[t];if(c)return e.jsx(Fo,{icon:e.jsx(c.Icon,{size:26}),title:c.title,crumbLabel:c.crumbLabel,meta:c.meta,assistKey:t,onBack:a,lead:c.lead,illustration:Go(t)??e.jsx(Gt,{nodes:c.journey}),chatPrompt:c.chatPrompt,onChatWithAI:i,faqs:c.faqs});const d=t==="api-docs"&&r?Ah:G_[t];return d?e.jsx(d,{onBack:a,onComplete:()=>o==null?void 0:o(t),onChatWithAI:i}):e.jsx(Wh,{onBack:a,topicKey:t,topicName:s,topicDesc:n})}const A6=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPlaceholder:Wh,SetupTopicRouter:Gh},Symbol.toStringTag,{value:"Module"}));function Uh({onBack:t}){const{concepts:s}=Du(),[n,r]=l.useState(""),[a,o]=l.useState(null),i=l.useMemo(()=>{const c=n.trim().toLowerCase();return!c||!s?s??[]:s.filter(d=>[d.term,d.category,...d.aka].join(" ").toLowerCase().includes(c))},[s,n]);return e.jsxs("div",{className:"learn-screen concepts-glossary",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"What these words mean"})]}),e.jsx("div",{className:"h",children:"What these words mean"}),e.jsx("div",{className:"hsub",children:"Plain-language explainers for the terms you'll run into while setting up your app. No jargon — just what each thing is, whether you need it, and what it costs."}),e.jsx("input",{type:"search",className:"concept-search",placeholder:"Search terms…",value:n,onChange:c=>r(c.target.value),"aria-label":"Search terms"}),e.jsx("div",{className:"tlist",children:s===null?Array.from({length:6}).map((c,d)=>e.jsx("div",{className:"trow soon","aria-hidden":"true",children:e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:" "}),e.jsx("div",{className:"td",children:" "})]})},d)):i.length===0?e.jsxs("div",{className:"concept-empty",children:['No terms match "',n,'".']}):i.map(c=>{const d=a===c.key;return e.jsxs("div",{className:"concept-row",children:[e.jsxs("button",{type:"button",className:"trow soon","aria-expanded":d,onClick:()=>o(d?null:c.key),children:[e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:c.term}),c.category?e.jsx("div",{className:"td",children:c.category}):null]}),e.jsx("span",{className:"arrow",children:d?"−":"+"})]}),d?e.jsx("div",{className:"concept-row-body",children:e.jsx($t,{variant:"compact",children:c.body})}):null]},c.key)})})]})}const O6=Object.freeze(Object.defineProperty({__proto__:null,ConceptsGlossaryScreen:Uh},Symbol.toStringTag,{value:"Module"})),De=({children:t})=>e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t}),kl={vercel:e.jsx(De,{children:e.jsx("path",{d:"M12 4l8 14H4z",fill:"currentColor",stroke:"none"})}),netlify:e.jsxs(De,{children:[e.jsx("path",{d:"M12 3l9 9-9 9-9-9z"}),e.jsx("path",{d:"M12 8v8M8 12h8"})]}),cloudflare:e.jsx(De,{children:e.jsx("path",{d:"M6 16h11a3 3 0 0 0 .3-6A5 5 0 0 0 8 9.2 4 4 0 0 0 6 16z"})}),fly:e.jsxs(De,{children:[e.jsx("circle",{cx:"12",cy:"10",r:"6"}),e.jsx("path",{d:"M9 15l-1 5 4-2 4 2-1-5"})]}),github:e.jsxs(De,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M9 20v-3c0-1 .5-1.6 1-2-2.3-.3-3.8-1.2-3.8-4a3 3 0 0 1 .8-2 2.8 2.8 0 0 1 .1-2s.8-.2 2.2.9a8 8 0 0 1 4 0c1.4-1.1 2.2-.9 2.2-.9a2.8 2.8 0 0 1 .1 2 3 3 0 0 1 .8 2c0 2.8-1.5 3.7-3.8 4 .5.4 1 1 1 2v3"})]}),anthropic:e.jsx(De,{children:e.jsx("path",{d:"M12 4v16M4 12h16M6.3 6.3l11.4 11.4M17.7 6.3L6.3 17.7"})}),neon:e.jsx(De,{children:e.jsx("path",{d:"M5 19V5l14 14V5"})}),stripe:e.jsx(De,{children:e.jsx("path",{d:"M6 8.5c0-1.4 1.5-2.5 3.5-2.5S13 6.8 13.4 8M6 15.5c0 1.4 1.5 2.5 3.5 2.5S13 17.2 13.4 16M9.5 6v12"})})},Sl={Domain:e.jsxs(De,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8.5"}),e.jsx("path",{d:"M3.5 12h17M12 3.5c2.5 2.3 2.5 14.7 0 17M12 3.5c-2.5 2.3-2.5 14.7 0 17"})]}),Hosting:e.jsxs(De,{children:[e.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"6",rx:"1.5"}),e.jsx("rect",{x:"3.5",y:"13.5",width:"17",height:"6",rx:"1.5"}),e.jsx("path",{d:"M7 7.5h.01M7 16.5h.01"})]}),Payments:e.jsxs(De,{children:[e.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),e.jsx("path",{d:"M3 9.5h18"})]}),Database:e.jsxs(De,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Database ORM":e.jsxs(De,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Backend platform":e.jsxs(De,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),Authentication:e.jsxs(De,{children:[e.jsx("circle",{cx:"9",cy:"9",r:"4"}),e.jsx("path",{d:"M12 12l7 7M16 16l2-2M18.5 13.5l1.5 1.5"})]}),"Transactional email":e.jsxs(De,{children:[e.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),e.jsx("path",{d:"M3.5 7l8.5 6 8.5-6"})]}),"Product analytics":e.jsxs(De,{children:[e.jsx("path",{d:"M4 20V4M4 20h16"}),e.jsx("path",{d:"M8 16v-3M12 16V8M16 16v-6"})]}),"Error monitoring":e.jsxs(De,{children:[e.jsx("path",{d:"M12 3l8 4v5c0 5-3.5 8-8 9-4.5-1-8-4-8-9V7z"}),e.jsx("path",{d:"M12 8.5v4M12 15.5h.01"})]})},U_={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)"}};function Yh(t){return t&&U_[t]||null}function Vh({providerId:t,category:s}){return t&&kl[t]?kl[t]:s&&Sl[s]?Sl[s]:null}const R6=Object.freeze(Object.defineProperty({__proto__:null,G:De,ProviderLogo:Vh,providerBrand:Yh},Symbol.toStringTag,{value:"Module"})),Nl=e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})}),Cl=e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),Y_=e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),V_=e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 3l18 18M10.6 10.6a3 3 0 0 0 4.2 4.2M9.9 5.2A9.6 9.6 0 0 1 12 5c6.5 0 10 7 10 7a15.4 15.4 0 0 1-3.3 4M6.2 6.2A15.5 15.5 0 0 0 2 12s3.5 7 10 7a9.7 9.7 0 0 0 3.1-.5"})});function K_(t){return t.length<=10?"•".repeat(Math.max(t.length,6)):`${t.slice(0,6)}••••••••••${t.slice(-4)}`}function Kh({apiKey:t}){const[s,n]=l.useState(!1);return e.jsxs("div",{className:"xsvc-detrow",children:[e.jsx("span",{className:"xsvc-detlabel",children:"API key"}),e.jsxs("button",{type:"button",className:"xsvc-keyval",onClick:()=>n(r=>!r),"aria-label":s?"Hide API key":"Reveal API key",title:s?"Click to hide":"Click to reveal",children:[e.jsx("span",{className:"mono",children:s?t:K_(t)}),e.jsx("span",{className:"eye","aria-hidden":"true",children:s?V_:Y_})]})]})}function Jh({svc:t,expanded:s,onToggle:n,onAction:r}){var i,c,d;const a=Vh({providerId:t.providerId,category:t.category}),o=Yh(t.providerId);return e.jsxs("div",{className:`xsvc-rowwrap${s?" open":""}`,children:[e.jsxs("div",{className:`xsvc-row${t.attn?" attn":""}`,role:"button",tabIndex:0,"aria-expanded":s,onClick:n,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),n())},children:[e.jsx("div",{className:`xsvc-tile t-${t.tone??"lime"}`,style:o?{background:o.bg,color:o.fg}:void 0,children:a??t.monogram??t.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"xsvc-rmain",children:[e.jsxs("div",{className:"xsvc-rname",children:[t.name,(i=t.tags)==null?void 0:i.map((u,h)=>e.jsx("span",{className:`xsvc-tag ${u.kind}`,children:u.text},h))]}),e.jsx("div",{className:"xsvc-rdesc",children:t.desc})]}),e.jsxs("div",{className:"xsvc-rright",children:[t.actionLabel?e.jsx("button",{type:"button",className:"xsvc-addkey",onClick:u=>{u.stopPropagation(),t.actionKey&&r&&r(t.actionKey)},children:t.actionLabel}):e.jsxs("div",{className:"xsvc-rmeta",children:[t.metaBig?e.jsx("div",{className:"big",children:t.metaBig}):null,t.metaLil?e.jsx("div",{className:"lil",children:t.metaLil}):null]}),e.jsx("span",{className:`xsvc-arr${s?" down":""}`,children:s?"▾":"→"})]})]}),s?e.jsxs("div",{className:"xsvc-detail",children:[(c=t.detail)==null?void 0:c.map((u,h)=>e.jsxs("div",{className:"xsvc-detrow",children:[e.jsx("span",{className:"xsvc-detlabel",children:u.label}),e.jsx("span",{className:`xsvc-detval${u.mono?" mono":""}`,children:u.value})]},h)),t.apiKey?e.jsx(Kh,{apiKey:t.apiKey}):null,!((d=t.detail)!=null&&d.length)&&!t.apiKey?e.jsx("div",{className:"xsvc-detrow",children:e.jsx("span",{className:"xsvc-detval",children:t.desc})}):null]}):null]})}function Xh({groups:t,summary:s,onBack:n,onOpenChat:r,onAction:a,defaultSort:o="type"}){const i=Array.isArray(t)&&t.some(g=>g.items.length>0),[c,d]=l.useState(o),[u,h]=l.useState(null),[p,f]=l.useState(""),m=g=>{g.preventDefault(),r==null||r(p.trim()||void 0),f("")},b=!i||c==="type"?(t??[]).filter(g=>g.items.length>0):[{label:"All providers",items:(t??[]).flatMap(g=>g.items).slice().sort((g,x)=>g.name.localeCompare(x.name))}];return e.jsxs("div",{className:"xsvc",children:[e.jsxs("div",{className:"xsvc-scroll",children:[e.jsx("div",{className:"xsvc-crumbs",children:e.jsx("button",{type:"button",className:"xsvc-back",onClick:n,"aria-label":"Back to Home",children:"‹ Home"})}),e.jsxs("div",{className:"xsvc-head",children:[e.jsxs("div",{className:"xsvc-titlerow",children:[e.jsx("h1",{children:"External Services"}),i?e.jsx("span",{className:"xsvc-count",children:s??"Every outside service, in one place."}):null]}),i?null:e.jsx("p",{className:"xsvc-sub",children:"Every outside service this project depends on: domains, API keys, and subscriptions, in one place."})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"xsvc-toolbar",children:[e.jsx("span",{className:"xsvc-sortlbl",children:"Sort by"}),e.jsxs("div",{className:"xsvc-seg",children:[e.jsx("button",{type:"button",className:c==="type"?"on":"",onClick:()=>d("type"),children:"Type"}),e.jsx("button",{type:"button",className:c==="provider"?"on":"",onClick:()=>d("provider"),children:"Provider"})]})]}),e.jsx("div",{className:"xsvc-groups",children:b.map(g=>e.jsxs("div",{className:"xsvc-group",children:[e.jsxs("div",{className:"xsvc-group-head",children:[e.jsx("span",{className:"xsvc-seclabel",children:g.label}),e.jsx("span",{className:"xsvc-seccount",children:g.items.length})]}),e.jsx("div",{className:"xsvc-rows",children:g.items.map((x,y)=>{const v=`${g.label}:${x.name}:${y}`;return e.jsx(Jh,{svc:x,expanded:u===v,onToggle:()=>h(j=>j===v?null:v),onAction:a},v)})})]},g.label))})]}):e.jsx("div",{className:"xsvc-empty-wrap",children:e.jsxs("div",{className:"xsvc-empty-card",children:[e.jsx("div",{className:"xsvc-empty-mark","aria-hidden":"true",children:e.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 3a9 9 0 1 0 9 9"}),e.jsx("path",{d:"M12 3v9l6 3"}),e.jsx("path",{d:"M16 4h5V9"})]})}),e.jsx("h2",{children:"No external services mapped yet"}),e.jsx("p",{children:"Tell the AI what this project relies on and it keeps everything organized: it tracks renewals, flags missing keys, and answers questions about your stack."}),e.jsxs("div",{className:"xsvc-chat-hero",children:[e.jsxs("div",{className:"xsvc-lead",children:[Cl,"Chat with the AI"]}),e.jsxs("form",{className:"xsvc-composer",onSubmit:m,children:[e.jsx("input",{className:"xsvc-cinput",type:"text",value:p,onChange:g=>f(g.target.value),placeholder:"e.g. We use Anthropic for the AI, Vercel for hosting, and our domain is codeyam.com"}),e.jsx("button",{type:"submit",className:"send","aria-label":"Send to the AI",children:Nl})]}),e.jsxs("div",{className:"xsvc-chips",children:[e.jsxs("button",{type:"button",className:"xsvc-chip",onClick:()=>r==null?void 0:r("Import my services from .env"),children:[e.jsx("span",{className:"g",children:"↳"}),"Import from .env"]}),e.jsxs("button",{type:"button",className:"xsvc-chip",onClick:()=>r==null?void 0:r("Scan package.json and Cargo.toml for services"),children:[e.jsx("span",{className:"g",children:"↳"}),"Scan package.json & Cargo.toml"]}),e.jsxs("button",{type:"button",className:"xsvc-chip",onClick:()=>r==null?void 0:r("Help me add a service manually"),children:[e.jsx("span",{className:"g",children:"↳"}),"Add one manually"]})]})]})]})})]}),i?e.jsxs("div",{className:"xsvc-bottombar",children:[e.jsx("div",{className:"xsvc-bb-sugg",children:["When does codeyam.com renew?","What's my monthly spend?","Anything missing a key?"].map(g=>e.jsx("button",{type:"button",className:"xsvc-chip",onClick:()=>r==null?void 0:r(g),children:g},g))}),e.jsxs("form",{className:"xsvc-bb-composer",onSubmit:m,children:[e.jsx("span",{className:"ai","aria-hidden":"true",children:Cl}),e.jsx("input",{className:"xsvc-cinput",type:"text",value:p,onChange:g=>f(g.target.value),placeholder:"Ask the AI about your domains, keys, subscriptions…"}),e.jsx("button",{type:"submit",className:"send","aria-label":"Send to the AI",children:Nl})]})]}):null]})}const E6=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:Kh,ExternalServicesScreen:Xh,ServiceRow:Jh},Symbol.toStringTag,{value:"Module"})),ln="your-app.vercel.app",J_=[{key:"connect",label:"Connect"},{key:"deploying",label:"Deploy"},{key:"live",label:"Go live"}];function si({onBack:t}){return e.jsx(oe,{icon:e.jsx(xs,{size:26}),title:"Hosting & going live",crumbLabel:"Hosting",meta:"Foundation · about 10 minutes",onBack:t,assistKey:"hosting"})}function Ls({stage:t}){return e.jsx(Mt,{steps:J_,currentKey:t})}const M6=Object.freeze(Object.defineProperty({__proto__:null,FlowBar:Ls,HSHeader:si,HS_URL:ln},Symbol.toStringTag,{value:"Module"}));function X_(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!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();n||s(a)}catch{n||s(null)}})(),()=>{n=!0}},[]),{target:t}}function Qh({onBack:t,onSetup:s}){const{target:n}=X_(),r=(n==null?void 0:n.detectedHost)??null;return e.jsxs(e.Fragment,{children:[e.jsx(si,{onBack:t}),e.jsxs("p",{className:"lead",children:["Right now your app only runs on ",e.jsx("b",{children:"your computer"}),". Hosting puts it online so anyone can open it with a link, like renting a small plot of land where your app lives."]}),e.jsx("p",{className:"lead dim",children:"You don't need to understand servers. We'll set it up for you and explain each step in plain language."}),e.jsx(Yc,{}),r&&e.jsxs("div",{className:"hosting-detected",role:"note",children:[e.jsxs("div",{className:"hosting-detected-title",children:["This project is already configured for ",e.jsx("b",{children:r.name})]}),e.jsxs("div",{className:"hosting-detected-detail",children:["We found ",e.jsx("code",{children:r.evidence})," in your project — let's use"," ",r.name,".",(n==null?void 0:n.buildCommand)&&e.jsxs(e.Fragment,{children:[" ","It builds with ",e.jsx("code",{children:n.buildCommand}),n.outputDir&&e.jsxs(e.Fragment,{children:[" ","into ",e.jsx("code",{children:n.outputDir})]}),"."]})]})]}),e.jsx("div",{className:"seclabel",children:r?"Or start fresh with our recommendation":"Recommended for your app"}),e.jsxs("div",{className:"provcard best",children:[e.jsx(vr,{}),e.jsxs("div",{className:"provbody",children:[e.jsxs("div",{className:"provtop",children:[e.jsx("span",{className:"provname",children:"Vercel"}),e.jsx("span",{className:"bestfit",children:"Best fit"})]}),e.jsx("div",{className:"provdesc",children:"Free to start, fast, and it works the way your app is already built. Most people in your spot pick this."}),e.jsx(Vc,{}),e.jsx(Kc,{})]})]}),e.jsx(Jc,{}),e.jsxs("div",{className:"cta-wrap",children:[e.jsxs("button",{type:"button",className:"cta",onClick:s,children:[e.jsx("span",{className:"ce",children:"☁️"})," Set up hosting with Vercel"]}),e.jsx("div",{className:"cta-note",children:"We'll walk you through every step. Nothing goes live until you say so."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),e.jsx(Xc,{}),e.jsx(Qc,{}),e.jsx(de,{assistKey:"hosting",topicName:"Hosting & going live"})]})}const I6=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewGuided:Qh},Symbol.toStringTag,{value:"Module"}));function Zh({onBack:t,onContinue:s,tokenMode:n=!1}){const[r,a]=l.useState("");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Connect Vercel"})]}),e.jsx(Ls,{stage:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:"🔗 Connect your Vercel account"}),e.jsx("div",{className:"psub",children:"This is a free account that holds your live app. If you don't have one yet, you'll make it in a few clicks, no setup required."}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(vr,{}),e.jsxs("div",{children:[e.jsx("div",{className:"cbt",children:"Sign in with Vercel"}),e.jsx("div",{className:"cbd",children:n?"Paste a Vercel access token to deploy your real app.":"We'll open Vercel in a new tab and bring you right back."})]})]}),n?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"real-token-label",htmlFor:"hosting-token",children:"Vercel access token"}),e.jsx("input",{id:"hosting-token",type:"password",className:"real-token-input",placeholder:"Paste your Vercel token",value:r,onChange:o=>a(o.target.value)}),e.jsxs("button",{type:"button",className:"auth-btn",disabled:r.trim().length===0,onClick:()=>s(r.trim()),children:[e.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})}),"Deploy with Vercel"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grant",children:[e.jsxs("div",{className:"grantrow",children:[e.jsx($e,{color:"var(--blue-300)"}),e.jsx("span",{children:"Create one project to hold your app"})]}),e.jsxs("div",{className:"grantrow",children:[e.jsx($e,{color:"var(--blue-300)"}),e.jsx("span",{children:"Publish updates when you choose to go live"})]}),e.jsxs("div",{className:"grantrow",children:[e.jsx($e,{color:"var(--blue-300)"}),e.jsx("span",{children:"Nothing else. We can't touch your other accounts or files"})]})]}),e.jsxs("button",{type:"button",className:"auth-btn",onClick:()=>s(),children:[e.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})}),"Continue with Vercel"]}),e.jsxs("div",{className:"auth-row",children:[e.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>s(),children:"I already have an account"}),e.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>s(),children:"Create one for me"})]})]})]}),e.jsx("div",{className:"reassure",children:"🔒 We only ask for what's needed to put this one app online. You can disconnect at any time from settings."})]})]})}const D6=Object.freeze(Object.defineProperty({__proto__:null,HostingConnectStep:Zh},Symbol.toStringTag,{value:"Module"})),Fn=["Packaging up your app","Uploading it to Vercel","Giving it a web address","Turning it on"],Pl=1100,Q_=700;function ep({onDone:t}){const[s,n]=l.useState(0),r=l.useRef(t);r.current=t,l.useEffect(()=>{const o=[];for(let i=1;i<=Fn.length;i++)o.push(setTimeout(()=>n(i),i*Pl));return o.push(setTimeout(()=>r.current(),Fn.length*Pl+Q_)),()=>o.forEach(clearTimeout)},[]);const a=Math.round(s/Fn.length*100);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(Ls,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),e.jsx("div",{className:"deploy-d",children:"This usually takes under a minute. You can keep working, we'll let you know."})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{style:{width:a+"%"}})}),e.jsx("div",{className:"dep-steps",children:Fn.map((o,i)=>e.jsxs("div",{className:"dep-step "+(i<s?"done":i===s?"active":"todo"),children:[e.jsx("div",{className:"dot",children:i<s?e.jsx($e,{size:12,color:"#0a0a0a"}):null}),e.jsx("div",{className:"sl",children:o})]},o))})]})]})}const L6=Object.freeze(Object.defineProperty({__proto__:null,HostingDeployStep:ep},Symbol.toStringTag,{value:"Module"})),Z_="hosting";function tp({provider:t,credential:s,onDone:n,onRetry:r}){const{stage:a,result:o,error:i,connect:c}=Uo(Z_,t),d=l.useRef(!1);l.useEffect(()=>{d.current||(d.current=!0,c(s))},[c,s]);const u=l.useRef(n);return u.current=n,l.useEffect(()=>{a==="ready"&&o&&u.current(o.value)},[a,o]),a==="error"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(Ls,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t put your app online"}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:r,children:"Try again"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(Ls,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?"Connecting to your hosting account…":"Building and publishing your app. This usually takes under a minute."})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const F6=Object.freeze(Object.defineProperty({__proto__:null,HostingRealDeployStep:tp},Symbol.toStringTag,{value:"Module"})),e1=1600;function sp(t){const[s,n]=l.useState(!1),r=l.useRef(null),a=l.useCallback(()=>{var o;try{(o=navigator.clipboard)==null||o.writeText(t)}catch{}n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),e1)},[t]);return{copied:s,copy:a}}function np({onFinish:t,liveUrl:s}){const n=s??ln,r=s??"https://"+ln,{copied:a,copy:o}=sp(r);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Live"})]}),e.jsx(Ls,{stage:"live"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:"Your app is live"}),e.jsx("div",{className:"lh-d",children:"Anyone with this link can open your app right now."})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"🌍"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:"Your link"}),e.jsx("div",{className:"uc-u",children:n})]}),e.jsxs("div",{className:"uc-actions",children:[e.jsx("button",{type:"button",className:"btn-copy",onClick:o,children:a?"✓ Copied":"Copy link"}),e.jsx("button",{type:"button",className:"btn-visit",disabled:!s,onClick:s?()=>window.open(s,"_blank","noopener"):void 0,children:"Visit →"})]})]}),e.jsxs("div",{className:"domain-row",children:[e.jsx("span",{className:"dre",children:"🏷️"}),e.jsxs("div",{children:[e.jsx("div",{className:"drt",children:"Want your own web address?"}),e.jsx("div",{className:"drd",children:"Connect a custom domain. Optional, and you can do it anytime."})]}),e.jsx("button",{type:"button",className:"drbtn",children:"Add a domain"})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx($e,{})," Hosting is now set up"]}),e.jsx("button",{type:"button",className:"lf-back",onClick:t,children:"Back to Setup"})]})]})]})}const z6=Object.freeze(Object.defineProperty({__proto__:null,HostingLiveStep:np},Symbol.toStringTag,{value:"Module"}));function rp({onBack:t,onRedeploy:s}){const{copied:n,copy:r}=sp("https://"+ln),[a,o]=l.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsx(si,{onBack:t}),e.jsxs("div",{className:"conn-card",children:[e.jsx(vr,{}),e.jsxs("div",{className:"conn-body",children:[e.jsxs("div",{className:"conn-top",children:[e.jsx("span",{className:"conn-name",children:"Connected to Vercel"}),e.jsxs("span",{className:"conn-live",children:[e.jsx("span",{className:"lbdot"}),"Live"]})]}),e.jsxs("div",{className:"conn-acct",children:["Account ",e.jsx("b",{children:"your-app"})," · connected today"]})]}),e.jsx("button",{type:"button",className:"conn-disc",children:"Disconnect"})]}),e.jsx("div",{className:"seclabel",children:"Your live app"}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"🌍"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:"Your link"}),e.jsx("div",{className:"uc-u",children:ln})]}),e.jsxs("div",{className:"uc-actions",children:[e.jsx("button",{type:"button",className:"btn-copy",onClick:r,children:n?"✓ Copied":"Copy link"}),e.jsx("button",{type:"button",className:"btn-visit",children:"Visit →"})]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:28},children:"Latest deploy"}),e.jsxs("div",{className:"dep-card",children:[e.jsxs("div",{className:"depc-row",children:[e.jsx("span",{className:"depc-dot"}),e.jsxs("div",{className:"depc-main",children:[e.jsx("div",{className:"depc-t",children:"Live · deployed 2 minutes ago"}),e.jsx("div",{className:"depc-d",children:"Built and published from your latest changes."})]}),e.jsx("button",{type:"button",className:"depc-btn",onClick:s,children:"Redeploy"})]}),e.jsxs("div",{className:"depc-toggle",children:[e.jsxs("div",{children:[e.jsx("div",{className:"depc-tt",children:"Publish changes automatically"}),e.jsx("div",{className:"depc-td",children:"When you make changes, we'll put them live for you. Turn this off to publish by hand."})]}),e.jsx("span",{className:"toggle"+(a?" on":""),onClick:()=>o(i=>!i),role:"switch","aria-checked":a,tabIndex:0,children:e.jsx("span",{})})]})]})]})}const $6=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewConnected:rp},Symbol.toStringTag,{value:"Module"}));function ap({direction:t="guided",onBack:s,onComplete:n,connector:r,onOpenSharedBrowser:a}){const[o,i]=l.useState("overview"),[c,d]=l.useState(""),[u,h]=l.useState(void 0),p=r!==void 0;let f;return o==="overview"?f=t==="connected"?e.jsx(rp,{onBack:s,onRedeploy:()=>i("deploying")}):e.jsx(Qh,{onBack:s,onSetup:()=>i("connect")}):o==="connect"?f=e.jsx(Zh,{onBack:()=>i("overview"),tokenMode:p,onContinue:m=>{p&&d(m??""),i("deploying")}}):o==="deploying"?f=p?e.jsx(tp,{provider:r.provider,credential:c,onDone:m=>{h(m),i(t==="connected"?"overview":"live")},onRetry:()=>i("connect")}):e.jsx(ep,{onDone:()=>i(t==="connected"?"overview":"live")}):f=e.jsx(np,{liveUrl:u,onFinish:()=>{n==null||n(),s()}}),e.jsxs("div",{className:"hosting-screen",children:[f,a&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[12px]",children:[e.jsx("button",{type:"button",className:"rounded px-3 py-1.5",style:{background:"var(--bg-card)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",cursor:"pointer"},onClick:a,children:"Open shared browser →"}),e.jsx("span",{style:{color:"var(--text-secondary)"},children:"Walk the hosting console together — you and the assistant both drive."})]})]})}const B6=Object.freeze(Object.defineProperty({__proto__:null,HostingScreen:ap},Symbol.toStringTag,{value:"Module"}));function op({recipe:t,onBack:s,onMarkDone:n,status:r,onRevert:a,copyWriter:o}){return e.jsxs("div",{className:"learn-screen run-locally-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:s,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:s,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Run it locally"})]}),e.jsx("div",{className:"h",children:"Run it locally"}),e.jsx("div",{className:"hsub",children:"Right now your app runs inside this editor's Live Preview. Running it on your own machine lets you debug with your own tools, show it offline, or hand it to a teammate. Here's how, for this exact project."}),t===null?e.jsx("div",{className:"rl-loading","aria-hidden":"true",children:"Loading run instructions…"}):e.jsxs("div",{className:"rl-sections",children:[t.prereqs.length>0&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Prerequisites"}),e.jsx("ul",{className:"rl-prereqs",children:t.prereqs.map(i=>e.jsxs("li",{className:"rl-prereq",children:[e.jsx("span",{className:"rl-prereq-label",children:i.label}),e.jsx("span",{className:"rl-prereq-detail",children:i.detail})]},i.label))})]}),t.install&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Install"}),e.jsx(sn,{command:t.install,writer:o})]}),e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:t.runLabel||"Run"}),e.jsx(sn,{command:t.run,writer:o})]}),t.loadSteps&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:t.loadSteps.label}),e.jsx("ol",{className:"rl-load-steps",children:t.loadSteps.steps.map(i=>e.jsx("li",{className:"rl-load-step",children:i},i))}),t.loadTarget&&e.jsxs("div",{className:"rl-load-target",children:[e.jsx("div",{className:"rl-load-target-label",children:t.loadTarget.label}),e.jsx(sn,{command:t.loadTarget.path,writer:o})]})]}),t.reachableAt&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Open it"}),e.jsxs("div",{className:"rl-reachable",children:["Once it's running, open"," ",e.jsx("a",{className:"rl-url",href:t.reachableAt,target:"_blank",rel:"noreferrer",children:t.reachableAt}),"."]})]}),t.notes.length>0&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Notes"}),e.jsx("ul",{className:"rl-notes",children:t.notes.map(i=>e.jsx("li",{className:"rl-note",children:i},i))})]}),e.jsx(de,{assistKey:"run-locally",topicName:"Run it locally"}),n&&e.jsx(he,{label:"Got it — mark as done",note:"You can revisit these steps anytime.",status:r,onComplete:()=>n(),onRevert:a,onBack:s})]})]})}const q6=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyScreen:op},Symbol.toStringTag,{value:"Module"}));function ip({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Re,{size:26}),title:"Store accounts",meta:"Foundation · about 15 minutes",onBack:t,assistKey:"store-accounts"}),e.jsxs("p",{className:"lead",children:["To publish your extension, you first register as a developer with the"," ",e.jsx("b",{children:"Chrome Web Store"}),". This is a one-time setup that gives you a dashboard for uploading, updating, and managing your listing."]}),e.jsx("p",{className:"lead dim",children:"It's not the same as a regular Google account upgrade — there's a one-time registration fee and a short profile to fill in."}),e.jsx(mt,{linkKey:"chrome.devConsole"}),e.jsx("div",{className:"seclabel",children:"What you'll do"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Pay the one-time developer fee.",children:["The Chrome Web Store charges a single"," ",e.jsx("b",{children:ce("chromeStore.fee").value})," registration fee per account — not per extension. There's no recurring cost. The registration guide walks through the exact steps."]}),e.jsx(R,{lead:"Complete your developer profile.",children:"A public display name and a contact email. The email is verified and used for store communications and review notices."}),e.jsx(R,{lead:"Verify your identity and payment profile.",children:"Paying the fee requires a verified Google payment profile, and you must verify your contact information (email, and sometimes a phone number) before you can publish. Do this early — an unverified account can't push a listing live."}),e.jsx(R,{lead:"Decide on a publisher identity.",children:"You can publish under your own name or a group publisher. Group publishers are worth it if a team will manage the listing."})]}),e.jsx(mt,{linkKey:"chrome.register",label:"Read the Chrome Web Store registration guide"}),e.jsx(jr,{}),e.jsx(de,{assistKey:"store-accounts",topicName:"Store accounts"}),e.jsx(he,{label:"I've registered my developer account",note:"You only need to do this once. The next steps reuse the same account.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const H6=Object.freeze(Object.defineProperty({__proto__:null,StoreAccountsScreen:ip},Symbol.toStringTag,{value:"Module"}));function lp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(rt,{size:26}),title:"Store assets",meta:"About 30 minutes · design time",onBack:t,assistKey:"extension-store-assets"}),e.jsxs("p",{className:"lead",children:["Your store listing needs a set of images at ",e.jsx("b",{children:"exact dimensions"}),". The store rejects assets that are the wrong size, so it's worth getting these right before you submit."]}),e.jsx("div",{className:"seclabel",children:"Required"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Store icon — 128×128 PNG.",children:"The icon shown in the store and in the user's toolbar. Use a transparent or solid background; avoid tiny text."}),e.jsx(R,{lead:"At least one screenshot — 1280×800 or 640×400.",children:"Show your extension in action. The first screenshot is the one most users actually look at, so lead with your strongest."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Recommended"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Small promo tile — 440×280.",children:"Shown in store listings and search results. A clean tile noticeably improves install rates."}),e.jsx(R,{lead:"Marquee promo tile — 1400×560.",children:"Only used if the store features your extension, but worth having ready."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"PNG or JPEG"}),e.jsx("span",{className:"chip",children:"No misleading imagery"}),e.jsx("span",{className:"chip",children:"Up to 5 screenshots"})]}),e.jsx(mt,{linkKey:"chrome.devConsole",label:"Upload assets in the developer dashboard"}),e.jsx(de,{assistKey:"extension-store-assets",topicName:"Store assets"}),e.jsx(he,{label:"My store assets are ready",note:"You can update assets later — a new upload doesn't restart the whole review.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const W6=Object.freeze(Object.defineProperty({__proto__:null,ExtensionAssetsScreen:lp},Symbol.toStringTag,{value:"Module"})),cp={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 cn(t){const s=t.trim();return s.includes("://")||s.startsWith("*")||s==="<all_urls>"}function t1(t){const s=t.trim();return s==="<all_urls>"?!0:cn(s)?s.replace(/^\*?:\/\//,"").split("/")[0]==="*":!1}function s1(t){const s=t.trim();return s==="<all_urls>"?"Run on every site the user visits. Only request this if your extension truly needs it — reviewers scrutinise it closely.":t1(s)?`Run on a very broad set of sites (${s}). Reviewers treat broad host access like <all_urls> — narrow it to the exact origins you need, or use activeTab instead.`:cn(s)?`Run only on the specific sites this pattern matches (${s}).`:cp[s]??"Explain, in one plain sentence, exactly what this permission lets your extension do for the user."}function n1(t){const s=t.trim();return cn(s)||s in cp}const r1=["storage","activeTab","scripting","https://api.example.com/*"];function Ga({perm:t}){return e.jsxs("div",{className:"reason",children:[e.jsx($e,{}),e.jsxs("span",{children:[e.jsx("b",{children:e.jsx("code",{children:t})})," ",s1(t),n1(t)?null:e.jsx("span",{className:"bestfit",style:{marginLeft:8},children:"needs your wording"})]})]},t)}function dp({permissions:t=r1,onBack:s,onComplete:n,status:r,onRevert:a}){const o=t.filter(cn),i=t.filter(c=>!cn(c));return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Re,{size:26}),title:"Permissions",meta:"About 20 minutes · often missed",onBack:s,assistKey:"permissions-justification"}),e.jsxs("p",{className:"lead",children:["The store asks you to justify ",e.jsx("b",{children:"every permission"})," your extension requests. A clear, honest reason for each one is the difference between a smooth review and a rejection."]}),e.jsxs("p",{className:"lead dim",children:["These are read from your ",e.jsx("code",{children:"manifest.json"}),". Review the suggested justification for each and tighten it to match what your extension actually does."]}),e.jsxs("div",{className:"asknote",style:{marginTop:4},children:[e.jsx("b",{children:"Single-purpose policy:"})," every permission must serve your extension's one stated purpose. Unrelated permissions get rejected even when each is individually justified — it's one of the top rejection causes."]}),e.jsx("div",{className:"seclabel",children:"API permissions you request"}),i.length===0?e.jsx("p",{className:"lead dim",children:"Your manifest requests no API permissions to justify here."}):e.jsx("div",{className:"reasons",children:i.map(c=>e.jsx(Ga,{perm:c},c))}),e.jsx("div",{className:"seclabel",children:"Host permissions"}),o.length===0?e.jsx("p",{className:"lead dim",children:"Your manifest requests no host permissions — the easiest possible review on this axis."}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"lead dim",children:["Host permissions are submitted in a ",e.jsx("b",{children:"separate field"})," on the dashboard and scrutinised the hardest — narrow them to the exact origins you need."]}),e.jsx("div",{className:"reasons",children:o.map(c=>e.jsx(Ga,{perm:c},c))})]}),t.length===0&&e.jsx("p",{className:"lead dim",children:"Your manifest requests no special permissions — there's nothing to justify. That's the easiest possible review."}),e.jsx("div",{className:"asknote",style:{marginTop:14},children:"Rule of thumb: if you can't explain why a permission helps the user, remove it. Fewer permissions means a faster review and more installs."}),e.jsx(mt,{linkKey:"chrome.devConsole",label:"Submit justifications in the developer dashboard"}),e.jsx(de,{assistKey:"permissions-justification",topicName:"Permissions"}),e.jsx(he,{label:"My permissions are justified",note:"Reviewers read these. Vague or copy-pasted reasons are the most common rejection.",status:r,onComplete:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const G6=Object.freeze(Object.defineProperty({__proto__:null,PermissionRow:Ga,PermissionsJustificationScreen:dp},Symbol.toStringTag,{value:"Module"}));function up({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"Privacy policy",meta:"About 20 minutes · disclosure required for every extension",onBack:t,assistKey:"privacy-policy"}),e.jsxs("p",{className:"lead",children:["A privacy policy at a public URL is required for any extension that accesses user data. Separately, ",e.jsx("b",{children:"every"})," extension must complete the data-use disclosure in the dashboard — even one that collects nothing has to declare that. Mismatches between the policy and the disclosure get flagged."]}),e.jsx("p",{className:"lead dim",children:`Even if you collect almost nothing, you still declare that — "we don't collect personal data" is a valid, common policy.`}),e.jsx("div",{className:"seclabel",children:'The "Privacy practices" tab'}),e.jsxs("p",{className:"lead dim",children:["The disclosure lives on the dashboard's ",e.jsx("b",{children:"Privacy practices"})," tab. You can't submit until you check its three mandatory certifications:"]}),e.jsxs(ne,{children:[e.jsx(R,{lead:"You don't sell or transfer data to third parties",children:"outside of approved use cases."}),e.jsx(R,{lead:"You don't use or transfer data for purposes unrelated",children:"to your extension's single purpose."}),e.jsx(R,{lead:"You don't use or transfer data to determine creditworthiness",children:"or for lending purposes."})]}),e.jsx("div",{className:"seclabel",children:"Your policy must cover"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"What you collect.",children:"List the categories of data — settings, content the user enters, usage analytics — in plain terms."}),e.jsx(R,{lead:"Why you collect it.",children:"Tie each category to a feature. The store cross-checks this against your permission justifications."}),e.jsx(R,{lead:"Where it goes.",children:"Whether data stays on the device, syncs to the user's account, or is sent to a server you run or a third party."}),e.jsx(R,{lead:"How users can reach you.",children:"A contact method for privacy questions or deletion requests."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Hosted at a public URL"}),e.jsx("span",{className:"chip",children:"Linked in the dashboard"}),e.jsx("span",{className:"chip",children:"Matches your data disclosure"})]}),e.jsx(de,{assistKey:"privacy-policy",topicName:"Privacy policy"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const U6=Object.freeze(Object.defineProperty({__proto__:null,ExtensionPrivacyPolicyScreen:up},Symbol.toStringTag,{value:"Module"}));function hp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Re,{size:26}),title:"OAuth & sign-in verification",meta:"Days to weeks · a separate review from the store listing",onBack:t,assistKey:"oauth-verification"}),e.jsxs("p",{className:"lead",children:["If your extension signs users in with Google, the OAuth"," ",e.jsx("b",{children:"consent screen"})," goes through its own verification — separate from, and slower than, the Chrome Web Store listing review. Plan for it early; it's the step that surprises people the week they hoped to launch."]}),e.jsx("p",{className:"lead dim",children:"This only applies if you request Google account access. Sign-in handled entirely by your own backend, or no sign-in at all, skips this gate completely."}),e.jsxs("div",{className:"asknote",style:{marginTop:4},children:[e.jsx("b",{children:"Two reviews, two timelines:"})," the store reviews your extension listing; Google separately reviews the ",e.jsx("b",{children:"OAuth consent screen"})," tied to your Cloud project. Approval on one is not approval on the other."]}),e.jsx("div",{className:"seclabel",children:"How long depends on the scopes you ask for"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Non-sensitive scopes (email, profile).",children:"Basic sign-in. No verification wait — your consent screen works for everyone as soon as you publish it."}),e.jsx(R,{lead:"Sensitive scopes (Gmail, Drive, Calendar).",children:"Require app verification. Expect a multi-day to multi-week review and a justification for why you need each scope."}),e.jsx(R,{lead:"Restricted scopes (full mailbox, all files).",children:"Pull in an annual third-party security assessment that can run weeks and cost real money. Avoid unless your product truly needs them."})]}),e.jsx("div",{className:"seclabel",children:"Before you submit for verification"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Request the narrowest scope that works.",children:"Drop from a restricted scope to a sensitive one, or a sensitive one to a non-sensitive one, wherever your feature allows — it's the single biggest lever on review time."}),e.jsx(R,{lead:"Verify your domain and publish a privacy policy.",children:"Verified ownership of every domain on the consent screen and a live policy URL are prerequisites — the same policy your listing needs."}),e.jsx(R,{lead:"Match scopes to your permission justifications.",children:"Reviewers cross-check the OAuth scopes against the case you make on the Permissions topic. Inconsistencies stall both reviews."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Separate from the store review"}),e.jsx("span",{className:"chip",children:"Sensitive scopes = verification"}),e.jsx("span",{className:"chip",children:"Restricted scopes = security assessment"})]}),e.jsx(mt,{linkKey:"google.oauthConsent"}),e.jsx(de,{assistKey:"oauth-verification",topicName:"OAuth & sign-in verification"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const Y6=Object.freeze(Object.defineProperty({__proto__:null,OAuthVerificationScreen:hp},Symbol.toStringTag,{value:"Module"}));function pp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Ae,{size:26}),title:"Single purpose & listing quality",meta:"About 30 minutes · two of the top rejection causes",onBack:t,assistKey:"single-purpose-listing"}),e.jsxs("p",{className:"lead",children:["Every extension must have a ",e.jsx("b",{children:"single, narrow purpose"}),", and your listing has to describe it clearly. Bundling unrelated features, or a vague/keyword-stuffed listing, are among the most common reasons a submission gets rejected — both before you ever reach a human reviewer and during manual review."]}),e.jsx("p",{className:"lead dim",children:"Write your one-sentence purpose first. Everything else — permissions, the description, the category — should follow from it."}),e.jsx("div",{className:"seclabel",children:"The single-purpose policy"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"One narrow purpose, stated in a sentence.",children:`"Save articles to read later," not "a toolkit for productivity." If you can't say it in one sentence, it's probably two extensions.`}),e.jsx(R,{lead:"No unrelated functionality.",children:"A second, tangential feature — even a useful one — gets the whole extension rejected. Ship it separately if it doesn't serve the one purpose."}),e.jsx(R,{lead:"Permissions trace back to that purpose.",children:"Every permission you request should obviously serve the stated purpose, which is exactly what the Permissions topic asks you to justify."})]}),e.jsx("div",{className:"seclabel",children:"Listing quality"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"A description that says what it does, not what it's like.",children:"Lead with the purpose and the concrete value. Reviewers and users both bounce off generic marketing copy."}),e.jsx(R,{lead:"The right category.",children:"Pick the category that matches the purpose. A mismatched category is a flag and hurts discovery."}),e.jsx(R,{lead:"No keyword stuffing or misleading claims.",children:`Repeated keywords in the title/description, fake "official" branding, or features you don't actually have are explicit policy violations.`})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"One sentence, one purpose"}),e.jsx("span",{className:"chip",children:"Description matches behavior"}),e.jsx("span",{className:"chip",children:"Honest title & category"})]}),e.jsx(mt,{linkKey:"chrome.devConsole",label:"Edit the listing description in the developer dashboard"}),e.jsx(de,{assistKey:"single-purpose-listing",topicName:"Single purpose & listing quality"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const V6=Object.freeze(Object.defineProperty({__proto__:null,SinglePurposeListingScreen:pp},Symbol.toStringTag,{value:"Module"}));function mp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(rt,{size:26}),title:"Manifest & versioning",meta:"About 15 minutes · enforced before review even starts",onBack:t,assistKey:"manifest-versioning"}),e.jsxs("p",{className:"lead",children:["Your ",e.jsx("code",{children:"manifest.json"})," has to satisfy a few hard rules before the store will accept an upload at all — these checks run"," ",e.jsx("b",{children:"before"})," any human review. Getting them right means your Submit step goes through on the first try instead of bouncing."]}),e.jsx("p",{className:"lead dim",children:"These are mechanical, not judgment calls — but each one rejects the upload outright, with an error that isn't always obvious."}),e.jsx("div",{className:"seclabel",children:"The rules the store enforces"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Manifest V3 is required.",children:[e.jsx("code",{children:'"manifest_version": 3'}),". V2 is no longer accepted for new uploads — a service worker replaces the old background page, and blocking ",e.jsx("code",{children:"webRequest"})," is gone."]}),e.jsxs(R,{lead:"The version must strictly increase on every upload.",children:["Bump ",e.jsx("code",{children:"version"})," for each upload — the store rejects a re-used or lower number. This is the most common upload failure: forgetting to bump after a fix."]}),e.jsxs(R,{lead:"Use a valid version format.",children:["One to four dot-separated integers (e.g. ",e.jsx("code",{children:"1.2.0"}),"). Each part is compared numerically, so ",e.jsx("code",{children:"1.10"})," is newer than"," ",e.jsx("code",{children:"1.9"}),"."]})]}),e.jsx("div",{className:"seclabel",children:"Worth setting deliberately"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"minimum_chrome_version.",children:"Set it to the oldest Chrome you actually support. The store won't offer the extension to older browsers — sparing those users a version that would break for them."}),e.jsxs(R,{lead:"Keep name, description, and icons in sync.",children:["The manifest's ",e.jsx("code",{children:"name"}),"/",e.jsx("code",{children:"description"})," seed your listing, and the icon set here is what the store and toolbar render."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"manifest_version: 3"}),e.jsx("span",{className:"chip",children:"version strictly increases"}),e.jsx("span",{className:"chip",children:"minimum_chrome_version set"})]}),e.jsx(de,{assistKey:"manifest-versioning",topicName:"Manifest & versioning"}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const K6=Object.freeze(Object.defineProperty({__proto__:null,ManifestVersioningScreen:mp},Symbol.toStringTag,{value:"Module"}));function fp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Le,{size:26}),title:"Submit for review",meta:"About 15 minutes · then a review wait",onBack:t,assistKey:"submit-review"}),e.jsx("p",{className:"lead",children:"Last step: package your extension, upload it, and submit for review. Once you submit, the Chrome Web Store checks your listing against its policies before it goes public."}),e.jsx("div",{className:"seclabel",children:"Packaging & submitting"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Build and zip the extension.",children:"Produce your production build and zip its folder — the zip is what you upload, not the source repository."}),e.jsxs(R,{lead:"Put manifest.json at the zip root.",children:["The ",e.jsx("code",{children:"manifest.json"})," must sit at the top level of the zip, not inside a nested folder. Zipping the parent directory instead of its contents is a top first-upload failure."]}),e.jsx(R,{lead:"Upload and fill in the listing.",children:"Drop the zip into the dashboard, then complete the description, category, assets, and the data-use disclosure."}),e.jsx(R,{lead:"Choose visibility and rollout.",children:"At submit time you pick the distribution — public, unlisted, or private — and can stage a percentage rollout to release gradually."}),e.jsx(R,{lead:"Submit for review.",children:"Once everything validates, submit. You can't edit a submission while it's under review — but you can keep developing and submit a new version, and a rejection doesn't lose your draft."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"What to expect"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Timelines vary — hours to weeks.",children:"Many reviews clear in hours to a few days, but a new publisher account, broad host permissions, remote code, or OAuth scopes can push it to weeks. Plan for the longer end if any of those apply."}),e.jsx(R,{lead:"Rejections come with a reason.",children:"If it's rejected, the store says why. The usual culprits are permission justifications and the privacy policy — both covered in the earlier steps."})]}),e.jsx(mt,{linkKey:"chrome.devConsole",label:"Upload and submit in the developer dashboard"}),e.jsx(jr,{}),e.jsx(de,{assistKey:"submit-review",topicName:"Submit for review"}),e.jsx(he,{label:"I've submitted for review",note:"Once approved, your store listing link is what you share to install the extension.",status:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const J6=Object.freeze(Object.defineProperty({__proto__:null,SubmitReviewScreen:fp},Symbol.toStringTag,{value:"Module"})),a1=[{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 ${ce("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 ${ce("chromeStore.fee").value} developer account if you want the unlisted-listing path (link-shareable, auto-updating, and trusted by Chrome).`}];function gp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{icon:e.jsx(Le,{size:26}),title:"Share with testers",meta:"About 10 minutes · no public listing",onBack:t,assistKey:"share-testing"}),e.jsx("p",{className:"lead",children:"Want a few people to try your extension before it's public? You don't have to go through the Chrome Web Store review. There are three ways to hand a build to testers — from a zip you email today, to a private store listing that auto-updates, to a self-hosted package for managed fleets. Pick by how many testers you have and whether they need updates."}),e.jsx("div",{className:"seclabel",children:"Load unpacked (zip handoff)"}),e.jsxs(ne,{children:[e.jsx(R,{lead:"Build, zip, and send it.",children:"Produce your production build and zip the output folder. Each tester opens the browser's extensions page, enables Developer mode, and chooses “Load unpacked” on the unzipped folder. No account, no review — it works the moment they load it."}),e.jsxs(R,{lead:"Put manifest.json at the zip root.",children:["The ",e.jsx("code",{children:"manifest.json"})," must sit at the top level of the unzipped folder, not inside a nested directory — the same gotcha that trips up store uploads."]}),e.jsxs(R,{lead:"Know the trade-offs.",children:["There is ",e.jsx("b",{children:"no auto-update"})," — to ship a fix you re-send the zip and testers reload it. Chrome also shows a persistent “disable developer-mode extensions” warning, which can confuse non-technical testers. Best for a handful of trusted people on a short loop."]})]}),e.jsx(Zt,{assistKey:"share-testing",topicName:"Share with testers",goalId:"zip-load-unpacked",buttonLabel:'Ask AI to help with the "Load Unpacked (Zip Handoff)" goal'}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Unlisted / private Web Store listing"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Upload to the store, but hide it.",children:["You still upload to the Chrome Web Store, but set visibility to"," ",e.jsx("b",{children:"Unlisted"})," (link-shareable, not discoverable in search) or"," ",e.jsx("b",{children:"Private"})," (restricted to named testers). Anyone with the link installs in one click — no Developer mode, no warning."]}),e.jsx(R,{lead:"It auto-updates and is trusted by Chrome.",children:"Push a new version and the store delivers it to every tester automatically. Because it's a real store install, Chrome trusts it — none of the unpacked-build friction."}),e.jsxs(R,{lead:"It still needs the one-time developer account.",children:["An unlisted listing requires the same"," ",e.jsx("b",{children:ce("chromeStore.fee").value})," developer registration as a public one (see the ",e.jsx("b",{children:"Store accounts"})," topic). An unlisted listing also still goes through review — it just isn't publicly discoverable once approved."]})]}),e.jsx(mt,{linkKey:"chrome.devConsole",label:"Upload an unlisted build in the developer dashboard"}),e.jsx(Zt,{assistKey:"share-testing",topicName:"Share with testers",goalId:"unlisted-listing",buttonLabel:'Ask AI to help with the "Unlisted / Private Web Store Listing" goal'}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Self-hosted .crx + update_url (advanced)"}),e.jsxs(ne,{children:[e.jsxs(R,{lead:"Host the packed .crx and an update manifest.",children:["Pack the extension to a ",e.jsx("code",{children:".crx"}),", host it alongside an update manifest, and point the manifest's ",e.jsx("code",{children:"update_url"})," at it. This is the only path that needs no store account at all."]}),e.jsxs(R,{lead:"Chrome blocks off-store .crx for ordinary users.",children:["For a normal browser profile, Chrome refuses to install an off-store",e.jsx("code",{children:".crx"}),". This path really exists for"," ",e.jsx("b",{children:"managed / enterprise"})," force-install via admin policy (e.g. a company's device management) — not for casual beta testers."]})]}),e.jsx(Zt,{assistKey:"share-testing",topicName:"Share with testers",goalId:"self-host-crx",buttonLabel:'Ask AI to help with the "Self-Hosted .crx + update_url (Advanced)" goal'}),e.jsx(Ye,{items:a1}),e.jsx(jr,{}),e.jsx(he,{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:n,onComplete:()=>s==null?void 0:s(),onRevert:r,onBack:t})]})}const X6=Object.freeze(Object.defineProperty({__proto__:null,ExtensionDistributionScreen:gp},Symbol.toStringTag,{value:"Module"}));function ts({tone:t="cost",title:s,children:n}){const r=t==="wait"?"⏳":t==="size"?"⬇":"$";return e.jsxs("div",{className:"sd-callout "+t,children:[e.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:r}),e.jsxs("div",{children:[e.jsx("div",{className:"sd-callout-t",children:s}),e.jsx("div",{className:"sd-callout-b",children:n})]})]})}function lt({store:t,badge:s,enrollUrl:n,enrollLabel:r,children:a}){const o=t==="ios"?"Apple App Store":"Google Play",i=t==="ios"?"":"▶";return e.jsxs("div",{className:"sd-store "+t,children:[e.jsx("div",{className:"sd-store-mark","aria-hidden":"true",children:i}),e.jsxs("div",{className:"sd-store-body",children:[e.jsxs("div",{className:"sd-store-top",children:[e.jsx("span",{className:"sd-store-name",children:o}),e.jsx("span",{className:"sd-store-badge",children:s})]}),e.jsx("div",{className:"sd-store-desc",children:a}),n&&e.jsx("a",{className:"sd-store-enroll",href:n,target:"_blank",rel:"noreferrer noopener",children:r??"Enrol →"})]})]})}function rs({items:t}){return e.jsx("div",{className:"sd-checks",children:t.map((s,n)=>e.jsxs("div",{className:"sd-check",children:[e.jsx($e,{}),e.jsx("span",{children:s})]},n))})}const Q6=Object.freeze(Object.defineProperty({__proto__:null,CheckList:rs,CostCallout:ts,StoreCard:lt},Symbol.toStringTag,{value:"Module"}));function ks(t){return t==="ios"||t==="both"}function $s(t){return t==="android"||t==="both"}const Tl=["swift","swiftui","ios","uikit"],Al=["kotlin","android","jetpack-compose"];function Ol(t,s){return t&&!s?"ios":s&&!t?"android":null}function o1(t){if(!t)return"both";const s=t.platforms;if(Array.isArray(s)){const a=s.some(i=>String(i).toLowerCase().includes("ios")),o=s.some(i=>String(i).toLowerCase().includes("android"));if(a&&!o)return"ios";if(o&&!a)return"android";if(a||o)return"both"}const n=String(t.framework??"").toLowerCase();if(n){const a=Ol(Tl.some(o=>n.includes(o)),Al.some(o=>n.includes(o)));if(a)return a}const r=String(t.id??"").toLowerCase().split("-");if(r.some(Boolean)){const a=Ol(Tl.some(o=>r.includes(o)),Al.some(o=>r.includes(o)));if(a)return a}return"both"}function bp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=ks(t),i=$s(t),c=[{q:"Do I really have to pay before I can ship?",a:"Yes — there's no free tier for publishing to the stores. Apple charges $99/year and Google a one-time $25. You can build and test for free; the fee is the gate to actually listing the app."},{q:"How long does verification take?",a:"Anywhere from a few hours to several days for identity checks. The slow part is organisation/business verification — and if you need a brand-new D-U-N-S number for Apple, that alone can take up to ~2 weeks. Start it well before your planned launch."},{q:"Why is my Play account stuck in closed testing?",a:"Personal Google Play accounts created after 2023-11-13 must run a closed test with at least 12 testers opted in for 14 continuous days before they can request production access. If your tester count drops below 12, the 14-day clock resets. Organisation accounts are generally not subject to this."},{q:"Do I need a Mac to ship an iOS app?",a:"Practically, yes — building, signing, and uploading an iOS build needs Xcode, which only runs on macOS. You can write the code anywhere, but the final build and submission step expects a Mac (or a cloud Mac/CI service)."},{q:"Can I publish to just one store first?",a:"Absolutely. Many teams ship to one platform to start. Enrol only in the account you need now — you can add the other later without redoing anything."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(Re,{size:26}),title:"Developer accounts",meta:"One-time setup · paid · about 20 minutes",assistKey:"dev-accounts"}),e.jsx("p",{className:"lead",children:"Before an app can reach the stores, you have to enrol as a developer with each company you ship to. This is the account that owns your app, signs your builds, and gets paid out — so it's worth doing carefully and once."}),e.jsxs(ts,{tone:"cost",title:"These accounts cost money up front",children:["Plan for this before you start — there's no free tier for publishing.",o&&i?" Together that's $99 the first year plus a one-time $25.":""]}),e.jsx("div",{className:"seclabel",children:"What to set up"}),o?e.jsxs(lt,{store:"ios",badge:ce("appleDeveloper.fee").value,enrollUrl:"https://developer.apple.com/programs/enroll/",enrollLabel:"Enrol in the Apple Developer Program →",children:["Enrol in the ",e.jsx("b",{children:"Apple Developer Program"})," at developer.apple.com. The membership renews yearly; let it lapse and your apps are pulled from sale. Enrolling as an organisation needs a D-U-N-S number — if you don't already have one, issuance can take ",e.jsx("b",{children:"up to ~2 weeks"}),", so start this well before your planned launch."]}):null,i?e.jsxs(lt,{store:"android",badge:ce("googlePlay.fee").value,enrollUrl:"https://play.google.com/console/signup",enrollLabel:"Open Google Play Console signup →",children:["Register for the ",e.jsx("b",{children:"Google Play Console"})," at play.google.com/console. The fee is one-time, not yearly. ",ce("playStore.closedTestGate").value," ","— and if your tester count drops below 12, the 14-day clock resets. Organisation accounts are generally not subject to this gate. Factor the closed-test window into your timeline."]}):null,e.jsx(ts,{tone:"wait",title:"Verification isn't instant",children:"Identity and (for organisations) business verification can take anywhere from a few hours to several days. Get this out of the way before you're ready to ship, not the night before."}),e.jsx(Ye,{items:c}),e.jsx(de,{assistKey:"dev-accounts",topicName:"Developer accounts"}),e.jsx(he,{label:"Mark developer accounts as set up",note:"Do this once you've enrolled and your account is verified.",status:r,onComplete:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const Z6=Object.freeze(Object.defineProperty({__proto__:null,DevAccountsScreen:bp},Symbol.toStringTag,{value:"Module"}));function xp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=ks(t),i=$s(t),c=[{q:"Do my screenshots have to be the exact pixel sizes?",a:"For the required sets, yes — App Store Connect rejects the wrong dimensions. Capture on the 6.9″ iPhone simulator (1320×2868) and Apple scales that master down for the smaller phones; the older 6.7″/6.5″ sizes are still accepted if that's all you have."},{q:"Why does my Google Play listing keep getting rejected?",a:"The most common cause is a missing feature graphic (1024×500) — it's mandatory and easy to forget — or placeholder/lorem-ipsum screens. Make sure the 512×512 icon, the feature graphic, and at least two real phone screenshots are all uploaded."},{q:"Do I need separate icons for each store?",a:"Yes, at different sizes: a 1024×1024 master for the App Store and a 512×512 icon for Google Play. Both must be square PNGs with no transparency and no pre-rounded corners — the stores round them for you."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(rt,{size:26}),title:"Store assets",meta:"Design work · about 1–2 hours",assistKey:"store-assets"}),e.jsx("p",{className:"lead",children:"Every store listing needs artwork: a high-resolution app icon, a set of screenshots, and some promo imagery. The stores reject submissions with the wrong sizes or placeholder art, so it's worth getting these right before you submit."}),e.jsx("div",{className:"seclabel",children:"The essentials, everywhere"}),e.jsx(rs,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"App icon"})," — a square PNG with no transparency and no rounded corners (the stores round them for you). Apple wants a 1024×1024 master; Google Play wants a 512×512 icon — export both, not one size everywhere."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Screenshots"})," — captured on the exact device sizes each store asks for, not scaled-up phone shots."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"No placeholder art"}),' — "lorem ipsum" screens and stock icons are the most common rejection reason.']})]}),e.jsx("div",{className:"seclabel",children:"Per store"}),o?e.jsxs(lt,{store:"ios",badge:ce("appleScreenshots.iphone").value,children:["The App Store's primary iPhone set is now the ",e.jsx("b",{children:"6.9″ (1320×2868)"})," ","size — capture on that simulator and Apple scales the master down for smaller phones. The older 6.7″/6.5″ sizes (1290×2796, 1242×2688) are still accepted as a fallback. If your app supports iPad, also provide the ",ce("appleScreenshots.ipad").value," master. App previews (short videos) are optional but help conversion."]}):null,i?e.jsxs(lt,{store:"android",badge:"512×512 icon + feature graphic",children:["Google Play needs a ",e.jsx("b",{children:"512×512"})," icon (not the 1024×1024 iOS master), a 1024×500 ",e.jsx("b",{children:"feature graphic"})," (the banner at the top of your listing — easy to forget), and at least two phone screenshots. The feature graphic is mandatory; the listing won't publish without it."]}):null,e.jsx(Ye,{items:c}),e.jsx(de,{assistKey:"store-assets",topicName:"Store assets"}),e.jsx(he,{label:"Mark store assets as ready",note:"Do this once your icon and screenshots are exported at the right sizes.",status:r,onComplete:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const eR=Object.freeze(Object.defineProperty({__proto__:null,StoreAssetsScreen:xp},Symbol.toStringTag,{value:"Module"}));function yp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=ks(t),i=$s(t);return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(Ae,{size:26}),title:"Store listing",meta:"Writing + forms · about 45 minutes",assistKey:"store-listing"}),e.jsx("p",{className:"lead",children:"The listing is how people decide whether to install. It's your title and subtitle, the description, a category, and a keyword set — plus the privacy disclosures the stores now require. The writing sells; the privacy form is a hard gate."}),e.jsx("div",{className:"seclabel",children:"Write these"}),e.jsx(rs,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Title & subtitle"})," — clear over clever. The first few words are what shows in search results."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Description"})," — lead with what the app does and who it's for; keep the keyword-stuffing out, both stores penalise it."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Category"})," — pick the one your app actually fits; it affects where you rank."]})]}),e.jsx("div",{className:"seclabel",children:"Privacy is required now"}),o?e.jsxs(lt,{store:"ios",badge:"Nutrition labels",children:["Apple's ",e.jsx("b",{children:'privacy "nutrition labels"'})," ask you to declare exactly what data your app collects and how it's used. You fill these in App Store Connect; they show on your listing. Misdeclaring is grounds for removal, so answer them honestly."]}):null,i?e.jsxs(lt,{store:"android",badge:"Data safety form",children:["Google Play's ",e.jsx("b",{children:"Data safety"})," form covers the same ground — collection, sharing, and security practices. It's mandatory; the listing can't go live until it's complete and consistent with what your app actually does."]}):null,e.jsx(de,{assistKey:"store-listing",topicName:"Store listing"}),e.jsx(he,{label:"Mark store listing as drafted",note:"Do this once your copy is written and the privacy form is filled in.",status:r,onComplete:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const tR=Object.freeze(Object.defineProperty({__proto__:null,StoreListingScreen:yp},Symbol.toStringTag,{value:"Module"}));function vp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=ks(t),i=$s(t),c=[{q:"How long does the first store review really take?",a:"Once you're set up, per-update reviews are fast — Apple usually within a day, Google often within hours. The slow one is a new Google Play account's first production-access approval, which can take ~7 days on top of the closed-testing gate. Plan your launch date around that first approval, not the steady-state speed."},{q:"Why is my Play app stuck before I can go to production?",a:ce("playStore.closedTestGate").value+" — and the 14-day clock resets if the tester count drops below 12. Organisation accounts are generally not subject to this gate."},{q:"How many testers can I have?",a:"On TestFlight, up to 100 internal testers (your team) and up to 10,000 external testers. On Google Play, internal testing is a small email list, while closed/open tracks scale much larger."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(Le,{size:26}),title:"Testing & distribution",meta:"Build + review · hours to days",assistKey:"testing-distribution"}),e.jsx("p",{className:"lead",children:"Before you release to everyone, you put a build in front of a small group of testers, then submit that build for the store's review. Both steps use the store's own tooling — you don't email APKs around."}),e.jsxs(ts,{tone:"size",title:"First native build pulls a large SDK",children:["Producing a real device build downloads the platform toolchain — often",e.jsx("b",{children:" 8–12 GB"})," and ",e.jsx("b",{children:"10–30 minutes"})," the first time. Run the iOS pre-flight checks in ",e.jsx("code",{children:"MOBILE_SETUP.md"})," before you kick it off so a missing platform SDK surfaces in seconds, not ten minutes in."]}),e.jsx("div",{className:"seclabel",children:"Get a build to testers"}),o?e.jsxs(e.Fragment,{children:[e.jsxs(lt,{store:"ios",badge:"TestFlight",children:["Upload to ",e.jsx("b",{children:"TestFlight"})," from Xcode or your CI. Internal testers (up to 100 on your team) get builds instantly; ",e.jsx("b",{children:"external testers go up to 10,000"}),` and go through a lighter "beta" review first. This is also how you sanity-check the exact binary you'll submit.`]}),e.jsx(Zt,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-testflight",buttonLabel:"Ask AI to help: Prep a TestFlight upload"})]}):null,i?e.jsxs(e.Fragment,{children:[e.jsxs(lt,{store:"android",badge:"Internal testing",children:["Use a Play Console ",e.jsx("b",{children:"internal testing"})," track for instant distribution to a list of tester emails. Promote the same build up through closed → open → production tracks as your confidence grows. Note the production gate: ",ce("playStore.closedTestGate").value," ","(the 14-day clock resets below 12). Organisation accounts are generally not subject to this."]}),e.jsx(Zt,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-play-internal",buttonLabel:"Ask AI to help: Set up Play internal testing"})]}):null,e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Get ready for store review"}),e.jsx("p",{className:"lead",children:"Before you submit, run a pre-review pass across the stores you target: your privacy / data-safety answers match what the code actually does, the required usage-description strings are present, no debug or placeholder content ships, and deep links and permissions really work. Submitting a clean build is the fastest way through review."}),e.jsxs(ts,{tone:"wait",title:"Review takes real time",children:["Store review is a human process. Once you're established, per-update reviews are quick — Apple typically within a day, Google often within hours. The slow one is a ",e.jsx("b",{children:"new Google Play account's first production-access approval (~7 days)"}),", separate from and on top of the closed-testing gate. Build that first approval into your launch date — you can't rush it."]}),e.jsx(Zt,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-store-review",buttonLabel:"Ask AI to help: Get ready for store review"}),e.jsx(Ye,{items:c}),e.jsx(he,{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:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const sR=Object.freeze(Object.defineProperty({__proto__:null,TestingDistributionScreen:vp},Symbol.toStringTag,{value:"Module"}));function jp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=ks(t),i=$s(t),c=[{q:"Can I test push on the iOS simulator?",a:"Partly. Xcode 14+/macOS 13+ simulators can receive a payload you drag onto them, but real end-to-end APNs delivery is unreliable on the simulator. Verify real delivery on a physical device before you rely on it."},{q:"Why aren't my notifications showing up?",a:"The most common reason is that the user never granted permission — on iOS notifications are off until they explicitly opt in, and Android 13+ also needs a runtime permission prompt. Check the permission state first, then your APNs key / FCM token wiring."},{q:"Do I have to add push before I launch?",a:"No — push is optional. If your app doesn't need to reach people while it's closed, skip it. You can add APNs/FCM later without resubmitting the rest of your setup."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(Wo,{size:26}),title:"Push notifications",meta:"Optional · about 1 hour",assistKey:"push-notifications"}),e.jsx("p",{className:"lead",children:"Push lets your app reach people when it's closed. Each platform has its own delivery service you register with — you don't send notifications directly, you hand them to Apple or Google to deliver."}),e.jsx("div",{className:"seclabel",children:"The delivery services"}),o?e.jsxs(lt,{store:"ios",badge:"APNs",children:["Apple's ",e.jsx("b",{children:"Push Notification service (APNs)"}),". You create an APNs key or certificate in your developer account and register your app's capability in Xcode. On iOS the user must explicitly grant permission — notifications are off until they say yes."]}):null,i?e.jsxs(lt,{store:"android",badge:"FCM",children:["Google's ",e.jsx("b",{children:"Firebase Cloud Messaging (FCM)"}),". Add the Firebase config to your app and use the FCM token to target a device. Android 13+ also requires a runtime permission prompt, so don't assume delivery without it."]}):null,e.jsx("div",{className:"seclabel",children:"Get this right"}),e.jsx(rs,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Ask at the right moment."})," Prompt for permission when the value is obvious, not on first launch — a denied prompt is hard to recover."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Make them opt-in and useful."})," Noisy notifications get your app muted or uninstalled."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Test on a real device."})," Push is unreliable on the iOS simulator — Xcode 14+/macOS 13+ can receive a dropped payload, but verify real delivery on a physical device."]})]}),e.jsx(Ye,{items:c}),e.jsx(de,{assistKey:"push-notifications",topicName:"Push notifications"}),e.jsx(he,{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:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const nR=Object.freeze(Object.defineProperty({__proto__:null,PushNotificationsScreen:jp},Symbol.toStringTag,{value:"Module"}));function wp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(ft,{size:26}),title:"Crash reporting",meta:"Recommended · about 30 minutes",assistKey:"crash-reporting"}),e.jsx("p",{className:"lead",children:"Once real people run your app, some of them will hit crashes you never saw in testing — on devices and OS versions you don't own. Crash reporting captures those automatically so you find out before the one-star reviews do."}),e.jsx("div",{className:"seclabel",children:"What you'll get"}),e.jsx(rs,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Stack traces"})," pointing at the exact line that failed, grouped so you see which crash hits the most people first."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Device context"})," — OS version, model, and steps — so you can reproduce instead of guessing."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Trends over time"})," so you can tell whether a release made things better or worse."]})]}),e.jsx("div",{className:"seclabel",children:"Common tools"}),e.jsxs("p",{className:"lead dim",children:[e.jsx("b",{children:"Firebase Crashlytics"})," (free, works on both platforms) and"," ",e.jsx("b",{children:"Sentry"})," (crashes plus broader error monitoring) are the usual starting points. Both drop in as an SDK; pick one and wire it once."]}),e.jsxs("div",{className:"sd-callout size",children:[e.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:"⬇"}),e.jsxs("div",{children:[e.jsx("div",{className:"sd-callout-t",children:"Upload your symbols, or reports are noise"}),e.jsx("div",{className:"sd-callout-b",children:"Release builds are stripped, so a raw crash is unreadable hex. Upload the debug symbols (dSYMs on iOS, mapping files on Android) on every release — most SDKs automate this in CI — or your stack traces won't point at real code."})]})]}),e.jsx(de,{assistKey:"crash-reporting",topicName:"Crash reporting"}),e.jsx(he,{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:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const rR=Object.freeze(Object.defineProperty({__proto__:null,CrashReportingScreen:wp},Symbol.toStringTag,{value:"Module"}));function _p({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=ks(t),i=$s(t),c=[{q:"Can't I just use Stripe like on the web?",a:"Not for digital goods consumed in the app — unlocking features, virtual currency, subscriptions. Those must go through the store's billing, and shipping a side payment link for them is one of the most common rejections. Stripe is fine for real-world goods and services (a ride, a physical product, an in-person class)."},{q:"Why is the commission lower in some cases?",a:"Both stores drop to 15% for most small developers — Apple's Small Business Program (under ~$1M/year) and Google's first $1M/year — and for subscriptions (Apple after the subscriber's first year, Google from day one). Above those thresholds the standard rate is 30%."},{q:"How do I test a purchase without being charged?",a:"Both stores have sandbox testers: Apple uses Sandbox Apple IDs in App Store Connect, Google uses license-test accounts in the Play Console. Purchases run end-to-end against test billing so you can verify the unlock flow without real money."},{q:"Do I have to verify the purchase on a server?",a:"For anything worth protecting, yes. Validate the store receipt / purchase token server-side before granting entitlements — a client-only check is trivially bypassed. Both platforms publish server-side verification APIs."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(Dt,{size:26}),title:"In-app purchases & subscriptions",meta:"When you sell inside the app · about 30 minutes",assistKey:"in-app-purchases"}),e.jsxs("p",{className:"lead",children:["Selling anything digital inside your app — a subscription, a feature unlock, in-app currency — doesn't work like web checkout. The stores require you to use ",e.jsx("i",{children:"their"})," billing, take a cut, and reject apps that route around it. Getting this right early saves a painful rewrite later."]}),e.jsx(ts,{tone:"cost",title:"The store takes a commission on every sale",children:"Budget for it in your pricing from the start — the cut comes off the top of every transaction, before you see a cent."}),e.jsx("div",{className:"seclabel",children:"What you'll wire up"}),o?e.jsxs(lt,{store:"ios",badge:ce("appStore.commission").value,children:["Use ",e.jsx("b",{children:"StoreKit"})," (StoreKit 2 is the current API) to define products in App Store Connect and present the native purchase sheet. Apple's cut is ",ce("appStore.commission").value,"."," ",e.jsx(es,{fact:ce("appStore.commission")})]}):null,i?e.jsxs(lt,{store:"android",badge:ce("googlePlay.commission").value,children:["Use the ",e.jsx("b",{children:"Google Play Billing Library"})," to define products in the Play Console and launch the billing flow. Google's service fee is"," ",ce("googlePlay.commission").value,"."," ",e.jsx(es,{fact:ce("googlePlay.commission")})]}):null,e.jsx("div",{className:"seclabel",children:"The rule that gets apps rejected"}),e.jsx(rs,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Digital goods must use store billing."}),' Subscriptions, feature unlocks, virtual currency — all of it goes through StoreKit / Play Billing. A Stripe link or "pay on our website" prompt for these is a rejection.']}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Physical goods and real-world services don't."})," A ride, a shipped product, an in-person class — bill those however you like; the stores explicitly don't want their cut of those."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Verify entitlements server-side."})," Validate the receipt or purchase token on your backend before unlocking — never trust the client alone."]})]}),e.jsx(Ye,{items:c}),e.jsx(de,{assistKey:"in-app-purchases",topicName:"In-app purchases & subscriptions"}),e.jsx(he,{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:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const aR=Object.freeze(Object.defineProperty({__proto__:null,InAppPurchasesScreen:_p},Symbol.toStringTag,{value:"Module"}));function kp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=ks(t),i=[{q:"Do I need a privacy policy even if I collect almost nothing?",a:"Yes. Both stores require a reachable privacy policy URL for essentially every app — even a trivial one. It has to be live before you submit, and it must match what your app actually does. A dead link or a mismatch is a rejection."},{q:"Why do I have to let people delete their account in the app?",a:"Both Apple and Google require that apps which let you create an account also let you delete it — and the data tied to it — from inside the app (a web link is allowed alongside, but the in-app path must exist). It's a hard review gate, not a nicety."},{q:"What exactly counts as 'tracking' for the iOS prompt?",a:"Linking a user's data with data from other companies' apps or sites for advertising or sharing with data brokers. If you do that, you must show the App Tracking Transparency prompt and only track if they allow it. Plain first-party analytics usually isn't 'tracking' in Apple's sense — but the store privacy questionnaire still has to be answered honestly."},{q:"Is the privacy questionnaire the same as the privacy policy?",a:"No — they're two things. The store's privacy questionnaire (Apple's 'privacy nutrition label', Google's Data safety form) is a structured declaration you fill in at submission; the privacy policy is your own hosted page. Both have to agree with each other and with the app's real behavior."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(Re,{size:26}),title:"App privacy & tracking",meta:"Submission gate · about 30 minutes",assistKey:"app-privacy"}),e.jsx("p",{className:"lead",children:`A build that runs perfectly still gets held at review if its privacy story isn't in order. These gates are about what you tell users you do with their data — and the stores check them on every submission, so it's worth handling before you hit "submit," not after a rejection.`}),e.jsx("div",{className:"seclabel",children:"The gates that apply everywhere"}),e.jsx(rs,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"A live privacy policy URL."})," Host a policy that matches what the app actually collects, and make sure the link resolves — a dead link is an instant rejection."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"In-app account deletion."})," If users can create an account, they must be able to delete it — and its data — from inside the app. Both stores require this path to exist."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"An honest privacy declaration."})," Fill in Apple's privacy label and Google's Data safety form to match reality; a mismatch with your policy or your code is a rejection."]})]}),o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:"iOS only — the tracking prompt"}),e.jsxs(ts,{tone:"wait",title:"App Tracking Transparency is its own gate",children:["If your app tracks users across other companies' apps and sites — for ads or to share with data brokers — iOS requires the"," ",e.jsx("b",{children:"App Tracking Transparency"}),' prompt before any of it, and you may only track users who tap "Allow." Declare your tracking honestly; tracking without the prompt is a rejection (and, if shipped, an enforcement risk).']})]}):null,e.jsx(Ye,{items:i}),e.jsx(de,{assistKey:"app-privacy",topicName:"App privacy & tracking"}),e.jsx(he,{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:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const oR=Object.freeze(Object.defineProperty({__proto__:null,AppPrivacyScreen:kp},Symbol.toStringTag,{value:"Module"}));function Sp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=[{q:"How long does review actually take?",a:"Apple is often a day or less now; Google can be a few hours to a few days, and longer for a brand-new account or a sensitive permission. The killer isn't the queue — it's the round-trips. Every rejection restarts the clock, so the way to ship fast is to not get rejected."},{q:"What's the most common avoidable rejection?",a:"Incomplete or inaccurate metadata and missing reviewer access. If a feature is behind a login, the reviewer needs a working demo account (or a documented way in) — otherwise they can't test it and they reject. Screenshots that don't match the app and broken support/privacy links are close behind."},{q:"What does 'minimum functionality' mean?",a:"Apple in particular rejects apps that are too thin — a repackaged website, a static brochure, or something that could just be a web page. The app needs to do something that justifies being an app. If it's borderline, add real native value before submitting."},{q:"I got rejected — now what?",a:"Read the exact guideline they cite, fix that specific thing, and reply in Resolution Center / the Play policy console with what you changed. Don't resubmit blind. If you genuinely disagree, you can respond or appeal — but a clean, targeted fix is almost always faster than arguing."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(oe,{onBack:s,icon:e.jsx(Ae,{size:26}),title:"Getting through review",meta:"Before you submit · about 20 minutes",assistKey:"app-review"}),e.jsx("p",{className:"lead",children:"Every store submission goes through a human (and automated) review, and it's where launches slip by weeks. The good news: almost every rejection is avoidable and predictable. Knock these out before you submit and most apps clear review on the first try."}),e.jsx(ts,{tone:"wait",title:"Rejections cost round-trips, not just time",children:"Each rejection sends you back to the end of the queue. Front-loading the common reasons is the single biggest thing you can do to ship on schedule."}),e.jsx("div",{className:"seclabel",children:"Clear these before submitting"}),e.jsx(rs,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Complete, accurate metadata."})," Real screenshots that match the current app, a truthful description, and working support and privacy URLs. Placeholder or mismatched assets get rejected."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"A demo account for the reviewer."})," Anything behind a login needs working credentials (or a documented bypass) in the review notes — otherwise the reviewer can't test it and rejects."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Enough functionality to be an app."})," Especially on iOS, a thin wrapper around a website or a static brochure gets rejected for minimum functionality. Make sure it does something app-worthy."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Honest permissions and data use."})," Every permission you request needs a clear in-context reason, and your store privacy declaration has to match what the app does."]})]}),e.jsx(Ye,{items:o}),e.jsx(de,{assistKey:"app-review",topicName:"Getting through review"}),e.jsx(he,{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:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const iR=Object.freeze(Object.defineProperty({__proto__:null,AppReviewScreen:Sp},Symbol.toStringTag,{value:"Module"})),i1=5e3,Rl=50;function l1(){const[t,s]=l.useState([]),[n,r]=l.useState(0),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[h,p]=l.useState(null),f=l.useRef("idle"),m=l.useRef([]),b=l.useRef(null);l.useEffect(()=>{m.current=t},[t]),l.useEffect(()=>{b.current=a},[a]);const g=l.useCallback(async()=>{if(f.current==="idle"){f.current="initial",c(!0),p(null);try{const v=await fetch(`/api/history?limit=${Rl}`);if(!v.ok)throw new Error(`HTTP ${v.status}`);const j=await v.json();s(j.entries??[]),r(j.total??0),o(j.nextCursor??null),j.error&&p(j.error)}catch(v){p(v instanceof Error?v.message:"Failed to load history")}finally{c(!1),f.current="idle"}}},[]),x=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 g();return}f.current="poll";try{const w=await fetch(`/api/history?since=${encodeURIComponent(v)}`);if(!w.ok)throw new Error(`HTTP ${w.status}`);const _=await w.json(),S=new Set(m.current.map(N=>N.commit.sha)),C=(_.entries??[]).filter(N=>!S.has(N.commit.sha));C.length>0&&(s(N=>[...C,...N]),r(N=>N+C.length))}catch(w){p(w instanceof Error?w.message:"Failed to poll history")}finally{f.current="idle"}},[g]),y=l.useCallback(async()=>{if(f.current!=="idle")return;const v=b.current;if(v){f.current="more",u(!0);try{const j=await fetch(`/api/history?limit=${Rl}&before=${encodeURIComponent(v)}`);if(!j.ok)throw new Error(`HTTP ${j.status}`);const w=await j.json();s(_=>[..._,...w.entries??[]]),o(w.nextCursor??null),typeof w.total=="number"&&r(w.total)}catch(j){p(j instanceof Error?j.message:"Failed to load more commits")}finally{u(!1),f.current="idle"}}},[]);return l.useEffect(()=>{g();const v=setInterval(()=>{x()},i1);return()=>clearInterval(v)},[g,x]),{rows:t,total:n,hasMore:a!==null,loading:i,loadingMore:d,error:h,loadMore:y,reload:g}}const ua={rows:[],total:0,truncated:!1,repo:null,screenshotsRepoRelDir:"",loading:!1,error:null};function c1(t){const[s,n]=l.useState(ua),r=(t==null?void 0:t.from)??null,a=(t==null?void 0:t.to)??null;return l.useEffect(()=>{if(r===null||a===null){n(ua);return}let o=!1;n(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||n({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||n({...ua,error:c instanceof Error?c.message:"Failed to load range"})}),()=>{o=!0}},[r,a]),s}function Np(t){const s=new Map;return t.forEach((n,r)=>{var o;const a=((o=n.entry)==null?void 0:o.scenarioScreenshots)??[];for(const i of a)s.has(i.name)||s.set(i.name,r)}),s}const d1=[/\.test\.[jt]sx?$/,/\.spec\.[jt]sx?$/,/__tests__\//,/tests?\//];function ni(t){return t.filter(s=>d1.some(n=>n.test(s.path)))}function u1(t){const s={},n={total:0,passed:0,failed:0},r=new Set,a=new Set,o=new Set,i=[];let c=0,d=0;for(const u of t){if(!u.entry){d++;continue}c++;const h=u.entry.type||"other";s[h]=(s[h]??0)+1,u.commit.authorName&&r.add(u.commit.authorName),u.entry.testResults&&(n.total+=u.entry.testResults.total,n.passed+=u.entry.testResults.passed,n.failed+=u.entry.testResults.failed);for(const p of ni(u.entry.modifiedFiles??[]))o.add(p.path);for(const p of u.entry.scenarioScreenshots??[])a.has(p.name)||(a.add(p.name),i.push(p))}return{totalChanges:c,byType:s,testFilesTouched:o.size,testTotals:n,screenshots:i,contributors:[...r],hiddenCommitOnlyCount:d}}const h1=[{key:"all-time",label:"All time"},{key:"last-24h",label:"Last 24 hours"},{key:"last-3d",label:"Last 3 days"},{key:"last-week",label:"Last week"},{key:"last-month",label:"Last month"}],zn=864e5;function p1(t,s){const n=s.toISOString();switch(t){case"last-24h":return{from:new Date(s.getTime()-zn).toISOString(),to:n};case"last-3d":return{from:new Date(s.getTime()-3*zn).toISOString(),to:n};case"last-week":return{from:new Date(s.getTime()-7*zn).toISOString(),to:n};case"last-month":return{from:new Date(s.getTime()-30*zn).toISOString(),to:n};case"all-time":case"custom":return null}}function m1(t){const s=new Date(t.from),n=new Date(t.to);if(isNaN(s.getTime())||isNaN(n.getTime()))return`${t.from} – ${t.to}`;const r=h=>h.toLocaleDateString("en-US",{month:"short"}),a=r(s),o=s.getDate(),i=s.getFullYear(),c=r(n),d=n.getDate(),u=n.getFullYear();return i===u&&s.getMonth()===n.getMonth()?`${a} ${o} – ${d}, ${u}`:i===u?`${a} ${o} – ${c} ${d}, ${u}`:`${a} ${o}, ${i} – ${c} ${d}, ${u}`}function Cp({commit:t}){return e.jsxs("div",{className:"rounded-lg border px-4 py-3",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"var(--text-dim)"},children:[e.jsx("span",{className:"font-mono uppercase tracking-wide",style:{color:"var(--text-muted)"},children:"commit"}),e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:t.shortSha}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:Pu(t.timestamp)}),t.authorName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:t.authorName})]})]}),e.jsx("p",{className:"mt-1 text-sm truncate",style:{color:"var(--text-primary)"},children:t.subject})]})}const lR=Object.freeze(Object.defineProperty({__proto__:null,CommitOnlyHistoryRow:Cp},Symbol.toStringTag,{value:"Module"}));function Fr({entry:t,commit:s,onSelectScreenshot:n}){const r=ni(t.modifiedFiles??[]);return e.jsxs("div",{className:"rounded-lg border",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3",style:{borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`text-xs font-medium uppercase tracking-wide ${Tu(t.type)}`,children:t.type}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:Pu(t.timestamp)}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:"·"}),e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:s.shortSha}),s.authorName&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["· ",s.authorName]})]})]}),e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:t.title})]}),e.jsxs("div",{className:"px-4 py-3 flex flex-col gap-3",children:[t.userRequest&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:"Prompt"}),e.jsx(Sr,{children:t.userRequest})]}),(t.scenarioScreenshots??[]).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:"Screenshots"}),e.jsx(Ho,{screenshots:t.scenarioScreenshots??[],onSelect:n})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Tests"}),t.testResults&&e.jsx(Cr,{total:t.testResults.total,passed:t.testResults.passed,failed:t.testResults.failed})]}),r.length>0?e.jsx("ul",{className:"flex flex-col gap-0.5",children:r.map(a=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx(Nr,{status:a.status}),e.jsx("span",{className:"font-mono text-xs truncate",style:{color:"var(--text-secondary)"},children:a.path})]},a.path))}):e.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No test files changed"})]})]})]})}const cR=Object.freeze(Object.defineProperty({__proto__:null,HistoryEntryCard:Fr},Symbol.toStringTag,{value:"Module"}));function Pp({selection:t,onChange:s,now:n=new Date}){const[r,a]=l.useState(""),[o,i]=l.useState(""),c=u=>{s({preset:u,range:p1(u,n)})},d=(u,h)=>{a(u),i(h),u&&h&&s({preset:"custom",range:{from:new Date(`${u}T00:00:00Z`).toISOString(),to:new Date(`${h}T23:59:59Z`).toISOString()}})};return e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[h1.map(u=>{const h=t.preset===u.key;return e.jsx("button",{type:"button",onClick:()=>c(u.key),"aria-pressed":h,className:`rounded border px-2.5 py-1 text-xs transition ${h?"border-[var(--accent-primary)] text-[var(--text-primary)]":"border-[var(--border-default)] text-[var(--text-muted)] hover:bg-[var(--bg-subtle)]"}`,children:u.label},u.key)}),e.jsx("span",{className:"mx-1 text-xs text-[var(--text-dim)]",children:"or"}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-[var(--text-dim)]",children:["From",e.jsx("input",{type:"date","aria-label":"Custom range start",value:r,onChange:u=>d(u.target.value,o),className:"rounded border border-[var(--border-default)] bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]"})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-[var(--text-dim)]",children:["To",e.jsx("input",{type:"date","aria-label":"Custom range end",value:o,onChange:u=>d(r,u.target.value),className:"rounded border border-[var(--border-default)] bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]"})]})]})}const dR=Object.freeze(Object.defineProperty({__proto__:null,HistoryRangeSelector:Pp},Symbol.toStringTag,{value:"Module"}));function f1(t){const{rangeLabel:s,summary:n,rows:r,repo:a,screenshotsRepoRelDir:o}=t,i=(a==null?void 0:a.rawUrlTemplate)??null,c=[];c.push(`# Change digest — ${s}`),c.push(""),c.push(g1(n)),n.hiddenCommitOnlyCount>0&&(c.push(""),c.push(`_${n.hiddenCommitOnlyCount} non-journaled commit${n.hiddenCommitOnlyCount===1?"":"s"} hidden._`));const d=r.filter(u=>u.entry!==null);for(const u of d){const h=u.entry;c.push(""),c.push(`## ${h.title}`),c.push(""),c.push(`- **Type:** ${h.type}`),c.push(`- **Commit:** \`${u.commit.shortSha}\``),h.description&&(c.push(""),c.push(h.description));const p=ni(h.modifiedFiles??[]);if(p.length>0){c.push(""),c.push("**Test files:**");for(const m of p)c.push(`- \`${m.path}\``)}const f=h.scenarioScreenshots??[];if(f.length>0)if(c.push(""),i)for(const m of f){if(!m.screenshotPath)continue;const b=i.replace("{sha}",u.commit.sha).replace("{path}",b1(o,m.screenshotPath));c.push(`![${m.name}](${b})`)}else{c.push("**Screenshots (local only):**");for(const m of f)c.push(`- ${m.name}`)}}return c.join(`
11
- `)}function g1(t){const s=[];s.push(`**${t.totalChanges}** change${t.totalChanges===1?"":"s"}`);const n=Object.entries(t.byType).map(([r,a])=>`${a} ${r}`);return n.length>0&&s.push(n.join(", ")),s.push(`${t.testFilesTouched} test file${t.testFilesTouched===1?"":"s"}`),t.testTotals.total>0&&s.push(`${t.testTotals.passed}/${t.testTotals.total} tests passed`),s.push(`${t.screenshots.length} screenshot${t.screenshots.length===1?"":"s"}`),s.join(" · ")}function b1(t,s){const n=t.replace(/\/+$/,""),r=s.replace(/^\/+/,"");return n?`${n}/${r}`:r}function Tp({summary:t}){return e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[e.jsxs("span",{className:"text-[var(--text-primary)]",children:[t.totalChanges," change",t.totalChanges===1?"":"s"]}),Object.entries(t.byType).map(([s,n])=>e.jsxs("span",{className:Tu(s),children:[n," ",s]},s)),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.testFilesTouched," test file",t.testFilesTouched===1?"":"s"]}),e.jsx(Cr,{total:t.testTotals.total,passed:t.testTotals.passed,failed:t.testTotals.failed}),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.screenshots.length," screenshot",t.screenshots.length===1?"":"s"]}),t.contributors.length>0&&e.jsx("span",{className:"text-[var(--text-dim)]",children:t.contributors.join(", ")})]})}const uR=Object.freeze(Object.defineProperty({__proto__:null,HistoryDigestStatRow:Tp},Symbol.toStringTag,{value:"Module"}));function Ap({rangeLabel:t,summary:s,rows:n,repo:r,screenshotsRepoRelDir:a,truncated:o,onPreviewScreenshot:i}){const[c,d]=l.useState(!1),u=Np(n),h=async()=>{const p=f1({rangeLabel:t,summary:s,rows:n,repo:r,screenshotsRepoRelDir:a});try{await navigator.clipboard.writeText(p),d(!0),setTimeout(()=>d(!1),2e3)}catch{}};return s.totalChanges===0?e.jsxs("div",{children:[e.jsx(Ua,{rangeLabel:t,onCopy:h,copied:c}),e.jsxs("div",{className:"py-10 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No changes in this window."}),s.hiddenCommitOnlyCount>0&&e.jsxs("p",{className:"mt-2 text-xs",children:[s.hiddenCommitOnlyCount," non-journaled commit",s.hiddenCommitOnlyCount===1?"":"s"," hidden."]})]})]}):e.jsxs("div",{children:[e.jsx(Ua,{rangeLabel:t,onCopy:h,copied:c}),e.jsx(Tp,{summary:s}),s.hiddenCommitOnlyCount>0&&e.jsxs("p",{className:"mb-3 text-xs text-[var(--text-dim)]",children:[s.hiddenCommitOnlyCount," non-journaled commit",s.hiddenCommitOnlyCount===1?"":"s"," hidden from this digest."]}),o&&e.jsxs("p",{className:"mb-3 text-xs text-[var(--accent-yellow,#eab308)]",children:["Showing the ",n.length," most recent changes in this window — narrow the range to see the rest."]}),s.screenshots.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-[var(--text-muted)]",children:"Screenshots"}),e.jsx(Ho,{screenshots:s.screenshots,onSelect:i?p=>i({...p,isLatest:u.get(p.name)===x1(n,p.name)}):void 0})]}),e.jsx("div",{className:"flex flex-col gap-3",children:n.map((p,f)=>p.entry?e.jsx(Fr,{entry:p.entry,commit:p.commit,onSelectScreenshot:i?m=>i({...m,isLatest:u.get(m.name)===f}):void 0},p.commit.sha):null)})]})}function Ua({rangeLabel:t,onCopy:s,copied:n}){return e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-primary)]",children:t}),e.jsx("button",{type:"button",onClick:s,className:"rounded border border-[var(--border-default)] px-2.5 py-1 text-xs text-[var(--text-muted)] hover:bg-[var(--bg-subtle)]",children:n?"Copied!":"Copy summary"})]})}function x1(t,s){return t.findIndex(n=>{var r;return(((r=n.entry)==null?void 0:r.scenarioScreenshots)??[]).some(a=>a.name===s)})}const hR=Object.freeze(Object.defineProperty({__proto__:null,DigestHeader:Ua,HistoryDigest:Ap},Symbol.toStringTag,{value:"Module"}));function Op({onPreviewScreenshot:t}={}){const[s,n]=l.useState({preset:"all-time",range:null});return e.jsxs(Qt,{children:[e.jsx(Pp,{selection:s,onChange:n}),s.range?e.jsx(y1,{range:s.range,onPreviewScreenshot:t}):e.jsx(v1,{onPreviewScreenshot:t})]})}function y1({range:t,onPreviewScreenshot:s}){const{rows:n,truncated:r,repo:a,screenshotsRepoRelDir:o,loading:i,error:c}=c1(t);if(i)return e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading digest..."});if(c)return e.jsxs("div",{className:"py-12 text-center text-[var(--accent-red)]",children:["Failed to load digest: ",c]});const d=u1(n);return e.jsx(Ap,{rangeLabel:m1(t),summary:d,rows:n,repo:a,screenshotsRepoRelDir:o,truncated:r,onPreviewScreenshot:s})}function v1({onPreviewScreenshot:t}){const{rows:s,total:n,hasMore:r,loading:a,loadingMore:o,error:i,loadMore:c}=l1();if(a)return e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading history..."});if(i&&s.length===0)return e.jsxs("div",{className:"py-12 text-center text-[var(--accent-red)]",children:["Failed to load history: ",i]});if(s.length===0)return e.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No commits yet."}),e.jsx("p",{className:"mt-2 text-sm",children:"Commits and journal entries will appear here as you build features."})]});const d=Math.max(n,s.length),u=Np(s);return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mb-3 text-xs",style:{color:"var(--text-dim)"},children:[s.length," of ",d," commit",d===1?"":"s"]}),e.jsx("div",{className:"flex flex-col gap-3",children:s.map((h,p)=>h.entry?e.jsx(Fr,{entry:h.entry,commit:h.commit,onSelectScreenshot:t?f=>t({...f,isLatest:u.get(f.name)===p}):void 0},h.commit.sha):e.jsx(Cp,{commit:h.commit},h.commit.sha))}),r?e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>void c(),disabled:o,className:"rounded border border-[var(--border)] px-3 py-1 text-sm text-[var(--text-muted)] hover:bg-[var(--bg-subtle)] disabled:opacity-50",children:o?"Loading...":"Load older commits"})}):null]})}const pR=Object.freeze(Object.defineProperty({__proto__:null,HistoryTab:Op},Symbol.toStringTag,{value:"Module"})),j1="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 w1(){const t=typeof Notification<"u"?Notification.permission:"unknown",s=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!1,n=typeof document<"u"?document.hidden:!1;let r=null;try{r=typeof localStorage<"u"?localStorage.getItem("codeyam.idleDebug"):null}catch{}const a=typeof navigator<"u"?navigator.userAgent:"unknown";return{notificationPermission:t,hasFocus:s,hidden:n,idleDebug:r,userAgent:a}}function El(t){return t.length===0?"_(no events in window)_":`\`\`\`jsonl
12
- ${t.map(n=>JSON.stringify(n)).join(`
13
- `)}
14
- \`\`\``}function ha(t,s){return t.trim().length===0?`_(${s} empty)_`:`\`\`\`
15
- ${t}
16
- \`\`\``}function _1(t){var x,y,v;const{bundle:s,browser:n,uiBufferText:r,prompt:a,agentName:o}=t,i=(s==null?void 0:s.now)??new Date().toISOString(),c=(s==null?void 0:s.session)??Ao(),d=(s==null?void 0:s.windowMinutes)??10,u=((x=s==null?void 0:s.environment)==null?void 0:x.editorVersion)??"unknown",h=((y=s==null?void 0:s.environment)==null?void 0:y.platform)??"unknown",p=((v=s==null?void 0:s.environment)==null?void 0:v.projectDir)??"unknown",f=(a??j1).trim(),m=[`- Notification.permission: ${n.notificationPermission}`,`- document.hasFocus(): ${n.hasFocus}`,`- document.hidden: ${n.hidden}`,`- localStorage.codeyam.idleDebug: ${n.idleDebug===null?"(unset)":JSON.stringify(n.idleDebug)}`,`- userAgent: ${n.userAgent}`].join(`
17
- `),b=s&&s.truncations.length>0?`> **Truncations:** ${s.truncations.join("; ")}`:"";return["# CodeYam Notification Debug Bundle","",f,"","---","",`**Captured:** ${i}`,`**UI session:** ${c} (window: last ${d} minutes)`,`**Editor version:** ${u}`,`**Platform:** ${h}`,`**Project:** ${p}`,o?`**Agent:** ${o}`:null,"","**Browser state:**",m,"",b,"","## UI idle trace (persisted)","",El((s==null?void 0:s.uiTrace)??[]),"","## UI idle trace (in-memory ring buffer — may be ahead of persisted)","",ha(r,"in-memory buffer"),"","## Rust idle trace","",El((s==null?void 0:s.rustTrace)??[]),"","## editor-server.log (filtered to idle= within window)","",ha((s==null?void 0:s.editorServerLog)??"","editor-server.log"),"","## dev-server.log (last lines)","",ha((s==null?void 0:s.devServerLog)??"","dev-server.log"),""].filter(j=>j!==null).join(`
18
- `)}async function k1(t={}){const s=encodeURIComponent(Ao());let n=null,r=null;try{const c=await fetch(`/api/idle-trace/bundle?session=${s}&minutes=10`);c.ok?n=await c.json():r=`HTTP ${c.status}`}catch(c){r=c instanceof Error?c.message:String(c)}const a=w1(),o=Aw({agentName:t.agentName});return{markdown:_1({bundle:n,browser:a,uiBufferText:o,prompt:t.prompt,agentName:t.agentName}),bundle:n,error:r}}const S1=1500;function N1(t=S1){const[s,n]=l.useState(null),r=l.useRef(null),a=l.useCallback((o,i)=>{r.current!==null&&clearTimeout(r.current),n(o),r.current=setTimeout(()=>{n(null),r.current=null},i??t)},[t]);return l.useEffect(()=>()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),{label:s,flash:a}}const C1=2500;function Rp({agentName:t}){const[s,n]=l.useState(!1),{label:r,flash:a}=N1(C1),o=async()=>{n(!0);const{markdown:i,bundle:c,error:d}=await k1({agentName:t});try{await navigator.clipboard.writeText(i);const u=((c==null?void 0:c.uiTrace.length)??0)+((c==null?void 0:c.rustTrace.length)??0),h=Math.round(i.length/1024*10)/10,p=d?`Copied (offline — ${u} events, ${h} KB)`:`Copied ${u} events · ${h} KB`;a(p)}catch{a("Copy failed")}finally{n(!1)}};return e.jsx("button",{onClick:()=>void o(),disabled:s,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??(s?"Gathering bundle…":"Debug Notifications")})}const mR=Object.freeze(Object.defineProperty({__proto__:null,DebugNotificationsButton:Rp},Symbol.toStringTag,{value:"Module"})),pa={sound:"soft-double-tap",systemNotification:!0,idleOnStop:!1,idleOnNotification:!0},P1=[{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"}],Ep="codeyam-editor-notifications";function Mp(){try{const t=localStorage.getItem(Ep);if(!t)return pa;const s=JSON.parse(t);return{...pa,...s}}catch{return pa}}function Ip(t){localStorage.setItem(Ep,JSON.stringify(t))}const T1={"soft-double-tap":t=>([0,.12].forEach(s=>{const n=t.createOscillator(),r=t.createGain();n.connect(r),r.connect(t.destination),n.type="sine",n.frequency.value=392,r.gain.setValueAtTime(.25,t.currentTime+s),r.gain.exponentialRampToValueAtTime(.01,t.currentTime+s+.1),n.start(t.currentTime+s),n.stop(t.currentTime+s+.1)}),{count:2,longestStopSec:.22}),"gentle-chime":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="sine",s.frequency.setValueAtTime(523,t.currentTime),s.frequency.setValueAtTime(659,t.currentTime+.15),n.gain.setValueAtTime(.3,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),s.start(),s.stop(t.currentTime+.4),{count:1,longestStopSec:.4}},"warm-ding":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="sine",s.frequency.value=330,n.gain.setValueAtTime(.35,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),s.start(),s.stop(t.currentTime+.6),{count:1,longestStopSec:.6}},"mellow-two-tone":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="sine",s.frequency.setValueAtTime(294,t.currentTime),s.frequency.setValueAtTime(440,t.currentTime+.18),n.gain.setValueAtTime(.3,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),s.start(),s.stop(t.currentTime+.5),{count:1,longestStopSec:.5}},"triangle-bell":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="triangle",s.frequency.value=523,n.gain.setValueAtTime(.4,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),s.start(),s.stop(t.currentTime+.8),{count:1,longestStopSec:.8}}};function ma(t,s){const n=s;X(t,{name:n==null?void 0:n.name,message:n==null?void 0:n.message})}function Dp(t){if(t==="off")return;X("audio-playsound-entered",{soundId:t});let s;try{s=new AudioContext}catch(r){ma("audio-context-failed",r);return}X("audio-context-created",{state:s.state});const n=()=>{let r;try{r=T1[t](s)}catch(a){ma("audio-context-failed",a),s.close().catch(()=>{});return}X("audio-oscillators-scheduled",{soundId:t,count:r.count,longestStopSec:r.longestStopSec}),setTimeout(()=>{s.close().then(()=>X("audio-context-closed")).catch(()=>{})},(r.longestStopSec+.1)*1e3)};s.state==="running"?n():s.state==="suspended"?(X("audio-context-resume-attempted"),s.resume().then(()=>{X("audio-context-resume-ok",{state:s.state}),n()},r=>{ma("audio-context-resume-failed",r),s.close().catch(()=>{})})):(X("audio-context-failed",{name:"UnexpectedState",message:`AudioContext state "${s.state}"`}),s.close().catch(()=>{}))}function Ya({label:t,checked:s,onChange:n,className:r}){return e.jsxs("label",{className:`flex items-center gap-2 cursor-pointer${r?` ${r}`:""}`,children:[e.jsx("input",{type:"checkbox",checked:s,onChange:a=>n(a.target.checked),className:"accent-green-500"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t})]})}const fR=Object.freeze(Object.defineProperty({__proto__:null,IdleTriggerCheckbox:Ya},Symbol.toStringTag,{value:"Module"}));function ri({settings:t,onChange:s}){const n=t.idleOnStop??!1,r=t.idleOnNotification??!0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Notification sound"}),e.jsx("div",{className:"flex flex-col gap-0.5",children:P1.map(a=>e.jsx("button",{onClick:()=>{s({...t,sound:a.id}),a.id!=="off"&&Dp(a.id)},className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors",style:{background:t.sound===a.id?"var(--bg-input)":"transparent",color:t.sound===a.id?"var(--text-primary)":"var(--text-secondary)"},children:a.label},a.id))})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Trigger idle on"}),e.jsx(Ya,{label:"Claude stops",checked:n,onChange:a=>s({...t,idleOnStop:a})}),e.jsx(Ya,{label:"Claude sends a notification",checked:r,onChange:a=>s({...t,idleOnNotification:a}),className:"mt-1"})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.systemNotification,onChange:a=>{const o=a.target.checked;s({...t,systemNotification:o}),o&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"System notification"})]}),e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--text-dim)"},children:"Shows when tab is not visible"}),typeof Notification<"u"&&Notification.permission==="denied"&&e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--accent-red, #ef4444)"},children:"Notifications are blocked. Click the lock icon in your address bar → Site settings → Notifications → Allow"})]})]})}const gR=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsControls:ri},Symbol.toStringTag,{value:"Module"}));function Lp({settings:t,onChange:s,agentName:n}){const[r,a]=l.useState(!1),o=l.useRef(null),i=t.idleOnStop??!1,c=t.idleOnNotification??!0,d=t.sound!=="off"||t.systemNotification||i||c;return l.useEffect(()=>{if(!r)return;const u=h=>{o.current&&!o.current.contains(h.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),e.jsxs("div",{className:"h-7 flex items-center px-3 text-xs shrink-0",style:{background:"var(--bg-nav)",borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",ref:o,children:[e.jsx("button",{onClick:()=>{a(!r),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"cursor-pointer transition-colors",style:{color:d?"var(--accent-green)":"var(--text-dim)",fontSize:"11px"},children:d?"Notifications On":"Notifications Off"}),r&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx(ri,{settings:t,onChange:s}),e.jsx("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:e.jsx(Rp,{agentName:n})})]})]})]})}const bR=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsPopover:Lp},Symbol.toStringTag,{value:"Module"})),Fp="codeyam-editor-notifications-prompted",A1="codeyam-editor-notifications";function zp(){try{localStorage.setItem(Fp,"1")}catch{}}function O1(){try{return localStorage.getItem(Fp)!==null||localStorage.getItem(A1)!==null}catch{return!0}}function $p({settings:t,onChange:s}){const[n,r]=l.useState(()=>!O1());if(!n)return null;const a=()=>{zp(),r(!1)},o=()=>{s({...t,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission(),a()};return e.jsxs("div",{className:"rounded-lg px-4 py-2.5 mb-3 flex items-center gap-3",style:{background:"var(--surface-card)",border:"1px solid var(--lime-300)"},children:[e.jsx("span",{"aria-hidden":"true",style:{fontSize:15,lineHeight:1,color:"var(--lime-300)"},children:"🔔"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-strong)"},children:"Get notified when Claude finishes"}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-faint)",marginLeft:8},children:"We'll ping you when the agent stops or pauses."})]}),e.jsx("button",{onClick:o,className:"shrink-0 cursor-pointer transition-colors",style:{background:"var(--action-bg)",color:"var(--action-fg)",fontSize:"12.5px",fontWeight:600,borderRadius:9,padding:"7px 14px"},children:"Enable"}),e.jsx("button",{onClick:a,className:"shrink-0 cursor-pointer",style:{color:"var(--text-faint)",fontSize:"12px"},children:"Not now"})]})}const xR=Object.freeze(Object.defineProperty({__proto__:null,NotificationSetupBanner:$p},Symbol.toStringTag,{value:"Module"}));function Bp(){const[t,s]=l.useState(null);return l.useEffect(()=>{fetch("/api/editor-setup-answers").then(n=>{if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}).then(n=>{s(n!==null)}).catch(()=>{s(!1)})},[]),{saved:t}}function qp({appStatsLength:t,configLoading:s,scenariosLoading:n,setupAnswersSaved:r,hasStepState:a}){return t===0&&!s&&!n&&r===!1&&!a}function Hp({projectDescription:t}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Building your project…"}),e.jsx("blockquote",{className:"mt-4 border-l-2 border-[var(--accent-active)] pl-4 text-sm italic text-[var(--text-dim)]",children:t}),e.jsxs("p",{className:"mt-6 text-sm text-[var(--text-dim)]",children:["Your app will appear here as it’s built. The agent is scaffolding it now on the ",e.jsx("strong",{children:"Build"})," tab — open it to follow along."]})]})}const yR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateBuildingPanel:Hp},Symbol.toStringTag,{value:"Module"}));function Wp(){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"No app scaffolded yet"}),e.jsxs("p",{className:"mt-4 text-sm text-[var(--text-dim)]",children:["Your project hasn’t been scaffolded yet. Open the"," ",e.jsx("strong",{children:"Build"})," tab to start building."]})]})}const vR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateNoAppPanel:Wp},Symbol.toStringTag,{value:"Module"}));function Gp({onClick:t}){return e.jsx("button",{type:"button",onClick:t,"data-testid":"app-overview-empty-open-build",className:"mt-6 inline-flex items-center gap-2 rounded border border-[var(--accent-active)] bg-[var(--accent-active)] px-4 py-2 text-xs font-medium uppercase tracking-wide text-black transition-colors hover:bg-[var(--accent-active)]/90 cursor-pointer",children:"Open Build tab"})}const jR=Object.freeze(Object.defineProperty({__proto__:null,OpenBuildTabButton:Gp},Symbol.toStringTag,{value:"Module"}));function Up({projectDescription:t,onOpenBuildTab:s}){const n=t!==null&&t.trim().length>0;return e.jsxs("div",{className:"mx-auto max-w-2xl px-5 py-12 text-[var(--text-primary)]",children:[n?e.jsx(Hp,{projectDescription:t}):e.jsx(Wp,{}),e.jsx(Gp,{onClick:s})]})}const wR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyState:Up},Symbol.toStringTag,{value:"Module"}));function Yp({stats:t,onSelectApp:s,testsLoading:n,testsRefreshing:r,onRunTests:a,currentRunner:o}){return e.jsx("div",{className:"flex flex-col gap-4",children:t.map(i=>e.jsx(gu,{stats:i,onClick:()=>s(i.app.dir),testsLoading:n,testsRefreshing:r,onRunTests:a,currentRunner:o},i.app.dir))})}const _R=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewGrid:Yp},Symbol.toStringTag,{value:"Module"}));function Vp({projectTitle:t,coverage:s,onCoverageClick:n}){return e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t}),e.jsx(qo,{coverage:s,testId:"app-overview-coverage",onClick:n})]})}const kR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewHeader:Vp},Symbol.toStringTag,{value:"Module"})),R1=28,E1=21,M1=4,I1=5,D1={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"},L1={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"},F1={1:"Triage",2:"Route",3:"Wrap Up",4:"Complete"},z1={1:"Ground",2:"Generate",3:"Iterate",4:"Resolve",5:"Return"},$1={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."},B1={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 a first pass of the session narrative, 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:"Finalize the session narrative against post-Verify code, 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."},q1={1:"Classify the request: does it change application source the project should test and capture scenarios for, or not?",2:"Route the classified request to the right workflow or into an open-ended session.",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."},H1={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."},W1={ui:D1,backend:L1,assist:F1,design:z1},G1={ui:$1,backend:B1,assist:q1,design:H1},U1={ui:R1,backend:E1,assist:M1,design:I1},Y1={ui:"UI Flow",backend:"Backend Flow",assist:"Assist Flow",design:"Design Round"},V1=["ui","backend","assist","design"];function Pt(t){return V1.includes(t)?t:"ui"}function ai(t,s){return W1[Pt(s)][t]??"?"}function K1(t,s){return G1[Pt(s)][t]??""}function oi(t){return U1[Pt(t)]}function Kp(t){return Y1[Pt(t)]}function Jp(t,s){const n=Pt(s);return{description:K1(t,n),label:ai(t,n),prefix:Kp(n),totalSteps:oi(n)}}const J1={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"},X1={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"},Q1=[{phaseId:"understand",phaseLabel:"Understanding your idea",phaseSteps:[1,2,3]},{phaseId:"setup",phaseLabel:"Setting things up",phaseSteps:[4,5]},{phaseId:"build",phaseLabel:"Building your app",phaseSteps:[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]}],Z1=[{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]}];function ek(t,s){return(Pt(s)==="backend"?X1:J1)[t]??""}function tk(t){return Pt(t)==="backend"?Z1:Q1}const sk={building:{stat:"Building now",sub:"in progress",color:"var(--green-300)",attn:!1},"needs-input":{stat:"Needs you",sub:"your okay",color:"var(--amber-300)",attn:!0},waiting:{stat:"Waiting for you",sub:"paused",color:"var(--amber-300)",attn:!0}};function ii({isBuilding:t,buildingLabel:s,buildingStepLabel:n,buildingStepIndicator:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u,onResetBuild:h}){const p=s||"your latest change",f=sk[a];return t?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"drow building"+(f.attn?" attn":""),onClick:d,children:[e.jsx("div",{className:"dspin"}),e.jsxs("div",{className:"dmain",children:[e.jsxs("div",{className:"dname",children:["What's building"," ",e.jsx("span",{className:"livedot"+(f.attn?" warn":"")})]}),e.jsx("div",{className:"ddesc",children:a==="building"?e.jsxs(e.Fragment,{children:["Building ",e.jsx("b",{children:p}),n?e.jsxs(e.Fragment,{children:[" — ",n.toLowerCase(),"."]}):"."]}):a==="needs-input"?e.jsxs(e.Fragment,{children:[e.jsx("b",{children:p}),n?e.jsxs(e.Fragment,{children:[" — ",n.toLowerCase(),"."]}):"."," ","It needs your okay to keep going."]}):e.jsxs(e.Fragment,{children:[e.jsx("b",{children:p}),n?e.jsxs(e.Fragment,{children:[" — ",n.toLowerCase(),"."]}):"."," ","Paused, waiting for you to pick it back up."]})}),i||r?e.jsxs("div",{className:"bstep",children:[i?e.jsx("span",{className:"bflow",children:Kp(i)}):null,r]}):null,a==="building"?e.jsx("div",{className:"bbar",children:e.jsx("div",{className:"bbar-fill",style:{width:o!=null?`${Math.round(o*100)}%`:"12%"}})}):null]}),e.jsxs("div",{className:"dright",children:[e.jsxs("div",{className:"dmeta",children:[e.jsx("span",{className:"stat",style:{color:f.color},children:f.stat}),f.sub]}),e.jsx("span",{className:"arr",children:"→"})]})]}),h?e.jsx("div",{className:"bstatus-foot",children:e.jsx("button",{type:"button","data-testid":"build-status-reset",onClick:h,className:"bstatus-reset",children:"Cancel build & reset everything"})}):null]}):e.jsxs("button",{type:"button",className:"drow ready",onClick:u??d,children:[e.jsx("div",{className:"dic ic-ready",children:e.jsx(Le,{size:19})}),e.jsxs("div",{className:"dmain",children:[e.jsx("div",{className:"dname",children:"Ready to build?"}),e.jsx("div",{className:"ddesc",children:c?e.jsxs(e.Fragment,{children:["You last built ",e.jsx("b",{children:c}),"."]}):e.jsx(e.Fragment,{children:"Describe a change and I'll build it."})})]}),e.jsx("div",{className:"dright",children:e.jsx("span",{className:"cta-pill",children:"Build a new feature →"})})]})}const SR=Object.freeze(Object.defineProperty({__proto__:null,BuildingDoor:ii},Symbol.toStringTag,{value:"Module"}));function Xp({isBuilding:t,buildingLabel:s,buildingStepLabel:n,buildingStepIndicator:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,onOpenBuilding:c,onResetBuild:d}){return t?e.jsx("section",{"data-testid":"home-build-status-section",className:"mt-6 mb-6",children:e.jsx("div",{className:"home-landing",style:{padding:0},children:e.jsx("div",{className:"doorrows",children:e.jsx(ii,{isBuilding:t,buildingLabel:s,buildingStepLabel:n,buildingStepIndicator:r,buildingStatus:a,buildingProgress:o,buildingMode:i,onOpenBuilding:c,onStartNewFeature:c,onResetBuild:d})})})}):null}const NR=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildStatusSection:Xp},Symbol.toStringTag,{value:"Module"}));async function nk(t){try{t.description&&await fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:t.description,allowOverwrite:!0})});const s={appFormats:t.appFormats,techStackId:t.techStackId,designApproach:t.designApproach};t.defaultDevice&&(s.defaultDevice=t.defaultDevice),await fetch("/api/editor-setup-answers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch{}}const Ml=["product-type","description","tech-stack","notifications","design-approach"];function rk(t){return t==="files"||t==="chat"?[...Ml,"design-details"]:Ml}const Qp="codeyam.questionnaire.draft";function li(t){return`${Qp}:${t}`}function ak(t){if(t===null||typeof t!="object")return!1;const s=t;if(typeof s.step!="number"||!Number.isFinite(s.step)||typeof s.savedAt!="string"||s.designChatLaunched!==void 0&&typeof s.designChatLaunched!="boolean")return!1;const n=s.answers;if(n===null||typeof n!="object")return!1;const r=n;return!(!Array.isArray(r.appFormats)||!r.appFormats.every(a=>typeof a=="string")||typeof r.description!="string"||r.techStackId!==null&&typeof r.techStackId!="string"||r.designApproach!==null&&typeof r.designApproach!="string"||r.defaultDevice!==null&&typeof r.defaultDevice!="string")}function fa(t){try{const s=localStorage.getItem(li(t));if(s===null)return null;const n=JSON.parse(s);return ak(n)?n:null}catch{return null}}function ok(t,s){try{localStorage.setItem(li(t),JSON.stringify(s))}catch{}}function ik(t){try{localStorage.removeItem(li(t))}catch{}}function lk(){try{localStorage.removeItem(Qp)}catch{}}function ck(){const[t,s]=l.useState([]);return l.useEffect(()=>{fetch("/api/editor-stacks").then(n=>n.json()).then(s).catch(()=>{})},[]),{techStacks:t}}function dk(t,s,n){if(s.length===0||s.includes("other"))return"Strong";let r=!1,a=!1;const o=(n||"").toLowerCase();["swift","swiftui","healthkit","jetpack","native ios","ios native","android native","kotlin native","objective-c"].some(c=>o.includes(c))&&(a=!0);for(const c of s)c==="web"?t.naturalShape==="web"&&t.id!=="chrome-extension-react"&&(r=!0):c==="static"?t.naturalShape==="static-site"&&(r=!0):c==="mobile"?(t.naturalShape==="mobile-hybrid"||t.naturalShape==="native-mobile")&&(r=!0):c==="chrome-extension"?t.id==="chrome-extension-react"&&(r=!0):c==="mcpb"&&t.id==="go-web-mcpb"&&(r=!0);return r?a&&(t.id==="expo-react-native"||t.id==="capacitor-vite-react")?"Adjacent":"Strong":"Mismatch"}function Zp({dragActive:t,inputRef:s,onDragOver:n,onDragLeave:r,onDrop:a,onFilePick:o}){return e.jsxs("label",{onDragOver:n,onDragLeave:r,onDrop:a,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"var(--spacing-xl, 32px)",border:`2px dashed ${t?"var(--accent-active)":"var(--border-default)"}`,borderRadius:12,background:t?"var(--bg-elevated, rgba(255,255,255,0.03))":"var(--bg-input)",cursor:"pointer",textAlign:"center",gap:"var(--spacing-xs, 4px)"},children:[e.jsx("input",{ref:s,type:"file",multiple:!0,onChange:o,style:{display:"none"}}),e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500},children:"Drop files here, or click to choose"}),e.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"PNG, JPG, PDF, Markdown — anything that describes your design"})]})}const CR=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropLabel:Zp},Symbol.toStringTag,{value:"Module"}));function em({pending:t,onDescriptionChange:s,onRemove:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px)",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-input)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500},children:t.file.name}),e.jsx("button",{type:"button",onClick:()=>n(t.id),style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:"Remove"})]}),e.jsx("textarea",{value:t.description,onChange:r=>s(t.id,r.target.value),placeholder:"What does this file show? (optional)",rows:2,style:{width:"100%",padding:"var(--spacing-sm, 8px)",background:"var(--bg-default)",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-primary)",fontSize:"var(--text-xs, 12px)",resize:"vertical",outline:"none",fontFamily:"inherit"}})]})}const PR=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCard:em},Symbol.toStringTag,{value:"Module"}));function tm({pending:t,onDescriptionChange:s,onRemove:n}){return t.length===0?null:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)",marginTop:"var(--spacing-md, 12px)"},children:t.map(r=>e.jsx(em,{pending:r,onDescriptionChange:s,onRemove:n},r.id))})}const TR=Object.freeze(Object.defineProperty({__proto__:null,PendingFileList:tm},Symbol.toStringTag,{value:"Module"}));function sm({message:t}){return t?e.jsx("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-xs, 12px)"},children:t}):null}const AR=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveErrorMessage:sm},Symbol.toStringTag,{value:"Module"}));function nm({filenames:t}){return!t||t.length===0?null:e.jsxs("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--text-secondary)",fontSize:"var(--text-xs, 12px)"},children:["Added ",t.length," file",t.length===1?"":"s","."]})}const OR=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveSuccessMessage:nm},Symbol.toStringTag,{value:"Module"}));function rm({disabled:t,submitting:s,onClick:n}){return e.jsx("button",{type:"button",onClick:n,disabled:t,style:{marginTop:"var(--spacing-md, 12px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",background:t?"var(--bg-input)":"var(--accent-active)",color:t?"var(--text-muted)":"var(--text-on-accent, white)",border:t?"1px solid var(--border-default)":"1px solid var(--accent-active)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontWeight:500,cursor:t?"not-allowed":"pointer"},children:s?"Saving…":"Save assets"})}const RR=Object.freeze(Object.defineProperty({__proto__:null,SaveAssetsButton:rm},Symbol.toStringTag,{value:"Module"})),Il=1024*1024*1024;function ci({onAssetsSaved:t}){const[s,n]=l.useState([]),[r,a]=l.useState(!1),[o,i]=l.useState(null),[c,d]=l.useState(null),[u,h]=l.useState(!1),p=l.useRef(null),f=l.useCallback(y=>{d(null);const v=y.filter(j=>j.size>Il?(d(`${j.name} is larger than the ${Il/(1024*1024*1024)}GB safety ceiling`),!1):!0);n(j=>[...j,...v.map(w=>({id:`${w.name}-${w.size}-${Math.random().toString(36).slice(2)}`,file:w,description:""}))])},[]),m=l.useCallback(y=>{y.target.files&&f(Array.from(y.target.files)),y.target.value=""},[f]),b=l.useCallback((y,v)=>{n(j=>j.map(w=>w.id===y?{...w,description:v}:w))},[]),g=l.useCallback(y=>{n(v=>v.filter(j=>j.id!==y))},[]),x=l.useCallback(async()=>{if(s.length!==0){a(!0),d(null);try{const y=new FormData;for(const _ of s)y.append("description",_.description),y.append("file",_.file,_.file.name);const v=await fetch("/api/editor-design-assets",{method:"POST",body:y});if(!v.ok)throw new Error(v.status===413?"That file is too large to add.":`Could not save assets (status ${v.status}).`);const w=(await v.json()).written??s.map(_=>_.file.name);i(w),n([]),t==null||t(w)}catch(y){d(y instanceof Error?y.message:String(y))}finally{a(!1)}}},[s,t]);return e.jsxs(e.Fragment,{children:[e.jsx(Zp,{dragActive:u,inputRef:p,onDragOver:y=>{y.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:y=>{y.preventDefault(),h(!1),f(Array.from(y.dataTransfer.files))},onFilePick:m}),e.jsx(tm,{pending:s,onDescriptionChange:b,onRemove:g}),e.jsx(sm,{message:c}),e.jsx(nm,{filenames:o}),e.jsx(rm,{disabled:s.length===0||r,submitting:r,onClick:x})]})}const ER=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropZone:ci},Symbol.toStringTag,{value:"Module"}));function Ft({title:t,subtitle:s,children:n}){return e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"var(--text-xl, 22px)",fontWeight:700,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:t}),e.jsx("p",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-muted)",marginBottom:"var(--spacing-lg, 24px)"},children:s}),n]})}const MR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireStepPanel:Ft},Symbol.toStringTag,{value:"Module"}));function am({onAssetsSaved:t}){return e.jsx(Ft,{title:"Add your design files",subtitle:"Drop in anything: brand assets, mockups, references. Tell us briefly what each one shows.",children:e.jsx(ci,{onAssetsSaved:t})})}const IR=Object.freeze(Object.defineProperty({__proto__:null,DesignAddAssetsStep:am},Symbol.toStringTag,{value:"Module"}));function Rs({label:t,description:s,selected:n,onClick:r,multi:a}){return e.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",width:"100%",textAlign:"left",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",background:"var(--bg-input)",border:n?"1.5px solid var(--accent-active)":"1px solid var(--border-default)",borderRadius:8,cursor:"pointer",transition:"border-color 0.15s"},children:[e.jsx(om,{selected:n,multi:a}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:500,color:"var(--text-primary)"},children:t}),s&&e.jsx("span",{style:{display:"block",fontSize:"var(--text-xs, 12px)",color:"var(--text-muted)",marginTop:2},children:s})]})]})}function om({selected:t,multi:s}){return e.jsx("span",{style:{width:16,height:16,borderRadius:s?3:"50%",border:t?"none":"1.5px solid var(--text-dim)",background:t?"var(--accent-active)":"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:t&&e.jsx("span",{style:{color:"#000",fontSize:11,fontWeight:700,lineHeight:1},children:"✓"})})}const DR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireOptionCard:Rs,QuestionnaireOptionIndicator:om},Symbol.toStringTag,{value:"Module"})),uk=[{id:"files",label:"I have design files and/or a design system",description:"Add screenshots, mockups, brand guides — anything that defines the look you want."},{id:"chat",label:"I need help on this, can we chat about it?",description:"After setup we'll generate mockups against curated moodboards and you pick a direction."},{id:"skip",label:"I'm not too worried about design, can we start building?",description:"Skip design for now. You can revisit it any time."}];function im({selected:t,onSelect:s}){return e.jsx(Ft,{title:"How should we approach design?",subtitle:"Pick whichever feels right — you can always change direction later.",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:uk.map(n=>e.jsx(Rs,{label:n.label,description:n.description,selected:t===n.id,onClick:()=>s(n.id)},n.id))})})}const LR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignApproachStep:im},Symbol.toStringTag,{value:"Module"}));function lm(){const[t,s]=l.useState(()=>Mp());l.useEffect(()=>{zp()},[]);const n=a=>{s(a),Ip(a)},r=()=>{n({...t,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()};return e.jsx(Ft,{title:"Want to be notified when Claude finishes?",subtitle:"Building can take a while. Turn on a sound or a system notification and we'll ping you when the agent stops or pauses — so you can step away while it works.",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[e.jsx("button",{onClick:r,className:"text-left px-3 py-2 rounded cursor-pointer transition-colors",style:{background:t.systemNotification?"var(--bg-input)":"var(--accent-green, #16a34a)",color:t.systemNotification?"var(--text-primary)":"#fff",fontSize:"var(--text-sm, 14px)",fontWeight:600,border:"1px solid var(--border-default)"},children:t.systemNotification?"System notifications enabled":"Enable notifications"}),e.jsx("div",{className:"flex flex-col gap-3 rounded p-3",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:e.jsx(ri,{settings:t,onChange:n})}),e.jsx("p",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-dim)"},children:'This is optional — you can skip it and change it any time from the "Notifications" control in the footer.'})]})})}const FR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireNotificationsStep:lm},Symbol.toStringTag,{value:"Module"}));function hk(t,s){const n=l.useRef(s);l.useEffect(()=>{n.current=s},[s]),l.useEffect(()=>{if(!t)return;let r=!1,a=null;const o=async()=>{try{const c=await(await fetch("/api/editor-design-state")).json();!r&&c.active&&n.current(c.active)}catch{}finally{r||(a=window.setTimeout(o,3e3))}};return o(),()=>{r=!0,a!==null&&window.clearTimeout(a)}},[t])}function cm({providerLabel:t,preparing:s,onLaunch:n,variant:r="chat"}){const a=r==="files"?e.jsxs(e.Fragment,{children:["Click the button below to start a design session with ",t,"."," ",t," will turn the assets you added above into HTML mockups you can compare and iterate on."]}):e.jsxs(e.Fragment,{children:["Click the button below to launch a chat window with ",t," so that ",t," can generate some design options for you to consider and iterate on."]}),o=r==="files"?e.jsxs(e.Fragment,{children:[t," reads the design assets you added in the"," ",e.jsx("strong",{children:"Add your design files"})," step above — keep adding more any time and ",t," will fold them in."]}):e.jsxs(e.Fragment,{children:[t," will ask whether you have any design assets — logos, screenshots, brand guides, or inspiration. You can add them any time from the ",e.jsx("strong",{children:"Add assets"})," panel in the Live Preview on the right (drag-and-drop or browse)."]}),i=r==="files"?"Start a design session":`Launch ${t} Design Chat`;return e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 var(--spacing-md, 12px)",fontSize:"var(--text-md, 15px)",lineHeight:1.5,color:"var(--text-primary)"},children:a}),e.jsx("p",{style:{margin:"0 0 var(--spacing-lg, 16px)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5,color:"var(--text-secondary)"},children:o}),e.jsx("button",{onClick:n,disabled:s,style:{background:s?"var(--bg-surface)":"var(--accent-active)",border:"none",color:s?"var(--text-dim)":"#000",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:s?"not-allowed":"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:s?"Preparing design moodboards…":i})]})}const zR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatLaunchPanel:cm},Symbol.toStringTag,{value:"Module"}));function Va({description:t,launched:s,onLaunched:n,onDesignSelected:r,onPreviewUrl:a,variant:o="chat"}){const[i,c]=l.useState({kind:"preparing"}),{config:d}=St(),u=zt(d==null?void 0:d.provider),h=l.useRef(s),p=o==="chat"||s;l.useEffect(()=>{if(p)return a==null||a("/design-exploration"),()=>{a==null||a(null)}},[a,p]),l.useEffect(()=>{let x=!1;return(async()=>{try{const y=!h.current,[v,j,w]=await Promise.all([fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:t,allowOverwrite:!0})}),fetch("/api/editor-design-systems-install",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}),y?fetch("/api/editor-design-reset",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}):Promise.resolve(null)]);if(!j.ok){const _=await j.text().catch(()=>`${j.status}`);throw new Error(_||`install failed: ${j.status}`)}if(w&&!w.ok){const _=await w.text().catch(()=>`${w.status}`);throw new Error(_||`design-reset failed: ${w.status}`)}v.ok||console.warn("[QuestionnaireDesignChatStep] editor-project-info failed; skill will prompt for description",v.status),x||c({kind:"ready"})}catch(y){x||c({kind:"error",message:y instanceof Error?y.message:String(y)})}})(),()=>{x=!0}},[t]),hk(s,r);const f=i.kind==="preparing",m=o==="files"?"Turn your assets into a mockup":"Explore design directions",b=o==="files"?"Start a design session and the agent will turn the assets you uploaded into HTML mockups — pick one by number from the Live Preview.":"Chat with the agent, share any design assets, then pick a mockup by number from the Live Preview.",g=o==="files"?"Try Skip instead, or keep uploading assets and try again.":"Try the Files or Skip approach instead.";return e.jsx(Ft,{title:m,subtitle:b,children:s?e.jsx(vs,{chatName:"initial-design",slashCommand:"/codeyam-design",height:420}):i.kind==="error"?e.jsxs("div",{style:{padding:"var(--spacing-md, 12px)",marginBottom:"var(--spacing-sm, 8px)",borderRadius:8,background:"var(--bg-danger-soft, rgba(248,113,113,0.12))",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:["Couldn't prepare design moodboards: ",i.message,". ",g]}):e.jsx(cm,{providerLabel:u,preparing:f,onLaunch:n,variant:o})})}const $R=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatStep:Va},Symbol.toStringTag,{value:"Module"})),pk=[{id:"Desktop",label:"Desktop",description:"Standard desktop browser viewport"},{id:"Tablet",label:"Tablet",description:"Tablet-sized portrait viewport"},{id:"Mobile",label:"Mobile",description:"Phone-sized portrait viewport"}];function dm({selected:t,onSelect:s}){return e.jsx("div",{style:{marginTop:"var(--spacing-xl, 32px)"},children:e.jsx(Ft,{title:"Where will this web app primarily be viewed?",subtitle:"This sets the default viewport for every scenario captured in your project.",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:pk.map(n=>e.jsx(Rs,{label:n.label,description:n.description,selected:t===n.id,onClick:()=>s(n.id)},n.id))})})})}const BR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDeviceSelector:dm},Symbol.toStringTag,{value:"Module"}));function di(){return e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-subtle)",fontSize:"var(--text-sm, 14px)",color:"var(--text-muted)"},children:"Before we dive in, help us comprehend what you want to build better."})}const qR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireIntroBanner:di},Symbol.toStringTag,{value:"Module"}));function um({step:t,canAdvance:s,isFinalStep:n,isAdvancing:r,onBack:a,onNext:o,onFinish:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",marginTop:"var(--spacing-lg, 24px)"},children:[t>1&&e.jsx("button",{onClick:a,style:{background:"none",border:"1px solid var(--border-default)",color:"var(--text-secondary)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:"pointer",fontSize:"var(--text-sm, 14px)"},children:"← Back"}),n?e.jsx("button",{onClick:i,disabled:!s,style:{background:s?"var(--accent-active)":"var(--bg-surface)",border:"none",color:s?"#000":"var(--text-dim)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:s?"pointer":"not-allowed",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:"FINISH →"}):e.jsx("button",{onClick:o,disabled:!s||r,style:{background:s?"var(--accent-active)":"var(--bg-surface)",border:"none",color:s?"#000":"var(--text-dim)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:s&&!r?"pointer":"not-allowed",fontSize:"var(--text-sm, 14px)",fontWeight:600,opacity:r?.7:1},children:r?"…":"NEXT →"})]})}const HR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireNavButtons:um},Symbol.toStringTag,{value:"Module"}));function hm({currentStep:t,stepLabels:s,onStepClick:n}){return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",paddingTop:"var(--spacing-lg, 24px)"},children:s.map((r,a)=>{const o=a+1,i=o===t,c=o<t;return e.jsx("button",{onClick:()=>{c&&n(o)},style:{background:"none",border:"none",cursor:c?"pointer":"default",padding:"var(--spacing-xs, 4px) 0",fontSize:"var(--text-sm, 14px)",color:i?"var(--text-primary)":c?"var(--text-secondary)":"var(--text-dim)",fontWeight:i?500:400,textAlign:"left",transition:"color 0.15s"},children:r},o)})})}const WR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireStepNav:hm},Symbol.toStringTag,{value:"Module"})),mk=[{id:"web",label:"Website/Web App"},{id:"static",label:"Static Website"},{id:"desktop",label:"Desktop App"},{id:"mcpb",label:"Claude Desktop App (mcpb)"},{id:"chrome-extension",label:"Chrome Extension"},{id:"mobile",label:"Mobile App"},{id:"other",label:"Other"}],fk={"product-type":"What Type Of Product Do You Want To Build?",description:"Describe Your Product","tech-stack":"Do You Have A Preferred Tech Stack?",notifications:"Notifications","design-approach":"How Should We Approach Design","design-details":"Design Details"},Dl=560,gk=960;function pm(t){const{projectDir:s,loaded:n}=qc(),r=l.useRef(!1);return l.useEffect(()=>{n&&!r.current&&(r.current=!0,lk())},[n]),n?e.jsx(mm,{...t,projectDir:s}):e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:e.jsx(di,{})})}function mm({onComplete:t,onPreviewUrl:s,projectDir:n}){const[r,a]=l.useState(()=>{const P=n?fa(n):null;return P?P.step:1}),[o,i]=l.useState(()=>{const P=n?fa(n):null;return(P==null?void 0:P.answers)??{appFormats:[],description:"",techStackId:null,designApproach:null,defaultDevice:null}}),[c,d]=l.useState(null),[u,h]=l.useState(!1),[p,f]=l.useState(()=>{const P=n?fa(n):null;return(P==null?void 0:P.designChatLaunched)??!1}),m=l.useRef(p),{techStacks:b}=ck(),g=rk(o.designApproach),x=g[r-1],y=r===g.length,v=g.map(P=>fk[P]);l.useEffect(()=>{r>g.length&&a(g.length)},[r,g.length]);const j=l.useRef(!0);l.useEffect(()=>{if(j.current){j.current=!1;return}n!==null&&ok(n,{step:r,answers:o,designChatLaunched:p,savedAt:new Date().toISOString()})},[r,o,p,n]);const w=l.useCallback(()=>{f(!0)},[]),[_,S]=l.useState(m.current?{state:"pending"}:{state:"ready",active:null});l.useEffect(()=>{if(!m.current)return;let P=!1;return(async()=>{try{const A=await(await fetch("/api/editor-design-state")).json();P||S({state:"ready",active:A.active??null})}catch{P||S({state:"ready",active:null})}})(),()=>{P=!0}},[]);const C=l.useCallback(P=>{i(E=>{const A=E.appFormats.includes(P),H=A?E.appFormats.filter(G=>G!==P):[...E.appFormats,P],z=P==="web"&&A?null:E.defaultDevice;return{...E,appFormats:H,defaultDevice:z}})},[]),N=l.useCallback(P=>{i(E=>({...E,defaultDevice:P}))},[]),T=l.useCallback(P=>{i(E=>({...E,designApproach:E.designApproach===P?null:P}))},[]),O=l.useCallback(async()=>{await nk(o),n!==null&&ik(n),t==null||t(o)},[o,t,n]),k=l.useRef(!1);l.useEffect(()=>{k.current||_.state==="ready"&&x==="design-details"&&(o.designApproach==="chat"||o.designApproach==="files")&&c!==null&&c!==_.active&&(k.current=!0,O())},[x,o.designApproach,c,O,_]);const D=l.useCallback(()=>{a(P=>P+1)},[]),$=o.appFormats.includes("web"),B=(()=>{switch(x){case"product-type":return o.appFormats.length>0&&(!$||o.defaultDevice!==null);case"description":return o.description.trim().length>0;case"notifications":return!0;case"design-approach":return o.designApproach!==null;case"design-details":return o.designApproach==="chat"?c!==null:!0;default:return!0}})(),q=x==="description"?gk:x==="design-details"&&(o.designApproach==="chat"||o.designApproach==="files"&&p)?"100%":Dl;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:[e.jsx(di,{}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"var(--spacing-xl, 32px)"},children:[e.jsxs("div",{style:{maxWidth:q},children:[x==="product-type"&&e.jsxs(e.Fragment,{children:[e.jsx(Ft,{title:"What type of product do you want to build?",subtitle:"Select as many as you need.",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:mk.map(P=>e.jsx(Rs,{label:P.label,selected:o.appFormats.includes(P.id),onClick:()=>C(P.id),multi:!0},P.id))})}),$&&e.jsx(dm,{selected:o.defaultDevice,onSelect:N})]}),x==="description"&&e.jsx(Ft,{title:"Describe your product",subtitle:"What are you building? This helps us set up the right starting point.",children:e.jsx("textarea",{value:o.description,onChange:P=>i(E=>({...E,description:P.target.value})),placeholder:"e.g. A task management app for remote teams with real-time collaboration...",style:{width:"100%",minHeight:180,padding:"var(--spacing-md, 12px)",background:"var(--bg-input)",border:"1px solid var(--border-default)",borderRadius:8,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",resize:"vertical",outline:"none",fontFamily:"inherit"}})}),x==="tech-stack"&&(()=>{const P=b.map(A=>{const H=dk(A,o.appFormats,o.description);let z=A.name,G=A.description;return H==="Strong"?G=A.reasonStrong||A.description:H==="Adjacent"?(z=`${A.name} (Recommended — Closest Fit)`,G=A.reasonAdjacent||A.description):H==="Mismatch"&&(z=`${A.name} (Mismatch — Pivot Required)`,G=A.reasonMismatch||A.description),{stack:A,fit:H,label:z,description:G}}),E=P.filter(A=>A.fit!=="Mismatch"||u);return e.jsxs(Ft,{title:"Do you have a preferred tech stack?",subtitle:"Choose a starting template, or let CodeYam decide.",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:[e.jsx(Rs,{label:"Let CodeYam decide",description:"We'll pick the best stack based on your product",selected:o.techStackId===null,onClick:()=>i(A=>({...A,techStackId:null}))}),E.map(({stack:A,label:H,description:z})=>e.jsx(Rs,{label:H,description:z,selected:o.techStackId===A.id,onClick:()=>i(G=>({...G,techStackId:A.id}))},A.id))]}),P.some(A=>A.fit==="Mismatch")&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"var(--spacing-md, 12px)"},children:e.jsx("button",{type:"button",onClick:()=>h(A=>!A),style:{background:"none",border:"none",color:"var(--accent-active)",cursor:"pointer",fontSize:"var(--text-xs, 12px)",textDecoration:"underline",padding:0},children:u?"Hide incompatible stacks":"Show all stacks"})})]})})(),x==="notifications"&&e.jsx(lm,{}),x==="design-approach"&&e.jsx(im,{selected:o.designApproach,onSelect:T}),x==="design-details"&&o.designApproach==="files"&&e.jsxs(e.Fragment,{children:[e.jsx(am,{}),e.jsx(Va,{description:o.description,launched:p,onLaunched:w,onDesignSelected:d,onPreviewUrl:s,variant:"files"})]}),x==="design-details"&&o.designApproach==="chat"&&e.jsx(Va,{description:o.description,launched:p,onLaunched:w,onDesignSelected:d,onPreviewUrl:s})]}),e.jsxs("div",{style:{maxWidth:Dl},children:[e.jsx(um,{step:r,canAdvance:B,isFinalStep:y,onBack:()=>a(P=>P-1),onNext:()=>{B&&D()},onFinish:O}),e.jsx(hm,{currentStep:r,stepLabels:v,onStepClick:a})]})]})]})}const GR=Object.freeze(Object.defineProperty({__proto__:null,NewProjectQuestionnaire:pm,NewProjectQuestionnaireInner:mm},Symbol.toStringTag,{value:"Module"}));function fm({projectTitle:t,projectDescription:s,stats:n,coverage:r,onSelectApp:a,configLoading:o,scenariosLoading:i,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:h,stepState:p,onPreviewUrl:f,onComplete:m,onOpenBuildTab:b,onCoverageClick:g,isBuilding:x=!1,buildingLabel:y,buildingStepLabel:v,buildingStepIndicator:j,buildingStatus:w,buildingProgress:_,onResetBuild:S}){const{saved:C}=Bp();return n.length===0?o||i||C===null?null:qp({appStatsLength:n.length,configLoading:!!o,scenariosLoading:!!i,setupAnswersSaved:C,hasStepState:!!p})?e.jsx(pm,{onPreviewUrl:f,onComplete:m}):e.jsx(Up,{projectDescription:s??null,onOpenBuildTab:b??(()=>{})}):e.jsx("div",{className:"px-5 py-5",children:e.jsxs("div",{style:{width:"100%",maxWidth:1e3,marginInline:"auto"},children:[e.jsx(Vp,{projectTitle:t,coverage:r,onCoverageClick:g}),e.jsx(Xp,{isBuilding:x,buildingLabel:y,buildingStepLabel:v,buildingStepIndicator:j,buildingStatus:w,buildingProgress:_,buildingMode:p==null?void 0:p.mode,onOpenBuilding:b??(()=>{}),onResetBuild:S??(()=>{})}),e.jsx(Yp,{stats:n,onSelectApp:a,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:h})]})})}const UR=Object.freeze(Object.defineProperty({__proto__:null,AppOverview:fm},Symbol.toStringTag,{value:"Module"}));function gm({sessionContent:t,stepIndicator:s}){return e.jsxs("div",{className:"flex flex-col h-full",children:[s,t]})}const YR=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLayout:gm},Symbol.toStringTag,{value:"Module"}));function bm({activeTab:t,buildTab:s,footer:n,resultsPanel:r,minimizedResults:a,resultsMode:o}){return e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:t==="build"?"visible":"hidden",pointerEvents:t==="build"?"auto":"none"},children:[e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{style:{flex:o==="full"?"0 0 50%":"1 1 auto",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:s}),o==="full"?r:null,o==="minimized"?a:null]}),n]})}const VR=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPaneLayout:bm},Symbol.toStringTag,{value:"Module"}));function bk(t=!1){return{title:"Session Ready to Resume",description:t?"CodeYam saved this build session while it was waiting on the next workflow action. Review the current feature and step below, then click resume when you're ready to continue.":"CodeYam found a saved build session for this feature. Review the current feature and step below, then click resume when you're ready to continue.",buttonLabel:"Resume Session",providersLabel:null}}function xk(t,s){const n=zt(t),r=zt(s);return{title:"Saved Handoff Ready",description:`A ${n} 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:`${n} to ${r}`}}function yk({resumeMode:t,previousProvider:s,currentProvider:n,awaitingUserInput:r=!1}){return t!=="handoff"||s==null||n==null||s===n?bk(r):xk(s,n)}function xm({label:t,onContinue:s}){return e.jsx("button",{onClick:s,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer font-medium",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)"},children:t})}const KR=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryActionButton:xm},Symbol.toStringTag,{value:"Module"}));function ym({children:t}){return e.jsx("div",{className:"flex items-center justify-center h-full",role:"dialog","aria-modal":"true",style:{background:"var(--bg-deep)",color:"var(--text-secondary)"},children:e.jsx("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:t})})}const JR=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryDialog:ym},Symbol.toStringTag,{value:"Module"}));function vm({description:t,title:s}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",style:{color:"var(--text-primary)"},children:s}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--text-muted)"},children:t})]})}const XR=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryHeader:vm},Symbol.toStringTag,{value:"Module"}));function Qn({label:t,rowClassName:s,value:n}){return e.jsxs("div",{className:s,children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:[t,":"]})," ",e.jsx("span",{style:{color:"var(--text-primary)"},children:n})]})}const QR=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummaryRow:Qn},Symbol.toStringTag,{value:"Module"}));function jm({featureName:t,editorStep:s,editorStepLabel:n,providersLabel:r}){return e.jsxs("div",{className:"rounded p-3 mb-5 text-sm",style:{background:"var(--bg-deep)"},children:[t&&e.jsx(Qn,{label:"Feature",value:t,rowClassName:"mb-1"}),s!=null&&n&&e.jsx(Qn,{label:"Step",value:`${s} (${n})`}),r&&e.jsx(Qn,{label:"Providers",value:r,rowClassName:"mt-1"})]})}const ZR=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummary:jm},Symbol.toStringTag,{value:"Module"}));function vk(t){const s=l.useCallback(n=>{n.key==="Enter"&&(n.preventDefault(),t())},[t]);l.useEffect(()=>(window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)),[s])}function wm({featureName:t,editorStep:s,workflowMode:n,previousProvider:r,currentProvider:a,resumeMode:o,awaitingUserInput:i=!1,onContinue:c}){const d=yk({resumeMode:o,previousProvider:r,currentProvider:a,awaitingUserInput:i}),u=s==null?null:ai(s,n);return vk(c),e.jsxs(ym,{children:[e.jsx(vm,{title:d.title,description:d.description}),e.jsx(jm,{featureName:t,editorStep:s,editorStepLabel:u,providersLabel:d.providersLabel}),e.jsx(xm,{label:d.buttonLabel,onContinue:c})]})}const eE=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecovery:wm},Symbol.toStringTag,{value:"Module"}));function _m({awaitingUserInput:t,currentProvider:s,editorStep:n,featureName:r,onContinue:a,previousProvider:o,resumeMode:i,workflowMode:c}){return e.jsx(wm,{featureName:r,editorStep:n,workflowMode:c,previousProvider:o,currentProvider:s,resumeMode:i,awaitingUserInput:t,onContinue:a})}const tE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabRecoveryPanel:_m},Symbol.toStringTag,{value:"Module"}));function jk({sessionDecision:t,sessionInfo:s,buildLaunchGateArmed:n,stepState:r}){return{recoveryFeatureName:(r==null?void 0:r.feature)??(s==null?void 0:s.feature)??null,recoveryStep:(r==null?void 0:r.step)??(s==null?void 0:s.step)??null,recoveryMode:(r==null?void 0:r.mode)??(s==null?void 0:s.mode)??null,showTerminal:!n&&(t==="continue"||t==="fresh"||t==="no-session")&&(r!==null||s!==null),shouldResumeSameProvider:t==="continue"&&(s==null?void 0:s.resumeMode)==="resume"}}const Zn=8e3,wk="agent-banner-ready",_k="agent-auth-required";let lr=!1,cr=!1,It=[],Ll=!1,Ut=null,Kt=null,er=!1;function kk(){Ll||typeof window>"u"||(Ll=!0,window.addEventListener(wk,()=>{const t=!cr;if(t){cr=!0;const s=It;It=[];for(const n of s)n("banner")}if(er&&(er=!1,Kt&&Ut===null)){X("dispatch-rename-after-auth",{label:Kt.label,reason:"first-observed-frame-after-auth"}),Ut=Kt,ar(Kt.label,Kt.send);return}Ut&&(X("dispatch-rename-reapply",{label:Ut.label,reason:t?"first-observed-frame":"second-observed-frame"}),ar(Ut.label,Ut.send))}),window.addEventListener(_k,()=>{er=!0,X("agent-auth-required-observed",{});const t=It;It=[];for(const s of t)s("auth-required")}))}kk();function Sk(){return cr?Promise.resolve("banner"):new Promise(t=>{let s=!1;const n=a=>{s||(s=!0,clearTimeout(r),t(a))};It.push(n);const r=setTimeout(()=>{if(s)return;s=!0;const a=It.indexOf(n);a>=0&&It.splice(a,1),t("fallback")},Zn)})}async function km(t,s,n=0,r=ew,a=!1){if(lr){X("dispatch-rename-suppressed",{caller:s,label:t});return}lr=!0,Kt={label:t,send:r},X("dispatch-rename",{phase:"queued",caller:s,label:t,fallbackMs:Zn,postReadyDelayMs:n});const o=await Sk();if(o==="auth-required"){X("dispatch-rename-deferred-for-auth",{caller:s,label:t});return}if(a&&o==="fallback"){X("dispatch-rename-skipped-no-banner",{caller:s,label:t,fallbackMs:Zn});return}n>0&&await new Promise(i=>setTimeout(i,n)),o==="fallback"&&X("dispatch-rename-fallback",{caller:s,label:t,fallbackMs:Zn}),X("dispatch-rename",{phase:"fired",caller:s,label:t,source:o,postReadyDelayMs:n}),Ut={label:t,send:r},ar(t,r)}function Nk(){lr=!1,cr=!1,It=[],Ut=null,Kt=null,er=!1}function Ck(){lr=!1,It=[],Kt=null}const Pk="Editor";function Tk({provider:t,agentStartMode:s,currentFeature:n}){const r=l.useRef(!1);l.useEffect(()=>{if(!(r.current||t!=="claude"||s!=="fresh")){if(n!==null){r.current=!0;return}r.current=!0,km(Pk,"build-session-seed",Bc,void 0,!0)}},[t,s,n])}function Sm({snippet:t,onRetry:s,onDismiss:n}){return e.jsx("div",{"data-testid":"build-tab-startup-error",className:"border-b border-red-500/30 bg-red-950/40 text-red-100 px-4 py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm mb-1",children:"Claude didn't start"}),e.jsx("pre",{"data-testid":"build-tab-startup-error-snippet",className:"font-mono text-xs whitespace-pre-wrap break-words bg-black/40 text-red-50 px-2 py-1 rounded max-h-40 overflow-auto",children:t})]}),e.jsxs("div",{className:"flex items-start gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:s,"data-testid":"build-tab-startup-error-retry",className:"px-3 py-1.5 rounded bg-red-500 text-white text-sm font-medium cursor-pointer hover:bg-red-400",children:"Retry"}),e.jsx("button",{type:"button",onClick:n,"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 sE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabStartupError:Sm},Symbol.toStringTag,{value:"Module"}));function ui(t,s,n){l.useEffect(()=>{const r=o=>{const i=o.target;t.current&&t.current.contains(i)||n!=null&&n.current&&n.current.contains(i)||s()},a=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",a)}},[t,s,n])}function Nm(t=768){const s=`(max-width: ${t-.02}px)`,[n,r]=l.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(s).matches);return l.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia(s);r(a.matches);const o=i=>r(i.matches);return a.addEventListener("change",o),()=>a.removeEventListener("change",o)},[s]),n}const Cm=[{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 Pm({defaultOpen:t=!1}){return Nm()?e.jsx(Tm,{defaultOpen:t}):null}function Tm({defaultOpen:t=!1}){const{config:s}=St(),[n,r]=l.useState(t),a=l.useRef(null),o=l.useRef(null),i=l.useCallback(()=>r(!1),[]);ui(a,i,o);const c=s&&s.mobileTerminalCommands.length>0?s.mobileTerminalCommands:Cm,d=l.useCallback(u=>{u.submit?Pa(u.send):Ta(u.send),r(!1)},[]);return e.jsxs("div",{className:"absolute top-2 right-2 z-20 flex flex-col items-end",children:[e.jsx("button",{ref:o,type:"button","data-testid":"mobile-command-menu-toggle","aria-haspopup":"menu","aria-expanded":n,"aria-label":"Terminal commands",onClick:()=>r(u=>!u),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"}),n&&e.jsx("div",{ref:a,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:c.map((u,h)=>e.jsx("button",{type:"button",role:"menuitem","data-testid":`mobile-command-${h}`,onClick:()=>d(u),className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:u.label},`${u.label}-${h}`))})]})}const nE=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MOBILE_TERMINAL_COMMANDS:Cm,MobileTerminalCommandMenu:Pm,MobileTerminalCommandMenuPanel:Tm},Symbol.toStringTag,{value:"Module"})),Ak=1e3;let Ka=0;function $n(){Ka=Date.now()}function Ok(){return Ka===0?1/0:Date.now()-Ka}function Rk(){return Ok()<Ak}function hi(t,s,n=50){const r=l.useRef(s);r.current=s,l.useEffect(()=>{const a=t.current;if(!a)return;let o=null;const i=new ResizeObserver(c=>{o&&clearTimeout(o);const d=c[0];d&&(o=setTimeout(()=>{r.current(d)},n))});return i.observe(a),()=>{o&&clearTimeout(o),i.disconnect()}},[t,n])}const dr=20*1024*1024,Ek=3e4,Am=3e3;function Om(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>{const a=r.result;if(typeof a!="string"){n(new Error("Unexpected FileReader result"));return}const o=a.indexOf(",");s(o===-1?a:a.slice(o+1))},r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(t)})}function Mk(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`drop-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Rm(t){return/^[A-Za-z0-9._/\-]+$/.test(t)?t:`"${t.replace(/(["\\$`])/g,"\\$1")}"`}function Em(t){const s=t.items;if(!s||s.length===0||typeof s[0].webkitGetAsEntry!="function")return!1;for(const r of Array.from(s)){const a=r.webkitGetAsEntry();if(a&&a.isDirectory)return!0}return!1}function Ik({wsRef:t,insertInput:s}){const[n,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useRef(new Map),c=l.useRef(0);l.useEffect(()=>{if(a===null)return;const j=window.setTimeout(()=>o(null),Am);return()=>window.clearTimeout(j)},[a]);const d=l.useCallback(j=>{o(j)},[]),u=l.useCallback((j,w)=>{const _=i.current.get(j);_&&(i.current.delete(j),_.resolve(w))},[]),h=l.useCallback((j,w)=>{const _=i.current.get(j);_&&(i.current.delete(j),_.reject(w))},[]),p=l.useCallback(j=>{for(const[,w]of i.current)w.reject(j);i.current.clear()},[]),f=l.useCallback(async j=>{if(j.size>dr)throw new Error(`File too large (max ${dr/(1024*1024)} MB)`);const w=t.current;if(!w||w.readyState!==WebSocket.OPEN)throw new Error("Not connected — try again in a moment");const _=await Om(j),S=Mk(),C=new Promise((N,T)=>{const O=window.setTimeout(()=>{i.current.delete(S)&&T(new Error("Timed out waiting for save to complete"))},Ek);i.current.set(S,{resolve:k=>{window.clearTimeout(O),N(k)},reject:k=>{window.clearTimeout(O),T(new Error(k))}})});return w.send(JSON.stringify({type:"drop",id:S,name:j.name||"unnamed",mime:j.type||"application/octet-stream",data:_})),C},[t]),m=l.useCallback(async j=>{if(j.length===0)return;const w=[];for(const _ of j)try{w.push(await f(_))}catch(S){const C=S instanceof Error?S.message:String(S);d(`Attach failed: ${C}`);return}s(w.map(Rm).join(" ")+" ")},[f,d,s]),b=l.useCallback(j=>{j.dataTransfer.types.includes("Files")&&(j.preventDefault(),c.current+=1,r(!0))},[]),g=l.useCallback(j=>{j.dataTransfer.types.includes("Files")&&j.preventDefault()},[]),x=l.useCallback(j=>{j.dataTransfer.types.includes("Files")&&(c.current=Math.max(0,c.current-1),c.current===0&&r(!1))},[]),y=l.useCallback(async j=>{if(!j.dataTransfer.types.includes("Files"))return;if(j.preventDefault(),c.current=0,r(!1),Em(j.dataTransfer)){d("Folder drops are not supported — drag individual files instead");return}const w=Array.from(j.dataTransfer.files).filter(_=>_.size>0);await m(w)},[m,d]),v=l.useCallback(async j=>{var S;const w=(S=j.clipboardData)==null?void 0:S.items;if(!w)return;const _=[];for(const C of Array.from(w))if(C.kind==="file"&&C.type.startsWith("image/")){const N=C.getAsFile();N&&_.push(N)}_.length!==0&&(j.preventDefault(),await m(_))},[m]);return{dragActive:n,errorToast:a,dropHandlers:{onDragEnter:b,onDragOver:g,onDragLeave:x,onDrop:y},pasteHandler:v,resolveDrop:u,rejectDrop:h,cancelAllDrops:p,showError:d}}function pi(t){const[s,n]=l.useState(0);l.useEffect(()=>{if(s===0)return;const a=window.setTimeout(()=>n(0),t);return()=>window.clearTimeout(a)},[s,t]);const r=l.useCallback(()=>{n(a=>a+1)},[]);return[s>0,r]}function Dk(t=2e3){return new Promise(s=>{let n=!1,r=null;const a=i=>{if(!n){n=!0,clearTimeout(o);try{r==null||r.close()}catch{}s(i)}},o=setTimeout(()=>a(!1),t);try{const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/health`;r=new WebSocket(c),r.onmessage=()=>a(!0),r.onopen=()=>a(!0),r.onerror=()=>a(!1),r.onclose=()=>a(!1)}catch{a(!1)}})}function Lk(t){return t>=200&&t<300?"valid":t===401?"stale":"unreachable"}async function Mm(t=1500){try{const s=await fetch("/api/session-check",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(t)});return Lk(s.status)}catch{return"unreachable"}}async function Fk(){try{await fetch("/build",{credentials:"same-origin",cache:"no-store"})}catch{return!1}return await Mm()==="valid"}function zk({session:t,attempts:s,max:n}){return t!=="stale"?"check-transport":s<n?"reacquire":"give-up"}function Im(){return e.jsx("div",{"data-testid":"terminal-drop-overlay",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(30, 30, 30, 0.85)",color:"#D7FF63",fontFamily:"'IBM Plex Mono', monospace",fontSize:14,border:"2px dashed #D7FF63",borderRadius:6,pointerEvents:"none",zIndex:5},children:"Drop file to attach"})}const rE=Object.freeze(Object.defineProperty({__proto__:null,TerminalDropOverlay:Im},Symbol.toStringTag,{value:"Module"}));function Dm({message:t}){return e.jsx("div",{"data-testid":"terminal-drop-toast",style:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",background:"#3a1f1f",color:"#ff9494",border:"1px solid #7a3939",borderRadius:4,padding:"6px 12px",fontFamily:"'IBM Plex Mono', monospace",fontSize:12,zIndex:6,pointerEvents:"none"},children:t})}const aE=Object.freeze(Object.defineProperty({__proto__:null,TerminalDropToast:Dm},Symbol.toStringTag,{value:"Module"}));function zr(){return e.jsx("div",{"data-testid":"terminal-copied-toast",style:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",background:"#1f3a23",color:"#94ff94",border:"1px solid #397a39",borderRadius:4,padding:"6px 12px",fontFamily:"'IBM Plex Mono', monospace",fontSize:12,zIndex:6,pointerEvents:"none"},children:"Copied"})}const oE=Object.freeze(Object.defineProperty({__proto__:null,TerminalCopiedToast:zr},Symbol.toStringTag,{value:"Module"})),Fl=15,$k=3,Bk=2;function Lm({provider:t,agentStartMode:s,sessionId:n,onAgentIdle:r,onAgentActive:a,onUserInput:o,onStartupFailed:i,onStartupFailedCleared:c,suppressReconnectOnStopBuilding:d=!1,launchIntent:u=!1}){if(bt())return null;const h=l.useRef(null),p=l.useRef(null),f=l.useRef(null),m=l.useRef(null),b=l.useRef(!1),g=l.useRef(s??"fresh"),x=l.useRef(n??null),y=l.useRef(u),[v,j]=l.useState({kind:"connecting"}),[w,_]=l.useState(0),[S,C]=pi(1200);l.useEffect(()=>{g.current=s??"fresh",x.current=n??null,y.current=u},[s,n,u]);const N=l.useRef(r);N.current=r;const T=l.useRef(a);T.current=a;const O=l.useRef(o);O.current=o;const k=l.useRef(i);k.current=i;const D=l.useRef(c);D.current=c;const $=Ik({wsRef:m,insertInput:P=>{var E,A;((E=m.current)==null?void 0:E.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:P})),$n(),(A=O.current)==null||A.call(O)}}),B=l.useRef($);B.current=$;const q=l.useCallback(P=>{var E;return((E=m.current)==null?void 0:E.readyState)===WebSocket.OPEN?(m.current.send(JSON.stringify({type:"input",data:P})),!0):!1},[]);return tw(q,v.kind==="open"),hi(h,()=>{var P;f.current&&p.current&&(f.current.fit(),((P=m.current)==null?void 0:P.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:p.current.cols,rows:p.current.rows})))}),l.useEffect(()=>{if(!h.current||b.current)return;b.current=!0;const P=new ko.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),E=new So.FitAddon;P.loadAddon(E),P.open(h.current),p.current=P,f.current=E;const A=No(P,h.current,{onError:W=>B.current.showError(W),onCopy:()=>C()}),H=Co(P,{sendInput:W=>{var Y,V;((Y=m.current)==null?void 0:Y.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:W})),$n(),(V=O.current)==null||V.call(O)}});requestAnimationFrame(()=>{E.fit(),P.focus()});let z=!1,G=0,Q=!1,se=0,le=0,re=null;function U(){Q=!1;try{const W=new WebSocket(rw({provider:t,mode:g.current,sessionId:x.current??void 0,launch:y.current,cols:P.cols,rows:P.rows}));m.current=W,W.binaryType="arraybuffer",W.onmessage=Y=>{var V,pe,ue,ve;if(Y.data instanceof ArrayBuffer)P.write(new Uint8Array(Y.data));else if(typeof Y.data=="string")try{const Z=JSON.parse(Y.data);if(Z.type==="error"){z=!0,j({kind:"server-error",message:aw(Z)});return}if(Z.type==="session-id")g.current="resume",x.current=Z.sessionId??null;else if(Z.type==="agent-idle"||Z.type==="claude-idle"){const Te=typeof Z.source=="string"?Z.source:void 0;X("ws-message-received",{type:Z.type,source:Te}),(V=N.current)==null||V.call(N,Te)}else if(Z.type==="agent-active"||Z.type==="claude-active")X("ws-message-received-active",{type:Z.type}),(pe=T.current)==null||pe.call(T);else if(Z.type==="idle-diag"){const{site:Te,event:ae,...xe}=Z;X(`rust:${ae??"unknown"}`,{site:Te,...xe})}else Z.type==="drop-complete"?B.current.resolveDrop(String(Z.id??""),String(Z.path??"")):Z.type==="drop-error"?B.current.rejectDrop(String(Z.id??""),String(Z.message??"drop failed")):Z.type==="startup-failed"?(ue=k.current)==null||ue.call(k,String(Z.snippet??"")):Z.type==="startup-failed-cleared"?(ve=D.current)==null||ve.call(D):Z.type==="agent-banner-ready"?(X("agent-banner-ready",{}),window.dispatchEvent(new CustomEvent("agent-banner-ready"))):Z.type==="agent-auth-required"?(X("agent-auth-required",{}),window.dispatchEvent(new CustomEvent("agent-auth-required"))):Z.type==="agent-auth-resolved"&&(X("agent-auth-resolved",{}),window.dispatchEvent(new CustomEvent("agent-auth-resolved")))}catch{}},W.onopen=()=>{G=0,Q=!0,se=0,le=0,j({kind:"open"}),X("ws-open"),W.send(JSON.stringify({type:"resize",cols:P.cols,rows:P.rows}));try{typeof localStorage<"u"&&localStorage.getItem("codeyam.idleDebug")==="1"&&(W.send(JSON.stringify({type:"enable-idle-diag",sessionId:Ao()})),X("idle-diag-enabled"))}catch{}},W.onerror=()=>{},W.onclose=async()=>{if(X("ws-close",{reconnectAttempts:G}),B.current.cancelAllDrops("Not connected"),z){j(V=>V.kind==="server-error"?V:{kind:"ended"}),P.writeln(`\r
19
- \x1B[90m[Terminal session ended]\x1B[0m`);return}const Y=await ow();if(!z){if(!Y){j({kind:"server-stopped"}),re==null||re(),re=iw(2e3,()=>{z||window.location.reload()});return}if(Q)se=0;else{se++;const V=await Mm();if(z)return;const pe=zk({session:V,attempts:le,max:Bk});if(pe==="reacquire"){le++,j({kind:"session-stale"});const ve=await Fk();if(z)return;if(ve){se=0,U();return}j({kind:"session-stale",canRetry:!0});return}if(pe==="give-up"){j({kind:"session-stale",canRetry:!0});return}const ue=await Dk();if(z)return;if(!ue||se>=$k){j({kind:"edge-unreachable"});return}}if(G<Fl){const V=G<4?1e3*Math.pow(2,G):1e4;G++,j({kind:"reconnecting",attempt:G,maxAttempts:Fl}),setTimeout(()=>{z||U()},V)}else j({kind:"failed"})}}}catch{j({kind:"failed"})}}try{E.fit()}catch{}U();let ge=0;const ie=1e3;function be(){var Y;const W=Date.now();W-ge>=ie&&((Y=m.current)==null?void 0:Y.readyState)===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"browser-activity"})),ge=W)}document.addEventListener("mousemove",be),document.addEventListener("keydown",be),document.addEventListener("mousedown",be),P.onData(W=>{var Y,V;((Y=m.current)==null?void 0:Y.readyState)===WebSocket.OPEN?m.current.send(JSON.stringify({type:"input",data:W})):_(pe=>pe+1),$n(),(V=O.current)==null||V.call(O)});const K=h.current;function L(W){var Z,Te,ae,xe;const Y=W,V=(Z=Y.clipboardData)==null?void 0:Z.items;if(V){for(const Ne of Array.from(V))if(Ne.kind==="file"&&Ne.type.startsWith("image/")){W.preventDefault(),W.stopPropagation(),B.current.pasteHandler(Y);return}}const pe=((Te=Y.clipboardData)==null?void 0:Te.getData("text"))??"";if(!pe)return;W.preventDefault(),W.stopPropagation();const ue=pe.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),ve=P.modes.bracketedPasteMode?`\x1B[200~${ue}\x1B[201~`:ue;((ae=m.current)==null?void 0:ae.readyState)===WebSocket.OPEN?m.current.send(JSON.stringify({type:"input",data:ve})):_(Ne=>Ne+1),$n(),(xe=O.current)==null||xe.call(O)}K.addEventListener("paste",L,!0);function I(W){var pe,ue;const Y=W.detail;if(!Y)return;((pe=m.current)==null?void 0:pe.readyState)===WebSocket.OPEN?((ue=m.current)==null||ue.send(JSON.stringify({type:"input",data:Y})),X("terminal-send-input",{len:Y.length,firstChars:Y.slice(0,16),wsOpen:!0,dropped:!1})):X("terminal-send-input",{len:Y.length,firstChars:Y.slice(0,16),wsOpen:!1,dropped:!0})}window.addEventListener("terminal-send-input",I),sw();function F(){Po(),P.focus()}window.addEventListener("terminal-focus",F);function te(){var W;z=!0,(W=m.current)==null||W.close(),j({kind:"ended"}),P.reset()}return d&&window.addEventListener("build-session-stopped",te),()=>{var W;z=!0,re==null||re(),re=null,document.removeEventListener("mousemove",be),document.removeEventListener("keydown",be),document.removeEventListener("mousedown",be),window.removeEventListener("terminal-send-input",I),lw(),window.removeEventListener("terminal-focus",F),d&&window.removeEventListener("build-session-stopped",te),K.removeEventListener("paste",L,!0),H(),(W=m.current)==null||W.close(),A(),P.dispose(),b.current=!1}},[t]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},"data-terminal-emulator":!0,onDragEnter:$.dropHandlers.onDragEnter,onDragOver:$.dropHandlers.onDragOver,onDragLeave:$.dropHandlers.onDragLeave,onDrop:$.dropHandlers.onDrop,onPaste:$.pasteHandler,children:[e.jsx("div",{ref:h,className:"flex-1",tabIndex:-1,style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3,outline:"none"},onPointerDown:()=>{gl(h.current,()=>{var P;return(P=p.current)==null?void 0:P.focus()})},onClick:()=>{gl(h.current,()=>{var P;return(P=p.current)==null?void 0:P.focus()})}}),$.dragActive&&e.jsx(Im,{}),$.errorToast&&e.jsx(Dm,{message:$.errorToast}),S&&e.jsx(zr,{}),e.jsx(nw,{status:v,pulseKey:w,onRefresh:()=>window.location.reload()})]})}const iE=Object.freeze(Object.defineProperty({__proto__:null,TerminalEmulator:Lm},Symbol.toStringTag,{value:"Module"}));function Fm({onAgentActive:t,onAgentIdle:s,onUserInput:n,provider:r,sessionId:a,shouldResumeSameProvider:o,currentFeature:i}){const[c,d]=l.useState(null),[u,h]=l.useState(0);Tk({provider:r,agentStartMode:o?"resume":"fresh",currentFeature:i}),l.useEffect(()=>()=>{Nk()},[]);const p=l.useCallback(b=>{d(b)},[]),f=l.useCallback(()=>{d(null)},[]),m=l.useCallback(()=>{d(null),h(b=>b+1)},[]);return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[c!==null&&e.jsx(Sm,{snippet:c,onRetry:m,onDismiss:f}),e.jsxs("div",{className:"relative flex flex-col flex-1 min-h-0",children:[e.jsx(Lm,{provider:r,agentStartMode:o?"resume":"fresh",sessionId:o?a:null,onAgentIdle:s,onAgentActive:t,onUserInput:n,onStartupFailed:p,onStartupFailedCleared:f,suppressReconnectOnStopBuilding:!0,launchIntent:!0},u),e.jsx(Pm,{}),e.jsx("div",{className:"absolute top-2 left-2 z-20 md:left-auto md:right-2",children:e.jsx(cw,{className:"rounded-full bg-gray-800/90 px-3 py-1.5 shadow-lg ring-1 ring-white/10 backdrop-blur"})})]})]})}const lE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabTerminalSession:Fm},Symbol.toStringTag,{value:"Module"}));function qk(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return l.useMemo(()=>r=>{s.forEach(a=>a(r))},s)}const $r=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Bs(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function mi(t){return"nodeType"in t}function at(t){var s,n;return t?Bs(t)?t:mi(t)&&(s=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?s:window:window}function fi(t){const{Document:s}=at(t);return t instanceof s}function vn(t){return Bs(t)?!1:t instanceof at(t).HTMLElement}function zm(t){return t instanceof at(t).SVGElement}function qs(t){return t?Bs(t)?t.document:mi(t)?fi(t)?t:vn(t)||zm(t)?t.ownerDocument:document:document:document}const kt=$r?l.useLayoutEffect:l.useEffect;function gi(t){const s=l.useRef(t);return kt(()=>{s.current=t}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return s.current==null?void 0:s.current(...r)},[])}function Hk(){const t=l.useRef(null),s=l.useCallback((r,a)=>{t.current=setInterval(r,a)},[]),n=l.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,n]}function dn(t,s){s===void 0&&(s=[t]);const n=l.useRef(t);return kt(()=>{n.current!==t&&(n.current=t)},s),n}function jn(t,s){const n=l.useRef();return l.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...s])}function ur(t){const s=gi(t),n=l.useRef(null),r=l.useCallback(a=>{a!==n.current&&(s==null||s(a,n.current)),n.current=a},[]);return[n,r]}function Ja(t){const s=l.useRef();return l.useEffect(()=>{s.current=t},[t]),s.current}let ga={};function wn(t,s){return l.useMemo(()=>{if(s)return s;const n=ga[t]==null?0:ga[t]+1;return ga[t]=n,t+"-"+n},[t,s])}function $m(t){return function(s){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((o,i)=>{const c=Object.entries(i);for(const[d,u]of c){const h=o[d];h!=null&&(o[d]=h+t*u)}return o},{...s})}}const Es=$m(1),un=$m(-1);function Wk(t){return"clientX"in t&&"clientY"in t}function bi(t){if(!t)return!1;const{KeyboardEvent:s}=at(t.target);return s&&t instanceof s}function Gk(t){if(!t)return!1;const{TouchEvent:s}=at(t.target);return s&&t instanceof s}function Xa(t){if(Gk(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:n}=t.touches[0];return{x:s,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:n}=t.changedTouches[0];return{x:s,y:n}}}return Wk(t)?{x:t.clientX,y:t.clientY}:null}const hn=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:n}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:n}=t;return"scaleX("+s+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[hn.Translate.toString(t),hn.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:n,easing:r}=t;return s+" "+n+"ms "+r}}}),zl="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Uk(t){return t.matches(zl)?t:t.querySelector(zl)}const Yk={display:"none"};function Vk(t){let{id:s,value:n}=t;return nt.createElement("div",{id:s,style:Yk},n)}function Kk(t){let{id:s,announcement:n,ariaLiveType:r="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return nt.createElement("div",{id:s,style:a,role:"status","aria-live":r,"aria-atomic":!0},n)}function Jk(){const[t,s]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&s(r)},[]),announcement:t}}const Bm=l.createContext(null);function Xk(t){const s=l.useContext(Bm);l.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(t)},[t,s])}function Qk(){const[t]=l.useState(()=>new Set),s=l.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[l.useCallback(r=>{let{type:a,event:o}=r;t.forEach(i=>{var c;return(c=i[a])==null?void 0:c.call(i,o)})},[t]),s]}const Zk={draggable:`
20
- To pick up a draggable item, press the space bar.
21
- While dragging, use the arrow keys to move the item.
22
- Press space again to drop the item in its new position, or press escape to cancel.
23
- `},eS={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was moved over droppable area "+n.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was dropped over droppable area "+n.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function tS(t){let{announcements:s=eS,container:n,hiddenTextDescribedById:r,screenReaderInstructions:a=Zk}=t;const{announce:o,announcement:i}=Jk(),c=wn("DndLiveRegion"),[d,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),Xk(l.useMemo(()=>({onDragStart(p){let{active:f}=p;o(s.onDragStart({active:f}))},onDragMove(p){let{active:f,over:m}=p;s.onDragMove&&o(s.onDragMove({active:f,over:m}))},onDragOver(p){let{active:f,over:m}=p;o(s.onDragOver({active:f,over:m}))},onDragEnd(p){let{active:f,over:m}=p;o(s.onDragEnd({active:f,over:m}))},onDragCancel(p){let{active:f,over:m}=p;o(s.onDragCancel({active:f,over:m}))}}),[o,s])),!d)return null;const h=nt.createElement(nt.Fragment,null,nt.createElement(Vk,{id:r,value:a.draggable}),nt.createElement(Kk,{id:c,announcement:i}));return n?gs.createPortal(h,n):h}var Fe;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Fe||(Fe={}));function hr(){}function $l(t,s){return l.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function sS(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return l.useMemo(()=>[...s].filter(r=>r!=null),[...s])}const gt=Object.freeze({x:0,y:0});function qm(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function Hm(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return n-r}function nS(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return r-n}function Bl(t){let{left:s,top:n,height:r,width:a}=t;return[{x:s,y:n},{x:s+a,y:n},{x:s,y:n+r},{x:s+a,y:n+r}]}function Wm(t,s){if(!t||t.length===0)return null;const[n]=t;return n[s]}function ql(t,s,n){return s===void 0&&(s=t.left),n===void 0&&(n=t.top),{x:s+t.width*.5,y:n+t.height*.5}}const rS=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=ql(s,s.left,s.top),o=[];for(const i of r){const{id:c}=i,d=n.get(c);if(d){const u=qm(ql(d),a);o.push({id:c,data:{droppableContainer:i,value:u}})}}return o.sort(Hm)},aS=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=Bl(s),o=[];for(const i of r){const{id:c}=i,d=n.get(c);if(d){const u=Bl(d),h=a.reduce((f,m,b)=>f+qm(u[b],m),0),p=Number((h/4).toFixed(4));o.push({id:c,data:{droppableContainer:i,value:p}})}}return o.sort(Hm)};function oS(t,s){const n=Math.max(s.top,t.top),r=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),i=a-r,c=o-n;if(r<a&&n<o){const d=s.width*s.height,u=t.width*t.height,h=i*c,p=h/(d+u-h);return Number(p.toFixed(4))}return 0}const iS=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=[];for(const o of r){const{id:i}=o,c=n.get(i);if(c){const d=oS(c,s);d>0&&a.push({id:i,data:{droppableContainer:o,value:d}})}}return a.sort(nS)};function lS(t,s,n){return{...t,scaleX:s&&n?s.width/n.width:1,scaleY:s&&n?s.height/n.height:1}}function Gm(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:gt}function cS(t){return function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];return a.reduce((i,c)=>({...i,top:i.top+t*c.y,bottom:i.bottom+t*c.y,left:i.left+t*c.x,right:i.right+t*c.x}),{...n})}}const dS=cS(1);function uS(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function hS(t,s,n){const r=uS(s);if(!r)return t;const{scaleX:a,scaleY:o,x:i,y:c}=r,d=t.left-i-(1-a)*parseFloat(n),u=t.top-c-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),h=a?t.width/a:t.width,p=o?t.height/o:t.height;return{width:h,height:p,top:u,right:d+h,bottom:u+p,left:d}}const pS={ignoreTransform:!1};function Hs(t,s){s===void 0&&(s=pS);let n=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:h}=at(t).getComputedStyle(t);u&&(n=hS(n,u,h))}const{top:r,left:a,width:o,height:i,bottom:c,right:d}=n;return{top:r,left:a,width:o,height:i,bottom:c,right:d}}function Hl(t){return Hs(t,{ignoreTransform:!0})}function mS(t){const s=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:s,bottom:n,width:s,height:n}}function fS(t,s){return s===void 0&&(s=at(t).getComputedStyle(t)),s.position==="fixed"}function gS(t,s){s===void 0&&(s=at(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=s[a];return typeof o=="string"?n.test(o):!1})}function Br(t,s){const n=[];function r(a){if(s!=null&&n.length>=s||!a)return n;if(fi(a)&&a.scrollingElement!=null&&!n.includes(a.scrollingElement))return n.push(a.scrollingElement),n;if(!vn(a)||zm(a)||n.includes(a))return n;const o=at(t).getComputedStyle(a);return a!==t&&gS(a,o)&&n.push(a),fS(a,o)?n:r(a.parentNode)}return t?r(t):n}function Um(t){const[s]=Br(t,1);return s??null}function ba(t){return!$r||!t?null:Bs(t)?t:mi(t)?fi(t)||t===qs(t).scrollingElement?window:vn(t)?t:null:null}function Ym(t){return Bs(t)?t.scrollX:t.scrollLeft}function Vm(t){return Bs(t)?t.scrollY:t.scrollTop}function Qa(t){return{x:Ym(t),y:Vm(t)}}var ze;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ze||(ze={}));function Km(t){return!$r||!t?!1:t===document.scrollingElement}function Jm(t){const s={x:0,y:0},n=Km(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},a=t.scrollTop<=s.y,o=t.scrollLeft<=s.x,i=t.scrollTop>=r.y,c=t.scrollLeft>=r.x;return{isTop:a,isLeft:o,isBottom:i,isRight:c,maxScroll:r,minScroll:s}}const bS={x:.2,y:.2};function xS(t,s,n,r,a){let{top:o,left:i,right:c,bottom:d}=n;r===void 0&&(r=10),a===void 0&&(a=bS);const{isTop:u,isBottom:h,isLeft:p,isRight:f}=Jm(t),m={x:0,y:0},b={x:0,y:0},g={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+g.height?(m.y=ze.Backward,b.y=r*Math.abs((s.top+g.height-o)/g.height)):!h&&d>=s.bottom-g.height&&(m.y=ze.Forward,b.y=r*Math.abs((s.bottom-g.height-d)/g.height)),!f&&c>=s.right-g.width?(m.x=ze.Forward,b.x=r*Math.abs((s.right-g.width-c)/g.width)):!p&&i<=s.left+g.width&&(m.x=ze.Backward,b.x=r*Math.abs((s.left+g.width-i)/g.width)),{direction:m,speed:b}}function yS(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:i}=window;return{top:0,left:0,right:o,bottom:i,width:o,height:i}}const{top:s,left:n,right:r,bottom:a}=t.getBoundingClientRect();return{top:s,left:n,right:r,bottom:a,width:t.clientWidth,height:t.clientHeight}}function Xm(t){return t.reduce((s,n)=>Es(s,Qa(n)),gt)}function vS(t){return t.reduce((s,n)=>s+Ym(n),0)}function jS(t){return t.reduce((s,n)=>s+Vm(n),0)}function wS(t,s){if(s===void 0&&(s=Hs),!t)return;const{top:n,left:r,bottom:a,right:o}=s(t);Um(t)&&(a<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const _S=[["x",["left","right"],vS],["y",["top","bottom"],jS]];class xi{constructor(s,n){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=Br(n),a=Xm(r);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,i,c]of _S)for(const d of i)Object.defineProperty(this,d,{get:()=>{const u=c(r),h=a[o]-u;return this.rect[d]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class nn{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=s}add(s,n,r){var a;(a=this.target)==null||a.addEventListener(s,n,r),this.listeners.push([s,n,r])}}function kS(t){const{EventTarget:s}=at(t);return t instanceof s?t:qs(t)}function xa(t,s){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof s=="number"?Math.sqrt(n**2+r**2)>s:"x"in s&&"y"in s?n>s.x&&r>s.y:"x"in s?n>s.x:"y"in s?r>s.y:!1}var ut;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ut||(ut={}));function Wl(t){t.preventDefault()}function SS(t){t.stopPropagation()}var fe;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(fe||(fe={}));const Qm={start:[fe.Space,fe.Enter],cancel:[fe.Esc],end:[fe.Space,fe.Enter,fe.Tab]},NS=(t,s)=>{let{currentCoordinates:n}=s;switch(t.code){case fe.Right:return{...n,x:n.x+25};case fe.Left:return{...n,x:n.x-25};case fe.Down:return{...n,y:n.y+25};case fe.Up:return{...n,y:n.y-25}}};class yi{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:n}}=s;this.props=s,this.listeners=new nn(qs(n)),this.windowListeners=new nn(at(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ut.Resize,this.handleCancel),this.windowListeners.add(ut.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ut.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:n}=this.props,r=s.node.current;r&&wS(r),n(gt)}handleKeyDown(s){if(bi(s)){const{active:n,context:r,options:a}=this.props,{keyboardCodes:o=Qm,coordinateGetter:i=NS,scrollBehavior:c="smooth"}=a,{code:d}=s;if(o.end.includes(d)){this.handleEnd(s);return}if(o.cancel.includes(d)){this.handleCancel(s);return}const{collisionRect:u}=r.current,h=u?{x:u.left,y:u.top}:gt;this.referenceCoordinates||(this.referenceCoordinates=h);const p=i(s,{active:n,context:r.current,currentCoordinates:h});if(p){const f=un(p,h),m={x:0,y:0},{scrollableAncestors:b}=r.current;for(const g of b){const x=s.code,{isTop:y,isRight:v,isLeft:j,isBottom:w,maxScroll:_,minScroll:S}=Jm(g),C=yS(g),N={x:Math.min(x===fe.Right?C.right-C.width/2:C.right,Math.max(x===fe.Right?C.left:C.left+C.width/2,p.x)),y:Math.min(x===fe.Down?C.bottom-C.height/2:C.bottom,Math.max(x===fe.Down?C.top:C.top+C.height/2,p.y))},T=x===fe.Right&&!v||x===fe.Left&&!j,O=x===fe.Down&&!w||x===fe.Up&&!y;if(T&&N.x!==p.x){const k=g.scrollLeft+f.x,D=x===fe.Right&&k<=_.x||x===fe.Left&&k>=S.x;if(D&&!f.y){g.scrollTo({left:k,behavior:c});return}D?m.x=g.scrollLeft-k:m.x=x===fe.Right?g.scrollLeft-_.x:g.scrollLeft-S.x,m.x&&g.scrollBy({left:-m.x,behavior:c});break}else if(O&&N.y!==p.y){const k=g.scrollTop+f.y,D=x===fe.Down&&k<=_.y||x===fe.Up&&k>=S.y;if(D&&!f.x){g.scrollTo({top:k,behavior:c});return}D?m.y=g.scrollTop-k:m.y=x===fe.Down?g.scrollTop-_.y:g.scrollTop-S.y,m.y&&g.scrollBy({top:-m.y,behavior:c});break}}this.handleMove(s,Es(un(p,this.referenceCoordinates),m))}}}handleMove(s,n){const{onMove:r}=this.props;s.preventDefault(),r(n)}handleEnd(s){const{onEnd:n}=this.props;s.preventDefault(),this.detach(),n()}handleCancel(s){const{onCancel:n}=this.props;s.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}yi.activators=[{eventName:"onKeyDown",handler:(t,s,n)=>{let{keyboardCodes:r=Qm,onActivation:a}=s,{active:o}=n;const{code:i}=t.nativeEvent;if(r.start.includes(i)){const c=o.activatorNode.current;return c&&t.target!==c?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function Gl(t){return!!(t&&"distance"in t)}function Ul(t){return!!(t&&"delay"in t)}class vi{constructor(s,n,r){var a;r===void 0&&(r=kS(s.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=s,this.events=n;const{event:o}=s,{target:i}=o;this.props=s,this.events=n,this.document=qs(i),this.documentListeners=new nn(this.document),this.listeners=new nn(r),this.windowListeners=new nn(at(i)),this.initialCoordinates=(a=Xa(o))!=null?a:gt,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:s,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(ut.Resize,this.handleCancel),this.windowListeners.add(ut.DragStart,Wl),this.windowListeners.add(ut.VisibilityChange,this.handleCancel),this.windowListeners.add(ut.ContextMenu,Wl),this.documentListeners.add(ut.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ul(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Gl(n)){this.handlePending(n);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(s,n){const{active:r,onPending:a}=this.props;a(r,s,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:s}=this,{onStart:n}=this.props;s&&(this.activated=!0,this.documentListeners.add(ut.Click,SS,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ut.SelectionChange,this.removeTextSelection),n(s))}handleMove(s){var n;const{activated:r,initialCoordinates:a,props:o}=this,{onMove:i,options:{activationConstraint:c}}=o;if(!a)return;const d=(n=Xa(s))!=null?n:gt,u=un(a,d);if(!r&&c){if(Gl(c)){if(c.tolerance!=null&&xa(u,c.tolerance))return this.handleCancel();if(xa(u,c.distance))return this.handleStart()}if(Ul(c)&&xa(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}s.cancelable&&s.preventDefault(),i(d)}handleEnd(){const{onAbort:s,onEnd:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleCancel(){const{onAbort:s,onCancel:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleKeydown(s){s.code===fe.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const CS={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ji extends vi{constructor(s){const{event:n}=s,r=qs(n.target);super(s,CS,r)}}ji.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const PS={move:{name:"mousemove"},end:{name:"mouseup"}};var Za;(function(t){t[t.RightClick=2]="RightClick"})(Za||(Za={}));class TS extends vi{constructor(s){super(s,PS,qs(s.event.target))}}TS.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;return n.button===Za.RightClick?!1:(r==null||r({event:n}),!0)}}];const ya={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class AS extends vi{constructor(s){super(s,ya)}static setup(){return window.addEventListener(ya.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(ya.move.name,s)};function s(){}}}AS.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;const{touches:a}=n;return a.length>1?!1:(r==null||r({event:n}),!0)}}];var rn;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(rn||(rn={}));var pr;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(pr||(pr={}));function OS(t){let{acceleration:s,activator:n=rn.Pointer,canScroll:r,draggingRect:a,enabled:o,interval:i=5,order:c=pr.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:h,delta:p,threshold:f}=t;const m=ES({delta:p,disabled:!o}),[b,g]=Hk(),x=l.useRef({x:0,y:0}),y=l.useRef({x:0,y:0}),v=l.useMemo(()=>{switch(n){case rn.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case rn.DraggableRect:return a}},[n,a,d]),j=l.useRef(null),w=l.useCallback(()=>{const S=j.current;if(!S)return;const C=x.current.x*y.current.x,N=x.current.y*y.current.y;S.scrollBy(C,N)},[]),_=l.useMemo(()=>c===pr.TreeOrder?[...u].reverse():u,[c,u]);l.useEffect(()=>{if(!o||!u.length||!v){g();return}for(const S of _){if((r==null?void 0:r(S))===!1)continue;const C=u.indexOf(S),N=h[C];if(!N)continue;const{direction:T,speed:O}=xS(S,N,v,s,f);for(const k of["x","y"])m[k][T[k]]||(O[k]=0,T[k]=0);if(O.x>0||O.y>0){g(),j.current=S,b(w,i),x.current=O,y.current=T;return}}x.current={x:0,y:0},y.current={x:0,y:0},g()},[s,w,r,g,o,i,JSON.stringify(v),JSON.stringify(m),b,u,_,h,JSON.stringify(f)])}const RS={x:{[ze.Backward]:!1,[ze.Forward]:!1},y:{[ze.Backward]:!1,[ze.Forward]:!1}};function ES(t){let{delta:s,disabled:n}=t;const r=Ja(s);return jn(a=>{if(n||!r||!a)return RS;const o={x:Math.sign(s.x-r.x),y:Math.sign(s.y-r.y)};return{x:{[ze.Backward]:a.x[ze.Backward]||o.x===-1,[ze.Forward]:a.x[ze.Forward]||o.x===1},y:{[ze.Backward]:a.y[ze.Backward]||o.y===-1,[ze.Forward]:a.y[ze.Forward]||o.y===1}}},[n,s,r])}function MS(t,s){const n=s!=null?t.get(s):void 0,r=n?n.node.current:null;return jn(a=>{var o;return s==null?null:(o=r??a)!=null?o:null},[r,s])}function IS(t,s){return l.useMemo(()=>t.reduce((n,r)=>{const{sensor:a}=r,o=a.activators.map(i=>({eventName:i.eventName,handler:s(i.handler,r)}));return[...n,...o]},[]),[t,s])}var pn;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(pn||(pn={}));var eo;(function(t){t.Optimized="optimized"})(eo||(eo={}));const Yl=new Map;function DS(t,s){let{dragging:n,dependencies:r,config:a}=s;const[o,i]=l.useState(null),{frequency:c,measure:d,strategy:u}=a,h=l.useRef(t),p=x(),f=dn(p),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]),b=l.useRef(null),g=jn(y=>{if(p&&!n)return Yl;if(!y||y===Yl||h.current!==t||o!=null){const v=new Map;for(let j of t){if(!j)continue;if(o&&o.length>0&&!o.includes(j.id)&&j.rect.current){v.set(j.id,j.rect.current);continue}const w=j.node.current,_=w?new xi(d(w),w):null;j.rect.current=_,_&&v.set(j.id,_)}return v}return y},[t,o,n,p,d]);return l.useEffect(()=>{h.current=t},[t]),l.useEffect(()=>{p||m()},[n,p]),l.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),l.useEffect(()=>{p||typeof c!="number"||b.current!==null||(b.current=setTimeout(()=>{m(),b.current=null},c))},[c,p,m,...r]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:o!=null};function x(){switch(u){case pn.Always:return!1;case pn.BeforeDragging:return n;default:return!n}}}function Zm(t,s){return jn(n=>t?n||(typeof s=="function"?s(t):t):null,[s,t])}function LS(t,s){return Zm(t,s)}function FS(t){let{callback:s,disabled:n}=t;const r=gi(s),a=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,n]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function qr(t){let{callback:s,disabled:n}=t;const r=gi(s),a=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function zS(t){return new xi(Hs(t),t)}function Vl(t,s,n){s===void 0&&(s=zS);const[r,a]=l.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??n)!=null?u:null}const h=s(t);return JSON.stringify(d)===JSON.stringify(h)?d:h})}const i=FS({callback(d){if(t)for(const u of d){const{type:h,target:p}=u;if(h==="childList"&&p instanceof HTMLElement&&p.contains(t)){o();break}}}}),c=qr({callback:o});return kt(()=>{o(),t?(c==null||c.observe(t),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(c==null||c.disconnect(),i==null||i.disconnect())},[t]),r}function $S(t){const s=Zm(t);return Gm(t,s)}const Kl=[];function BS(t){const s=l.useRef(t),n=jn(r=>t?r&&r!==Kl&&t&&s.current&&t.parentNode===s.current.parentNode?r:Br(t):Kl,[t]);return l.useEffect(()=>{s.current=t},[t]),n}function qS(t){const[s,n]=l.useState(null),r=l.useRef(t),a=l.useCallback(o=>{const i=ba(o.target);i&&n(c=>c?(c.set(i,Qa(i)),new Map(c)):null)},[]);return l.useEffect(()=>{const o=r.current;if(t!==o){i(o);const c=t.map(d=>{const u=ba(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,Qa(u)]):null}).filter(d=>d!=null);n(c.length?new Map(c):null),r.current=t}return()=>{i(t),i(o)};function i(c){c.forEach(d=>{const u=ba(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),l.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,i)=>Es(o,i),gt):Xm(t):gt,[t,s])}function Jl(t,s){s===void 0&&(s=[]);const n=l.useRef(null);return l.useEffect(()=>{n.current=null},s),l.useEffect(()=>{const r=t!==gt;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?un(t,n.current):gt}function HS(t){l.useEffect(()=>{if(!$r)return;const s=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of s)n==null||n()}},t.map(s=>{let{sensor:n}=s;return n}))}function WS(t,s){return l.useMemo(()=>t.reduce((n,r)=>{let{eventName:a,handler:o}=r;return n[a]=i=>{o(i,s)},n},{}),[t,s])}function ef(t){return l.useMemo(()=>t?mS(t):null,[t])}const Xl=[];function GS(t,s){s===void 0&&(s=Hs);const[n]=t,r=ef(n?at(n):null),[a,o]=l.useState(Xl);function i(){o(()=>t.length?t.map(d=>Km(d)?r:new xi(s(d),d)):Xl)}const c=qr({callback:i});return kt(()=>{c==null||c.disconnect(),i(),t.forEach(d=>c==null?void 0:c.observe(d))},[t]),a}function US(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return vn(s)?s:t}function YS(t){let{measure:s}=t;const[n,r]=l.useState(null),a=l.useCallback(u=>{for(const{target:h}of u)if(vn(h)){r(p=>{const f=s(h);return p?{...p,width:f.width,height:f.height}:f});break}},[s]),o=qr({callback:a}),i=l.useCallback(u=>{const h=US(u);o==null||o.disconnect(),h&&(o==null||o.observe(h)),r(h?s(h):null)},[s,o]),[c,d]=ur(i);return l.useMemo(()=>({nodeRef:c,rect:n,setRef:d}),[n,c,d])}const VS=[{sensor:ji,options:{}},{sensor:yi,options:{}}],KS={current:{}},tr={draggable:{measure:Hl},droppable:{measure:Hl,strategy:pn.WhileDragging,frequency:eo.Optimized},dragOverlay:{measure:Hs}};class an extends Map{get(s){var n;return s!=null&&(n=super.get(s))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:n}=s;return!n})}getNodeFor(s){var n,r;return(n=(r=this.get(s))==null?void 0:r.node.current)!=null?n:void 0}}const JS={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new an,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:hr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:tr,measureDroppableContainers:hr,windowRect:null,measuringScheduled:!1},XS={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:hr,draggableNodes:new Map,over:null,measureDroppableContainers:hr},Hr=l.createContext(XS),tf=l.createContext(JS);function QS(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new an}}}function ZS(t,s){switch(s.type){case Fe.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Fe.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case Fe.DragEnd:case Fe.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Fe.RegisterDroppable:{const{element:n}=s,{id:r}=n,a=new an(t.droppable.containers);return a.set(r,n),{...t,droppable:{...t.droppable,containers:a}}}case Fe.SetDroppableDisabled:{const{id:n,key:r,disabled:a}=s,o=t.droppable.containers.get(n);if(!o||r!==o.key)return t;const i=new an(t.droppable.containers);return i.set(n,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:i}}}case Fe.UnregisterDroppable:{const{id:n,key:r}=s,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new an(t.droppable.containers);return o.delete(n),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function eN(t){let{disabled:s}=t;const{active:n,activatorEvent:r,draggableNodes:a}=l.useContext(Hr),o=Ja(r),i=Ja(n==null?void 0:n.id);return l.useEffect(()=>{if(!s&&!r&&o&&i!=null){if(!bi(o)||document.activeElement===o.target)return;const c=a.get(i);if(!c)return;const{activatorNode:d,node:u}=c;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const h of[d.current,u.current]){if(!h)continue;const p=Uk(h);if(p){p.focus();break}}})}},[r,s,a,i,o]),null}function tN(t,s){let{transform:n,...r}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...r}),n):n}function sN(t){return l.useMemo(()=>({draggable:{...tr.draggable,...t==null?void 0:t.draggable},droppable:{...tr.droppable,...t==null?void 0:t.droppable},dragOverlay:{...tr.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function nN(t){let{activeNode:s,measure:n,initialRect:r,config:a=!0}=t;const o=l.useRef(!1),{x:i,y:c}=typeof a=="boolean"?{x:a,y:a}:a;kt(()=>{if(!i&&!c||!s){o.current=!1;return}if(o.current||!r)return;const u=s==null?void 0:s.node.current;if(!u||u.isConnected===!1)return;const h=n(u),p=Gm(h,r);if(i||(p.x=0),c||(p.y=0),o.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const f=Um(u);f&&f.scrollBy({top:p.y,left:p.x})}},[s,i,c,r,n])}const sf=l.createContext({...gt,scaleX:1,scaleY:1});var Yt;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Yt||(Yt={}));const rN=l.memo(function(s){var n,r,a,o;let{id:i,accessibility:c,autoScroll:d=!0,children:u,sensors:h=VS,collisionDetection:p=iS,measuring:f,modifiers:m,...b}=s;const g=l.useReducer(ZS,void 0,QS),[x,y]=g,[v,j]=Qk(),[w,_]=l.useState(Yt.Uninitialized),S=w===Yt.Initialized,{draggable:{active:C,nodes:N,translate:T},droppable:{containers:O}}=x,k=C!=null?N.get(C):null,D=l.useRef({initial:null,translated:null}),$=l.useMemo(()=>{var ye;return C!=null?{id:C,data:(ye=k==null?void 0:k.data)!=null?ye:KS,rect:D}:null},[C,k]),B=l.useRef(null),[q,P]=l.useState(null),[E,A]=l.useState(null),H=dn(b,Object.values(b)),z=wn("DndDescribedBy",i),G=l.useMemo(()=>O.getEnabled(),[O]),Q=sN(f),{droppableRects:se,measureDroppableContainers:le,measuringScheduled:re}=DS(G,{dragging:S,dependencies:[T.x,T.y],config:Q.droppable}),U=MS(N,C),ge=l.useMemo(()=>E?Xa(E):null,[E]),ie=He(),be=LS(U,Q.draggable.measure);nN({activeNode:C!=null?N.get(C):null,config:ie.layoutShiftCompensation,initialRect:be,measure:Q.draggable.measure});const K=Vl(U,Q.draggable.measure,be),L=Vl(U?U.parentElement:null),I=l.useRef({activatorEvent:null,active:null,activeNode:U,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),F=O.getNodeFor((n=I.current.over)==null?void 0:n.id),te=YS({measure:Q.dragOverlay.measure}),W=(r=te.nodeRef.current)!=null?r:U,Y=S?(a=te.rect)!=null?a:K:null,V=!!(te.nodeRef.current&&te.rect),pe=$S(V?null:K),ue=ef(W?at(W):null),ve=BS(S?F??U:null),Z=GS(ve),Te=tN(m,{transform:{x:T.x-pe.x,y:T.y-pe.y,scaleX:1,scaleY:1},activatorEvent:E,active:$,activeNodeRect:K,containerNodeRect:L,draggingNodeRect:Y,over:I.current.over,overlayNodeRect:te.rect,scrollableAncestors:ve,scrollableAncestorRects:Z,windowRect:ue}),ae=ge?Es(ge,T):null,xe=qS(ve),Ne=Jl(xe),je=Jl(xe,[K]),Oe=Es(Te,Ne),Be=Y?dS(Y,Te):null,et=$&&Be?p({active:$,collisionRect:Be,droppableRects:se,droppableContainers:G,pointerCoordinates:ae}):null,xt=Wm(et,"id"),[Ce,ht]=l.useState(null),as=V?Te:Es(Te,je),Bt=lS(as,(o=Ce==null?void 0:Ce.rect)!=null?o:null,K),qe=l.useRef(null),yt=l.useCallback((ye,_e)=>{let{sensor:We,options:ke}=_e;if(B.current==null)return;const Ee=N.get(B.current);if(!Ee)return;const M=ye.nativeEvent,Ve=new We({active:B.current,activeNode:Ee,event:M,options:ke,context:I,onAbort(we){if(!N.get(we))return;const{onDragAbort:Pe}=H.current,Ke={id:we};Pe==null||Pe(Ke),v({type:"onDragAbort",event:Ke})},onPending(we,dt,Pe,Ke){if(!N.get(we))return;const{onDragPending:Ge}=H.current,Me={id:we,constraint:dt,initialCoordinates:Pe,offset:Ke};Ge==null||Ge(Me),v({type:"onDragPending",event:Me})},onStart(we){const dt=B.current;if(dt==null)return;const Pe=N.get(dt);if(!Pe)return;const{onDragStart:Ke}=H.current,Je={activatorEvent:M,active:{id:dt,data:Pe.data,rect:D}};gs.unstable_batchedUpdates(()=>{Ke==null||Ke(Je),_(Yt.Initializing),y({type:Fe.DragStart,initialCoordinates:we,active:dt}),v({type:"onDragStart",event:Je}),P(qe.current),A(M)})},onMove(we){y({type:Fe.DragMove,coordinates:we})},onEnd:ct(Fe.DragEnd),onCancel:ct(Fe.DragCancel)});qe.current=Ve;function ct(we){return async function(){const{active:Pe,collisions:Ke,over:Je,scrollAdjustedTranslate:Ge}=I.current;let Me=null;if(Pe&&Ge){const{cancelDrop:ot}=H.current;Me={activatorEvent:M,active:Pe,collisions:Ke,delta:Ge,over:Je},we===Fe.DragEnd&&typeof ot=="function"&&await Promise.resolve(ot(Me))&&(we=Fe.DragCancel)}B.current=null,gs.unstable_batchedUpdates(()=>{y({type:we}),_(Yt.Uninitialized),ht(null),P(null),A(null),qe.current=null;const ot=we===Fe.DragEnd?"onDragEnd":"onDragCancel";if(Me){const Se=H.current[ot];Se==null||Se(Me),v({type:ot,event:Me})}})}}},[N]),Tt=l.useCallback((ye,_e)=>(We,ke)=>{const Ee=We.nativeEvent,M=N.get(ke);if(B.current!==null||!M||Ee.dndKit||Ee.defaultPrevented)return;const Ve={active:M};ye(We,_e.options,Ve)===!0&&(Ee.dndKit={capturedBy:_e.sensor},B.current=ke,yt(We,_e))},[N,yt]),qt=IS(h,Tt);HS(h),kt(()=>{K&&w===Yt.Initializing&&_(Yt.Initialized)},[K,w]),l.useEffect(()=>{const{onDragMove:ye}=H.current,{active:_e,activatorEvent:We,collisions:ke,over:Ee}=I.current;if(!_e||!We)return;const M={active:_e,activatorEvent:We,collisions:ke,delta:{x:Oe.x,y:Oe.y},over:Ee};gs.unstable_batchedUpdates(()=>{ye==null||ye(M),v({type:"onDragMove",event:M})})},[Oe.x,Oe.y]),l.useEffect(()=>{const{active:ye,activatorEvent:_e,collisions:We,droppableContainers:ke,scrollAdjustedTranslate:Ee}=I.current;if(!ye||B.current==null||!_e||!Ee)return;const{onDragOver:M}=H.current,Ve=ke.get(xt),ct=Ve&&Ve.rect.current?{id:Ve.id,rect:Ve.rect.current,data:Ve.data,disabled:Ve.disabled}:null,we={active:ye,activatorEvent:_e,collisions:We,delta:{x:Ee.x,y:Ee.y},over:ct};gs.unstable_batchedUpdates(()=>{ht(ct),M==null||M(we),v({type:"onDragOver",event:we})})},[xt]),kt(()=>{I.current={activatorEvent:E,active:$,activeNode:U,collisionRect:Be,collisions:et,droppableRects:se,draggableNodes:N,draggingNode:W,draggingNodeRect:Y,droppableContainers:O,over:Ce,scrollableAncestors:ve,scrollAdjustedTranslate:Oe},D.current={initial:Y,translated:Be}},[$,U,et,Be,N,W,Y,se,O,Ce,ve,Oe]),OS({...ie,delta:T,draggingRect:Be,pointerCoordinates:ae,scrollableAncestors:ve,scrollableAncestorRects:Z});const os=l.useMemo(()=>({active:$,activeNode:U,activeNodeRect:K,activatorEvent:E,collisions:et,containerNodeRect:L,dragOverlay:te,draggableNodes:N,droppableContainers:O,droppableRects:se,over:Ce,measureDroppableContainers:le,scrollableAncestors:ve,scrollableAncestorRects:Z,measuringConfiguration:Q,measuringScheduled:re,windowRect:ue}),[$,U,K,E,et,L,te,N,O,se,Ce,le,ve,Z,Q,re,ue]),is=l.useMemo(()=>({activatorEvent:E,activators:qt,active:$,activeNodeRect:K,ariaDescribedById:{draggable:z},dispatch:y,draggableNodes:N,over:Ce,measureDroppableContainers:le}),[E,qt,$,K,y,z,N,Ce,le]);return nt.createElement(Bm.Provider,{value:j},nt.createElement(Hr.Provider,{value:is},nt.createElement(tf.Provider,{value:os},nt.createElement(sf.Provider,{value:Bt},u)),nt.createElement(eN,{disabled:(c==null?void 0:c.restoreFocus)===!1})),nt.createElement(tS,{...c,hiddenTextDescribedById:z}));function He(){const ye=(q==null?void 0:q.autoScrollEnabled)===!1,_e=typeof d=="object"?d.enabled===!1:d===!1,We=S&&!ye&&!_e;return typeof d=="object"?{...d,enabled:We}:{enabled:We}}}),aN=l.createContext(null),Ql="button",oN="Draggable";function iN(t){let{id:s,data:n,disabled:r=!1,attributes:a}=t;const o=wn(oN),{activators:i,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:h,draggableNodes:p,over:f}=l.useContext(Hr),{role:m=Ql,roleDescription:b="draggable",tabIndex:g=0}=a??{},x=(d==null?void 0:d.id)===s,y=l.useContext(x?sf:aN),[v,j]=ur(),[w,_]=ur(),S=WS(i,s),C=dn(n);kt(()=>(p.set(s,{id:s,key:o,node:v,activatorNode:w,data:C}),()=>{const T=p.get(s);T&&T.key===o&&p.delete(s)}),[p,s]);const N=l.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":r,"aria-pressed":x&&m===Ql?!0:void 0,"aria-roledescription":b,"aria-describedby":h.draggable}),[r,m,g,x,b,h.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:N,isDragging:x,listeners:r?void 0:S,node:v,over:f,setNodeRef:j,setActivatorNodeRef:_,transform:y}}function lN(){return l.useContext(tf)}const cN="Droppable",dN={timeout:25};function uN(t){let{data:s,disabled:n=!1,id:r,resizeObserverConfig:a}=t;const o=wn(cN),{active:i,dispatch:c,over:d,measureDroppableContainers:u}=l.useContext(Hr),h=l.useRef({disabled:n}),p=l.useRef(!1),f=l.useRef(null),m=l.useRef(null),{disabled:b,updateMeasurementsFor:g,timeout:x}={...dN,...a},y=dn(g??r),v=l.useCallback(()=>{if(!p.current){p.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),m.current=null},x)},[x]),j=qr({callback:v,disabled:b||!i}),w=l.useCallback((N,T)=>{j&&(T&&(j.unobserve(T),p.current=!1),N&&j.observe(N))},[j]),[_,S]=ur(w),C=dn(s);return l.useEffect(()=>{!j||!_.current||(j.disconnect(),p.current=!1,j.observe(_.current))},[_,j]),l.useEffect(()=>(c({type:Fe.RegisterDroppable,element:{id:r,key:o,disabled:n,node:_,rect:f,data:C}}),()=>c({type:Fe.UnregisterDroppable,key:o,id:r})),[r]),l.useEffect(()=>{n!==h.current.disabled&&(c({type:Fe.SetDroppableDisabled,id:r,key:o,disabled:n}),h.current.disabled=n)},[r,o,n,c]),{active:i,rect:f,isOver:(d==null?void 0:d.id)===r,node:_,over:d,setNodeRef:S}}function mn(t,s,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(s,1)[0]),r}function hN(t,s){return t.reduce((n,r,a)=>{const o=s.get(r);return o&&(n[a]=o),n},Array(t.length))}function Bn(t){return t!==null&&t>=0}function pN(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==s[n])return!1;return!0}function mN(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const nf=t=>{let{rects:s,activeIndex:n,overIndex:r,index:a}=t;const o=mn(s,r,n),i=s[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}},qn={scaleX:1,scaleY:1},fN=t=>{var s;let{activeIndex:n,activeNodeRect:r,index:a,rects:o,overIndex:i}=t;const c=(s=o[n])!=null?s:r;if(!c)return null;if(a===n){const u=o[i];return u?{x:0,y:n<i?u.top+u.height-(c.top+c.height):u.top-c.top,...qn}:null}const d=gN(o,a,n);return a>n&&a<=i?{x:0,y:-c.height-d,...qn}:a<n&&a>=i?{x:0,y:c.height+d,...qn}:{x:0,y:0,...qn}};function gN(t,s,n){const r=t[s],a=t[s-1],o=t[s+1];return r?n<s?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 rf="Sortable",af=nt.createContext({activeIndex:-1,containerId:rf,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:nf,disabled:{draggable:!1,droppable:!1}});function bN(t){let{children:s,id:n,items:r,strategy:a=nf,disabled:o=!1}=t;const{active:i,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:h}=lN(),p=wn(rf,n),f=c.rect!==null,m=l.useMemo(()=>r.map(S=>typeof S=="object"&&"id"in S?S.id:S),[r]),b=i!=null,g=i?m.indexOf(i.id):-1,x=u?m.indexOf(u.id):-1,y=l.useRef(m),v=!pN(m,y.current),j=x!==-1&&g===-1||v,w=mN(o);kt(()=>{v&&b&&h(m)},[v,m,b,h]),l.useEffect(()=>{y.current=m},[m]);const _=l.useMemo(()=>({activeIndex:g,containerId:p,disabled:w,disableTransforms:j,items:m,overIndex:x,useDragOverlay:f,sortedRects:hN(m,d),strategy:a}),[g,p,w.draggable,w.droppable,j,m,x,d,f,a]);return nt.createElement(af.Provider,{value:_},s)}const xN=t=>{let{id:s,items:n,activeIndex:r,overIndex:a}=t;return mn(n,r,a).indexOf(s)},yN=t=>{let{containerId:s,isSorting:n,wasDragging:r,index:a,items:o,newIndex:i,previousItems:c,previousContainerId:d,transition:u}=t;return!u||!r||c!==o&&a===i?!1:n?!0:i!==a&&s===d},vN={duration:200,easing:"ease"},of="transform",jN=hn.Transition.toString({property:of,duration:0,easing:"linear"}),wN={roleDescription:"sortable"};function _N(t){let{disabled:s,index:n,node:r,rect:a}=t;const[o,i]=l.useState(null),c=l.useRef(n);return kt(()=>{if(!s&&n!==c.current&&r.current){const d=a.current;if(d){const u=Hs(r.current,{ignoreTransform:!0}),h={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(h.x||h.y)&&i(h)}}n!==c.current&&(c.current=n)},[s,n,r,a]),l.useEffect(()=>{o&&i(null)},[o]),o}function kN(t){let{animateLayoutChanges:s=yN,attributes:n,disabled:r,data:a,getNewIndex:o=xN,id:i,strategy:c,resizeObserverConfig:d,transition:u=vN}=t;const{items:h,containerId:p,activeIndex:f,disabled:m,disableTransforms:b,sortedRects:g,overIndex:x,useDragOverlay:y,strategy:v}=l.useContext(af),j=SN(r,m),w=h.indexOf(i),_=l.useMemo(()=>({sortable:{containerId:p,index:w,items:h},...a}),[p,a,w,h]),S=l.useMemo(()=>h.slice(h.indexOf(i)),[h,i]),{rect:C,node:N,isOver:T,setNodeRef:O}=uN({id:i,data:_,disabled:j.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...d}}),{active:k,activatorEvent:D,activeNodeRect:$,attributes:B,setNodeRef:q,listeners:P,isDragging:E,over:A,setActivatorNodeRef:H,transform:z}=iN({id:i,data:_,attributes:{...wN,...n},disabled:j.draggable}),G=qk(O,q),Q=!!k,se=Q&&!b&&Bn(f)&&Bn(x),le=!y&&E,re=le&&se?z:null,ge=se?re??(c??v)({rects:g,activeNodeRect:$,activeIndex:f,overIndex:x,index:w}):null,ie=Bn(f)&&Bn(x)?o({id:i,items:h,activeIndex:f,overIndex:x}):w,be=k==null?void 0:k.id,K=l.useRef({activeId:be,items:h,newIndex:ie,containerId:p}),L=h!==K.current.items,I=s({active:k,containerId:p,isDragging:E,isSorting:Q,id:i,index:w,items:h,newIndex:K.current.newIndex,previousItems:K.current.items,previousContainerId:K.current.containerId,transition:u,wasDragging:K.current.activeId!=null}),F=_N({disabled:!I,index:w,node:N,rect:C});return l.useEffect(()=>{Q&&K.current.newIndex!==ie&&(K.current.newIndex=ie),p!==K.current.containerId&&(K.current.containerId=p),h!==K.current.items&&(K.current.items=h)},[Q,ie,p,h]),l.useEffect(()=>{if(be===K.current.activeId)return;if(be!=null&&K.current.activeId==null){K.current.activeId=be;return}const W=setTimeout(()=>{K.current.activeId=be},50);return()=>clearTimeout(W)},[be]),{active:k,activeIndex:f,attributes:B,data:_,rect:C,index:w,newIndex:ie,items:h,isOver:T,isSorting:Q,isDragging:E,listeners:P,node:N,overIndex:x,over:A,setNodeRef:G,setActivatorNodeRef:H,setDroppableNodeRef:O,setDraggableNodeRef:q,transform:F??ge,transition:te()};function te(){if(F||L&&K.current.newIndex===w)return jN;if(!(le&&!bi(D)||!u)&&(Q||I))return hn.Transition.toString({...u,property:of})}}function SN(t,s){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t==null?void 0:t.draggable)!=null?n:s.draggable,droppable:(r=t==null?void 0:t.droppable)!=null?r:s.droppable}}function mr(t){if(!t)return!1;const s=t.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const NN=[fe.Down,fe.Right,fe.Up,fe.Left],CN=(t,s)=>{let{context:{active:n,collisionRect:r,droppableRects:a,droppableContainers:o,over:i,scrollableAncestors:c}}=s;if(NN.includes(t.code)){if(t.preventDefault(),!n||!r)return;const d=[];o.getEnabled().forEach(p=>{if(!p||p!=null&&p.disabled)return;const f=a.get(p.id);if(f)switch(t.code){case fe.Down:r.top<f.top&&d.push(p);break;case fe.Up:r.top>f.top&&d.push(p);break;case fe.Left:r.left>f.left&&d.push(p);break;case fe.Right:r.left<f.left&&d.push(p);break}});const u=aS({collisionRect:r,droppableRects:a,droppableContainers:d});let h=Wm(u,"id");if(h===(i==null?void 0:i.id)&&u.length>1&&(h=u[1].id),h!=null){const p=o.get(n.id),f=o.get(h),m=f?a.get(f.id):null,b=f==null?void 0:f.node.current;if(b&&m&&p&&f){const x=Br(b).some((S,C)=>c[C]!==S),y=lf(p,f),v=PN(p,f),j=x||!y?{x:0,y:0}:{x:v?r.width-m.width:0,y:v?r.height-m.height:0},w={x:m.left,y:m.top};return j.x&&j.y?w:un(w,j)}}}};function lf(t,s){return!mr(t)||!mr(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function PN(t,s){return!mr(t)||!mr(s)||!lf(t,s)?!1:t.data.current.sortable.index<s.data.current.sortable.index}function ss(t,s=Date.now()){if(!t)return"unknown";const n=Date.parse(t);if(Number.isNaN(n))return t;const r=Math.round((s-n)/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 wi({title:t,filePath:s}){return e.jsxs("div",{className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] break-words",children:t}),e.jsx("div",{"data-testid":"plan-expanded-header-file-path",className:"mt-0.5 text-xs font-mono text-[var(--text-dim)] break-all",children:s})]})}const cE=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedHeader:wi},Symbol.toStringTag,{value:"Module"}));function Ws(){const[t,s]=l.useState(()=>Date.now());return l.useEffect(()=>{const n=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(n)},[]),t}function cf(t){return{dead:t.sessionAlive===!1}}function df({claim:t,staleFetch:s=!1}){const n=Ws(),{dead:r}=cf(t),a=t.claimedBy.agentProvider??"agent",o=r?" (inactive)":"",i=ss(t.claimedBy.startedAt,n),c=t.source==="local"?`● this session · started ${i}`:t.source==="same-machine"?`claimed by ${a}@${t.claimedBy.machine} (same machine) · ${i}`:`claimed by ${a}@${t.claimedBy.machine} · ${i}`;return e.jsxs("span",{"data-testid":`plan-row-claim-badge-${t.slug}`,title:`Source: ${t.source}${o}${s?" (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 dE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowClaimBadge:df},Symbol.toStringTag,{value:"Module"}));function TN(){const[t,s]=l.useState(!1),[n,r]=l.useState(null);return{updatePlan:l.useCallback(async(o,i)=>{s(!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{s(!1)}},[]),saving:t,error:n}}function uf({slug:t,onClose:s}){return e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:e.jsx(vs,{chatName:`edit-plan-${t}`,slashCommand:`/codeyam-edit-plan ${t}`,height:360,onClose:s})})}const uE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedChat:uf},Symbol.toStringTag,{value:"Module"}));function hf({titleDraft:t,bodyDraft:s,saving:n,error:r,onTitleChange:a,onBodyChange:o,onSave:i,onCancel:c}){const d=Math.min(20,Math.max(8,s.split(`
24
- `).length));return e.jsxs("div",{className:"border-t border-[var(--border-subtle)] px-3 py-2 flex flex-col gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:u=>a(u.target.value),"aria-label":"Plan title",className:"w-full px-2 py-1 text-sm rounded border border-[var(--border-subtle)] bg-[var(--bg-input,transparent)] text-[var(--text-primary)]"}),e.jsx("textarea",{value:s,onChange:u=>o(u.target.value),"aria-label":"Plan body",rows:d,className:"w-full px-2 py-1 text-xs rounded border border-[var(--border-subtle)] bg-[var(--bg-input,transparent)] text-[var(--text-primary)] font-mono resize-y"}),r&&e.jsx("p",{className:"text-xs text-[var(--accent-red)]",role:"alert",children:r}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:c,disabled:n,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer disabled:opacity-60",children:"Cancel"}),e.jsx("button",{type:"button",onClick:i,disabled:n,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:n?"Saving…":"Save"})]})]})}const hE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedEdit:hf},Symbol.toStringTag,{value:"Module"}));function pf({onClick:t}){return e.jsx("button",{type:"button",onClick:t,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"Edit"})}const pE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditButton:pf},Symbol.toStringTag,{value:"Module"}));function mf({providerLabel:t,onClick:s}){return e.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40",title:`Open a chat with ${t} seeded with this plan's contents`,children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"Edit with ",t]})}const mE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditChatButton:mf},Symbol.toStringTag,{value:"Module"}));function ff({dep:t}){const s=!t.satisfied&&t.title===null,n=t.satisfied?"completed":s?"missing":"blocked",r=t.satisfied?{borderColor:"var(--border-subtle)",color:"var(--text-dim)"}:{borderColor:"var(--accent-warn, #c08a2c)",color:"var(--accent-warn, #c08a2c)"};return e.jsxs("li",{"data-testid":`plan-row-dep-${t.slug}`,className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border whitespace-nowrap",style:r,children:n}),e.jsx("span",{className:t.satisfied?"text-[var(--text-dim)] truncate":"text-[var(--text-primary)] truncate",children:s?`missing: ${t.slug}`:t.title??t.slug})]})}const fE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDependencyEntry:ff},Symbol.toStringTag,{value:"Module"}));function _i({dependencies:t}){return e.jsxs("div",{"data-testid":"plan-row-deps",className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mb-1.5",children:"Depends on"}),e.jsx("ul",{className:"flex flex-col gap-1",children:t.map(s=>e.jsx(ff,{dep:s},s.slug))})]})}const gE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedDependencies:_i},Symbol.toStringTag,{value:"Module"}));function gf({title:t,filePath:s,body:n,providerLabel:r,onEdit:a,onChat:o,dependencies:i}){return e.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[e.jsx(wi,{title:t,filePath:s}),i&&i.length>0&&e.jsx(_i,{dependencies:i}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx($t,{variant:"compact",children:n})}),e.jsxs("div",{className:"flex gap-2 justify-end px-3 py-2 border-t border-[var(--border-subtle)]",children:[e.jsx(pf,{onClick:a}),e.jsx(mf,{providerLabel:r,onClick:o})]})]})}const bE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedView:gf},Symbol.toStringTag,{value:"Module"}));function bf({plan:t,dependencies:s}){const[n,r]=l.useState("view"),[a,o]=l.useState(t.title),[i,c]=l.useState(t.body),{updatePlan:d,saving:u,error:h}=TN(),{config:p}=St(),f=zt(p==null?void 0:p.provider);return l.useEffect(()=>{o(t.title),c(t.body),r("view")},[t.slug]),n==="chat"?e.jsx(uf,{slug:t.slug,onClose:()=>r("view")}):n==="edit"?e.jsx(hf,{titleDraft:a,bodyDraft:i,saving:u,error:h,onTitleChange:o,onBodyChange:c,onSave:async()=>{try{await d(t.slug,{title:a,body:i}),r("view")}catch{}},onCancel:()=>{o(t.title),c(t.body),r("view")}}):e.jsx(gf,{title:t.title,filePath:t.filePath,body:t.body,providerLabel:f,onEdit:()=>r("edit"),onChat:()=>r("chat"),dependencies:s})}const xE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedBody:bf},Symbol.toStringTag,{value:"Module"})),xf="Building is in progress, please wait for it to complete before starting a new build session.";function yf({slug:t,onRun:s,launching:n=!1,blocked:r=!1}){const a=u=>{u.stopPropagation(),!n&&s(t)},o="text-[10px] uppercase tracking-wide px-2 py-0.5 rounded border border-[var(--accent-primary)] text-[var(--accent-primary)] cursor-pointer hover:bg-[var(--accent-primary)] hover:text-[var(--surface-bg)] disabled:opacity-60 disabled:cursor-not-allowed transition",i=" opacity-60 cursor-not-allowed hover:bg-transparent hover:text-[var(--accent-primary)]",c=n,d=r&&!n;return e.jsx("button",{type:"button",onClick:a,disabled:c,"data-testid":`plan-run-${t}`,title:d?xf:void 0,className:o+(d?i:""),children:n?"Launching…":"Run"})}const yE=Object.freeze(Object.defineProperty({__proto__:null,PlanRunButton:yf},Symbol.toStringTag,{value:"Module"}));function ki({plan:t,expanded:s,onToggle:n,onRun:r,launching:a=!1,blocked:o=!1,position:i,dragHandleRef:c,dragHandleAttributes:d,dragHandleListeners:u,sortableRef:h,sortableStyle:p,isDragging:f=!1,unsatisfiedDepCount:m=0,unsatisfiedDepTooltip:b,dependencies:g,claim:x,staleFetch:y=!1,expandedBodyVariant:v="full"}){const j=w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),n())};return e.jsxs("li",{ref:h,style:p,className:`border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)] ${f?"opacity-60 shadow-lg":""}`,children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:j,className:"w-full text-left px-3 py-2 flex items-center justify-between gap-3 bg-transparent cursor-pointer",children:[c&&e.jsx("span",{ref:c,"data-testid":`plan-drag-${t.slug}`,"aria-label":"Reorder plan",...d??{},...u??{},onClick:w=>w.stopPropagation(),className:"cursor-grab active:cursor-grabbing text-[var(--text-dim)] select-none leading-none px-1 -ml-1",children:"⋮⋮"}),typeof i=="number"&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)] tabular-nums min-w-[1.25rem]",children:[i,"."]}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-[var(--text-primary)]",children:t.title}),r&&e.jsx(yf,{slug:t.slug,onRun:r,launching:a,blocked:o}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-dim)]",children:t.mode}),m>0&&e.jsxs("span",{"data-testid":`plan-row-blocked-${t.slug}`,title:b,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 · ",m," dep",m===1?"":"s"]}),x&&e.jsx(df,{claim:x,staleFetch:y}),e.jsx("span",{className:"text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:ss(t.createdAt)})]}),s&&(v==="view"?e.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[e.jsx(wi,{title:t.title,filePath:t.filePath}),g&&g.length>0&&e.jsx(_i,{dependencies:g}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx($t,{variant:"compact",children:t.body})})]}):e.jsx(bf,{plan:t,dependencies:g}))]})}const vE=Object.freeze(Object.defineProperty({__proto__:null,PlanRow:ki},Symbol.toStringTag,{value:"Module"}));function vf({plan:t,position:s,expanded:n,onToggle:r,onRun:a,launching:o,blocked:i,draggable:c,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:h,claim:p,staleFetch:f}){const{attributes:m,listeners:b,setNodeRef:g,setActivatorNodeRef:x,transform:y,transition:v,isDragging:j}=kN({id:t.slug,disabled:!c}),w={transform:hn.Transform.toString(y),transition:v};return e.jsx(ki,{plan:t,expanded:n,onToggle:r,onRun:a,launching:o,blocked:i,position:s,sortableRef:g,sortableStyle:w,isDragging:j,dragHandleRef:c?x:void 0,dragHandleAttributes:c?m:void 0,dragHandleListeners:c?b:void 0,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:h,claim:p,staleFetch:f})}const jE=Object.freeze(Object.defineProperty({__proto__:null,SortablePlanRow:vf},Symbol.toStringTag,{value:"Module"}));function Wr({plans:t,loading:s,error:n,onRun:r,launchingSlug:a,launchError:o,blocked:i=!1,onReorder:c,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:h,staleFetch:p}){const[f,m]=l.useState(null),[b,g]=l.useState(null),[x,y]=l.useState(null);l.useEffect(()=>{g(null)},[t]);const v=b??t,j=v.length;return e.jsxs("div",{className:"mt-6",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["Queued Changes (",j,")"]}),o&&e.jsxs("p",{className:"mt-2 text-sm text-[var(--accent-red)]",children:["Failed to launch plan: ",o]}),x&&e.jsxs("p",{className:"mt-2 text-sm text-[var(--accent-red)]",children:["Failed to reorder plans: ",x]}),e.jsx(jf,{plans:v,loading:s,error:n,expandedSlug:f,onToggle:w=>m(_=>_===w?null:w),onRun:r,launchingSlug:a??null,blocked:i,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:h,staleFetch:p,onReorder:c?async w=>{g(w),y(null);try{await c(w.map(_=>_.slug))}catch(_){g(null),y(_ instanceof Error?_.message:"Unknown error")}}:void 0})]})}function jf({plans:t,loading:s,error:n,expandedSlug:r,onToggle:a,onRun:o,launchingSlug:i,blocked:c,onReorder:d,depAnnotationsBySlug:u,dependenciesBySlug:h,claimsBySlug:p,staleFetch:f}){const m=sS($l(ji,{activationConstraint:{distance:4}}),$l(yi,{coordinateGetter:CN})),b=l.useMemo(()=>t.map(y=>y.slug),[t]);if(s)return e.jsx("p",{className:"mt-3 text-sm text-[var(--text-muted)]",children:"Loading plans…"});if(n)return e.jsxs("p",{className:"mt-3 text-sm text-[var(--accent-red)]",children:["Failed to load plans: ",n]});if(t.length===0)return e.jsx("p",{className:"mt-3 text-sm text-[var(--text-dim)]",children:"No plans yet. Click PLAN NEXT CHANGE to create one."});const g=y=>{const{active:v,over:j}=y;if(!j||v.id===j.id||!d)return;const w=t.findIndex(S=>S.slug===v.id),_=t.findIndex(S=>S.slug===j.id);w===-1||_===-1||d(mn(t,w,_))},x=e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"plan-list",children:t.map((y,v)=>{const j=u==null?void 0:u[y.slug],w=p==null?void 0:p.get(y.slug);return e.jsx(vf,{plan:y,position:v+1,expanded:r===y.slug,onToggle:()=>a(y.slug),onRun:o,launching:i===y.slug,blocked:c,draggable:!!d,unsatisfiedDepCount:j==null?void 0:j.count,unsatisfiedDepTooltip:j==null?void 0:j.tooltip,dependencies:h==null?void 0:h[y.slug],claim:w,staleFetch:f},y.slug)})});return d?e.jsx(rN,{sensors:m,collisionDetection:rS,onDragEnd:g,children:e.jsx(bN,{items:b,strategy:fN,children:x})}):x}const wE=Object.freeze(Object.defineProperty({__proto__:null,QueuedChangesBody:jf,QueuedChangesSection:Wr},Symbol.toStringTag,{value:"Module"}));function wf({awaitingPlanLaunchChoice:t,configLoading:s,sessionLoading:n,sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i,provider:c,onContinueSession:d,onAgentIdle:u,onAgentActive:h,onUserInput:p,pendingPlans:f,pendingPlansLoading:m,pendingPlansError:b,onLaunchPlan:g,launchingSlug:x,launchError:y,onReorderPlans:v,isAgentBuilding:j}){const{recoveryFeatureName:w,recoveryStep:_,recoveryMode:S,showTerminal:C,shouldResumeSameProvider:N}=jk({sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i});return r==="pending"?e.jsx(_m,{featureName:w,editorStep:_,workflowMode:S,currentProvider:c,previousProvider:(a==null?void 0:a.provider)??null,resumeMode:(a==null?void 0:a.resumeMode)??"fresh",awaitingUserInput:(a==null?void 0:a.awaitingUserInput)??!1,onContinue:d}):t&&f.length>0&&a===null&&i===null?e.jsx(Qt,{children:e.jsx(Wr,{plans:f,loading:m,error:b,onRun:T=>{var k;const O=((k=f.find(D=>D.slug===T))==null?void 0:k.title)??T;g(T,O)},launchingSlug:x,launchError:y,blocked:j,onReorder:v})}):C?e.jsx(Fm,{provider:c,shouldResumeSameProvider:N,sessionId:(a==null?void 0:a.sessionId)??null,onAgentIdle:u,onAgentActive:h,onUserInput:p,currentFeature:(i==null?void 0:i.feature)??null}):r==="no-session"&&i===null?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-slate-500 space-y-4 px-10 text-center",children:[e.jsx("div",{className:"text-lg font-medium text-slate-400",children:"Ready to build"}),e.jsx("p",{className:"max-w-md",children:"Your first session will start automatically. You can queue changes or wait for the project to initialize."})]}):null}const _E=Object.freeze(Object.defineProperty({__proto__:null,BuildTabSessionContent:wf},Symbol.toStringTag,{value:"Module"}));function AN(t){return t?{step:t.step??0,feature:t.feature??null,startedAt:t.startedAt??"",mode:Pt(t.mode),slug:t.slug??null}:null}const ON=3e3;function _n(){const[t,s]=l.useState(null),[n,r]=l.useState(!0),a=l.useRef(null),o=l.useRef(null),i=l.useCallback(()=>{fetch("/api/step").then(c=>c.json()).then(c=>{const d=AN(c),u=JSON.stringify(d);u!==o.current&&(o.current=u,s(d)),r(!1)}).catch(()=>{r(!1)})},[]);return l.useEffect(()=>(i(),a.current=setInterval(i,ON),()=>{a.current&&clearInterval(a.current)}),[i]),{stepState:t,loading:n,refetch:i}}const st={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};function RN(t){return{hasSession:(t==null?void 0:t.hasSession)??st.hasSession,resumeMode:(t==null?void 0:t.resumeMode)??st.resumeMode,provider:(t==null?void 0:t.provider)??st.provider,feature:(t==null?void 0:t.feature)??st.feature,step:(t==null?void 0:t.step)??st.step,mode:(t==null?void 0:t.mode)==null?st.mode:Pt(t.mode),label:(t==null?void 0:t.label)??st.label,sessionId:(t==null?void 0:t.sessionId)??st.sessionId,awaitingUserInput:(t==null?void 0:t.awaitingUserInput)??st.awaitingUserInput,reopenResults:(t==null?void 0:t.reopenResults)??st.reopenResults,preview:(t==null?void 0:t.preview)??st.preview,agentBrokerLive:(t==null?void 0:t.agentBrokerLive)??st.agentBrokerLive,resultsShown:(t==null?void 0:t.resultsShown)??st.resultsShown}}function Si(t){const s=t==null?void 0:t.pollIntervalMs,[n,r]=l.useState(null),[a,o]=l.useState(!0),i=l.useCallback(async()=>{o(!0);try{const d=await(await fetch("/api/session-info")).json();r(RN(d))}catch{r(c=>c??st)}finally{o(!1)}},[]);return l.useEffect(()=>{i()},[i]),l.useEffect(()=>{if(s==null||s<=0)return;const c=setInterval(()=>{i()},s);return()=>clearInterval(c)},[s,i]),{sessionInfo:n,loading:a,refetch:i}}const EN=5e3;function MN(){const[t,s]=l.useState(null),[n,r]=l.useState(!0),a=l.useRef(null);return l.useEffect(()=>{const o=()=>{fetch("/api/prompt").then(i=>i.json()).then(i=>{s(i.prompt??null),r(!1)}).catch(()=>r(!1))};return o(),a.current=setInterval(o,EN),()=>{a.current&&clearInterval(a.current)}},[]),{prompt:t,loading:n}}function IN({currentDecision:t,sessionInfo:s,sessionLoading:n,attachedSessionId:r=null}){return n||!s?t:t==="continue"&&s.hasSession?"continue":t==="fresh"&&s.hasSession&&s.resumeMode==="resume"?"fresh":s.resumeMode==="resume"&&s.hasSession&&r!=null&&s.sessionId===r?"continue":s.resumeMode==="resume"||s.resumeMode==="handoff"?"pending":"fresh"}let sr=null;const DN=1e4;function LN(){sr=Date.now()}function FN(){if(sr==null)return!1;const t=Date.now()-sr;return sr=null,t<=DN}const Ni="codeyam.buildTab.attachedSessionId";function zN(t){try{window.sessionStorage.setItem(Ni,t)}catch{}}function $N(){try{return window.sessionStorage.getItem(Ni)}catch{return null}}function BN(){try{window.sessionStorage.removeItem(Ni)}catch{}}function qN({sessionLoading:t,sessionInfo:s}){const n=l.useRef(void 0);n.current===void 0&&(n.current=$N());const[r,a]=l.useState(()=>FN()?"fresh":"no-session");l.useEffect(()=>{a(i=>IN({currentDecision:i,sessionInfo:s,sessionLoading:t,attachedSessionId:n.current??null}))},[t,s]),l.useEffect(()=>{if(s){if(!s.hasSession){BN(),n.current=null;return}s.sessionId&&(r==="continue"||r==="fresh")&&(zN(s.sessionId),n.current=s.sessionId)}},[r,s]);const o=l.useCallback(()=>{a("continue")},[]);return{sessionDecision:r,handleContinueSession:o}}function Zl(){const t=document.activeElement;return t===null||t===document.body||t===document.documentElement||t instanceof HTMLElement&&t.dataset.navTab==="true"}function ec(t,s,n,r=0){return t>=n.left-r&&t<=n.right+r&&s>=n.top-r&&s<=n.bottom+r}function it(){const t=()=>{typeof window<"u"&&window.dispatchEvent(new Event("terminal-focus"))};t();const s=requestAnimationFrame(t),n=setTimeout(t,50);return()=>{cancelAnimationFrame(s),clearTimeout(n)}}function tc(t){sc(t,!0);let s=!1;const n=()=>{s||(s=!0,sc(t,!1))};typeof requestAnimationFrame=="function"?(requestAnimationFrame(n),setTimeout(n,100)):queueMicrotask(n)}function sc(t,s){const n=t;if(typeof n.inert=="boolean"){n.inert=s;return}s?t.setAttribute("inert",""):t.removeAttribute("inert")}function va(t){Po(),tc(t),t.blur(),it(),queueMicrotask(()=>{document.activeElement===t&&(tc(t),t.blur(),it())})}function HN(t){const s=l.useRef(!1),n=l.useRef(null);l.useEffect(()=>{if(!t)return;function r(){if(!s.current&&Zl()){s.current=!0;try{Po(),window.dispatchEvent(new Event("terminal-focus"))}finally{s.current=!1}}}function a(){queueMicrotask(r)}function o(){const u=document.activeElement;u instanceof HTMLIFrameElement&&(n.current=u)}function i(u){const h=document.activeElement;if(h instanceof HTMLIFrameElement){if(u.target===h)return;va(h),d(h);return}const p=n.current;if(!p||u.target===p)return;const f=u;if(typeof f.clientX=="number"&&typeof f.clientY=="number"){const m=p.getBoundingClientRect();if(ec(f.clientX,f.clientY,m,1))return}va(p),d(p)}function c(u){const h=document.activeElement;if(!(h instanceof HTMLIFrameElement))return;n.current=h;const p=h.getBoundingClientRect();ec(u.clientX,u.clientY,p,1)||(va(h),d(h))}function d(u){requestAnimationFrame(()=>{document.activeElement!==u&&(Zl()||(n.current=null))})}return document.addEventListener("focusin",o),document.addEventListener("focusout",a),window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),document.addEventListener("mouseup",a),document.addEventListener("pointerdown",i,!0),document.addEventListener("mousedown",i,!0),document.addEventListener("click",i,!0),document.addEventListener("pointermove",c,{capture:!0,passive:!0}),()=>{document.removeEventListener("focusin",o),document.removeEventListener("focusout",a),window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a),document.removeEventListener("mouseup",a),document.removeEventListener("pointerdown",i,!0),document.removeEventListener("mousedown",i,!0),document.removeEventListener("click",i,!0),document.removeEventListener("pointermove",c,{capture:!0})}},[t])}function WN({sessionLoading:t,sessionInfo:s,onRestorePreview:n}){const r=l.useRef(!1);l.useEffect(()=>{t||!(s!=null&&s.preview)||s.resumeMode!=="resume"&&s.resumeMode!=="handoff"||r.current||(r.current=!0,n==null||n(s.preview))},[n,s,t])}function GN(t){const s=l.useRef(t);l.useEffect(()=>{t&&t!==s.current&&(ar(t),s.current=t)},[t])}function UN(t,s,n){l.useEffect(()=>{if(!s)return;const r=a=>{t.current&&!t.current.contains(a.target)&&n()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,s,n])}function _f({displayName:t,hasPrompt:s,expanded:n,onToggle:r}){return s?e.jsxs("button",{onClick:r,className:"flex items-center gap-1 cursor-pointer transition-colors min-w-0",style:{color:"var(--text-secondary)"},children:[e.jsx("span",{className:"font-medium truncate",children:t}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`shrink-0 transition-transform ${n?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}):e.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-secondary)"},children:t})}const kE=Object.freeze(Object.defineProperty({__proto__:null,FeatureNameButton:_f},Symbol.toStringTag,{value:"Module"}));function kf({prompt:t}){return e.jsx("div",{style:{background:"var(--bg-input)",borderBottom:"1px solid var(--border-default)",maxHeight:"16rem",overflowY:"auto",padding:"0 0.75rem 0.75rem"},children:e.jsx($t,{variant:"compact",children:t})})}const SE=Object.freeze(Object.defineProperty({__proto__:null,PromptDropdownPanel:kf},Symbol.toStringTag,{value:"Module"}));function Sf({currentStep:t,isExpanded:s,mode:n,onToggle:r=()=>{},stepNum:a}){const o=a===t,i=a<t,{description:c,label:d}=Jp(a,n);return e.jsxs("div",{onClick:r,className:"cursor-pointer",children:[e.jsxs("div",{className:"w-full px-3 py-0.5 flex items-center gap-2 text-left transition-colors",style:{color:o?"var(--accent-active)":i?"var(--text-secondary)":"var(--text-muted)",fontWeight:o?500:void 0},onMouseEnter:u=>u.currentTarget.style.background="var(--bg-input)",onMouseLeave:u=>u.currentTarget.style.background="transparent",children:[e.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[a,"."]}),e.jsx("span",{className:"flex-1",children:d}),c&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`shrink-0 opacity-40 transition-transform ${s?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),s&&c&&e.jsx("div",{className:"px-3 pb-1.5 pl-10",children:e.jsx("p",{className:"text-[10px] m-0 leading-relaxed",style:{color:"var(--text-dim)"},children:c})})]},a)}const NE=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorDropdownItem:Sf},Symbol.toStringTag,{value:"Module"}));function Nf({step:t,feature:s,mode:n,projectTitle:r,userPrompt:a}){const[o,i]=l.useState(!1),[c,d]=l.useState(null),[u,h]=l.useState(!1),[p,f]=l.useState(null),m=l.useRef(null),b=l.useRef(null),g=l.useRef(null),x=l.useRef(null);l.useLayoutEffect(()=>{if(!o)return;const N=()=>{var O;const T=(O=b.current)==null?void 0:O.getBoundingClientRect();T&&f({top:T.bottom+4,right:window.innerWidth-T.right})};return N(),window.addEventListener("resize",N),window.addEventListener("scroll",N,!0),()=>{window.removeEventListener("resize",N),window.removeEventListener("scroll",N,!0)}},[o]),l.useEffect(()=>{if(!o)return;const N=T=>{var k,D;const O=T.target;(k=m.current)!=null&&k.contains(O)||(D=g.current)!=null&&D.contains(O)||i(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[o]),UN(x,u,l.useCallback(()=>h(!1),[]));const y=s&&t>0,v=s||"New Working Session",j=Pt(n),w=Jp(t,j),_=y?w.label:null,S=w.totalSteps,C=w.prefix;return t===0?e.jsxs("div",{className:"h-8 flex items-center justify-between px-3 text-xs shrink-0 select-none",style:{background:"var(--bg-input)",borderBottom:"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"truncate",style:{color:"var(--text-dim)"},children:r||"New Project"}),e.jsx("span",{style:{color:"var(--text-dim)",opacity:.5},children:">"}),e.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-muted)"},children:v})]}),e.jsx("span",{style:{color:"var(--text-dim)"},children:s?"Starting…":"Waiting for session"})]}):e.jsxs("div",{className:"shrink-0",ref:x,children:[e.jsxs("div",{className:"h-8 flex items-center justify-between px-3 text-xs select-none",style:{background:"var(--bg-input)",borderBottom:u?"none":"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"truncate",style:{color:"var(--text-dim)"},children:r||"New Project"}),e.jsx("span",{style:{color:"var(--text-dim)",opacity:.5},children:">"}),e.jsx(_f,{displayName:v,hasPrompt:!!a,expanded:u,onToggle:()=>h(N=>!N)})]}),y&&e.jsxs("div",{className:"relative",ref:m,children:[e.jsxs("button",{ref:b,onClick:()=>i(N=>!N),className:"flex items-center gap-1.5 cursor-pointer transition-colors",style:{color:"var(--text-secondary)"},children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:"::"}),e.jsxs("span",{children:[C," ",t,e.jsxs("span",{style:{color:"var(--text-dim)"},children:[" / ",S]}),": ",_]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`transition-transform ${o?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),o&&p&&gs.createPortal(e.jsx("div",{ref:g,className:"w-52 rounded-lg shadow-lg py-1 text-xs max-h-[70vh] overflow-y-auto",style:{position:"fixed",top:p.top,right:p.right,zIndex:60,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:Array.from({length:S},(N,T)=>T+1).map(N=>{const T=c===N;return e.jsx(Sf,{currentStep:t,isExpanded:T,mode:j,onToggle:()=>d(T?null:N),stepNum:N},N)})}),document.body)]})]}),u&&a&&e.jsx(kf,{prompt:a})]})}const CE=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorBar:Nf},Symbol.toStringTag,{value:"Module"}));function Cf({awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,isActive:n,onAgentIdle:r,onAgentActive:a,onUserInput:o,provider:i,onRestorePreview:c,pendingPlans:d,pendingPlansLoading:u,pendingPlansError:h,onLaunchPlan:p,launchingSlug:f,launchError:m,onReorderPlans:b,isAgentBuilding:g}){const{stepState:x}=_n(),{config:y,loading:v}=St(),{prompt:j}=MN(),{sessionInfo:w,loading:_}=Si(),{sessionDecision:S,handleContinueSession:C}=qN({sessionLoading:_,sessionInfo:w});return HN(n),WN({sessionLoading:_,sessionInfo:w,onRestorePreview:c}),GN((x==null?void 0:x.feature)??null),e.jsx(gm,{stepIndicator:e.jsx(Nf,{step:(x==null?void 0:x.step)??0,feature:(x==null?void 0:x.feature)??null,mode:(x==null?void 0:x.mode)??"ui",projectTitle:(y==null?void 0:y.projectTitle)??null,userPrompt:j}),sessionContent:e.jsx(wf,{awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,configLoading:v,sessionLoading:_,sessionDecision:S,sessionInfo:w,stepState:x,provider:i,onContinueSession:C,onAgentIdle:r,onAgentActive:a,onUserInput:o,pendingPlans:d,pendingPlansLoading:u,pendingPlansError:h,onLaunchPlan:p,launchingSlug:f,launchError:m,onReorderPlans:b,isAgentBuilding:g})})}const PE=Object.freeze(Object.defineProperty({__proto__:null,BuildTab:Cf},Symbol.toStringTag,{value:"Module"}));function Pf({refreshing:t,onRefresh:s,onClose:n,minimizeMode:r=!1}){return e.jsxs("div",{className:"shrink-0 px-4 py-2 bg-[var(--bg-card)] border-b border-[var(--border-default)] flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Working Session Results"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:s,disabled:t,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-xs leading-none px-2 py-1 border border-[var(--border-default)] rounded disabled:opacity-50",title:"Refresh session data",children:t?"…":"↻"}),e.jsx("button",{onClick:n,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-lg leading-none px-1",title:r?"Minimize results panel":"Close results panel",children:r?"▾":"✕"})]})]})}const TE=Object.freeze(Object.defineProperty({__proto__:null,SessionResultsPanelHeader:Pf},Symbol.toStringTag,{value:"Module"}));function Zs(t,s){if(t.length===0)return{selectedIndex:-1,scenario:null};if("direction"in s){const r=s.direction==="next"?1:-1,a=(s.selectedIndex+r+t.length)%t.length;return{selectedIndex:a,scenario:t[a]}}if("slug"in s){const r=t.findIndex(a=>a.slug===s.slug);return r>=0?{selectedIndex:r,scenario:t[r]}:Zs(t,{defaultSelection:!0,selectedIndex:s.selectedIndex})}const n=Math.min(s.selectedIndex??0,t.length-1);return{selectedIndex:n,scenario:t[n]}}function fr(t,s){if(!s)return{headline:t,collapsed:[]};const n=[],r=[];for(const a of t)a.demonstratesNew?n.push(a):r.push(a);return{headline:n,collapsed:r}}function Ci(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&typeof t.name=="string"?t.name:String(t)}function YN(t){if(t!=null&&typeof t=="object"){const{description:s}=t;if(typeof s=="string"&&s.trim()!=="")return s}}function Pi({fn:t,testid:s}){return e.jsxs("div",{className:"flex items-start gap-2","data-testid":s,children:[e.jsx("span",{className:"text-[10px] text-[var(--text-muted)] mt-0.5 shrink-0",children:"fn"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium text-[var(--text-primary)]",children:t.name}),t.description&&e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:t.description}),e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] font-mono mt-0.5",children:t.filePath})]})]})}const AE=Object.freeze(Object.defineProperty({__proto__:null,FunctionChangeRow:Pi},Symbol.toStringTag,{value:"Module"})),VN="no-isolation-harness";function Tf(t){var s;return t.coverageStatus==="reason"&&((s=t.untestabilityReason)==null?void 0:s.kind)===VN}const KN="/api/editor-session-summary",JN=3e3;function Af(t=JN){const[s,n]=l.useState(null),[r,a]=l.useState(!0),[o,i]=l.useState(!1),c=l.useCallback(async()=>{i(!0);try{const d=await fetch(KN);d.ok&&n(await d.json())}catch{}i(!1),a(!1)},[]);return l.useEffect(()=>{c()},[c]),l.useEffect(()=>{if(t<=0)return;const d=window.setInterval(c,t);return()=>window.clearInterval(d)},[c,t]),{summary:s,loading:r,refreshing:o,refresh:c}}function Of({onClose:t,onSelectScenario:s,previewSlug:n=null,minimizeMode:r=!1}){var w;const{summary:a,loading:o,refreshing:i,refresh:c}=Af(),[d,u]=l.useState(0),h=l.useMemo(()=>a?[...a.application,...a.components]:[],[a]),p=l.useMemo(()=>n&&h.some(_=>_.slug===n)?n:null,[h,n]),f=p??((w=h[d])==null?void 0:w.slug);l.useEffect(()=>{if(!p)return;const _=h.findIndex(S=>S.slug===p);_>=0&&_!==d&&u(_)},[h,p,d]);const m=l.useCallback(_=>{h.length!==0&&(document.activeElement instanceof HTMLIFrameElement||Rk()||(_.key==="ArrowRight"?(_.preventDefault(),u(S=>{const C=Zs(h,{direction:"next",selectedIndex:S});return C.scenario&&(s==null||s(C.scenario.slug,C.scenario.url)),C.selectedIndex})):_.key==="ArrowLeft"&&(_.preventDefault(),u(S=>{const C=Zs(h,{direction:"previous",selectedIndex:S});return C.scenario&&(s==null||s(C.scenario.slug,C.scenario.url)),C.selectedIndex}))))},[h,s]);l.useEffect(()=>(window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)),[m]);const b=l.useRef(!1);if(l.useEffect(()=>{if(b.current||h.length===0)return;b.current=!0;const _=Zs(h,{defaultSelection:!0,selectedIndex:d});_.scenario&&(s==null||s(_.scenario.slug,_.scenario.url))},[h,s,d]),o)return e.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:e.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:e.jsx("div",{className:"text-sm text-[var(--text-muted)]",children:"No session data available."})});const g=a.application.length+a.components.length,x=a.hubDominated??!1,y=fr(a.application,x),v=fr(a.components,x),j=(_,S)=>{var N,T;const C=Zs(h,{slug:_,selectedIndex:d});C.selectedIndex>=0&&u(C.selectedIndex),s==null||s(((N=C.scenario)==null?void 0:N.slug)??_,((T=C.scenario)==null?void 0:T.url)??S)};return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-[var(--bg-deep)]",style:{borderTop:"2px solid #005c75"},children:[e.jsx(Pf,{refreshing:i,onRefresh:c,onClose:t,minimizeMode:r}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[a.userPrompt&&e.jsx(Rf,{text:a.userPrompt}),e.jsxs(en,{title:"Application",icon:"🌐",count:y.headline.length,impactedCount:y.collapsed.length,empty:g===0?"No scenarios in this session":void 0,children:[y.headline.length>0&&e.jsx(Mf,{scenarios:y.headline,selectedSlug:f,onSelect:j}),e.jsx(to,{scenarios:y.collapsed,selectedSlug:f,onSelect:j})]}),e.jsxs(en,{title:"Components",icon:"🧩",count:v.headline.length,impactedCount:v.collapsed.length,children:[v.headline.length>0&&e.jsx(Ef,{scenarios:v.headline,selectedSlug:f,onSelect:j}),e.jsx(to,{scenarios:v.collapsed,selectedSlug:f,onSelect:j})]}),e.jsx(en,{title:"Functions",icon:"⚙️",count:a.functions.length,children:a.functions.length>0&&e.jsx(Df,{functions:a.functions})}),e.jsx(en,{title:"Modified Files",icon:"📄",count:a.modifiedFiles.length,children:a.modifiedFiles.length>0&&e.jsx(Lf,{files:a.modifiedFiles})})]})]})}function Rf({text:t}){const[s,n]=l.useState(!1),r=t.split(`
25
- `)[0],a=t.includes(`
26
- `)||t.length>120;return e.jsxs("div",{className:"px-1 pb-2",children:[e.jsx("div",{className:"text-[10px] font-semibold text-[var(--text-muted)] uppercase tracking-wide mb-1",children:"User Request"}),s?e.jsxs("div",{children:[e.jsx($t,{variant:"compact",children:t}),a&&e.jsx("button",{onClick:()=>n(!1),className:"text-[#D7FF63] hover:underline text-xs mt-1",children:"Show less"})]}):e.jsxs("div",{className:"text-xs text-[var(--text-secondary)] leading-relaxed",children:[r.slice(0,120),a&&e.jsx("button",{onClick:()=>n(!0),className:"text-[#D7FF63] hover:underline ml-1 text-xs",children:"Read more..."})]})]})}function en({title:t,icon:s,count:n,impactedCount:r=0,empty:a,children:o}){const i=n+r;return e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-input)] flex items-center gap-2",children:[e.jsx("span",{className:"text-xs",children:s}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-primary)]",children:t}),e.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",n,r>0?` +${r} impacted`:"",")"]})]}),e.jsx("div",{className:"p-3",children:i===0?e.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:a||`No ${t.toLowerCase()} in this session`}):o})]})}function fn({scenarios:t,selectedSlug:s,onSelect:n}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("div",{className:"flex gap-2",style:{minWidth:"min-content"},children:t.map(r=>e.jsx(If,{scenario:r,isSelected:r.slug===s,onSelect:n},r.slug))})})}function to({scenarios:t,selectedSlug:s,onSelect:n}){const[r,a]=l.useState(!1);return t.length===0?null:e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]",children:[e.jsxs("button",{onClick:()=>a(o=>!o),className:"text-[11px] text-[var(--text-muted)] hover:text-[var(--text-secondary)] flex items-center gap-1",children:[e.jsx("span",{children:r?"▾":"▸"}),e.jsxs("span",{children:[t.length," more impacted by hub-file changes (not recaptured this session)"]})]}),r&&e.jsx("div",{className:"mt-2",children:e.jsx(fn,{scenarios:t,selectedSlug:s,onSelect:n})})]})}function Ef({scenarios:t,selectedSlug:s,onSelect:n}){const r={};for(const i of t){const c=i.componentName||"Unknown";r[c]||(r[c]=[]),r[c].push(i)}const a=Object.keys(r).sort(),o=t.some(Tf);return e.jsxs("div",{className:"space-y-3",children:[o&&e.jsx("div",{className:"text-[10px] leading-snug text-[var(--text-muted)] bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded px-2 py-1.5",children:"This stack has no component isolation harness, so leaf components are verified inside the full app scenarios rather than in isolation."}),a.map(i=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] mb-1",children:i}),e.jsx(fn,{scenarios:r[i],selectedSlug:s,onSelect:n})]},i))]})}function Mf({scenarios:t,selectedSlug:s,onSelect:n}){if(!t.some(i=>i.routeName))return e.jsx(fn,{scenarios:t,selectedSlug:s,onSelect:n});const a={};for(const i of t){const c=i.routeName||"Other";a[c]||(a[c]=[]),a[c].push(i)}const o=Object.keys(a).sort();return e.jsx("div",{className:"space-y-3",children:o.map(i=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] mb-1",children:i}),e.jsx(fn,{scenarios:a[i],selectedSlug:s,onSelect:n})]},i))})}function If({scenario:t,isSelected:s,onSelect:n}){var o;const r=t.name.replace(/\s*\[.*\]\s*$/,"").trim(),a=Tf(t);return e.jsxs("div",{className:"shrink-0 cursor-pointer group",onClick:()=>n==null?void 0:n(t.slug,t.url),title:t.name,children:[e.jsx("div",{className:`w-24 h-24 rounded overflow-hidden flex items-center justify-center bg-[var(--bg-surface)] transition-colors ${s?"border-2 border-[#005c75] shadow-md":"border border-[var(--border-default)] group-hover:border-[#005c75]"}`,children:t.screenshotPaths.length>0?e.jsx(Nt,{screenshotPath:t.screenshotPaths[0],cacheBuster:t.screenshotCapturedAtMs??void 0,alt:t.name}):t.coverageStatus==="needs-isolated-scenario"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:"Backed only by a unit test — capture an isolated scenario so this component is viewable in the editor.",children:[e.jsx("span",{className:"text-amber-500 text-lg leading-none",children:"⚠"}),e.jsx("span",{className:"text-[8px] leading-tight text-amber-700",children:"needs isolated scenario"})]}):t.coverageStatus==="reason"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:t.untestabilityReason?`${t.untestabilityReason.kind}: ${t.untestabilityReason.justification}`:"Covered by a recorded untestability reason.",children:[e.jsx("span",{className:"text-[var(--text-muted)] text-lg leading-none",children:"🧪"}),e.jsx("span",{className:"text-[8px] leading-tight text-[var(--text-muted)]",children:((o=t.untestabilityReason)==null?void 0:o.kind)??"test-backed"})]}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-[var(--text-muted)] text-lg",children:"📷"})}),e.jsx("div",{className:`mt-1 text-[10px] truncate w-24 ${s?"text-[#005c75] font-medium":"text-[var(--text-secondary)] group-hover:text-[#005c75]"}`,children:r}),a&&e.jsx("div",{className:"mt-0.5 w-24 text-[9px] leading-tight text-[var(--text-muted)]",children:"Covered via app scenarios — no isolation harness"})]})}function Df({functions:t}){return e.jsx("div",{className:"divide-y divide-gray-100 -mx-3 -mb-3",children:t.map(s=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx(Pi,{fn:s}),s.tests.length>0&&e.jsx("div",{className:"ml-5 mt-1.5 space-y-0.5",children:s.tests.map((n,r)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-green-500 text-[10px]",children:"✓"}),e.jsx("span",{className:"text-[10px] text-[var(--text-secondary)]",children:Ci(n)})]},r))}),s.testFile&&s.tests.length===0&&e.jsx("div",{className:"ml-5 mt-1 text-[10px] text-[var(--text-muted)] font-mono",children:s.testFile})]},`${s.filePath}::${s.name}`))})}function Lf({files:t}){return e.jsx("div",{className:"divide-y divide-gray-100 -mx-3 -mb-3",children:t.map(s=>e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[e.jsx(Nr,{status:s.status}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono truncate",children:s.path})]},s.path))})}const OE=Object.freeze(Object.defineProperty({__proto__:null,ApplicationGroups:Mf,CollapsedImpactedScenarios:to,ComponentGroups:Ef,FilesList:Lf,FunctionsList:Df,ScenarioThumbnail:If,ScenarioThumbnailStrip:fn,Section:en,SessionResultsPanel:Of,UserPrompt:Rf},Symbol.toStringTag,{value:"Module"}));function Ff({onExpand:t}){const{summary:s}=Af(),n=(s==null?void 0:s.hubDominated)??!1,r=fr((s==null?void 0:s.application)??[],n),a=fr((s==null?void 0:s.components)??[],n),o=r.headline.length+a.headline.length,i=r.collapsed.length+a.collapsed.length;return e.jsxs("button",{type:"button",onClick:t,title:"Expand working session results",className:"shrink-0 w-full flex items-center gap-2 px-4 py-1.5 text-left bg-[var(--bg-card)] hover:bg-[var(--bg-input)] transition-colors",style:{borderTop:"2px solid #005c75"},children:[e.jsx("span",{className:"text-[var(--text-muted)] text-xs leading-none",children:"▴"}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-primary)]",children:"Working Session Results"}),e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:[o," new",i>0?` · ${i} impacted`:""]})]})}const RE=Object.freeze(Object.defineProperty({__proto__:null,MinimizedSessionResults:Ff},Symbol.toStringTag,{value:"Module"}));function XN(t,s){return(t==null?void 0:t.mode)!=="ui"?!1:(t==null?void 0:t.slug)==="feature-complete"||!!s}const QN=new Set(["ui-present","backend-present"]);function zf(t){return!!(t!=null&&t.slug)&&QN.has(t.slug)}function ZN({stepState:t,resultsShown:s,featureCompleteActive:n,userExpanded:r}){return n?"hidden":zf(t)?(t==null?void 0:t.mode)==="ui"?"full":"hidden":XN(t,s)?r?"full":"minimized":"hidden"}function $f({awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,buildActivated:n,activeTab:r,onSelectScenario:a,previewSlug:o=null,showResultsCommandKey:i,hideResultsCommandKey:c,onAgentIdle:d,onAgentActive:u,onUserInput:h,notifSettings:p,onSettingsChange:f,provider:m,onRestorePreview:b,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:v,launchingSlug:j,launchError:w,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:C}){const{stepState:N}=_n(),{sessionInfo:T}=Si({pollIntervalMs:15e3}),[O,k]=l.useState(!1),[D,$]=l.useState(!1),[B,q]=l.useState(0),P=(T==null?void 0:T.resultsShown)??!1;l.useEffect(()=>{P||($(!1),k(!1))},[P]),l.useEffect(()=>{i&&($(!1),k(!0),q(Q=>Q+1))},[i]),l.useEffect(()=>{c&&k(!1)},[c]);const E=zf(N),A=ZN({stepState:N,resultsShown:P,featureCompleteActive:C,userExpanded:O}),H=E&&D?"hidden":A,z=l.useCallback(()=>{E?$(!0):k(!1)},[E]),G=l.useCallback(()=>{k(!0),q(Q=>Q+1)},[]);return n?e.jsx(bm,{activeTab:r,resultsMode:H,buildTab:e.jsx(Cf,{awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,isActive:r==="build",onAgentIdle:d,onAgentActive:u,onUserInput:h,provider:m,onRestorePreview:b,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:v,launchingSlug:j,launchError:w,onReorderPlans:_,isAgentBuilding:S}),resultsPanel:e.jsx(Of,{onClose:z,onSelectScenario:a,previewSlug:o,minimizeMode:!E},B),minimizedResults:e.jsx(Ff,{onExpand:G}),footer:e.jsx(Lp,{settings:p,onChange:f,agentName:m})}):null}const EE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPane:$f},Symbol.toStringTag,{value:"Module"})),e2=e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M5.50742 6.94462H6.6669C6.89825 6.94462 7.12013 6.85463 7.28372 6.69444C7.44731 6.53426 7.53921 6.317 7.53921 6.09047C7.53921 5.86394 7.44731 5.64668 7.28372 5.4865C7.12013 5.32631 6.89825 5.23633 6.6669 5.23633H5.51133C5.27997 5.23633 5.05809 5.32631 4.8945 5.4865C4.73091 5.64668 4.639 5.86394 4.639 6.09047C4.639 6.20264 4.61644 6.31372 4.57261 6.41735C4.52877 6.52098 4.46451 6.61513 4.38351 6.69444C4.3025 6.77376 4.20634 6.83668 4.1005 6.8796C3.99467 6.92253 3.88124 6.94462 3.76668 6.94462H2.61111C2.38009 6.94462 2.15851 7.03435 1.99498 7.19412C1.83144 7.35389 1.7393 7.57066 1.73878 7.79687C1.73878 8.02307 1.64715 8.24003 1.48398 8.40016C1.32081 8.56029 1.09944 8.6505 0.868421 8.65101C0.637744 8.65202 0.416859 8.74245 0.25411 8.90253C0.0913609 9.0626 -2.30897e-06 9.27929 0 9.50516C-5.79344e-07 9.73086 0.0914247 9.94733 0.254229 10.1071C0.417033 10.2669 0.637923 10.3569 0.868421 10.3574C1.09944 10.3579 1.32081 10.4481 1.48398 10.6082C1.64715 10.7684 1.73878 10.9853 1.73878 11.2115C1.73878 11.4381 1.83069 11.6553 1.99429 11.8155C2.15788 11.9757 2.37976 12.0657 2.61111 12.0657H3.76668C3.9977 12.0657 4.21928 12.1554 4.38282 12.3152C4.54635 12.475 4.63848 12.6917 4.639 12.9179C4.639 13.1445 4.73091 13.3617 4.8945 13.5219C5.05809 13.6821 5.27997 13.7721 5.51133 13.7721H6.6669C6.78136 13.7721 6.8947 13.75 7.00043 13.707C7.10615 13.6641 7.20218 13.6011 7.28303 13.5218C7.36388 13.4424 7.42794 13.3483 7.47157 13.2447C7.51519 13.141 7.53753 13.03 7.53727 12.9179C7.53727 12.6919 7.44556 12.4751 7.28234 12.3153C7.11911 12.1555 6.89773 12.0657 6.6669 12.0657H5.50937C5.27836 12.0652 5.05698 11.975 4.89381 11.8148C4.73064 11.6547 4.639 11.4377 4.639 11.2115C4.639 10.985 4.5471 10.7678 4.38351 10.6076C4.21991 10.4474 3.99804 10.3574 3.76668 10.3574H2.59745C2.36929 10.3574 2.15025 10.2697 1.98746 10.1132C1.82468 9.95667 1.73117 9.74381 1.72707 9.52044C1.72707 9.52044 1.72707 9.52045 1.72707 9.50516C1.72707 9.50516 1.72707 9.49369 1.72707 9.48796C1.73117 9.26459 1.82468 9.05173 1.98746 8.89519C2.15025 8.73866 2.36929 8.65097 2.59745 8.65101H3.76668C3.99804 8.65101 4.21991 8.56102 4.38351 8.40084C4.5471 8.24065 4.639 8.0234 4.639 7.79687C4.639 7.57117 4.73043 7.35468 4.89324 7.19491C5.05604 7.03514 5.27692 6.94513 5.50742 6.94462Z",fill:"currentColor"}),e.jsx("path",{d:"M17.1351 5.27098C16.9037 5.27098 16.6818 5.36096 16.5183 5.52115C16.3547 5.68133 16.2628 5.89859 16.2628 6.12512V7.83152C16.2628 7.94368 16.2402 8.05475 16.1964 8.15838C16.1525 8.26201 16.0883 8.35618 16.0073 8.43549C15.9263 8.51481 15.8301 8.57771 15.7243 8.62064C15.6184 8.66356 15.505 8.68566 15.3904 8.68566C15.1594 8.68616 14.938 8.77637 14.7749 8.9365C14.6117 9.09663 14.5201 9.31361 14.5201 9.53981C14.5196 9.76602 14.4274 9.98278 14.2639 10.1426C14.1003 10.3023 13.8788 10.392 13.6477 10.392C13.4167 10.392 13.1951 10.3023 13.0316 10.1426C12.8681 9.98278 12.7759 9.76602 12.7754 9.53981C12.7754 9.31361 12.6838 9.09663 12.5206 8.9365C12.3574 8.77637 12.1361 8.68616 11.9051 8.68566C11.7905 8.68566 11.6771 8.66356 11.5712 8.62064C11.4654 8.57771 11.3692 8.51481 11.2882 8.43549C11.2072 8.35618 11.143 8.26201 11.0991 8.15838C11.0553 8.05475 11.0327 7.94368 11.0327 7.83152V6.13086C11.0383 6.01542 11.0199 5.90007 10.9786 5.7918C10.9374 5.68352 10.8741 5.58458 10.7926 5.50095C10.7112 5.41732 10.6132 5.35074 10.5047 5.30526C10.3962 5.25977 10.2794 5.23633 10.1614 5.23633C10.0434 5.23633 9.92656 5.25977 9.81805 5.30526C9.70955 5.35074 9.61161 5.41732 9.53015 5.50095C9.44869 5.58458 9.38541 5.68352 9.34414 5.7918C9.30287 5.90007 9.28446 6.01542 9.29004 6.13086V7.83724C9.29004 8.06345 9.38168 8.28041 9.54485 8.44054C9.70802 8.60067 9.9294 8.69089 10.1604 8.6914C10.3918 8.6914 10.6136 8.78138 10.7772 8.94157C10.9408 9.10175 11.0327 9.31901 11.0327 9.54554C11.0332 9.77174 11.1254 9.98851 11.2889 10.1483C11.4525 10.308 11.674 10.3978 11.9051 10.3978C12.1351 10.3983 12.3556 10.4877 12.5186 10.6466C12.6816 10.8055 12.7739 11.021 12.7754 11.2462V12.966C12.7754 13.1922 12.8671 13.4091 13.0302 13.5693C13.1934 13.7294 13.4148 13.8196 13.6458 13.8201C13.8771 13.8201 14.099 13.7301 14.2626 13.5699C14.4262 13.4097 14.5181 13.1925 14.5181 12.966V11.2596C14.5181 11.0334 14.6097 10.8164 14.7729 10.6563C14.9361 10.4961 15.1575 10.4059 15.3885 10.4054C15.6195 10.4054 15.8411 10.3157 16.0046 10.1559C16.1682 9.99616 16.2603 9.77938 16.2608 9.55318C16.2608 9.32664 16.3527 9.10939 16.5163 8.9492C16.6799 8.78902 16.9018 8.69904 17.1331 8.69904C17.3641 8.69853 17.5855 8.60832 17.7487 8.44819C17.9119 8.28806 18.0035 8.07109 18.0035 7.84488V6.13086C18.0043 6.01853 17.9824 5.90715 17.9392 5.80311C17.8959 5.69907 17.8321 5.6044 17.7515 5.52453C17.6708 5.44466 17.5748 5.38115 17.4691 5.33764C17.3633 5.29414 17.2498 5.27148 17.1351 5.27098Z",fill:"currentColor"})]}),t2=e.jsx("path",{d:"M28.609 14.209C27.883 14.209 27.2597 14.0807 26.739 13.824C26.2183 13.5673 25.793 13.2337 25.463 12.823C25.1403 12.4123 24.902 11.965 24.748 11.481C24.594 10.997 24.517 10.5313 24.517 10.084V9.842C24.517 9.34333 24.594 8.852 24.748 8.368C24.9093 7.884 25.155 7.444 25.485 7.048C25.815 6.652 26.233 6.33667 26.739 6.102C27.2523 5.86 27.8573 5.739 28.554 5.739C29.28 5.739 29.9107 5.871 30.446 6.135C30.9887 6.39167 31.4213 6.75833 31.744 7.235C32.0667 7.70433 32.261 8.25433 32.327 8.885H30.754C30.6953 8.51833 30.5633 8.21033 30.358 7.961C30.16 7.70433 29.907 7.51367 29.599 7.389C29.291 7.257 28.9427 7.191 28.554 7.191C28.158 7.191 27.806 7.26067 27.498 7.4C27.19 7.532 26.9333 7.72267 26.728 7.972C26.5227 8.22133 26.365 8.51467 26.255 8.852C26.1523 9.18933 26.101 9.56333 26.101 9.974C26.101 10.37 26.1523 10.7367 26.255 11.074C26.365 11.4113 26.5263 11.7083 26.739 11.965C26.9517 12.2143 27.212 12.4087 27.52 12.548C27.8353 12.6873 28.1983 12.757 28.609 12.757C29.2103 12.757 29.7163 12.6103 30.127 12.317C30.545 12.0163 30.798 11.5983 30.886 11.063H32.459C32.3857 11.635 32.1913 12.1593 31.876 12.636C31.5607 13.1127 31.128 13.494 30.578 13.78C30.028 14.066 29.3717 14.209 28.609 14.209ZM36.5271 14.209C35.9991 14.209 35.5334 14.1247 35.1301 13.956C34.7268 13.7873 34.3858 13.56 34.1071 13.274C33.8284 12.9807 33.6158 12.6507 33.4691 12.284C33.3298 11.9173 33.2601 11.536 33.2601 11.14V10.909C33.2601 10.4983 33.3334 10.1097 33.4801 9.743C33.6341 9.369 33.8504 9.039 34.1291 8.753C34.4151 8.45967 34.7598 8.23233 35.1631 8.071C35.5664 7.90233 36.0211 7.818 36.5271 7.818C37.0331 7.818 37.4878 7.90233 37.8911 8.071C38.2944 8.23233 38.6354 8.45967 38.9141 8.753C39.2001 9.039 39.4164 9.369 39.5631 9.743C39.7098 10.1097 39.7831 10.4983 39.7831 10.909V11.14C39.7831 11.536 39.7098 11.9173 39.5631 12.284C39.4238 12.6507 39.2148 12.9807 38.9361 13.274C38.6574 13.56 38.3164 13.7873 37.9131 13.956C37.5098 14.1247 37.0478 14.209 36.5271 14.209ZM36.5271 12.9C36.9011 12.9 37.2164 12.8193 37.4731 12.658C37.7298 12.4893 37.9241 12.2657 38.0561 11.987C38.1881 11.701 38.2541 11.3783 38.2541 11.019C38.2541 10.6523 38.1844 10.3297 38.0451 10.051C37.9131 9.765 37.7151 9.54133 37.4511 9.38C37.1944 9.21133 36.8864 9.127 36.5271 9.127C36.1678 9.127 35.8561 9.21133 35.5921 9.38C35.3354 9.54133 35.1374 9.765 34.9981 10.051C34.8588 10.3297 34.7891 10.6523 34.7891 11.019C34.7891 11.3783 34.8551 11.701 34.9871 11.987C35.1264 12.2657 35.3244 12.4893 35.5811 12.658C35.8378 12.8193 36.1531 12.9 36.5271 12.9ZM43.5969 14.198C43.1789 14.198 42.7939 14.121 42.4419 13.967C42.0899 13.813 41.7856 13.5967 41.5289 13.318C41.2723 13.0393 41.0743 12.7167 40.9349 12.35C40.7956 11.976 40.7259 11.5727 40.7259 11.14V10.909C40.7259 10.4837 40.7919 10.084 40.9239 9.71C41.0633 9.336 41.2539 9.00967 41.4959 8.731C41.7453 8.45233 42.0423 8.236 42.3869 8.082C42.7389 7.92067 43.1276 7.84 43.5529 7.84C44.0223 7.84 44.4329 7.94267 44.7849 8.148C45.1443 8.346 45.4303 8.64667 45.6429 9.05C45.8556 9.45333 45.9729 9.95933 45.9949 10.568L45.5439 10.04V5.97H47.0729V14H45.8629V11.459H46.1269C46.1049 12.0677 45.9803 12.5773 45.7529 12.988C45.5256 13.3913 45.2249 13.6957 44.8509 13.901C44.4843 14.099 44.0663 14.198 43.5969 14.198ZM43.9379 12.911C44.2386 12.911 44.5136 12.845 44.7629 12.713C45.0123 12.5737 45.2103 12.3757 45.3569 12.119C45.5109 11.855 45.5879 11.547 45.5879 11.195V10.755C45.5879 10.403 45.5109 10.1097 45.3569 9.875C45.2029 9.633 45.0013 9.44967 44.7519 9.325C44.5026 9.193 44.2313 9.127 43.9379 9.127C43.6079 9.127 43.3146 9.20767 43.0579 9.369C42.8086 9.523 42.6106 9.743 42.4639 10.029C42.3246 10.315 42.2549 10.6487 42.2549 11.03C42.2549 11.4113 42.3283 11.745 42.4749 12.031C42.6216 12.3097 42.8196 12.526 43.0689 12.68C43.3256 12.834 43.6153 12.911 43.9379 12.911ZM51.4863 14.209C50.973 14.209 50.522 14.121 50.1333 13.945C49.752 13.769 49.433 13.5343 49.1763 13.241C48.927 12.9403 48.7363 12.6067 48.6043 12.24C48.4797 11.8733 48.4173 11.4993 48.4173 11.118V10.909C48.4173 10.513 48.4797 10.1317 48.6043 9.765C48.7363 9.391 48.927 9.061 49.1763 8.775C49.433 8.48167 49.7483 8.25067 50.1223 8.082C50.4963 7.906 50.929 7.818 51.4203 7.818C52.0657 7.818 52.6047 7.961 53.0373 8.247C53.4773 8.52567 53.8073 8.896 54.0273 9.358C54.2473 9.81267 54.3573 10.304 54.3573 10.832V11.382H49.0663V10.447H53.4003L52.9273 10.909C52.9273 10.5277 52.8723 10.2013 52.7623 9.93C52.6523 9.65867 52.4837 9.44967 52.2563 9.303C52.0363 9.15633 51.7577 9.083 51.4203 9.083C51.083 9.083 50.797 9.16 50.5623 9.314C50.3277 9.468 50.148 9.69167 50.0233 9.985C49.906 10.271 49.8473 10.6157 49.8473 11.019C49.8473 11.393 49.906 11.7267 50.0233 12.02C50.1407 12.306 50.3203 12.5333 50.5623 12.702C50.8043 12.8633 51.1123 12.944 51.4863 12.944C51.8603 12.944 52.1647 12.8707 52.3993 12.724C52.634 12.57 52.7843 12.383 52.8503 12.163H54.2583C54.1703 12.5737 54.0017 12.933 53.7523 13.241C53.503 13.549 53.184 13.7873 52.7953 13.956C52.414 14.1247 51.9777 14.209 51.4863 14.209ZM57.2956 10.931L54.8756 5.97H56.4816L58.3296 9.853L57.9776 9.743H59.0226L58.6486 9.853L60.3316 5.97H61.8496L59.6166 10.931H57.2956ZM57.6916 14V10.689H59.2206V14H57.6916ZM66.0534 14V12.229H65.8004V10.26C65.8004 9.91533 65.7161 9.65867 65.5474 9.49C65.3788 9.32133 65.1184 9.237 64.7664 9.237C64.5831 9.237 64.3631 9.24067 64.1064 9.248C63.8498 9.25533 63.5894 9.26633 63.3254 9.281C63.0688 9.28833 62.8378 9.29933 62.6324 9.314V8.016C62.8011 8.00133 62.9918 7.98667 63.2044 7.972C63.4171 7.95733 63.6334 7.95 63.8534 7.95C64.0808 7.94267 64.2934 7.939 64.4914 7.939C65.1074 7.939 65.6171 8.01967 66.0204 8.181C66.4311 8.34233 66.7391 8.59533 66.9444 8.94C67.1571 9.28467 67.2634 9.73567 67.2634 10.293V14H66.0534ZM64.1284 14.154C63.6958 14.154 63.3144 14.077 62.9844 13.923C62.6618 13.769 62.4088 13.549 62.2254 13.263C62.0494 12.977 61.9614 12.6323 61.9614 12.229C61.9614 11.789 62.0678 11.4297 62.2804 11.151C62.5004 10.8723 62.8048 10.6633 63.1934 10.524C63.5894 10.3847 64.0514 10.315 64.5794 10.315H65.9654V11.228H64.5574C64.2054 11.228 63.9341 11.316 63.7434 11.492C63.5601 11.6607 63.4684 11.8807 63.4684 12.152C63.4684 12.4233 63.5601 12.6433 63.7434 12.812C63.9341 12.9807 64.2054 13.065 64.5574 13.065C64.7701 13.065 64.9644 13.0283 65.1404 12.955C65.3238 12.8743 65.4741 12.7423 65.5914 12.559C65.7161 12.3683 65.7858 12.1117 65.8004 11.789L66.1744 12.218C66.1378 12.636 66.0351 12.988 65.8664 13.274C65.7051 13.56 65.4778 13.78 65.1844 13.934C64.8984 14.0807 64.5464 14.154 64.1284 14.154ZM68.9012 14V8.027H70.1112V10.59H70.0012C70.0012 9.98867 70.0782 9.48633 70.2322 9.083C70.3862 8.67233 70.6136 8.36433 70.9142 8.159C71.2222 7.94633 71.6036 7.84 72.0582 7.84H72.1242C72.5862 7.84 72.9676 7.94633 73.2682 8.159C73.5762 8.36433 73.8036 8.67233 73.9502 9.083C74.1042 9.48633 74.1812 9.98867 74.1812 10.59H73.7962C73.7962 9.98867 73.8732 9.48633 74.0272 9.083C74.1886 8.67233 74.4196 8.36433 74.7202 8.159C75.0282 7.94633 75.4096 7.84 75.8642 7.84H75.9302C76.3922 7.84 76.7772 7.94633 77.0852 8.159C77.3932 8.36433 77.6242 8.67233 77.7782 9.083C77.9396 9.48633 78.0202 9.98867 78.0202 10.59V14H76.4912V10.447C76.4912 10.073 76.3959 9.776 76.2052 9.556C76.0146 9.32867 75.7432 9.215 75.3912 9.215C75.0392 9.215 74.7569 9.33233 74.5442 9.567C74.3316 9.79433 74.2252 10.1023 74.2252 10.491V14H72.6962V10.447C72.6962 10.073 72.6009 9.776 72.4102 9.556C72.2196 9.32867 71.9482 9.215 71.5962 9.215C71.2442 9.215 70.9619 9.33233 70.7492 9.567C70.5366 9.79433 70.4302 10.1023 70.4302 10.491V14H68.9012Z",fill:"currentColor"});function gr({className:t="h-5",markOnly:s=!1}){return e.jsxs("svg",{className:t,viewBox:s?"0 0 19 20":"0 0 79 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":s?"CodeYam":"CodeYam Editor",children:[e2,!s&&t2]})}const ME=Object.freeze(Object.defineProperty({__proto__:null,CyLogo:gr},Symbol.toStringTag,{value:"Module"}));function Bf({name:t}){const s={width:13,height:13,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},n=t.toLowerCase(),r=n.includes("landscape"),a=n.includes("iphone"),o=n.includes("ipad");return n.includes("laptop")?e.jsxs("svg",{...s,children:[e.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),e.jsx("path",{d:"M2 18h20"})]}):n.includes("desktop")||n.includes("monitor")?e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}):n.includes("tablet")||n.includes("ipad")?r?e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),o?e.jsx("path",{d:"M5 12h.01"}):e.jsx("path",{d:"M18 12h.01"})]}):e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),o?e.jsx("path",{d:"M12 5h.01"}):e.jsx("path",{d:"M12 18h.01"})]}):n.includes("phone")||n.includes("iphone")||n.includes("mobile")?r?e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2",y:"7",width:"20",height:"10",rx:a?3:2}),a?e.jsx("path",{d:"M5 9.5v5"}):e.jsx("path",{d:"M18 12h.01"})]}):e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:a?3:2}),a?e.jsx("path",{d:"M10 4.5h4"}):e.jsx("path",{d:"M12 18h.01"})]}):e.jsx("span",{className:"text-xs",children:t})}const IE=Object.freeze(Object.defineProperty({__proto__:null,DeviceIcon:Bf},Symbol.toStringTag,{value:"Module"})),nc=["·","✢","✳","✶","✻","✽"],s2=160;function br({testId:t="nav-build-dot-active",ariaLabel:s="Build in progress"}={}){const[n,r]=l.useState(0);return l.useEffect(()=>{const a=window.setInterval(()=>r(o=>(o+1)%nc.length),s2);return()=>window.clearInterval(a)},[]),e.jsx("span",{"data-testid":t,"aria-label":s,className:"mr-1 inline-block w-3 text-center text-[#D7FF63] leading-none text-[11px] tabular-nums",children:nc[n]})}const DE=Object.freeze(Object.defineProperty({__proto__:null,BuildSpinner:br},Symbol.toStringTag,{value:"Module"}));function qf({size:t=16}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}const LE=Object.freeze(Object.defineProperty({__proto__:null,EnvelopeIcon:qf},Symbol.toStringTag,{value:"Module"}));function Hf({size:t=16}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}const FE=Object.freeze(Object.defineProperty({__proto__:null,GearIcon:Hf},Symbol.toStringTag,{value:"Module"}));function Wf({onNavigateToBuild:t,onDismiss:s}){return l.useEffect(()=>(X("banner-mounted",{}),()=>{X("banner-unmounted",{})}),[]),e.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-1.5 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg border border-[#FF8B43]/60 bg-[#2a1500] shrink-0",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#FF8B43] shrink-0"}),e.jsxs("span",{className:"text-sm text-[#FF8B43]",children:["Claude is waiting for you."," ",e.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),s()},className:"p-0.5 text-[#FF8B43]/60 hover:text-[#FF8B43] transition-colors cursor-pointer",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const zE=Object.freeze(Object.defineProperty({__proto__:null,IdleBanner:Wf},Symbol.toStringTag,{value:"Module"})),n2=[{key:"home",label:"Home"},{key:"plan",label:"Plan"},{key:"build",label:"Build"},{key:"history",label:"History"}];function ja(){if(typeof document>"u")return;const t=document.activeElement;t instanceof HTMLElement&&t.blur()}function Gf({activeTab:t,onTabChange:s,onSendTranscript:n,buildIdle:r=!1,isAgentBuilding:a=!1,planIdle:o=!1,planActive:i=!1,bannerVisible:c=!1,onDismissIdleBanner:d,buildDisabled:u=!1,showLogo:h=!0}){const p=c&&t!=="build",f=r,m=a&&!r,b=m?"green":f?"orange":"none",g=l.useRef(b);l.useEffect(()=>{g.current!==b&&(X("build-tab-dot-change",{from:g.current,to:b}),g.current=b)},[b]);const x=o,y=i&&!o,v=y?"green":x?"orange":"none",j=l.useRef(v);return l.useEffect(()=>{j.current!==v&&(X("plan-tab-dot-change",{from:j.current,to:v}),j.current=v)},[v]),e.jsxs("div",{className:"shrink-0",children:[e.jsxs("div",{className:"@container bg-black h-10 flex items-center px-4 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(gr,{className:"h-5 text-white shrink-0 @max-[440px]:hidden"}),e.jsx(gr,{markOnly:!0,className:"h-5 text-white shrink-0 hidden @max-[440px]:block"})]}),e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"})]}),e.jsx("div",{className:"flex items-center gap-1",children:n2.map(w=>w.key==="build"&&u?e.jsx("button",{type:"button","data-nav-tab":"true","data-testid":"nav-build-disabled",title:"Connect your provider account on the Home tab to enable Build",onClick:()=>{s("home"),ja()},className:"px-2.5 py-2.5 text-sm text-[#5A5A5A] cursor-not-allowed font-light whitespace-nowrap",children:w.label},w.key):e.jsxs(or,{href:Os(w.key),"data-nav-tab":"true",onNavigate:()=>{s(w.key),ja(),w.key==="build"&&it()},className:`px-2.5 py-2.5 text-sm transition-colors cursor-pointer inline-flex items-center whitespace-nowrap ${t===w.key?"text-[#D7FF63] font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[w.key==="build"&&m&&e.jsx(br,{}),w.key==="build"&&f&&e.jsx("span",{"data-testid":"nav-build-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),w.key==="plan"&&y&&e.jsx(br,{testId:"nav-plan-dot-active",ariaLabel:"Planning in progress"}),w.key==="plan"&&x&&e.jsx("span",{"data-testid":"nav-plan-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),w.label]},w.key))})]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white",title:"Send Session Feedback",children:e.jsx(qf,{})}),e.jsx(or,{href:Os("settings"),"data-nav-tab":"true",onNavigate:()=>{s("settings"),ja()},className:`p-1.5 rounded-md transition-colors cursor-pointer inline-flex items-center ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white"}`,title:"Settings",children:e.jsx(Hf,{})})]}),p&&e.jsx(Wf,{onNavigateToBuild:()=>s("build"),onDismiss:d??(()=>{})})]})}const $E=Object.freeze(Object.defineProperty({__proto__:null,EditorNavBar:Gf},Symbol.toStringTag,{value:"Module"}));function Uf({projectTitle:t}){const s=typeof t=="string"&&t.trim().length>0;return e.jsxs("div",{"data-tauri-drag-region":!0,"data-testid":"desktop-title-bar",className:"shrink-0 bg-black h-9 flex items-center justify-center gap-2 px-4 select-none",children:[e.jsx(gr,{className:"h-5 text-white shrink-0"}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),e.jsx("span",{className:"text-white text-sm truncate max-w-[60%]",children:t})]})]})}const BE=Object.freeze(Object.defineProperty({__proto__:null,DesktopTitleBar:Uf},Symbol.toStringTag,{value:"Module"}));function Gr({target:t,onStored:s,onClose:n}){const[r,a]=l.useState(""),[o,i]=l.useState(!1),[c,d]=l.useState(null),[u,h]=l.useState(!1),p=l.useCallback(async()=>{if(r.trim()){i(!0),d(null),h(!1);try{const f=await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t.topic,provider:"passthrough",credential:r.trim(),credential_fields:{envVar:t.envVar}})});if(!f.ok){if(dw(f.status)==="transient"){h(!0),d(`The editor was briefly unreachable (HTTP ${f.status}). Your key wasn't rejected — try again.`);return}const b=await f.json().catch(()=>({}));d(b.error??`Could not store the key (HTTP ${f.status}).`);return}const m=await f.json().catch(()=>({}));if(m.success===!1||m.status==="error"){d(m.message??m.error??"The key was rejected.");return}a(""),s()}catch{h(!0),d("Could not reach the editor to store the key. Try again.")}finally{i(!1)}}},[r,t,s]);return e.jsx("div",{"data-testid":"app-service-credential-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:e.jsxs("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-[#3A3A3A] bg-[#161616] p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-white",children:["Add your ",t.serviceName," API key"]}),e.jsx("button",{"data-testid":"app-service-credential-close",onClick:n,className:"text-[#8E8E8E] hover:text-white cursor-pointer","aria-label":"Close",children:"✕"})]}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["The key is stored in",e.jsx("code",{className:"mx-1 text-[#D7FF63]",children:".codeyam/setup-connections.json"}),"(owner-only, gitignored) and injected into your app as",e.jsx("code",{className:"mx-1 text-[#D7FF63]",children:t.envVar})," — never committed."]}),t.docsUrl?e.jsx("a",{href:t.docsUrl,target:"_blank",rel:"noreferrer",className:"inline-block text-sm text-[#7EA6FF] hover:underline",children:"Where to find this key →"}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:r,onChange:f=>a(f.target.value),placeholder:`${t.serviceName} API key`,className:"flex-1 min-w-0 px-2 py-1.5 rounded bg-black border border-[#3A3A3A] text-white text-sm"}),e.jsx("button",{onClick:()=>void p(),disabled:o||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:o?"Saving…":"Save"})]}),c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-[#FF8B43]",children:c}),u?e.jsx("button",{"data-testid":"app-service-credential-retry",onClick:()=>void p(),disabled:o||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md border border-[#3A3A3A] text-white font-medium cursor-pointer disabled:opacity-50",children:o?"Saving…":"Retry"}):null]}):null]})})}const qE=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialModal:Gr},Symbol.toStringTag,{value:"Module"}));function r2(t,s){for(const n of t.filesByDirectory)for(const r of n.files)if(r.filePath===s)return r;return null}function Yf(t){return t>=80?"#16a34a":t>=50?"#eab308":"#dc2626"}function kn({coverage:t}){const s=Math.max(0,Math.min(100,t.percent)),n=Yf(s);return e.jsxs("div",{className:"flex items-center gap-2 min-w-[140px]","data-testid":"coverage-bar",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:e.jsx("div",{"data-testid":"coverage-bar-fill",className:"h-full rounded-full",style:{width:`${s}%`,backgroundColor:n}})}),e.jsxs("span",{className:"text-xs font-mono tabular-nums",style:{color:n},children:[Math.round(s),"%"]})]})}const HE=Object.freeze(Object.defineProperty({__proto__:null,CoverageBar:kn},Symbol.toStringTag,{value:"Module"}));function Vf({file:t,onSelectFile:s}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-directory-file-row",children:[e.jsx("button",{type:"button",onClick:()=>s(t),className:"flex-1 min-w-0 text-left text-xs text-gray-700 truncate hover:underline cursor-pointer",children:t.filePath}),e.jsx(kn,{coverage:t.coverage})]})}const WE=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryFileRow:Vf},Symbol.toStringTag,{value:"Module"}));function Kf({group:t,onSelectFile:s}){return e.jsxs("details",{"data-testid":"coverage-details-directory-group",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-gray-800",children:[t.directory||"(root)"," ·"," ",e.jsxs("span",{className:"text-gray-500",children:[t.files.length," file",t.files.length===1?"":"s"]})]}),e.jsx("ul",{className:"divide-y divide-gray-100 mt-2",children:t.files.map(n=>e.jsx(Vf,{file:n,onSelectFile:s},n.filePath))})]})}const GE=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryGroup:Kf},Symbol.toStringTag,{value:"Module"}));function Jf({directories:t,onSelectFile:s}){return t.length===0?null:e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-directories-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By directory"}),e.jsx("div",{className:"flex flex-col gap-3",children:t.map(n=>e.jsx(Kf,{group:n,onSelectFile:s},n.directory||"(root)"))})]})}const UE=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoriesSection:Jf},Symbol.toStringTag,{value:"Module"}));function Xf({entry:t,onSelectFile:s}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-entry-row",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{type:"button",onClick:()=>s(t.filePath),className:"text-sm font-medium text-gray-900 truncate text-left hover:underline cursor-pointer",children:t.name}),e.jsx("div",{className:"text-xs text-gray-500 truncate",children:t.filePath}),t.linkedTests.length>0&&e.jsxs("div",{className:"text-xs text-gray-400 truncate",children:[t.linkedTests.length," linked test",t.linkedTests.length===1?"":"s"]})]}),e.jsx(kn,{coverage:{percent:t.percent,hitLines:t.hitLines,totalLines:t.totalLines}})]})}const YE=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntryRow:Xf},Symbol.toStringTag,{value:"Module"}));function Qf({entries:t,onSelectFile:s}){return e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-entries-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By glossary entry"}),t.length===0?e.jsx("p",{className:"text-xs text-gray-500","data-testid":"coverage-details-entries-empty",children:"No glossary entries have coverage data yet."}):e.jsx("ul",{className:"divide-y divide-gray-100",children:t.map(n=>e.jsx(Xf,{entry:n,onSelectFile:s},`${n.filePath}::${n.name}`))})]})}const VE=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntriesSection:Qf},Symbol.toStringTag,{value:"Module"}));function Zf({file:t}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"orphaned-file-row",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"text-xs text-gray-500 truncate",children:t.filePath})}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-400",title:"Coverage at file level — no glossary entry maps to this file.",children:"file-level"}),e.jsx(kn,{coverage:t.coverage})]})}const KE=Object.freeze(Object.defineProperty({__proto__:null,OrphanedFileRow:Zf},Symbol.toStringTag,{value:"Module"}));function eg({files:t,onSelectFile:s}){return t.length===0?null:e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-orphaned-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"Orphaned files"}),e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:[t.length," file",t.length===1?"":"s"," with coverage but no glossary entry."]}),e.jsx("ul",{className:"divide-y divide-gray-100",children:t.map(n=>e.jsx("div",{onClick:()=>s(n.filePath),role:"button",tabIndex:0,className:"cursor-pointer",onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s(n.filePath))},children:e.jsx(Zf,{file:n})},n.filePath))})]})}const JE=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsOrphanedSection:eg},Symbol.toStringTag,{value:"Module"}));function tg({line:t,hits:s}){const n=s>0;return e.jsxs("li",{className:"flex items-center gap-3 py-1 font-mono text-xs","data-testid":n?"coverage-line-hit":"coverage-line-miss",children:[e.jsx("span",{className:"w-12 text-right text-gray-400",children:t}),e.jsx("span",{className:n?"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:n?`×${s}`:"miss"})]})}const XE=Object.freeze(Object.defineProperty({__proto__:null,CoverageLineRow:tg},Symbol.toStringTag,{value:"Module"}));function sg({file:t,onBack:s}){const n=Object.entries(t.lines).map(([r,a])=>({line:Number(r),hits:a})).sort((r,a)=>r.line-a.line);return e.jsxs("div",{"data-testid":"coverage-file-drilldown",className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:s,className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":"coverage-file-drilldown-back",children:"← Back"}),e.jsx("div",{className:"text-sm font-medium text-gray-900 truncate mt-1",children:t.filePath})]}),e.jsx(kn,{coverage:t.coverage})]}),n.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:"No instrumented lines in this file."}):e.jsx("ul",{className:"divide-y divide-gray-100 max-h-[50vh] overflow-y-auto","data-testid":"coverage-file-drilldown-lines",children:n.map(({line:r,hits:a})=>e.jsx(tg,{line:r,hits:a},r))})]})}const QE=Object.freeze(Object.defineProperty({__proto__:null,CoverageFileDrilldown:sg},Symbol.toStringTag,{value:"Module"}));function ng({title:t,aggregate:s,aggregateTestId:n}){return e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900 m-0",children:t}),s&&s.totalLines>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[s.hitLines,"/",s.totalLines," lines"]}),e.jsxs("span",{className:"text-xs font-semibold",style:{color:Yf(s.percent)},"data-testid":n,children:[Math.round(s.percent),"% overall"]})]})]})}const ZE=Object.freeze(Object.defineProperty({__proto__:null,CoverageSectionHeader:ng},Symbol.toStringTag,{value:"Module"}));function rg({warnings:t}){return t.length===0?null:e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"coverage-warnings-banner",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-amber-800 m-0",children:"Coverage Warnings"}),e.jsx("ul",{className:"mt-1 space-y-1 text-sm text-amber-700 list-none p-0 m-0",children:t.map((s,n)=>e.jsx("li",{className:"break-words",children:s},n))})]})]})})}const eM=Object.freeze(Object.defineProperty({__proto__:null,CoverageWarningsBanner:rg},Symbol.toStringTag,{value:"Module"}));function ag({onClose:t,fetchDetails:s=a2,initialData:n}){const[r,a]=l.useState(n??null),[o,i]=l.useState(null),[c,d]=l.useState(null);l.useEffect(()=>{if(n)return;let p=!1;return s().then(f=>{p||a(f)}).catch(f=>{p||i(f instanceof Error?f.message:String(f))}),()=>{p=!0}},[s,n]);const u=l.useCallback(p=>{p.key==="Escape"&&(p.preventDefault(),c?d(null):t())},[t,c]);l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]);const h=p=>{if(!r)return;const f=r2(r,p);f&&d(f)};return e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"coverage-details-modal",onClick:t,children:e.jsxs("div",{className:"max-w-3xl w-full mx-4 p-6 rounded-lg bg-[var(--bg-card)] max-h-[90vh] overflow-y-auto",onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:"Project coverage"}),e.jsx("button",{type:"button",onClick:t,className:"text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer","data-testid":"coverage-details-modal-close","aria-label":"Close",children:"✕"})]}),o&&e.jsxs("p",{className:"text-sm text-red-700","data-testid":"coverage-details-modal-error",children:["Failed to load coverage details: ",o]}),!r&&!o&&e.jsx("p",{className:"text-sm text-[var(--text-muted)]","data-testid":"coverage-details-modal-loading",children:"Loading coverage details…"}),r&&c&&e.jsx(sg,{file:c,onBack:()=>d(null)}),r&&!c&&e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ng,{title:"Overall",aggregate:r.projectWide,aggregateTestId:"coverage-details-modal-aggregate"}),r.coverageWarnings.length>0&&e.jsx(rg,{warnings:r.coverageWarnings}),e.jsx(Qf,{entries:r.entries,onSelectFile:h}),e.jsx(eg,{files:r.orphanedFiles,onSelectFile:h}),e.jsx(Jf,{directories:r.filesByDirectory,onSelectFile:d})]})]})})}function a2(){return fetch("/api/coverage/details").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()})}const tM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsModal:ag},Symbol.toStringTag,{value:"Module"}));function o2(t,s){const n=t.filter(r=>!tn(r.route));if(n.length>0){if(n.length===1){const r=n[0],a=r.scenarios.filter(o=>!tn(o.url));if(a.length>1)return a.map((o,i)=>({key:o.slug||`scn-${i}`,name:o.name,route:r.route||null,scenarioSlug:o.slug,screenshotPath:o.screenshotPaths[0]??null,screenshotCb:o.screenshotCapturedAtMs??null}))}return n.map((r,a)=>{const o=r.scenarios.find(c=>c.screenshotPaths.length>0),i=o??r.scenarios[0];return{key:r.route||`route-${a}`,name:r.displayName||r.route||"Page",route:r.route||null,scenarioSlug:(i==null?void 0:i.slug)??null,screenshotPath:(o==null?void 0:o.screenshotPaths[0])??null,screenshotCb:(o==null?void 0:o.screenshotCapturedAtMs)??null}})}return s.filter(r=>!tn(r.url)).map((r,a)=>({key:r.slug||`scn-${a}`,name:r.name,route:r.url,scenarioSlug:r.slug,screenshotPath:r.screenshotPaths[0]??null,screenshotCb:r.screenshotCapturedAtMs??null}))}function og({items:t,maxVisible:s=6,showAll:n=!1,onSelect:r,onOpenAll:a}){const o=n?t:t.slice(0,s),i=t.length-o.length;return e.jsxs("div",{className:"exdoor",children:[e.jsxs("button",{type:"button",className:"exhead",onClick:a,children:[e.jsx("div",{className:"dic",children:e.jsx(Ou,{size:20})}),e.jsxs("div",{className:"grow",children:[e.jsx("div",{className:"dname",children:"Explore your app"}),e.jsx("div",{className:"ddesc",children:"Every page of your app. Click one to see it live."})]}),e.jsx("span",{className:"open",children:"Open all →"})]}),e.jsxs("div",{className:"rail",children:[o.length===0?e.jsx("div",{className:"railempty",children:"No pages registered yet — they'll appear here as you build."}):o.map(c=>e.jsxs("button",{type:"button",className:"pcard",onClick:()=>r(c),children:[e.jsx("div",{className:"pthumb",children:c.screenshotPath?e.jsx("img",{className:"pshot",src:ns(c.screenshotPath,c.screenshotCb??void 0),alt:`${c.name} preview`,loading:"lazy"}):e.jsx("div",{className:"pnopreview",children:"No preview"})}),e.jsx("div",{className:"pname",children:c.name})]},c.key)),i>0?e.jsx("div",{className:"allcard",children:e.jsxs("button",{type:"button",className:"alltile",onClick:a,children:[e.jsxs("span",{className:"n",children:["+",i]}),e.jsx("span",{className:"l",children:i===1?"page":"pages"})]})}):null]})]})}const sM=Object.freeze(Object.defineProperty({__proto__:null,ExploreRail:og},Symbol.toStringTag,{value:"Module"})),nr=5;function ig({admin:t,isBuilding:s,buildingLabel:n,buildingStepLabel:r,buildingStepIndicator:a=null,buildingStatus:o="building",buildingProgress:i=null,lastBuiltLabel:c,plansCount:d,learnDoneCount:u,exploreSlot:h,onOpenBuilding:p,onStartNewFeature:f,onResetBuild:m,onOpenPlans:b,onOpenLearn:g,onExternalServices:x}){const y=Math.max(0,Math.min(nr,u)),v=Array.from({length:nr},(j,w)=>w<y);return e.jsxs("div",{className:"doorrows",children:[e.jsx(ii,{isBuilding:s,buildingLabel:n,buildingStepLabel:r,buildingStepIndicator:a,buildingStatus:o,buildingProgress:i,lastBuiltLabel:c,onOpenBuilding:p,onStartNewFeature:f,onResetBuild:m}),e.jsxs("button",{type:"button",className:"drow",onClick:b,children:[e.jsx("div",{className:"dic ic-plan",children:e.jsx(Ru,{size:19})}),e.jsxs("div",{className:"dmain",children:[e.jsx("div",{className:"dname",children:"Plans"}),e.jsx("div",{className:"ddesc",children:"Changes you've described, waiting to build next."})]}),e.jsxs("div",{className:"dright",children:[e.jsxs("div",{className:"dmeta",children:[e.jsxs("span",{className:"stat",children:[d," queued"]}),"to build"]}),e.jsx("span",{className:"arr",children:"→"})]})]}),h,t?e.jsxs("button",{type:"button",className:"drow quiet",onClick:g,children:[e.jsx("div",{className:"dic ic-learn",children:e.jsx(Pr,{size:19})}),e.jsxs("div",{className:"dmain",children:[e.jsx("div",{className:"dname",children:"Setup"}),e.jsx("div",{className:"ddesc",children:"Hosting, real data, security, emails. The things every app eventually needs."})]}),e.jsxs("div",{className:"dright",children:[e.jsxs("div",{className:"dmeta",children:[e.jsxs("span",{className:"stat",children:[y," of ",nr," set up"]}),e.jsx("span",{className:"lines",children:v.map((j,w)=>e.jsx("span",{className:j?"ln done":"ln"},w))})]}),e.jsx("span",{className:"arr",children:"→"})]})]}):null,t?e.jsxs("button",{type:"button",className:"drow quiet",onClick:x,children:[e.jsx("div",{className:"dic ic-learn",children:e.jsx(Lt,{size:19})}),e.jsxs("div",{className:"dmain",children:[e.jsx("div",{className:"dname",children:"External Services"}),e.jsx("div",{className:"ddesc",children:"Domains, hosting, API keys, payments, database. Every outside service this app depends on, in one place."})]}),e.jsx("div",{className:"dright",children:e.jsx("span",{className:"arr",children:"→"})})]}):null]})}const nM=Object.freeze(Object.defineProperty({__proto__:null,DoorRows:ig,LEARN_TOPIC_COUNT:nr},Symbol.toStringTag,{value:"Module"}));function lg({projectTitle:t,app:s,routeEntities:n,allScenarios:r,admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:f,learnDoneCount:m,onSelectScenario:b,onOpenAllSimulations:g,onOpenBuilding:x,onStartNewFeature:y,onResetBuild:v,onOpenPlans:j,onOpenLearn:w,onExternalServices:_,onBackToProjects:S,launcherUrl:C,projectCount:N=0,showExploreRail:T=!0}){const O=l.useMemo(()=>o2(n,r),[n,r]),k=!!C||N>=2,[D,$]=l.useState(!1),B=async()=>{if(C){window.location.href=C;return}if(!D){$(!0);try{const E=await fetch("/api/launcher/ensure",{method:"POST"}),A=await E.json().catch(()=>({}));if(E.ok&&typeof A.url=="string"){window.location.href=A.url;return}$(!1)}catch{$(!1)}}},q=(t==null?void 0:t.trim())||s.name||"Your project",P=E=>{E.scenarioSlug?b(E.scenarioSlug):g()};return e.jsxs("div",{className:"home-landing",children:[S||k?e.jsxs("div",{className:"crumbs",children:[k?e.jsx("button",{type:"button",className:"back",disabled:D,onClick:()=>{B()},children:D?"Opening launcher…":"‹ All projects"}):null,S?e.jsx("button",{type:"button",className:"back",onClick:S,children:"‹ Projects"}):null]}):null,e.jsx("div",{className:"project",children:q}),e.jsx("div",{className:"seclabel",children:"Your project"}),e.jsx(ig,{admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:f,learnDoneCount:m,exploreSlot:T?e.jsx(og,{items:O,showAll:!0,onSelect:P,onOpenAll:g}):null,onOpenBuilding:x,onStartNewFeature:y,onResetBuild:v,onOpenPlans:j,onOpenLearn:w,onExternalServices:_})]})}const rM=Object.freeze(Object.defineProperty({__proto__:null,HomeLanding:lg},Symbol.toStringTag,{value:"Module"})),i2={Domain:"blue",Hosting:"blue",Payments:"green",Database:"indigo","Database ORM":"indigo","Backend platform":"indigo",Authentication:"amber","Transactional email":"lime","Product analytics":"lime","Error monitoring":"amber"},rc=["Domain","Hosting","Database","Database ORM","Backend platform","Authentication","Payments","Transactional email","Product analytics","Error monitoring"];function l2(t){var n;const s=t.trim().split(/\s+/).filter(Boolean);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():(((n=s[0])==null?void 0:n[0])??"?").toUpperCase()}function cg(t){return t.envVars.length>0&&!t.credentialPresent}function c2(t){if(t.note)return t.note;const s=t.evidence[0];if(!s)return t.category;const n=t.evidence.length>1?` · +${t.evidence.length-1} more`:"";return`${s.value} in ${s.source}${n}`}function d2(t){const s=[{label:"Category",value:t.category}];t.envVars.length>0&&s.push({label:"Env vars",value:t.envVars.join(", "),mono:!0}),s.push({label:t.credentialPresent?"Key":"Key status",value:t.credentialPresent?"Configured":"Not set yet"});for(const n of t.evidence.slice(0,4))s.push({label:"Detected in",value:`${n.value} · ${n.source}`,mono:!0});return t.docsUrl&&s.push({label:"Docs",value:t.docsUrl}),s}function u2(t){const s=[],n=t.envVars[0];n&&s.push({text:n,kind:"env"}),t.envVars.length>0&&t.credentialPresent&&s.push({text:"Key set",kind:"set"});const r=cg(t);return{monogram:l2(t.name),providerId:t.key,category:t.category,tone:i2[t.category]??"lime",name:t.name,desc:c2(t),tags:s.length?s:void 0,actionLabel:r?"Add key":void 0,actionKey:r?t.key:void 0,attn:r,detail:d2(t)}}function ac(t){const s=rc.indexOf(t);return s===-1?rc.length:s}function h2(t){const s=(t??[]).filter(c=>c.status!=="dismissed");if(s.length===0)return{groups:[],summary:""};const n=new Map;for(const c of s){const d=n.get(c.category);d?d.push(c):n.set(c.category,[c])}const r=[...n.entries()].sort(([c],[d])=>ac(c)-ac(d)||c.localeCompare(d)).map(([c,d])=>({label:c,items:d.slice().sort((u,h)=>u.name.localeCompare(h.name)).map(u2)})),a=s.filter(cg).length,o=s.length===1?"service":"services",i=a>0?`${s.length} ${o} · ${a} need${a===1?"s":""} your attention`:`${s.length} ${o} detected`;return{groups:r,summary:i}}function p2(t){return t.credentialPresent?" (key configured)":t.envVars.length>0?" (needs a key)":""}function m2(t,s){const n=(t??[]).filter(o=>o.status!=="dismissed"),r=n.length?`
27
-
28
- Detected in this project so far:
29
- ${n.map(o=>`- ${o.name} (${o.category})${p2(o)}`).join(`
30
- `)}`:`
31
-
32
- No external services have been auto-detected in this project yet.`,a=s!=null&&s.trim()?`
33
-
34
- The user opened this chat with the following message. Respond to it directly and helpfully as your FIRST reply, before anything else:
35
- "${s.trim()}"`:`
36
-
37
- 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,`
38
-
39
- Help with whatever they want here: what's wired up, what's missing an API key, `,"how to add or remove a service, and renewals or monthly cost. Those last two are NOT in ","the repo, so ASK the user rather than guessing. Be concise and concrete.",a].join("")}function dg({onBack:t}){const{services:s,refetch:n}=Qo(),[r,a]=l.useState(!1),[o,i]=l.useState(void 0),[c,d]=l.useState(null),{groups:u,summary:h}=l.useMemo(()=>h2(s),[s]),p=f=>{var g;const m=(s??[]).find(x=>x.key===f),b=(g=m==null?void 0:m.envVars)==null?void 0:g[0];!m||!b||d({serviceName:m.name,envVar:b,topic:m.topic,docsUrl:m.docsUrl})};return e.jsxs("div",{className:"xsvc-connected",children:[e.jsx(Xh,{groups:u,summary:h,onBack:t,onOpenChat:f=>{i(f),a(!0)},onAction:p}),r?e.jsxs("div",{className:"xsvc-chatdock",role:"dialog","aria-label":"Chat about external services",children:[e.jsxs("div",{className:"xsvc-chatdock-head",children:[e.jsx("span",{children:"Chat about your external services"}),e.jsx("button",{type:"button",className:"xsvc-chatdock-close",onClick:()=>a(!1),children:"Close ✕"})]}),e.jsx(vs,{chatName:"external-services",prompt:m2(s,o),height:380,onClose:()=>a(!1)})]}):null,c?e.jsx(Gr,{target:c,onStored:()=>{d(null),n()},onClose:()=>d(null)}):null]})}const aM=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesScreenConnected:dg},Symbol.toStringTag,{value:"Module"})),f2={provider:"vercel"},ug={"dev-accounts":bp,"store-assets":xp,"store-listing":yp,"testing-distribution":vp,"push-notifications":jp,"crash-reporting":wp,"in-app-purchases":_p,"app-privacy":kp,"app-review":Sp};function oc(t){return t in ug}function g2(){const[t,s]=l.useState(null),n=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();s(Array.isArray(i)?i:[])}catch{s([])}},[]);l.useEffect(()=>{n()},[n]);const r=l.useCallback((o,i)=>{s(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(()=>{n()})},[n]),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 n(),{key:c.key,existed:!!c.existed}},[n]);return{topics:t,setStatus:r,addTopic:a}}function b2(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!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();n||s(Array.isArray(a)?a:[])}catch{n||s([])}})(),()=>{n=!0}},[]),{groups:t}}function x2(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!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();n||s(a)}catch{n||s(null)}})(),()=>{n=!0}},[]),{recipe:t}}function y2(t,s){if(s(),hw()){Pa(t);return}uw(bl).then(n=>{n?Pa(t):console.warn(`[setup-chat] Build terminal did not attach within ${bl}ms; prompt not sent`)})}const v2=new Set(["share-testing","store-accounts","store-assets","permissions-justification","oauth-verification","privacy-policy","single-purpose-listing","manifest-versioning","submit-review"]);function hg({appDetailProps:t,appOverviewProps:s,selectedApp:n,projectTitle:r,admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:f,onNavigateToPlan:m,onNavigateToBuild:b,onResetBuild:g,onBackToProjects:x,launcherUrl:y,projectCount:v,onOpenSetupBrowser:j}){const[w,_]=l.useState(!1),S=()=>_(!0),C=()=>_(!1),[N,T]=l.useState("landing"),[O,k]=l.useState(null),[D,$]=l.useState(null),{topics:B,setStatus:q,addTopic:P}=g2(),E=(B==null?void 0:B.filter(F=>F.status==="done").length)??0,A=F=>{var te;return((te=B==null?void 0:B.find(W=>W.key===F))==null?void 0:te.status)??"available"},{services:H,dismiss:z,refetch:G}=Qo(),[Q,se]=l.useState(null),le=l.useCallback(F=>{var W;const te=(W=F.envVars)==null?void 0:W[0];te&&se({serviceName:F.name,envVar:te,topic:F.topic,docsUrl:F.docsUrl})},[]),{recipe:re}=x2(),U=o1(ku()),{groups:ge}=b2(),ie=(B==null?void 0:B.some(F=>F.key==="dev-accounts"))??!1,be=(B==null?void 0:B.some(F=>F.key==="deploy-target"))??!1,K=F=>{F==="run-locally"?T("run-locally"):ie&&oc(F)?($(F),T("mobile-setup")):v2.has(F)?T(F):oc(F)?($(F),T("mobile-setup")):(k(F),T("topic"))},L=!!(t.selectedRouteEntity||t.selectedEntityHash);let I;if(!n)I=e.jsx(fm,{...s,onCoverageClick:S},"app-overview");else if(L||N==="detail"){const F=N==="detail"&&!L;I=e.jsxs(e.Fragment,{children:[F?e.jsx("div",{className:"home-landing",style:{padding:"20px 28px 0"},children:e.jsxs("div",{className:"crumbs",style:{marginBottom:0},children:[e.jsx("button",{type:"button",className:"back",onClick:()=>T("landing"),"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:()=>T("landing"),children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Explore your app"})]})}):null,e.jsx(Cu,{app:n,...t,onCoverageClick:S})]})}else if(N==="learn")I=e.jsx(Ba,{topics:B,detectedServices:H,onBack:()=>T("landing"),onOpenHosting:()=>T("hosting"),onOpenTopic:K,onOpenLibraries:()=>T("libraries"),onDismissService:z,onAddCredential:le,onCreateTopic:P,onOpenConcepts:()=>T("concepts")});else if(N==="libraries")I=e.jsx(qu,{groups:ge,onBack:()=>T("learn")});else if(N==="concepts")I=e.jsx(Uh,{onBack:()=>T("learn")});else if(N==="external-services")I=e.jsx(dg,{onBack:()=>T("landing")});else if(N==="hosting")I=e.jsx(ap,{connector:f2,onBack:()=>T("learn"),onComplete:()=>q("hosting","done"),onOpenSharedBrowser:j});else if(N==="run-locally")I=e.jsx(op,{recipe:re,onBack:()=>T("learn"),status:A("run-locally"),onMarkDone:()=>q("run-locally","done"),onRevert:()=>q("run-locally","available")});else if(N==="share-testing")I=e.jsx(gp,{onBack:()=>T("learn"),status:A("share-testing"),onComplete:()=>q("share-testing","done"),onRevert:()=>q("share-testing","available")});else if(N==="store-accounts")I=e.jsx(ip,{onBack:()=>T("learn"),status:A("store-accounts"),onComplete:()=>q("store-accounts","done"),onRevert:()=>q("store-accounts","available")});else if(N==="store-assets")I=e.jsx(lp,{onBack:()=>T("learn"),status:A("store-assets"),onComplete:()=>q("store-assets","done"),onRevert:()=>q("store-assets","available")});else if(N==="permissions-justification")I=e.jsx(dp,{onBack:()=>T("learn"),status:A("permissions-justification"),onComplete:()=>q("permissions-justification","done"),onRevert:()=>q("permissions-justification","available")});else if(N==="oauth-verification")I=e.jsx(hp,{onBack:()=>T("learn"),status:A("oauth-verification"),onComplete:()=>q("oauth-verification","done"),onRevert:()=>q("oauth-verification","available")});else if(N==="privacy-policy")I=e.jsx(up,{onBack:()=>T("learn"),status:A("privacy-policy"),onComplete:()=>q("privacy-policy","done"),onRevert:()=>q("privacy-policy","available")});else if(N==="single-purpose-listing")I=e.jsx(pp,{onBack:()=>T("learn"),status:A("single-purpose-listing"),onComplete:()=>q("single-purpose-listing","done"),onRevert:()=>q("single-purpose-listing","available")});else if(N==="manifest-versioning")I=e.jsx(mp,{onBack:()=>T("learn"),status:A("manifest-versioning"),onComplete:()=>q("manifest-versioning","done"),onRevert:()=>q("manifest-versioning","available")});else if(N==="submit-review")I=e.jsx(fp,{onBack:()=>T("learn"),status:A("submit-review"),onComplete:()=>q("submit-review","done"),onRevert:()=>q("submit-review","available")});else if(N==="topic"&&O){const F=(B==null?void 0:B.find(te=>te.key===O))??null;I=e.jsx(Gh,{topicKey:O,topicName:F==null?void 0:F.name,topicDesc:F==null?void 0:F.desc,isBackend:be,onBack:()=>T("learn"),onComplete:te=>q(te,"done"),onChatWithAI:te=>y2(te,b)})}else if(N==="mobile-setup"&&D){const F=ug[D];I=F?e.jsx(F,{platform:U,onBack:()=>T("learn"),status:A(D),onComplete:()=>q(D,"done"),onRevert:()=>q(D,"available")}):e.jsx(Ba,{topics:B,detectedServices:H,onBack:()=>T("landing"),onOpenHosting:()=>T("hosting"),onOpenTopic:K,onDismissService:z,onAddCredential:le})}else I=e.jsxs(e.Fragment,{children:[e.jsx(lg,{app:n,projectTitle:r,routeEntities:t.routeEntities,allScenarios:t.allScenarios,admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:f,learnDoneCount:E,onSelectScenario:t.onSelectScenario,onOpenAllSimulations:()=>T("detail"),onOpenBuilding:b,onStartNewFeature:b,onResetBuild:g,onOpenPlans:m,onOpenLearn:()=>T("learn"),onExternalServices:()=>T("external-services"),onBackToProjects:x,launcherUrl:y,projectCount:v,showExploreRail:!1}),e.jsx(Qd,{appDetailProps:t,selectedApp:n})]});return e.jsxs(Iu,{children:[I,w&&e.jsx(ag,{onClose:C}),Q?e.jsx(Gr,{target:Q,onStored:()=>{se(null),G()},onClose:()=>se(null)}):null]})}const oM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellHomeTabContent:hg},Symbol.toStringTag,{value:"Module"}));function pg({activeTab:t,awaitingPlanLaunchChoice:s,buildLaunchGateArmed:n,buildActivated:r,hideResultsCommandKey:a,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,onAgentIdle:d,onAgentActive:u,onUserInput:h,notifSettings:p,onSettingsChange:f,provider:m,onRestorePreview:b,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:v,launchingSlug:j,launchError:w,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:C}){return r?e.jsx($f,{awaitingPlanLaunchChoice:s,buildLaunchGateArmed:n,buildActivated:r,activeTab:t,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,hideResultsCommandKey:a,onAgentIdle:d,onAgentActive:u,onUserInput:h,notifSettings:p,onSettingsChange:f,provider:m,onRestorePreview:b,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:v,launchingSlug:j,launchError:w,onReorderPlans:_,isAgentBuilding:S,featureCompleteActive:C}):null}const iM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellBuildLayer:pg},Symbol.toStringTag,{value:"Module"}));function mg({onMouseDown:t}){return e.jsx("div",{onMouseDown:t,className:"shrink-0 flex items-center justify-center group",style:{width:12,cursor:"col-resize",background:"var(--bg-surface)",borderLeft:"1px solid var(--border-default)",borderRight:"1px solid var(--border-default)"},children:e.jsx("div",{className:"w-0.5 h-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"var(--text-dim)"}})})}const lM=Object.freeze(Object.defineProperty({__proto__:null,PanelDivider:mg},Symbol.toStringTag,{value:"Module"})),j2=[{key:"editor",label:"Editor"},{key:"preview",label:"Preview"}];function fg({active:t,onChange:s,isAgentBuilding:n=!1,buildIdle:r=!1}){const a=n&&!r,o=r;return e.jsx("div",{"data-testid":"mobile-pane-switcher",className:"shrink-0 flex w-full",style:{background:"var(--bg-nav)",borderTop:"1px solid var(--border-default)",paddingBottom:"env(safe-area-inset-bottom)"},children:j2.map(i=>{const c=t===i.key;return e.jsxs("button",{"data-testid":`mobile-pane-switcher-${i.key}`,onClick:()=>s(i.key),"aria-pressed":c,className:`flex-1 flex items-center justify-center gap-1 h-12 text-sm border-t-2 transition-colors cursor-pointer ${c?"text-[#D7FF63] border-[#D7FF63] font-medium":"text-[#8E8E8E] border-transparent font-light"}`,children:[i.key==="editor"&&a&&e.jsx(br,{}),i.key==="editor"&&o&&e.jsx("span",{"data-testid":"mobile-pane-switcher-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),i.label]},i.key)})})}const cM=Object.freeze(Object.defineProperty({__proto__:null,MobilePaneSwitcher:fg},Symbol.toStringTag,{value:"Module"}));function gg({isCollapsed:t,leftPane:s,onResizeStart:n,previewPane:r,splitRef:a,isNarrow:o,mobilePane:i,onMobilePaneChange:c,isAgentBuilding:d=!1,buildIdle:u=!1,hidePreview:h=!1,onHomeLivePageBack:p}){return o?e.jsxs("div",{ref:a,className:"fixed inset-0 flex flex-col",style:{background:"var(--bg-surface)"},children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:`absolute inset-0 flex ${i==="editor"?"":"hidden"}`,children:s}),e.jsx("div",{className:`absolute inset-0 flex ${i==="preview"?"":"hidden"}`,children:r})]}),e.jsx(fg,{active:i,onChange:c,isAgentBuilding:d,buildIdle:u})]}):p?e.jsx("div",{ref:a,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:r}):h?e.jsx("div",{ref:a,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:s}):e.jsxs("div",{ref:a,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:[!t&&e.jsxs(e.Fragment,{children:[s,e.jsx(mg,{onMouseDown:n})]}),r]})}const dM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLayout:gg},Symbol.toStringTag,{value:"Module"}));function bg(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i}=_s(),c=l.useCallback(async()=>{r(!0),o(null);try{const d=await fetch("/api/plans");if(!d.ok)throw new Error(`HTTP ${d.status}`);const u=await d.json();s(Array.isArray(u)?u.map(h=>({...h,dependsOn:Array.isArray(h.dependsOn)?h.dependsOn:[]})):[])}catch(d){o(d instanceof Error?d.message:"Failed to load plans")}finally{r(!1)}},[]);return l.useEffect(()=>{c()},[c,i]),{plans:t,loading:n,error:a,refetch:c}}function xg(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i,claimsVersion:c}=_s(),d=l.useCallback(async()=>{r(!0),o(null);try{const u=await fetch("/api/plan-claims");if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=await u.json();s(Array.isArray(h)?h:[])}catch(u){o(u instanceof Error?u.message:"Failed to load plan claims")}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d,i,c]),{claims:t,loading:n,error:a,refetch:d}}function yg(){const[t,s]=l.useState(null),{claimsVersion:n}=_s(),r=l.useCallback(async()=>{try{const a=await fetch("/api/plan-claims/sync-status");if(!a.ok)return;const o=await a.json();s(o)}catch{}},[]);return l.useEffect(()=>{r()},[r,n]),l.useEffect(()=>{const a=setInterval(()=>void r(),1e4);return()=>clearInterval(a)},[r]),{status:t}}function w2(){const[t,s]=l.useState(null),n=l.useCallback(async()=>{try{const r=await fetch("/api/server/staleness");if(!r.ok)return;const a=await r.json();s(a)}catch{}},[]);return l.useEffect(()=>{n()},[n]),l.useEffect(()=>{const r=setInterval(()=>void n(),6e4);return()=>clearInterval(r)},[n]),{staleness:t}}const wa="codeyam-editor editor plan-claims-status",_2="git push origin HEAD";function vg(t,s){switch(t){case"credential":return{message:"Plan tracking isn't reaching the remote — git credentials need refreshing. Run the command below from a shell to wake the credential helper.",command:_2};case"network":return{message:"Plan tracking can't reach the remote (network failure). Check connectivity, then run the command below for details.",command:wa};case"git-spawn":return{message:"Plan tracking can't launch git. Run the command below for the failing invocation.",command:wa};default:return{message:`Plan tracking is failing (${s} failed ticks). Teammates' in-flight plans may not appear. Run the command below for details.`,command:wa}}}function jg({status:t}){const{copied:s,copy:n}=gn(),r=(t==null?void 0:t.consecutiveFailures)??0;if((t==null?void 0:t.enabled)===!1||r<3)return null;const{message:a,command:o}=vg(t==null?void 0:t.lastErrorCategory,r);return e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3","data-testid":"plan-claim-sync-banner",role:"alert",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm text-amber-800",children:[a," ",e.jsx("code",{className:"text-xs",children:o})," ",e.jsx("button",{type:"button",className:"underline text-amber-700 hover:text-amber-900",onClick:()=>void n(o),children:s?"Copied":"Copy command"})]})]})})}const uM=Object.freeze(Object.defineProperty({__proto__:null,PlanClaimSyncBanner:jg,planClaimSyncBannerContent:vg},Symbol.toStringTag,{value:"Module"})),ic="codeyam-editor editor restart-server";function Ti({staleness:t,backendOutOfDate:s=!1}){var i;const{copied:n,copy:r}=gn(),a=!!(t!=null&&t.stale);if(!a&&!s)return null;const o=((i=t==null?void 0:t.info)==null?void 0:i.minutesStale)??0;return e.jsx("div",{className:"rounded-lg p-3","data-testid":"server-staleness-banner",role:"alert",style:{background:"rgba(239, 111, 111, 0.08)",border:"0.5px solid rgba(239, 111, 111, 0.3)"},children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--red-300)"},children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[a?e.jsxs(e.Fragment,{children:["The editor-server is running a stale binary (rebuilt ",o," min ago). Restart it to pick up the latest plan tracking fixes."]}):e.jsx(e.Fragment,{children:"The editor-server is out of date — it's running an older build that can't drive the Build tab. Restart it to reconnect."})," ","Run"," ",e.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:ic}),"."," ",e.jsx("button",{type:"button",className:"underline",style:{color:"var(--red-300)"},onClick:()=>void r(ic),children:n?"Copied":"Copy command"})]})]})})}const hM=Object.freeze(Object.defineProperty({__proto__:null,ServerStalenessBanner:Ti},Symbol.toStringTag,{value:"Module"}));function wg(t){const s=new Map;for(const n of t){const r=s.get(n.slug);(!r||r.source!=="local"&&n.source==="local")&&s.set(n.slug,n)}return s}function k2(t,s){return t.filter(n=>n.source==="local"||!s.has(n.slug))}function _g(t=10){const[s,n]=l.useState([]),[r,a]=l.useState(!0),[o,i]=l.useState(null),c=l.useCallback(async()=>{a(!0),i(null);try{const d=await fetch(`/api/plans/completed?limit=${t}`);if(!d.ok)throw new Error(`HTTP ${d.status}`);const u=await d.json();n(Array.isArray(u)?u:[])}catch(d){i(d instanceof Error?d.message:"Failed to load completed plans")}finally{a(!1)}},[t]);return l.useEffect(()=>{c()},[c]),{plans:s,loading:r,error:o,refetch:c}}function kg(){const[t,s]=l.useState(()=>new Set),[n,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:[];s(new Set(u.filter(h=>typeof h=="string")))}catch(c){o(c instanceof Error?c.message:"Failed to load completed plan slugs")}finally{r(!1)}},[]);return l.useEffect(()=>{i()},[i]),{slugs:t,loading:n,error:a,refetch:i}}function S2(t,s,n){const r=new Map(s.map(a=>[a.slug,a]));return t.dependsOn.map(a=>{var o;return{slug:a,title:((o=r.get(a))==null?void 0:o.title)??null,satisfied:n.has(a)}})}function Sg(t){return t.filter(s=>!s.satisfied)}function Ng(t){const{slugs:s}=kg();return l.useMemo(()=>{const n={},r={};for(const a of t){const o=a.dependsOn??[];if(o.length===0)continue;const i=S2({...a,dependsOn:o},t,s);r[a.slug]=i;const c=Sg(i);c.length!==0&&(n[a.slug]={count:c.length,tooltip:c.map(d=>d.title??`missing: ${d.slug}`).join(", ")})}return{annotationsBySlug:n,dependenciesBySlug:r}},[t,s])}let Ms={hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null};function Ur(t){Ms={...Ms,...t}}function N2(){return Ms}function C2(){return Ms.hasActiveSession||Ms.isAgentBuilding||!!Ms.stepStateFeature}const P2=500;async function T2(){var t;try{const s=await fetch("/api/config");if(!s.ok)return!0;const n=await s.json();return((t=n==null?void 0:n.providerAuth)==null?void 0:t.state)==="authenticated"}catch{return!0}}async function Ai(){let t=!1,s;try{const n=await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})});s=n.status,n.ok&&(t=!0)}catch{}t&&Ur({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),X("clear-editor-session",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function A2(){let t=!1,s;try{const n=await fetch("/api/stop-building",{method:"POST",headers:{"Content-Type":"application/json"}});s=n.status,n.ok&&(t=!0)}catch{}t&&Ur({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),X("stop-building",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function O2(){let t=!1,s;try{const n=await fetch("/api/reset-everything",{method:"POST",headers:{"Content-Type":"application/json"}});s=n.status,n.ok&&(t=!0)}catch{}t&&Ur({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),X("reset-everything",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function Oi(t={}){const s=N2(),n=t.caller??"unknown",r=t.bypassLiveGuard===!0;if(C2()&&!r){X("launch-editor-skill",{caller:n,suppressed:!0,snapshot:s,bypassLiveGuard:!1});return}Ck(),X("launch-editor-skill",{caller:n,suppressed:!1,snapshot:s,bypassLiveGuard:r}),!(t.provider==="gemini"||t.provider==="opencode")&&(km(t.renameLabel??"Editor",n,Bc),Ta("/clear\r"),await new Promise(a=>setTimeout(()=>{Ta("/codeyam-editor\r"),a()},P2)))}async function R2(t={}){if(await Ai(),!await T2()){X("launch-editor-skill",{caller:t.caller??"unknown",suppressed:!0,reason:"provider-not-authenticated"}),console.warn("[launchEditorWorkflow] provider not authenticated; aborting launch (the terminal gate would refuse the PTY).");return}await Oi(t)}function Ri(t,s=!1,n=s){const r=Ow(t),a=s&&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(()=>{n&&r==="build"&&window.history.replaceState(null,"",Os("home"))},[n,r]);const u=l.useCallback(f=>{if(s&&f==="build"){window.history.pushState(null,"",Os("home"));return}window.history.pushState(null,"",Os(f)),f==="build"&&i(!0),f==="plan"&&d(!0)},[s]),h=l.useCallback(()=>{s||(window.history.pushState(null,"",Os("build")),i(!0))},[s]),p=l.useCallback(()=>{i(!1)},[]);return{activeTab:a,buildActivated:o,planActivated:c,navigateToTab:u,showBuildTab:h,deactivateBuild:p}}const E2=15e3;function Cg(t={}){const{launchAnchored:s=!1}=t,{showBuildTab:n}=Ri(typeof window>"u"?"/":window.location.pathname),{config:r}=St(),[a,o]=l.useState(null),[i,c]=l.useState(null),d=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},[]),h=l.useCallback(()=>{u(),o(null)},[u]);l.useEffect(()=>{a!==null&&s&&h()},[a,s,h]),l.useEffect(()=>u,[u]);const p=l.useCallback(async(f,m)=>{if(a)return!1;c(null),o(f);try{try{await Ai(),LN()}catch{}const b=await fetch(`/api/plans/${encodeURIComponent(f)}/select`,{method:"POST"});if(!b.ok){let g=`HTTP ${b.status}`;try{const x=await b.json();x!=null&&x.error&&(g=x.error)}catch{}throw new Error(g)}n()}catch(b){return c(b instanceof Error?b.message:"Failed to launch plan"),h(),!1}return u(),d.current=setTimeout(()=>{d.current=null,o(null)},E2),Oi({caller:"plan-launcher",renameLabel:m,provider:r==null?void 0:r.provider,bypassLiveGuard:!0}).catch(b=>{c(b instanceof Error?b.message:"Failed to launch plan")}),!0},[a,n,r==null?void 0:r.provider,h,u]);return{launchingSlug:a,error:i,launchPlan:p}}function Pg({onClose:t}){const s=n=>{n.target===n.currentTarget&&t()};return e.jsx("div",{"data-testid":"plan-run-blocked-modal",onClick:s,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Build in progress"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:xf}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsx("button",{onClick:t,"data-testid":"plan-run-blocked-ok",className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"OK"})})]})})}const pM=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedModal:Pg},Symbol.toStringTag,{value:"Module"}));function Tg({deps:t,onClose:s}){const n=r=>{r.target===r.currentTarget&&s()};return e.jsx("div",{"data-testid":"plan-run-dependencies-modal",onClick:n,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Prerequisite plans not yet built"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"This plan depends on the following changes that have not yet been built. Run them first, then come back to this one."}),e.jsx("ul",{className:"flex flex-col gap-1.5 mb-4",children:t.map(r=>e.jsx("li",{"data-testid":`plan-dep-${r.slug}`,className:"text-sm text-[var(--text-primary)]",children:r.title===null?e.jsxs("span",{className:"text-[var(--text-muted)]",children:["missing: ",r.slug," — was the prerequisite plan deleted?"]}):r.title},r.slug))}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsx("button",{onClick:s,"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 mM=Object.freeze(Object.defineProperty({__proto__:null,PlanRunDependenciesModal:Tg},Symbol.toStringTag,{value:"Module"}));function Ag({claim:t,onCancel:s,onConfirm:n}){const r=Ws(),a=t.claimedBy.agentProvider??"agent",o=t.claimedBy.currentStep??"unknown",i=t.sessionAlive===!1,c=i?"Previous session (no longer running)":"Another session is working on this plan",d=i?"Reclaim and run":"Run anyway";l.useEffect(()=>{const h=p=>{p.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s]);const u=h=>{h.target===h.currentTarget&&s()};return e.jsx("div",{"data-testid":"plan-run-foreign-claim-modal",onClick:u,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{"data-testid":"plan-foreign-claim-heading",className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:c}),e.jsxs("div",{className:"text-sm text-[var(--text-muted)] mb-4 flex flex-col gap-1",children:[e.jsxs("span",{"data-testid":"plan-foreign-claim-identity",children:["claimed by ",a,"@",t.claimedBy.machine]}),e.jsxs("span",{children:["started ",ss(t.claimedBy.startedAt,r)]}),e.jsxs("span",{"data-testid":"plan-foreign-claim-step",children:["on step ",o," (",ss(t.currentStepEnteredAt,r)," on step)"]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:s,"data-testid":"plan-run-foreign-claim-cancel",className:"flex-1 px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--bg-elevated, transparent)",border:"1px solid var(--border-default)",color:"var(--text-primary)"},type:"button",children:"Cancel"}),e.jsx("button",{onClick:n,"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 fM=Object.freeze(Object.defineProperty({__proto__:null,PlanRunForeignClaimModal:Ag},Symbol.toStringTag,{value:"Module"}));function Ei({dependenciesBySlug:t,claimsBySlug:s,isAgentBuilding:n=!1,onLaunch:r}){const[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),h=m=>{if(n){o(!0);return}const b=Sg(t[m]??[]);if(b.length>0){c(b);return}const g=s.get(m);if(g&&g.source!=="local"){u(g);return}r(m)},p=()=>{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=e.jsxs(e.Fragment,{children:[a&&e.jsx(Pg,{onClose:()=>o(!1)}),i&&e.jsx(Tg,{deps:i,onClose:()=>c(null)}),d&&e.jsx(Ag,{claim:d,onCancel:()=>u(null),onConfirm:p})]});return{requestRun:h,gateModals:f}}function Og(t){return{reorderPlans:l.useCallback(async n=>{const r=await fetch("/api/plans/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slugs:n})});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error??`HTTP ${r.status}`)}t==null||t()},[t])}}const M2={describe:"Claude Code will remember your plans and suggest them once the current building session is over.",prototype:"Build a working prototype with the agent. When it's right, formalize into Build to decompose, test, and ship."};function Rg({subTab:t="describe"}={}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:"Plan your next move"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--text-dim)]",children:M2[t]})]})}const gM=Object.freeze(Object.defineProperty({__proto__:null,PlanTabHeader:Rg},Symbol.toStringTag,{value:"Module"})),I2=[{id:"describe",label:"Describe A Plan"},{id:"prototype",label:"Prototype A Plan"}];function Eg({active:t,onChange:s}){return e.jsx("div",{className:"mt-3 flex items-center gap-1 border-b border-[var(--border-subtle)]",role:"tablist","data-testid":"plan-sub-tabs",children:I2.map(n=>{const r=n.id===t;return e.jsx("button",{type:"button",role:"tab","aria-selected":r,"data-testid":`plan-sub-tab-${n.id}`,onClick:()=>s(n.id),className:"px-2.5 py-2 text-sm transition-colors cursor-pointer border-b -mb-px "+(r?"text-[var(--accent-active)] border-[var(--accent-active)] font-medium":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-primary)] font-light"),children:n.label},n.id)})})}const bM=Object.freeze(Object.defineProperty({__proto__:null,PlanSubTabs:Eg},Symbol.toStringTag,{value:"Module"}));function Mg({onClose:t}){return e.jsx(vs,{chatName:"prototype",slashCommand:"/codeyam-prototype",height:480,onClose:t})}const xM=Object.freeze(Object.defineProperty({__proto__:null,PrototypeAgentChat:Mg},Symbol.toStringTag,{value:"Module"})),Ig="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 Dg(){return e.jsxs("div",{"data-testid":"prototype-building-banner",className:"mt-3 rounded border px-4 py-3 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",color:"var(--text-muted)"},children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Build in progress."})," ",Ig]})}const yM=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_BUILDING_IN_PROGRESS_MESSAGE:Ig,PrototypeBuildingInProgressBanner:Dg},Symbol.toStringTag,{value:"Module"}));function so({open:t,disabled:s=!1,onToggle:n}){const r="mt-3 inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors",a=s?"border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"border-[var(--accent-active)] text-[var(--accent-active)] hover:bg-[var(--accent-active)] hover:text-black cursor-pointer";return e.jsx("button",{type:"button",onClick:s?void 0:n,disabled:s,"aria-disabled":s,title:s?"Building is in progress.":t?"Close Prototype":"Start Prototyping","data-testid":"start-prototyping",className:`${r} ${a}`,children:t?"Close Prototype":"Start Prototyping"})}const vM=Object.freeze(Object.defineProperty({__proto__:null,StartPrototypingButton:so},Symbol.toStringTag,{value:"Module"})),no=800;function on(t){window.dispatchEvent(new CustomEvent("miniagent-send-input",{detail:t}))}function D2(t){return new Promise(s=>{let n=!1;const r=()=>{n||(n=!0,window.removeEventListener("miniagent-output",r),clearTimeout(a),s())},a=setTimeout(r,t);window.addEventListener("miniagent-output",r,{once:!0})})}const Lg='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 Fg({disabled:t=!1,onClick:s}={}){const[n,r]=l.useState(!1),a=l.useRef(!1),o=async()=>{if(!(t||a.current)){a.current=!0,r(!0);try{on(Lg),await D2(no),on("\r"),s==null||s()}finally{a.current=!1,r(!1)}}},i=t||n;return e.jsx("button",{type:"button",onClick:o,disabled:i,"data-testid":"finish-and-formalize",className:"mt-3 inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors "+(i?"border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"border-[var(--accent-active)] text-[var(--accent-active)] hover:bg-[var(--accent-active)] hover:text-black cursor-pointer"),children:"Finish and Formalize in Build"})}const jM=Object.freeze(Object.defineProperty({__proto__:null,FINISH_AND_FORMALIZE_INSTRUCTION:Lg,FinishAndFormalizeButton:Fg},Symbol.toStringTag,{value:"Module"}));function zg(t,s){return`Launches a chat window with ${t} to ${s==="describe"?"describe your plan":"start prototyping"}.`}function Mi({providerLabel:t,kind:s}){return e.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":`plan-chat-launch-caption-${s}`,children:zg(t,s)})}const wM=Object.freeze(Object.defineProperty({__proto__:null,PlanChatLaunchCaption:Mi,planChatLaunchCaptionText:zg},Symbol.toStringTag,{value:"Module"}));function $g({isAgentBuilding:t,onLaunched:s,launchSignal:n=0}){const[r,a]=l.useState(!1),[o,i]=l.useState(!1),{config:c}=St(),d=zt(c==null?void 0:c.provider),u=l.useRef(s);u.current=s;const h=l.useRef(n);l.useEffect(()=>{var m;n!==h.current&&(h.current=n,i(!1),a(!1),(m=u.current)==null||m.call(u))},[n]);const p=()=>{if(t)return;const m=!r;m&&it(),a(m)},f=()=>{a(!1)};return t?e.jsxs("div",{"data-testid":"prototype-pane",children:[e.jsx(Dg,{}),e.jsx(so,{open:!1,disabled:!0,onToggle:()=>{}})]}):e.jsxs("div",{"data-testid":"prototype-pane",children:[e.jsx(so,{open:r,onToggle:p}),!r&&e.jsx(Mi,{providerLabel:d,kind:"prototype"}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Mg,{onClose:f}),e.jsx(Fg,{disabled:o,onClick:()=>i(!0)}),o&&e.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":"prototype-awaiting-formalize",children:"Waiting for the agent to write the plan file…"})]})]})}const _M=Object.freeze(Object.defineProperty({__proto__:null,PrototypePane:$g},Symbol.toStringTag,{value:"Module"}));function Bg({open:t,onToggle:s}){return e.jsx("button",{type:"button",onClick:s,className:"mt-3 inline-flex items-center gap-2 rounded border border-[var(--accent-active)] px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-[var(--accent-active)] hover:bg-[var(--accent-active)] hover:text-black transition-colors cursor-pointer","data-testid":"plan-next-change",children:t?"Close Planner":"Plan Next Change"})}const kM=Object.freeze(Object.defineProperty({__proto__:null,PlanNextChangeButton:Bg},Symbol.toStringTag,{value:"Module"}));function qg({onClose:t}){return e.jsx(vs,{chatName:"plan",slashCommand:"/codeyam-plan",height:360,onClose:t})}const SM=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthoringChat:qg},Symbol.toStringTag,{value:"Module"}));function Hg({providerLabel:t,chatOpen:s,onChatToggle:n,onChatClose:r}){return e.jsxs("div",{"data-testid":"describe-pane",children:[e.jsx(Bg,{open:s,onToggle:n}),!s&&e.jsx(Mi,{providerLabel:t,kind:"describe"}),s&&e.jsx(qg,{onClose:r})]})}const NM=Object.freeze(Object.defineProperty({__proto__:null,DescribePane:Hg},Symbol.toStringTag,{value:"Module"}));function Wg({claim:t}){const s=Ws(),n=t.claimedBy.agentProvider??"agent",r=t.claimedBy.machine,a=t.claimedBy.currentStep??null,o=ss(t.currentStepEnteredAt,s),i=ss(t.claimedBy.startedAt,s),{dead:c}=cf(t);return e.jsxs("li",{className:"flex flex-col gap-1 rounded border border-[var(--border-subtle)] px-3 py-2","data-testid":`in-flight-row-${t.slug}`,"data-session-alive":c?"false":void 0,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm text-[var(--text-default)]",children:t.title}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)]","data-testid":`in-flight-source-${t.slug}`,children:t.source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{"data-testid":`plan-claim-identity-${t.slug}`,children:["claimed by ",n,"@",r]}),a&&e.jsxs("span",{"data-testid":`plan-claim-step-${t.slug}`,children:["step ",a," · ",o," on step"]}),e.jsxs("span",{"data-testid":`plan-claim-started-${t.slug}`,children:["started ",i]}),c&&e.jsx("span",{className:"text-[var(--text-muted)]",children:"(inactive)"})]})]})}const CM=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRow:Wg},Symbol.toStringTag,{value:"Module"}));function Gg({claims:t}){return t.length===0?null:e.jsxs("div",{className:"mt-6","data-testid":"in-flight-section",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["In Flight (",t.length,")"]}),e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"in-flight-list",children:t.map(s=>e.jsx(Wg,{claim:s},`${s.slug}:${s.claimedBy.machine}:${s.claimedBy.sessionId}:${s.claimedBy.pid}:${s.claimedBy.startedAt}`))})]})}const PM=Object.freeze(Object.defineProperty({__proto__:null,InFlightSection:Gg},Symbol.toStringTag,{value:"Module"})),L2=5e3;function F2(){const[t,s]=l.useState([]),[n,r]=l.useState(null),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(null),h=l.useRef(!1),p=l.useCallback(async()=>{c(!0),u(null);try{const b=await fetch("/api/branch-queue/status");if(!b.ok)throw new Error(`HTTP ${b.status}`);const g=await b.json();if(h.current)return;s(Array.isArray(g.entries)?g.entries:[]),r(g.branch??null),o(g.remote??null)}catch(b){if(h.current)return;u(b instanceof Error?b.message:"Failed to load branch queue"),s([])}finally{h.current||c(!1)}},[]);l.useEffect(()=>{h.current=!1,p();const b=setInterval(()=>{p()},L2);return()=>{h.current=!0,clearInterval(b)}},[p]);const f=l.useCallback(async(b,g,x)=>{const y={uuid:b,priority:g};typeof x=="number"&&(y.expectedPriority=x);const v=await fetch("/api/branch-queue/set-priority",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y)});if(!v.ok){const j=await v.text().catch(()=>"");throw new Error(`set-priority ${v.status}: ${j}`)}await p()},[p]),m=l.useCallback(async b=>{const g=await fetch("/api/branch-queue/release",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({uuid:b})});if(!g.ok){const x=await g.text().catch(()=>"");throw new Error(`release ${g.status}: ${x}`)}await p()},[p]);return{entries:t,branch:n,remote:a,loading:i,error:d,setPriority:f,release:m,refetch:p}}function z2(){const[t,s]=l.useState(null),[n,r]=l.useState(null),a=l.useCallback(c=>{s(c)},[]),o=l.useCallback(c=>{r(c)},[]),i=l.useCallback(()=>{s(null),r(null)},[]);return{dragSourceUuid:t,dragOverUuid:n,beginDrag:a,hoverOver:o,reset:i}}function $2(t,s){const n=new Map(s.map(i=>[i.uuid,i])),r=[],a=new Set;for(const i of t.order){const c=n.get(i.uuid);c&&(r.push(c),a.add(i.uuid))}for(const i of s)a.has(i.uuid)||(r.push(i),a.add(i.uuid));const o=new Set;for(const i of t.releasedUuids)n.has(i)&&o.add(i);return{order:r,releasedUuids:o}}const B2=new Set;function _a(t,s){return t??{order:[...s],releasedUuids:new Set}}function q2(){const[t,s]=l.useState(null),n=l.useCallback(h=>t?t.order:h,[t]),r=l.useCallback((h,p,f)=>{s(m=>{const b=_a(m,f),g=b.order.findIndex(y=>y.uuid===h),x=b.order.findIndex(y=>y.uuid===p);return g===-1||x===-1||g===x?b:{...b,order:mn(b.order,g,x)}})},[]),a=l.useCallback((h,p,f)=>{s(m=>{const b=_a(m,f),g=b.order.findIndex(y=>y.uuid===h);if(g===-1)return b;const x=g-p;return x<0||x>=b.order.length?b:{...b,order:mn(b.order,g,x)}})},[]),o=l.useCallback((h,p)=>{s(f=>{const m=_a(f,p),b=new Set(m.releasedUuids);return b.has(h)?b.delete(h):b.add(h),{...m,releasedUuids:b}})},[]),i=l.useCallback(h=>{s(p=>p?$2(p,h):null)},[]),c=l.useCallback(()=>s(null),[]),d=l.useCallback(h=>t?t.releasedUuids.size>0||t.order.length!==h.length?!0:t.order.some((p,f)=>{var m;return p.uuid!==((m=h[f])==null?void 0:m.uuid)}):!1,[t]),u=l.useCallback(h=>{var g,x;if(!t)return 0;const p=t.releasedUuids,f=h.filter(y=>!p.has(y.uuid)),m=t.order.filter(y=>!p.has(y.uuid));let b=0;for(let y=0;y<m.length;y++)((g=m[y])==null?void 0:g.uuid)!==((x=f[y])==null?void 0:x.uuid)&&b++;return b},[t]);return{isActive:t!==null,displayEntries:n,releasedUuids:(t==null?void 0:t.releasedUuids)??B2,isDirty:d,reorderedCount:u,releasedCount:(t==null?void 0:t.releasedUuids.size)??0,moveByDrag:r,nudge:a,toggleRelease:o,reconcile:i,reset:c}}const H2=10;function W2(t,s,n){const r=new Map(n.map(d=>[d.uuid,d])),a=n.filter(d=>s.has(d.uuid)).map(d=>d.uuid),o=t.filter(d=>!s.has(d.uuid)),i=o.length,c=[];return o.forEach((d,u)=>{const h=r.get(d.uuid);if(!h)return;const p=(i-u)*H2;h.meta.priority!==p&&c.push({uuid:d.uuid,priority:p,expectedPriority:h.meta.priority})}),{releases:a,priorities:c}}function Ug({priority:t,uuid:s,onNudge:n}){const r=t===0?"priority 0":t>0?`priority +${t}`:`priority ${t}`;return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] rounded border border-[var(--border-subtle)] px-2 py-1 text-[var(--text-muted)]","data-testid":`commit-queue-priority-chip-${s}`,children:[e.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-down-${s}`,onClick:()=>void n(-1),"aria-label":"Lower priority",children:"−"}),e.jsx("span",{"data-testid":`commit-queue-priority-value-${s}`,children:r}),e.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-up-${s}`,onClick:()=>void n(1),"aria-label":"Raise priority",children:"+"})]})}const TM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueuePriorityChip:Ug},Symbol.toStringTag,{value:"Module"}));function Yg({uuid:t,markedForRelease:s,onToggle:n}){return s?e.jsx("button",{type:"button",className:"text-xs px-2 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:text-[var(--text-default)] cursor-pointer","data-testid":`commit-queue-undo-release-${t}`,onClick:n,title:"Keep this entry in the queue",children:"Undo remove"}):e.jsx("button",{type:"button",className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:border-[var(--accent-danger)] hover:text-[var(--accent-danger)] cursor-pointer","data-testid":`commit-queue-release-${t}`,onClick:n,title:"Mark this entry for removal",children:"Force release"})}const AM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueReleaseButton:Yg},Symbol.toStringTag,{value:"Module"}));function Vg({entry:t,isHead:s}){const n=Ws(),r=t.meta.agentProvider??"agent",a=t.meta.machine,o=t.meta.currentStep??null,i=ss(t.meta.startedAt??t.committerDate,n);return e.jsxs("div",{className:"flex-1 flex flex-col gap-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-[var(--text-default)] truncate",children:[r,"@",a]}),s&&e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-strong)]","data-testid":`commit-queue-head-marker-${t.uuid}`,children:"← head"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[o&&e.jsxs("span",{"data-testid":`commit-queue-step-${t.uuid}`,children:["step ",o]}),e.jsxs("span",{"data-testid":`commit-queue-started-${t.uuid}`,children:["started ",i]}),e.jsxs("span",{"data-testid":`commit-queue-pid-${t.uuid}`,children:["pid ",t.meta.pid]})]})]})}const OM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowIdentity:Vg},Symbol.toStringTag,{value:"Module"}));function Kg({entry:t,position:s,isHead:n,markedForRelease:r,onPriorityNudge:a,onToggleRelease:o,onDragStart:i,onDragOver:c,onDrop:d,isDragging:u,isDragOver:h}){return e.jsxs("li",{"data-testid":`commit-queue-row-${t.uuid}`,draggable:!0,onDragStart:p=>{p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",t.uuid),i()},onDragOver:p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",c()},onDrop:p=>{p.preventDefault(),d()},"data-marked-for-release":r||void 0,className:`group flex items-center gap-3 rounded border px-3 py-2 ${n?"border-[var(--accent-strong)]":"border-[var(--border-subtle)]"} ${u?"opacity-40":""} ${h?"ring-2 ring-[var(--accent-strong)]":""} ${r?"opacity-50 line-through":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"cursor-grab select-none text-[var(--text-dim)] hover:text-[var(--text-default)]",title:"Drag to reorder","data-testid":`commit-queue-drag-${t.uuid}`,children:"⋮⋮"}),e.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)] w-6 text-right","data-testid":`commit-queue-position-${t.uuid}`,children:[s,"."]}),e.jsx(Vg,{entry:t,isHead:n}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ug,{priority:t.meta.priority,uuid:t.uuid,onNudge:a}),e.jsx(Yg,{uuid:t.uuid,markedForRelease:r,onToggle:o})]})]})}const RM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRow:Kg},Symbol.toStringTag,{value:"Module"}));function Jg({reorderedCount:t,releasedCount:s,saving:n,onSave:r,onCancel:a}){const o=[];t>0&&o.push(`${t} reordered`),s>0&&o.push(`${s} to remove`);const i=o.join(" · ")||"Unsaved changes";return e.jsxs("div",{"data-testid":"commit-queue-save-bar",className:"mt-3 flex items-center justify-between gap-3 border-t border-[var(--accent-strong)] pt-3",children:[e.jsx("span",{className:"text-xs text-[var(--text-muted)]","data-testid":"commit-queue-save-summary",children:i}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button","data-testid":"commit-queue-cancel",onClick:a,disabled:n,className:"text-xs px-3 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:text-[var(--text-default)] disabled:opacity-50 cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"commit-queue-save",onClick:r,disabled:n,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:n?"Saving…":"Save"})]})]})}const EM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSaveBar:Jg},Symbol.toStringTag,{value:"Module"}));function Xg({entriesOverride:t,branchOverride:s}={}){const n=F2(),r=t!==void 0,a=t??n.entries,o=s??n.branch,i=z2(),c=q2(),{reconcile:d}=c,[u,h]=l.useState(null),[p,f]=l.useState(!1);if(l.useEffect(()=>{r||d(a)},[a,d,r]),!r&&n.loading&&a.length===0||a.length===0)return null;const m=c.displayEntries(a),b=c.isDirty(a),g=w=>{var C;const _=i.dragSourceUuid,S=(C=m[w])==null?void 0:C.uuid;i.reset(),!(_===null||!S||_===S)&&c.moveByDrag(_,S,a)},x=(w,_)=>{c.nudge(w.uuid,_,a)},y=w=>{c.toggleRelease(w.uuid,a)},v=()=>{h(null),c.reset()},j=async()=>{const{releases:w,priorities:_}=W2(m,new Set(c.releasedUuids),a);h(null),f(!0);try{if(!r){for(const S of w)await n.release(S);for(const S of _)await n.setPriority(S.uuid,S.priority,S.expectedPriority);await n.refetch()}c.reset()}catch(S){h(S instanceof Error?S.message:"Failed to save changes")}finally{f(!1)}};return e.jsxs("div",{className:"mt-6","data-testid":"commit-queue-section",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["Commit Queue (",m.length,")"]}),o&&e.jsx("span",{className:"text-[11px] text-[var(--text-dim)]","data-testid":"commit-queue-branch",children:o})]}),u&&e.jsx("div",{className:"mt-2 text-xs text-[var(--accent-danger)]","data-testid":"commit-queue-error",children:u}),e.jsx("ol",{className:"mt-3 flex flex-col gap-2","data-testid":"commit-queue-list",children:m.map((w,_)=>e.jsx(Kg,{entry:w,position:_+1,isHead:_===0,markedForRelease:c.releasedUuids.has(w.uuid),onPriorityNudge:S=>x(w,S),onToggleRelease:()=>y(w),onDragStart:()=>i.beginDrag(w.uuid),onDragOver:()=>i.hoverOver(w.uuid),onDrop:()=>g(_),isDragging:i.dragSourceUuid===w.uuid,isDragOver:i.dragOverUuid===w.uuid&&i.dragSourceUuid!==w.uuid},w.uuid))}),b&&e.jsx(Jg,{reorderedCount:c.reorderedCount(a),releasedCount:c.releasedCount,saving:p,onSave:j,onCancel:v})]})}const MM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSection:Xg},Symbol.toStringTag,{value:"Module"}));function G2(t){const[s,n]=l.useState(null),[r,a]=l.useState(!0),[o,i]=l.useState(null);return l.useEffect(()=>{let c=!1;return(async()=>{a(!0),i(null);try{const d=new Date(new Date(t).getTime()-1).toISOString(),u=await fetch(`/api/journal?since=${encodeURIComponent(d)}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const p=((await u.json()).entries??[]).find(f=>f.timestamp===t)??null;c||n(p)}catch(d){c||(n(null),i(d instanceof Error?d.message:"Failed to load journal entry"))}finally{c||a(!1)}})(),()=>{c=!0}},[t]),{entry:s,loading:r,error:o}}function Qg({journalTimestamp:t}){const{entry:s,loading:n,error:r}=G2(t);return n?e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Loading journal entry…"}):r?e.jsxs("p",{className:"text-sm text-[var(--accent-red)]",children:["Failed to load journal entry: ",r]}):s?e.jsx(Fr,{entry:s}):e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No journal entry found for this plan yet."})}const IM=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanExpandedBody:Qg},Symbol.toStringTag,{value:"Module"}));function Zg({plan:t,expanded:s,onToggle:n}){return e.jsxs("li",{className:"border border-[var(--border-subtle)] rounded-lg",children:[e.jsxs("button",{type:"button",onClick:n,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:[e.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-[var(--text-primary)]",children:t.title}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-dim)]",children:t.mode}),e.jsx("span",{className:"text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:ss(t.completedAt)}),t.completedBy&&e.jsxs("span",{className:"text-[10px] text-[var(--text-dim)] whitespace-nowrap","data-testid":`completed-plan-by-${t.slug}`,children:["completed by ",t.completedBy.agentProvider??"agent","@",t.completedBy.machine]}),e.jsx("span",{className:"text-xs text-[var(--text-dim)] whitespace-nowrap","data-testid":"completed-plan-row-chevron",children:s?"▼":"▶"})]}),s&&e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]","data-testid":"completed-plan-row-body",children:e.jsx(Qg,{journalTimestamp:t.journalTimestamp})})]})}const DM=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanRow:Zg},Symbol.toStringTag,{value:"Module"}));function eb({plans:t,loading:s,error:n}){const[r,a]=l.useState(null),o=t.length;return e.jsxs("div",{className:"mt-6",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["Completed Plans (",o,")"]}),e.jsx(tb,{plans:t,loading:s,error:n,expandedSlug:r,onToggle:i=>a(c=>c===i?null:i)})]})}function tb({plans:t,loading:s,error:n,expandedSlug:r,onToggle:a}){return s?e.jsx("p",{className:"mt-3 text-sm text-[var(--text-muted)]",children:"Loading completed plans…"}):n?e.jsxs("p",{className:"mt-3 text-sm text-[var(--accent-red)]",children:["Failed to load completed plans: ",n]}):t.length===0?e.jsx("p",{className:"mt-3 text-sm text-[var(--text-dim)]",children:"Plans you complete will appear here."}):e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"recent-plans-list",children:t.map(o=>e.jsx(Zg,{plan:o,expanded:r===o.slug,onToggle:()=>a(o.slug)},o.slug))})}const LM=Object.freeze(Object.defineProperty({__proto__:null,RecentPlansBody:tb,RecentPlansSection:eb},Symbol.toStringTag,{value:"Module"}));function sb({chatOpen:t,onChatOpenChange:s,isActive:n=!0,isAgentBuilding:r=!1,launchingSlug:a,launchError:o,onLaunchPlan:i,initialSubTab:c="describe",prototypeLaunchSignal:d=0}={}){const{plans:u,loading:h,error:p,refetch:f}=bg(),{claims:m}=xg(),{slugs:b}=kg(),{status:g}=yg(),{staleness:x}=w2(),y=((g==null?void 0:g.consecutiveFailures)??0)>=3,{plans:v,loading:j,error:w}=_g(),{config:_}=St(),S=zt(_==null?void 0:_.provider),C=i!==void 0,N=Cg(),T=C?a??null:N.launchingSlug,O=C?o??null:N.error,[k,D]=l.useState(!1),$=l.useMemo(()=>wg(m),[m]),B=l.useMemo(()=>k2(m,b),[m,b]),[q,P]=l.useState(c),E=t!==void 0,A=E?t:k,H=ie=>{E||D(ie),s==null||s(ie)},z=()=>{H(!1),f()},G=()=>{const ie=!A;ie&&it(),H(ie)};l.useEffect(()=>{if(!(!n||!A))return it()},[n,A]);const{annotationsBySlug:Q,dependenciesBySlug:se}=Ng(u),le=ie=>{var K;const be=((K=u.find(L=>L.slug===ie))==null?void 0:K.title)??ie;if(i){i(ie,be);return}N.launchPlan(ie,be)},{requestRun:re,gateModals:U}=Ei({dependenciesBySlug:se,claimsBySlug:$,isAgentBuilding:r,onLaunch:le}),{reorderPlans:ge}=Og(f);return e.jsxs(Qt,{testId:"plan-tab",children:[e.jsx(Rg,{subTab:q}),e.jsx(Eg,{active:q,onChange:P}),q==="describe"&&e.jsx(Hg,{providerLabel:S,chatOpen:A,onChatToggle:G,onChatClose:z}),q==="prototype"&&e.jsx($g,{isAgentBuilding:r,onLaunched:()=>P("describe"),launchSignal:d}),e.jsx(Ti,{staleness:x}),e.jsx(jg,{status:g}),e.jsx(Wr,{plans:u,loading:h,error:p,onRun:re,launchingSlug:T,launchError:O,blocked:r,onReorder:ge,depAnnotationsBySlug:Q,dependenciesBySlug:se,claimsBySlug:$,staleFetch:y}),e.jsx(Gg,{claims:B}),e.jsx(Xg,{}),e.jsx(eb,{plans:v,loading:j,error:w}),U]})}const FM=Object.freeze(Object.defineProperty({__proto__:null,PlanTab:sb},Symbol.toStringTag,{value:"Module"}));function nb({activeTab:t,planActivated:s,chatOpen:n,onChatOpenChange:r,isAgentBuilding:a=!1,launchingPlanSlug:o,planLaunchError:i,onLaunchPlan:c,prototypeLaunchSignal:d=0}){return s?e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:t==="plan"?"visible":"hidden",pointerEvents:t==="plan"?"auto":"none"},children:e.jsx(sb,{chatOpen:n,onChatOpenChange:r,isActive:t==="plan",isAgentBuilding:a,launchingSlug:o,launchError:i,onLaunchPlan:c,prototypeLaunchSignal:d})}):null}const zM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPlanLayer:nb},Symbol.toStringTag,{value:"Module"})),U2="desktop",lc="codeyam:isDesktopApp";function Y2(t=typeof window<"u"?window:void 0){var o,i,c;if(!t)return!1;try{if(((o=t.sessionStorage)==null?void 0:o.getItem(lc))==="1")return!0}catch{}const n=new URLSearchParams(((i=t.location)==null?void 0:i.search)??"").get(U2)==="1",r=typeof t.__TAURI__<"u",a=n||r;if(a)try{(c=t.sessionStorage)==null||c.setItem(lc,"1")}catch{}return a}function rb({visible:t,children:s}){return e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-auto",style:{visibility:t?"visible":"hidden"},children:s})}const $M=Object.freeze(Object.defineProperty({__proto__:null,TabPane:rb},Symbol.toStringTag,{value:"Module"}));function ab({activeTab:t,children:s}){const n=["home","build","plan","history","reviews","settings"];return e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:n.map(r=>e.jsx(rb,{visible:t===r,children:s[r]},r))})}const BM=Object.freeze(Object.defineProperty({__proto__:null,LeftPanel:ab},Symbol.toStringTag,{value:"Module"}));function ob({label:t,description:s,checked:n,disabled:r=!1,onChange:a,children:o}){return e.jsxs("div",{className:"py-3",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:i=>a(i.target.checked),className:"accent-green-500 mt-0.5"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"text-[12px] block",style:{color:"var(--text-primary)"},children:t}),e.jsx("span",{className:"text-[11px] block mt-0.5",style:{color:"var(--text-dim)"},children:s})]})]}),o]})}const qM=Object.freeze(Object.defineProperty({__proto__:null,CheckInToggleRow:ob},Symbol.toStringTag,{value:"Module"}));function Ii({options:t,value:s,onChange:n,disabled:r=!1,ariaLabel:a}){return e.jsx("div",{className:"flex gap-1",role:a?"radiogroup":void 0,"aria-label":a,children:t.map(o=>{const i=o.value===s;return e.jsx("button",{type:"button",role:a?"radio":void 0,"aria-checked":a?i:void 0,title:o.hint,disabled:r,onClick:()=>n(o.value),className:"text-[11px] px-2 py-1 rounded cursor-pointer transition-colors",style:{background:i?"var(--bg-input)":"transparent",color:i?"var(--text-primary)":"var(--text-secondary)"},children:o.label},o.value)})})}const HM=Object.freeze(Object.defineProperty({__proto__:null,SegmentedPicker:Ii},Symbol.toStringTag,{value:"Module"})),V2=[{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 ib({autoAction:t,branchState:s,disabled:n=!1,onChange:r}){return s.onPrimaryBranch?e.jsx("div",{className:"mt-2 ml-6",children:e.jsxs("p",{className:"text-[11px]",style:{color:"var(--text-dim)"},children:["Fast commit is disabled on"," ",s.primaryBranch??"the primary branch"," — this check-in will commit normally."]})}):e.jsxs("div",{className:"mt-2 ml-6",children:[e.jsx("div",{className:"text-[11px] mb-1",style:{color:"var(--text-muted)"},children:"When it runs on its own"}),e.jsx(Ii,{options:V2,value:t,onChange:r,disabled:n,ariaLabel:"Autonomous commit action"})]})}const WM=Object.freeze(Object.defineProperty({__proto__:null,HardeningAutoAction:ib},Symbol.toStringTag,{value:"Module"})),lb={checkIns:{planAccepted:{pause:!0},prototypeCompleted:{pause:!0},hardeningCompleted:{pause:!0,autoAction:"commit"},push:{pause:!0}}};function cc(t){const s=(t==null?void 0:t.checkIns)??{},n=lb.checkIns;return{checkIns:{planAccepted:s.planAccepted??n.planAccepted,prototypeCompleted:s.prototypeCompleted??n.prototypeCompleted,hardeningCompleted:s.hardeningCompleted??n.hardeningCompleted,push:s.push??n.push}}}function K2(){const[t,s]=l.useState(lb),[n,r]=l.useState({currentBranch:null,primaryBranch:null,onPrimaryBranch:!1}),[a,o]=l.useState(!0),[i,c]=l.useState(!1),[d,u]=l.useState(null);l.useEffect(()=>{let p=!1;return(async()=>{var f;try{const m=await fetch("/api/config");if(!m.ok)throw new Error(`config request failed (${m.status})`);const b=await m.json();if(p)return;const g=(b==null?void 0:b.currentBranch)??null,x=((f=b==null?void 0:b.audit)==null?void 0:f.branchBaseRef)??null;s(cc(b==null?void 0:b.workflow)),r({currentBranch:g,primaryBranch:x,onPrimaryBranch:g!==null&&g===x})}catch(m){p||u(m instanceof Error?m.message:String(m))}finally{p||o(!1)}})(),()=>{p=!0}},[]);const h=l.useCallback(async(p,f)=>{const m=t;s(p),c(!0),u(null);try{const b=await fetch("/api/workflow-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:f,workflow:p})}),g=await b.json().catch(()=>({}));if(!b.ok||(g==null?void 0:g.success)===!1)throw new Error((g==null?void 0:g.message)??(g==null?void 0:g.error)??`save failed (${b.status})`);g!=null&&g.workflow&&s(cc(g.workflow))}catch(b){s(m),u(b instanceof Error?b.message:String(b))}finally{c(!1)}},[t]);return{settings:t,branchState:n,loading:a,saving:i,error:d,save:h}}const J2=[{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."}],X2=[{value:"local",label:"This machine only"},{value:"project",label:"Whole project"}];function cb(){const[t,s]=l.useState("local"),{settings:n,branchState:r,loading:a,saving:o,error:i,save:c}=K2(),d=n.checkIns.hardeningCompleted;return e.jsxs("section",{className:"mt-4",children:[e.jsx("h3",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:"Workflow"}),e.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-dim)"},children:"Checked means the workflow pauses and asks you at that point. Unchecked means it keeps going on its own."}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Apply to"}),e.jsx(Ii,{options:X2,value:t,onChange:s})]}),e.jsx("div",{className:"mt-3",children:J2.map(u=>{const h=n.checkIns[u.key];return e.jsx(ob,{label:u.label,description:u.description,checked:h.pause,disabled:a||o,onChange:p=>void c({checkIns:{...n.checkIns,[u.key]:{...h,pause:p}}},t),children:u.key==="hardeningCompleted"&&!d.pause&&e.jsx(ib,{autoAction:d.autoAction,branchState:r,disabled:o,onChange:p=>void c({checkIns:{...n.checkIns,hardeningCompleted:{...d,autoAction:p}}},t)})},u.key)})}),i&&e.jsxs("p",{className:"text-[11px] mt-3",role:"alert",style:{color:"var(--accent-red, #ef4444)"},children:["Could not save: ",i]})]})}const GM=Object.freeze(Object.defineProperty({__proto__:null,WorkflowSettingsSection:cb},Symbol.toStringTag,{value:"Module"}));function db(){return e.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4",children:[e.jsx("h2",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:"Settings"}),e.jsx(cb,{})]})}const UM=Object.freeze(Object.defineProperty({__proto__:null,SettingsTab:db},Symbol.toStringTag,{value:"Module"}));function ub({activeTab:t,appTabContent:s,leftWidth:n,onPreviewScreenshot:r}){const a=t!=="build"&&t!=="plan",[o,i]=l.useState(!1),[c,d]=l.useState(!1),[u,h]=l.useState(!1);return l.useEffect(()=>{t==="history"&&i(!0),t==="reviews"&&d(!0),t==="settings"&&h(!0)},[t]),e.jsx("div",{className:"absolute inset-0 flex flex-col",style:{visibility:a?"visible":"hidden",pointerEvents:a?"auto":"none"},children:e.jsx(ab,{activeTab:t,width:n,children:{home:s,build:null,plan:null,history:o?e.jsx(Op,{onPreviewScreenshot:r}):null,reviews:c?e.jsx(Au,{}):null,settings:u?e.jsx(db,{}):null}})})}const YM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellTabLayer:ub},Symbol.toStringTag,{value:"Module"}));function hb(t){const{annotationsBySlug:s,dependenciesBySlug:n}=Ng(t),{claims:r}=xg(),{status:a}=yg(),o=l.useMemo(()=>wg(r),[r]),i=((a==null?void 0:a.consecutiveFailures)??0)>=3;return{annotationsBySlug:s,dependenciesBySlug:n,claimsBySlug:o,staleFetch:i}}function pb({plans:t,onPickPlan:s,launchingSlug:n,planError:r,onSubmitPrompt:a,submittingPrompt:o,promptError:i,onStartBlank:c,pendingPlansLoading:d,pendingPlansError:u,isAgentBuilding:h}){const[p,f]=l.useState(""),{annotationsBySlug:m,dependenciesBySlug:b,claimsBySlug:g,staleFetch:x}=hb(t),{requestRun:y,gateModals:v}=Ei({dependenciesBySlug:b,claimsBySlug:g,isAgentBuilding:h,onLaunch:N=>{var O;const T=((O=t.find(k=>k.slug===N))==null?void 0:O.title)??N;s(N,T)}}),j=p.trim(),w=j.length>0,_=o||n!==null,S=()=>{_||(w?a(j):c())},C=N=>{(N.metaKey||N.ctrlKey)&&N.key==="Enter"&&(N.preventDefault(),S())};return e.jsxs("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"build-launch-modal",children:[e.jsxs("div",{className:"max-w-lg w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"What do you want to build?"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:t.length>0?"Pick a queued plan to run, or describe a new build and kick it off directly.":"Describe what you want to build, or just start a session."}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"max-h-48 overflow-y-auto mb-3","data-testid":"build-launch-modal-plan-list",children:e.jsx(Wr,{plans:t,loading:d,error:u,onRun:y,launchingSlug:n,launchError:r,blocked:h,depAnnotationsBySlug:m,dependenciesBySlug:b,claimsBySlug:g,staleFetch:x})}),e.jsxs("div",{className:"flex items-center gap-3 my-4 text-xs text-[var(--text-dim)]","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"}),e.jsx("span",{children:"or"}),e.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"})]})]}),e.jsx("p",{className:"text-xs uppercase tracking-wide text-[var(--text-dim)] mb-2",children:"Describe what you want to build"}),e.jsx("textarea",{value:p,onChange:N=>f(N.target.value),onKeyDown:C,rows:4,disabled:o||n!==null,placeholder:"e.g. Add a dark-mode toggle to the settings page",className:"w-full px-3 py-2 rounded-md text-sm resize-y disabled:opacity-50 disabled:cursor-not-allowed",style:{background:"var(--bg-deep, #0e0e0e)",color:"var(--text-primary)",border:"1px solid var(--border-default)"},"data-testid":"build-launch-modal-textarea"}),i&&e.jsx("p",{className:"mt-2 text-xs",style:{color:"var(--text-danger, #ff6b6b)"},"data-testid":"build-launch-modal-prompt-error",children:i}),e.jsx("div",{className:"mt-4 flex items-center justify-end gap-2",children:e.jsx("button",{type:"button",onClick:S,disabled:_,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":"build-launch-modal-submit",children:o?"Starting…":w?"Start build":"Start Building"})}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Cmd/Ctrl+Enter submits"})]}),v]})}const VM=Object.freeze(Object.defineProperty({__proto__:null,BuildLaunchModal:pb},Symbol.toStringTag,{value:"Module"}));function mb({onCreateNewPlan:t,onContinueSession:s,onViewPlans:n}){return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},"data-testid":"plan-complete-dialog",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Plan Saved!"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Your plan has been committed. Start a fresh plan, continue this session to write a related follow-up with the current context, or head back to see the list."}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("button",{onClick:t,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"Create New Plan"}),e.jsx("button",{onClick: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:"Continue with this planning session"}),e.jsx("button",{onClick:n,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},type:"button",children:"View Plans"})]})]})}const KM=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteDialog:mb},Symbol.toStringTag,{value:"Module"}));function fb({onCreateNewPlan:t,onContinueSession:s,onViewPlans:n}){return e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsx(mb,{onCreateNewPlan:t,onContinueSession:s,onViewPlans:n})})}const JM=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteTransition:fb},Symbol.toStringTag,{value:"Module"}));function Q2(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-terminal-emulator], .xterm")}function Z2(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-post-push-modal]")}function gb({onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o=0}){const i=o>0&&a,c={background:"var(--accent-active)",color:"var(--bg-deep)"},d={background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},u={background:"transparent",color:"var(--accent-danger, #f87171)",border:"1px solid var(--accent-danger, #f87171)"};return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Feature Complete!"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Your changes have been committed and pushed. You can start a new feature with a fresh context, or continue working in the current session."}),e.jsxs("div",{className:"flex flex-col gap-3",children:[i&&e.jsx("button",{onClick:a,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:c,type:"button",children:"Select A Plan"}),e.jsx("button",{onClick:t,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:i?d:c,type:"button",children:"Start Next Feature"}),e.jsx("button",{onClick:s,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:d,type:"button",children:"Continue in Current Session"}),e.jsx("button",{onClick:n,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:u,type:"button","data-testid":"post-push-stop-building",children:"Stop Building"}),r&&e.jsx("button",{onClick:r,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-dim)",border:"1px solid var(--border-default)"},type:"button",children:"Send Session Feedback"})]}),e.jsx("p",{className:"mt-4 text-center text-xs text-[var(--text-dim)]",children:i?"Press Enter to pick a queued plan":"Press Enter to start a new feature with a fresh context"})]})}const XM=Object.freeze(Object.defineProperty({__proto__:null,PostPushTransitionDialog:gb},Symbol.toStringTag,{value:"Module"}));function bb({onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o=0}){const i=l.useCallback(c=>{if(c.key!=="Enter"||Q2(c.target))return;const d=c.target===document.body||c.target===document.documentElement||c.target===document;!Z2(c.target)&&!d||(c.preventDefault(),o>0&&a?a():t())},[a,t,o]);return l.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]),e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-post-push-modal":!0,children:e.jsx(gb,{onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o})})}const QM=Object.freeze(Object.defineProperty({__proto__:null,PostPushTransition:bb},Symbol.toStringTag,{value:"Module"}));function xb({plans:t,onSelect:s,onCancel:n,launchingSlug:r,error:a}){const[o,i]=l.useState(null),c=l.useMemo(()=>{const g={};for(const x of t)g[x.slug]=x;return g},[t]),{annotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:h,staleFetch:p}=hb(t),{requestRun:f,gateModals:m}=Ei({dependenciesBySlug:u,claimsBySlug:h,onLaunch:l.useCallback(g=>{const x=c[g];x&&s(x.slug,x.title)},[s,c])}),b=l.useCallback(g=>{if(g.key==="Escape"){g.preventDefault(),n();return}g.key==="Enter"&&t.length>0&&!r&&(g.preventDefault(),f(t[0].slug))},[r,n,f,t]);return l.useEffect(()=>(window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)),[b]),t.length===0?null:e.jsxs("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"select-plan-modal",children:[e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Select A Plan"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Pick a queued plan to run next. Its body primes the editor workflow in a fresh session."}),e.jsx("ul",{className:"flex flex-col gap-2 max-h-[50vh] overflow-y-auto mb-2",children:t.map((g,x)=>{var y,v;return e.jsx(ki,{plan:g,position:x+1,expanded:o===g.slug,onToggle:()=>i(j=>j===g.slug?null:g.slug),onRun:f,launching:r===g.slug,unsatisfiedDepCount:(y=d[g.slug])==null?void 0:y.count,unsatisfiedDepTooltip:(v=d[g.slug])==null?void 0:v.tooltip,dependencies:u[g.slug],claim:h.get(g.slug),staleFetch:p,expandedBodyVariant:"view"},g.slug)})}),a&&e.jsx("p",{className:"text-xs mb-3",style:{color:"var(--text-danger, #ff6b6b)"},"data-testid":"select-plan-error",children:a}),e.jsx("button",{type:"button",onClick:n,className:"w-full px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Cancel"}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Press Enter to launch the first plan, Escape to cancel"})]}),m]})}const ZM=Object.freeze(Object.defineProperty({__proto__:null,SelectPlanModal:xb},Symbol.toStringTag,{value:"Module"}));function yb({activeTab:t,onSendTranscript:s,appTabContent:n,awaitingPlanLaunchChoice:r,buildActivated:a,planActivated:o,buildIdle:i=!1,isAgentBuilding:c=!1,planActive:d=!1,planIdle:u=!1,bannerVisible:h=!1,onDismissIdleBanner:p,hideResultsCommandKey:f,leftWidth:m,fullWidth:b=!1,navigateToTab:g,onAgentActive:x,onAgentIdle:y,onUserInput:v,notifSettings:j,onSettingsChange:w,provider:_,onContinueInSession:S,onRestorePreview:C,onResultsScenarioSelect:N,previewSlug:T=null,onStartNextFeature:O,onStopBuilding:k,showPostPushModal:D,completionModalPermitted:$=!0,showResultsCommandKey:B,planChatOpen:q,onPlanChatOpenChange:P,showPlanCompleteModal:E,onCreateNewPlan:A,onContinueSession:H,onViewPlans:z,pendingPlans:G,onSelectPlan:Q,selectPlanOpen:se,onPickPlan:le,onCancelSelectPlan:re,launchingPlanSlug:U,planLaunchError:ge,prototypeLaunchSignal:ie=0,showBuildLaunchModal:be=!1,buildLaunchGateArmed:K=!1,onSubmitBuildPrompt:L,submittingBuildPrompt:I=!1,buildPromptError:F=null,onStartBlankBuild:te,pendingPlansLoading:W,pendingPlansError:Y,onReorderPlans:V,buildDisabled:pe=!1,onPreviewScreenshot:ue,projectTitle:ve=null}){const Z=Y2();return e.jsxs("div",{className:`${b?"flex-1 w-full min-w-0":"shrink-0"} flex flex-col overflow-hidden`,style:b?{background:"var(--bg-deep)"}:{width:m,background:"var(--bg-deep)"},children:[Z&&e.jsx(Uf,{projectTitle:ve}),e.jsx(Gf,{activeTab:t,onTabChange:g,onSendTranscript:s,buildIdle:i,isAgentBuilding:c,planActive:d,planIdle:u,bannerVisible:h,onDismissIdleBanner:p,buildDisabled:pe,showLogo:!Z}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.jsx(pg,{awaitingPlanLaunchChoice:r,buildLaunchGateArmed:K,buildActivated:a,activeTab:t,onSelectScenario:N,previewSlug:T,showResultsCommandKey:B,hideResultsCommandKey:f,onAgentIdle:y,onAgentActive:x,onUserInput:v,notifSettings:j,onSettingsChange:w,provider:_,onRestorePreview:C,pendingPlans:G,pendingPlansLoading:W,pendingPlansError:Y,onLaunchPlan:le,launchingSlug:U,launchError:ge,onReorderPlans:V,isAgentBuilding:c,featureCompleteActive:D}),e.jsx(nb,{activeTab:t,planActivated:o,chatOpen:q,onChatOpenChange:P,isAgentBuilding:c,launchingPlanSlug:U,planLaunchError:ge,onLaunchPlan:le,prototypeLaunchSignal:ie}),e.jsx(ub,{activeTab:t,appTabContent:n,leftWidth:m,onPreviewScreenshot:ue}),D&&$&&t==="build"&&!se?e.jsx(bb,{onStartNextFeature:O,onContinueInSession:S,onStopBuilding:k,onSendTranscript:s,onSelectPlan:Q,pendingPlanCount:G.length}):null,se&&t==="build"?e.jsx(xb,{plans:G,onSelect:le,onCancel:re,launchingSlug:U,error:ge}):null,be&&t==="build"&&!D&&L&&te?e.jsx(pb,{plans:G,onPickPlan:le,launchingSlug:U,planError:ge,onSubmitPrompt:L,submittingPrompt:I,promptError:F,onStartBlank:te,pendingPlansLoading:W,pendingPlansError:Y,isAgentBuilding:c}):null,E&&t==="plan"?e.jsx(fb,{onCreateNewPlan:A,onContinueSession:H,onViewPlans:z}):null]})]})}const eI=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLeftPane:yb},Symbol.toStringTag,{value:"Module"})),dc=5173;function Di(t){if(t.startsWith("http"))try{return new URL(t).pathname}catch{return t}return t.split("?")[0]??t}function Li(t){return t?parseInt(t.port||(t.protocol==="https:"?"443":"80"),10):0}function Fi(t,{appPort:s,currentPort:n,previewOrigin:r}){return t.startsWith("http")?t:r?`${r}${t}`:n===s?t:`http://localhost:${s}${t}`}function vb(t,s,n,r,a){if(n&&n.length>0)return Fi(n,{appPort:r,currentPort:s,previewOrigin:a});const o=`/scenario/${t}`;return a?`${a}${o}`:s===dc?o:`http://localhost:${dc}${o}`}const eC=["/apps","/entities","/app","/build","/history","/settings","/plan"];function jb(t){if(!t)return!1;const s=Di(t);return eC.some(n=>s===n||s.startsWith(`${n}/`))}function wb(t,s,n){const r=typeof window<"u"?Li(window.location):0;let a="";if(Xj(t)==="component"?a=vb(t.slug,r,t.url,s,n):t.url&&(a=Fi(t.url,{appPort:s,currentPort:r,previewOrigin:n})),a&&!jb(a))try{const o=!a.startsWith("http"),i=typeof window<"u"?window.location.origin:"http://localhost",c=new URL(a,i);return c.searchParams.set("_codeyam_scenario",t.slug),o?c.pathname+c.search+c.hash:c.toString()}catch{return a}return a}async function uc(t,s=null){try{const n={pid:t};s&&(n.url=s),await fetch("/api/editor-iframe-loaded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}async function tC(t){try{await fetch("/api/editor-iframe-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({error:t})})}catch{}}async function sC(t){try{await fetch("/api/editor-iframe-banner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seedError:t})})}catch{}}async function nC(t){try{await fetch("/api/editor-iframe-auth-needed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({previewOrigin:t})})}catch{}}async function rC(t){try{await fetch("/api/editor-preview-escape",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({escapedPath:t})})}catch{}}function aC(t,s,n,r,a){const o=t-a*2,i=s-a*2;return o<=0||i<=0?1:Math.min(1,o/n,i/r)}const oC=32;function iC({currentHeight:t,currentWidth:s,isFilled:n}){const[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(h=>{const p=h.getBoundingClientRect();a({width:p.width,height:p.height})},[]),d=l.useCallback(h=>{if(o.current&&(o.current.disconnect(),o.current=null),i.current=h,!h){a(null);return}c(h);const p=new ResizeObserver(()=>{const f=i.current;f&&c(f)});p.observe(h),o.current=p},[c]),u=n||!r?1:aC(r.width,r.height,s,t,oC);return{containerRef:d,containerSize:r,scale:u}}const lC={kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!1},hc=[400,800,1500,3e3];function _b(){const[t,s]=l.useState({kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!0});return l.useEffect(()=>{let n=!1,r,a=0;const o=()=>{const d=hc[Math.min(a,hc.length-1)];a+=1,r=setTimeout(c,d)},i=()=>{s(d=>d.loading?lC:d),o()},c=()=>{fetch("/api/project-stack").then(d=>d.ok?d.json():{}).then(d=>{n||(cC(d)?s(dC(d)):i())}).catch(()=>{n||i()})};return c(),()=>{n=!0,r&&clearTimeout(r)}},[]),t}function cC(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length>0}function dC(t){const s=t&&typeof t=="object"&&"preview"in t?t.preview:null;if(!s||typeof s!="object")return{kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!1};const n=s;return{kind:uC(n.kind),fallbackKind:hC(n.fallbackKind),fallbackPort:typeof n.fallbackPort=="number"?n.fallbackPort:null,loading:!1}}function uC(t){return t==="simulator-ios"?"simulator-ios":t==="simulator-android"?"simulator-android":"iframe"}function hC(t){return t==="iframe"||t==="simulator-ios"||t==="simulator-android"?t:null}const pC="codeyam:client-routing-detected";function mC(t){const[s,n]=l.useState(!1);return l.useEffect(()=>{if(!t)return;function r(a){var o;a.origin===window.location.origin&&((o=a.data)==null?void 0:o.type)===pC&&n(!0)}return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[t]),s}const fC=700;function kb({pollMs:t=fC,paused:s=!1,onError:n}={}){const[r,a]=l.useState(0),[o,i]=l.useState({kind:"loading"}),c=l.useRef(n);return c.current=n,l.useEffect(()=>{if(s)return;let d=!1;const u=window.setInterval(()=>{d||a(h=>h+1)},t);return()=>{d=!0,window.clearInterval(u)}},[t,s]),l.useEffect(()=>{if(s)return;let d=!1;return fetch(`/api/simulator-frame?t=${r}`,{method:"HEAD"}).then(async u=>{var p;if(d)return;if(u.ok){i({kind:"ok"});return}if(u.status===503){const f=await gC(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 h=`simulator frame request failed (${u.status})`;i({kind:"capture-failed",message:h}),(p=c.current)==null||p.call(c,h)}).catch(u=>{var p;if(d)return;const h=u instanceof Error?u.message:"simulator frame request errored";i({kind:"capture-failed",message:h}),(p=c.current)==null||p.call(c,h)}),()=>{d=!0}},[r,s]),{state:o,isBooted:o.kind==="ok",frameToken:r}}async function gC(t){try{return await t.json()}catch{return null}}function bC(t,s){const n=(t==null?void 0:t.screenshotPaths)??[];if(n.length===0)return null;if(s){const r=`--${s.toLowerCase()}.png`,a=n.find(o=>o.toLowerCase().endsWith(r));if(a)return a}return n[0]??null}function xC(t,s,n){switch(t){case 1:case 2:return"Setting up...";case 3:return`Building — ${s} files modified, ${n} 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 ro(){const t=Date.now();try{const s=await fetch("/api/editor-session-summary"),n=Date.now()-t;return s.ok?{ok:!0,data:await s.json(),statusCode:s.status,durationMs:n,error:null}:{ok:!1,data:null,statusCode:s.status,durationMs:n,error:`HTTP ${s.status}`}}catch(s){return{ok:!1,data:null,statusCode:null,durationMs:Date.now()-t,error:s instanceof Error?s.message:String(s)}}}const yC=50,vC={status:"loading",lastSuccessAt:null,lastErrorAt:null,lastErrorMessage:null,fetchCount:0,errorCount:0};function jC(t,s,n){return{status:s.ok?"connected":"disconnected",lastSuccessAt:s.ok?n:t.lastSuccessAt,lastErrorAt:s.ok?t.lastErrorAt:n,lastErrorMessage:s.ok?t.lastErrorMessage:s.error,fetchCount:t.fetchCount+1,errorCount:t.errorCount+(s.ok?0:1)}}function wC(t,s){return{timestamp:s,success:t.ok,statusCode:t.statusCode,durationMs:t.durationMs,error:t.error}}function _C(t,s){return[s,...t].slice(0,yC)}function kC(){const[t,s]=l.useState(vC),[n,r]=l.useState([]),a=l.useCallback(i=>{const c=Date.now();r(d=>_C(d,wC(i,c))),s(d=>jC(d,i,c))},[]),o=l.useCallback(()=>{s(i=>({...i,status:"polling"}))},[]);return{connectionState:t,fetchLog:n,recordFetch:a,markPolling:o}}async function SC(t){try{const r=await fetch("/api/test-results");if(r.ok&&(await r.json()).running)return{kind:"busy"}}catch{}const s={tests:[t.name]};t.file&&(s.changedFiles=[t.file]);let n;try{n=await fetch("/api/test-results/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch(r){return{kind:"error",message:r instanceof Error?r.message:String(r)}}if(n.ok)return{kind:"accepted"};try{const r=await n.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 ${n.status}).`}}function NC(t,s){if(!t.narrative)return null;for(const n of t.narrative.changes)for(const r of n.tests)if(r.name===s)return{lastRunAt:r.lastRunAt,status:r.status??"unknown"};return null}async function CC(t,s,n){const r=n.intervalMs??2e3,a=n.nowMs??(()=>Date.now()),o=n.sleep??(c=>new Promise(d=>setTimeout(d,c))),i=a()+n.timeoutMs;for(;;){const c=await ro();if(c.ok&&c.data){const d=NC(c.data,t.name);if(d!=null&&d.lastRunAt&&Date.parse(d.lastRunAt)>s)return{kind:"completed",status:d.status,summary:c.data}}if(a()>=i)return{kind:"timeout"};await o(r)}}function PC(t){return!t||t<=0?3e4:Math.max(3e4,t*2)}function TC({onSummaryUpdate:t,getLastDurationMs:s}){const[n,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 SC(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=PC(s()),h=await CC(o,c,{timeoutMs:u});h.kind==="completed"?(t(h.summary),r(null)):r({name:i,state:{phase:"timeout"}})})()},[t,s]);return{active:n,onRerun:a}}function AC(t){switch(t.status){case"connected":return{dotClass:"bg-green-500",label:"Connected",labelClass:"text-green-400"};case"polling":return{dotClass:"bg-yellow-400 animate-pulse",label:"Polling...",labelClass:"text-yellow-400"};case"disconnected":return{dotClass:"bg-red-500",label:"Disconnected",labelClass:"text-red-400"};case"loading":default:return{dotClass:"bg-[var(--text-muted)]",label:"Connecting...",labelClass:"text-[var(--text-muted)]"}}}function Sb({state:t}){const s=Ws(),{dotClass:n,label:r,labelClass:a}=AC(t);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium","data-testid":"connection-status-badge",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${n}`,"data-testid":"connection-status-dot"}),e.jsx("span",{className:a,"data-testid":"connection-status-label",children:r}),t.lastSuccessAt!=null&&e.jsxs("span",{className:"text-[var(--text-muted)]","data-testid":"connection-status-updated",children:["Updated ",Aa(t.lastSuccessAt,s)]})]})}const tI=Object.freeze(Object.defineProperty({__proto__:null,BackendConnectionStatusBadge:Sb},Symbol.toStringTag,{value:"Module"}));function Nb({feature:t,connectionState:s,statusChip:n,userPrompt:r}){return e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:[e.jsx("h1",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:t||"Working Session Results"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx(Sb,{state:s}),n&&e.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)] rounded-full","data-testid":"status-chip",children:n})]}),r&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]","data-testid":"user-prompt-section",children:[e.jsx("div",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wide",children:"Your request"}),e.jsx("div",{className:"mt-2 bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded-md p-3",children:e.jsx(Sr,{maxHeight:90,moreLabel:"View More",lessLabel:"View Less",fadeColor:"var(--bg-input)",children:r})})]})]})}const sI=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsHeader:Nb},Symbol.toStringTag,{value:"Module"}));function OC(t,s,n=[]){var r;return{headline:(r=t.description)!=null&&r.trim()?t.description:t.name,name:t.name,file:t.file,status:t.status??"unknown",failureMessage:t.failureMessage,change:s.title,lastRunAt:t.lastRunAt,lastRunKind:t.lastRunKind,recentStatuses:t.recentStatuses,exercises:n.filter(a=>a.tests.some(o=>Ci(o)===t.name)),example:t.example}}function Cb(t,s=[]){const n=[],r=[];let a=0;for(const o of t.tests){if(o.verified===!1){a+=1;continue}const i=OC(o,t,s);i.status==="passing"?n.push(i):r.push(i)}return{worksNow:n,inProgress:r,unverifiedCount:a}}function RC(t,s=[]){const n=[],r=[];let a=0;for(const o of t.changes){const i=Cb(o,s);n.push(...i.worksNow),r.push(...i.inProgress),a+=i.unverifiedCount}return{worksNow:n,inProgress:r,unverifiedCount:a}}function EC(t){if(!t||t.length<2)return!1;const s=t.some(r=>r.status==="pass"),n=t.some(r=>r.status==="fail");return s&&n}function MC(t){if(t==null||t===0)return"";const s=Math.abs(t),n=t>0?"slower":"faster";return`${s}s ${n} than the previous run`}function Pb({status:t}){switch(t){case"passing":return e.jsx("span",{className:"text-green-500 text-xs mt-0.5 shrink-0",children:"✓"});case"failing":return e.jsx("span",{className:"text-red-500 text-xs mt-0.5 shrink-0",children:"✗"});case"running":return e.jsx("span",{className:"text-[#D7FF63] text-xs mt-0.5 shrink-0 animate-spin",children:"◠"});default:return e.jsx("span",{className:"text-gray-400 text-xs mt-0.5 shrink-0",children:"●"})}}const nI=Object.freeze(Object.defineProperty({__proto__:null,NarrativeTestStatusIcon:Pb},Symbol.toStringTag,{value:"Module"})),pc="font-mono text-[11px] text-[var(--text-primary)] whitespace-pre-wrap break-words min-w-0",mc="w-0 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] align-top pr-3 py-1 whitespace-nowrap";function Tb({example:t}){return e.jsxs("div",{"data-testid":"behavior-example",children:[e.jsx("table",{className:"w-full border-collapse",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{className:mc,children:"Input"}),e.jsx("td",{className:`${pc} py-1`,"data-testid":"example-input",children:t.input})]}),e.jsxs("tr",{children:[e.jsx("td",{className:mc,children:"Output"}),e.jsx("td",{className:`${pc} py-1`,"data-testid":"example-output",children:t.output})]})]})}),t.note&&e.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1 mb-0 italic","data-testid":"example-note",children:t.note})]})}const rI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorExampleTable:Tb},Symbol.toStringTag,{value:"Module"})),IC="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function DC(t){switch(t.phase){case"busy":return"Tests are already running — try again once they finish.";case"error":return t.message;case"timeout":return"Couldn't confirm — check test results.";default:return null}}function Ab({rerun:t={phase:"idle"},onRerun:s,disabled:n=!1,disabledReason:r}){const a=t.phase==="verifying",o=DC(t),i=t.phase==="error",c=n||a;return e.jsxs("div",{"data-testid":"evidence-rerun",children:[e.jsx("div",{className:IC,children:"Re-run"}),e.jsxs("button",{type:"button",onClick:s,disabled:c,title:n?r:void 0,"aria-busy":a,"data-testid":"rerun-button",className:"inline-flex items-center gap-1.5 text-[11px] px-2 py-1 rounded border border-[var(--border-default)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--text-muted)] disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:[a&&e.jsx("span",{className:"inline-block w-3 h-3 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full animate-spin"}),a?"Verifying…":"Re-run this test"]}),o&&e.jsx("p",{className:`text-[11px] mt-1 m-0 ${i?"text-red-600":"text-[var(--text-muted)]"}`,"data-testid":"rerun-note",children:o})]})}const aI=Object.freeze(Object.defineProperty({__proto__:null,RerunSection:Ab},Symbol.toStringTag,{value:"Module"}));function LC(t){return t==="passing"?"passed":t==="failing"?"failed":"ran"}function FC(t){switch(t){case"full":return"full run";case"changed":return"changed-files run";case"targeted":return"targeted run"}}function Ob(t){var r;const s=t.status==="failing"&&!!t.failureMessage,n=(((r=t.recentStatuses)==null?void 0:r.length)??0)>0;return!!t.lastRunAt||t.exercises.length>0||s||!!t.example||n}const Js="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function Rb({behavior:t,rerun:s={phase:"idle"},onRerun:n,disabled:r=!1,disabledReason:a}){const o=Ws(),i=t.status==="failing"&&!!t.failureMessage;return e.jsxs("div",{className:"mt-2 ml-5 space-y-3","data-testid":"behavior-evidence-drawer",children:[t.lastRunAt&&e.jsxs("div",{"data-testid":"evidence-verified",children:[e.jsx("div",{className:Js,children:"Verified"}),e.jsxs("p",{className:"text-[11px] text-[var(--text-secondary)] m-0",children:[LC(t.status)," ",Aa(Date.parse(t.lastRunAt),o),t.lastRunKind&&e.jsxs("span",{className:"text-[var(--text-muted)]",children:[" (",FC(t.lastRunKind),")"]})]})]}),t.example&&e.jsxs("div",{"data-testid":"evidence-example",children:[e.jsx("div",{className:Js,children:"Example"}),e.jsx(Tb,{example:t.example})]}),t.recentStatuses&&t.recentStatuses.length>0&&e.jsxs("div",{"data-testid":"evidence-recent-runs",children:[e.jsx("div",{className:Js,children:"Recent runs"}),e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:[...t.recentStatuses].reverse().map((c,d)=>e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${c.status==="pass"?"bg-green-500":c.status==="fail"?"bg-red-500":"bg-[var(--text-dim)]"}`,title:`${c.status} · ${Aa(Date.parse(c.at),o)}`,"data-testid":`recent-run-dot-${c.status}`},`${c.at}-${d}`))})]}),t.exercises.length>0&&e.jsxs("div",{"data-testid":"evidence-exercises",children:[e.jsx("div",{className:Js,children:"Exercises"}),e.jsx("ul",{className:"list-none p-0 m-0 space-y-1",children:t.exercises.map(c=>e.jsxs("li",{className:"text-[11px] text-[var(--text-secondary)] flex items-center gap-x-1.5",children:[e.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:c.name}),e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsx("span",{className:"font-mono text-[var(--text-dim)] min-w-0 truncate",children:c.filePath}),c.coverage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[Math.round(c.coverage.percent),"% covered"]})]})]},c.name))})]}),i&&e.jsxs("div",{"data-testid":"evidence-failure",children:[e.jsx("div",{className:Js,children:"Failure"}),e.jsx("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-[11px] font-mono text-red-700 whitespace-pre-wrap overflow-x-auto","data-testid":"failure-message",children:t.failureMessage})]}),e.jsx(Ab,{rerun:s,onRerun:n,disabled:r,disabledReason:a})]})}const oI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorEvidenceDrawer:Rb,hasDrawerContent:Ob},Symbol.toStringTag,{value:"Module"}));function Eb({behavior:t,rerun:s}){var h,p;const[n,r]=l.useState(!1),a=Ob(t),o=EC(t.recentStatuses),i=((h=s==null?void 0:s.active)==null?void 0:h.name)===t.name,c=i?s.active.state:{phase:"idle"},d=c.phase==="verifying",u=((p=s==null?void 0:s.active)==null?void 0:p.state.phase)==="verifying"&&!i;return e.jsx("div",{"data-testid":"behavior-item",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Pb,{status:d?"running":t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-[var(--text-primary)] leading-relaxed",children:[t.headline,o&&e.jsx("span",{className:"ml-1.5 align-middle inline-block px-1.5 py-0.5 rounded text-[10px] font-medium text-[var(--text-muted)] bg-[var(--bg-surface)] border border-[var(--border-default)]",title:"Recent runs mix passes and failures — this behavior is intermittently failing","data-testid":"flaky-chip",children:"flaky?"})]}),e.jsxs("div",{className:"flex items-center gap-x-1.5 mt-1 text-[11px]",children:[e.jsx("span",{className:"text-[var(--text-muted)] font-mono min-w-0 truncate",children:t.name}),t.file&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),e.jsx("span",{className:"text-[var(--text-dim)] font-mono min-w-0 truncate",children:t.file})]}),t.change&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),e.jsx("span",{className:"text-[var(--text-muted)] opacity-70 shrink-0",children:t.change})]})]})]}),a&&e.jsx("button",{className:"shrink-0 text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer text-[10px] leading-none mt-1 px-1",onClick:()=>r(!n),"aria-expanded":n,"aria-label":n?"Hide evidence":"Show evidence","data-testid":"toggle-evidence-drawer",children:n?"▾":"▸"})]}),a&&n&&e.jsx(Rb,{behavior:t,rerun:c,onRerun:s?()=>s.onRerun(t):void 0,disabled:u,disabledReason:"Verifying another behavior…"})]})]})})}const iI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorItem:Eb},Symbol.toStringTag,{value:"Module"}));function ao({label:t,behaviors:s,tone:n,rerun:r}){if(s.length===0)return null;const a=n==="positive"?"text-green-500":"text-[var(--text-secondary)]";return e.jsxs("section",{className:"space-y-3","data-testid":"behavior-group",children:[e.jsxs("h2",{className:`text-xs font-semibold uppercase tracking-wide m-0 ${a}`,"data-testid":"behavior-group-heading",children:[t," (",s.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.map(o=>e.jsx(Eb,{behavior:o,rerun:r},`${o.change}:${o.name}`))})]})}const lI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGroup:ao},Symbol.toStringTag,{value:"Module"}));function zi({ways:t}){return t.length===0?null:e.jsxs("div",{className:"space-y-1.5","data-testid":"ways-to-test",children:[e.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0",children:"Ways to test"}),e.jsx("ul",{className:"list-disc pl-4 space-y-1 m-0",children:t.map((s,n)=>e.jsx("li",{className:"text-sm leading-relaxed","data-testid":"way-to-test",children:zC(s)},n))})]})}function zC(t){return t.kind==="run-scenario"&&t.scenarioUrl?e.jsxs("a",{href:t.scenarioUrl,target:"_blank",rel:"noopener",className:"text-[var(--accent-blue)] hover:underline inline-flex items-center gap-1","data-testid":"way-to-test-scenario-link",children:[t.text,e.jsx("span",{"aria-hidden":"true",className:"text-[10px] opacity-70",children:"↗ open in dev app"})]}):t.kind==="staging-only"?e.jsx("span",{className:"text-[var(--text-muted)] italic","data-testid":"way-to-test-staging-only",children:t.text}):e.jsx("span",{className:"text-[var(--text-primary)]",children:t.text})}const cI=Object.freeze(Object.defineProperty({__proto__:null,WaysToTestList:zi},Symbol.toStringTag,{value:"Module"}));function Mb({change:t,functions:s=[],rerun:n}){const{worksNow:r,inProgress:a}=Cb(t,s);return e.jsxs("section",{className:"space-y-3 pt-4 border-t border-[var(--border-subtle)]","data-testid":"change-card",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] leading-relaxed m-0",children:t.description}),e.jsx(zi,{ways:t.waysToTest??[]}),e.jsx(ao,{label:"Works now",behaviors:r,tone:"positive",rerun:n}),e.jsx(ao,{label:"In progress",behaviors:a,tone:"pending",rerun:n})]})}const dI=Object.freeze(Object.defineProperty({__proto__:null,ChangeCard:Mb},Symbol.toStringTag,{value:"Module"}));function Ib({narrative:t,functions:s=[],rerun:n}){const{unverifiedCount:r}=RC(t,s);return e.jsxs("div",{className:"space-y-6","data-testid":"behavior-gallery",children:[t.summary&&e.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-relaxed m-0",children:t.summary}),t.changes.map((a,o)=>e.jsx(Mb,{change:a,functions:s,rerun:n},`${a.title}:${o}`)),r>0&&e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)] m-0","data-testid":"unverified-footnote",children:[r," test",r===1?"":"s"," not yet found in source."]})]})}const uI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGallery:Ib},Symbol.toStringTag,{value:"Module"}));function Db({step:t}){return e.jsx("div",{className:"text-sm text-[var(--text-muted)]","data-testid":"behavior-gallery-empty",children:e.jsx("span",{"data-testid":"behavior-gallery-prebuild",children:"The build will describe what it’s creating here as it works."})})}const hI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGalleryEmptyState:Db},Symbol.toStringTag,{value:"Module"}));function $C(t){const s=t.trim();if(s==="??")return"New";switch(s.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 s||t}}function Lb({path:t,status:s,testid:n}){return e.jsxs("li",{className:"flex items-center gap-2","data-testid":n,children:[e.jsx("span",{className:"font-mono text-[var(--text-primary)] truncate",children:t}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)] shrink-0",children:$C(s)})]})}const pI=Object.freeze(Object.defineProperty({__proto__:null,BuildFileRow:Lb},Symbol.toStringTag,{value:"Module"}));function Fb({feature:t,modifiedFiles:s,functions:n,waysToTestBaseline:r,step:a}){const o=new Set(n.map(u=>u.filePath)),i=s.filter(u=>!o.has(u.path)),c=(()=>{const u=new Map;for(const h of n.flatMap(p=>p.tests)){const p=Ci(h);if(!p)continue;const f=YN(h),m=u.get(p);m?m.description===void 0&&f!==void 0&&(m.description=f):u.set(p,{name:p,description:f})}return Array.from(u.values())})(),d=a>=4;return e.jsxs("div",{className:"text-sm space-y-5","data-testid":"build-progress-detail",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-[var(--accent-blue)] animate-pulse","aria-hidden":"true"}),e.jsx("span",{className:"text-[var(--text-primary)] font-medium",children:t?`Building ${t}…`:"Building…"})]}),e.jsxs("section",{"data-testid":"build-areas-changed",children:[e.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0 mb-1.5",children:"Areas being changed"}),n.length===0&&s.length===0?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Gathering changes…"}):e.jsxs("div",{className:"space-y-3",children:[n.length>0&&e.jsx("ul",{className:"list-none pl-0 m-0 space-y-2",children:n.map(u=>e.jsx("li",{children:e.jsx(Pi,{fn:u,testid:"build-area-function"})},`${u.filePath}::${u.name}`))}),i.length>0&&e.jsxs("div",{children:[n.length>0&&e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-muted)] mb-1",children:"Other files"}),e.jsx("ul",{className:"list-none pl-0 m-0 space-y-0.5",children:i.map(u=>e.jsx(Lb,{path:u.path,status:u.status,testid:"build-area-file"},u.path))})]})]})]}),e.jsxs("section",{"data-testid":"build-tests",children:[e.jsxs("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0 mb-1.5",children:["Tests validating the change",c.length>0&&e.jsxs("span",{className:"ml-1 text-[var(--text-muted)] font-normal normal-case tracking-normal",children:["(",c.length,")"]})]}),c.length===0?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Tests will appear here as they’re written."}):e.jsx("ul",{className:"list-none pl-0 m-0 space-y-1",children:c.map(u=>e.jsxs("li",{"data-testid":"build-test-name",children:[e.jsx("div",{className:"font-mono text-xs text-[var(--text-primary)]",children:u.name}),u.description&&e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:u.description})]},u.name))})]}),e.jsxs("section",{"data-testid":"build-ways-to-test",children:[e.jsx(zi,{ways:r??[]}),e.jsx("div",{className:"mt-1.5 text-xs text-[var(--text-muted)] italic",children:d?"Detailed ways to test appear once the build finishes verifying.":"Detailed ways to test appear once the build finishes."})]})]})}const mI=Object.freeze(Object.defineProperty({__proto__:null,BuildProgressDetail:Fb},Symbol.toStringTag,{value:"Module"}));function BC(t){return t.filter(Boolean).join(" · ")}function qC(t){if(!t)return"";const s=Math.round(t.global.percent);if(t.previousGlobal==null)return`coverage ${s}%`;const n=Math.round(t.global.percent-t.previousGlobal);if(n===0)return`coverage ${s}% (±0)`;const r=n>0?"+":"−";return`coverage ${s}% (${r}${Math.abs(n)})`}function zb({stats:t,thresholds:s,trendDeltaSecs:n}){if(!t)return null;const r=t.runners.length||t.per_runner.length,a=t.per_runner.filter(i=>i.duration_ms!=null).map(i=>`${i.name} ${Math.round(i.duration_ms/1e3)}s`),o=BC([`${r} runner${r===1?"":"s"}`,`${t.passed} passed`,t.failed>0?`${t.failed} failed`:"",...a,qC(s),MC(n)]);return e.jsx("p",{className:"text-[11px] text-[var(--text-muted)] font-mono m-0","data-testid":"run-evidence-line",children:o})}const fI=Object.freeze(Object.defineProperty({__proto__:null,RunEvidenceLine:zb},Symbol.toStringTag,{value:"Module"})),HC=5e3;function $b(){const[t,s]=l.useState(null),[n,r]=l.useState(!0),{connectionState:a,recordFetch:o,markPolling:i}=kC(),c=l.useRef(null),d=l.useRef(null);d.current=t;const u=TC({onSummaryUpdate:s,getLastDurationMs:l.useCallback(()=>{var m,b;return(b=(m=d.current)==null?void 0:m.testRunnerStats)==null?void 0:b.duration_ms},[])});if(l.useEffect(()=>{async function m(){const b=await ro();o(b),b.ok&&b.data&&s(b.data),r(!1)}return m(),()=>{c.current&&clearInterval(c.current)}},[o]),l.useEffect(()=>(c.current&&(clearInterval(c.current),c.current=null),(t==null?void 0:t.live)===!0&&(c.current=setInterval(async()=>{i();const m=await ro();o(m),m.ok&&m.data&&s(m.data)},HC)),()=>{c.current&&clearInterval(c.current)}),[t==null?void 0:t.live,o,i]),n)return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center",children:e.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!t)return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center text-[var(--text-muted)] text-sm",children:"No session data available."});const h=t.step??0,p=t.functions.reduce((m,b)=>m+b.tests.length,0),f=xC(h,t.modifiedFiles.length,p);return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] p-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsx(Nb,{feature:t.feature,connectionState:a,statusChip:f,userPrompt:t.userPrompt}),e.jsx(zb,{stats:t.testRunnerStats,thresholds:t.coverageThresholds,trendDeltaSecs:t.suiteTrendDeltaSecs}),e.jsx("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:t.narrative?e.jsx(Ib,{narrative:t.narrative,functions:t.functions,rerun:u}):h>=3?e.jsx(Fb,{feature:t.feature,modifiedFiles:t.modifiedFiles,functions:t.functions,waysToTestBaseline:t.waysToTestBaseline,step:h}):e.jsx(Db,{step:h})})]})})}const gI=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPage:$b},Symbol.toStringTag,{value:"Module"}));function Bb(){return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx($b,{})})}const bI=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPanelView:Bb},Symbol.toStringTag,{value:"Module"}));function qb({onClose:t}){const[s,n]=l.useState(""),r=l.useRef(null);return l.useEffect(()=>{var a;(a=r.current)==null||a.focus()},[]),l.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[t]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-1",children:"Create New State"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Describe the state you want Claude to build."}),e.jsx("textarea",{ref:r,value:s,onChange:a=>n(a.target.value),placeholder:"e.g. Empty inbox with a friendly empty-state illustration",rows:5,className:"w-full px-3 py-2 text-sm rounded mb-4 resize-none focus:outline-none",style:{background:"var(--bg-input)",border:"1px solid var(--border-default)",color:"var(--text-primary)"}}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-md text-sm transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Cancel"}),e.jsx("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 Claude"})]})]})})}const xI=Object.freeze(Object.defineProperty({__proto__:null,CreateStatePlaceholderModal:qb},Symbol.toStringTag,{value:"Module"}));function Hb(){const[t,s]=l.useState(null),n=l.useRef(!0),r=l.useCallback(async()=>{try{const a=await fetch("/api/editor-design-assets");if(!a.ok)return;const o=await a.json();n.current&&s(Array.isArray(o.assets)?o.assets:[])}catch{}},[]);return l.useEffect(()=>(n.current=!0,r(),()=>{n.current=!1}),[r]),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{padding:"var(--spacing-lg, 16px)",gap:"var(--spacing-md, 12px)",overflow:"auto"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"var(--text-md, 15px)",fontWeight:600,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:"Add design assets"}),e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)",lineHeight:1.5},children:"Drag design assets onto codeyam-editor, or browse to add them — logos, screenshots, brand guides, inspiration. The agent reads whatever you add and folds it into the mockups."})]}),e.jsx(ci,{onAssetsSaved:r}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:[e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Added assets"}),t===null?e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"Loading…"}):t.length===0?e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"No assets added yet."}):t.map(a=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px)",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-input)"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:500,color:"var(--text-primary)"},children:a.filename}),a.description.trim().length>0&&e.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:a.description})]},a.filename))]})]})}const yI=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetsView:Hb},Symbol.toStringTag,{value:"Module"}));function WC(t,s){var c;const n=[],r=Object.entries(s.vars).filter(([,d])=>d&&d.trim());if(r.length>0){const d=r.map(([u,h])=>` ${u}: ${h};`).join(`
40
- `);n.push(`:root {
41
- ${d}
42
- }`)}if(s.primaryFont){const d=fc(s.primaryFont,s.primaryFontStack);n.push(`body, p, li, span, button, input, textarea, select, label { font-family: ${d} !important; }`)}if(s.secondaryFont){const d=fc(s.secondaryFont,s.secondaryFontStack);n.push(`h1, h2, h3, h4, h5, h6, .heading, [class*="title"], [class*="headline"] { font-family: ${d} !important; }`)}const a=n.length>0?`<style data-codeyam-overrides="1">
43
- ${n.join(`
44
-
45
- `)}
46
- </style>`:"",o=s.fontsHref?`<link rel="preconnect" href="https://fonts.googleapis.com">
47
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
48
- <link rel="stylesheet" href="${s.fontsHref}" data-codeyam-fonts="1">`:"";if(!a&&!o)return t;const i=t.search(/<\/head\s*>/i);if(i===-1){const d=t.search(/<body[^>]*>/i);if(d===-1)return`${o}
49
- ${a}
50
- ${t}`;const u=d+(((c=t.match(/<body[^>]*>/i))==null?void 0:c[0].length)??0);return`${t.slice(0,u)}
51
- ${o}
52
- ${a}
53
- ${t.slice(u)}`}return`${t.slice(0,i)}
54
- ${o}
55
- ${a}
56
- ${t.slice(i)}`}function fc(t,s){const n=/\s/.test(t)?`"${t}"`:t,r=(s==null?void 0:s.trim())||"system-ui, sans-serif";return`${n}, ${r}`}const GC={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function Yr(t){return t.replace(/^\d{1,2}-/,"").replace(/-mockup\.html$/i,"").replace(/\.html$/i,"")}function UC(t,s){if(t===null||t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(t[n].filename!==s[n].filename||t[n].url!==s[n].url||t[n].name!==s[n].name)return!1;return!0}const YC="\x1B[200~",VC="\x1B[201~";function KC(t,s=JC){const n=t.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),r=`${YC}${n}${VC}`;return s(r),new Promise(a=>{setTimeout(()=>{s("\r"),a()},pw)})}function JC(t){window.dispatchEvent(new CustomEvent("miniagent-send-input",{detail:t}))}function XC({feedbackByFilename:t,mockupFilenames:s}){const n={};for(const o of s){const i=t[o];if(!i)continue;const c=typeof i.rating=="number",d=i.comment.trim().length>0;!c&&!d||(n[o]={rating:c?i.rating:null,comment:i.comment.trim()})}return Object.keys(n).length===0?"Iterate: before regenerating anything, first ask the user in the chat which of these designs (if any) are close enough to keep and just tweak — and let them know that every other design will be discarded and redesigned fresh. Wait for their reply before writing any mockup. No per-card feedback was provided, so let their answer guide what to keep vs. redesign from scratch.":`Iterate: before regenerating anything, first ask the user in the chat which of these designs (if any) are close enough to keep and just tweak — and let them know that every other design will be discarded and redesigned fresh from the feedback below. Wait for their reply before writing any mockup.
57
-
58
- Once they answer: for designs they choose to keep, refine them in place using their specific feedback, keeping the same numeric prefix and design system. For every other design, redesign it fresh from the feedback — each redesign must directly address the specific comment and rating for that card (a pointed comment is a concrete instruction the redesign must visibly resolve; a low rating means change direction further). For fresh redesigns, weigh the rating and comment to decide whether to keep the same design system with a new layout, or swap in a different system from .codeyam/design/design_systems/ — avoid duplicating a system already used by a kept card. When you change a slot's design system, delete the old NN-*.html file before writing the new NN-<newsystem>-mockup.html so each slot has exactly one file. Keep numeric filename prefixes stable so slots don't move.
59
-
60
- Per-card feedback (rating is 1-100 or null; comment may be empty):
61
-
62
- \`\`\`json
63
- `+JSON.stringify(n,null,2)+"\n```"}const QC=9e4;function ZC(t){return!!(t.agentRespondedAfterDispatch||e3(t.snapshotFilenames,t.latestFilenames))}function e3(t,s){if(t.length!==s.length)return!0;const n=[...t].sort(),r=[...s].sort();for(let a=0;a<n.length;a++)if(n[a]!==r[a])return!0;return!1}function t3(t){const s={},n={},r=t.split(`
64
- `);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 b=d[1].length;o=o.slice(0,b-1),o[b-1]=d[2].trim();continue}if(!c.startsWith("|"))continue;const u=c.split("|").map(b=>b.trim());if(u.length<3)continue;const h=u[1].replace(/`/g,"").trim(),p=u[2].replace(/`/g,"").trim();if(!/^--[A-Za-z0-9_-]+$/.test(h)||!s3(p))continue;const f=o.filter(Boolean).join(" / "),m=Wb(f)?n:s;h in m||(m[h]=p)}return{light:s,dark:n}}function Wb(t){return/\bdark[\s-]?mode\b|\bdark\b\s*(palette|variant|theme)?/i.test(t)}function s3(t){return!!(/^#[0-9a-fA-F]{3,8}$/.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)||/^oklch\(/i.test(t))}const n3=["Background","Surface","Text","Primary","Secondary","Accent"],r3={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 a3(t){const s=[],n=t.split(`
65
- `);let r=!1,a="",o=0,i=null,c=[];for(let d=0;d<n.length;d++){const h=n[d].trim();if(!r){const p=/^(#{1,6})\s+(.+)$/.exec(h);if(p){const m=p[1].length;c=c.slice(0,m-1),c[m-1]=p[2].trim(),i=p[2].trim();continue}const f=/^```(\w*)/.exec(h);f&&(r=!0,a=f[1].toLowerCase(),o=d+1);continue}if(h==="```"){if(a==="css"||a===""){const p=n.slice(o,d).join(`
66
- `);for(const f of i3(p)){const m=c.filter(Boolean).join(" / "),b=o3(f.selector)||Wb(m);s.push({selector:f.selector,heading:i,isDark:b,vars:f.vars})}}r=!1,a=""}}return s}function o3(t){return/\[data-theme[~|*$^]?="?dark"?\]/.test(t)}function i3(t){const s=[],n=/(:root[^\{]*?)\{([\s\S]*?)\}/g;let r;for(;(r=n.exec(t))!==null;){const a=r[1].trim(),o=r[2],i={},c=/(--[A-Za-z0-9_-]+)\s*:\s*([^;\n]+?)\s*(?:;|$)/g;let d;for(;(d=c.exec(o))!==null;){const u=d[1],h=d[2].replace(/\/\*.*?\*\//g,"").trim();h&&(i[u]=h)}Object.keys(i).length>0&&s.push({selector:a,vars:i})}return s}function l3(t,s){const n=r3[s];for(const r of Object.keys(t))for(const a of n)if(a.test(r))return{cssVar:r,value:t[r]};return{cssVar:null,value:null}}function c3(t){const s=/\[data-palette[~|*$^]?="?([^"\]]+)"?\]/.exec(t);return s?s[1].split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):null}function d3(t){if(!t)return"Default";let s=t.replace(/\(.+?\)/g,"");return s=s.replace(/\bpalette\b/i,"").replace(/\bmode\b/i,""),/\bdark\b/i.test(s)?"Default":(s=s.replace(/\bdark\b/i,""),s=s.replace(/\blight\b/i,""),s=s.trim().replace(/\s+/g," "),s||"Default")}function gc(t){const s=n3.map(n=>{const{cssVar:r,value:a}=l3(t,n);return{label:n,cssVar:r,value:a}});return{vars:t,slots:s}}function $i(t){const s=a3(t),n=new Map,r=new Map,a=[];for(const o of s){const c=c3(o.selector)??d3(o.heading);a.includes(c)||a.push(c),o.isDark?r.has(c)||r.set(c,o.vars):n.has(c)||n.set(c,o.vars)}if(n.size===0){const o=t3(t);o.light&&Object.keys(o.light).length>0&&(a.unshift("Default"),n.set("Default",o.light),o.dark&&Object.keys(o.dark).length>0&&r.set("Default",o.dark))}return a.map(o=>{const i=n.get(o);if(!i)return null;const c=r.get(o)??null;return{name:o,light:gc(i),dark:c?gc(c):null}}).filter(o=>o!==null)}function u3(t){const s=Object.keys(t);if(s.length===0)return{};const n=Yb(t),r={};for(const a of s){const o=t[a];if(!o||!o.trim())continue;const i=n.get(a)??null;r[a]=m3(o,i)}return r}const Gb="#0f1115",h3="#181b21",Ub="#e8eaed";function p3(t){const s=Yb(t);let n=null,r=null;for(const[a,o]of s){const i=t[a];!i||!i.trim()||(o==="Background"&&n===null&&(n=i),o==="Text"&&r===null&&(r=i))}return{bg:n??Gb,text:r??Ub}}function Yb(t){var i;const n=["```css",":root {",Object.entries(t).map(([c,d])=>` ${c}: ${d};`).join(`
67
- `),"}","```"].join(`
68
- `),r=$i(n),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 m3(t,s){switch(s){case"Background":return Gb;case"Surface":return h3;case"Text":return Ub;case"Primary":case"Secondary":case"Accent":return bc(t);default:return bc(t)}}function bc(t){const s=f3(t.trim());if(!s)return t;const{h:n,s:r,l:a}=g3(s.r,s.g,s.b),{r:o,g:i,b:c}=b3(n,r,1-a),d=u=>u.toString(16).padStart(2,"0");return s.a!=null&&s.a<1?`rgba(${o}, ${i}, ${c}, ${s.a})`:`#${d(o)}${d(i)}${d(c)}`}function f3(t){const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(s){let r=s[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 n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(t);return n?{r:ka(parseInt(n[1],10)),g:ka(parseInt(n[2],10)),b:ka(parseInt(n[3],10)),a:n[4]!=null?parseFloat(n[4]):void 0}:null}function ka(t){return Math.max(0,Math.min(255,t))}function g3(t,s,n){const r=t/255,a=s/255,o=n/255,i=Math.max(r,a,o),c=Math.min(r,a,o),d=(i+c)/2;let u=0,h=0;if(i!==c){const p=i-c;switch(h=d>.5?p/(2-i-c):p/(i+c),i){case r:u=(a-o)/p+(a<o?6:0);break;case a:u=(o-r)/p+2;break;default:u=(r-a)/p+4;break}u/=6}return{h:u,s:h,l:d}}function b3(t,s,n){if(s===0){const i=Math.round(n*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=n<.5?n*(1+s):n+s-n*s,o=2*n-a;return{r:Math.round(r(o,a,t+1/3)*255),g:Math.round(r(o,a,t)*255),b:Math.round(r(o,a,t-1/3)*255)}}function x3(t){const[s,n]=l.useState({}),r=l.useRef(!0);return l.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),l.useEffect(()=>{if(!t)return;const a=new Set,o=t.map(i=>Yr(i.filename)).filter(i=>a.has(i)?!1:(a.add(i),!(i in s)));o.length!==0&&(async()=>{var i,c,d;for(const u of o)try{const h=await fetch(`/api/editor-design-systems/${u}`);if(!h.ok)continue;const p=await h.json().catch(()=>null);if(!(p!=null&&p.content)){r.current&&n(x=>({...x,[u]:null}));continue}const f=$i(p.content),m=((c=(i=f[0])==null?void 0:i.dark)==null?void 0:c.vars)??null,b=((d=f[0])==null?void 0:d.light.vars)??null,g=m&&Object.keys(m).length>0?m:b&&Object.keys(b).length>0?u3(b):null;r.current&&n(x=>({...x,[u]:g}))}catch{r.current&&n(h=>({...h,[u]:null}))}})()},[t,s]),s}function y3(){const[t,s]=l.useState([]);return l.useEffect(()=>{let n=!1;async function r(){try{const o=await fetch("/api/editor-mockups-history");if(!o.ok)return;const i=await o.json();n||s(Array.isArray(i)?i:[])}catch{}}r();const a=window.setInterval(r,4e3);return()=>{n=!0,window.clearInterval(a)}},[]),t}function Vb({round:t,onRestore:s,restoring:n=!1}){if(!t||!t.mockups||t.mockups.length===0)return e.jsx(zo,{});const r=t.feedback??{};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-md, 14px)"},children:[s&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",onClick:s,disabled:n,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:n?"default":"pointer",opacity:n?.6:1},children:n?"Bringing back…":"Bring back this round"})}),e.jsx("div",{"data-mockup-archived-round":!0,style:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:t.mockups.map((a,o)=>{const i=r[a.filename],c=o+1,d=a.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsxs("div",{style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)"},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(c).padStart(2,"0")}),e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{textTransform:"capitalize",fontWeight:500,color:"var(--text-primary)",textDecoration:"none"},children:d})]}),e.jsx("iframe",{src:a.url,title:a.name,sandbox:"",style:{width:"100%",aspectRatio:"1 / 1",border:"none",pointerEvents:"none",background:"var(--bg-card, #1a1a1a)"}}),i&&(typeof i.rating=="number"||i.comment.trim().length>0)&&e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",borderTop:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:4,fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[typeof i.rating=="number"&&e.jsxs("div",{children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Rating ·"," "]}),e.jsxs("span",{style:{color:"var(--text-primary)"},children:[i.rating,"/100"]})]}),i.comment.trim().length>0&&e.jsxs("div",{style:{lineHeight:1.4},children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Note ·"," "]}),e.jsx("span",{style:{color:"var(--text-primary)"},children:i.comment})]})]})]},a.filename)})})]})}const vI=Object.freeze(Object.defineProperty({__proto__:null,MockupArchivedRoundView:Vb},Symbol.toStringTag,{value:"Module"})),Bi=[{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]}],v3={sans:"Sans-serif",serif:"Serif",display:"Display",mono:"Monospace"};function Kb(t){const s=new Set,n=[];for(const r of t){if(!r||s.has(r))continue;s.add(r);const a=Bi.find(c=>c.family===r),o=(a==null?void 0:a.weights)??[400,700],i=r.replace(/ /g,"+");n.push(`family=${i}:wght@${o.join(";")}`)}return n.length===0?"":`https://fonts.googleapis.com/css2?${n.join("&")}&display=swap`}function j3(t,s,n){const r={},a=xc(t,n),o=xc(s,n),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 xc(t,s){return t?s==="dark"&&t.dark?t.dark.slots:t.light.slots:[]}function w3(t,s,n){var a,o;return s!=="dark"?n:{...((o=(a=t[0])==null?void 0:a.dark)==null?void 0:o.vars)??{},...n}}function _3(t,s){const[n,r]=l.useState({kind:"loading"});return l.useEffect(()=>{let a=!1;return r({kind:"loading"}),(async()=>{try{const[o,i]=await Promise.all([fetch(t),fetch(`/api/editor-design-systems/${s}`)]),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:$i(d)})}catch(o){a||r({kind:"error",message:o instanceof Error?o.message:String(o)})}})(),()=>{a=!0}},[t,s]),n}function Jb(t,s,n){l.useEffect(()=>{if(!t)return;const r=o=>{var c;const i=o.target;(c=s.current)!=null&&c.contains(i)||n()},a=o=>{o.key==="Escape"&&n()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",a)}},[t,s,n])}function Hn(t,s,n){return{name:t,light:yc(s),dark:n?yc(n):null}}function yc(t){const s=[{label:"Background",cssVar:"--bg-default",value:t.bg},{label:"Surface",cssVar:"--bg-surface",value:t.surface},{label:"Text",cssVar:"--text-primary",value:t.text},{label:"Primary",cssVar:"--accent-primary",value:t.primary},{label:"Secondary",cssVar:"--accent-secondary",value:t.secondary},{label:"Accent",cssVar:"--accent-highlight",value:t.accent}],n={};for(const r of s)r.cssVar&&r.value&&(n[r.cssVar]=r.value);return{vars:n,slots:s}}function k3(){return[Hn("Lime Bright",{bg:"#F4F4EE",surface:"#FFFFFF",text:"#0F0F0F",primary:"#D7FF63",secondary:"#9DA48F",accent:"#FF6B5C"},{bg:"#14160F",surface:"#25251F",text:"#F1EFEA",primary:"#D7FF63",secondary:"#4D5247",accent:"#FF6B5C"}),Hn("Warm Cream",{bg:"#EFE9DA",surface:"#F8F3E7",text:"#3B2F1C",primary:"#C44536",secondary:"#7A9E7E",accent:"#EAA64A"},{bg:"#1F1A11",surface:"#2A2418",text:"#EFE9DA",primary:"#E07767",secondary:"#A9CBA9",accent:"#EAA64A"}),Hn("Cool Mono",{bg:"#F5F6F8",surface:"#FFFFFF",text:"#101218",primary:"#2B2D3A",secondary:"#8B8FA3",accent:"#5C8DFF"},{bg:"#0E1016",surface:"#181B23",text:"#E9EBF2",primary:"#E9EBF2",secondary:"#8B8FA3",accent:"#7CA0FF"}),Hn("Bold Pop",{bg:"#FFF8F0",surface:"#FFFFFF",text:"#181818",primary:"#FF3D7F",secondary:"#3DD2FF",accent:"#FFD60A"},{bg:"#161113",surface:"#1F1A1D",text:"#FFF8F0",primary:"#FF3D7F",secondary:"#3DD2FF",accent:"#FFD60A"})]}function Xb({palettes:t,activeName:s,theme:n,onApply:r}){const a=(()=>{const o=new Set(t.map(c=>c.name.toLowerCase())),i=k3().filter(c=>!o.has(c.name.toLowerCase()));return[...t,...i]})();return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:a.map(o=>{const i=n==="dark"&&o.dark?o.dark:o.light,c=o.name===s;return e.jsx("button",{type:"button",onClick:()=>r(o),"aria-pressed":c,"aria-label":`Apply ${o.name} palette`,title:o.name,style:{padding:4,border:c?"2px solid var(--accent-active, #D7FF63)":"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-elevated)",cursor:"pointer"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 18px)",gridTemplateRows:"repeat(2, 18px)",gap:2},children:i.slots.map(d=>e.jsx("span",{title:d.label,style:{width:18,height:18,borderRadius:4,border:"1px solid var(--border-default)",background:d.value??"transparent"}},d.label))})},o.name)})})}const jI=Object.freeze(Object.defineProperty({__proto__:null,ColorPalettePicker:Xb},Symbol.toStringTag,{value:"Module"}));function Qb({slots:t,values:s,onChange:n}){return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:"8px 16px"},children:t.map(r=>{const a=!r.cssVar,o=r.cssVar?s[r.cssVar]??r.value??"":"",i=S3(o);return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"70px 1fr 80px",alignItems:"center",gap:6,opacity:a?.4:1,minWidth:0},children:[e.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-primary)",fontWeight:500},children:r.label}),e.jsx("input",{type:"color","aria-label":`${r.label} color`,disabled:a,value:i,onChange:c=>{r.cssVar&&n(r.cssVar,c.target.value)},style:{width:"100%",height:28,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-elevated)",cursor:a?"not-allowed":"pointer"}}),e.jsx("input",{type:"text","aria-label":`${r.label} hex`,disabled:a,value:o,onChange:c=>{r.cssVar&&n(r.cssVar,c.target.value)},spellCheck:!1,style:{padding:"4px 6px",fontSize:"var(--text-xs, 12px)",fontFamily:"var(--font-mono, monospace)",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-elevated)",color:"var(--text-primary)"}})]},r.label)})})}function S3(t){const s=t.trim();return/^#[0-9a-fA-F]{6}$/.test(s)?s.toLowerCase():/^#[0-9a-fA-F]{3}$/.test(s)?`#${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}`.toLowerCase():"#000000"}const wI=Object.freeze(Object.defineProperty({__proto__:null,ColorSwatchEditor:Qb},Symbol.toStringTag,{value:"Module"}));function oo({children:t}){return e.jsx("h4",{style:{margin:"0 0 8px",fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.08em"},children:t})}const _I=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePanelSectionHeading:oo},Symbol.toStringTag,{value:"Module"}));function Zb({palettes:t,activeName:s,theme:n,slots:r,vars:a,onApplyPalette:o,onColorChange:i}){return e.jsxs("div",{role:"menu",style:{padding:"var(--spacing-md, 12px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{children:[e.jsx(oo,{children:"Palettes"}),e.jsx(Xb,{palettes:t,activeName:s,theme:n,onApply:o})]}),e.jsxs("div",{children:[e.jsx(oo,{children:"Individual colors"}),e.jsx(Qb,{slots:r,values:a,onChange:i})]})]})}const kI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeColorsPanel:Zb},Symbol.toStringTag,{value:"Module"}));function ex({message:t}){return e.jsx("div",{style:{padding:"var(--spacing-md, 12px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:t})}const SI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeErrorBanner:ex},Symbol.toStringTag,{value:"Module"}));let vc=!1;function N3(){if(vc||typeof document>"u")return;vc=!0;const t=Kb(Bi.map(n=>n.family));if(!t)return;const s=document.createElement("link");s.rel="stylesheet",s.href=t,s.dataset.codeyamFontPreviews="1",document.head.appendChild(s)}function io({label:t,value:s,onChange:n,hint:r}){const[a,o]=l.useState(!1),i=l.useRef(null),c=l.useRef(null),d=l.useRef(null);l.useEffect(()=>{N3()},[]);const u=l.useCallback(()=>o(!1),[]);Jb(a,d,u);const h={sans:[],serif:[],display:[],mono:[]};for(const p of Bi)h[p.category].push(p);return e.jsxs("div",{ref:d,style:{display:"flex",flexDirection:"column",gap:4,fontSize:"var(--text-xs, 12px)",color:"var(--text-primary)",position:"relative"},children:[e.jsx("span",{style:{fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontSize:11,fontWeight:500,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)"},children:t}),r&&e.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},children:r}),e.jsxs("button",{ref:i,type:"button","aria-haspopup":"listbox","aria-expanded":a,onClick:()=>o(p=>!p),style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,padding:"6px 10px",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontFamily:s?`"${s}", system-ui, sans-serif`:"inherit",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{children:s??"System default"}),e.jsx("span",{"aria-hidden":!0,style:{opacity:.6},children:"▾"})]}),a&&e.jsxs("div",{ref:c,role:"listbox",style:{position:"absolute",top:"100%",left:0,right:0,marginTop:4,zIndex:20,background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",maxHeight:320,overflowY:"auto",padding:4},children:[e.jsx(lo,{family:null,label:"System default",isActive:s===null,onPick:()=>{n(null),o(!1)}}),Object.keys(h).map(p=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"6px 10px 2px",fontSize:"var(--text-xs, 11px)",color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:700},children:v3[p]}),h[p].map(f=>e.jsx(lo,{family:f.family,label:f.family,isActive:s===f.family,onPick:()=>{n(f.family),o(!1)}},f.family))]},p))]})]})}function lo({family:t,label:s,isActive:n,onPick:r}){return e.jsx("button",{type:"button",role:"option","aria-selected":n,onClick:r,style:{display:"block",width:"100%",padding:"8px 10px",background:n?"var(--bg-elevated)":"transparent",color:"var(--text-primary)",border:"none",borderRadius:4,fontSize:16,fontFamily:t?`"${t}", system-ui, sans-serif`:"inherit",textAlign:"left",cursor:"pointer"},children:s})}const NI=Object.freeze(Object.defineProperty({__proto__:null,FontOptionRow:lo,FontPicker:io},Symbol.toStringTag,{value:"Module"}));function tx({primaryFont:t,secondaryFont:s,onPrimaryChange:n,onSecondaryChange:r}){return e.jsxs("div",{role:"menu",style:{padding:"var(--spacing-md, 12px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-default)",display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsx(io,{label:"Headings",value:s,onChange:r}),e.jsx(io,{label:"Body text",value:t,onChange:n})]})}const CI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeFontsPanel:tx},Symbol.toStringTag,{value:"Module"}));function qi(t){const s=/<meta\b[^>]*>/gi;let n;for(;(n=s.exec(t))!==null;){const r=n[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 C3(t,s){const{vars:n,bg:r,text:a}=P3(s),o=Object.entries(n).filter(([,p])=>p&&p.trim());if(o.length===0)return t;const i=[`:root {
69
- `+o.map(([p,f])=>` ${p}: ${f};`).join(`
70
- `)+`
71
- }`,":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(`
72
- `)}</style>`;if(t.search(/<\/head\s*>/i)===-1)return`${c}
73
- ${t}`;const u=T3(t),h=u.search(/<\/head\s*>/i);return`${u.slice(0,h)}
74
- ${c}
75
- ${u.slice(h)}`}function P3(t){return t&&typeof t=="object"&&"vars"in t&&typeof t.vars=="object"?t:{vars:t}}function T3(t){const s=/<html\b([^>]*)>/i,n=s.exec(t);if(!n)return t;let r=n[1];/\bdata-theme\s*=/.test(r)||(r+=' data-theme="dark"');const a=/\bclass\s*=\s*("|')([\s\S]*?)\1/,o=a.exec(r);if(o){const i=o[2].split(/\s+/).filter(Boolean);if(!i.includes("dark")){const c=[...i,"dark"].join(" ");r=r.replace(a,`class=${o[1]}${c}${o[1]}`)}}else r+=' class="dark"';return t.replace(s,`<html${r}>`)}function sx({html:t,srcDoc:s,theme:n,mockupUrl:r,mockupName:a}){const o=qi(t)??"desktop",i=o==="mobile"||o==="tablet",c=o==="mobile"?390:o==="tablet"?834:null;return e.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:i?"#1a1a1a":"white",backgroundImage:i?"radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px)":void 0,backgroundSize:i?"12px 12px":void 0,display:"flex",justifyContent:"center"},children:e.jsx("iframe",{title:`Customize preview: ${a}`,srcDoc:s,sandbox:"",style:{width:i&&c?`${c}px`:"100%",height:"100%",minHeight:800,border:"none",background:"white",flexShrink:0}},`${r}-${n}`)})}const PI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePreviewArea:sx},Symbol.toStringTag,{value:"Module"}));function Hi({theme:t,onToggle:s,size:n=28}){return e.jsx("button",{type:"button",onClick:s,"aria-label":t==="light"?"Switch to dark mode":"Switch to light mode","aria-pressed":t==="dark",title:t==="light"?"Dark mode":"Light mode",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:n,height:n,background:"var(--bg-card, #1a1a1a)",border:"1px solid var(--border-default)",borderRadius:6,cursor:"pointer",color:"var(--text-primary)",padding:0,fontSize:14,lineHeight:1},children:t==="light"?"☾":"☀"})}const TI=Object.freeze(Object.defineProperty({__proto__:null,MockupCardThemeToggleButton:Hi},Symbol.toStringTag,{value:"Module"}));function Wn(t){return{height:28,padding:"0 8px",background:t?"#555":"#3a3a3a",color:t?"#ffffff":"#d1d5db",border:"none",borderRadius:4,fontSize:11,fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontWeight:400,letterSpacing:"0.04em",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4}}function nx({systemName:t,openMenu:s,theme:n,hasDark:r,saving:a,toolbarRef:o,onBack:i,onToggleMenu:c,onToggleTheme:d,onReset:u,onSave:h}){return e.jsxs("div",{ref:o,style:{display:"flex",alignItems:"center",gap:8,padding:"0 8px",height:40,borderBottom:"1px solid #3d3d3d",background:"#2d2d2d",flexWrap:"nowrap"},children:[e.jsx("button",{type:"button",onClick:i,"aria-label":"Back to mockups",style:{...Wn(!1),background:"transparent"},children:"← Back"}),e.jsxs("span",{style:{color:"#9ca3af",fontSize:13,fontFamily:"'IBM Plex Sans', system-ui, sans-serif",fontWeight:400,marginRight:4},children:["Customize: ",t]}),e.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":s==="fonts",onClick:()=>c("fonts"),style:Wn(s==="fonts"),children:["Fonts ",e.jsx("span",{"aria-hidden":!0,style:{opacity:.7},children:"▾"})]}),e.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":s==="colors",onClick:()=>c("colors"),style:Wn(s==="colors"),children:["Colors ",e.jsx("span",{"aria-hidden":!0,style:{opacity:.7},children:"▾"})]}),e.jsx("button",{type:"button",onClick:u,style:{...Wn(!1),background:"transparent",color:"#9ca3af"},children:"Reset"}),e.jsx("div",{style:{flex:1}}),r&&e.jsx(Hi,{theme:n,onToggle:d,size:28}),e.jsx("button",{type:"button",onClick:h,disabled:a,style:{height:28,padding:"0 10px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"none",borderRadius:4,fontSize:11,fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontWeight:500,letterSpacing:"0.04em",cursor:a?"wait":"pointer",opacity:a?.7:1},children:a?"SAVING…":"SAVE"})]})}const AI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeToolbar:nx},Symbol.toStringTag,{value:"Module"}));function rx({mockup:t,systemName:s,initial:n,onBack:r,onSave:a,saving:o=!1}){var T;const i=_3(t.url,s),[c,d]=l.useState(n),[u,h]=l.useState(null),[p,f]=l.useState("light"),[m,b]=l.useState(null),g=l.useRef(null),x=l.useCallback(()=>b(null),[]);Jb(m!==null,g,x);const y=l.useMemo(()=>{const O=[];return c.primaryFont&&O.push(c.primaryFont),c.secondaryFont&&O.push(c.secondaryFont),O.length===0?null:Kb(O)},[c.primaryFont,c.secondaryFont]),v=l.useMemo(()=>i.kind!=="ready"?c.vars:w3(i.palettes,p,c.vars),[i,c.vars,p]),j=l.useMemo(()=>i.kind!=="ready"?"":WC(i.html,{...c,vars:v,fontsHref:y}),[i,c,v,y]),w=l.useCallback(O=>{h(O.name);const k=i.kind==="ready"?i.palettes[0]:void 0,D=j3(k,O,p);d($=>({...$,vars:{...$.vars,...D}}))},[i,p]),_=l.useCallback((O,k)=>{h(null),d(D=>({...D,vars:{...D.vars,[O]:k}}))},[]),S=l.useCallback(()=>{d({vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null}),h(null)},[]),C=l.useMemo(()=>{if(i.kind!=="ready"||i.palettes.length===0)return[{label:"Background",cssVar:"--bg-default",value:null},{label:"Surface",cssVar:"--bg-surface",value:null},{label:"Text",cssVar:"--text-primary",value:null},{label:"Primary",cssVar:"--accent-primary",value:null},{label:"Secondary",cssVar:"--accent-secondary",value:null},{label:"Accent",cssVar:"--accent-highlight",value:null}];const O=i.palettes[0];return p==="dark"&&O.dark?O.dark.slots:O.light.slots},[i,p]),N=i.kind==="ready"&&!!((T=i.palettes[0])!=null&&T.dark);return e.jsxs("div",{"data-testid":"mockup-customize-view",className:"flex-1 flex flex-col min-w-0",style:{overflow:"hidden",position:"relative"},children:[e.jsxs("div",{ref:g,children:[e.jsx(nx,{systemName:s,openMenu:m,theme:p,hasDark:N,saving:o,toolbarRef:{current:null},onBack:()=>r(c),onToggleMenu:O=>b(k=>k===O?null:O),onToggleTheme:()=>f(O=>O==="light"?"dark":"light"),onReset:S,onSave:()=>a(c)}),m==="fonts"&&e.jsx(tx,{primaryFont:c.primaryFont,secondaryFont:c.secondaryFont,onPrimaryChange:O=>d(k=>({...k,primaryFont:O})),onSecondaryChange:O=>d(k=>({...k,secondaryFont:O}))}),m==="colors"&&e.jsx(Zb,{palettes:i.kind==="ready"?i.palettes:[],activeName:u,theme:p,slots:C,vars:c.vars,onApplyPalette:w,onColorChange:_})]}),i.kind==="error"&&e.jsx(ex,{message:i.message}),i.kind==="loading"?e.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"white",padding:"var(--spacing-lg, 16px)",color:"var(--text-secondary)"},children:"Loading mockup…"}):i.kind==="ready"?e.jsx(sx,{html:i.html,srcDoc:j,theme:p,mockupUrl:t.url,mockupName:t.name}):null]})}const OI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeView:rx},Symbol.toStringTag,{value:"Module"})),A3={desktop:{w:1440,h:900},tablet:{w:834,h:1112},mobile:{w:390,h:844}},jc="desktop",O3=1280,R3=1280,E3="#1a1a1a",M3="radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px)",I3="12px 12px";function D3(t,s,n,r){if(t<=0||s<=0||n<=0||r<=0)return{scale:0,offsetX:0,offsetY:0};const a=Math.min(t/n,s/r),o=n*a,i=r*a;return{scale:a,offsetX:Math.max(0,(t-o)/2),offsetY:Math.max(0,(s-i)/2)}}function ax(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M4.5 2.5h-2v7h7v-2"}),e.jsx("path",{d:"M7 2.5h2.5V5"}),e.jsx("path",{d:"M9.5 2.5L5.5 6.5"})]})}function ox({displayNumber:t,formattedName:s,theme:n,showThemeToggle:r,busy:a,openInNewTabUrl:o,onToggleTheme:i,onChoose:c,onCustomize:d}){return e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(t).padStart(2,"0")}),o?e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${s} in new tab`,title:"Open in new tab",onClick:u=>u.stopPropagation(),style:{display:"inline-flex",alignItems:"center",gap:4,minWidth:0,color:"var(--text-primary)",textDecoration:"none"},children:[e.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:"var(--text-muted)",lineHeight:1,flexShrink:0},children:e.jsx(ax,{})})]}):e.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-xs, 8px)",flexShrink:0},children:[r&&e.jsx(Hi,{theme:n,onToggle:i}),e.jsx("button",{type:"button",onClick:d,disabled:a,style:{padding:"6px 14px",background:"var(--bg-card, #1a1a1a)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:"var(--text-xs, 12px)",fontWeight:500,cursor:a?"wait":"pointer",opacity:a?.6:1},children:"Customize"}),e.jsx("button",{type:"button",onClick:c,disabled:a,style:{padding:"6px 14px",background:"var(--accent-active, #7c3aed)",color:"var(--text-on-accent, #fff)",border:"1px solid transparent",borderRadius:6,fontSize:"var(--text-xs, 12px)",fontWeight:600,cursor:a?"wait":"pointer",opacity:a?.6:1,boxShadow:a?"none":"0 0 0 3px color-mix(in srgb, var(--accent-active, #7c3aed) 30%, transparent), 0 2px 6px color-mix(in srgb, var(--accent-active, #7c3aed) 40%, transparent)"},children:"Select"})]})]})}const RI=Object.freeze(Object.defineProperty({__proto__:null,MockupCardFooter:ox,OpenInNewTabIcon:ax},Symbol.toStringTag,{value:"Module"})),L3=700;function F3({srcDoc:t,url:s,theme:n,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),L3);return()=>window.clearTimeout(m)},[t,s,n]);const h=()=>{const m=window.requestAnimationFrame(()=>{const b=window.requestAnimationFrame(()=>i(!0));u.current.push(b)});u.current.push(m)};l.useEffect(()=>()=>{u.current.forEach(m=>window.cancelAnimationFrame(m)),u.current=[]},[]);const p=o&&r>0;return{handleIframeLoad:h,visible:p,showSkeleton:!a||!p||!c}}function Qe({widthPct:t,heightPx:s,variant:n="surface"}){const r=n==="overlay"?"linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.12) 45%, rgba(255,255,255,0.04) 90%)":"linear-gradient(90deg, var(--bg-surface) 0%, var(--border-default) 45%, var(--bg-surface) 90%)";return e.jsx("div",{style:{width:`${t}%`,height:s,borderRadius:4,background:r,backgroundSize:"200% 100%",animation:"mockup-skeleton-shimmer 1.6s linear infinite",opacity:n==="surface"?.85:1}})}const EI=Object.freeze(Object.defineProperty({__proto__:null,SkeletonBar:Qe},Symbol.toStringTag,{value:"Module"}));function ix(){return e.jsxs("div",{"aria-label":"Loading mockup",style:{position:"absolute",inset:0,padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[e.jsx("style",{children:`
76
- @keyframes mockup-skeleton-shimmer {
77
- 0% { background-position: -200% 0; }
78
- 100% { background-position: 200% 0; }
79
- }
80
- `}),e.jsx(Qe,{widthPct:45,heightPx:14,variant:"overlay"}),e.jsx(Qe,{widthPct:70,heightPx:10,variant:"overlay"}),e.jsx("div",{style:{height:"6%"}}),e.jsx(Qe,{widthPct:100,heightPx:32,variant:"overlay"}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(Qe,{widthPct:48,heightPx:48,variant:"overlay"}),e.jsx(Qe,{widthPct:48,heightPx:48,variant:"overlay"})]}),e.jsx(Qe,{widthPct:88,heightPx:10,variant:"overlay"}),e.jsx(Qe,{widthPct:60,heightPx:10,variant:"overlay"})]})}const MI=Object.freeze(Object.defineProperty({__proto__:null,MockupSkeletonOverlay:ix},Symbol.toStringTag,{value:"Module"}));function Wi({html:t,url:s,title:n,viewport:r,theme:a,darkVars:o}){const i=l.useRef(null),[c,d]=l.useState(0),[u,h]=l.useState(0),p=A3[r];l.useEffect(()=>{const w=i.current;if(!w)return;const _=()=>{const C=w.clientWidth,N=w.clientHeight;C>0&&d(C),N>0&&h(N)};if(_(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(_);return S.observe(w),()=>S.disconnect()},[]);const{scale:f,offsetX:m,offsetY:b}=D3(c,u,p.w,p.h),g=t&&a==="dark"&&o?C3(t,{vars:o,...p3(o)}):t,{handleIframeLoad:x,visible:y,showSkeleton:v}=F3({srcDoc:g,url:s,theme:a,scale:f,hasContent:t!==null}),j=()=>window.open(s,"_blank","noopener,noreferrer");return e.jsxs("div",{ref:i,onClick:j,style:{position:"relative",width:"100%",aspectRatio:`${O3} / ${R3}`,overflow:"hidden",cursor:"pointer",backgroundColor:E3,backgroundImage:M3,backgroundSize:I3},children:[t!==null&&e.jsx("iframe",{src:g?void 0:s,srcDoc:g??void 0,title:n,sandbox:"",onLoad:x,style:{width:p.w,height:p.h,border:"none",background:"white",transform:f>0?`scale(${f})`:"scale(0)",transformOrigin:"top left",pointerEvents:"none",position:"absolute",top:b,left:m,visibility:y?"visible":"hidden"}},a),v&&e.jsx(ix,{})]})}const II=Object.freeze(Object.defineProperty({__proto__:null,MockupCardPreviewSlot:Wi},Symbol.toStringTag,{value:"Module"})),z3=`
81
- .mockup-feedback-slider {
82
- -webkit-appearance: none;
83
- appearance: none;
84
- background: transparent;
85
- height: 18px;
86
- padding: 0;
87
- margin: 0;
88
- cursor: pointer;
89
- }
90
- .mockup-feedback-slider:focus { outline: none; }
91
- .mockup-feedback-slider::-webkit-slider-runnable-track {
92
- height: 4px;
93
- background: #4a4a4a;
94
- border-radius: 2px;
95
- }
96
- .mockup-feedback-slider::-moz-range-track {
97
- height: 4px;
98
- background: #4a4a4a;
99
- border-radius: 2px;
100
- border: none;
101
- }
102
- .mockup-feedback-slider::-moz-range-progress {
103
- background: #4a4a4a;
104
- height: 4px;
105
- border-radius: 2px;
106
- }
107
- .mockup-feedback-slider::-webkit-slider-thumb {
108
- -webkit-appearance: none;
109
- appearance: none;
110
- width: 14px;
111
- height: 14px;
112
- border-radius: 50%;
113
- background: #5a5a5a;
114
- border: none;
115
- margin-top: -5px;
116
- cursor: pointer;
117
- transition: background 120ms ease;
118
- }
119
- .mockup-feedback-slider::-moz-range-thumb {
120
- width: 14px;
121
- height: 14px;
122
- border-radius: 50%;
123
- background: #5a5a5a;
124
- border: none;
125
- cursor: pointer;
126
- transition: background 120ms ease;
127
- }
128
- .mockup-feedback-slider[data-rated="true"]::-webkit-slider-runnable-track {
129
- /* Two stacked layers: a grey overlay that masks the right portion of
130
- * the track from progress% onward, and a full-width red-amber-keylime
131
- * rainbow underneath. The visible filled portion is the slice of the
132
- * rainbow up to the thumb position. */
133
- background:
134
- linear-gradient(
135
- to right,
136
- transparent 0%,
137
- transparent var(--mockup-feedback-progress, 0%),
138
- #4a4a4a var(--mockup-feedback-progress, 0%),
139
- #4a4a4a 100%
140
- ),
141
- linear-gradient(
142
- to right,
143
- rgb(239, 68, 68) 0%,
144
- rgb(251, 191, 36) 50%,
145
- rgb(215, 255, 99) 100%
146
- );
147
- }
148
- .mockup-feedback-slider[data-rated="true"]::-moz-range-track {
149
- background: linear-gradient(
150
- to right,
151
- rgb(239, 68, 68) 0%,
152
- rgb(251, 191, 36) 50%,
153
- rgb(215, 255, 99) 100%
154
- );
155
- }
156
- .mockup-feedback-slider[data-rated="true"]::-moz-range-progress {
157
- /* Firefox draws ::-moz-range-progress on top of ::-moz-range-track,
158
- * so the progress layer would otherwise hide the rainbow below it.
159
- * Leave it transparent so the rainbow shows through up to the value. */
160
- background: transparent;
161
- }
162
- .mockup-feedback-slider[data-rated="true"]::-webkit-slider-thumb {
163
- background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
164
- }
165
- .mockup-feedback-slider[data-rated="true"]::-moz-range-thumb {
166
- background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
167
- }
168
- `,$3=`
169
- .mockup-feedback-comment {
170
- width: 100%;
171
- padding: var(--spacing-sm, 8px) var(--spacing-sm, 10px);
172
- background: var(--bg-card, #1a1a1a);
173
- color: var(--text-primary);
174
- border: 1px solid var(--border-default);
175
- border-radius: 6px;
176
- font-size: var(--text-xs, 12px);
177
- line-height: 1.4;
178
- resize: vertical;
179
- box-sizing: border-box;
180
- min-height: 56px;
181
- outline: none;
182
- }
183
- .mockup-feedback-comment:focus,
184
- .mockup-feedback-comment:focus-visible {
185
- border-color: var(--text-primary, #ffffff);
186
- outline: none;
187
- box-shadow: 0 0 0 1px var(--text-primary, #ffffff);
188
- }
189
- `;function lx({comment:t,onCommentChange:s}){return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:$3}),e.jsx("textarea",{value:t,onChange:n=>s(n.target.value),placeholder:"What do you like or would like to change? (optional)",rows:3,className:"mockup-feedback-comment"})]})}const DI=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackCommentBox:lx},Symbol.toStringTag,{value:"Module"})),cx=[239,68,68],co=[251,191,36],dx=[215,255,99];function B3(t){const s=Math.max(1,Math.min(100,t));let n,r,a;s<=50?(n=cx,r=co,a=(s-1)/49):(n=co,r=dx,a=(s-50)/50);const o=Math.round(n[0]+(r[0]-n[0])*a),i=Math.round(n[1]+(r[1]-n[1])*a),c=Math.round(n[2]+(r[2]-n[2])*a);return`rgb(${o}, ${i}, ${c})`}`${cx.join(", ")}${co.join(", ")}${dx.join(", ")}`;function ux(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3z"}),e.jsx("path",{d:"M17 2h2.5a2.5 2.5 0 0 1 2.5 2.5v6A2.5 2.5 0 0 1 19.5 13H17"})]})}function hx(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3z"}),e.jsx("path",{d:"M7 22H4.5a2.5 2.5 0 0 1-2.5-2.5v-6A2.5 2.5 0 0 1 4.5 11H7"})]})}const LI=Object.freeze(Object.defineProperty({__proto__:null,ThumbDownIcon:ux,ThumbUpIcon:hx},Symbol.toStringTag,{value:"Module"}));function px({rating:t,onRatingChange:s}){const n=t!=null,r=n&&t<=33,a=n&&t>=67;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-sm, 10px)"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:r?"var(--text-primary)":"var(--text-muted)",display:"inline-flex",alignItems:"center"},children:e.jsx(ux,{})}),e.jsx("input",{type:"range",min:1,max:100,step:1,value:t??50,onPointerDown:()=>{n||s(50)},onChange:o=>s(Number(o.target.value)),"aria-label":"Rate this mockup from 1 to 100",className:"mockup-feedback-slider","data-rated":n?"true":"false",style:{flex:1,"--mockup-feedback-progress":`${t??0}%`,"--mockup-feedback-color":n?B3(t):"var(--accent-active, #D7FF63)"}}),e.jsx("span",{"aria-hidden":"true",style:{color:a?"var(--text-primary)":"var(--text-muted)",display:"inline-flex",alignItems:"center"},children:e.jsx(hx,{})})]})}const FI=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackRatingSlider:px},Symbol.toStringTag,{value:"Module"})),mx={rating:null,comment:""};function fx({value:t,onChange:s}){return e.jsxs("div",{"data-mockup-feedback":!0,style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",borderTop:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 10px)",background:"var(--bg-surface)"},children:[e.jsx("style",{children:z3}),e.jsx(px,{rating:t.rating,onRatingChange:n=>s({...t,rating:n})}),e.jsx(lx,{comment:t.comment,onCommentChange:n=>s({...t,comment:n})})]})}const zI=Object.freeze(Object.defineProperty({__proto__:null,EMPTY_FEEDBACK:mx,MockupCardFeedback:fx},Symbol.toStringTag,{value:"Module"}));function gx({mockup:t,displayNumber:s,onChoose:n,onCustomize:r,busy:a=!1,darkVars:o=null,feedback:i,onFeedbackChange:c}){const[d,u]=l.useState(null),[h,p]=l.useState(jc),[f,m]=l.useState("light");if(l.useEffect(()=>{if(!t)return;let g=!1;return(async()=>{try{const x=await fetch(t.url);if(!x.ok)return;const y=await x.text();if(g)return;u(y),p(qi(y)??jc)}catch{}})(),()=>{g=!0}},[t==null?void 0:t.url]),!t)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:160,border:"1px dashed var(--border-default)",borderRadius:12,background:"var(--bg-surface)",color:"var(--text-muted)",fontSize:"var(--text-sm, 14px)"},children:"No mockup to preview"});const b=t.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsx(ox,{displayNumber:s,formattedName:b,theme:f,showThemeToggle:!!o,busy:a,openInNewTabUrl:t.url,onToggleTheme:()=>m(g=>g==="light"?"dark":"light"),onChoose:()=>n==null?void 0:n(t),onCustomize:()=>r==null?void 0:r(t)}),e.jsx(Wi,{html:d,url:t.url,title:t.name,viewport:h,theme:f,darkVars:o}),c&&e.jsx(fx,{value:i??mx,onChange:c})]})}const $I=Object.freeze(Object.defineProperty({__proto__:null,MockupCard:gx},Symbol.toStringTag,{value:"Module"}));function bx({displayNumber:t}){return e.jsxs("div",{"data-mockup-placeholder":!0,"aria-label":"The AI is designing this mockup",style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsx("style",{children:`
190
- @keyframes mockup-skeleton-shimmer {
191
- 0% { background-position: -200% 0; }
192
- 100% { background-position: 200% 0; }
193
- }
194
- `}),e.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"1 / 1",overflow:"hidden",background:"var(--bg-elevated, #141414)",padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[e.jsx(Qe,{widthPct:45,heightPx:14}),e.jsx(Qe,{widthPct:70,heightPx:10}),e.jsx("div",{style:{height:"6%"}}),e.jsx(Qe,{widthPct:100,heightPx:32}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(Qe,{widthPct:48,heightPx:48}),e.jsx(Qe,{widthPct:48,heightPx:48})]}),e.jsx(Qe,{widthPct:88,heightPx:10}),e.jsx(Qe,{widthPct:60,heightPx:10})]}),e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",display:"flex",alignItems:"center",gap:"var(--spacing-sm, 8px)"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(t).padStart(2,"0")}),e.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},"data-testid":"mockup-placeholder-label",children:"The AI is designing this mockup…"})]})})]})}const BI=Object.freeze(Object.defineProperty({__proto__:null,MockupPlaceholderCard:bx},Symbol.toStringTag,{value:"Module"}));function xx({slots:t,darkVarsBySystem:s,busyFilename:n,feedbackByFilename:r,onFeedbackChange:a,onChoose:o,onCustomize:i}){return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:t.map(c=>c.mockup?e.jsx(gx,{mockup:c.mockup,displayNumber:c.number,onChoose:o,onCustomize:i,busy:n===c.mockup.filename,darkVars:s[Yr(c.mockup.filename)]??null,feedback:r==null?void 0:r[c.mockup.filename],onFeedbackChange:a?d=>a(c.mockup.filename,d):void 0},`mockup-${c.mockup.filename}`):e.jsx(bx,{displayNumber:c.number},`placeholder-${c.number}`))})}const qI=Object.freeze(Object.defineProperty({__proto__:null,MockupGrid:xx},Symbol.toStringTag,{value:"Module"}));function yx(){return e.jsxs("div",{"data-mockup-generating-overlay":!0,style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"var(--spacing-md, 14px)",zIndex:5,background:"var(--bg-overlay, rgba(15,17,21,0.45))",backdropFilter:"blur(1px)",borderRadius:12,pointerEvents:"auto"},children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}),e.jsx("div",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:500},children:"Generating new designs…"})]})}const HI=Object.freeze(Object.defineProperty({__proto__:null,MockupGridGeneratingOverlay:yx},Symbol.toStringTag,{value:"Module"}));function vx(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M9 18h6"}),e.jsx("path",{d:"M10 22h4"}),e.jsx("path",{d:"M12 2a7 7 0 0 0-4 12.74V17a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.26A7 7 0 0 0 12 2z"})]})}function jx(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}function wx({onDismiss:t}){return e.jsxs("div",{role:"note","data-mockup-info-banner":!0,style:{display:"flex",alignItems:"flex-start",gap:"var(--spacing-md, 14px)",padding:"var(--spacing-md, 14px) var(--spacing-md, 16px)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:12,background:"rgba(215, 255, 99, 0.04)"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0,paddingTop:1},children:e.jsx(vx,{})}),e.jsxs("p",{style:{flex:1,margin:0,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5},children:[e.jsx("strong",{style:{fontWeight:700},children:"Not sure which to pick?"})," ","Rate these designs and jot a quick note. We'll refine them into a fresh round — no need to choose yet."]}),e.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss tip",title:"Dismiss",style:{flexShrink:0,padding:4,background:"transparent",color:"var(--text-muted)",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx(jx,{})})]})}const WI=Object.freeze(Object.defineProperty({__proto__:null,CloseIcon:jx,LightbulbIcon:vx,MockupGridInfoBanner:wx},Symbol.toStringTag,{value:"Module"}));function _x(){return e.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-3.36-7"}),e.jsx("polyline",{points:"21 4 21 10 15 10"})]})}function kx({feedbackCount:t,busy:s,onIterate:n}){const r=t===0?"Add a rating or note above, then iterate.":t===1?"1 card has feedback — iterate to refresh the round.":`${t} cards have feedback — iterate to refresh the round.`;return e.jsxs("div",{style:{marginTop:"var(--spacing-md, 12px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-md, 16px)",padding:"var(--spacing-md, 16px) var(--spacing-lg, 20px)",border:"1px solid var(--border-default)",borderRadius:12,background:"var(--bg-card, #1a1a1a)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 14px)",minWidth:0},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0},children:e.jsx(_x,{})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.jsx("span",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:600,lineHeight:1.3},children:"Ready for the next round?"}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"var(--text-xs, 12px)",lineHeight:1.4,marginTop:2},children:r})]})]}),e.jsx("button",{type:"button",onClick:n,disabled:s,"data-mockup-iterate":!0,style:{flexShrink:0,padding:"10px 22px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:8,fontSize:"var(--text-sm, 14px)",fontWeight:600,cursor:s?"wait":"pointer",opacity:s?.6:1},children:s?"Sending…":"Iterate"})]})}const GI=Object.freeze(Object.defineProperty({__proto__:null,MockupGridIterateButton:kx,RefreshCycleIcon:_x},Symbol.toStringTag,{value:"Module"}));function Sx(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}function Nx(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Cx({archivedRoundsNewestFirst:t,selected:s,onSelect:n}){if(!t||t.length===0)return null;const a=[...[...t].reverse(),"current"],o=a.length,i=a.indexOf(s),c=i===-1?o-1:i,d=s==="current",u=c>0,h=c<o-1,p=d?`Round ${o} of ${o} · Current`:`Round ${c+1} of ${o} · Archived`;return e.jsxs("div",{"data-mockup-round-pager":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-sm, 10px)",padding:"var(--spacing-xs, 6px) var(--spacing-md, 14px)",border:"1px solid var(--border-default)",borderRadius:10,background:"var(--bg-card, #1a1a1a)"},children:[e.jsx(uo,{ariaLabel:"Previous round",disabled:!u,onClick:()=>u&&n(a[c-1]),icon:e.jsx(Sx,{})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)"},children:p}),!d&&e.jsx("button",{type:"button",onClick:()=>n("current"),style:{padding:"4px 10px",background:"transparent",color:"var(--accent-active, #D7FF63)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:6,fontSize:"var(--text-xs, 11px)",fontWeight:500,cursor:"pointer"},children:"Return to current"})]}),e.jsx(uo,{ariaLabel:"Next round",disabled:!h,onClick:()=>h&&n(a[c+1]),icon:e.jsx(Nx,{})})]})}function uo({ariaLabel:t,disabled:s,onClick:n,icon:r}){return e.jsx("button",{type:"button",onClick:n,disabled:s,"aria-label":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,background:"transparent",color:s?"var(--text-dim, #666)":"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,cursor:s?"default":"pointer",opacity:s?.5:1,padding:0},children:r})}const UI=Object.freeze(Object.defineProperty({__proto__:null,ChevronLeftIcon:Sx,ChevronRightIcon:Nx,MockupRoundPager:Cx,PagerArrowButton:uo},Symbol.toStringTag,{value:"Module"}));function Px({mockup:t,busy:s,onCancel:n,onConfirm:r}){l.useEffect(()=>{const o=i=>{i.key==="Escape"&&!s&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[s,n]);const a=t.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.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:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Ready to start building?",onClick:o=>o.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(440px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"hidden",aspectRatio:"16 / 9",background:"#1a1a1a",position:"relative"},children:e.jsx("iframe",{src:t.url,title:`${a} thumbnail`,sandbox:"",style:{width:1440,height:900,border:"none",background:"white",transform:"scale(0.305)",transformOrigin:"top left",pointerEvents:"none",position:"absolute",top:0,left:0}})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Ready to start building?"}),e.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13,textTransform:"capitalize"},children:["Using ",e.jsx("strong",{style:{color:"var(--text-primary)"},children:a})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:n,disabled:s,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:s?"wait":"pointer",opacity:s?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:r,disabled:s,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:s?"wait":"pointer",opacity:s?.7:1,fontFamily:"inherit"},children:s?"Starting…":"Start building"})]})]})})}const YI=Object.freeze(Object.defineProperty({__proto__:null,StartBuildingConfirmModal:Px},Symbol.toStringTag,{value:"Module"}));function As(t,s){if(!s)return t;const n=t.includes("?")?"&":"?";return`${t}${n}round=${encodeURIComponent(s)}`}function Tx({onDesignConfirmed:t,round:s}={}){const[n,r]=l.useState(null),[a,o]=l.useState(null),[i,c]=l.useState(null),[d,u]=l.useState(null),[h,p]=l.useState(null),[f,m]=l.useState(null),[b,g]=l.useState({}),[x,y]=l.useState({}),[v,j]=l.useState(!1),[w,_]=l.useState(!1),S=l.useRef([]),C=l.useRef(!1),N=l.useRef(!1),[T,O]=l.useState(null),[k,D]=l.useState(()=>typeof window>"u"?!1:window.sessionStorage.getItem("mockup-grid-tip-dismissed")==="1"),[$,B]=l.useState("current"),q=y3(),P=l.useRef(null),E=x3(n),A=l.useRef(!0),H=l.useCallback(async()=>{try{const[L,I]=await Promise.all([fetch(As("/api/editor-mockups",s)),fetch(As("/api/editor-mockups-target",s))]),F=await L.json(),te=await I.json();A.current&&(r(W=>UC(W,F)||C.current&&F.length<S.current.length?W:F),o(W=>W===te.count?W:te.count))}catch(L){A.current&&c(L instanceof Error?L.message:String(L))}},[s]);l.useEffect(()=>{A.current=!0,H();const L=window.setInterval(H,4e3);return()=>{A.current=!1,window.clearInterval(L)}},[H]),l.useEffect(()=>{let L=!1;return(async()=>{try{const I=await fetch(As("/api/editor-mockups-feedback",s));if(!I.ok)return;const F=await I.json();if(L||!F||typeof F!="object"||Array.isArray(F))return;const te={};for(const[W,Y]of Object.entries(F)){if(!Y||typeof Y!="object")continue;const V=Y;V.rating!=null&&typeof V.rating!="number"||V.comment!=null&&typeof V.comment!="string"||(te[W]={rating:typeof V.rating=="number"?V.rating:null,comment:typeof V.comment=="string"?V.comment:""})}y(te)}catch{}})(),()=>{L=!0}},[]);const z=l.useCallback((L,I)=>{y(F=>{const te={...F,[L]:I};return P.current!=null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{fetch(As("/api/editor-mockups-feedback",s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)}).catch(()=>{})},400),te})},[s]);l.useEffect(()=>()=>{P.current!=null&&window.clearTimeout(P.current)},[]);const G=l.useCallback(()=>{if(!n)return;const L=n.map(F=>F.filename);S.current=L,N.current=!1,_(!1),j(!0),B("current");const I=XC({feedbackByFilename:x,mockupFilenames:L});(async()=>{try{await fetch("/api/editor-mockups-archive",{method:"POST"})}catch{}await KC(I),A.current&&(N.current=!0,y({}),fetch(As("/api/editor-mockups-feedback",s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).catch(()=>{}))})()},[x,n,s]);l.useEffect(()=>{C.current=v},[v]),l.useEffect(()=>{if(!v)return;const L=()=>{N.current&&_(!0)};return window.addEventListener("miniagent-output",L),()=>window.removeEventListener("miniagent-output",L)},[v]),l.useEffect(()=>{if(!v)return;const L=window.setTimeout(()=>{A.current&&j(!1)},QC);return()=>window.clearTimeout(L)},[v]),l.useEffect(()=>{v&&ZC({snapshotFilenames:S.current,latestFilenames:(n??[]).map(L=>L.filename),agentRespondedAfterDispatch:w})&&j(!1)},[v,n,w]);const Q=l.useCallback(async L=>{O(L);try{const I=await fetch("/api/editor-mockups-restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({round:L})});if(!I.ok){const F=await I.text().catch(()=>`${I.status}`);throw new Error(F||`restore failed: ${I.status}`)}A.current&&(B("current"),H())}catch(I){A.current&&c(I instanceof Error?I.message:String(I))}finally{A.current&&O(null)}},[H]),se=l.useCallback(L=>{m(L)},[]),le=l.useCallback(async()=>{if(!f)return;const L=f;u(L.filename);try{const I=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:L.filename})});if(!I.ok){const F=await I.text().catch(()=>`${I.status}`);throw new Error(F||`select failed: ${I.status}`)}A.current&&(m(null),t==null||t({kind:"use",filename:L.filename}))}catch(I){c(I instanceof Error?I.message:String(I))}finally{A.current&&u(null)}},[f,t]),re=l.useCallback(L=>{const I=Yr(L.filename);p({mockup:L,systemName:I})},[]),U=l.useCallback(L=>{h&&g(I=>({...I,[h.mockup.filename]:L})),p(null)},[h]),ge=l.useCallback(async L=>{if(h){u(h.mockup.filename);try{const I=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:h.mockup.filename,overrides:{vars:L.vars,primaryFont:L.primaryFont,secondaryFont:L.secondaryFont}})});if(!I.ok){const F=await I.text().catch(()=>`${I.status}`);throw new Error(F||`select failed: ${I.status}`)}g(F=>({...F,[h.mockup.filename]:L})),p(null),t==null||t({kind:"use",filename:h.mockup.filename})}catch(I){c(I instanceof Error?I.message:String(I))}finally{A.current&&u(null)}}},[h,t]);if(h)return e.jsx(rx,{mockup:h.mockup,systemName:h.systemName,initial:b[h.mockup.filename]??GC,onBack:U,onSave:ge,saving:d===h.mockup.filename});if(!n)return e.jsx("div",{style:{padding:"var(--spacing-lg, 16px)"},children:e.jsx("div",{style:{color:"var(--text-secondary)"},children:"Loading design mockups…"})});const ie=n.reduce((L,I)=>{const F=/^(\d{1,2})-/.exec(I.filename);return F?Math.max(L,parseInt(F[1],10)):L},0),be=Math.max(a??0,ie);if(be===0)return e.jsx(zo,{});const K=Array.from({length:be},(L,I)=>{const F=I+1,te=String(F).padStart(2,"0"),W=n.find(Y=>Y.filename.startsWith(`${te}-`))??null;return{number:F,mockup:W}});return e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{padding:"var(--spacing-lg, 16px)",gap:"var(--spacing-md, 12px)",overflow:"auto"},children:[!k&&e.jsx(wx,{onDismiss:()=>{D(!0),typeof window<"u"&&window.sessionStorage.setItem("mockup-grid-tip-dismissed","1")}}),e.jsx(Cx,{archivedRoundsNewestFirst:q.map(L=>L.round),selected:$,onSelect:B}),i&&e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderRadius:8,background:"var(--bg-danger-soft, rgba(248,113,113,0.12))",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:i}),$==="current"?e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[e.jsxs("div",{style:v?{opacity:.4,pointerEvents:"none"}:void 0,children:[e.jsx(xx,{slots:K,darkVarsBySystem:E,busyFilename:d,feedbackByFilename:x,onFeedbackChange:z,onChoose:se,onCustomize:re}),n.length>0&&e.jsx("div",{style:{marginTop:"var(--spacing-md, 12px)"},children:e.jsx(kx,{feedbackCount:Object.values(x).filter(L=>typeof L.rating=="number"||L.comment.trim().length>0).length,busy:v,onIterate:G})})]}),v&&e.jsx(yx,{})]}):(()=>{const L=q.find(I=>I.round===$);return L?e.jsx(Vb,{round:L,onRestore:()=>Q(L.round),restoring:T===L.round}):e.jsx("div",{style:{padding:"var(--spacing-md, 14px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:"Loading archived round…"})})(),f&&e.jsx(Px,{mockup:f,busy:d===f.filename,onCancel:()=>m(null),onConfirm:le})]})}const VI=Object.freeze(Object.defineProperty({__proto__:null,DesignExplorationView:Tx,systemNameFromFilename:Yr,withRoundParam:As},Symbol.toStringTag,{value:"Module"}));function Ax({onDesignConfirmed:t}){const[s,n]=l.useState("assets"),r=l.useRef(!0),a=l.useRef(0);return l.useEffect(()=>{r.current=!0;const o=async()=>{try{const d=await(await fetch("/api/editor-design-active-tab")).json();if(!r.current)return;d.tab!==null&&d.nonce!==null&&d.nonce>a.current&&(a.current=d.nonce,n(d.tab))}catch{}};o();const i=window.setInterval(o,4e3);return()=>{r.current=!1,window.clearInterval(i)}},[]),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderBottom:"1px solid var(--border-default)"},children:[{id:"assets",label:"Add assets"},{id:"mockups",label:"Mockups"}].map(({id:o,label:i})=>{const c=s===o;return e.jsx("button",{type:"button",role:"tab","aria-selected":c,onClick:()=>n(o),style:{padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,border:"none",cursor:"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:500,background:c?"var(--accent-active)":"transparent",color:c?"var(--text-on-accent, white)":"var(--text-secondary)"},children:i},o)})}),s==="assets"?e.jsx(Hb,{}):e.jsx(Tx,{onDesignConfirmed:t})]})}const KI=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPreviewPane:Ax},Symbol.toStringTag,{value:"Module"}));function Ox({deviceLabel:t,actions:s}){return e.jsxs("div",{role:"note",className:"flex items-center gap-2 border-b border-l-4 px-3 py-2 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("rect",{x:"3",y:"4",width:"7",height:"16",rx:"1"}),e.jsx("rect",{x:"14",y:"4",width:"7",height:"16",rx:"1"}),e.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22",strokeDasharray:"2 2"})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"font-semibold",children:"Live mirror — not interactive."})," ",e.jsxs("span",{style:{color:"var(--text-dim)"},children:["Tap and type directly in the ",t," window."]})]}),s?e.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:s}):null]})}const JI=Object.freeze(Object.defineProperty({__proto__:null,NativeMirrorNotice:Ox},Symbol.toStringTag,{value:"Module"}));function Rx({isCollapsed:t,onToggle:s}){return e.jsx("button",{onClick:s,className:`p-1.5 rounded transition-colors cursor-pointer ${t?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:t?"Show editor":"Hide editor",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 17l5-5-5-5"}),e.jsx("path",{d:"M6 17l5-5-5-5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 17l-5-5 5-5"}),e.jsx("path",{d:"M18 17l-5-5 5-5"})]})})})}const XI=Object.freeze(Object.defineProperty({__proto__:null,CollapseToggleButton:Rx},Symbol.toStringTag,{value:"Module"}));function ho({label:t,value:s,disabled:n,onCommit:r}){const[a,o]=l.useState(String(s));l.useEffect(()=>{o(String(s))},[s]);const i=()=>{const c=Number.parseInt(a,10);if(!Number.isFinite(c)||c<=0){o(String(s));return}c!==s&&r(c)};return e.jsxs("label",{className:`flex items-center gap-0.5 px-1 py-0.5 rounded bg-[#2A2929] text-xs ${n?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 select-none",children:t}),e.jsx("input",{type:"text",inputMode:"numeric",value:a,disabled:n,"aria-label":t==="H"?"Height":"Width",onChange:c=>o(c.target.value.replace(/[^0-9]/g,"")),onBlur:i,onKeyDown:c=>{c.key==="Enter"?(i(),c.target.blur()):c.key==="Escape"&&(o(String(s)),c.target.blur())},className:"w-8 bg-transparent text-gray-200 text-center text-[11px] font-mono focus:outline-none disabled:cursor-not-allowed [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})]})}const QI=Object.freeze(Object.defineProperty({__proto__:null,DimensionInput:ho},Symbol.toStringTag,{value:"Module"}));function Ex({isFilled:t,onToggle:s}){return e.jsx("button",{onClick:s,className:`p-1.5 rounded transition-colors cursor-pointer ${t?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:t?"Exit fullscreen":"Fill page with preview",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t?e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})}const ZI=Object.freeze(Object.defineProperty({__proto__:null,FillPreviewButton:Ex},Symbol.toStringTag,{value:"Module"}));function Mx({previewUrl:t}){return e.jsx("button",{onClick:()=>{t&&window.open(t,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})}const e8=Object.freeze(Object.defineProperty({__proto__:null,OpenInNewTabButton:Mx},Symbol.toStringTag,{value:"Module"})),po=new Set;function q3(t){return po.add(t),()=>{po.delete(t)}}function H3(){for(const t of po)t()}function Ix(){return e.jsx("button",{onClick:()=>H3(),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Refresh preview","aria-label":"Refresh preview",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("polyline",{points:"1 20 1 14 7 14"}),e.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})})}const t8=Object.freeze(Object.defineProperty({__proto__:null,RefreshPreviewButton:Ix},Symbol.toStringTag,{value:"Module"}));function wc(t){var n;return t.route==="Uncategorized"?2:t.route.startsWith("/isolated-components/")||((n=t.scenarios[0])==null?void 0:n.scenarioType)==="component"?1:0}function Dx(t){const s=new Map;for(const n of t){const r=n.url??"Uncategorized",a=s.get(r)??[];a.push(n),s.set(r,a)}return Array.from(s.entries()).map(([n,r])=>({route:n,scenarios:r})).sort((n,r)=>{const a=wc(n)-wc(r);return a!==0?a:n.route.localeCompare(r.route)})}function W3(t,s){const n=s.trim().toLowerCase();return n?t.filter(r=>{const a=(r.url??"").toLowerCase(),o=r.name.toLowerCase(),i=(r.componentName??"").toLowerCase();return a.includes(n)||o.includes(n)||i.includes(n)}):t}function Lx({tab:t,hasQuery:s}){return s?e.jsx("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:"No matches for your search."}):e.jsxs("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:["No ",t==="pages"?"pages":"components"," yet."]})}const s8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerEmptyMessage:Lx},Symbol.toStringTag,{value:"Module"}));function Fx({scenario:t,active:s,onClick:n}){const r=t.screenshotPaths[0],a=wr(t);return e.jsxs("button",{onClick:n,className:`w-32 text-left rounded border transition-colors cursor-pointer ${s?"border-[#007a99] bg-[#1a2a30]":"border-[#3d3d3d] bg-[#1a1a1a] hover:border-[#555]"}`,title:t.name,children:[e.jsx("div",{className:"aspect-[4/3] w-full overflow-hidden rounded-t border-b border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:r?e.jsx("img",{src:ns(r),alt:t.name,className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-[10px] text-gray-600",children:"No screenshot"})}),e.jsx("div",{className:"px-2 py-1 text-[11px] text-gray-200 truncate",children:a})]})}const n8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerScenarioThumbnail:Fx},Symbol.toStringTag,{value:"Module"}));function zx({group:t,currentSlug:s,onSelect:n}){const r=t.scenarios[0]?ad(t.scenarios[0]):null;return e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 mb-1.5 px-1",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-200 truncate",children:r??t.route}),r?e.jsx("span",{className:"text-[10px] text-gray-500 font-mono truncate",children:t.route}):null]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.scenarios.map(a=>e.jsx(Fx,{scenario:a,active:a.slug===s,onClick:()=>n(a.slug)},a.slug))})]})}const r8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerRouteSection:zx},Symbol.toStringTag,{value:"Module"}));function mo({label:t,active:s,count:n,onClick:r}){return e.jsxs("button",{onClick:r,className:`flex items-center gap-1.5 px-2 py-1 rounded text-[10px] font-semibold tracking-wider cursor-pointer transition-colors ${s?"text-white bg-[#3a3a3a]":"text-gray-500 hover:text-gray-300"}`,children:[t,e.jsx("span",{className:`text-[10px] font-mono px-1 rounded ${s?"bg-[#555] text-gray-200":"bg-[#2a2a2a] text-gray-500"}`,children:n})]})}const a8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerTabButton:mo},Symbol.toStringTag,{value:"Module"}));function $x({scenarioGroups:t,currentSlug:s,onSelect:n,onClose:r,triggerRef:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(""),u=l.useRef(null),h=l.useRef(null);l.useEffect(()=>{var y;(y=h.current)==null||y.focus()},[]),ui(u,r,a);const p=l.useMemo(()=>t.flatMap(y=>y.scenarios),[t]),f=l.useMemo(()=>W3(p,c),[p,c]),m=l.useMemo(()=>f.filter(yr),[f]),b=l.useMemo(()=>f.filter(wo),[f]),g=o==="pages"?m:b,x=l.useMemo(()=>Dx(g),[g]);return e.jsxs("div",{ref:u,className:"absolute top-full left-0 mt-1 bg-[#222] border border-[#3d3d3d] rounded-lg shadow-2xl z-50 w-[560px] max-h-[480px] flex flex-col",role:"dialog",children:[e.jsxs("div",{className:"flex items-center border-b border-[#3d3d3d] px-2 py-1.5 gap-2",children:[e.jsx(mo,{label:"PAGES",active:o==="pages",count:m.length,onClick:()=>i("pages")}),e.jsx(mo,{label:"COMPONENTS",active:o==="components",count:b.length,onClick:()=>i("components")}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{ref:h,value:c,onChange:y=>d(y.target.value),placeholder:"Search…",className:"w-48 px-2 py-1 text-xs bg-[#1a1a1a] border border-[#3d3d3d] rounded text-gray-200 focus:outline-none focus:border-[#007a99]"}),e.jsx("button",{onClick:r,"aria-label":"Close",className:"p-1 text-gray-500 hover:text-gray-200 cursor-pointer",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"overflow-y-auto p-3 flex-1 min-h-0",children:x.length===0?e.jsx(Lx,{tab:o,hasQuery:c.trim().length>0}):x.map(y=>e.jsx(zx,{group:y,currentSlug:s,onSelect:v=>{n(v),r()}},y.route))})]})}const o8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerDropdown:$x},Symbol.toStringTag,{value:"Module"}));function Bx(){return e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.jsx("path",{d:"M14 3v6h6"})]})}function qx(){return e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]})}function Gi({className:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:t??"opacity-70 shrink-0 text-gray-400",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}const i8=Object.freeze(Object.defineProperty({__proto__:null,ComponentGlyph:qx,DropdownChevron:Gi,PageGlyph:Bx},Symbol.toStringTag,{value:"Module"}));function Hx({currentScenario:t,isOpen:s,onClick:n,buttonRef:r}){const a=t?wo(t):!1,o=(t==null?void 0:t.screenshotPaths[0])??null,i=t?a?t.componentName??t.name:ad(t)??t.url??t.name:"Select a page";return e.jsxs("button",{ref:r,onClick:n,className:`flex items-center gap-1.5 max-w-[260px] pl-0.5 pr-1.5 py-0.5 rounded transition-colors cursor-pointer text-xs ${t?"text-gray-200":"text-gray-500"} ${s?"bg-[#555]":"hover:bg-[#4a4a4a]"}`,title:i,"aria-haspopup":"menu","aria-expanded":s,children:[e.jsxs("span",{className:"flex items-center gap-0.5 bg-[#1f1f1f] border border-[#3d3d3d] rounded p-0.5",children:[e.jsx("span",{className:"w-6 h-4 overflow-hidden rounded-sm bg-[#0f0f0f] flex items-center justify-center text-gray-500",children:o?e.jsx("img",{src:ns(o),alt:"",className:"w-full h-full object-cover"}):a?e.jsx(qx,{}):e.jsx(Bx,{})}),e.jsx(Gi,{})]}),e.jsx("span",{className:"truncate",children:i})]})}const l8=Object.freeze(Object.defineProperty({__proto__:null,PagePill:Hx},Symbol.toStringTag,{value:"Module"}));function Wx({scenario:t,active:s,onClick:n}){const r=t.screenshotPaths[0];return e.jsxs("button",{onClick:n,className:`flex items-center gap-2 w-full px-2 py-1.5 text-left transition-colors cursor-pointer ${s?"bg-[#1a2a30]":"hover:bg-[#2a2a2a]"}`,children:[e.jsx("div",{className:"w-10 h-7 shrink-0 rounded overflow-hidden border border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:r?e.jsx("img",{src:ns(r),alt:"",className:"w-full h-full object-cover"}):null}),e.jsx("div",{className:`text-xs truncate flex-1 min-w-0 ${s?"text-white":"text-gray-200"}`,children:wr(t)})]})}const c8=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdownRow:Wx},Symbol.toStringTag,{value:"Module"}));function Gx({currentScenario:t,scenarioGroups:s,onSelect:n,onCreateNew:r,onClose:a,triggerRef:o}){const i=l.useRef(null);ui(i,a,o);const c=l.useMemo(()=>Eo(t,s),[t,s]);return e.jsxs("div",{ref:i,className:"absolute top-full right-0 mt-1 bg-[#222] border border-[#3d3d3d] rounded-lg shadow-2xl z-50 w-72 max-h-[400px] flex flex-col",role:"menu",children:[e.jsx("div",{className:"overflow-y-auto py-1 flex-1 min-h-0",children:c.map(d=>e.jsx(Wx,{scenario:d,active:d.slug===t.slug,onClick:()=>{n(d.slug),a()}},d.slug))}),e.jsx("button",{onClick:()=>{r(),a()},className:"border-t border-[#3d3d3d] px-3 py-2 text-left text-[11px] font-mono tracking-wide text-[var(--accent-active)] hover:bg-[var(--accent-active)]/10 cursor-pointer",children:"+ CREATE NEW STATE"})]})}const d8=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdown:Gx},Symbol.toStringTag,{value:"Module"}));function Ux({label:t,disabled:s,isOpen:n,onClick:r,buttonRef:a}){return e.jsxs("button",{ref:a,onClick:()=>{s||r()},disabled:s,className:`flex items-center gap-1.5 max-w-[200px] h-7 px-2.5 rounded transition-colors text-xs ${s?"bg-[#3a3a3a] text-gray-600 cursor-not-allowed":n?"bg-[#444] text-gray-200 cursor-pointer":"bg-[#3a3a3a] text-gray-200 hover:bg-[#444] cursor-pointer"}`,title:s?"No active state":t,"aria-haspopup":"menu","aria-expanded":n,children:[e.jsx("span",{className:"truncate",children:t}),e.jsx(Gi,{className:"opacity-70 shrink-0"})]})}const u8=Object.freeze(Object.defineProperty({__proto__:null,StatesPillButton:Ux},Symbol.toStringTag,{value:"Module"}));function Yx({viewport:t,isActive:s,onSelect:n}){return e.jsx("button",{onClick:n,className:`p-1 rounded transition-colors cursor-pointer ${s?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${t.name} (${t.width}×${t.height})`,children:e.jsx(Bf,{name:t.name})})}const h8=Object.freeze(Object.defineProperty({__proto__:null,ViewportPresetButton:Yx},Symbol.toStringTag,{value:"Module"}));function Vx({viewports:t,active:s,onChange:n,currentWidth:r,currentHeight:a,previewUrl:o,isCollapsed:i,onToggleCollapsed:c,isFilled:d,onToggleFilled:u,containerWidth:h,containerHeight:p,onCustomSizeChange:f,currentScenario:m,scenarioGroups:b,onShowScenarioPreview:g,onCreateStateRequest:x,isNarrow:y=!1,onBack:v,onPlanChange:j,onToggleStatesModal:w,statesModalOpen:_=!1}){const[S,C]=l.useState(!1),[N,T]=l.useState(!1),O=l.useRef(null),k=l.useRef(null),D=d&&h?Math.round(h):r,$=d&&p?Math.round(p):a,B=m?wr(m):"No state",q=!m;return e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 h-10 grid grid-cols-[1fr_auto_1fr] items-center px-2",children:[e.jsx("div",{className:"justify-self-start",children:v?e.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 h-7 px-2 rounded text-sm text-[#ddd] hover:bg-[#3a3a3a]",children:[e.jsx("span",{"aria-hidden":"true",children:"←"})," Home"]}):y?null:e.jsx(Rx,{isCollapsed:i,onToggle:c})}),e.jsxs("div",{className:`flex items-center gap-2 justify-self-center ${y?"min-w-0 overflow-x-auto":""}`,children:[e.jsxs("div",{className:"relative flex items-center bg-[#3a3a3a] rounded h-7 px-1 gap-1",children:[e.jsx(Hx,{currentScenario:m,isOpen:S,onClick:()=>{C(P=>!P),T(!1)},buttonRef:O}),S&&e.jsx($x,{scenarioGroups:b,currentSlug:(m==null?void 0:m.slug)??null,onSelect:g,onClose:()=>C(!1),triggerRef:O}),e.jsx("span",{className:"w-px h-5 bg-[#555] mx-1 shrink-0","aria-hidden":"true"}),t.map(P=>e.jsx(Yx,{viewport:P,isActive:!d&&s===P.name,onSelect:()=>{d&&u(),n(P.name)}},P.name)),e.jsx(Ex,{isFilled:d,onToggle:u}),e.jsx(ho,{label:"H",value:$,disabled:d,onCommit:P=>f(r,P)}),e.jsx(ho,{label:"W",value:D,disabled:d,onCommit:P=>f(P,a)}),e.jsx(Ix,{}),e.jsx(Mx,{previewUrl:o})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.jsx("div",{className:"relative",children:w?_?null:e.jsx("button",{type:"button",onClick:w,className:"font-mono text-[10px] leading-none uppercase tracking-widest underline underline-offset-2 whitespace-nowrap hover:opacity-80",style:{color:"var(--lime-300)"},children:"Scenarios"}):e.jsxs(e.Fragment,{children:[e.jsx(Ux,{label:B,disabled:q,isOpen:N,onClick:()=>{T(P=>!P),C(!1)},buttonRef:k}),N&&m&&e.jsx(Gx,{currentScenario:m,scenarioGroups:b,onSelect:g,onCreateNew:x,onClose:()=>T(!1),triggerRef:k})]})})})]}),e.jsx("div",{className:"justify-self-end",children:j?e.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 p8=Object.freeze(Object.defineProperty({__proto__:null,NavigationBar:Vx},Symbol.toStringTag,{value:"Module"}));function Kx(){return e.jsxs("div",{style:{padding:"3rem 1rem",textAlign:"center",color:"var(--text-muted)"},children:[e.jsx("h2",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-secondary)",margin:"0 0 0.5rem 0"},children:"No plan loaded"}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem"},children:"Ask the AI to draft a plan, or pick one from the Plan tab."})]})}const m8=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewEmptyState:Kx},Symbol.toStringTag,{value:"Module"}));function Jx({title:t}){return e.jsx("h1",{style:{fontSize:"1.5rem",fontWeight:600,color:"var(--text-primary)",margin:"0 0 1rem 0",paddingBottom:"0.75rem",borderBottom:"1px solid var(--border-subtle)"},children:t})}const f8=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewHeader:Jx},Symbol.toStringTag,{value:"Module"})),_c={prompt:null,title:null};function Xx(){const[t,s]=l.useState(_c),[n,r]=l.useState(!0);return l.useEffect(()=>{let a=!1;return(async()=>{try{const i=await(await fetch("/api/prompt")).json();a||s({prompt:i.prompt??null,title:i.title??null})}catch{a||s(_c)}finally{a||r(!1)}})(),()=>{a=!0}},[]),{...t,loading:n}}function Qx(){const{prompt:t,title:s,loading:n}=Xx();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:n?null:t?e.jsxs(e.Fragment,{children:[s?e.jsx(Jx,{title:s}):null,e.jsx($t,{children:t})]}):e.jsx(Kx,{})})})}const g8=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewPanelView:Qx},Symbol.toStringTag,{value:"Module"}));function Zx({message:t}){return e.jsx("span",{style:{color:"var(--text-dim)"},children:t})}const b8=Object.freeze(Object.defineProperty({__proto__:null,PreviewEmptyState:Zx},Symbol.toStringTag,{value:"Module"}));function ey({hasDevServerConfigured:t}){const s=t?"Starting your app…":"Your app will display here once set up";return e.jsx("div",{"data-testid":"preview-waiting-placeholder",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",color:"var(--text-dim)"},children:e.jsx("span",{children:s})})}const x8=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingPlaceholder:ey},Symbol.toStringTag,{value:"Module"}));function ty(t,s,n){const r=[t];return s&&r.push(`reload:${s}`),n&&r.push(`command:${n}`),r.join("::")}function sy({currentWidth:t,currentHeight:s,isFilled:n,scale:r}){const a=e.jsx("div",{className:"w-full h-full border border-dashed rounded flex items-center justify-center text-center px-6",style:{borderColor:"var(--border-default)",background:"var(--bg-surface)",color:"var(--text-dim)"},children:e.jsxs("div",{className:"text-sm leading-relaxed",children:[e.jsx("div",{className:"font-medium",children:"Live Preview unavailable"}),e.jsxs("div",{className:"opacity-70 mt-1",children:[t,"×",s]})]})});return n?a:e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:t,height:s,transform:r<1?`scale(${r})`:void 0,transformOrigin:"center center",flexShrink:0},children:a})}const ny=l.forwardRef(function({currentHeight:s,currentWidth:n,isFilled:r,previewUrl:a,scale:o,reloadNonce:i,commandNonce:c,iframeKey:d,onLoad:u,onError:h},p){if(bt())return e.jsx(sy,{currentWidth:n,currentHeight:s,isFilled:r,scale:o});const f=d??ty(a,i,c),m=()=>{h&&h("iframe error event")};return e.jsx("div",{className:r?"w-full h-full":"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:r?void 0:{width:n,height:s,transform:o<1?`scale(${o})`:void 0,transformOrigin:"center center",flexShrink:0},children:e.jsx("iframe",{ref:p,src:a,title:"Live Preview",style:{width:"100%",height:"100%",border:"none",background:"var(--bg-deep)"},onLoad:u,onError:m},f)})}),y8=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedPreviewPlaceholder:sy,PreviewFrame:ny},Symbol.toStringTag,{value:"Module"}));function ry({label:t="Loading preview..."}={}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-3 bg-[var(--bg-deep)]/80 backdrop-blur-sm text-[var(--text-muted)]",children:[e.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:t})]})}const v8=Object.freeze(Object.defineProperty({__proto__:null,PreviewLoadingSpinner:ry},Symbol.toStringTag,{value:"Module"}));function G3(t){var s,n;try{const r=(n=(s=t==null?void 0:t.contentWindow)==null?void 0:s.location)==null?void 0:n.href;return typeof r=="string"?r:null}catch{return null}}function U3(t,s){if(!s||!t||t==="about:blank")return null;let n;try{n=new URL(t,window.location.origin).pathname}catch{return null}return n===bs||n.startsWith(`${bs}/`)?null:n}function Y3(t){return{type:"error",message:`The app navigated to "${t}", which is outside the Live Preview (everything the preview serves lives under ${bs}). That path is served by the editor, so the frame would have rendered codeyam-editor instead of your app. The preview was stopped rather than showing you the wrong application.`,filename:t,lineno:null,colno:null,stack:[`Frame navigated to: ${t}`,`Expected to stay under: ${bs}`,"",`Why this happens: the Live Preview is served from the same-origin ${bs} 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(`
195
- `),timestampMs:Date.now(),dedupeKey:`preview-escape:${t}`,count:1}}function V3({previewUrl:t,resetKey:s,capturedErrors:n}){const[r,a]=l.useState(null),o=t.startsWith(bs);l.useEffect(()=>{a(null)},[s,t]);const i=l.useCallback(u=>{const h=G3(u),p=U3(h,o);return a(p),p!==null&&rC(p),h},[o]),c=l.useCallback(()=>a(null),[]),d=l.useMemo(()=>r?[...n,Y3(r)]:n,[n,r]);return{escaped:r!==null,overlayErrors:d,noteFrameLoad:i,clearEscape:c}}function K3(t,s){const n=l.useRef(!1);l.useEffect(()=>{n.current||t&&t.startCommand&&(t.intendedRunning||t.status==="stopped"&&(n.current=!0,s()))},[t,s])}function J3(t,s){const[n,r]=l.useState(!1),a=l.useCallback(()=>{n?(r(!1),t.deactivate(),t.clearSelection()):(r(!0),t.activate())},[n,t]);return l.useEffect(()=>{n&&(r(!1),t.clearSelection())},[s]),{isActive:n,toggle:a}}function X3(t,s){const[n,r]=l.useState(t),a=l.useRef(null);return l.useEffect(()=>{if(t!==!1){a.current!==null&&(window.clearTimeout(a.current),a.current=null),r(t);return}if(a.current===null)return a.current=window.setTimeout(()=>{a.current=null,r(!1)},s),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},[t,s]),n}function Q3(t,s=!0,n="running"){const r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(0),c=l.useRef(null);l.useEffect(()=>{t!=null&&(r.current!=null&&t!==r.current?(a.current=!1,i(h=>h+1)):r.current==null&&(a.current?s&&uc(t,c.current):i(h=>h+1)),r.current=t)},[t,s]);const d=l.useCallback(h=>{a.current=!0,h&&(c.current=h),s&&t!=null&&uc(t,h??c.current)},[t,s]),u=l.useCallback(h=>{s&&tC(h)},[s]);return{reloadNonce:o,handleIframeLoad:d,handleIframeError:u}}const Z3=1500,eP=2e3,tP=3e3,sP=2;function nP(){return typeof window>"u"?!1:window.location.pathname.startsWith("/scenario/")?!0:bt()}function rP(t,s=!1){const n=nP(),[r,a]=l.useState(n?!0:null),[o,i]=l.useState(null),[c,d]=l.useState(0),[u,h]=l.useState(0),p=l.useRef(null),f=l.useRef(null),m=l.useRef(null),b=l.useRef(!1),g=l.useRef(t),x=l.useRef(s);l.useEffect(()=>{g.current=t},[t]),l.useEffect(()=>{x.current=s},[s]);const y=l.useCallback(()=>{f.current!=null&&(clearTimeout(f.current),f.current=null)},[]),v=l.useCallback(async()=>{if(b.current||x.current)return;const S=g.current;if(!S)return;m.current&&m.current.abort();const C=new AbortController;m.current=C;const N=setTimeout(()=>C.abort(),tP);let T=!1;try{await fetch(S,{mode:"no-cors",cache:"no-store",signal:C.signal}),T=!0}catch{T=!1}finally{clearTimeout(N)}if(!b.current){if(i(Date.now()),T){if(d(0),p.current!==!0){const O=p.current===!1;p.current=!0,a(!0),O&&h(k=>k+1)}}else d(O=>{const k=O+1;return k>=sP&&p.current!==!1&&(p.current=!1,a(!1)),k});j()}},[]),j=l.useCallback(()=>{if(b.current)return;y();const S=p.current===!0?eP:Z3;f.current=setTimeout(()=>{f.current=null,v()},S)},[y,v]),w=l.useCallback(()=>{y(),v()},[y,v]);l.useEffect(()=>{if(!n)return b.current=!1,v(),()=>{b.current=!0,y(),m.current&&(m.current.abort(),m.current=null)}},[v,y,n]),l.useEffect(()=>{n||v()},[t,v,n]);const _=l.useRef(s);return l.useEffect(()=>{if(n)return;const S=_.current;_.current=s,S&&!s&&v()},[s,v,n]),{healthy:r,lastProbeAt:o,failedProbeCount:c,reloadNonce:u,invalidate:w}}const kc={loaded:!1,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:null};function aP(t){const{active:s,trigger:n}=t,[r,a]=l.useState(kc),o=l.useRef(null),i=l.useCallback(()=>{var d;(d=o.current)==null||d.abort();const c=new AbortController;o.current=c,fetch("/api/dev-server-recent-requests",{signal:c.signal}).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.json()}).then(u=>{if(c.signal.aborted)return;const p=(u.stalls??[]).reduce((f,m)=>Math.max(f,m.durationMs??0),0);a({loaded:!0,stalledRequests:u.stalledRequests??0,fastRequests:u.fastRequests??0,longestStallMs:p,tailReadFailedReason:u.tailReadFailedReason??null})}).catch(u=>{c.signal.aborted||a({loaded:!0,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:u instanceof Error?u.message:"fetch failed"})})},[]);return l.useEffect(()=>{var c;if(!s){a(kc),(c=o.current)==null||c.abort();return}return i(),()=>{var d;(d=o.current)==null||d.abort()}},[s,n,i]),r}function oP(t){return!t||!t.loaded||t.tailReadFailedReason?null:t.stalledRequests>0?`Recent requests took up to ${Math.max(1,Math.round(t.longestStallMs/1e3))}s — the dev server is responding, just slowly. Check the dev-server log for what's blocking the render.`:t.fastRequests===0?"No recent activity in the dev-server log — the dev server may have stopped accepting connections. Restart it if this persists.":null}function iP({liveIframeHealthy:t,previewReachable:s}){return t===!0||s===!0}function lP({hasDevServerConfigured:t,hasServed:s}){return!t||s}const cP=2e3;function dP(t,s){const[n,r]=l.useState(0),a=l.useRef(t),o=l.useRef(s),i=l.useRef(0);return l.useEffect(()=>{const c=a.current,d=o.current;if(a.current=t,o.current=s,!(s===!1)||!(t===!0)||!(c===!1&&t===!0)&&!(d===!0&&s===!1))return;const m=Date.now();m-i.current<cP||(i.current=m,r(b=>b+1))},[t,s]),n}const Gn={windowMs:1e4,threshold:4,ringBufferSize:16};function uP({pidNonce:t,probeNonce:s,draftNonce:n,windowMs:r=Gn.windowMs,threshold:a=Gn.threshold}){const[o,i]=l.useState(!1),[c,d]=l.useState([]),[u,h]=l.useState(0),p=l.useRef(!1),f=l.useRef(t),m=l.useRef(s),b=l.useRef(n),g=l.useCallback(y=>{const v=Date.now(),j=v-r;let w=[];d(S=>{const C=S.filter(N=>N.timestampMs>=j);return C.push({reason:y,timestampMs:v}),C.length>Gn.ringBufferSize&&C.splice(0,C.length-Gn.ringBufferSize),w=C,C});const _=w.filter(S=>S.timestampMs>=j).length;if(!p.current&&_>=a){p.current=!0,i(!0);return}p.current||h(S=>S+1)},[r,a]);l.useEffect(()=>{t!==f.current&&(f.current=t,g("pid"))},[t,g]),l.useEffect(()=>{s!==m.current&&(m.current=s,g("probe"))},[s,g]),l.useEffect(()=>{n!==b.current&&(b.current=n,g("draft"))},[n,g]);const x=l.useCallback(()=>{p.current=!1,i(!1),d([]),h(y=>y+1)},[]);return{tripped:o,recentReloads:c,gatedNonce:u,reset:x}}function hP(t,s,n=To){const r=l.useRef(void 0);l.useEffect(()=>{if(!s){r.current=t;return}if(typeof t=="number"){if(r.current===void 0){r.current=t;return}t>r.current&&(r.current=t,n())}},[t,s,n])}const Sc=20,pP="codeyam-error-capture";function mP(t,s=0){const[n,r]=l.useState([]),a=l.useCallback(()=>r([]),[]);return l.useEffect(()=>{r([])},[s]),l.useEffect(()=>{function o(i){const c=i.data;if(!c||c.source!==pP)return;const d=t.current;if(d&&i.source!==d.contentWindow)return;const u=c.payload;!u||typeof u!="object"||!u.dedupeKey||r(h=>{const p=h.findIndex(m=>m.dedupeKey===u.dedupeKey);if(p>=0){const m=h.slice();return m[p]={...m[p],count:m[p].count+1,timestampMs:u.timestampMs},m}const f=[...h,{...u,count:1}];return f.length>Sc?f.slice(f.length-Sc):f})}return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[t]),{errors:n,clear:a}}const Sa=[500,1e3,2e3];async function fP(t){try{const n=await(await fetch(`/api/probe-url?url=${encodeURIComponent(t)}`)).json();return{status:typeof(n==null?void 0:n.status)=="number"?n.status:null}}catch{return{status:null}}}async function gP(){try{const s=await(await fetch("/api/dev-server-log/slice?lines=40")).json();return Array.isArray(s==null?void 0:s.lines)?s.lines:[]}catch{return[]}}function bP(t,s){const[n,r]=l.useState({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return l.useEffect(()=>{if(!t){r({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return}let a=!1;return r({status:null,clickThroughBroken:!1,logLines:[],loading:!0}),(async()=>{const o=1+Sa.length;let i=null;for(let d=0;d<o;d++){if(a)return;const{status:u}=await fP(t);if(a)return;if(i=u,u===null||u<500){r({status:u,clickThroughBroken:!1,logLines:[],loading:!1});return}d<Sa.length&&await new Promise(h=>setTimeout(h,Sa[d]))}const c=await gP();a||r({status:i,clickThroughBroken:!0,logLines:c,loading:!1})})(),()=>{a=!0}},[t,s]),n}function ay({url:t,status:s,logLines:n,onRetry:r}){return e.jsx("div",{role:"alert","data-testid":"iframe-click-through-error-card",className:"absolute inset-0 z-20 flex items-center justify-center bg-zinc-950/85 p-6",children:e.jsxs("div",{className:"max-w-2xl w-full rounded-md border border-red-700 bg-zinc-900 text-zinc-100 shadow-xl",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-red-800 flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[e.jsxs("div",{className:"text-sm font-semibold text-red-300",children:["Scenario render failed (HTTP ",s,")"]}),e.jsx("div",{className:"mt-1 text-xs text-zinc-400 break-all",children:t}),e.jsx("div",{className:"mt-2 text-xs text-zinc-300",children:"The iframe URL returned a server error. This is a bug — capture and click should always agree. Check the dev-server log below and refresh once the underlying error is fixed."})]}),e.jsx("button",{type:"button",onClick:r,className:"flex-shrink-0 px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"})]}),e.jsx("div",{className:"px-5 py-4 max-h-72 overflow-auto font-mono text-[11px] leading-snug text-zinc-300 whitespace-pre-wrap",children:n.length>0?n.join(`
196
- `):e.jsxs("span",{className:"text-zinc-500 italic",children:["No dev-server log lines available — see"," ",e.jsx("code",{children:".codeyam/logs/dev-server.log"}),"."]})})]})})}const j8=Object.freeze(Object.defineProperty({__proto__:null,IframeClickThroughErrorCard:ay},Symbol.toStringTag,{value:"Module"}));function xP(t){if(t===null||!t.startCommand)return{isRestarting:!1,isFailed:!1,isStarting:!1,isStopped:!1};const s=t.status==="failed",n=!s&&t.status!=="running"&&t.intendedRunning&&(t.restartCount??0)>0,r=!s&&t.intendedRunning&&t.status!=="running"&&(t.restartCount??0)===0,a=t.status==="stopped"&&!t.intendedRunning;return{isRestarting:n,isFailed:s,isStarting:r,isStopped:a}}const yP=20;function vP(t){const{hasDevServerConfigured:s,probeHealthy:n,backendIframeHealthy:r,isStarting:a,isRestarting:o,isFailed:i,isStopped:c,isPrePrototype:d,withinStartupGrace:u,previewReachable:h,hasEverServed:p}=t;return s?i?"crashed":r===!0||h===!0||n===!0&&r!==!1?null:d?"scaffolding":c?p?"stopped":null:o?"restarting":a||u||!p?null:n===!1?"reconnecting":r===!1&&n===!0?"disconnected":n===null?"probing":"reconnecting":null}function jP(t){return t===null||t.status!=="running"?!1:t.liveIframeHealthy!==!1}const wP=5,_P=3;function kP(t,s){return t===null||t<=0?!1:t<=(s==="backend"?_P:wP)}const Nc="Setting up your project",Cc="Preparing your project — the preview will appear once it's ready.",SP={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."},NP={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Preparing the project environment."};function CP(t,s){return t===null?{title:Nc,body:Cc}:{title:Nc,body:(s==="backend"?NP:SP)[t]??Cc}}function oy({restartCount:t}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-[10px] font-bold text-primary",children:t>0?`#${t}`:""})]})}const w8=Object.freeze(Object.defineProperty({__proto__:null,RestartSpinner:oy},Symbol.toStringTag,{value:"Module"})),PP={probing:{title:"Checking Live Preview",body:"Probing the dev server before showing the iframe…",spinner:!0},starting:{title:"Starting Dev Server",body:"Waiting for the development server to start…",spinner:!0},restarting:{title:"Dev Server Restarting",body:"The Live Preview server crashed unexpectedly. CodeYam is automatically recovering it…",spinner:!0},reconnecting:{title:"Reconnecting Live Preview",body:"Waiting for the dev server to respond…",spinner:!0},disconnected:{title:"Preview Disconnected",body:"The dev server is running, but the preview lost its connection after a restart. Reload the preview to reconnect — there's no need to restart the dev server.",spinner:!1},stopped:{title:"Dev Server Not Running",body:"Starting automatically…",spinner:!1},crashed:{title:"Dev Server Crashed",body:"Recovery is taking longer than usual.",spinner:!1},scaffolding:{title:"Setting up your project",body:"Preparing your project — the preview will appear once it's ready.",spinner:!0}};function iy({variant:t,restartCount:s=0,showRetry:n=!1,onRetry:r,bodyOverride:a}){const{title:o,body:i,spinner:c}=PP[t],d=a??i,u=t==="disconnected",h=!!r&&(u||n),p=u?"Reload preview":"Retry now";return e.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":t,className:"absolute inset-0 bg-white/90 dark:bg-gray-900/90 backdrop-blur-sm flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4 text-center max-w-md p-6",children:[c?e.jsx(oy,{restartCount:s}):e.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6 text-gray-500 dark:text-gray-400","aria-hidden":"true",children:[e.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),e.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:o}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:d})]}),h&&r&&e.jsx("button",{type:"button",onClick:r,className:"mt-2 px-4 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",children:p})]})})}const _8=Object.freeze(Object.defineProperty({__proto__:null,PreviewUnhealthyOverlay:iy},Symbol.toStringTag,{value:"Module"}));function TP(t){return t.slice().reverse().map(s=>{const n=s.filename!=null?`
197
- at ${s.filename}${s.lineno!=null?`:${s.lineno}`:""}${s.colno!=null?`:${s.colno}`:""}`:"",r=s.stack?`
198
- ${s.stack}`:"",a=s.count>1?` (×${s.count})`:"";return`[${s.type}]${a} ${s.message}${n}${r}`}).join(`
199
-
200
- `)}function AP(t){if(t.length===0)return"no reloads recorded";const s={};for(const n of t)s[n.reason]=(s[n.reason]??0)+1;return Object.entries(s).map(([n,r])=>`${n}×${r}`).join(", ")}function ly({count:t,onExpand:s,onClear:n}){const r=`${t} ${t===1?"Error":"Errors"}`;return e.jsx("div",{"data-testid":"preview-error-badge",className:"absolute bottom-3 right-3 z-50 pointer-events-auto",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-full shadow-lg border border-red-300 dark:border-red-800 bg-white dark:bg-gray-900",style:{background:"var(--bg-surface, rgba(255,255,255,0.97))"},children:[e.jsxs("button",{type:"button",onClick:s,"aria-label":`Expand ${r}`,className:"cursor-pointer flex items-center gap-1.5 pl-2.5 pr-2 py-1 text-xs font-medium text-red-700 dark:text-red-300 hover:bg-red-50 dark:hover:bg-red-950/40 rounded-l-full",children:[e.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full bg-red-600"}),e.jsx("span",{children:r}),e.jsx("span",{"aria-hidden":"true",className:"text-gray-400",children:"›"})]}),e.jsx("button",{type:"button",onClick:n,"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 k8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorBadge:ly},Symbol.toStringTag,{value:"Module"}));function cy({headline:t,tripped:s,onClear:n,closeAriaLabel:r="Dismiss errors"}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3 border-b border-red-200 dark:border-red-900",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:t}),e.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:s?"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 Claude."})]}),e.jsx("button",{type:"button",onClick:n,className:"cursor-pointer text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":r,children:"✕"})]})}const S8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayHeader:cy},Symbol.toStringTag,{value:"Module"}));function dy({error:t,expanded:s,onToggle:n}){return e.jsxs("li",{className:"rounded border border-red-200 dark:border-red-900 bg-red-50/60 dark:bg-red-950/30",children:[e.jsxs("button",{type:"button",onClick:n,className:"w-full flex items-start gap-2 text-left px-2 py-1.5 hover:bg-red-100/60 dark:hover:bg-red-900/30",children:[e.jsx("span",{className:"mt-0.5 text-red-500","aria-hidden":"true",children:s?"▾":"▸"}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-red-500 dark:text-red-400 mr-2",children:t.type}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 break-words",children:t.message}),t.count>1&&e.jsxs("span",{className:"ml-2 text-gray-500",children:["×",t.count]}),t.filename&&e.jsxs("span",{className:"block text-[11px] text-gray-500 mt-0.5 truncate",children:[t.filename,t.lineno!=null?`:${t.lineno}`:"",t.colno!=null?`:${t.colno}`:""]})]})]}),s&&t.stack&&e.jsx("pre",{className:"px-3 pb-2 text-[11px] font-mono text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",children:t.stack})]})}const N8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorRow:dy},Symbol.toStringTag,{value:"Module"}));function uy({errors:t,emptyHint:s}){const[n,r]=l.useState(null);return t.length===0?e.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:e.jsx("li",{className:"text-gray-500 px-2 py-3",children:s??"No runtime errors captured yet."})}):e.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:t.slice().reverse().map(a=>e.jsx(dy,{error:a,expanded:n===a.dedupeKey,onToggle:()=>r(n===a.dedupeKey?null:a.dedupeKey)},a.dedupeKey))})}const C8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorList:uy},Symbol.toStringTag,{value:"Module"}));function hy({canCopy:t,reasonsSummary:s,copyState:n,onCopy:r,onCopyForClaude:a,onRetry:o}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 border-t border-red-200 dark:border-red-900 bg-gray-50 dark:bg-gray-900/40",children:[e.jsx("button",{type:"button",onClick:r,disabled:!t,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:"Copy errors"}),e.jsx("button",{type:"button",onClick:a,disabled:!t,className:"px-2.5 py-1 text-xs rounded bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:"Copy and ask Claude"}),e.jsx("button",{type:"button",onClick:o,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"}),e.jsxs("span",{className:"ml-auto text-[11px] text-gray-500",children:["Reloads in last 10s: ",s,n==="copied"&&e.jsx("span",{className:"ml-2 text-emerald-600",children:"copied ✓"}),n==="failed"&&e.jsx("span",{className:"ml-2 text-red-500",children:"copy blocked"})]})]})}const P8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayFooter:hy},Symbol.toStringTag,{value:"Module"})),OP=`Fix this error in the live preview. Here is what the captured runtime error reported:
201
-
202
- `;function py({tripped:t,errors:s,recentReloads:n,serverHealthy:r,onRetry:a,onClear:o}){const[i,c]=l.useState("idle"),[d,u]=l.useState(!0),h=l.useMemo(()=>TP(s),[s]),p=l.useMemo(()=>AP(n),[n]);if(l.useEffect(()=>{s.length===0&&u(!0)},[s.length]),!t&&s.length===0)return null;const f=r&&!t,m=f&&d&&s.length>0,b=t?`Live Preview paused — ${s.length} error${s.length===1?"":"s"} captured`:`${s.length} runtime error${s.length===1?"":"s"} captured`;async function g(x){const y=await mw(x+h);c(y?"copied":"failed"),setTimeout(()=>c("idle"),1500)}return m?e.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":"false","data-collapsed":"true",className:"absolute inset-0 z-50 pointer-events-none",children:e.jsx(ly,{count:s.length,onExpand:()=>u(!1),onClear:o})}):e.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":t?"true":"false","data-collapsed":"false",className:"absolute inset-0 z-50 flex flex-col items-stretch p-4 pointer-events-none",children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl rounded-lg shadow-lg pointer-events-auto flex flex-col",style:{background:"var(--bg-surface, rgba(255,255,255,0.97))",border:"1px solid var(--border-default, #ef4444)",maxHeight:"100%"},children:[e.jsx(cy,{headline:b,tripped:t,onClear:f?()=>u(!0):o,closeAriaLabel:f?"Minimize errors":"Dismiss errors"}),e.jsx(uy,{errors:s,emptyHint:t?`Breaker tripped before any runtime error was reported. Reasons in window: ${p}.`:null}),e.jsx(hy,{canCopy:s.length>0,reasonsSummary:p,copyState:i,onCopy:()=>g(""),onCopyForClaude:()=>g(OP),onRetry:a})]})})}const T8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlay:py},Symbol.toStringTag,{value:"Module"}));function RP(t){if(!t)return null;const s=Object.entries(t).map(([n,r])=>`${n}=${typeof r=="string"?r:JSON.stringify(r)}`);return s.length>0?s.join(", "):null}function my({previewUrl:t,description:s,demonstratesState:n}){const r=l.useMemo(()=>{try{return new URL(t,window.location.origin).searchParams.get("_codeyam_scenario")}catch{return null}},[t]),a=l.useMemo(()=>RP(n),[n]);if(!r)return null;const o=s!=null&&s.trim()?s.trim():null;return e.jsxs("div",{className:"absolute top-2 left-2 z-30 flex flex-col gap-0.5 max-w-[16rem] px-2 py-1 rounded bg-black/60 backdrop-blur-sm border border-white/10 shadow-lg pointer-events-none select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),e.jsxs("span",{className:"text-[10px] font-medium text-white/90 tracking-wide uppercase",children:["Scenario: ",r]})]}),o?e.jsx("span",{className:"text-[10px] text-white/70 leading-snug whitespace-pre-line",children:o}):null,a?e.jsx("span",{className:"text-[9px] font-mono text-white/50 tracking-wide",children:a}):null]})}const A8=Object.freeze(Object.defineProperty({__proto__:null,ActiveScenarioOverlay:my},Symbol.toStringTag,{value:"Module"}));function fy(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx("h3",{className:"text-sm font-bold text-gray-900 dark:text-gray-100 uppercase tracking-tight",children:"Dev Server Crash Recovery Failed"})]}),e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 font-medium",children:"LAST 50 LOG LINES"})]})}const O8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogHeader:fy},Symbol.toStringTag,{value:"Module"}));function gy({logs:t}){return e.jsx("div",{className:"flex-1 bg-black p-4 font-mono text-[11px] leading-relaxed overflow-y-auto text-gray-300",children:t.length>0?t.map((s,n)=>e.jsx("div",{className:"whitespace-pre-wrap break-all border-l-2 border-gray-800 pl-3 mb-1",children:s},n)):e.jsx("div",{className:"italic text-gray-600",children:"No logs captured..."})})}const R8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogViewer:gy},Symbol.toStringTag,{value:"Module"}));function by({text:t,label:s="Copy",copiedLabel:n="Copied!",writer:r,className:a="shrink-0 px-3 py-1.5 text-xs font-medium rounded-md bg-red-600 hover:bg-red-700 disabled:bg-red-300 disabled:cursor-not-allowed text-white transition-colors"}){const{copied:o,copy:i}=gn({writer:r});return e.jsx("button",{type:"button",onClick:()=>{i(t)},disabled:t.length===0,className:a,children:o?n:s})}const E8=Object.freeze(Object.defineProperty({__proto__:null,CopyButton:by},Symbol.toStringTag,{value:"Module"}));function xy(){return e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-red-800 dark:text-red-300 font-medium mb-1",children:"CodeYam was unable to restart the dev server after several attempts."}),e.jsx("p",{className:"text-xs text-red-700/80 dark:text-red-400/80",children:"Copy the logs and share them with Claude to investigate the underlying bug."})]})}const M8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooterMessage:xy},Symbol.toStringTag,{value:"Module"}));function yy({logs:t,copyWriter:s}){return e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-950/30 border-t border-red-100 dark:border-red-900/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx(xy,{}),e.jsx(by,{text:t.join(`
203
- `),label:"Copy logs",writer:s})]})})}const I8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooter:yy},Symbol.toStringTag,{value:"Module"}));function vy({logs:t}){return e.jsxs("div",{className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[e.jsx(fy,{}),e.jsx(gy,{logs:t}),e.jsx(yy,{logs:t})]})}const D8=Object.freeze(Object.defineProperty({__proto__:null,DevServerCrashLog:vy},Symbol.toStringTag,{value:"Module"})),Pc=20;function EP(t){if(!t)return null;try{return new Date(t).toLocaleTimeString()}catch{return null}}function jy({lastError:t,failureCount:s,failedAtMs:n,holder:r,onRetry:a,onReap:o}){const[i,c]=l.useState(!1),d=t.split(`
204
- `),u=d.length>Pc,h=i||!u?d:d.slice(d.length-Pc),p=EP(n);return e.jsxs("div",{"data-testid":"dev-server-failed-panel",className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[e.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:["Dev server failed to start after ",s," ",s===1?"attempt":"attempts"]}),p&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["Last attempt: ",p]}),r&&e.jsxs("div",{"data-testid":"dev-server-failed-holder",className:"mt-3 rounded border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/30 px-3 py-2 text-xs text-amber-900 dark:text-amber-100",children:[e.jsxs("div",{children:["Port ",e.jsx("span",{className:"font-semibold",children:r.port})," is held by:"]}),e.jsxs("div",{className:"mt-1 font-mono",children:["PID ",r.pid," — ",r.command]})]})]}),e.jsx("pre",{"data-testid":"dev-server-failed-error",className:"flex-1 overflow-auto px-6 py-4 m-0 font-mono text-xs leading-relaxed text-gray-800 dark:text-gray-200 whitespace-pre",children:h.join(`
205
- `)}),e.jsxs("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between gap-3",children:[u?e.jsx("button",{type:"button",onClick:()=>c(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`}):e.jsx("span",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&o&&e.jsx("button",{type:"button","data-testid":"dev-server-failed-reap",onClick:o,className:"px-4 py-1.5 text-sm font-medium rounded border border-amber-500 text-amber-700 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-900/50",children:"Kill orphan and retry"}),e.jsx("button",{type:"button","data-testid":"dev-server-failed-retry",onClick:a,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})]})]})]})}const L8=Object.freeze(Object.defineProperty({__proto__:null,DevServerFailedPanel:jy},Symbol.toStringTag,{value:"Module"}));function wy({diagnostic:t,onRetry:s}){const{expectedPort:n,actualPort:r,appName:a,currentStartCommand:o,remediation:i}=t;return e.jsxs("div",{"data-testid":"preview-port-mismatch-card",className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-auto",children:[e.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Dev server port conflict"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[a," bound port"," ",e.jsx("span",{className:"font-semibold",children:r}),", but the editor needs the app on port"," ",e.jsx("span",{className:"font-semibold",children:n})," so its reverse proxy (mocking, capture) can sit in front."]})]}),e.jsxs("div",{className:"flex-1 px-6 py-4 text-sm text-gray-800 dark:text-gray-200 space-y-3",children:[e.jsx("p",{children:i}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Current start command"}),e.jsx("pre",{className:"m-0 font-mono text-xs leading-relaxed whitespace-pre-wrap rounded bg-gray-100 dark:bg-gray-800 px-3 py-2",children:o||"(none configured)"})]})]}),e.jsx("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-end",children:e.jsx("button",{type:"button","data-testid":"preview-port-mismatch-retry",onClick:s,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})})]})}const F8=Object.freeze(Object.defineProperty({__proto__:null,PreviewPortMismatchCard:wy},Symbol.toStringTag,{value:"Module"})),Tc=48,MP=100,IP=320,DP=192;function LP({containerHeight:t,containerWidth:s,viewportHeight:n,viewportWidth:r}){if(!(r!=null&&n!=null&&s!=null&&t!=null&&r>0&&n>0&&s>0&&t>0))return{width:IP,height:DP,hasViewport:!1};const o=s-Tc*2,i=t-Tc*2-MP,c=Math.min(1,o/r,i/n);return{width:Math.round(r*c),height:Math.round(n*c),hasViewport:!0}}function fo({containerHeight:t,containerWidth:s,heading:n="The app is being edited",onDismiss:r,scenarioName:a,screenshotPath:o,subtext:i="Live preview will load when the build agent is idle",viewportHeight:c,viewportWidth:d}){const{width:u,height:h,hasViewport:p}=LP({containerWidth:s,containerHeight:t,viewportWidth:d,viewportHeight:c}),f={width:u,height:h,...p?{overflowY:"auto"}:{}};return e.jsx("div",{className:"absolute inset-0 bg-white/90 dark:bg-gray-900/90 backdrop-blur-sm flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4 text-center p-6",children:[e.jsx("div",{className:"rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700 shadow-md",style:f,children:e.jsx(Nt,{screenshotPath:o??void 0,alt:a??"Scenario preview",className:p?"w-full h-auto":"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:n}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:i})]}),e.jsx("button",{onClick:r,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:"Dismiss"})]})})}const z8=Object.freeze(Object.defineProperty({__proto__:null,BuildingPreviewOverlay:fo},Symbol.toStringTag,{value:"Module"}));function _y({isActive:t,onToggle:s,interactionAvailable:n=!0}){return e.jsx("button",{onClick:n?s:void 0,disabled:!n,title:n?t?"Exit Debug Mode":"Debug Mode":"Click-to-select is unavailable for this stack's preview (served from a separate origin)",className:"absolute z-50",style:{bottom:16,right:16,width:40,height:40,borderRadius:"50%",border:t?"2px solid var(--accent-blue)":"1px solid var(--border-default)",background:t?"var(--accent-blue)":"var(--bg-surface)",color:t?"#000":"var(--text-secondary)",cursor:n?"pointer":"not-allowed",display:"none",alignItems:"center",justifyContent:"center",opacity:n?t?1:.6:.35,transition:"all 0.15s ease",fontSize:18},onMouseEnter:r=>{n&&(r.currentTarget.style.opacity="1")},onMouseLeave:r=>{n&&(t||(r.currentTarget.style.opacity="0.6"))},children:t?"✕":"🔍"})}const $8=Object.freeze(Object.defineProperty({__proto__:null,DebugModeButton:_y},Symbol.toStringTag,{value:"Module"}));function FP(){const[t,s]=l.useState(null),n=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){s({message:(c==null?void 0:c.error)??`HTTP ${i.status}`,command:(c==null?void 0:c.command)??null});return}s(null)}catch(i){s({message:i instanceof Error?i.message:String(i),command:null})}},[]),r=l.useCallback(()=>s(null),[]);return{openInEditor:n,lastError:t,clearError:r}}function ky({tag:t,id:s,className:n,text:r,detectionMethod:a,previewUrl:o}){return e.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[e.jsx("div",{className:"rounded overflow-hidden flex-1",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",minHeight:200,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{style:{color:"var(--text-secondary)",fontSize:12},children:[e.jsxs("div",{className:"text-center",style:{color:"var(--text-secondary)"},children:["Preview: ",o.split("/").pop()]}),e.jsxs("div",{className:"mt-2 p-3 rounded",style:{background:"var(--bg-surface)",border:"1px dashed var(--border-default)",fontSize:11,fontFamily:"monospace"},children:["<",t,s?` id="${s}"`:"",n?` class="${n.slice(0,40)}"`:"",">",e.jsx("br",{}),r.slice(0,60),r.length>60?"...":""]})]})}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)"},children:["Detected via: ",a]})]})}const B8=Object.freeze(Object.defineProperty({__proto__:null,DebugModalElementPreview:ky},Symbol.toStringTag,{value:"Module"}));function Sy({ancestors:t,onOpenInEditor:s}){return t.length===0?e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:12,fontStyle:"italic"},children:"No component ancestry available."}):e.jsx("ul",{className:"flex flex-col gap-1",style:{listStyle:"none",padding:0,margin:0},children:t.map((n,r)=>{const a=n.sourceFile&&n.lineNumber?`${n.sourceFile}:${n.lineNumber}`:n.sourceFile??"(unknown source)",o=!!n.sourceFile;return e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{background:"var(--bg-deep)"},children:[e.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontSize:12},children:n.componentName??"<anonymous>"}),e.jsx("span",{style:{color:"var(--text-secondary)",fontFamily:"monospace",fontSize:11,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),o&&e.jsx("button",{onClick:()=>s(n.sourceFile,n.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"})]},`${n.componentName??"anon"}-${r}`)})})}const q8=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestryList:Sy},Symbol.toStringTag,{value:"Module"}));function Ny({ancestors:t,onOpenInEditor:s}){const[n,r]=l.useState(t.length>1);return t.length===0?null:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("button",{onClick:()=>r(a=>!a),className:"text-left",style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,cursor:"pointer",padding:0},children:[n?"▾":"▸"," Component ancestry (",t.length,")"]}),n&&e.jsx(Sy,{ancestors:t,onOpenInEditor:s})]})}const H8=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestrySection:Ny},Symbol.toStringTag,{value:"Module"}));function Cy({propsNames:t}){if(t.length===0)return null;const s=()=>{var n;(n=navigator.clipboard)==null||n.writeText(t.join(", "))};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontSize:12},children:"props:"}),t.map(n=>e.jsx("span",{onClick:s,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:n},n))]})}const W8=Object.freeze(Object.defineProperty({__proto__:null,DebugPropsChips:Cy},Symbol.toStringTag,{value:"Module"}));function Py({componentDisplay:t,sourceDisplay:s,tag:n,id:r,boundingBox:a,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:d,ancestors:u,propsNames:h,onOpenInEditor:p,onGoToIsolated:f,onCreatePlan:m,onClose:b}){const g=c||!o.trim();return e.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[e.jsx("h3",{style:{color:"var(--text-primary)",fontSize:16,fontWeight:600,margin:0},children:t}),s&&e.jsx("div",{className:"px-2 py-1 rounded",style:{background:"var(--bg-deep)",fontSize:12,fontFamily:"monospace",color:"var(--accent-blue)"},children:s}),e.jsxs("div",{className:"flex flex-col gap-1",style:{color:"var(--text-secondary)",fontSize:12},children:[e.jsxs("div",{children:["Element: <",n,">",r?` #${r}`:""]}),e.jsxs("div",{children:["Position: ",Math.round(a.x),", ",Math.round(a.y)," (",Math.round(a.width),"x",Math.round(a.height),")"]})]}),e.jsx(Cy,{propsNames:h}),e.jsx(Ny,{ancestors:u,onOpenInEditor:p}),e.jsx("textarea",{value:o,onChange:x=>i(x.target.value),placeholder:"Describe the issue or desired change...",className:"flex-1 p-2 rounded resize-none",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",color:"var(--text-primary)",fontSize:13,minHeight:80,outline:"none"}}),e.jsxs("div",{className:"flex gap-2",children:[d&&e.jsx("button",{onClick: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"}),e.jsx("button",{onClick:m,disabled:g,className:"px-3 py-1.5 rounded text-sm flex-1",style:{background:g?"var(--bg-deep)":"var(--accent-blue)",border:"none",color:g?"var(--text-secondary)":"#000",cursor:g?"not-allowed":"pointer",fontWeight:600},children:c?"Creating...":"Create Fix Plan"}),e.jsx("button",{onClick:b,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 G8=Object.freeze(Object.defineProperty({__proto__:null,DebugModalInfoPanel:Py},Symbol.toStringTag,{value:"Module"}));function Ty({error:t,onDismiss:s}){return e.jsxs("div",{onClick:n=>n.stopPropagation(),className:"fixed bottom-4 left-1/2 px-3 py-2 rounded",style:{transform:"translateX(-50%)",background:"var(--bg-surface)",border:"1px solid var(--accent-red, #f85149)",color:"var(--text-primary)",fontSize:12,zIndex:60,maxWidth:520},children:[e.jsxs("div",{children:["Open in editor failed: ",t.message]}),t.command&&e.jsx("div",{style:{fontFamily:"monospace",fontSize:11,marginTop:4},children:t.command}),e.jsx("button",{onClick:s,className:"mt-1",style:{background:"transparent",border:"none",color:"var(--accent-blue)",cursor:"pointer",fontSize:11,padding:0},children:"Dismiss"})]})}const U8=Object.freeze(Object.defineProperty({__proto__:null,OpenInEditorErrorToast:Ty},Symbol.toStringTag,{value:"Module"}));function Ay({element:t,previewUrl:s,onClose:n,onGoToIsolated:r,onCreatePlan:a}){const[o,i]=l.useState(""),[c,d]=l.useState(!1),{openInEditor:u,lastError:h,clearError:p}=FP(),f=async()=>{d(!0);try{await a(o,t)}finally{d(!1)}},m=t.componentName??`<${t.element.tag}>`,b=t.sourceFile?`${t.sourceFile}${t.lineNumber?`:${t.lineNumber}`:""}`:null;return e.jsxs("div",{className:"absolute inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.7)"},onClick:n,children:[e.jsxs("div",{className:"flex gap-4 p-6 rounded-lg max-w-3xl w-full mx-4",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",maxHeight:"80vh"},onClick:g=>g.stopPropagation(),children:[e.jsx(ky,{tag:t.element.tag,id:t.element.id,className:t.element.className,text:t.element.text,detectionMethod:t.detectionMethod,previewUrl:s}),e.jsx(Py,{componentDisplay:m,sourceDisplay:b,tag:t.element.tag,id:t.element.id,boundingBox:t.element.boundingBox,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:!!t.componentName,ancestors:t.ancestors,propsNames:t.propsNames,onOpenInEditor:u,onGoToIsolated:()=>r(t.componentName),onCreatePlan:f,onClose:n})]}),h&&e.jsx(Ty,{error:h,onDismiss:p})]})}const Y8=Object.freeze(Object.defineProperty({__proto__:null,DebugModal:Ay},Symbol.toStringTag,{value:"Module"}));function Oy(){return e.jsx("div",{className:"absolute z-40 px-2 py-1 rounded",style:{bottom:8,right:8,background:"var(--bg-surface)",border:"1px solid var(--accent-blue)",color:"var(--accent-blue)",fontSize:11,fontWeight:600,pointerEvents:"none",fontFamily:"system-ui"},"data-testid":"debug-freeze-pill",children:"Debug — frozen"})}const V8=Object.freeze(Object.defineProperty({__proto__:null,DebugFreezePill:Oy},Symbol.toStringTag,{value:"Module"}));function Ry({hoveredElement:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 z-40",style:{border:"3px solid var(--accent-blue)",cursor:"crosshair",pointerEvents:"none"}}),t&&e.jsx("div",{className:"absolute z-40 px-2 py-1 rounded",style:{top:8,left:8,background:"var(--accent-blue)",color:"#000",fontSize:12,fontWeight:600,pointerEvents:"none"},children:t.componentName??`<${t.element.tag}>`}),e.jsx(Oy,{})]})}const K8=Object.freeze(Object.defineProperty({__proto__:null,DebugOverlay:Ry},Symbol.toStringTag,{value:"Module"}));function Ey(){return e.jsx("div",{className:"absolute z-40 pointer-events-none",style:{top:0,left:0,right:0,bottom:0,border:"2px solid var(--accent-blue, #D7FF63)",borderRadius:4,boxSizing:"border-box"},children:e.jsx("div",{style:{position:"absolute",top:0,left:16,padding:"2px 8px",background:"var(--accent-blue, #D7FF63)",color:"#000",fontSize:10,fontWeight:700,fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:"0 0 4px 4px",letterSpacing:.5},children:"INSPECT MODE"})})}const J8=Object.freeze(Object.defineProperty({__proto__:null,InspectModeRibbon:Ey},Symbol.toStringTag,{value:"Module"}));function zP(t,s,n){const{width:r,maxHeight:a,gap:o}=n,i=t.y+t.height+o,c=i+a>s.height,d=c?Math.max(o,t.y-a-o):i,u=Math.max(o,Math.min(t.x,s.width-r-o));return{top:d,left:u,placedAbove:c}}function My({onDismiss:t}){return e.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:999998,background:"transparent"}})}const X8=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBackdrop:My},Symbol.toStringTag,{value:"Module"}));function Iy({match:t,onOpen:s}){return e.jsxs("button",{onClick:()=>s(t),style:{width:"100%",textAlign:"left",padding:"6px 8px",background:"rgba(88, 166, 255, 0.12)",color:"inherit",border:"1px solid rgba(88, 166, 255, 0.4)",borderRadius:4,cursor:"pointer",fontFamily:"monospace",fontSize:11},children:[e.jsx("div",{style:{fontWeight:600},children:t.endpoint}),e.jsx("div",{style:{opacity:.85},children:t.jsonPath})]})}const Q8=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchButton:Iy},Symbol.toStringTag,{value:"Module"}));function Dy({matches:t,onOpen:s}){return e.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},children:t.map((n,r)=>e.jsx("li",{children:e.jsx(Iy,{match:n,onOpen:s})},`${n.endpoint}${n.jsonPath}${r}`))})}const Z8=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchList:Dy},Symbol.toStringTag,{value:"Module"}));function Ly({clickedText:t,matches:s,corpusEmpty:n,onOpenInPanel:r}){return e.jsxs("div",{style:{padding:"8px 12px"},children:[e.jsxs("div",{style:{opacity:.7,marginBottom:6,wordBreak:"break-all"},children:["Clicked: ",e.jsx("code",{children:Fy(t,120)||"(empty)"})]}),n?e.jsx("div",{style:{opacity:.85},children:"No mocks were consumed on this page load yet."}):s.length===0?e.jsx("div",{style:{opacity:.85},children:"No direct mock value matches — this value may be computed or concatenated."}):e.jsx(Dy,{matches:s,onOpen:r})]})}function Fy(t,s){return t.length<=s?t:t.slice(0,s-1)+"…"}const e7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBody:Ly,truncate:Fy},Symbol.toStringTag,{value:"Module"}));function zy({onDismiss:t}){return e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--border-muted, #374151)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontWeight:600},children:"Data source"}),e.jsx("button",{onClick:t,"aria-label":"Dismiss",style:{background:"transparent",color:"inherit",border:"none",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}const t7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardHeader:zy},Symbol.toStringTag,{value:"Module"})),Ac=320,Oc=320,$P=8;function $y({clickedText:t,matches:s,anchor:n,onOpenInPanel:r,onDismiss:a,corpusEmpty:o}){l.useEffect(()=>{function h(p){p.key==="Escape"&&a()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[a]);const i=typeof window<"u"?window.innerHeight:800,c=typeof window<"u"?window.innerWidth:1200,{top:d,left:u}=zP(n,{width:c,height:i},{width:Ac,maxHeight:Oc,gap:$P});return e.jsxs(e.Fragment,{children:[e.jsx(My,{onDismiss:a}),e.jsxs("div",{style:{position:"fixed",top:d,left:u,width:Ac,maxHeight:Oc,zIndex:999999,background:"var(--bg-surface, #1f2937)",color:"var(--text-primary, #f3f4f6)",border:"1px solid var(--border-muted, #374151)",borderRadius:8,boxShadow:"0 10px 30px rgba(0,0,0,0.5)",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:12,overflow:"auto"},role:"dialog","aria-label":"Mock data source inspector",children:[e.jsx(zy,{onDismiss:a}),e.jsx(Ly,{clickedText:t,matches:s,corpusEmpty:o,onOpenInPanel:r})]})]})}const s7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCard:$y},Symbol.toStringTag,{value:"Module"}));function By({healthy:t,reason:s,authNeeded:n}){const r=n?"auth-needed":t===!0?"healthy":t===!1?"unhealthy":"unknown",o={healthy:{bg:"#1f3a24",border:"#2f6b3a",dot:"#4ade80",label:"Live"},unhealthy:{bg:"#3a1f1f",border:"#6b2f2f",dot:"#f87171",label:"Stale"},unknown:{bg:"#2a2a2a",border:"#444",dot:"#9ca3af",label:"—"},"auth-needed":{bg:"#3a2f1f",border:"#6b552f",dot:"#fbbf24",label:"Sign in"}}[r];return e.jsxs("div",{role:"status","aria-label":`Live preview iframe: ${r}`,title:r==="auth-needed"?"Live Preview runs on a separate secured host that needs sign-in. Open it top-level to sign in, then reload.":r==="healthy"?"Live Preview iframe is healthy and matches the running dev server.":r==="unhealthy"?s?`Live Preview iframe is stale: ${s}`:"Live Preview iframe is stale and out of sync with the dev server.":"Live Preview iframe health unknown.",style:{position:"absolute",top:8,right:8,display:"inline-flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:999,backgroundColor:o.bg,border:`1px solid ${o.border}`,color:"#fff",fontSize:11,fontFamily:"monospace",zIndex:30,pointerEvents:"auto"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:o.dot,boxShadow:r==="healthy"?`0 0 6px ${o.dot}`:void 0}}),e.jsx("span",{children:o.label})]})}const n7=Object.freeze(Object.defineProperty({__proto__:null,LiveIframeHealthPill:By},Symbol.toStringTag,{value:"Module"}));function qy(){const{projectDir:t,inContainer:s,loaded:n}=qc();if(!n||t===null)return null;const r=s===null?null:s?"in the cloud container":"on this machine";return e.jsxs("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:["Connected to the editor server at ",e.jsx("code",{children:t}),r?`, running ${r}`:"","."]})}const r7=Object.freeze(Object.defineProperty({__proto__:null,ConnectionIdentityLine:qy},Symbol.toStringTag,{value:"Module"}));function Hy({hint:t,onRecheck:s}){const n=()=>{var r;(r=navigator.clipboard)==null||r.writeText(t.flag)};return e.jsx("div",{role:"dialog","aria-label":"Preview port forward required",className:"absolute inset-0 z-40 flex items-center justify-center p-8",style:{background:"var(--bg-surface)"},children:e.jsxs("div",{className:"flex max-w-md flex-col items-start gap-4 rounded-lg border border-l-4 p-6",style:{background:"var(--bg-base)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("path",{d:"M4 12h6"}),e.jsx("path",{d:"M14 12h6"}),e.jsx("path",{d:"M17 9l3 3-3 3"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.5"})]}),e.jsxs("span",{className:"text-base font-semibold",children:["Forward port ",t.port," to see the Live Preview"]})]}),e.jsxs("p",{className:"text-sm",style:{color:"var(--text-dim)"},children:["This app routes on the client, so its preview is served from its own origin on port ",t.port,". Your connection forwards the editor port only, so that origin isn’t reachable from this browser. Add this to your SSH tunnel, then reload:"]}),e.jsx("code",{className:"w-full rounded px-3 py-2 text-sm",style:{background:"var(--bg-surface)",color:"var(--text-primary)"},children:t.flag}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",onClick:n,className:"rounded px-3 py-2 text-sm font-medium",style:{background:"var(--accent-primary)",color:"var(--bg-base)"},children:"Copy forward flag"}),e.jsx("button",{type:"button",onClick:s,className:"rounded border px-3 py-2 text-sm",style:{borderColor:"var(--border-default)",color:"var(--text-primary)"},children:"I’ve forwarded it — reload preview"})]}),e.jsx(qy,{})]})})}const a7=Object.freeze(Object.defineProperty({__proto__:null,PreviewForwardPortNotice:Hy},Symbol.toStringTag,{value:"Module"}));function Wy(t){if(!t)return null;let s;try{s=new URL(t)}catch{return null}if(!(s.hostname==="localhost"||s.hostname==="127.0.0.1"||s.hostname==="[::1]"||s.hostname==="::1"))return null;const r=Number(s.port);return!Number.isInteger(r)||r<=0||r>65535?null:{port:r,flag:`-L ${r}:localhost:${r}`}}function Rc(t,s){return(s==null?void 0:s.previewOrigin)??(t==null?void 0:t.previewOrigin)??null}function Gy(t,s){if(!t||!/^https?:\/\//i.test(t))return!0;const n=typeof window<"u"?window.location.origin:null;if(!n)return!1;try{return new URL(t).origin===n}catch{return!0}}async function BP(t,s){if(Gy(t))return"unknown";try{return(await fetch(t,{credentials:"include",redirect:"manual",mode:"no-cors"})).type==="opaqueredirect"?"needs-signin":"authed"}catch{return Wy(t)?"unreachable":"unknown"}}function qP(t,s){const[n,r]=l.useState("unknown"),[a,o]=l.useState(0),i=l.useCallback(async()=>{const d=await BP(t);r(u=>(u==="needs-signin"&&d==="authed"&&o(h=>h+1),d)),d!=="unknown"&&!bt()&&nC(d==="needs-signin"?t??null:null)},[t]);l.useEffect(()=>{i()},[i,s]);const c=l.useCallback(()=>{i()},[i]);return{authState:n,recheck:c,remountNonce:a}}function Ec(t){if(!t||typeof t!="object")return null;const s=t;return{componentName:s.componentName??null,sourceFile:s.sourceFile??null,lineNumber:s.lineNumber??null,detectionMethod:s.detectionMethod??"dom-heuristics",ancestors:Array.isArray(s.ancestors)?s.ancestors:[],propsNames:Array.isArray(s.propsNames)?s.propsNames:[],element:s.element}}function HP(t){const[s,n]=l.useState(!1),[r,a]=l.useState(null),[o,i]=l.useState(null),c=l.useRef(!1),d=l.useCallback(f=>{const m=t.current;m!=null&&m.contentWindow&&m.contentWindow.postMessage({type:f},"*")},[t]),u=l.useCallback(()=>{n(!0),a(null),i(null),d("codeyam:debug:activate")},[d]),h=l.useCallback(()=>{n(!1),a(null),i(null),d("codeyam:debug:deactivate")},[d]),p=l.useCallback(()=>{i(null)},[]);return l.useEffect(()=>{function f(m){!m.data||typeof m.data.type!="string"||(m.data.type==="codeyam:debug:hover"?a(Ec(m.data.payload)):m.data.type==="codeyam:debug:selected"&&i(Ec(m.data.payload)))}return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[]),l.useEffect(()=>{c.current&&!s&&(c.current=!1),s&&(c.current=!0)},[s]),{isActive:s,hoveredElement:r,selectedElement:o,activate:u,deactivate:h,clearSelection:p}}const WP=/^\/api\/mock-panel(\/.*)?$/;function GP(t,s){return t.toUpperCase()!=="GET"?!1:WP.test(s)}function UP(t){return Array.isArray(t)?t.filter(s=>s.consumedThisPageLoad&&!GP(s.method,s.pathPattern)).map(s=>({endpoint:`${s.method} ${s.pathPattern}`,body:s.body})):[]}async function YP(t,s,n){return(await fetch("/api/debug/create-plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:t,componentName:s.componentName,sourceFile:s.sourceFile,lineNumber:s.lineNumber,detectionMethod:s.detectionMethod,element:s.element,previewUrl:n})})).json()}const VP=12;function KP(t,s,n){if(s.length===0)return[];const r=[];return go(t,s,n,"$",0,new Set,r),r}function JP(t,s){const n=[];for(const o of t)for(const i of KP(o.body,s,o.endpoint))n.push(i);const r=new Set,a=[];for(const o of n){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 go(t,s,n,r,a,o,i){if(t==null)return;const c=typeof t;if(c==="string"||c==="number"||c==="boolean"){String(t)===s&&i.push({endpoint:n,jsonPath:r,matchedValue:String(t),pathDepth:a});return}if(!(a>=VP)&&!o.has(t)){if(o.add(t),Array.isArray(t))for(let d=0;d<t.length;d++)go(t[d],s,n,`${r}[${d}]`,a+1,o,i);else if(c==="object")for(const[d,u]of Object.entries(t))go(u,s,n,`${r}.${d}`,a+1,o,i);o.delete(t)}}const XP={backgroundColor:"#1e1e1e",backgroundImage:"conic-gradient(#262626 25%, #1e1e1e 0 50%, #262626 0 75%, #1e1e1e 0)",backgroundSize:"16px 16px"};function Uy({buildingScenarioName:t,buildingScenarioSlug:s,buildingScenarioDescription:n,buildingScreenshotPath:r,containerHeight:a,containerRef:o,containerWidth:i,currentHeight:c,currentWidth:d,emptyStateMessage:u,isFilled:h,onDismissBuildingOverlay:p,historicalScreenshotPath:f,historicalScenarioName:m,historicalHeading:b,historicalSubtext:g,onDismissHistoricalPreview:x,previewSlug:y,previewUrl:v,previewOrigin:j,scale:w,commandNonce:_}){var Gs,Xe;const S=!!m&&!s,C=!!s||S,N=l.useRef(null),T=o??N,O=l.useRef(null),{status:k,restart:D}=fw();K3(k,D);const{isRestarting:$,isFailed:B,isStarting:q,isStopped:P}=xP(k),{stepState:E}=_n(),A=kP((E==null?void 0:E.step)??null,(E==null?void 0:E.mode)??"ui"),H=(k==null?void 0:k.liveIframeHealthy)!==void 0,{reloadNonce:z,handleIframeLoad:G,handleIframeError:Q}=Q3((k==null?void 0:k.pid)??null,H,k==null?void 0:k.status),se=(k==null?void 0:k.status)==="failed",{healthy:le,failedProbeCount:re,reloadNonce:U,invalidate:ge}=rP(v,se),ie=X3(k==null?void 0:k.liveIframeHealthy,750),be=dP(le,ie),[K,L]=l.useState(0);l.useEffect(()=>gw(()=>{L(Ie=>Ie+1)}),[]),hP(k==null?void 0:k.sourceVersion,k==null?void 0:k.liveReloadEnabled);const{authState:I,recheck:F,remountNonce:te}=qP(j,v),W=l.useMemo(()=>Wy(j),[j]),Y=uP({pidNonce:z,probeNonce:U+be,draftNonce:K+te}),V=Y.gatedNonce,{errors:pe,clear:ue}=mP(O,V),{escaped:ve,overlayErrors:Z,noteFrameLoad:Te,clearEscape:ae}=V3({previewUrl:v,resetKey:V,capturedErrors:pe}),xe=bP(v,V),Ne=l.useCallback(()=>{Y.reset(),ue(),ae(),ge()},[Y,ue,ae,ge]),je=l.useCallback(()=>{ue(),ae()},[ue,ae]),Oe=l.useCallback(()=>To(),[]),Be=(k==null?void 0:k.devServerStartedSecsAgo)??null,et=Be!==null&&Be<yP,xt=!!(k!=null&&k.startCommand),Ce=iP({liveIframeHealthy:ie,previewReachable:(Gs=k==null?void 0:k.previewProbe)==null?void 0:Gs.reachable}),[ht,as]=l.useState(!1);l.useEffect(()=>{Ce&&!ht&&as(!0)},[Ce,ht]);const Bt=Ce||ht,qe=lP({hasDevServerConfigured:xt,hasServed:Bt}),yt=qe?v:"about:blank",Tt=ty(yt,V,_),[qt,os]=l.useState(null),is=qe&&qt!==Tt,He=vP({hasDevServerConfigured:xt,probeHealthy:le,backendRunning:(k==null?void 0:k.status)==="running",backendIframeHealthy:ie,isStarting:q,isRestarting:$,isFailed:B,isStopped:P,isPrePrototype:A,withinStartupGrace:et,previewReachable:((Xe=k==null?void 0:k.previewProbe)==null?void 0:Xe.reachable)===!0,hasEverServed:Bt}),ye=l.useRef(void 0);l.useEffect(()=>{var vt;if(ye.current===He)return;const Ie=ye.current;ye.current=He,console.debug(`[preview-overlay] ${Ie===void 0?"(init)":Ie??"none"} → ${He??"none"}`,{status:k==null?void 0:k.status,intendedRunning:k==null?void 0:k.intendedRunning,restartCount:k==null?void 0:k.restartCount,pid:k==null?void 0:k.pid,liveIframeHealthy:k==null?void 0:k.liveIframeHealthy,previewProbeReachable:(vt=k==null?void 0:k.previewProbe)==null?void 0:vt.reachable,devServerStartedSecsAgo:Be,withinStartupGrace:et,probeHealthy:le,isStarting:q,isRestarting:$,isFailed:B,isStopped:P})},[He,k,Be,et,le,q,$,B,P]);const _e=k==null?void 0:k.portDiagnostic,We=(_e==null?void 0:_e.conflict)===!0,ke=He==="scaffolding"?CP((E==null?void 0:E.step)??null,(E==null?void 0:E.mode)??"ui").body:void 0,Ee=aP({active:He==="reconnecting",trigger:re}),M=He==="reconnecting"?oP(Ee):null,Ve=ke??M??void 0,ct=re>=10,{isActive:we,hoveredElement:dt,selectedElement:Pe,activate:Ke,deactivate:Je,clearSelection:Ge}=HP(O),Me=l.useCallback(()=>{we?Je():Ke()},[we,Ke,Je]),{entries:ot}=bw(y??null),{isActive:Se,toggle:Sn}=J3({activate:Ke,deactivate:Je,clearSelection:Ge},z);l.useEffect(()=>(xl({isActive:Se,previewSlug:y??null}),()=>{xl({isActive:!1,previewSlug:null})}),[Se,y]),l.useEffect(()=>xw(()=>{Sn()}),[Sn]);const Ht=Se&&Pe?Pe.element.text.trim():"",Ss=l.useMemo(()=>UP(ot),[ot]),Nn=l.useMemo(()=>!Se||!Ht?[]:JP(Ss,Ht),[Se,Ht,Ss]),Cn=l.useCallback(async Ie=>{Ge(),Je();try{const ls=await(await fetch("/api/scenarios")).json(),Ns=Array.isArray(ls)?ls.find(Us=>Us.componentName===Ie):null;if(Ns!=null&&Ns.slug){const Us=Li(window.location),Vr=vb(Ns.slug,Us,null,0,j);window.history.pushState(null,"",Vr);return}}catch{}window.history.pushState(null,"","/entities")},[Ge,Je,j]),Pn=l.useCallback(async(Ie,vt)=>{try{await YP(Ie,vt,v),Ge(),Je()}catch(ls){console.error("Failed to create debug plan:",ls)}},[v,Ge,Je]);return e.jsx("div",{ref:T,className:`relative flex-1 flex overflow-hidden ${h?"":"items-center justify-center p-8"}`,style:h?{backgroundColor:"#fff"}:XP,children:v?e.jsxs(e.Fragment,{children:[e.jsx(ny,{ref:O,currentHeight:c,currentWidth:d,isFilled:h,previewUrl:yt,scale:w,iframeKey:Tt,onLoad:()=>{if(qe){const Ie=Te(O.current);G(Ie??v),os(Tt)}},onError:Q}),!qe&&e.jsx(ey,{hasDevServerConfigured:xt}),is&&e.jsx(ry,{}),!h&&e.jsx(my,{previewUrl:v,description:n}),!h&&e.jsx(By,{healthy:ie,reason:(k==null?void 0:k.iframeLastError)??null,authNeeded:I==="needs-signin"}),I==="needs-signin"&&j&&e.jsx(du,{previewOrigin:j,onRecheck:F}),I==="unreachable"&&W&&e.jsx(Hy,{hint:W,onRecheck:F}),we&&e.jsx(Ry,{hoveredElement:dt}),Se&&e.jsx(Ey,{}),Pe&&!Se&&e.jsx(Ay,{element:Pe,previewUrl:v,onClose:Ge,onGoToIsolated:Cn,onCreatePlan:Pn}),Pe&&Se&&e.jsx($y,{clickedText:Ht,matches:Nn,anchor:Pe.element.boundingBox,corpusEmpty:Ss.length===0,onOpenInPanel:Ie=>{yw({routeKey:Ie.endpoint,jsonPath:Ie.jsonPath}),Ge()},onDismiss:Ge}),!C&&e.jsx(_y,{isActive:we,onToggle:Me,interactionAvailable:Gy(j)}),se?e.jsx(jy,{lastError:(k==null?void 0:k.lastError)??(k==null?void 0:k.lastExit)??"(no error message captured)",failureCount:(k==null?void 0:k.failureCount)??0,failedAtMs:k==null?void 0:k.failedAtMs,holder:k==null?void 0:k.holder,onRetry:D,onReap:async()=>{await fetch("/api/editor-dev-server/reap",{method:"POST",headers:{"Content-Type":"application/json"}})}}):We&&_e?e.jsx(wy,{diagnostic:_e,onRetry:D}):He&&(He==="crashed"?e.jsx(vy,{logs:(k==null?void 0:k.logs)??[]}):e.jsx(iy,{variant:He,restartCount:(k==null?void 0:k.restartCount)??0,showRetry:ct,onRetry:He==="disconnected"?Oe:ge,bodyOverride:Ve})),e.jsx(py,{tripped:Y.tripped||ve,errors:Z,recentReloads:Y.recentReloads,serverHealthy:jP(k),onRetry:Ne,onClear:je}),xe.clickThroughBroken&&xe.status!==null&&e.jsx(ay,{url:v,status:xe.status,logLines:xe.logLines,onRetry:Ne}),s&&p&&e.jsx(fo,{containerHeight:a,containerWidth:i,onDismiss:p,scenarioName:t??null,screenshotPath:r??null,viewportHeight:c,viewportWidth:d}),S&&x&&e.jsx(fo,{containerHeight:a,containerWidth:i,heading:b??void 0,subtext:g??void 0,onDismiss:x,scenarioName:m??null,screenshotPath:f??null,viewportHeight:c,viewportWidth:d})]}):e.jsx(Zx,{message:u})})}const o7=Object.freeze(Object.defineProperty({__proto__:null,PreviewCanvas:Uy},Symbol.toStringTag,{value:"Module"}));function Yy({prompt:t}){const[s,n]=l.useState(!0);return e.jsxs("section",{"aria-label":"What you asked for",style:{border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"0.875rem 1rem",marginBottom:"1.5rem",background:"var(--bg-elevated)",fontFamily:"'IBM Plex Mono', monospace"},children:[e.jsxs("button",{type:"button",onClick:()=>n(r=>!r),"aria-expanded":s,style:{width:"100%",background:"transparent",border:"none",padding:0,margin:0,color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"inherit"},children:[e.jsx("span",{children:"What you asked for"}),e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",transition:"transform 150ms ease",transform:s?"rotate(0deg)":"rotate(-90deg)",color:"var(--text-muted)",fontSize:"0.75rem"},children:"▾"})]}),s?e.jsx("div",{style:{marginTop:"0.625rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",color:"var(--text-secondary)",fontSize:"0.8125rem",lineHeight:1.55},children:e.jsx($t,{children:t})}):null]})}const i7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDescriptionCard:Yy},Symbol.toStringTag,{value:"Module"}));function Vy({html:t,viewport:s}){return e.jsxs("div",{children:[e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Your chosen design"}),e.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:"6px",overflow:"hidden"},children:e.jsx(Wi,{html:t,url:"",title:"Chosen design",viewport:s,theme:"light",darkVars:null})})]})}const l7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupChosenMockup:Vy},Symbol.toStringTag,{value:"Module"}));function Ky({assets:t}){return e.jsxs("div",{children:[e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Design assets you added"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},children:t.map(s=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",padding:"0.5rem 0.625rem",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-input)"},children:[e.jsx("span",{style:{fontSize:"0.8125rem",fontWeight:500,color:"var(--text-primary)"},children:s.filename}),s.description.trim().length>0&&e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:s.description})]},s.filename))})]})}const c7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignAssetList:Ky},Symbol.toStringTag,{value:"Module"}));function Jy({mockupHtml:t,mockupViewport:s,assets:n}){const r=t!==null,a=n.length>0;return!r&&!a?null:e.jsxs("section",{"aria-label":"Your chosen design",style:{border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"0.875rem 1rem",marginBottom:"1.5rem",background:"var(--bg-elevated)",fontFamily:"'IBM Plex Mono', monospace"},children:[r&&e.jsx("div",{style:{marginBottom:a?"1rem":0},children:e.jsx(Vy,{html:t,viewport:s})}),a&&e.jsx(Ky,{assets:n})]})}const d7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignCard:Jy},Symbol.toStringTag,{value:"Module"}));function Xy(){return e.jsxs("header",{style:{marginBottom:"1.5rem",fontFamily:"'IBM Plex Mono', monospace"},children:[e.jsxs("h1",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-primary)",margin:"0 0 0.5rem 0",display:"flex",alignItems:"baseline",gap:"0.5rem"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-muted)",letterSpacing:"-0.1em"},children:"::"}),"Setting up your project…"]}),e.jsx("p",{style:{margin:0,color:"var(--text-muted)",fontSize:"0.8125rem"},children:"This usually takes a few minutes."})]})}const u7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupHeader:Xy},Symbol.toStringTag,{value:"Module"}));function QP(t,s){if(t.phaseSteps.length===0)return"pending";const n=t.phaseSteps[0],r=t.phaseSteps[t.phaseSteps.length-1];return s>r?"complete":s>=n?"active":"pending"}const bo="#D7FF63",ZP="var(--text-muted)";function Qy({status:t}){return t==="complete"?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:[e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:"#FFFFFF",strokeWidth:"1.5"}),e.jsx("path",{d:"M5.5 9.2 L8 11.5 L12.5 6.5",fill:"none",stroke:"#FFFFFF",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]}):t==="active"?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",role:"img","aria-label":"In progress",style:{flexShrink:0,display:"block",animation:"codeyam-setup-spin 1.1s linear infinite"},children:[e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:bo,strokeWidth:"1.5",opacity:"0.25"}),e.jsx("path",{d:"M9 1.5 A 7.5 7.5 0 0 1 16.5 9",fill:"none",stroke:bo,strokeWidth:"1.75",strokeLinecap:"round"})]}):e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:ZP,strokeWidth:"1.5"})})}function Zy({phase:t,status:s}){const n=s==="active"?bo:s==="complete"?"var(--text-primary)":"var(--text-muted)";return e.jsxs("li",{"data-phase-id":t.phaseId,"data-phase-status":s,style:{display:"flex",alignItems:"center",gap:"0.625rem"},children:[e.jsx(Qy,{status:s}),e.jsx("span",{style:{color:n,fontSize:"0.8125rem",fontFamily:"'IBM Plex Mono', monospace",fontWeight:s==="active"?600:400,letterSpacing:"0.01em"},children:t.phaseLabel})]})}const h7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressRow:Zy,StatusIndicator:Qy},Symbol.toStringTag,{value:"Module"}));function ev({currentStep:t,mode:s}){const n=tk(s);return e.jsx("section",{"aria-label":"Progress",style:{marginBottom:"0.5rem"},children:e.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:"0.875rem"},children:n.map(r=>{const a=QP(r,t);return e.jsx(Zy,{phase:r,status:a},r.phaseId)})})})}const p7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressList:ev},Symbol.toStringTag,{value:"Module"}));function e5(t){let s=t;const n=s.match(/^Feature: [^\n]*\n\nProject context: /);return n?s=s.slice(n[0].length):s.startsWith("Project context: ")&&(s=s.slice(17)),s.endsWith(`
206
- `)&&(s=s.slice(0,-1)),s}function tv({prompt:t,currentStep:s,mode:n,mockupHtml:r=null,mockupViewport:a="desktop",assets:o=[]}){return e.jsxs("div",{style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"1.5rem 1.75rem",maxWidth:"520px"},children:[e.jsx(Xy,{}),e.jsx(Yy,{prompt:e5(t)}),e.jsx(Jy,{mockupHtml:r,mockupViewport:a,assets:o}),e.jsx(ev,{currentStep:s,mode:n})]})}const m7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewView:tv},Symbol.toStringTag,{value:"Module"}));function t5(){const[t,s]=l.useState(null),[n,r]=l.useState("desktop"),[a,o]=l.useState([]);return l.useEffect(()=>{let i=!1;async function c(){try{const u=await fetch("/api/editor-design-selection");if(!u.ok)return;const h=await u.json();if(!h||typeof h.filename!="string"||!h.filename)return;const p=await fetch("/api/editor-design-selected-mockup");if(!p.ok)return;const f=await p.text();if(i||!f)return;s(f),r(qi(f)??"desktop")}catch{}}async function d(){try{const u=await fetch("/api/editor-design-assets");if(!u.ok)return;const h=await u.json();!i&&Array.isArray(h.assets)&&o(h.assets)}catch{}}return c(),d(),()=>{i=!0}},[]),{mockupHtml:t,mockupViewport:n,assets:a}}function sv(){const{prompt:t}=Xx(),{stepState:s}=_n(),{mockupHtml:n,mockupViewport:r,assets:a}=t5();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:e.jsx(tv,{prompt:t??"",currentStep:(s==null?void 0:s.step)??1,mode:(s==null?void 0:s.mode)??"ui",mockupHtml:n,mockupViewport:r,assets:a})})})}const f7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewPane:sv},Symbol.toStringTag,{value:"Module"}));function s5(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-terminal`}function n5(t,s,n=1500){if(t<=0)return!1;const r=s-t;return r>=0&&r<=n}function nv({assistantTyping:t}){return e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{children:"Shared setup terminal — you and the assistant both drive this shell."}),t&&e.jsx("span",{className:"rounded px-2 py-0.5",style:{background:"rgba(215, 255, 99, 0.15)",color:"#8fae00",border:"1px solid rgba(215, 255, 99, 0.4)"},children:"Assistant is typing…"})]})}const g7=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalHeader:nv},Symbol.toStringTag,{value:"Module"})),r5=1200,a5=1e3,o5=["\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
207
- `);function rv(){const t=bt(),s=l.useRef(null),n=l.useRef(null),r=l.useRef(null),a=l.useRef(null),o=l.useRef(!1),i=l.useRef(!1),c=l.useRef(null),[d,u]=l.useState(!1),[h,p]=pi(1200);function f(m){const b=a.current;(b==null?void 0:b.readyState)===WebSocket.OPEN&&b.send(new TextEncoder().encode(m))}return hi(s,()=>{if(r.current&&n.current){r.current.fit();const m=a.current;(m==null?void 0:m.readyState)===WebSocket.OPEN&&m.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))}}),l.useEffect(()=>{if(t)return;let m=!1;const b=async()=>{try{const x=await fetch("/api/setup-terminal/activity");if(!x.ok)return;const y=await x.json();if(m)return;u(n5(y.lastInjectMs??0,Date.now()))}catch{}};b();const g=window.setInterval(b,a5);return()=>{m=!0,window.clearInterval(g)}},[t]),l.useEffect(()=>{if(!s.current||o.current)return;o.current=!0,i.current=!1;const m=new ko.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),b=new So.FitAddon;m.loadAddon(b),m.open(s.current),n.current=m,r.current=b;const g=No(m,s.current,{onCopy:()=>p()}),x=Co(m,{sendInput:f});if(requestAnimationFrame(()=>{b.fit(),m.focus()}),t)return m.write(o5),u(!0),()=>{x(),g(),m.dispose(),o.current=!1};const y=()=>{if(i.current)return;const v=new WebSocket(s5());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,r5))}};return y(),m.onData(f),()=>{var v;i.current=!0,c.current!==null&&window.clearTimeout(c.current),(v=a.current)==null||v.close(),x(),g(),m.dispose(),o.current=!1}},[t]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[e.jsx(nv,{assistantTyping:d}),e.jsx("div",{ref:s,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var m;return(m=n.current)==null?void 0:m.focus()}}),h&&e.jsx(zr,{})]})}const b7=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalPane:rv},Symbol.toStringTag,{value:"Module"}));function i5(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-browser`}function l5(t){let s;try{s=JSON.parse(t)}catch{return null}if(typeof s!="object"||s===null)return null;const n=s;if(n.type!=="frame"||typeof n.data!="string")return null;const r=typeof n.w=="number"?n.w:0,a=typeof n.h=="number"?n.h:0;return{src:`data:image/jpeg;base64,${n.data}`,width:r,height:a}}function c5(t){const s=t.paneWidth>0&&t.frameWidth>0?t.frameWidth/t.paneWidth:1,n=t.paneHeight>0&&t.frameHeight>0?t.frameHeight/t.paneHeight:1;return JSON.stringify({kind:"mouse",event:t.event,x:Math.round(t.paneX*s),y:Math.round(t.paneY*n),button:"left",clickCount:1})}function d5(t,s,n=1500){if(t<=0)return!1;const r=s-t;return r>=0&&r<=n}function Xs(t,s){const n=`<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800" viewBox="0 0 1280 800">
208
- <rect width="1280" height="800" fill="#0b0d12"/>
209
- <rect width="1280" height="56" fill="#11141b"/>
210
- <text x="28" y="35" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="20" font-weight="700">${s}</text>
211
- ${t}
212
- </svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(n)}`}function pt(t,s,n,r,a){return`
213
- <text x="${t}" y="${s}" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">${r}</text>
214
- <rect x="${t}" y="${s+10}" width="${n}" height="40" rx="6" fill="#171b24" stroke="#2a303c"/>
215
- <text x="${t+14}" y="${s+36}" fill="#e7e9ee" font-family="ui-monospace, monospace" font-size="15">${a}</text>`}const u5={hosting:Xs(`
216
- <text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="28" font-weight="700">Production Deployment</text>
217
- <rect x="28" y="160" width="1224" height="120" rx="10" fill="#12161f" stroke="#232a36"/>
218
- <circle cx="60" cy="220" r="8" fill="#3ecf8e"/>
219
- <text x="82" y="212" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="17">my-app.vercel.app</text>
220
- <text x="82" y="238" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">Ready · deployed 2m ago · main@a1b2c3d</text>
221
- <rect x="28" y="320" width="360" height="44" rx="8" fill="#D7FF63"/>
222
- <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:Xs(`
223
- <text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">DNS Records — codeyam.com</text>
224
- ${pt(28,180,300,"Type","CNAME")}
225
- ${pt(360,180,420,"Name","www")}
226
- ${pt(812,180,440,"Value","cname.vercel-dns.com")}
227
- ${pt(28,280,300,"Type","A")}
228
- ${pt(360,280,420,"Name","@")}
229
- ${pt(812,280,440,"Value","76.76.21.21")}
230
- <rect x="28" y="380" width="220" height="44" rx="8" fill="#D7FF63"/>
231
- <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:Xs(`
232
- <rect x="440" y="200" width="400" height="380" rx="14" fill="#12161f" stroke="#232a36"/>
233
- <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>
234
- ${pt(472,300,336,"Email","you@example.com")}
235
- ${pt(472,380,336,"Password","••••••••••")}
236
- <rect x="472" y="470" width="336" height="44" rx="8" fill="#4c7fff"/>
237
- <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:Xs(`
238
- <text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">App Information</text>
239
- ${pt(28,180,560,"Name","CodeYam")}
240
- ${pt(620,180,632,"Subtitle","Build code and data scenarios together")}
241
- ${pt(28,280,1224,"Promotional Text","See your app in every state, before you ship it.")}
242
- <rect x="28" y="400" width="200" height="44" rx="8" fill="#4c7fff"/>
243
- <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:Xs(`
244
- <rect x="0" y="56" width="1280" height="3" fill="#D7FF63"/>
245
- <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")},h5={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 p5(t){return u5[t]}function m5(t){return h5[t]}function av({address:t,assistantNavigating:s,onBack:n,onForward:r,onReload:a,onStop:o}){const i={background:"var(--bg-input, #2a2a2a)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",borderRadius:4,width:24,height:22,cursor:"pointer",fontSize:12};return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Shared setup browser — you and the assistant both control this window."}),s&&e.jsx("span",{className:"rounded px-2 py-0.5",style:{background:"rgba(215, 255, 99, 0.15)",color:"#8fae00",border:"1px solid rgba(215, 255, 99, 0.4)"},children:"Assistant is navigating…"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",style:i,onClick:n,title:"Back","aria-label":"Back",children:"‹"}),e.jsx("button",{type:"button",style:i,onClick:r,title:"Forward","aria-label":"Forward",children:"›"}),e.jsx("button",{type:"button",style:i,onClick:a,title:"Reload","aria-label":"Reload",children:"↻"}),e.jsx("div",{className:"flex-1 truncate rounded px-2 py-0.5",style:{background:"var(--bg-input, #1e1e1e)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",fontFamily:"'IBM Plex Mono', monospace"},title:t,children:t||"about:blank"}),e.jsx("button",{type:"button",style:i,onClick:o,title:"Stop","aria-label":"Stop",children:"✕"})]})]})}const x7=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserHeader:av},Symbol.toStringTag,{value:"Module"})),f5=1200,g5=1e3;function ov({demo:t="hosting",address:s,assistantNavigating:n,disconnected:r=!1}={}){const o=bt()||n!==void 0||r,i=l.useRef(null),c=l.useRef(null),d=l.useRef(!1),u=l.useRef(null),h=l.useRef({width:0,height:0}),[p,f]=l.useState(o?p5(t):null),[m,b]=l.useState(s??(o?m5(t):"")),[g,x]=l.useState(n??!1),[y,v]=l.useState(!1);l.useEffect(()=>{if(o)return;let w=!1;const _=async()=>{try{const C=await fetch("/api/setup-browser/activity");if(!C.ok)return;const N=await C.json();if(w)return;x(d5(N.lastActMs??0,Date.now()))}catch{}};_();const S=window.setInterval(_,g5);return()=>{w=!0,window.clearInterval(S)}},[o]),l.useEffect(()=>{if(o)return;d.current=!1;const w=()=>{if(d.current)return;const _=new WebSocket(i5());c.current=_,_.onopen=()=>v(!0),_.onmessage=S=>{if(typeof S.data!="string")return;const C=l5(S.data);C&&(h.current={width:C.width,height:C.height},f(C.src))},_.onclose=()=>{v(!1),!d.current&&(u.current=window.setTimeout(w,f5))}};return w(),()=>{var _;d.current=!0,u.current!==null&&window.clearTimeout(u.current),(_=c.current)==null||_.close()}},[o]);function j(w,_){const S=c.current;if(!S||S.readyState!==WebSocket.OPEN)return;const C=_.currentTarget.getBoundingClientRect();S.send(c5({event:w,paneX:_.clientX-C.left,paneY:_.clientY-C.top,paneWidth:C.width,paneHeight:C.height,frameWidth:h.current.width,frameHeight:h.current.height}))}return e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[e.jsx(av,{address:m,assistantNavigating:g,onReload:()=>b(m)}),e.jsx("div",{ref:i,className:"flex-1 flex items-center justify-center overflow-hidden",style:{background:"#0b0d12",minHeight:0},children:r?e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center px-6",children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:"The shared browser session was stopped."}),e.jsx("button",{type:"button",className:"rounded px-3 py-1.5",style:{background:"#D7FF63",color:"#0b0d12",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Relaunch shared browser"})]}):p?e.jsx("img",{src:p,alt:"Shared setup browser viewport",className:"max-w-full max-h-full",style:{objectFit:"contain"},draggable:!1,onMouseDown:w=>j("mousePressed",w),onMouseUp:w=>j("mouseReleased",w)}):e.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:y?"Waiting for the first frame…":"Connecting to the shared browser…"})})]})}const y7=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserPane:ov},Symbol.toStringTag,{value:"Module"}));function iv({onDismiss:t}){return e.jsxs("div",{role:"status",className:"flex items-start justify-between gap-3 border-b border-[var(--accent-amber,#d97706)] bg-[var(--accent-amber,#d97706)]/10 px-4 py-2 text-sm text-[var(--accent-amber,#d97706)]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold",children:"This app uses client-side routing"}),e.jsxs("div",{className:"text-xs opacity-90",children:["The Live Preview is served from the"," ",e.jsx("code",{children:"/__codeyam_preview"})," subpath, which a client-side router cannot serve correctly on a reload or a deep link. In-app navigation works, but reloading may land on the wrong route. To fix it, set"," ",e.jsx("code",{children:"sameOriginSafe: false"})," in"," ",e.jsx("code",{children:".codeyam/stack.json"})," — the preview then runs on its own dedicated origin."]})]}),e.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss client-routing advisory",className:"shrink-0 rounded border border-[var(--accent-amber,#d97706)] px-2 py-1 text-xs hover:bg-[var(--accent-amber,#d97706)] hover:text-white",children:"Dismiss"})]})}const v7=Object.freeze(Object.defineProperty({__proto__:null,ClientRoutingAdvisory:iv},Symbol.toStringTag,{value:"Module"})),b5="Seed failed — DB state is unknown",x5="Preview capture failed — the app's data was seeded";function lv({error:t,kind:s,onRetry:n}){const r=s==="device"?x5:b5;return e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 border-b border-[var(--accent-red)] bg-[var(--accent-red)]/10 px-4 py-2 text-sm text-[var(--accent-red)]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold",children:r}),e.jsx("div",{className:"truncate text-xs opacity-90",children:t})]}),n?e.jsx("button",{type:"button",onClick:n,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 j7=Object.freeze(Object.defineProperty({__proto__:null,SeedErrorBanner:lv},Symbol.toStringTag,{value:"Module"}));function cv({label:t="Loading scenario..."}={}){return e.jsx("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-[var(--bg-deep)]/90 backdrop-blur-sm text-[var(--text-muted)]",children:t})}const w7=Object.freeze(Object.defineProperty({__proto__:null,SeedLoadingOverlay:cv},Symbol.toStringTag,{value:"Module"}));function dv(t){return t.state==="preflight-running"||t.state==="booting-simulator"||t.state==="simulator-booted"||t.state==="building-app"}const y5=1500;function uv({stackId:t,pollMs:s=y5,onStateChange:n}={}){const[r,a]=l.useState({state:"idle"}),[o,i]=l.useState(!1),c=l.useRef(n);c.current=n,l.useEffect(()=>{let h=!1,p=!0;const f=async()=>{var b;try{const g=await fetch("/api/simulator-status");if(!g.ok)return;const x=await g.json();if(h||!p)return;const{history:y,...v}=x;a(v),(b=c.current)==null||b.call(c,v)}catch{}};f();const m=window.setInterval(f,s);return()=>{h=!0,p=!1,window.clearInterval(m)}},[s]);const d=l.useCallback(async()=>{if(!o){i(!0);try{const h=t?JSON.stringify({stack_id:t}):"{}";await fetch("/api/start-simulator",{method:"POST",headers:{"content-type":"application/json"},body:h})}finally{i(!1)}}},[t,o]),u=o||dv(r);return{status:r,posting:o,buttonDisabled:u,start:d}}function hv({stderrTail:t,onClose:s}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},onClick:s,children:e.jsxs("div",{className:"max-w-2xl w-full max-h-[80vh] overflow-auto rounded p-4 font-mono text-xs",style:{background:"var(--bg-elevated)",color:"var(--text-primary)"},onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("strong",{children:"Build logs (stderr tail)"}),e.jsx("button",{type:"button",onClick:s,className:"opacity-70 hover:opacity-100",children:"✕"})]}),e.jsx("pre",{className:"whitespace-pre-wrap",children:t||"(no stderr captured)"})]})})}const _7=Object.freeze(Object.defineProperty({__proto__:null,BuildLogsModal:hv},Symbol.toStringTag,{value:"Module"}));function xo({stackId:t,pollMs:s,onStateChange:n}){const[r,a]=l.useState(!1),{status:o,start:i,buttonDisabled:c}=uv({stackId:t,pollMs:s,onStateChange:n}),d=o.state==="app-launched";return e.jsxs("div",{className:"flex items-center gap-3 text-sm",style:{color:"var(--text-primary)"},children:[e.jsx("button",{type:"button",onClick:i,disabled:c,className:"px-3 py-1 rounded font-medium disabled:opacity-40 disabled:cursor-not-allowed",style:d?{background:"var(--surface-raised)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",opacity:.7}:{background:"var(--accent-primary)",color:"var(--bg-deep)"},children:d?"Restart simulator":"Start simulator"}),e.jsx(pv,{status:o}),o.state==="build-failed"?e.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-xs underline opacity-80 hover:opacity-100",children:"see logs"}):null,r&&o.state==="build-failed"?e.jsx(hv,{stderrTail:o.stderrTail,onClose:()=>a(!1)}):null]})}function pv({status:t}){const s=Ui(t);return e.jsx("span",{className:"text-xs opacity-80","data-testid":"simulator-status-pill",children:s})}function Ui(t){switch(t.state){case"idle":return"No simulator running";case"preflight-running":return"Pre-flight checks…";case"preflight-failed":return`Pre-flight failed: ${t.check} — ${t.message}`;case"booting-simulator":return`Booting ${t.device}…`;case"simulator-booted":return`Simulator booted (${t.name})`;case"building-app":return`Building (${mv(t.elapsedSec)})…`;case"build-failed":return"Build failed";case"app-launched":return`App running ▸${t.appBundleId!=="com.codeyam.android"?" (host proxy active)":""}`;case"stopped":return t.reason.kind==="user-requested"?"Stopped":t.reason.kind==="editor-server-shutdown"?"Editor server shut down":t.reason.code!=null?`Stopped (exit ${t.reason.code})`:"Stopped"}}function mv(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),n=t%60;return`${s}m ${n.toString().padStart(2,"0")}s`}const k7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorLauncherControls:xo,StatusPill:pv,formatElapsed:mv,pillText:Ui},Symbol.toStringTag,{value:"Module"}));function fv({stackId:t,pollMs:s,onStateChange:n}){const{status:r,start:a,buttonDisabled:o}=uv({stackId:t,pollMs:s,onStateChange:n}),i=dv(r);return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full px-6 text-center",style:{color:"var(--text-primary)"},children:[e.jsx("div",{className:"text-3xl","aria-hidden":"true",children:"📱"}),e.jsx("div",{className:"text-sm font-medium",children:"No simulator running yet"}),e.jsx("div",{className:"text-xs opacity-70",children:i?Ui(r):"Start it to preview this scenario on device."}),e.jsx("button",{type:"button",onClick:a,disabled:o,className:"px-3 py-1 rounded font-medium disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent-primary)",color:"var(--bg-deep)"},children:"Start simulator"})]})}const S7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorNotBootedPrompt:fv},Symbol.toStringTag,{value:"Module"}));function rr({src:t,currentHeight:s,currentWidth:n,isFilled:r,scale:a}){return r?e.jsx("img",{src:t,alt:"Simulator / Emulator preview",className:"w-full h-full object-contain",style:{background:"var(--bg-deep)"}}):e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:n,height:s,transform:a<1?`scale(${a})`:void 0,transformOrigin:"center center",flexShrink:0},children:e.jsx("img",{src:t,alt:"Simulator / Emulator preview",style:{width:"100%",height:"100%",background:"var(--bg-deep)",objectFit:"contain"}})})}const N7=Object.freeze(Object.defineProperty({__proto__:null,DeviceFrameImage:rr},Symbol.toStringTag,{value:"Module"}));function xr({currentWidth:t,currentHeight:s,isFilled:n,scale:r,title:a,hint:o}){const i=e.jsx("div",{className:"w-full h-full border border-dashed rounded flex items-center justify-center text-center px-6",style:{borderColor:"var(--border-default)",background:"var(--bg-surface)",color:"var(--text-dim)"},children:e.jsxs("div",{className:"text-sm leading-relaxed",children:[e.jsx("div",{className:"font-medium",children:a}),e.jsx("div",{className:"opacity-70 mt-1",children:o})]})});return n?i:e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:t,height:s,transform:r<1?`scale(${r})`:void 0,transformOrigin:"center center",flexShrink:0},children:i})}const C7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorFrameNotice:xr},Symbol.toStringTag,{value:"Module"}));function gv({currentWidth:t,currentHeight:s,isFilled:n,scale:r,variant:a}){const o=a==="xcode-missing"?"Xcode/Android tooling not detected":"No simulator / emulator running",i=a==="xcode-missing"?"Install Xcode or Android SDK + command line tools, then boot a device.":"Boot a simulator or emulator to see the live preview.";return e.jsx(xr,{currentWidth:t,currentHeight:s,isFilled:n,scale:r,title:o,hint:i})}const P7=Object.freeze(Object.defineProperty({__proto__:null,NoBootedSimulatorPlaceholder:gv},Symbol.toStringTag,{value:"Module"})),v5=1500;function bv(t=v5){const[s,n]=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||n({available:(i==null?void 0:i.available)===!0,loading:!1,capturedAtMs:typeof(i==null?void 0:i.capturedAtMs)=="number"?i.capturedAtMs:null})}).catch(()=>{r||n(i=>({available:i.available,loading:!1,capturedAtMs:i.capturedAtMs}))})};a();const o=window.setInterval(a,t);return()=>{r=!0,window.clearInterval(o)}},[t]),s}const j5=700;function xv({currentHeight:t,currentWidth:s,isFilled:n,scale:r,pollMs:a=j5,onError:o,deviceLabel:i="iOS Simulator",scenarioScreenshotSrc:c=null,bootState:d}){const u=kb({pollMs:a,paused:!!c||!!d,onError:o}),{state:h,frameToken:p}=d??u,f=bv();if(c)return e.jsx(rr,{src:c,currentWidth:s,currentHeight:t,isFilled:n,scale:r});if(h.kind==="no-device"||h.kind==="xcode-missing"){if(!f.loading&&f.available){const b=f.capturedAtMs!=null?`/api/preview-capture?cb=${f.capturedAtMs}`:"/api/preview-capture";return e.jsx(rr,{src:b,currentWidth:s,currentHeight:t,isFilled:n,scale:r})}return e.jsx(gv,{currentWidth:s,currentHeight:t,isFilled:n,scale:r,variant:h.kind})}if(h.kind==="loading")return e.jsx(xr,{currentWidth:s,currentHeight:t,isFilled:n,scale:r,title:`Connecting to the ${i}…`,hint:"Waiting for the first live frame."});if(h.kind==="capture-failed")return e.jsx(xr,{currentWidth:s,currentHeight:t,isFilled:n,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=${p}`;return e.jsx(rr,{src:m,currentWidth:s,currentHeight:t,isFilled:n,scale:r})}const T7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorPreviewFrame:xv},Symbol.toStringTag,{value:"Module"}));function yv({emptyStateMessage:t,projectSetupInProgress:s,previewSlug:n,previewUrl:r,viewports:a,activeViewport:o,onViewportChange:i,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:h,currentWidth:p,currentHeight:f,onCustomSizeChange:m,buildingScenarioSlug:b,buildingScreenshotPath:g,buildingScenarioName:x,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:j,historicalScenarioName:w,historicalHeading:_,historicalSubtext:S,onDismissHistoricalPreview:C,previewSeeding:N,previewSeedError:T,previewSeedErrorKind:O,onRetrySeed:k,currentScenario:D,scenarioGroups:$,onShowScenarioPreview:B,commandNonce:q,previewOrigin:P,isNarrow:E=!1,onBack:A,onPlanChange:H,onDesignConfirmed:z}){const[G,Q]=l.useState(!1),se=!!A,re=(D?Eo(D,$??[]):[]).length>1,[U,ge]=l.useState(!0),[ie,be]=l.useState(!1),K=se?U:ie,L=se?ge:be,I=se||re,F=K&&!!D&&(se||re),[te,W]=l.useState({state:"idle"}),{containerRef:Y,containerSize:V,scale:pe}=iC({currentHeight:f,currentWidth:p,isFilled:u}),ue=_b(),Z=mC(P===bs),[Te,ae]=l.useState(!1);l.useEffect(()=>{bt()||sC(T??null)},[T]);const xe=bC(D,o),Ne=xe?ns(xe,D==null?void 0:D.screenshotCapturedAtMs):null,je=ia(ue.kind),Oe=!!Ne,Be=kb({paused:!je||Oe}),et=Be.state.kind==="no-device"||Be.state.kind==="xcode-missing",xt=ue.fallbackKind==="iframe"&&ue.fallbackPort!==null,Ce=je&&!Oe&&xt&&et,ht=ue.fallbackPort??0,Bt=(D?wb(D,ht,P):"")||Fi("/",{appPort:ht,currentPort:typeof window<"u"?Li(window.location):0,previewOrigin:P}),qe=r?Di(r):"",yt=qe==="/results"||qe.startsWith("/results/"),Tt=qe==="/plan-preview",qt=qe==="/design-exploration",os=qe==="/setup-terminal",is=qe==="/setup-browser";if(os)return e.jsx(rv,{});if(is)return e.jsx(ov,{});if(Tt)return e.jsx(Qx,{});if(yt)return e.jsx(Bb,{});if(qt)return e.jsx(Ax,{onDesignConfirmed:z});if(s&&!r&&!ue.loading&&!ia(ue.kind))return e.jsx(sv,{});const He=te.state==="app-launched";return e.jsxs("div",{"data-preview-pane":"true",className:"flex-1 flex flex-col min-w-0",children:[e.jsx(Vx,{viewports:a,active:o,onChange:i,currentWidth:p,currentHeight:f,previewUrl:r,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:h,containerWidth:(V==null?void 0:V.width)??null,containerHeight:(V==null?void 0:V.height)??null,onCustomSizeChange:m,currentScenario:D??null,scenarioGroups:$??[],onShowScenarioPreview:B??(()=>{}),onCreateStateRequest:()=>Q(!0),isNarrow:E,onBack:A,onPlanChange:H,onToggleStatesModal:I?()=>L(ye=>!ye):void 0,statesModalOpen:K}),T?e.jsx(lv,{error:T,kind:O,onRetry:k}):null,Z&&!Te?e.jsx(iv,{onDismiss:()=>ae(!0)}):null,F&&D?e.jsx(od,{currentScenario:D,scenarioGroups:$??[],onSelect:ye=>(B??(()=>{}))(ye),onCreateNew:()=>Q(!0),onClose:()=>L(!1)}):null,e.jsxs("div",{className:"relative flex-1 flex flex-col min-h-0",children:[je&&!Ce?e.jsxs(e.Fragment,{children:[e.jsx(Ox,{deviceLabel:la(ue.kind),actions:e.jsx(xo,{onStateChange:W})}),e.jsx("div",{ref:Y,className:"relative flex-1 flex overflow-hidden items-center justify-center p-8",style:{backgroundColor:"#1e1e1e"},children:He?e.jsx(xv,{currentHeight:f,currentWidth:p,isFilled:u,scale:pe,deviceLabel:la(ue.kind),scenarioScreenshotSrc:Ne,bootState:Be}):e.jsx(fv,{onStateChange:W})})]}):e.jsxs(e.Fragment,{children:[Ce?e.jsx(cu,{deviceLabel:la(ue.kind),actions:e.jsx(xo,{})}):null,e.jsx(Uy,{containerRef:Y,containerHeight:V==null?void 0:V.height,containerWidth:V==null?void 0:V.width,currentHeight:f,currentWidth:p,emptyStateMessage:t??"Select a scenario to preview",isFilled:u,previewSlug:Ce?(D==null?void 0:D.slug)??n:n,previewUrl:Ce?Bt:r,previewOrigin:P,scale:pe,buildingScenarioSlug:b,buildingScreenshotPath:g,buildingScenarioName:x,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:j,historicalScenarioName:w,historicalHeading:_,historicalSubtext:S,onDismissHistoricalPreview:C,commandNonce:q})]}),N?e.jsx(cv,{label:ia(ue.kind)?"Loading scenario on device…":void 0}):null]}),G?e.jsx(qb,{onClose:()=>Q(!1)}):null]})}const A7=Object.freeze(Object.defineProperty({__proto__:null,PreviewPanel:yv},Symbol.toStringTag,{value:"Module"})),yo="reset";function vv({busy:t,onCancel:s,onConfirm:n}){const[r,a]=l.useState(""),o=r.trim().toLowerCase()===yo;return l.useEffect(()=>{const i=c=>{c.key==="Escape"&&!t&&s()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t,s]),e.jsx("div",{role:"presentation",onClick:()=>{t||s()},style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:24},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Cancel build and reset everything?",onClick:i=>i.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(440px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Cancel build & reset everything?"}),e.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:["This stops the current build, clears the editor session, and"," ",e.jsx("strong",{style:{color:"var(--accent-red)"},children:"permanently discards uncommitted code changes"})," ","(back to the current commit). This cannot be undone."]})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:6,color:"var(--text-secondary)",fontSize:12},children:["Type ",e.jsx("strong",{style:{color:"var(--text-primary)"},children:yo})," to confirm",e.jsx("input",{type:"text",value:r,disabled:t,autoFocus:!0,"data-testid":"reset-confirm-input",onChange:i=>a(i.target.value),style:{padding:"8px 10px",background:"var(--bg-input, #0f0f0f)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontFamily:"inherit"}})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:s,disabled:t,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:t?"wait":"pointer",opacity:t?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:n,disabled:t||!o,"data-testid":"reset-confirm-button",style:{padding:"8px 18px",background:"var(--accent-red, #ff5c5c)",color:"#fff",border:"1px solid var(--accent-red, #ff5c5c)",borderRadius:6,fontSize:13,fontWeight:600,cursor:t?"wait":o?"pointer":"not-allowed",opacity:t||!o?.5:1,fontFamily:"inherit"},children:t?"Resetting…":"Reset everything"})]})]})})}const O7=Object.freeze(Object.defineProperty({__proto__:null,RESET_CONFIRM_WORD:yo,ResetBuildConfirmModal:vv},Symbol.toStringTag,{value:"Module"}));function w5(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{scenariosVersion:i}=_s(),c=l.useCallback(async()=>{r(!0),o(null);try{const u=await fetch("/api/scenarios");if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=(await u.json()).map(_o);s(Dx(h))}catch(u){o(u instanceof Error?u.message:"Failed to load scenarios")}finally{r(!1)}},[]);l.useEffect(()=>{c()},[c,i]);const d=t.reduce((u,h)=>u+h.scenarios.length,0);return{groups:t,loading:n,error:a,totalScenarios:d,reload:c}}function _5(t){if(Array.isArray(t))return{entities:t,unsurfacedPages:[],componentSurfaceReason:null};if(t&&typeof t=="object"){const s=t;return{entities:Array.isArray(s.entities)?s.entities:[],unsurfacedPages:Array.isArray(s.unsurfacedPages)?s.unsurfacedPages:[],componentSurfaceReason:k5(s.componentSurfaceReason)}}return{entities:[],unsurfacedPages:[],componentSurfaceReason:null}}function k5(t){if(!t||typeof t!="object")return null;const s=t.kind;return s==="no-component-scenarios"||s==="missing-from-glossary"||s==="not-visual-components"?t:null}function S5(){const[t,s]=l.useState([]),[n,r]=l.useState([]),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(null),{scenariosVersion:h}=_s(),p=l.useCallback(async()=>{c(!0),u(null);try{const f=await fetch("/api/app-route-entities");if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=_5(await f.json());s(m.entities.map(b=>({...b,scenarios:Array.isArray(b==null?void 0:b.scenarios)?b.scenarios.map(_o):[]}))),r(m.unsurfacedPages),o(m.componentSurfaceReason)}catch(f){u(f instanceof Error?f.message:"Failed to load app routes"),s([]),r([]),o(null)}finally{c(!1)}},[]);return l.useEffect(()=>{p()},[p,h]),{routeEntities:t,unsurfacedPages:n,componentSurfaceReason:a,loading:i,error:d,reload:p}}function Mc(t){const s=new Map;for(const n of t){const r=N5(n.path);let a=s.get(r);a||(a=[],s.set(r,a));for(const o of n.tests)a.push({...o,file:n.path})}return Array.from(s.entries()).map(([n,r])=>({feature:n,tests:r})).filter(n=>n.tests.length>0).sort((n,r)=>n.feature.localeCompare(r.feature))}function N5(t){const n=t.replace(/\\/g,"/").replace(/^\.\//,"").split("/").filter(r=>r.length>0);return n.length===0?"Other":n[0]==="crates"&&n.length>=2?`crates/${n[1]}`:t==="(no-file)"?"(no-file)":n[0]}function jv(t,s){if(s===".")return t;const n=s.endsWith("/")?s:`${s}/`;return t.map(r=>({feature:r.feature,tests:r.tests.filter(a=>a.file.startsWith(n))})).filter(r=>r.tests.length>0)}function wv(t,s,n){return n==="backend"?[]:t.map(r=>({...r,scenarios:r.scenarios.filter(yr)})).filter(r=>r.scenarios.length>0)}function _v(t){let s=0,n=0,r=0,a=0,o=0;for(const i of t)for(const c of i.tests)o+=1,s+=1,c.status==="passed"?n+=1:c.status==="skipped"?a+=1:c.status==="failed"&&(r+=1);return{total:s,passed:n,failed:r,ignored:a,discovered:o}}function C5(t){return t.reduce((s,n)=>s+n.scenarios.length,0)}const P5=3e3;function T5(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(!1),[h,p]=l.useState(null),[f,m]=l.useState(null),[b,g]=l.useState(null),x=l.useRef(null),y=l.useRef(null),v=l.useRef(!1),j=l.useRef(null),{testsVersion:w}=_s(),_=l.useCallback(async(D=!1)=>{var P;(P=x.current)==null||P.abort();const $=new AbortController;x.current=$;const{signal:B}=$;D&&(v.current=!0,o(!0));const q=!D&&j.current!==null;q||(r(!0),c(null));try{if(!D&&!q)try{const z=await fetch("/api/test-results/summary",{signal:B});if(z.ok){const G=await z.json();G.running?p(G.currentRunner??null):G.stats&&(m(G.stats),g(G.coverage??null))}}catch{}let E,A;if(q){E=j.current;const z=await fetch("/api/test-results",{signal:B});if(!z.ok)throw new Error(`test-results: HTTP ${z.status}`);A=await z.json()}else if(D){const z=await fetch("/api/test-results/refresh",{method:"POST",signal:B});if(!z.ok)throw new Error(`test-results: HTTP ${z.status}`);A=await z.json(),E=j.current??[]}else{const[z,G]=await Promise.all([fetch("/api/tests",{signal:B}),fetch("/api/test-results",{signal:B})]);if(!z.ok)throw new Error(`tests: HTTP ${z.status}`);if(!G.ok)throw new Error(`test-results: HTTP ${G.status}`);E=Mc(await z.json()),A=await G.json(),j.current=E}if(p(A.currentRunner??null),A.running&&v.current){y.current=setTimeout(()=>_(!1),P5);return}const H=v.current;if(v.current=!1,H){const z=await fetch("/api/tests",{signal:B});z.ok&&(E=Mc(await z.json()),j.current=E)}s(E),u(A.cached??!1),g(A.coverage??null),m(null),r(!1),o(!1)}catch(E){if(E instanceof DOMException&&E.name==="AbortError")return;v.current=!1,c(E instanceof Error?E.message:"Failed to load tests"),r(!1),o(!1)}},[]);l.useEffect(()=>(j.current=null,_(),()=>{var D;(D=x.current)==null||D.abort(),y.current&&clearTimeout(y.current)}),[_,w]);const{total:S,passed:C,failed:N,ignored:T,discovered:O}=l.useMemo(()=>_v(t),[t]),k=l.useCallback(()=>{v.current||_(!0)},[_]);return{groups:t,loading:n,refreshing:a,error:i,cached:d,currentRunner:h,summaryStats:f,coverage:b,totalTests:S,passedTests:C,failedTests:N,ignoredTests:T,discoveredTests:O,reload:_,refresh:k}}function Yi(t,s){return t.filter(n=>n.appDir===s)}function kv(t,s){return s?t.find(n=>n.route===s)??null:null}function Sv(t,s,n,r=null){const a=wv(t,s,n);return R5(a,r)}function A5(t){const s=t.filter(o=>o.defaultScenarioSlug);if(s.length===0)return null;const n=s.find(o=>o.route==="/"&&o.defaultScenarioSlug);if(n!=null&&n.defaultScenarioSlug)return n.defaultScenarioSlug;const r=s.find(o=>o.defaultScenarioSlug&&o.scenarios.some(i=>vo(i)));if(r!=null&&r.defaultScenarioSlug)return r.defaultScenarioSlug;const a=[...s].sort((o,i)=>o.route.length-i.route.length||o.route.localeCompare(i.route))[0];return(a==null?void 0:a.defaultScenarioSlug)??null}function O5(t){return(t==null?void 0:t.defaultScenarioSlug)??null}function Nv(t,s,n=null){const r=t.find(a=>a.type==="web");return r?Sv(s,r.dir,r.type,n):null}function R5(t,s){const n=t.flatMap(d=>d.scenarios.filter(u=>yr(u)).map(u=>({route:d.route,scenario:u})));if(n.length===0)return null;const r=Un(n.filter(({route:d,scenario:u})=>d==="/"&&vo(u)),s);if(r)return r.scenario.slug;const a=Un(n.filter(({route:d})=>d==="/"),s);if(a)return a.scenario.slug;const o=Un(n.filter(({scenario:d})=>vo(d)),s);if(o)return o.scenario.slug;const i=Math.min(...n.map(({route:d})=>d.length)),c=Un(n.filter(({route:d})=>d.length===i),s);return(c==null?void 0:c.scenario.slug)??null}function Un(t,s){return t.find(({scenario:n})=>E5(n,s))??t[0]??null}function E5(t,s){return s?t.dimensions.length===0||t.dimensions.includes(s):!0}function vo(t){return/\bhome\b/i.test(t.name)}function Ic(t){return new Set(t.flatMap(s=>s.scenarios.map(n=>n.slug)))}function Na({selectedApp:t,appRouteEntities:s,scenarioGroups:n,defaultScreenSize:r=null}){return t?A5(s)??Sv(n,t.dir,t.type,r):null}function M5({apps:t,hasExplicitAppSelection:s,scenarioGroups:n,defaultScreenSize:r=null}){return s||t.length===0||n.length===0?null:Nv(t,n,r)}function Dc(t){return O5(t)}function I5({apps:t,routeEntities:s,selectedApp:n,appRouteEntities:r}){if(n)return r;const a=t.find(o=>o.type==="web");return a?Yi(s,a.dir):[]}function D5({previewRouteEntities:t,selectedRouteEntity:s}){var r;if(s!=null&&s.route)return s.route;if(t.length===0)return null;const n=t.find(a=>a.route==="/");return n?n.route:((r=[...t].sort((a,o)=>a.route.length-o.route.length||a.route.localeCompare(o.route))[0])==null?void 0:r.route)??null}function L5({previewRouteEntities:t,path:s}){var r;const n=Di(s);return((r=kv(t,n))==null?void 0:r.defaultScenarioSlug)??null}function F5(t){return t.startsWith("/scenario/")||tn(t)}function z5(t){return F5(t)?!1:t==="/"||t==="/apps"||t==="/apps/"}function $5(t,s,n=""){const r=ca(n),[a,o]=l.useState(r.selectedAppDir),[i,c]=l.useState(r.selectedEntityHash);l.useEffect(()=>{const v=ca(n);o(j=>j===v.selectedAppDir?j:v.selectedAppDir),c(j=>j===v.selectedEntityHash?j:v.selectedEntityHash)},[n]),l.useEffect(()=>{if(typeof window>"u"||t.length!==1)return;const v=ca(n);if(v.selectedAppDir||v.selectedEntityHash||!z5(n))return;const j=da(t[0].dir);`${window.location.pathname}${window.location.search}`!==j&&(window.history.replaceState({},"",j),o(t[0].dir))},[t,n]);const d=l.useMemo(()=>i?s.find(v=>Oa(v)===i)??null:null,[s,i]),u=l.useMemo(()=>a?t.find(v=>v.dir===a)??null:d?t.find(v=>v.dir===d.appDir)??null:i?t.find(v=>v.type==="web")??t[0]??null:null,[t,a,d,i]),h=l.useMemo(()=>u?Yi(s,u.dir):[],[s,u]),p=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(da(v))}function b(){o(null),c(null),f("/apps")}function g(v){const j=h.find(S=>S.route===v);if(!j)return;const w=Oa(j),_=Zc(j);!w||!_||(c(w),f(_))}function x(v){c(v),f(`/entities/${v}`)}function y(){c(null),f(a?da(a):"/apps")}return{selectedApp:u,appRouteEntities:h,selectedEntityHash:i,selectedRouteEntity:p,selectApp:m,deselectApp:b,selectRoute:g,selectEntity:x,deselectRoute:y}}function B5(t,s,n,r,a="",o=null,i=!0,c){const[d,u]=l.useState(null),h=l.useRef(!1),p=l.useRef(!1),{selectedApp:f,appRouteEntities:m,selectedEntityHash:b,selectedRouteEntity:g,selectApp:x,deselectApp:y,selectRoute:v,selectEntity:j,deselectRoute:w}=$5(t,s,a),_=l.useMemo(()=>Ic(m),[m]),S=l.useMemo(()=>Ic(g?[g]:[]),[g]),C=l.useMemo(()=>Na({selectedApp:f,appRouteEntities:m,scenarioGroups:n,defaultScreenSize:o}),[m,o,n,f]),N=l.useMemo(()=>Dc(g),[g]),T=l.useMemo(()=>f?jv(r,f.dir):[],[r,f]);l.useEffect(()=>{if(h.current)return;if(c!=null&&c.current){h.current=!0;return}if(!i)return;const P=M5({apps:t,scenarioGroups:n,hasExplicitAppSelection:!!f,defaultScreenSize:o});P&&(u(P),h.current=!0)},[t,o,n,f,i,c]),l.useEffect(()=>{if(f){if(p.current){p.current=!1;return}if(g){if(!N||d&&S.has(d))return;u(N);return}C&&(d&&_.has(d)||u(C))}},[C,N,d,f,_,g,S]);function O(P){x(P);const E=t.find(H=>H.dir===P);if(!E)return;const A=Na({selectedApp:E,appRouteEntities:Yi(s,E.dir),scenarioGroups:n,defaultScreenSize:o});u(A)}function k(){y(),u(Nv(t,n,o))}function D(P){v(P);const E=Dc(kv(m,P));u(E)}const $=l.useCallback(P=>{p.current=!0,u(P)},[]);function B(){if(w(),!f)return;const P=Na({selectedApp:f,appRouteEntities:m,scenarioGroups:n,defaultScreenSize:o});P&&u(P)}function q(P){j(P)}return{selectedApp:f,appRouteEntities:m,appTestGroups:T,selectedEntityHash:b,selectedRouteEntity:g,previewSlug:d,setPreviewSlug:u,setPreviewSlugExplicit:$,selectApp:O,deselectApp:k,selectRoute:D,selectEntity:q,deselectRoute:B}}const q5=1e3;function H5(t,s){const n=l.useRef(t);n.current=t;const r=l.useRef(s);r.current=s;const a=l.useRef(null),o=l.useRef(null);l.useEffect(()=>{let i=!0;async function c(){var d;if(i){try{const u=a.current,h=u===null?"/api/editor-commands":`/api/editor-commands?since=${u}`,p=await fetch(h);if(p.ok){const f=await p.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??[])n.current(m)}}catch{}i&&setTimeout(c,q5)}}return c(),()=>{i=!1}},[])}function W5(){const[t,s]=l.useState({}),[n,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;s(u),r(!1)}).catch(d=>{c||(o(d.message),r(!1))}),()=>{c=!0}},[]);const i=l.useMemo(()=>u0(t),[t]);return{graph:t,entityLookup:i,loading:n,error:a}}function G5(t){return t==="/design-exploration"}function U5(t,s,n){return t.startsWith("http")||t?t:n?`${n}/results`:`http://127.0.0.1:${s}/results`}function Y5(t,s,n){return t.startsWith("http")||t?t:n?`${n}/plan-preview`:`http://127.0.0.1:${s}/plan-preview`}function Cv(t,s){if(!s)return null;for(const n of t)for(const r of n.scenarios)if(r.slug===s||r.id===s)return r;return null}function V5({directPreviewPath:t,fallbackPreviewPath:s,previewKind:n,selectedScenario:r,port:a,previewOrigin:o}){return n==="blank"?"":t&&(n==="application"||n==="results"||n==="plan-preview")?n==="results"?U5(t,a,o):n==="plan-preview"?Y5(t,a,o):t.startsWith("http")||G5(t)?t:o?`${o}${t}`:`http://127.0.0.1:${a}${t}`:r?wb({slug:r.slug,scenarioType:r.scenarioType,componentName:r.componentName,url:r.url},a,o):s?s.startsWith("http")?s:o?`${o}${s}`:`http://127.0.0.1:${a}${s}`:""}function K5(t,s=Date.now()){const n=t.includes("?")?"&":"?";return`${t}${n}_cb=${s}`}function jo(t,s){if(!t)return null;for(const n of s)for(const r of n.scenarios)if(r.slug===t)return r;return null}function J5({apps:t,appRouteEntities:s,directPreviewPath:n,fallbackPort:r,previewKind:a,previewOrigin:o,previewSlug:i,routeEntities:c,scenarioGroups:d,selectedApp:u,selectedRouteEntity:h}){const p=Cv(d,i),f=I5({apps:t,routeEntities:c,selectedApp:u,appRouteEntities:s}),m=D5({previewRouteEntities:f,selectedRouteEntity:h});let b="blank";a==="plan-preview"&&n?b="plan-preview":a==="results"&&n?b="results":a==="application"&&n?b="application":p?b=yr(p)?"application":"component":m&&(b="application");const g=V5({directPreviewPath:n,fallbackPreviewPath:m,previewKind:b,selectedScenario:p,port:r,previewOrigin:o});return{selectedScenario:p,previewRouteEntities:f,fallbackPreviewPath:m,resolvedPreviewKind:b,basePreviewUrl:g}}function X5({allowEditorRoutePreview:t,command:s,configLoaded:n,previewRouteEntities:r,scenarioGroups:a,scenarioDeferAvailable:o=!1}){const i=s.dimension??null,c=!!s.dimension,d=s.commandNonce;if(s.scenarioSlug??s.scenarioId){const g=s.scenarioSlug??s.scenarioId,x=Cv(a,g);return x?{clearCustomSize:c,scenarioSlug:x.slug,type:"show-scenario",viewportName:i,commandNonce:d}:o?{clearCustomSize:c,type:"defer",viewportName:i,commandNonce:d}:s.path?{clearCustomSize:c,path:s.path,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d}:{clearCustomSize:c,scenarioSlug:g,type:"show-scenario",viewportName:i,commandNonce:d}}if(!s.path)return{clearCustomSize:c,type:"refresh",viewportName:i,commandNonce:d};const u=s.path,h=u.startsWith("http")?new URL(u).pathname:u.split("?")[0]??u,p=h==="/results"||h.startsWith("/results/"),f=h==="/plan-preview",m=jb(u);if(f)return{clearCustomSize:c,path:u,previewKind:"plan-preview",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(p)return{clearCustomSize:c,path:u,previewKind:"results",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(m&&!t)return{clearCustomSize:c,type:n?"ignore":"defer",viewportName:i,commandNonce:d};if(m&&t)return{clearCustomSize:c,path:u,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d};const b=L5({previewRouteEntities:r,path:u});return b?{clearCustomSize:c,scenarioSlug:b,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 Q5(t,s,n,r,a){const o=r.dimensions;return o.length===0||o.includes(t)&&s===null&&n===null?null:o.find(i=>a.some(c=>c.name===i))??o[0]}const Z5=[{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 e4(t,s){const n=Object.entries(t);if(n.length===0)return Z5;const r=n.map(([a,o])=>({name:a,width:o.width,height:o.height}));if(s){const a=r.findIndex(o=>o.name===s);if(a>0){const[o]=r.splice(a,1);r.unshift(o)}}return r}const t4=1500;function s4({enabled:t,pollMs:s=t4}){const[n,r]=l.useState(0),a=l.useRef(void 0);return l.useEffect(()=>{if(!t)return;let o=!1;const i=async()=>{try{const d=await fetch("/api/simulator-status");if(!d.ok)return;const u=await d.json();if(o)return;const h=u.state,p=a.current;a.current=h,h==="app-launched"&&p!==void 0&&p!=="app-launched"&&r(f=>f+1)}catch{}};i();const c=window.setInterval(i,s);return()=>{o=!0,window.clearInterval(c)}},[t,s]),n}function n4({isInIframe:t,hydrated:s=!0,persistedPath:n,previewKind:r,resolvedViewport:a,selectedScenario:o}){l.useEffect(()=>{t||!s||fetch("/api/editor-preview-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:r==="blank"?null:r,path:n,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(()=>{})},[s,t,n,r,a.height,a.name,a.width,o==null?void 0:o.id,o==null?void 0:o.slug])}function r4({deviceLaunchGeneration:t=0,isInIframe:s,onActivated:n,previewKind:r,previewMedium:a,scenariosLoaded:o,selectedScenario:i,seedRetryToken:c=0}){const[d,u]=l.useState(!1),[h,p]=l.useState(null),[f,m]=l.useState(null);return l.useEffect(()=>{if(!o||s)return;if(Qj({isInIframe:s,previewKind:r,previewMedium:a,selectedScenario:i})){fetch("/api/editor-deactivate-scenario",{method:"POST"}).catch(()=>{});return}if(!i||i.scenarioType!=="application")return;let b=!1;return u(!0),p(null),m(null),fetch("/api/editor-activate-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:i.slug})}).then(async g=>{const x=await g.json().catch(()=>null);if(!b){if(!x||x.success===!1||x.seedError||x.deviceSeedError){p(x&&(x.seedError||x.deviceSeedError||x.error)||"scenario activation failed"),x!=null&&x.seedError?m("seed"):x!=null&&x.deviceSeedError||x!=null&&x.error?m("device"):m(null);return}n()}}).catch(g=>{b||(p(g instanceof Error?g.message:String(g)),m(null))}).finally(()=>{b||u(!1)}),()=>{b=!0}},[t,c,s,n,r,a,o,i==null?void 0:i.componentName,i==null?void 0:i.scenarioType,i==null?void 0:i.slug]),{seeding:d,seedError:h,seedErrorKind:f}}const a4=3;function o4({apps:t,appRouteEntities:s,configLoaded:n,defaultScreenSize:r,hydrated:a=!0,port:o,previewMedium:i,previewOrigin:c,projectTitle:d,previewSlug:u,routeEntities:h,scenarioGroups:p,scenariosLoaded:f,screenSizes:m,selectedApp:b,selectedRouteEntity:g,setPreviewSlug:x}){const[y,v]=l.useState(r??"Desktop"),j=l.useRef(!1),[w,_]=l.useState(null),[S,C]=l.useState(null),[N,T]=l.useState(null),[O,k]=l.useState(null),[D,$]=l.useState(()=>Date.now()),[B,q]=l.useState(0),P=l.useRef(null),E=l.useRef(!1),A=l.useMemo(()=>e4(m,r),[r,m]);l.useEffect(()=>{j.current||r&&(v(r),j.current=!0)},[r]);const H=l.useMemo(()=>w!==null&&S!==null?{name:"Custom",width:w,height:S}:A.find(ae=>ae.name===y)??A[0]??{name:"Desktop",width:1440,height:900},[y,S,w,A]),z=bt(),G=d==="CodeYam Editor",{basePreviewUrl:Q,fallbackPreviewPath:se,previewRouteEntities:le,resolvedPreviewKind:re,selectedScenario:U}=l.useMemo(()=>J5({apps:t,appRouteEntities:s,directPreviewPath:N,fallbackPort:o,previewKind:O,previewOrigin:c,previewSlug:u,routeEntities:h,scenarioGroups:p,selectedApp:b,selectedRouteEntity:g}),[t,s,N,o,O,c,u,h,p,b,g]),ge=l.useMemo(()=>Q?K5(Q,D):"",[Q,D]),ie=l.useCallback(ae=>{v(ae),_(null),C(null)},[]),be=l.useCallback((ae,xe)=>{_(ae),C(xe)},[]),K=l.useCallback(ae=>{x(ae),T(null),k(null),$(Date.now());const xe=jo(ae,p);if(!xe)return;const Ne=Q5(y,w,S,xe,A);Ne!==null&&(v(Ne),_(null),C(null))},[y,S,w,p,x,A]),L=l.useCallback((ae,xe)=>{const Ne=(xe==null?void 0:xe.retriesLeft)??a4,je=X5({allowEditorRoutePreview:G,command:ae,configLoaded:n,previewRouteEntities:le,scenarioGroups:p,scenarioDeferAvailable:Ne>0});if(je.viewportName&&v(je.viewportName),je.clearCustomSize&&(_(null),C(null)),je.type==="show-scenario"){K(je.scenarioSlug),q(Oe=>Oe+1);return}if(je.type==="defer"){P.current={command:ae,retriesLeft:Ne};return}if(je.type==="refresh"){$(Date.now()),q(Oe=>Oe+1);return}je.type!=="ignore"&&(je.type==="show-path"&&(k(je.previewKind),T(je.path),E.current=je.preserveDirectPreviewPathOnSlugChange,typeof je.previewSlug=="string"?x(je.previewSlug):je.previewSlug===null&&x(null)),$(Date.now()),q(Oe=>Oe+1))},[n,G,le,p,x,K]);l.useEffect(()=>{if(!n)return;const ae=P.current;ae&&(P.current=null,L(ae.command,{retriesLeft:ae.retriesLeft-1}))},[n,p,L]),l.useEffect(()=>{if(!(!u||N===null)){if(E.current){E.current=!1;return}T(null),k(null),$(Date.now())}},[N,u]);const I=l.useMemo(()=>re==="results"||re==="plan-preview"?N:re==="application"?N??(U==null?void 0:U.url)??se:null,[N,se,re,U==null?void 0:U.url]),F=l.useCallback(()=>{$(Date.now())},[]),[te,W]=l.useState(0),Y=l.useCallback(()=>{W(ae=>ae+1)},[]);n4({isInIframe:z,hydrated:a,persistedPath:I,previewKind:re,resolvedViewport:H,selectedScenario:U?{id:U.id??null,slug:U.slug}:null});const pe=s4({enabled:i==="simulator-ios"||i==="simulator-android"}),{seeding:ue,seedError:ve,seedErrorKind:Z}=r4({deviceLaunchGeneration:pe,seedRetryToken:te,isInIframe:z,onActivated:F,previewKind:re,previewMedium:i,scenariosLoaded:f,selectedScenario:U?{slug:U.slug,scenarioType:U.scenarioType,componentName:U.componentName??null}:null}),Te=l.useCallback(ae=>{T(ae),k(ae?"application":null),$(Date.now())},[]);return{viewports:A,resolvedViewport:H,previewUrl:ge,handleViewportChange:ie,handleCustomSizeChange:be,showScenarioPreview:K,handlePreviewCommand:L,setPreviewPath:Te,previewSeeding:ue,previewSeedError:ve,previewSeedErrorKind:Z,retrySeed:Y,commandNonce:B}}function i4({isInIframe:t,scenariosLoaded:s,restoredRef:n,onAdopt:r,onHydrated:a,onSettledEmpty:o}){const i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(null),u=l.useRef(s);u.current=s;const h=l.useRef(r),p=l.useRef(a),f=l.useRef(o);h.current=r,p.current=a,f.current=o;const m=l.useCallback(()=>{if(c.current||!u.current||n.current)return;const b=d.current;b&&(c.current=!0,n.current=!0,h.current(b))},[n]);l.useEffect(()=>{t||i.current||(i.current=!0,fetch("/api/editor-preview-state").then(b=>b.json()).then(b=>{b&&(b.scenarioSlug||b.path)&&(d.current=b,m())}).catch(()=>{}).finally(()=>{var b;p.current(),!c.current&&!d.current&&((b=f.current)==null||b.call(f))}))},[t,m]),l.useEffect(()=>{m()},[s,m])}function l4({isInIframe:t,onConverge:s}){const n=l.useRef(s);n.current=s,l.useEffect(()=>{if(!t)return q3(()=>{fetch("/api/editor-preview-state").then(r=>r.json()).then(r=>{r&&(r.scenarioSlug||r.path)&&n.current(r)}).catch(()=>{}).finally(()=>{To()})})},[t])}function c4({restoredRef:t,initiallySettled:s=!1,apply:n}){const r=l.useRef(s),a=l.useRef(null),o=l.useRef(n);o.current=n;const i=l.useCallback(u=>{t.current||(u.scenarioSlug||u.path)&&(t.current=!0,o.current(u))},[t]),c=l.useCallback(u=>{if(!t.current){if(!r.current){a.current=u;return}i(u)}},[i,t]),d=l.useCallback(()=>{r.current=!0;const u=a.current;a.current=null,u&&i(u)},[i]);return{requestRestore:c,onAdoptSettledEmpty:d}}function d4(t,{handlePreviewCommand:s,handleCustomSizeChange:n}){!t.scenarioSlug&&!t.path||(s({...t.scenarioSlug?{scenarioSlug:t.scenarioSlug}:{},...t.path?{path:t.path}:{},...t.dimension?{dimension:t.dimension}:{}}),t.dimension==="Custom"&&typeof t.width=="number"&&typeof t.height=="number"&&n(t.width,t.height))}function u4(){const[t,s]=l.useState(!1),n=l.useCallback(()=>{s(!0)},[]),r=l.useCallback(()=>{},[]),a=l.useCallback(()=>{},[]),o=l.useCallback(()=>{s(!1)},[]);return{showPostPushModal:t,onFeatureCompleteCommand:n,onAgentIdle:r,onAgentActive:a,dismissModal:o}}function Pv(t){return t===null||t.slug===null||t.slug==="feature-complete"}function h4({showPostPushModal:t,stepState:s,dismissModal:n}){const r=l.useRef(!1);l.useEffect(()=>{if(!t){r.current=!1;return}if(Pv(s)){r.current=!0;return}r.current&&(s==null?void 0:s.slug)!=null&&(n(),r.current=!1)},[t,s,n])}function p4(){const[t,s]=l.useState(!1),n=l.useCallback(()=>{s(!0)},[]),r=l.useCallback(()=>{s(!1)},[]);return{showPlanCompleteModal:t,onPlanCompleteCommand:n,dismissPlanCompleteModal:r}}function m4(){const{showBuildTab:t}=Ri(typeof window>"u"?"/":window.location.pathname),{config:s}=St(),[n,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useCallback(async c=>{if(n)return!1;o(null),r(!0);try{try{await Ai()}catch{}const d=await fetch("/api/build/start-from-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:c})});if(!d.ok){let u=`HTTP ${d.status}`;try{const h=await d.json();h!=null&&h.error&&(u=h.error)}catch{}throw new Error(u)}return t(),await Oi({provider:s==null?void 0:s.provider}),!0}catch(d){return o(d instanceof Error?d.message:"Failed to launch build"),!1}finally{r(!1)}},[n,t,s==null?void 0:s.provider]);return{launching:n,error:a,launchPrompt:i}}function f4({onTransitionToLive:t}){const[s,n]=l.useState(!1),[r,a]=l.useState(null),o=l.useRef(!1),i=l.useRef(null),c=l.useRef(t);c.current=t;const d=l.useCallback(()=>{o.current=!0,n(!0)},[]),u=l.useCallback(()=>{o.current=!1,n(!1);const m=i.current;m&&(i.current=null,a(null),c.current(m))},[]),h=l.useCallback(m=>o.current?(i.current=m,a(m),!0):!1,[]),p=l.useCallback(()=>{i.current=null,a(null)},[]),f=l.useCallback(()=>{o.current=!1,n(!1),i.current=null,a(null)},[]);return{isAgentBuilding:s,isAgentBuildingRef:o,buildingScenarioSlug:r,onAgentIdle:u,onAgentActive:d,guardScenarioSelect:h,clearBuildingOverlay:p,forceIdle:f}}function g4({chatOpen:t}){const[s,n]=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)&&(n(!0),a(!1))}function c(d){o(d)&&(n(!1),a(!0))}return window.addEventListener("miniagent-agent-active",i),window.addEventListener("miniagent-agent-idle",c),()=>{window.removeEventListener("miniagent-agent-active",i),window.removeEventListener("miniagent-agent-idle",c)}},[]),l.useEffect(()=>{t||(n(!1),a(!1))},[t]),{planActive:s,planIdle:r}}function b4(t,s,n){return t.map(r=>{const a=jv(s,r.dir),o=wv(n,r.dir,r.type),{total:i,passed:c,failed:d,ignored:u,discovered:h}=_v(a),p=C5(o);return{app:r,tests:{total:i,passed:c,failed:d,ignored:u,discovered:h},scenarios:{total:p,thumbnails:x4(o)}}})}function x4(t){const s=[];for(const n of t)for(const r of n.scenarios)if(r.screenshotPaths.length>0&&s.push({path:r.screenshotPaths[0],cacheBuster:r.screenshotCapturedAtMs}),s.length>=6)return s;return s}function y4(t,s){return t==null?null:Math.min(1,Math.max(.04,t/oi(s)))}function v4(t,s){return t==null||t===0?null:`${t} / ${oi(s)}: ${ai(t,s)}`}const j4="Your app will display here once set up.",w4="Loading your app…",_4="Setting up your project…",k4="Select a scenario to preview",S4="No preview is available for this project.";function N4({configLoading:t,hasNoApps:s,hasStepState:n,hasPreviewableApp:r,setupInProgress:a,hasCaptureFrame:o}){return t?w4:a&&!o?_4:s&&!n?j4:r?k4:S4}const C4=["web","mobile"];function P4(t){return C4.includes(t)}function T4(t,s){return s?{scenarioSlug:t,path:s}:{scenarioSlug:t}}function A4(t,s){return t==="needs-login"&&!s}function O4(t,s){if(!t)return null;for(const n of s)for(const r of n.scenarios)if(r.name===t)return r;return null}const R4="The app is being edited",E4="Live preview will load when the build agent is idle",M4="Showing a saved version",I4="This is a past version of this scenario";function D4({shot:t,isLatest:s,liveScenario:n,isAgentBuilding:r}){if(s&&n&&!r)return{kind:"live",slug:n.slug};const[a,o]=r?[R4,E4]:[M4,I4];return{kind:"historical",screenshotPath:t.screenshotPath??null,scenarioName:t.name,heading:a,subtext:o}}function Tv(t){return!t.hasActiveSession&&!t.isAgentBuilding&&!t.showPostPushModal&&t.launchingPlanSlug===null&&!t.submittingBuildPrompt&&!t.stepStateFeature&&!t.buildLaunchModalDismissed}function L4(t){return t.activeTab==="build"&&Tv(t)}const F4=900*1e3;function z4(){const[t,s]=l.useState(null),n=l.useCallback(async()=>{try{const r=await fetch("/api/server/update-check");if(!r.ok)return;const a=await r.json();s(a)}catch{}},[]);return l.useEffect(()=>{n()},[n]),l.useEffect(()=>{const r=setInterval(()=>void n(),F4);return()=>clearInterval(r)},[n]),{update:t}}function $4(t,s,n){const[r,a]=l.useState(!1),o=l.useCallback(()=>{a(!0)},[]),i=l.useCallback(c=>{a(!1),s(c)},[s]);return l.useEffect(()=>{r&&(t||(a(!1),n==null||n(),s("build")))},[r,t,s,n]),{arm:o,navigateToTabUser:i,pendingBuildNav:r}}const B4=4e3,q4=2;function Av({state:t,provider:s,credsPresent:n=!0,cliInstalled:r=!0,scannedDirs:a=[],reason:o=null,expiresAt:i=null,probeInFlight:c=!1,probeAttempts:d=0,backendOutOfDate:u=!1,sessionOngoing:h=!1,onAuthenticated:p,onAuthorized:f}){const[m,b]=l.useState(!1),[g,x]=l.useState(!1),y=zt(s),[v,j]=l.useState(!1);l.useEffect(()=>{if(t!=="unknown"){j(!1);return}const C=window.setTimeout(()=>j(!0),B4);return()=>window.clearTimeout(C)},[t]);const w=l.useCallback(()=>{b(!1),p(),f==null||f()},[p,f]),_=l.useCallback(async()=>{x(!0);try{await fetch("/api/auth/refresh-cache",{method:"POST"}),p()}catch{}finally{x(!1)}},[p]);if(t==="authenticated")return null;const S=m?e.jsx(jw,{provider:s,onAuthenticated:w,onClose:()=>b(!1)}):null;if(t==="unknown"){const C=o==="probe-timeout"&&d>=q4,N=r===!1||o==="cli-not-found";return!C&&!N&&(c||!v)||u?null:N?e.jsxs("div",{"data-testid":"provider-auth-cli-not-found","data-auth-card":!0,className:"m-4 rounded-lg border border-[#3A3A3A] bg-[#1E1E1E] p-5 space-y-3",children:[e.jsxs("p",{className:"text-sm text-white font-medium",children:[y," CLI not found"]}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["We couldn't find the ",y," CLI on this machine — we searched your PATH and the standard install locations",a.length>0?e.jsxs(e.Fragment,{children:[" (",a.join(", "),")"]}):e.jsx(e.Fragment,{children:" (~/.local/bin, ~/.cargo/bin, /opt/homebrew/bin, /usr/local/bin)"}),". Install the ",y," CLI, or add the directory it lives in to your PATH, then recheck. This is a PATH/install problem — re-authenticating won't fix it."]}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("button",{onClick:()=>void _(),"data-testid":"provider-auth-cli-not-found-recheck",disabled:g,className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:g?"Rechecking…":"Recheck after installing"})})]}):e.jsxs("div",{"data-testid":"provider-auth-checking","data-auth-card":!0,className:"m-4 rounded-lg border border-[#3A3A3A] bg-[#1E1E1E] p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{"data-testid":"provider-auth-checking-spinner","aria-hidden":"true",className:"h-4 w-4 rounded-full border-2 border-[#8E8E8E] border-t-transparent animate-spin"}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["Checking your ",y," account… If this takes more than a few seconds, your token may need refresh."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>b(!0),"data-testid":"provider-auth-checking-retry",className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Authenticate"}),e.jsx("button",{onClick:()=>void _(),"data-testid":"provider-auth-checking-recheck",disabled:g,className:"px-3 py-2 text-sm rounded-md border border-[#3A3A3A] text-white cursor-pointer disabled:opacity-50",children:g?"Rechecking…":"Already logged in? Recheck"})]}),S]})}return e.jsx(vw,{provider:s,credsPresent:n,reason:o,expiresAt:i,sessionOngoing:h,onAuthenticated:p,onAuthorized:f})}const R7=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthGate:Av},Symbol.toStringTag,{value:"Module"}));function Ov({update:t}){const{copied:s,copy:n}=gn();if(!t||!t.available)return null;const r=t.channel==="desktop";return e.jsx("div",{className:"rounded-lg p-4","data-testid":"update-available-banner",role:"status",style:{background:"rgba(91, 155, 213, 0.16)",border:"1px solid rgba(91, 155, 213, 0.55)",borderLeft:"4px solid var(--blue-300)",boxShadow:"0 2px 10px rgba(91, 155, 213, 0.18)"},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-xl leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--blue-300)"},children:"↑"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[e.jsx("div",{className:"font-semibold mb-1",style:{color:"var(--blue-300)"},children:r?"Update ready":"Update available"}),r?e.jsx(e.Fragment,{children:"It will install automatically after your current session ends. To install now, use the Check for Updates menu."}):e.jsxs(e.Fragment,{children:["A new version of CodeYam Editor is available (",e.jsxs("span",{style:{color:"var(--text-strong)",fontWeight:600},children:[t.currentVersion," → ",t.latestVersion]}),"). Run"," ",e.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:t.upgradeCommand})," ","to upgrade."," ",e.jsx("button",{type:"button",className:"mt-2 inline-block rounded px-2.5 py-1 text-xs font-medium",style:{background:"var(--blue-300)",color:"#0b1220"},onClick:()=>void n(t.upgradeCommand??""),children:s?"Copied":"Copy command"})]})]})]})})}const E7=Object.freeze(Object.defineProperty({__proto__:null,UpdateAvailableBanner:Ov},Symbol.toStringTag,{value:"Module"})),H4=300,Lc=150;function W4(t){const[s,n]=l.useState(null),r=l.useRef(!1),[a,o]=l.useState(!1),i=l.useCallback(()=>{var u;return((u=t.current)==null?void 0:u.clientWidth)??1200},[t]),c=s??Math.floor(i()/2),d=l.useCallback(u=>{u.preventDefault(),r.current=!0,o(!0)},[]);return l.useEffect(()=>{const u=p=>{var g;if(!r.current)return;const f=((g=t.current)==null?void 0:g.getBoundingClientRect().left)??0,m=p.clientX-f,b=i();m<Lc?n(0):m>b-Lc?n(b):n(Math.max(H4,m))},h=()=>{r.current&&(r.current=!1,o(!1))};return document.addEventListener("mousemove",u),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h)}},[t,i]),{leftWidth:c,isDragging:a,handleMouseDown:d}}const G4=3e3;function U4({hot:t,isInIframe:s,reload:n=()=>window.location.reload(),sustainedDisconnectMs:r=G4}){return()=>{}}function Y4(){l.useEffect(()=>U4({hot:void 0,isInIframe:bt()}),[])}const V4=5e3;function Fc(t){return new Promise(s=>{let n=!1;const r=()=>{n||(n=!0,window.removeEventListener("miniagent-agent-idle",a),clearTimeout(o),s())},a=i=>{const c=i.detail;(c==null?void 0:c.chatName)==="plan"&&r()},o=setTimeout(r,t);window.addEventListener("miniagent-agent-idle",a)})}function K4(t){return ww()?Promise.resolve():new Promise(s=>{let n=!1;const r=()=>{n||(n=!0,window.removeEventListener("miniagent-ws-open",r),clearTimeout(a),s())},a=setTimeout(r,t);window.addEventListener("miniagent-ws-open",r,{once:!0})})}async function zc(){await K4(V4),on("\x1B"),await Fc(no),on("/clear\r"),await Fc(no),on("/codeyam-plan\r")}function J4(){fetch("/api/clear-build-agent-session",{method:"POST"}).catch(()=>{})}function X4(t){const s=l.useRef(null),n=l.useRef(null);l.useEffect(()=>{if(typeof document>"u")return;n.current||(n.current=document.createElement("canvas"),n.current.width=64,n.current.height=64);const r=document.querySelector('link[rel="icon"]');if(!r){X("favicon-redraw",{idle:t,hasIcon:!1});return}if(s.current||(s.current=r.href),!t){r.href=s.current,X("favicon-restore",{});return}X("favicon-redraw",{idle:!0,hasIcon:!0});const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{const o=n.current,i=o.getContext("2d");i.clearRect(0,0,64,64);const c=56,d=(64-c)/2;i.drawImage(a,d,d,c,c);const u=12,h=64-u-1,p=u+1;i.beginPath(),i.arc(h,p,u,0,2*Math.PI),i.fillStyle="#ef4444",i.fill(),r.href=o.toDataURL("image/png")},a.src=s.current},[t]),l.useEffect(()=>()=>{if(typeof document>"u")return;const r=document.querySelector('link[rel="icon"]');r&&s.current&&(r.href=s.current)},[])}const Q4=120*1e3,Rv=1500;class Z4{constructor(s,n,r=X){wt(this,"deferred",!1);wt(this,"userActiveSinceLastOutput",!1);wt(this,"lastActivitySource",null);wt(this,"lastActivityAt",null);wt(this,"lastNotificationTime",null);wt(this,"actions");wt(this,"env");wt(this,"now");wt(this,"log");this.actions=s,this.env=n,this.now=n.now??(()=>Date.now()),this.log=r}reportUserActivity(s){this.userActiveSinceLastOutput=!0,this.lastActivitySource=s,this.lastActivityAt=this.now()}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(s,n){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:n,hasBrowserFocus:r,msSinceLastNotification:a,userActiveSinceLastOutput:this.userActiveSinceLastOutput,lastActivitySource:this.lastActivitySource,msSinceLastActivity:o},c=o!==null&&o<Rv;if(n&&r&&c)return this.userActiveSinceLastOutput=!1,this.log("suppressed-user-active",i),"suppressed";if(a!==null&&a<Q4)return this.log("cooldown",i),"cooldown";const d=this.notify(s);return this.log(d==="played"?"notify-played":"notify-played-no-sound",i),d}onBuildTabChange(s,n){return!s&&this.deferred?(this.deferred=!1,this.notify(n),!0):!1}onActive(){const s=this.deferred;this.deferred=!1,this.log("on-active",{hadDeferred:s}),this.actions.closeSystemNotification(),this.log("system-notification-closed-on-active",{hadDeferred:s})}onUserEngagement(){const s=this.deferred;return this.deferred=!1,s}get isDeferred(){return this.deferred}notify(s){const n=!!(s!=null&&s.sound)&&s.sound!=="off";n?(this.actions.playSound(s.sound),this.log("sound-played",{soundId:s.sound})):this.log("sound-skipped-off",{});const r=this.env.hasBrowserFocus(),a=typeof Notification<"u"?Notification.permission:"unknown";return!r&&(s!=null&&s.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(),n?"played":"played-no-sound"}}function eT(t,s){return new Z4({playSound:Dp,showSystemNotification:()=>{if(typeof Notification>"u"||Notification.permission!=="granted")return;s.current&&s.current.close();const n=t.current,r=new Notification(`${n} is ready for you`,{body:`${n} has finished and is waiting for your input.`,tag:"build-agent-idle"});r.onclick=()=>{window.focus(),r.close(),s.current=null},s.current=r},closeSystemNotification:()=>{typeof Notification>"u"||s.current&&(s.current.close(),s.current=null)}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"})}function tT(t,s){return t==="hook-stop"?s.idleOnStop:s.idleOnNotification}const sT=600*1e3,nT=3e3;function rT({agentName:t,isBuildTabActive:s,isAgentBuilding:n,buildSessionLive:r,featureCompleteKey:a,navigateToTab:o,onAgentIdleImmediate:i,onAgentActiveImmediate:c}){const d=l.useRef(t);d.current=t;const u=l.useRef(s);u.current=s;const h=l.useRef(i);h.current=i;const p=l.useRef(c);p.current=c;const[f,m]=l.useState(Mp),[b,g]=l.useState(!1),x=l.useRef(!1);x.current=b;const y=l.useRef(!1),v=l.useRef(null),j=l.useRef(null),w=l.useRef(null),_=l.useRef(typeof document<"u"&&document.hidden?Date.now():null),S=l.useRef(null),C=l.useRef(r??!1);C.current=r??!1,X4(b),w.current||(w.current=eT(d,j));const N=l.useCallback(A=>{m(A),Ip(A)},[]),T=l.useCallback(A=>{v.current!==null&&(clearTimeout(v.current),v.current=null,X("debounce-cancelled",{trigger:A}))},[]),O=l.useCallback(A=>{x.current&&X("idle-cleared",{trigger:A}),g(!1),x.current=!1,S.current=null,j.current&&(j.current.close(),j.current=null)},[]),k=l.useCallback(A=>{var H;if(!tT(A,f)){X("idle-suppressed-by-pref",{source:A});return}X("ws-idle-received",{buildTabActive:u.current,source:A}),(H=h.current)==null||H.call(h),T("re-arm-on-idle"),v.current=setTimeout(()=>{var se;v.current=null;const z=_.current,G=z===null?null:Date.now()-z,Q=z!==null&&Date.now()-z>sT;X("debounce-resolved",{suppressedForOvernight:Q,msHidden:G,buildTabActive:u.current}),Q||(se=w.current)==null||se.onIdle(f,u.current),g(!0),x.current=!0,S.current=Date.now(),y.current=!1,X("agent-currently-idle-set",{suppressedForOvernight:Q}),u.current&&it()},Rv)},[f,T]),D=l.useCallback(()=>{var A,H,z;(A=p.current)==null||A.call(p),T("agent-active"),(H=w.current)==null||H.onActive(),(z=w.current)==null||z.resetActivityFlag(),x.current&&C.current&&S.current!==null&&Date.now()-S.current>nT&&O("remote-resume")},[T,O]),$=l.useCallback(()=>{var A,H;T("user-input"),x.current&&((A=w.current)==null||A.onUserEngagement(),(H=w.current)==null||H.reportUserActivity("terminal-input"),y.current=!0,O("user-input"))},[T,O]),B=l.useCallback(A=>{var H;A==="build"&&(T("navigate-build"),x.current&&((H=w.current)==null||H.onUserEngagement(),y.current=!0,O("navigate-build"))),o(A)},[o,T,O]),q=l.useCallback(()=>{var A;T("dismiss-banner"),(A=w.current)==null||A.onUserEngagement(),y.current=!0,O("dismiss-banner")},[T,O]),P=l.useCallback(()=>{var A;T("stop-building"),(A=w.current)==null||A.onUserEngagement(),y.current=!0,O("stop-building")},[T,O]);l.useEffect(()=>{function A(){var U;x.current&&(y.current||(T("ack-notification"),(U=w.current)==null||U.onUserEngagement(),y.current=!0,X("notification-acknowledged",{trigger:"user-return"})))}function H(U){var ge;x.current&&u.current&&document.hasFocus()&&(document.hidden||((ge=w.current)==null||ge.onUserEngagement(),y.current=!0,O(U)))}function z(U){var ge;document.hasFocus()&&A(),(ge=w.current)==null||ge.reportUserActivity(U)}const G=()=>z("mousemove"),Q=()=>z("mousedown"),se=()=>z("keydown");function le(){document.hidden?_.current===null&&(_.current=Date.now()):(_.current=null,A(),H("tab-visible-on-build"))}function re(){var U;A(),H("window-focus-on-build"),(U=w.current)==null||U.reportUserActivity("focus")}return window.addEventListener("focus",re),document.addEventListener("visibilitychange",le),document.addEventListener("mousemove",G),document.addEventListener("mousedown",Q),document.addEventListener("keydown",se),()=>{T("unmount"),window.removeEventListener("focus",re),document.removeEventListener("visibilitychange",le),document.removeEventListener("mousemove",G),document.removeEventListener("mousedown",Q),document.removeEventListener("keydown",se)}},[T,O]);const E=l.useRef(a??0);return l.useEffect(()=>{var z;const A=a??0;if(A===E.current)return;E.current=A;const H=u.current&&document.hasFocus();X("feature-complete-fast-path",{skipBecauseWatching:H}),!H&&((z=w.current)==null||z.onIdle(f,!1),g(!0),x.current=!0,S.current=Date.now(),y.current=!1)},[a,f]),l.useEffect(()=>{var A,H;if((A=w.current)==null||A.onBuildTabChange(s,f),s)return x.current&&typeof document<"u"&&document.hasFocus()&&!document.hidden&&((H=w.current)==null||H.onUserEngagement(),y.current=!0,O("build-tab-active-on-focus")),it()},[s,f,O]),{buildIdle:b,bannerVisible:b,notifSettings:f,handleSettingsChange:N,handleAgentIdle:k,handleAgentActive:D,handleUserInput:$,handleNavigateToTab:B,dismissIdleBanner:q,clearIdleForStopBuilding:P}}const aT=1e4;function oT(t){const{isAgentBuilding:s,submittingBuildPrompt:n,launchingPlanSlug:r,sessionInfo:a,stepFeature:o,refetchSessionInfo:i}=t,[c,d]=l.useState(!1),u=l.useRef(!1),h=l.useCallback((f,m)=>{u.current!==f&&(X("build-session-live-change",{from:u.current,to:f,trigger:m}),u.current=f,d(f))},[]);return l.useEffect(()=>{s&&h(!0,"agent-active")},[s,h]),l.useEffect(()=>{n&&h(!0,"launch-prompt")},[n,h]),l.useEffect(()=>{r!==null&&h(!0,"launch-plan")},[r,h]),l.useEffect(()=>{((a==null?void 0:a.resumeMode)==="resume"||(a==null?void 0:a.resumeMode)==="handoff")&&h(!0,"resumable-session-detected")},[a,h]),l.useEffect(()=>{(a==null?void 0:a.agentBrokerLive)===!0&&h(!0,"broker-live-detected")},[a,h]),l.useEffect(()=>{a&&!a.hasSession&&!a.agentBrokerLive&&h(!1,"session-ended")},[a,h]),l.useEffect(()=>{if(!c)return;const f=setInterval(()=>{i()},aT);return()=>clearInterval(f)},[c,i]),{buildSessionLive:c,agentActivelyBuilding:c&&(!!o||s||n||r!==null),transitionBuildSessionLive:h}}function $c(t){const{isAgentBuilding:s,trigger:n,transitionBuildSessionLive:r}=t;if(s){X("build-session-live-suppress-clear",{trigger:n,reason:"agent-still-active"});return}r(!1,n)}const iT=new Set(["ui-confirm-plan","backend-confirm-plan","present-live","backend-confirm","ui-present","backend-review"]);function lT(t,s){return t&&iT.has(t)?"needs-input":s?"waiting":"building"}function cT(){const[t,s]=l.useState({loading:!1,error:null,downloaded:!1}),n=l.useCallback(async a=>{s({loading:!0,error:null,downloaded:!1});try{const i=await(await fetch("/api/editor-transcript-package")).json();if(!i.success){s({loading:!1,error:i.error||"Failed to package transcript",downloaded:!1});return}let c=i.content;a!=null&&a.trim()&&(c=`## User Notes
246
-
247
- ${a.trim()}
248
-
249
- ${c}`);const d=new Blob([c],{type:"text/markdown"}),u=URL.createObjectURL(d),h=document.createElement("a");h.href=u,h.download=i.filename,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(u),s({loading:!1,error:null,downloaded:!0})}catch(o){s({loading:!1,error:o instanceof Error?o.message:"Network error",downloaded:!1})}},[]),r=l.useCallback(()=>{s({loading:!1,error:null,downloaded:!1})},[]);return{...t,sendTranscript:n,reset:r}}function dT(t,s){var o;const n="feedback@codeyam.com",r=encodeURIComponent(`CodeYam Session Feedback: ${t||"Session"}`+(s!=null&&s.category?` [${s.category}]`:"")),a=encodeURIComponent([((o=s==null?void 0:s.note)==null?void 0:o.trim())||"(no note)","","(Please attach the downloaded transcript file.)"].join(`
250
-
251
- `));return`mailto:${n}?subject=${r}&body=${a}`}const uT=["bug","suggestion","question","praise"];function Ev({featureName:t,onClose:s}){const[n,r]=l.useState(""),[a,o]=l.useState(null),[i,c]=l.useState(!1),{loading:d,error:u,downloaded:h,sendTranscript:p}=cT(),f=l.useCallback(()=>{p(n)},[p,n]),m=l.useCallback(()=>{navigator.clipboard.writeText("feedback@codeyam.com").then(()=>{c(!0),setTimeout(()=>c(!1),2e3)})},[]),b=l.useCallback(g=>{o(x=>x===g?null:g)},[]);return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Send Session Transcript"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Download your session transcript and send it to the CodeYam team for feedback or debugging."}),e.jsxs("div",{className:"mb-3",children:[e.jsx("span",{className:"block text-xs text-[var(--text-muted)] mb-1.5",children:"Tag (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:uT.map(g=>{const x=a===g;return e.jsx("button",{type:"button","aria-pressed":x,onClick:()=>b(g),className:"px-2.5 py-1 rounded-full text-xs transition cursor-pointer",style:{background:x?"var(--accent-active)":"transparent",color:x?"var(--bg-deep)":"var(--text-secondary)",border:"1px solid var(--border-default)"},children:g},g)})})]}),e.jsx("textarea",{value:n,onChange:g=>r(g.target.value),placeholder:"What's on your mind? (optional)",className:"w-full h-20 px-3 py-2 text-sm rounded-md mb-4 resize-none",style:{background:"var(--bg-input, var(--bg-deep))",color:"var(--text-primary)",border:"1px solid var(--border-default)"}}),u&&e.jsx("p",{className:"text-sm text-red-400 mb-3",children:u}),e.jsxs("div",{className:"flex flex-col gap-3",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-green-400 text-center",children:"Transcript downloaded!"}),e.jsx("a",{href:dT(t,{note:n,category:a}),className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition text-center block",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},children:"Open Email Client"}),e.jsx("button",{onClick: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"}),e.jsx("p",{className:"text-xs text-[var(--text-dim)] text-center",children:"Attach the downloaded file to your email"})]}):e.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"}),e.jsx("button",{onClick:s,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"transparent",color:"var(--text-secondary)",border:h?"none":"1px solid var(--border-default)"},type:"button",children:h?"Done":"Cancel"})]})]})}const M7=Object.freeze(Object.defineProperty({__proto__:null,SendTranscriptModal:Ev},Symbol.toStringTag,{value:"Module"}));function Mv({sha:t,onClick:s}){if(!t)return null;const n=t.slice(0,6),r="font-mono text-[11px] leading-none px-1.5 py-0.5 rounded border border-white/5 bg-black/55 backdrop-blur-sm hover:bg-black/75";return e.jsx("div",{className:`fixed bottom-1 left-1 z-30 ${s?"":"pointer-events-none"}`,style:{paddingBottom:"env(safe-area-inset-bottom)"},children:s?e.jsx("button",{type:"button",onClick:s,"data-testid":"build-sha-badge",title:t,"aria-label":`Build commit ${t}`,className:`cursor-pointer ${r}`,style:{color:"var(--text-secondary)"},children:n}):e.jsx("span",{"data-testid":"build-sha-badge",title:t,"aria-label":`Build commit ${t}`,className:r,style:{color:"var(--text-secondary)"},children:n})})}const I7=Object.freeze(Object.defineProperty({__proto__:null,BuildShaBadge:Mv},Symbol.toStringTag,{value:"Module"}));function hT(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/raw-terminal`}function Iv(){if(bt())return null;const t=l.useRef(null),s=l.useRef(null),n=l.useRef(null),r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(!1),[c,d]=pi(1200);function u(h){const p=r.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&p.send(new TextEncoder().encode(h))}return hi(t,()=>{if(n.current&&s.current){n.current.fit();const h=r.current;(h==null?void 0:h.readyState)===WebSocket.OPEN&&h.send(JSON.stringify({type:"resize",cols:s.current.cols,rows:s.current.rows}))}}),l.useEffect(()=>{if(!t.current||a.current)return;a.current=!0;const h=new ko.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),p=new So.FitAddon;h.loadAddon(p),h.open(t.current),s.current=h,n.current=p;const f=No(h,t.current,{onCopy:()=>d()}),m=Co(h,{sendInput:u});requestAnimationFrame(()=>{p.fit(),h.focus()});const b=new WebSocket(hT());return r.current=b,b.binaryType="arraybuffer",b.onmessage=g=>{g.data instanceof ArrayBuffer&&h.write(new Uint8Array(g.data))},b.onopen=()=>{b.send(JSON.stringify({type:"resize",cols:h.cols,rows:h.rows}))},b.onclose=()=>{i(!0),h.writeln(`\r
252
- \x1B[90m[Shell session ended]\x1B[0m`)},h.onData(u),()=>{var g;(g=r.current)==null||g.close(),m(),f(),h.dispose(),a.current=!1}},[]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[e.jsx("div",{ref:t,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var h;return(h=s.current)==null?void 0:h.focus()}}),o&&e.jsx("div",{role:"alert",className:"absolute bottom-2 left-2 rounded px-2 py-1 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:"Shell disconnected — close and reopen for a fresh shell."}),c&&e.jsx(zr,{})]})}const D7=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalEmulator:Iv},Symbol.toStringTag,{value:"Module"}));function Dv({isOpen:t,onClose:s}){return l.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&s()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,s]),t?e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"raw-terminal-modal-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onMouseDown:n=>{n.target===n.currentTarget&&s()},children:e.jsxs("div",{className:"flex flex-col rounded-lg shadow-xl",style:{width:"80vw",height:"80vh",maxWidth:1200,maxHeight:800,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border-default)]",children:[e.jsx("h2",{id:"raw-terminal-modal-title",className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Terminal"}),e.jsx("button",{type:"button",onClick:s,"data-testid":"raw-terminal-modal-close","aria-label":"Close terminal",className:"text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"✕"})]}),e.jsx("div",{className:"flex-1 flex flex-col",style:{minHeight:0},children:e.jsx(Iv,{})})]})}):null}const L7=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalModal:Dv},Symbol.toStringTag,{value:"Module"}));function pT(){const[t,s]=l.useState(!1),[n,r]=l.useState(null),[a,o]=l.useState(null),i=l.useRef(0);l.useEffect(()=>{if(a===null)return;const f=window.setTimeout(()=>o(null),Am);return()=>window.clearTimeout(f)},[a]);const c=l.useRef(null),d=l.useCallback(()=>r(null),[]),u=l.useCallback(async f=>{if(f.length!==0){for(const m of f)if(m.size>dr){o(`${m.name} is larger than the ${dr/(1024*1024)} MB cap`);return}try{const m=await Promise.all(f.map(async y=>({filename:y.name||"unnamed",contentBase64:await Om(y)}))),b=await fetch("/api/editor-upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:m})});if(!b.ok){const y=await b.json().then(v=>v.error).catch(()=>null);throw new Error(y??`Upload failed: ${b.status}`)}const x=(await b.json()).written??[];if(x.length===0)throw new Error("Upload returned no saved files");r(x)}catch(m){o(m instanceof Error?m.message:String(m))}}},[]),h=l.useCallback(()=>{var f;(f=c.current)==null||f.click()},[]),p=l.useCallback(f=>{const m=f.target,b=Array.from(m.files??[]).filter(g=>g.size>0);m.value="",u(b)},[u]);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,s(!0))},b=y=>{f(y)&&y.preventDefault()},g=y=>{f(y)&&(i.current=Math.max(0,i.current-1),i.current===0&&s(!1))},x=y=>{var j;if(!f(y))return;if(y.defaultPrevented){i.current=0,s(!1);return}if(y.preventDefault(),i.current=0,s(!1),y.dataTransfer&&Em(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(w=>w.size>0);u(v)};return window.addEventListener("dragenter",m),window.addEventListener("dragover",b),window.addEventListener("dragleave",g),window.addEventListener("drop",x),()=>{window.removeEventListener("dragenter",m),window.removeEventListener("dragover",b),window.removeEventListener("dragleave",g),window.removeEventListener("drop",x)}},[u]),{dragActive:t,pendingPaths:n,error:a,clearPending:d,openPicker:h,fileInputRef:c,handlePickerChange:p}}function Lv({visible:t}){return t?e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)",pointerEvents:"none"},"data-testid":"global-file-drop-overlay","aria-hidden":"true",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 px-10 py-8 rounded-xl text-center",style:{border:"2px dashed var(--accent-active, #D7FF63)",background:"rgba(0, 0, 0, 0.30)"},children:[e.jsx("span",{className:"text-2xl font-semibold text-[var(--text-primary)]",children:"Drop files to add them to this session"}),e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:"Saved to .codeyam/uploads/ — then hand them to the agent"})]})}):null}const F7=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropOverlay:Lv},Symbol.toStringTag,{value:"Module"}));function Fv({message:t}){return e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-[80] px-4 py-2 rounded-md text-sm",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",color:"var(--text-danger, #ff6b6b)"},"data-testid":"global-file-drop-error",children:t})}const z7=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropToast:Fv},Symbol.toStringTag,{value:"Module"}));function zv({paths:t,onClose:s}){const{sendToAgent:n,agentReady:r}=_w(),[a,o]=l.useState(!1),i=l.useCallback(h=>{h.key==="Escape"&&(h.preventDefault(),s())},[s]);l.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]);const c=t.map(Rm).join(" "),d=l.useCallback(()=>{n(c+" ")&&s()},[n,c,s]),u=l.useCallback(()=>{var h;(h=navigator.clipboard)==null||h.writeText(c).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{})},[c]);return e.jsx("div",{className:"fixed inset-0 z-[75] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"file-drop-confirm-modal",children:e.jsxs("div",{className:"max-w-lg w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t.length===1?"File added":`${t.length} files added`}),e.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Saved to your project. Hand the path",t.length===1?"":"s"," to the agent so it can read"," ",t.length===1?"it":"them","."]}),e.jsx("ul",{className:"mb-4 max-h-48 overflow-y-auto rounded-md p-3 text-xs font-mono",style:{background:"var(--bg-deep, #0e0e0e)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"},"data-testid":"file-drop-confirm-paths",children:t.map(h=>e.jsx("li",{className:"truncate py-0.5",children:h},h))}),!r&&e.jsx("p",{className:"mb-3 text-xs",style:{color:"var(--text-dim)"},"data-testid":"file-drop-confirm-no-agent-hint",children:"Start or focus a session to hand the file to the agent."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},"data-testid":"file-drop-confirm-copy",children:a?"Copied":"Copy path"}),e.jsx("button",{type:"button",onClick:s,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:"Done"}),e.jsx("button",{type:"button",onClick:d,disabled:!r,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #fff)",border:"1px solid transparent"},"data-testid":"file-drop-confirm-tell-agent",children:"Tell the agent"})]}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Escape closes · files stay in .codeyam/uploads/"})]})})}const $7=Object.freeze(Object.defineProperty({__proto__:null,FileDropConfirmModal:zv},Symbol.toStringTag,{value:"Module"}));let Ca=null;function mT(t){if(typeof t!="object"||t===null)return null;const s=t.buildCommitSha;return typeof s!="string"||s===""||s==="unknown"?null:s}async function fT(){try{const t=await fetch("/api/health");return t.ok?mT(await t.json()):null}catch{return null}}function gT(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!0;return Ca||(Ca=fT()),Ca.then(r=>{n&&s(r)}),()=>{n=!1}},[]),{sha:t}}function bT(){var pl,ml,fl;Y4();const{sha:t}=gT(),s=Rw(),{state:n,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,probeInFlight:u,probeAttempts:h,backendFieldAbsent:p,refresh:f}=kw(),{update:m}=z4(),{sessionInfo:b,refetch:g}=Si({pollIntervalMs:15e3}),x=(b==null?void 0:b.agentBrokerLive)??!1,y=A4(n,x),{activeTab:v,buildActivated:j,planActivated:w,navigateToTab:_,deactivateBuild:S}=Ri(s,y,n==="needs-login"&&!x),[C,N]=l.useState(!1),T=l.useCallback(()=>{N(!0)},[]),{arm:O,navigateToTabUser:k}=$4(y,_,T),D=l.useCallback(()=>k("build"),[k]),[$,B]=l.useState(!1),[q,P]=l.useState(!1),E=bt(),[A,H]=l.useState(E),z=l.useRef(!1),G=l.useCallback(()=>H(!0),[]),[Q,se]=l.useState(E),[le,re]=l.useState(0),[U,ge]=l.useState(0),[ie,be]=l.useState(0),[K,L]=l.useState(0),[I,F]=l.useState(null),{showPostPushModal:te,onFeatureCompleteCommand:W,onAgentIdle:Y,onAgentActive:V,dismissModal:pe}=u4(),{showPlanCompleteModal:ue,onPlanCompleteCommand:ve,dismissPlanCompleteModal:Z}=p4(),[Te,ae]=l.useState(!1),[xe,Ne]=l.useState(!1),[je,Oe]=l.useState(!1),[Be,et]=l.useState(!1),[xt,Ce]=l.useState(!1),[ht,as]=l.useState(!1),Bt=l.useCallback(()=>{Oe(!0)},[]),qe=l.useCallback(()=>{Oe(!1)},[]),{plans:yt,loading:Tt,error:qt,refetch:os}=bg(),{plans:is}=_g(),{reorderPlans:He}=Og(os),{launchPrompt:ye,launching:_e,error:We}=m4(),[ke,Ee]=l.useState(null),{stepState:M,refetch:Ve}=_n();h4({showPostPushModal:te,stepState:M,dismissModal:pe});const ct=l.useRef(null),{leftWidth:we,handleMouseDown:dt}=W4(ct),Pe=Nm(768),[Ke,Je]=l.useState("editor"),Ge=l.useCallback(J=>{Je(J),J==="editor"&&(it(),typeof window<"u"&&window.dispatchEvent(new Event("resize")))},[]),[Me,ot]=l.useState(!1),Se=v==="home";l.useEffect(()=>{!Se&&Me&&ot(!1)},[Se,Me]);const{entityLookup:Sn}=W5(),{groups:Ht,loading:Ss,refreshing:Nn,currentRunner:Cn,coverage:Pn,refresh:Gs}=T5(),{groups:Xe,loading:Ie,reload:vt}=w5(),{routeEntities:ls,unsurfacedPages:Ns,componentSurfaceReason:Us,loading:Vr,error:$v}=S5(),{config:ee,apps:At,loading:Tn,refetch:Cs}=St(),Bv=_b(),cs=l.useMemo(()=>b4(At,Ht,Xe),[At,Xe,Ht]),{saved:qv}=Bp(),Hv=qp({appStatsLength:cs.length,configLoading:Tn,scenariosLoading:Ie,setupAnswersSaved:qv,hasStepState:!!M}),Kr=Se&&!Me&&!Hv,Wv=Pe||Kr?((pl=ct.current)==null?void 0:pl.clientWidth)??(typeof window<"u"?window.innerWidth:we):we,Gv=l.useCallback(()=>{B(J=>!J)},[]),Uv=l.useCallback(()=>{P(J=>!J)},[]),{selectedApp:ds,appRouteEntities:Vi,appTestGroups:Yv,selectedEntityHash:Vv,selectedRouteEntity:Ki,previewSlug:Ys,setPreviewSlugExplicit:Kv,selectApp:Jr,deselectApp:Xr,selectRoute:Qr,selectEntity:Jv,deselectRoute:Xv}=B5(At,ls,Xe,Ht,s,(ee==null?void 0:ee.defaultScreenSize)??null,Q,z),{viewports:Qv,resolvedViewport:Vs,previewUrl:Zv,handleViewportChange:ej,handleCustomSizeChange:Zr,showScenarioPreview:Ks,handlePreviewCommand:tt,setPreviewPath:ea,previewSeeding:tj,previewSeedError:sj,previewSeedErrorKind:nj,retrySeed:rj,commandNonce:aj}=o4({apps:At,appRouteEntities:Vi,configLoaded:!Tn,hydrated:A,port:(ee==null?void 0:ee.port)??5173,previewMedium:Bv.kind,previewOrigin:Rc(ee,ds),projectTitle:(ee==null?void 0:ee.projectTitle)??null,routeEntities:ls,screenSizes:(ee==null?void 0:ee.screenSizes)??{},defaultScreenSize:(ee==null?void 0:ee.defaultScreenSize)??null,scenarioGroups:Xe,scenariosLoaded:!Ie,selectedApp:ds,selectedRouteEntity:Ki,previewSlug:Ys,setPreviewSlug:Kv});l.useEffect(()=>{Se&&Me&&Vs.name==="Desktop"&&P(!0)},[Se,Me,Vs.name]);const{isAgentBuilding:Ot,isAgentBuildingRef:ta,buildingScenarioSlug:sa,onAgentIdle:Ji,onAgentActive:Xi,guardScenarioSelect:Qi,clearBuildingOverlay:jt,forceIdle:Zi}=f4({onTransitionToLive:Ks}),{planActive:oj,planIdle:ij}=g4({chatOpen:Te}),An=(b==null?void 0:b.resumeMode)==="resume"||(b==null?void 0:b.resumeMode)==="handoff",{launchPlan:On,launchingSlug:na,error:lj}=Cg({launchAnchored:An||!!(M!=null&&M.feature)}),{buildSessionLive:cj,agentActivelyBuilding:Rn,transitionBuildSessionLive:us}=oT({isAgentBuilding:Ot,submittingBuildPrompt:_e,launchingPlanSlug:na,sessionInfo:b,stepFeature:(M==null?void 0:M.feature)??null,refetchSessionInfo:g});l.useEffect(()=>{Ot&&b&&!b.hasSession&&!b.agentBrokerLive&&Zi()},[Ot,b,Zi]),l.useEffect(()=>{Ur({hasActiveSession:An,isAgentBuilding:Ot,stepStateFeature:(M==null?void 0:M.feature)??null})},[An,Ot,M==null?void 0:M.feature]),l.useEffect(()=>{const J=ee==null?void 0:ee.projectTitle;document.title=typeof J=="string"&&J.length>0?`CodeYam: ${J}`:"CodeYam"},[ee==null?void 0:ee.projectTitle]);const dj=l.useCallback(()=>{Y(),Ji()},[Y,Ji]),uj=l.useCallback(()=>{V(),Xi()},[V,Xi]),En=(ee==null?void 0:ee.provider)??Sw,hj=zt(En),{buildIdle:Mn,bannerVisible:pj,notifSettings:el,handleSettingsChange:tl,handleAgentIdle:mj,handleAgentActive:fj,handleUserInput:gj,handleNavigateToTab:sl,dismissIdleBanner:bj,clearIdleForStopBuilding:In}=rT({agentName:hj,isBuildTabActive:v==="build",isAgentBuilding:Ot,buildSessionLive:cj,featureCompleteKey:ie,navigateToTab:k,onAgentIdleImmediate:dj,onAgentActiveImmediate:uj}),nl=l.useMemo(()=>lT(M==null?void 0:M.slug,Mn),[M==null?void 0:M.slug,Mn]),rl=M?ek(M.step,M.mode):null,al=l.useMemo(()=>y4(M==null?void 0:M.step,M==null?void 0:M.mode),[M==null?void 0:M.step,M==null?void 0:M.mode]),ol=M?v4(M.step,M.mode):null,xj=((ml=is[0])==null?void 0:ml.title)??null,il=l.useCallback(J=>{Ee(null),!Qi(J)&&(Ks(J),Se&&ot(!0))},[Qi,Ks,Se]),yj=l.useCallback(J=>{const Ue=O4(J.name,Xe),hs=D4({shot:{name:J.name,screenshotPath:J.screenshotPath},isLatest:J.isLatest,liveScenario:Ue,isAgentBuilding:Ot});if(hs.kind==="live"){Ee(null),Ks(hs.slug);return}Ee({screenshotPath:hs.screenshotPath,scenarioName:hs.scenarioName,heading:hs.heading,subtext:hs.subtext})},[Ot,Xe,Ks]),vj=l.useCallback(()=>{Ee(null)},[]),Rt=l.useMemo(()=>jo(sa,Xe),[sa,Xe]),jj=((fl=Rt==null?void 0:Rt.screenshotPaths)==null?void 0:fl[0])??null,wj=(Rt==null?void 0:Rt.name)??null,_j=(Rt==null?void 0:Rt.description)??null,kj=l.useCallback(J=>{switch(J.type){case"preview":("scenarioSlug"in J||"scenarioId"in J)&&vt(),tt(J);break;case"showResults":jt(),vt(),re(Ue=>Ue+1),(M==null?void 0:M.mode)==="backend"&&tt({path:"/results",dimension:"Desktop"});break;case"hideResults":ge(Ue=>Ue+1);break;case"featureComplete":jt(),W(),be(Ue=>Ue+1),Cs(),Ve(),$c({isAgentBuilding:ta.current,trigger:"feature-complete",transitionBuildSessionLive:us});break;case"planComplete":ve(),Cs(),$c({isAgentBuilding:ta.current,trigger:"plan-complete",transitionBuildSessionLive:us});break;case"launchPlan":On(J.slug,J.title),L(Ue=>Ue+1);break;case"requestCredential":F({serviceName:J.serviceName,envVar:J.envVar,topic:J.topic,docsUrl:J.docsUrl});break}},[jt,tt,ta,On,W,ve,Cs,Ve,vt,M,us]);H5(kj,l.useCallback(()=>{window.location.reload()},[]));const Dn=(M==null?void 0:M.slug)==="ui-confirm-plan"||(M==null?void 0:M.slug)==="backend-confirm-plan",ra=l.useRef(null);l.useEffect(()=>{if(!M||!Dn){ra.current=null;return}ra.current!==M.step&&(ra.current=M.step,tt({path:"/plan-preview",dimension:"Desktop"}))},[M,Dn,tt]);const aa=l.useRef(null);l.useEffect(()=>{if(!M||M.mode!=="backend"||M.step<2||Dn){aa.current=null;return}aa.current!==M.step&&(aa.current=M.step,tt({path:"/results",dimension:"Desktop"}))},[M,Dn,tt]);const oa=l.useRef(!1);l.useEffect(()=>{(M==null?void 0:M.slug)==="ui-confirm-plan"?oa.current=!0:oa.current&&(oa.current=!1,ea(null))},[M,ea]);const Sj=l.useCallback(async()=>{pe(),N(!0),await R2({provider:En,renameLabel:(M==null?void 0:M.feature)??void 0,caller:"post-push-modal",bypassLiveGuard:!0}),it()},[pe,En,M]),Nj=l.useCallback(()=>{pe(),it()},[pe]),Cj=l.useCallback(async()=>{window.dispatchEvent(new CustomEvent("build-session-stopped")),await A2(),pe(),_("home"),S(),us(!1,"stop-building"),jt(),In(),N(!1),g()},[pe,_,S,us,jt,In,g]),Pj=l.useCallback(async()=>{as(!0),window.dispatchEvent(new CustomEvent("build-session-stopped")),await O2(),as(!1),Ce(!1),_("home"),S(),us(!1,"reset-everything"),jt(),In(),N(!1),g()},[_,S,us,jt,In,g]),Tj=l.useCallback(()=>{ae(!0),zc(),Z(),it()},[Z]),Aj=l.useCallback(()=>{ae(!0),Z(),it()},[Z]),Oj=l.useCallback(()=>{Z(),zc().finally(()=>{ae(!1),J4()})},[Z]),Rj=l.useCallback(()=>{Ne(!0)},[]),Ej=l.useCallback(()=>{Ne(!1)},[]),Mj=l.useCallback(async(J,Ue)=>{await On(J,Ue)&&(Ne(!1),N(!0),pe(),g())},[On,pe,g]),Ij=l.useCallback(async J=>{await ye(J)&&(N(!0),g())},[ye,g]),Dj=l.useCallback(()=>{N(!0)},[]),ll={hasActiveSession:An,isAgentBuilding:Ot,showPostPushModal:te,launchingPlanSlug:na,submittingBuildPrompt:_e,stepStateFeature:(M==null?void 0:M.feature)??null,buildLaunchModalDismissed:C},Lj=Tv(ll),cl=L4({activeTab:v,...ll}),Fj=cl||xe;l.useEffect(()=>{v==="build"&&g()},[v,g]),l.useEffect(()=>{v==="home"&&(Cs(),f())},[v,Cs,f]);const zj=l.useCallback(async(J,Ue)=>{jt(),tt(T4(J,Ue))},[jt,tt]),$j=l.useCallback(J=>{tt({...J.scenarioSlug?{scenarioSlug:J.scenarioSlug}:{},...J.path?{path:J.path}:{},...J.dimension?{dimension:J.dimension}:{}})},[tt]),{requestRestore:Bj,onAdoptSettledEmpty:dl}=c4({restoredRef:z,initiallySettled:E,apply:$j}),ul=l.useCallback(J=>{d4(J,{handlePreviewCommand:tt,handleCustomSizeChange:Zr})},[Zr,tt]),qj=l.useCallback(()=>{dl(),se(!0)},[dl]);i4({isInIframe:E,scenariosLoaded:!Ie,restoredRef:z,onAdopt:ul,onHydrated:G,onSettledEmpty:qj}),l4({isInIframe:E,onConverge:ul});const Hj=l.useMemo(()=>({apps:At,isSingleApp:At.length===1,onSelectApps:Xr,onSelectApp:Jr,onSelectRoute:Qr}),[At,Xr,Jr,Qr]),Wj=l.useMemo(()=>ds?cs.find(J=>J.app.dir===ds.dir)??null:null,[cs,ds]),Gj=e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"12px 28px 0"},children:e.jsx(Ti,{staleness:null,backendOutOfDate:p})}),e.jsx("div",{style:{padding:"12px 28px 0"},children:e.jsx(Ov,{update:m})}),e.jsx(Av,{state:n,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,probeInFlight:u,probeAttempts:h,backendOutOfDate:p,sessionOngoing:x,onAuthenticated:f,onAuthorized:D}),cs.length>0&&e.jsx("div",{style:{padding:"10px 28px 0"},children:e.jsx("div",{style:{width:"100%",maxWidth:1e3,marginInline:"auto"},children:e.jsx($p,{settings:el,onChange:tl})})}),e.jsx(hg,{selectedApp:ds,projectTitle:(ee==null?void 0:ee.projectTitle)??null,admin:(ee==null?void 0:ee.admin)??!1,isBuilding:Rn,buildingLabel:(M==null?void 0:M.feature)??null,buildingStepLabel:rl,buildingStepIndicator:ol,buildingStatus:nl,buildingProgress:al,lastBuiltLabel:xj,plansCount:yt.length,onNavigateToPlan:()=>_("plan"),onNavigateToBuild:()=>k("build"),onResetBuild:()=>Ce(!0),onBackToProjects:At.length>1?Xr:void 0,launcherUrl:(ee==null?void 0:ee.launcherUrl)??null,projectCount:(ee==null?void 0:ee.projectCount)??0,onOpenSetupBrowser:ee!=null&&ee.setupBrowserEnabled?()=>tt({path:"/setup-browser",dimension:"Desktop"}):void 0,appDetailProps:{navContext:Hj,routeEntities:Vi,unsurfacedPages:Ns,componentSurfaceReason:Us,routesLoading:Vr,routesError:$v,selectedEntityHash:Vv,selectedRouteEntity:Ki,testGroups:Yv,selectedSlug:Ys,entityLookup:Sn,allScenarios:Xe.flatMap(J=>J.scenarios),onSelectScenario:il,onSelectRoute:Qr,onSelectEntity:Jv,onBackToRoutes:Xv,onScenariosChanged:vt,coverage:Pn,showProjectBand:At.length===1,stats:Wj,testsLoading:Ss,testsRefreshing:Nn,onRunTests:Gs,currentRunner:Cn},appOverviewProps:{projectTitle:(ee==null?void 0:ee.projectTitle)??"Project",projectDescription:(ee==null?void 0:ee.projectDescription)??null,stats:cs,coverage:Pn,onSelectApp:Jr,configLoading:Tn,scenariosLoading:Ie,testsLoading:Ss,testsRefreshing:Nn,onRunTests:Gs,currentRunner:Cn,stepState:M,onPreviewUrl:ea,onComplete:async()=>{await Cs(),console.info("[EditorShell] questionnaire complete; arming pending build-nav",{providerAuthState:n,buildBlocked:y}),O()},onOpenBuildTab:()=>k("build"),isBuilding:Rn,buildingLabel:(M==null?void 0:M.feature)??null,buildingStepLabel:rl,buildingStepIndicator:ol,buildingStatus:nl,buildingProgress:al,onResetBuild:()=>Ce(!0)}})]}),Uj=cs.some(J=>P4(J.app.type)),Yj=Xe.reduce((J,Ue)=>J+Ue.scenarios.length,0),hl=!!M&&!Ie&&Yj===0,Vj=bv(),Et=pT();return e.jsx(Nw,{children:e.jsxs(Cw,{openPicker:Et.openPicker,children:[e.jsx(gg,{splitRef:ct,isCollapsed:$,hidePreview:Kr,onHomeLivePageBack:Se&&Me?()=>ot(!1):void 0,onResizeStart:dt,isNarrow:Pe,mobilePane:Ke,onMobilePaneChange:Ge,isAgentBuilding:Rn,buildIdle:Mn,leftPane:e.jsx(yb,{activeTab:v,onSendTranscript:Bt,appTabContent:Gj,awaitingPlanLaunchChoice:Fj,buildActivated:j,planActivated:w,buildIdle:Mn,isAgentBuilding:Rn,planActive:oj,planIdle:ij,bannerVisible:pj,onDismissIdleBanner:bj,hideResultsCommandKey:U,leftWidth:Wv,fullWidth:Pe||Kr,navigateToTab:sl,onAgentActive:fj,onAgentIdle:mj,onUserInput:gj,notifSettings:el,onSettingsChange:tl,provider:En,onRestorePreview:Bj,onResultsScenarioSelect:zj,previewSlug:Ys,showPostPushModal:te,completionModalPermitted:Pv(M),onStartNextFeature:Sj,onContinueInSession:Nj,onStopBuilding:Cj,showResultsCommandKey:le,planChatOpen:Te,onPlanChatOpenChange:ae,showPlanCompleteModal:ue,onCreateNewPlan:Tj,onContinueSession:Aj,onViewPlans:Oj,pendingPlans:yt,onSelectPlan:Rj,selectPlanOpen:xe,onPickPlan:Mj,onCancelSelectPlan:Ej,launchingPlanSlug:na,planLaunchError:lj,prototypeLaunchSignal:K,showBuildLaunchModal:cl,buildLaunchGateArmed:Lj,onSubmitBuildPrompt:Ij,submittingBuildPrompt:_e,buildPromptError:We,onStartBlankBuild:Dj,pendingPlansLoading:Tt,pendingPlansError:qt,onReorderPlans:He,buildDisabled:y,onPreviewScreenshot:yj,projectTitle:(ee==null?void 0:ee.projectTitle)??null}),previewPane:e.jsx(yv,{emptyStateMessage:N4({configLoading:Tn,hasNoApps:cs.length===0,hasStepState:!!M,hasPreviewableApp:Uj,setupInProgress:hl,hasCaptureFrame:Vj.available}),projectSetupInProgress:hl,previewSlug:Ys,previewUrl:Zv,viewports:Qv,activeViewport:Vs.name,onViewportChange:ej,isCollapsed:$,onToggleCollapsed:Gv,isNarrow:Pe,onBack:Se&&Me?()=>ot(!1):void 0,onPlanChange:Se&&Me?()=>sl("plan"):void 0,isFilled:q,onToggleFilled:Uv,currentWidth:Vs.width,currentHeight:Vs.height,onCustomSizeChange:Zr,buildingScenarioSlug:sa,buildingScreenshotPath:jj,buildingScenarioName:wj,buildingScenarioDescription:_j,onDismissBuildingOverlay:jt,historicalScreenshotPath:(ke==null?void 0:ke.screenshotPath)??null,historicalScenarioName:(ke==null?void 0:ke.scenarioName)??null,historicalHeading:(ke==null?void 0:ke.heading)??null,historicalSubtext:(ke==null?void 0:ke.subtext)??null,onDismissHistoricalPreview:vj,previewSeeding:tj,previewSeedError:sj,previewSeedErrorKind:nj,onRetrySeed:rj,currentScenario:jo(Ys,Xe),scenarioGroups:Xe,onShowScenarioPreview:il,commandNonce:aj,previewOrigin:Rc(ee,ds),onDesignConfirmed:()=>k("build")})}),je?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsx(Ev,{featureName:(M==null?void 0:M.feature)??null,onClose:qe})}):null,e.jsx(Dv,{isOpen:Be,onClose:()=>et(!1)}),e.jsx(Mv,{sha:t,onClick:()=>et(!0)}),e.jsx(Lv,{visible:Et.dragActive}),e.jsx("input",{ref:Et.fileInputRef,type:"file",multiple:!0,onChange:Et.handlePickerChange,style:{display:"none"},"data-testid":"global-file-picker-input"}),Et.error?e.jsx(Fv,{message:Et.error}):null,Et.pendingPaths?e.jsx(zv,{paths:Et.pendingPaths,onClose:Et.clearPending}):null,xt?e.jsx(vv,{busy:ht,onCancel:()=>Ce(!1),onConfirm:()=>void Pj()}):null,I?e.jsx(Gr,{target:I,onStored:()=>F(null),onClose:()=>F(null)}):null]})})}const B7=Object.freeze(Object.defineProperty({__proto__:null,EditorShell:bT},Symbol.toStringTag,{value:"Module"}));export{fs as $,Vo as A,eu as B,Sr as C,Tx as D,de as E,zv as F,Hc as G,Wc as H,X0 as I,Gc as J,rd as K,Vt as L,nu as M,or as N,od as O,du as P,Qd as Q,oy as R,Ho as S,Cr as T,nd as U,sd as V,Fo as W,t_ as X,Da as Y,Wt as Z,Jn as _,Tr as a,es as a$,ms as a0,ps as a1,Gt as a2,mt as a3,lu as a4,ou as a5,Ma as a6,kd as a7,cu as a8,zo as a9,rx as aA,nx as aB,sx as aC,tx as aD,Zb as aE,Hi as aF,ox as aG,lg as aH,Df as aI,io as aJ,lo as aK,Ls as aL,Lf as aM,jy as aN,Ax as aO,Hb as aP,ci as aQ,ts as aR,Ef as aS,Qb as aT,Xb as aU,to as aV,rs as aW,Mf as aX,Oo as aY,Ye as aZ,Lo as a_,Rf as aa,lt as ab,pv as ac,Qy as ad,uh as ae,dh as af,ch as ag,Wh as ah,Jt as ai,Mt as aj,oe as ak,he as al,Zt as am,Ov as an,Ti as ao,en as ap,fn as aq,If as ar,sn as as,R as at,tb as au,jf as av,wy as aw,jg as ax,uo as ay,xx as az,Ba as b,hd as b$,Zd as b0,my as b1,vr as b2,hx as b3,ux as b4,Is as b5,zr as b6,Ze as b7,jr as b8,yn as b9,Ae as bA,xs as bB,jx as bC,Kc as bD,Nx as bE,Sx as bF,$e as bG,ft as bH,Dt as bI,rt as bJ,Wo as bK,Qc as bL,Jc as bM,ey as bN,Qe as bO,Dy as bP,Iy as bQ,zy as bR,Ly as bS,My as bT,$y as bU,ay as bV,Ey as bW,ry as bX,cv as bY,lv as bZ,qf as b_,lh as ba,Pr as bb,Le as bc,ne as bd,Ix as be,_x as bf,Vc as bg,om as bh,kr as bi,Ru as bj,ax as bk,Fs as bl,vx as bm,Yc as bn,Qh as bo,rp as bp,np as bq,tp as br,ep as bs,Zh as bt,si as bu,Lt as bv,Xc as bw,Ou as bx,Qs as by,sy as bz,xO as c,Mb as c$,pd as c0,ud as c1,ld as c2,dd as c3,Nt as c4,ii as c5,ig as c6,fd as c7,Hd as c8,Ia as c9,fu as cA,pu as cB,uu as cC,Fa as cD,hu as cE,tg as cF,Vf as cG,Kf as cH,Jf as cI,eg as cJ,Xf as cK,Qf as cL,sg as cM,ag as cN,Zf as cO,ng as cP,rg as cQ,kn as cR,Pb as cS,zb as cT,Db as cU,Tb as cV,Ab as cW,Rb as cX,Eb as cY,ao as cZ,zi as c_,qd as ca,Ro as cb,Mv as cc,br as cd,ly as ce,dy as cf,uy as cg,hy as ch,cy as ci,py as cj,iv as ck,iy as cl,vy as cm,gy as cn,fy as co,xy as cp,yy as cq,by as cr,og as cs,Xp as ct,Vp as cu,Yp as cv,Gp as cw,Wp as cx,Hp as cy,Up as cz,Uh as d,gf as d$,Ib as d0,Sb as d1,Pi as d2,Lb as d3,Fb as d4,Nb as d5,$b as d6,Ff as d7,Pf as d8,Of as d9,Lm as dA,fb as dB,mb as dC,xb as dD,gb as dE,bb as dF,Fv as dG,Lv as dH,pb as dI,Qt as dJ,Qg as dK,Zg as dL,eb as dM,vf as dN,Vg as dO,Jg as dP,Yg as dQ,Ug as dR,Kg as dS,Xg as dT,Wg as dU,Gg as dV,Wr as dW,Tg as dX,Ag as dY,Pg as dZ,yf as d_,Bx as da,Gi as db,qx as dc,Wx as dd,zx as de,Fx as df,Lx as dg,mo as dh,Yx as di,Ux as dj,qb as dk,Gx as dl,$x as dm,Hx as dn,Vx as dp,Tm as dq,Pm as dr,Dm as ds,Im as dt,av as du,ov as dv,nv as dw,rv as dx,Iv as dy,Dv as dz,Tu as e,Ed as e$,hf as e0,_i as e1,uf as e2,bf as e3,mf as e4,pf as e5,ff as e6,df as e7,ki as e8,wi as e9,Rx as eA,mu as eB,Md as eC,wd as eD,_d as eE,jd as eF,rb as eG,Sf as eH,Nf as eI,md as eJ,Mo as eK,ed as eL,Wd as eM,Gd as eN,Yd as eO,Vd as eP,Kd as eQ,Jd as eR,Xd as eS,Io as eT,$d as eU,Fd as eV,Ld as eW,Dd as eX,zd as eY,Bd as eZ,Ad as e_,Mi as ea,Dg as eb,Fg as ec,so as ed,Mg as ee,$g as ef,Hg as eg,Eg as eh,qg as ei,Bg as ej,Rg as ek,sb as el,Ii as em,ib as en,cb as eo,ob as ep,db as eq,Mx as er,Ex as es,Vn as et,id as eu,xd as ev,gd as ew,yd as ex,bT as ey,ho as ez,Pu as f,am as f$,Rd as f0,Td as f1,Od as f2,Nd as f3,Sd as f4,$o as f5,$a as f6,wu as f7,_u as f8,xu as f9,Kx as fA,Qx as fB,Bb as fC,ny as fD,Zx as fE,Uy as fF,kf as fG,mg as fH,Rs as fI,um as fJ,dm as fK,di as fL,Cx as fM,bx as fN,kx as fO,wx as fP,yx as fQ,px as fR,lx as fS,fx as fT,Wi as fU,gx as fV,Vb as fW,cm as fX,Va as fY,lm as fZ,im as f_,Nu as fa,ju as fb,bu as fc,Ea as fd,Yn as fe,Do as ff,Ft as fg,hm as fh,Ox as fi,xr as fj,gv as fk,xo as fl,hv as fm,By as fn,Zy as fo,ev as fp,Ky as fq,Vy as fr,Jy as fs,Yy as ft,Xy as fu,vv as fv,Px as fw,sv as fx,tv as fy,Jx as fz,Xn as g,Gh as g$,mm as g0,pm as g1,ab as g2,Sp as g3,kp as g4,_p as g5,wp as g6,jp as g7,vp as g8,yp as g9,sh as gA,eh as gB,qh as gC,Bh as gD,$h as gE,zh as gF,Fh as gG,Ih as gH,Mh as gI,Hu as gJ,Wa as gK,Hh as gL,Ha as gM,gp as gN,fp as gO,mp as gP,pp as gQ,hp as gR,up as gS,Ga as gT,dp as gU,lp as gV,ip as gW,Lr as gX,op as gY,ap as gZ,Xh as g_,xp as ga,bp as gb,Eh as gc,Rh as gd,Oh as ge,Ah as gf,Th as gg,Ph as gh,Ch as gi,Nh as gj,Sh as gk,kh as gl,_h as gm,wh as gn,jh as go,yh as gp,xh as gq,bh as gr,gh as gs,fh as gt,ph as gu,hh as gv,mh as gw,ih as gx,oh as gy,ah as gz,da as h,gm as h$,Mu as h0,Eu as h1,$u as h2,Bu as h3,qu as h4,ru as h5,La as h6,au as h7,iu as h8,Au as h9,ym as hA,xm as hB,Wf as hC,Uf as hD,Gf as hE,Bf as hF,gr as hG,Ty as hH,Oy as hI,Cy as hJ,Ny as hK,Sy as hL,Ry as hM,Py as hN,ky as hO,Ay as hP,_y as hQ,fo as hR,_r as hS,bd as hT,Bo as hU,Fm as hV,Sm as hW,wf as hX,_m as hY,bm as hZ,$f as h_,Ya as ha,Rp as hb,$p as hc,ri as hd,Lp as he,Cp as hf,Ua as hg,Pp as hh,Tp as hi,Ap as hj,Fr as hk,Op as hl,Nr as hm,_f as hn,Hf as ho,fg as hp,ub as hq,nb as hr,yb as hs,gg as ht,pg as hu,hg as hv,jm as hw,Qn as hx,wm as hy,vm as hz,yv as i,PA as i$,Cf as i0,fm as i1,Cu as i2,gu as i3,Hy as i4,qy as i5,dg as i6,De as i7,Vh as i8,Kh as i9,Rr as iA,Ju as iB,ir as iC,Xo as iD,qa as iE,Zu as iF,Xu as iG,Ku as iH,Qu as iI,rr as iJ,fv as iK,xv as iL,EO as iM,BO as iN,FA as iO,DO as iP,GM as iQ,qO as iR,QA as iS,cI as iT,h8 as iU,l6 as iV,E7 as iW,RA as iX,EA as iY,TA as iZ,AA as i_,Jh as ia,zu as ib,Gr as ic,Av as id,nm as ie,sm as ig,rm as ih,tm as ii,em as ij,Zp as ik,Or as il,ei as im,nh as io,rh as ip,th as iq,Zo as ir,Dr as is,Ir as it,Mr as iu,Vu as iv,Er as iw,Yu as ix,Jo as iy,_t as iz,Id as j,ZM as j$,OA as j0,iO as j1,sR as j2,bA as j3,KA as j4,xA as j5,iA as j6,lA as j7,oA as j8,sO as j9,k7 as jA,C7 as jB,QO as jC,JO as jD,XO as jE,u6 as jF,A6 as jG,zA as jH,b7 as jI,g7 as jJ,$O as jK,zO as jL,BA as jM,$A as jN,FO as jO,LO as jP,RT as jQ,LA as jR,y7 as jS,x7 as jT,kO as jU,UM as jV,TE as jW,OE as jX,hM as jY,M7 as jZ,b6 as j_,iE as ja,aE as jb,rE as jc,oE as jd,YO as je,vO as jf,$M as jg,p6 as jh,J6 as ji,tR as jj,eR as jk,H6 as jl,NE as jm,CE as jn,u8 as jo,c8 as jp,d8 as jq,vM as jr,YI as js,C6 as jt,P6 as ju,jE as jv,EI as jw,V6 as jx,T7 as jy,S7 as jz,vd as k,FR as k$,HM as k0,w7 as k1,j7 as k2,w6 as k3,aA as k4,yO as k5,UT as k6,WT as k7,GT as k8,YT as k9,wA as kA,kA as kB,pA as kC,gA as kD,fA as kE,hA as kF,mA as kG,jO as kH,UA as kI,JA as kJ,XA as kK,w8 as kL,O7 as kM,aI as kN,d6 as kO,t8 as kP,r6 as kQ,LM as kR,GO as kS,MO as kT,x6 as kU,L7 as kV,D7 as kW,wE as kX,MR as kY,WR as kZ,DR as k_,KT as ka,VT as kb,VA as kc,PT as kd,YA as ke,rA as kf,RR as kg,CT as kh,tO as ki,q6 as kj,TO as kk,fI as kl,XT as km,JT as kn,FT as ko,NA as kp,CA as kq,SA as kr,MT as ks,IT as kt,MA as ku,jA as kv,vA as kw,yA as kx,sA as ky,_A as kz,KC as l,kM as l$,HR as l0,qR as l1,BR as l2,$R as l3,zR as l4,LR as l5,nR as l6,ZO as l7,i6 as l8,R6 as l9,C8 as lA,k8 as lB,b8 as lC,o7 as lD,T6 as lE,XM as lF,QM as lG,gM as lH,FM as lI,bM as lJ,fM as lK,mM as lL,yE as lM,pM as lN,bE as lO,hE as lP,gE as lQ,uE as lR,xE as lS,mE as lT,pE as lU,fE as lV,dE as lW,vE as lX,g8 as lY,f8 as lZ,m8 as l_,R7 as la,_M as lb,yM as lc,xM as ld,SE as le,h7 as lf,p7 as lg,m7 as lh,f7 as li,u7 as lj,d7 as lk,c7 as ll,i7 as lm,l7 as ln,x8 as lo,_8 as lp,ZA as lq,F8 as lr,A7 as ls,v8 as lt,y8 as lu,a7 as lv,N8 as lw,S8 as lx,P8 as ly,T8 as lz,qo as m,K6 as m$,cE as m0,JM as m1,KM as m2,uM as m3,wM as m4,SM as m5,G6 as m6,a6 as m7,TR as m8,PR as m9,UI as mA,BI as mB,GI as mC,WI as mD,HI as mE,eO as mF,qI as mG,LI as mH,FI as mI,DI as mJ,OI as mK,AI as mL,PI as mM,_I as mN,CI as mO,SI as mP,kI as mQ,TI as mR,II as mS,RI as mT,zI as mU,$I as mV,vI as mW,nE as mX,Q6 as mY,cM as mZ,RE as m_,UO as ma,lM as mb,i8 as mc,l8 as md,a8 as me,n8 as mf,r8 as mg,s8 as mh,o8 as mi,KE as mj,e8 as mk,U8 as ml,jR as mm,Y6 as mn,xR as mo,bR as mp,gR as mq,cA as mr,P7 as ms,GR as mt,p8 as mu,ET as mv,JI as mw,nI as mx,GA as my,MI as mz,Ev as n,X6 as n$,N6 as n0,zT as n1,n7 as n2,AO as n3,OO as n4,RO as n5,KO as n6,BM as n7,PO as n8,uA as n9,rM as nA,DA as nB,NR as nC,pR as nD,dR as nE,cR as nF,uR as nG,hR as nH,WM as nI,LT as nJ,DT as nK,z7 as nL,F7 as nM,FE as nN,AE as nO,NT as nP,s6 as nQ,NI as nR,jM as nS,ZI as nT,WA as nU,$7 as nV,kE as nW,AT as nX,aM as nY,E6 as nZ,U6 as n_,dA as na,HA as nb,c6 as nc,Z8 as nd,Q8 as ne,t7 as nf,e7 as ng,X8 as nh,s7 as ni,J8 as nj,PM as nk,CM as nl,aR as nm,j8 as nn,fR as no,zE as np,OT as nq,M6 as nr,B6 as ns,F6 as nt,I6 as nu,$6 as nv,z6 as nw,L6 as nx,D6 as ny,wO as nz,xn as o,ZE as o$,W6 as o0,sM as o1,m6 as o2,LE as o3,HT as o4,qT as o5,tA as o6,QT as o7,nA as o8,eA as o9,yI as oA,ER as oB,CR as oC,IR as oD,NM as oE,v6 as oF,W8 as oG,K8 as oH,mR as oI,$8 as oJ,G8 as oK,B8 as oL,Y8 as oM,V8 as oN,H8 as oO,q8 as oP,j6 as oQ,t6 as oR,ME as oS,e6 as oT,xI as oU,rR as oV,R8 as oW,O8 as oX,M8 as oY,I8 as oZ,eM as o_,WO as oa,YM as ob,zM as oc,eI as od,dM as oe,oM as of,iM as og,B7 as oh,QR as oi,ZR as oj,XR as ok,JR as ol,KR as om,eE as on,$E as oo,nM as op,QI as oq,IE as or,N7 as os,L8 as ot,D8 as ou,Z6 as ov,CO as ow,BE as ox,VI as oy,KI as oz,Pd as p,sI as p$,XE as p0,QE as p1,JE as p2,tM as p3,YE as p4,VE as p5,GE as p6,WE as p7,UE as p8,HE as p9,dI as pA,z8 as pB,SR as pC,lE as pD,sE as pE,_E as pF,tE as pG,VR as pH,EE as pI,YR as pJ,PE as pK,DE as pL,I7 as pM,mI as pN,_7 as pO,VM as pP,pI as pQ,ZT as pR,iI as pS,lI as pT,hI as pU,uI as pV,rI as pW,oI as pX,S6 as pY,bI as pZ,gI as p_,dO as pa,k6 as pb,E8 as pc,r7 as pd,O6 as pe,SO as pf,NO as pg,TT as ph,DM as pi,IM as pj,MM as pk,EM as pl,OM as pm,RM as pn,AM as po,TM as pp,lR as pq,o6 as pr,wI as ps,jI as pt,qA as pu,XI as pv,v7 as pw,h6 as px,qM as py,y6 as pz,ys as q,tI as q0,g6 as q1,OR as q2,AR as q3,aO as q4,nO as q5,hO as q6,fO as q7,gO as q8,mO as q9,IO as qA,Ar as qB,qE as qa,iR as qb,oR as qc,kR as qd,_R as qe,vR as qf,yR as qg,wR as qh,UR as qi,uO as qj,BT as qk,$T as ql,IA as qm,bO as qn,lO as qo,oO as qp,rO as qq,cO as qr,pO as qs,f6 as qt,_6 as qu,n6 as qv,VO as qw,_O as qx,A8 as qy,HO as qz,Q0 as r,Z0 as s,e_ as t,Re as u,Ko as v,Ds as w,ce as x,Gu as y,Yo as z};