@codeyam-editor/codeyam-editor 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/npm/cloud.js +192 -29
  2. package/npm/compose-conflict.js +59 -0
  3. package/npm/fleet-add-failure.js +123 -14
  4. package/npm/fleet-cleanup.js +129 -0
  5. package/npm/fleet-job-badge.js +28 -12
  6. package/npm/fleet-memory.js +44 -0
  7. package/npm/fleet-probe-transport.js +155 -0
  8. package/npm/fleet-revision.js +104 -0
  9. package/npm/fleet-running-plan.js +37 -7
  10. package/npm/launch-config.js +120 -4
  11. package/npm/scenario-check.js +52 -18
  12. package/npm/scenario-playwright.js +44 -10
  13. package/package.json +5 -5
  14. package/ui/dist/assets/{ContainerInspector-DgM0pTAx.js → ContainerInspector-Cu1tSN-o.js} +1 -1
  15. package/ui/dist/assets/EditorShell--V2ExYQ6.js +260 -0
  16. package/ui/dist/assets/ProjectLauncherScreen-Dmm6Z0mv.js +1 -0
  17. package/ui/dist/assets/ScenarioDataPanel-DjprZq2L.js +9 -0
  18. package/ui/dist/assets/{ScenarioDataPanelFullPage-BLqRCxQX.js → ScenarioDataPanelFullPage-BqMxWVKW.js} +1 -1
  19. package/ui/dist/assets/ScenarioRenderer-DqLVVMYS.js +21 -0
  20. package/ui/dist/assets/index-CjxWhkSy.css +1 -0
  21. package/ui/dist/assets/{index-DCHqRrwO.js → index-VuyqBbGJ.js} +2 -2
  22. package/ui/dist/assets/useServerIdentity-BdXy8TQv.js +1 -0
  23. package/ui/dist/index.html +2 -2
  24. package/ui/dist/assets/EditorShell-B7Q06uJ_.js +0 -252
  25. package/ui/dist/assets/ProjectLauncherScreen-BRrEr8Ng.js +0 -1
  26. package/ui/dist/assets/ScenarioDataPanel-BeQfa28g.js +0 -9
  27. package/ui/dist/assets/ScenarioRenderer-CIAxfHPh.js +0 -21
  28. package/ui/dist/assets/index-BygCiJSb.css +0 -1
  29. package/ui/dist/assets/useServerIdentity-B7rI0u3O.js +0 -1
@@ -0,0 +1,260 @@
1
+ var Qj=Object.defineProperty;var Zj=(t,s,n)=>s in t?Qj(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Ct=(t,s,n)=>Zj(t,typeof s!="symbol"?s+"":s,n);import{j as e}from"./markdown-C9tbsVHX.js";import{b as l,c as ys,R as st}from"./react-nrLBr15I.js";import{i as So,n as No,a as wt,r as e0,b as wr,c as da,d as ua,s as t0}from"./useEvents-S3Qk1Y_d.js";import{S as s0,b3 as gt,b4 as rt,aa as _s,b5 as n0,b6 as lr,b7 as r0,b8 as Wc,b9 as Oa,ba as Ra,u as a0,bb as Co,bc as Po,bd as To,be as Ao,bf as o0,bg as vl,a5 as i0,bh as l0,bi as c0,bj as d0,bk as u0,bl as Oo,bm as h0,a6 as p0,bn as m0,bo as f0,bp as jl,bq as g0,f as Ea,br as b0,e as Ro,bs as x0,bt as y0,i as v0,bu as wl,bv as j0,bw as w0,ab as _0,a9 as k0,bx as S0,by as N0,bz as C0,bA as P0,A as T0,bB as A0}from"./ScenarioDataPanel-DjprZq2L.js";import{e as O0,a as R0,i as an,g as Eo,d as E0,l as X,p as Ds,t as M0,P as vs,u as I0}from"./index-VuyqBbGJ.js";import{C as He,u as vn,a as dt,c as Gc,d as D0}from"./useServerIdentity-BdXy8TQv.js";import{M as Ht}from"./Markdown-Chgdf3PW.js";function Uc({count:t}){return e.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:t===1?"1 file queued":`${t} files queued`})}const HT=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCountLine:Uc},Symbol.toStringTag,{value:"Module"})),L0={webkitdirectory:""};function Yc({folderInputRef:t,onFolderPick:s}){return e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:t,type:"file",...L0,onChange:s,style:{display:"none"}}),e.jsx("button",{type:"button",onClick:()=>{var n;return(n=t.current)==null?void 0:n.click()},style:{display:"block",marginTop:"var(--spacing-xs, 4px)",marginBottom:"var(--spacing-sm, 8px)",padding:0,fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer",textDecoration:"underline"},children:"or choose a folder"})]})}const WT=Object.freeze(Object.defineProperty({__proto__:null,ChooseFolderButton:Yc},Symbol.toStringTag,{value:"Module"}));function Vc(){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 GT=Object.freeze(Object.defineProperty({__proto__:null,FullScreenIcon:Vc},Symbol.toStringTag,{value:"Module"}));function os(t,s){if(t.startsWith("http"))return t;const n=`/api/screenshots/${t}`;return typeof s=="number"?`${n}?cb=${s}`:n}function At({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?os(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 UT=Object.freeze(Object.defineProperty({__proto__:null,SafeScreenshot:At},Symbol.toStringTag,{value:"Module"}));function Kc({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(At,{screenshotPath:h.screenshotPath??void 0,cacheBuster:h.screenshotCapturedAtMs??void 0,alt:h.name,className:"max-h-[80vh] max-w-[90vw] object-contain"})})}),e.jsx("button",{type:"button",onClick:()=>d(1),disabled: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 YT=Object.freeze(Object.defineProperty({__proto__:null,ScenarioGalleryModal:Kc},Symbol.toStringTag,{value:"Module"}));function Jc({reason:t}){const{headline:s,detail:n}=Xc(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 Xc(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 ${Es(t.count,"scenario")} name ${Es(t.count,"a component","components")} not in the glossary${_l(t.examples)}.`,detail:"Deconstruct or register those components so they can be surfaced here."};case"not-visual-components":return{headline:`${t.count} ${Es(t.count,"component")} matched glossary ${Es(t.count,"entry","entries")} but ${Es(t.count,"is","are")} not recognized as visual ${Es(t.count,"component","components")}${_l(t.examples)}.`,detail:"Check `components.fileExtensions` in .codeyam/stack.json — a stack whose components are not .tsx/.jsx must list its own extensions."}}}function Es(t,s,n){return t===1?s:n??`${s}s`}function _l(t){return t.length===0?"":` (e.g. ${t.join(", ")})`}const VT=Object.freeze(Object.defineProperty({__proto__:null,ComponentSurfaceReasonNote:Jc,describeReason:Xc},Symbol.toStringTag,{value:"Module"})),F0="Good question. We'll explain this plainly as we go, and you can ask anything at any step. Nothing happens until you say go.",z0=[{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 $0(t){const s=t.toLowerCase();for(const n of z0)if(n.keywords.some(r=>s.includes(r)))return n.answer;return F0}const B0={"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 ue(t){return B0[t]}const q0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function H0(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:`${q0[n]} ${s[1]}`}function W0(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 G0=12;function U0(t,s){return t.staleness==="low"?!1:W0(t.verified,s)>G0}function ns({fact:t,asOf:s=new Date}){if(t.staleness==="low")return null;const n=U0(t,s);return e.jsxs("span",{className:"fact-fresh"+(n?" stale":""),title:`Source: ${t.source}`,children:[n?"needs re-check · ":"verified ",H0(t.verified)]})}const KT=Object.freeze(Object.defineProperty({__proto__:null,FactFreshness:ns},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 _r(){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 Qc(){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 Zc(){const t=ue("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(ns,{fact:t})]})]})}function ed(){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 td(){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 Y0=[{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 sd(){const[t,s]=l.useState(-1);return e.jsx("div",{className:"faq",children:Y0.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 nd(){const[t,s]=l.useState(""),[n,r]=l.useState(null),a=o=>{r($0(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 JT=Object.freeze(Object.defineProperty({__proto__:null,Alts:td,AskBox:nd,Check:$e,Chips:ed,Faq:sd,Journey:Qc,Reasons:Zc,VercelMark:_r},Symbol.toStringTag,{value:"Module"})),V0={"chrome.devConsole":{url:"https://chrome.google.com/webstore/devconsole",label:"Open the Chrome Web Store developer dashboard"},"chrome.register":{url:ue("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 K0(t){return V0[t]}function yt({linkKey:t,label:s}){const n=K0(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 re({children:t}){return e.jsx("div",{className:"reasons",children:t})}function O({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 Mo({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(re,{children:[e.jsxs(O,{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(O,{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 kr(){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:ue("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(yt,{linkKey:"firefox.amoDevHub"}),e.jsx(yt,{linkKey:"edge.partnerDashboard"})]})]})}const XT=Object.freeze(Object.defineProperty({__proto__:null,ChangelogSection:Mo,ReqItem:O,ReqList:re,SetupExternalLink:yt,StoreAlternativesNote:kr},Symbol.toStringTag,{value:"Module"}));function ha(t){const s=O0(t);if(s)return{selectedAppDir:s,selectedEntityHash:null};const n=R0(t);return n?{selectedAppDir:null,selectedEntityHash:n}:{selectedAppDir:null,selectedEntityHash:null}}function pa(t){return`/apps/${t}`}function J0(t){return`/entities/${t}`}function jn(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 ks(t){return(t.split("/").pop()??t).replace(/\.[^.]+$/,"")}function Ma(t){if(!t.pageFilePath)return null;const s=t.entityName??ks(t.pageFilePath);return jn(t.pageFilePath,s)}function rd(t){const s=Ma(t);return s===null?null:J0(s)}function cr({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 QT=Object.freeze(Object.defineProperty({__proto__:null,NavLink:cr},Symbol.toStringTag,{value:"Module"}));function ad({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(At,{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 ZT=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardThumbnail:ad},Symbol.toStringTag,{value:"Module"})),od=l.createContext(null),kl={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5"};function Io({routeEntity:t,onSelectRoute:s,onSelectScenario:n,columns:r=4,defaultCollapsed:a=!1}){const o=t.scenarios.length,i=l.useContext(od),[c,d]=l.useState(a);l.useEffect(()=>{i&&d(i.collapsed)},[i]);const u=rd(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(cr,{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 ${kl[r]??kl[4]}`,children:t.scenarios.map(f=>e.jsx(ad,{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 eA=Object.freeze(Object.defineProperty({__proto__:null,RouteListCard:Io},Symbol.toStringTag,{value:"Module"}));function id({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 tA=Object.freeze(Object.defineProperty({__proto__:null,GridColumnsIcon:id},Symbol.toStringTag,{value:"Module"}));function ld({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(id,{columns:r})},r))]})}const sA=Object.freeze(Object.defineProperty({__proto__:null,GridDensityControl:ld},Symbol.toStringTag,{value:"Module"}));function X0(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 cd({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(()=>X0(g),[g]),y=x.length>0&&!!a,v=l.useMemo(()=>{const _=h.trim().toLowerCase();return _?g.filter(k=>k.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=(_,k)=>k>0?`${_} · ${k}`:_;return e.jsxs("div",{children:[f&&y?e.jsx(Kc,{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(Vc,{})}),e.jsx("div",{className:"h-5 w-px bg-[var(--border-subtle)]"})]}):null,e.jsx(ld,{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((_,k)=>e.jsx(Io,{routeEntity:_,onSelectRoute:r,onSelectScenario:a,columns:d,defaultCollapsed:b},_.route??_.displayName??k)):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(Jc,{reason:n}):e.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",b?"components":"pages"," yet."]})]})}const nA=Object.freeze(Object.defineProperty({__proto__:null,RouteListTabs:cd},Symbol.toStringTag,{value:"Module"}));function Do(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 Ia(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 dd(t){return So(t)?t.componentName??Ia(t.name).pageName:Ia(t.name).pageName}function Sr(t){return Ia(t.name).stateName}function ud({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(()=>Do(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:os(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:Sr(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 rA=Object.freeze(Object.defineProperty({__proto__:null,LivePageScenariosModal:ud},Symbol.toStringTag,{value:"Module"})),Ss={apps:[],isSingleApp:!1,onSelectApps:()=>{},onSelectApp:()=>{},onSelectRoute:()=>{}};function Ns(){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 Q0(t){const[s,n]=l.useState({status:"idle"}),{scenariosVersion:r}=Ns();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(No):[]};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 Jn({message:t}){return e.jsx("div",{className:"px-5 py-8",children:e.jsx(He,{text:t,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}const aA=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentError:Jn},Symbol.toStringTag,{value:"Module"}));function Da(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"Loading routes..."})}const oA=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentLoading:Da},Symbol.toStringTag,{value:"Module"}));function Z0(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 hd({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 iA=Object.freeze(Object.defineProperty({__proto__:null,EntityRefCard:hd},Symbol.toStringTag,{value:"Module"}));function Xn({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(hd,{entityRef:n,onNavigate:s})},n.hash))})}const lA=Object.freeze(Object.defineProperty({__proto__:null,EntityRefList:Xn},Symbol.toStringTag,{value:"Module"}));function ew(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 tw(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 sw({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 pd({overrideCounts:t}){const s=t?sw(t):null;return s?e.jsx("div",{className:"text-xs text-[var(--text-dim)] mt-1",children:s}):null}const cA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowOverrideBadge:pd},Symbol.toStringTag,{value:"Module"})),nw=new Set(["Desktop"]);function md(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 fd({scenario:t,isSelected:s}){var r;const n=t.dimensions.length>0&&!(t.dimensions.length===1&&nw.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:md(t)}),e.jsx(pd,{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 dA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowMeta:fd,deriveRowLabel:md},Symbol.toStringTag,{value:"Module"}));function gd({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(At,{screenshotPath:t??void 0,cacheBuster:s??void 0,alt:""})})}const uA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowThumbnail:gd},Symbol.toStringTag,{value:"Module"}));function bd({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 hA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowActions:bd},Symbol.toStringTag,{value:"Module"}));function xd({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 pA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRenameForm:xd},Symbol.toStringTag,{value:"Module"}));function yd({scenario:t,isSelected:s,onSelect:n,onViewData:r,onScenariosChanged:a,children:o}){const i=ew(t.slug,t.name,a),{deleting:c,handleDelete:d}=tw(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(gd,{screenshotPath:t.screenshotPaths[0]??null,cacheBuster:t.screenshotCapturedAtMs}),e.jsx("div",{className:"flex-1 min-w-0",children:i.renaming?e.jsx(xd,{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(fd,{scenario:t,isSelected:s}),s&&e.jsx(bd,{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 mA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRow:yd},Symbol.toStringTag,{value:"Module"}));function vd(){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 fA=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioEmptyState:vd},Symbol.toStringTag,{value:"Module"}));function Lo({scenarios:t,selectedSlug:s,onSelectScenario:n,onScenariosChanged:r}){const[a,o]=l.useState(null);return t.length===0?e.jsx(vd,{}):e.jsx("div",{className:"grid grid-cols-1 gap-2",children:t.map(i=>e.jsx(yd,{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(s0,{variant:"inline",slug:i.slug,scenarioName:i.name,onClose:()=>o(null)})},i.slug))})}const gA=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioList:Lo},Symbol.toStringTag,{value:"Module"})),rw="This component renders no other tracked components.",aw="This component imports no tracked functions.",ow="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 jd({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(sn,{copy:Z0(s)}):e.jsx(Lo,{scenarios:s.scenarios,selectedSlug:a,onSelectScenario:o,onScenariosChanged:c})),t==="components"&&(n.length===0?e.jsx(sn,{copy:rw}):e.jsx(Xn,{refs:n,onNavigate:i})),t==="functions"&&(r.length===0?e.jsx(sn,{copy:aw}):e.jsx(Xn,{refs:r,onNavigate:i})),t==="callers"&&(s.callers.length===0?e.jsx(sn,{copy:ow}):e.jsx(Xn,{refs:s.callers,onNavigate:i}))]})}function sn({copy:t}){return e.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:t})}const bA=Object.freeze(Object.defineProperty({__proto__:null,EmptyTabCopy:sn,EntityDetailContent:jd},Symbol.toStringTag,{value:"Module"}));function iw(t){return typeof t!="string"&&typeof t.onClick=="function"}function lw(t){return typeof t=="string"?t:t.label}function cw(t,s){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s())}function wd({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=lw(n),o=r===s,i=!o&&iw(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=>cw(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 xA=Object.freeze(Object.defineProperty({__proto__:null,BreadcrumbNav:wd},Symbol.toStringTag,{value:"Module"}));function Nr({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(wd,{segments:d})}const yA=Object.freeze(Object.defineProperty({__proto__:null,EntityBreadcrumb:Nr},Symbol.toStringTag,{value:"Module"}));function _d({entity:t,app:s=null,routeEntity:n=null,navContext:r=Ss}){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(Nr,{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 vA=Object.freeze(Object.defineProperty({__proto__:null,EntityDetailHeader:_d},Symbol.toStringTag,{value:"Module"})),dw=["scenarios","components","functions"];function Fo({activeTab:t,onTabChange:s,scenarioCount:n,componentCount:r=0,functionCount:a=0,callersCount:o=0,tabs:i=dw}){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 jA=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityTabs:Fo},Symbol.toStringTag,{value:"Module"})),uw=["scenarios","components","functions"],hw=["scenarios","callers"];function kd({app:t=null,navContext:s=Ss,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"?hw:uw;return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(_d,{app:t,navContext:s,routeEntity:n,entity:r}),e.jsx(Fo,{activeTab:d,onTabChange:u,scenarioCount:r.scenarios.length,componentCount:h.length,functionCount:p.length,callersCount:r.callers.length,tabs:f}),e.jsx(jd,{activeTab:d,entity:r,componentRefs:h,functionRefs:p,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c})]})}const wA=Object.freeze(Object.defineProperty({__proto__:null,EntityDetail:kd},Symbol.toStringTag,{value:"Module"}));function pw(t){const s=[],n=[];for(const r of t)an(r.url)||(r.scenarioType==="component"?n.push(r):s.push(r));return{application:s,component:n}}function Sd({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:os(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 _A=Object.freeze(Object.defineProperty({__proto__:null,ScenarioCard:Sd},Symbol.toStringTag,{value:"Module"}));function La({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(Sd,{scenario:a,onPreview:()=>n(a.slug)},a.slug))})]})}const kA=Object.freeze(Object.defineProperty({__proto__:null,ScenarioTypeSection:La},Symbol.toStringTag,{value:"Module"}));function Nd({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 SA=Object.freeze(Object.defineProperty({__proto__:null,TestGroupHeader:Nd},Symbol.toStringTag,{value:"Module"}));function Cd({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 NA=Object.freeze(Object.defineProperty({__proto__:null,TestGroupRow:Cd},Symbol.toStringTag,{value:"Module"}));function Pd({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(Nd,{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(Cd,{test:o},`${o.file}-${o.key??o.line??i}`))})]},s.feature)})})}const CA=Object.freeze(Object.defineProperty({__proto__:null,TestGroupList:Pd},Symbol.toStringTag,{value:"Module"}));function Td({allScenarios:t,testGroups:s,onSelectScenario:n}){const{application:r,component:a}=pw(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(La,{label:"Application",scenarios:r,onSelectScenario:n}),a.length>0&&e.jsx(La,{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(Pd,{groups:s})})]})}const PA=Object.freeze(Object.defineProperty({__proto__:null,NonWebAppDetail:Td},Symbol.toStringTag,{value:"Module"}));function mw(t,s){const n=[],r=[];for(const a of t){const o=ks(a);/^[A-Z]/.test(o)&&!o.startsWith("use")?n.push(a):r.push(a)}return{componentImports:n,functionImports:r}}function Ad({ancestor:t,onNavigateToEntity:s}){const n=s?()=>s(jn(t.filePath,ks(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 TA=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainCard:Ad},Symbol.toStringTag,{value:"Module"}));function Od({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(Ad,{ancestor:n,onNavigateToEntity:s},`${n.kind}:${n.filePath}`))})]})}const AA=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainSection:Od},Symbol.toStringTag,{value:"Module"}));function fw({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&&ks(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 Qn(t){const s=[];for(const n of t.split("/"))n===""||n==="."||(n===".."?s.pop():s.push(n));return s.join("/")}function gw(t){const s=new Map;for(const[n,r]of Object.entries(t)){const a=Qn(n),o=ks(a),i=jn(a,o);s.has(i)||s.set(i,{hash:i,filePath:a,entityName:o,imports:r.imports.map(Qn),importedBy:r.importedBy.map(Qn)})}return s}function bw(t,s){if(!t)return null;const n=Qn(s);for(const r of t.values())if(r.filePath===n)return r;return null}function Rd(t,s){if(!t)return[];const n=[];for(const r of s){const a=bw(t,r);a&&n.push(a)}return n}function xw(t,s){return t.find(n=>n.pageFilePath===s)??null}function Ed(t){const s=t.split("/"),n=s.pop()??t,r=s.join("/");return{fileName:n,dirPath:r}}function Md({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 OA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCardHeader:Md},Symbol.toStringTag,{value:"Module"}));function Id({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(At,{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 RA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyScenarioStrip:Id},Symbol.toStringTag,{value:"Module"}));function Dd({importPath:t,entity:s,scenarios:n,onNavigate:r,onSelectScenario:a}){const{fileName:o,dirPath:i}=Ed(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(Md,{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(Id,{scenarios:n,onSelectScenario:a})]})}const EA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCard:Dd},Symbol.toStringTag,{value:"Module"}));function Ld(){return e.jsx("p",{className:"py-4 text-center text-xs text-[var(--text-dim)]",children:"No dependencies found"})}const MA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyEmptyState:Ld},Symbol.toStringTag,{value:"Module"}));function Fd({directImports:t,entityLookup:s,allScenarios:n,routeEntities:r,onNavigateToRoute:a,onNavigateToEntity:o,onSelectScenario:i}){const c=l.useMemo(()=>Rd(s,t),[s,t]);return t.length===0?e.jsx(Ld,{}):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)??ks(d),p=fw({importPath:d,derivedName:h,allScenarios:n??[],routeEntities:r??[]}),f=xw(r??[],d),m=jn(d,h),b=f?()=>a(f.route):o?()=>o(m):null;return e.jsx(Dd,{importPath:d,entity:u,scenarios:p,onNavigate:b,onSelectScenario:i},d)})})}const IA=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyList:Fd},Symbol.toStringTag,{value:"Module"}));function yw(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 zd({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 DA=Object.freeze(Object.defineProperty({__proto__:null,TestStatusIcon:zd},Symbol.toStringTag,{value:"Module"}));function $d({test:t}){const s=t.description.length>0;return e.jsxs("div",{className:"flex items-start gap-2 py-1",children:[e.jsx(zd,{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 LA=Object.freeze(Object.defineProperty({__proto__:null,TestItem:$d},Symbol.toStringTag,{value:"Module"}));function Bd({importPath:t,entityName:s,tests:n,onNavigate:r}){const{dirPath:a}=Ed(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($d,{test:o},`${o.file}:${o.key??o.line??i}`))}):e.jsx("p",{className:"text-xs text-[var(--text-dim)] italic",children:"No tests"})})]})}const FA=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionCard:Bd},Symbol.toStringTag,{value:"Module"}));function qd(){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 zA=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionEmptyState:qd},Symbol.toStringTag,{value:"Module"}));function Hd({functionImports:t,entityLookup:s,testGroups:n,onNavigateToEntity:r}){const a=l.useMemo(()=>Rd(s,t),[s,t]);return t.length===0?e.jsx(qd,{}):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)??ks(o),d=yw(o,s,n),u=r?()=>r(jn(o,c)):null;return e.jsx(Bd,{importPath:o,entityName:c,tests:d,onNavigate:u},o)})})}const $A=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionList:Hd},Symbol.toStringTag,{value:"Module"}));function Wd({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(Lo,{scenarios:s.scenarios,selectedSlug:o,onSelectScenario:u,onScenariosChanged:f}),t==="components"&&e.jsx(Fd,{directImports:n,entityLookup:i,allScenarios:c,routeEntities:d,onNavigateToRoute:h,onNavigateToEntity:p,onSelectScenario:u}),t==="functions"&&e.jsx(Hd,{functionImports:r,entityLookup:i,testGroups:a,onNavigateToEntity:p})]})}const BA=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailContent:Wd},Symbol.toStringTag,{value:"Module"}));function Gd({displayName:t,pageFilePath:s,app:n=null,routeEntity:r=null,navContext:a=Ss}){return e.jsxs("div",{className:"px-5 py-4",children:[e.jsx("div",{className:"mb-2",children:e.jsx(Nr,{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 qA=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailHeader:Gd},Symbol.toStringTag,{value:"Module"}));function Ud({app:t=null,navContext:s=Ss,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(()=>mw(n.directImports),[n.directImports]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(Gd,{app:t,navContext:s,routeEntity:n,displayName:n.displayName,pageFilePath:n.pageFilePath}),e.jsx(Od,{layoutChain:n.layoutChain??[],onNavigateToEntity:h}),e.jsx(Fo,{activeTab:f,onTabChange:m,scenarioCount:n.scenarios.length,componentCount:b.length,functionCount:g.length}),e.jsx(Wd,{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 HA=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetail:Ud},Symbol.toStringTag,{value:"Module"}));function Yd(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No routes discovered yet."})}const WA=Object.freeze(Object.defineProperty({__proto__:null,RouteListEmptyState:Yd},Symbol.toStringTag,{value:"Module"}));function Vd({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 GA=Object.freeze(Object.defineProperty({__proto__:null,RouteListSectionHeader:Vd},Symbol.toStringTag,{value:"Module"}));function Fa({label:t,routeEntities:s,onSelectRoute:n,onSelectScenario:r,className:a}){return e.jsxs("div",{className:a,children:[e.jsx(Vd,{label:t}),e.jsx("div",{children:s.map(o=>e.jsx(Io,{routeEntity:o,onSelectRoute:n,onSelectScenario:r},o.route))})]})}const UA=Object.freeze(Object.defineProperty({__proto__:null,RouteListSection:Fa},Symbol.toStringTag,{value:"Module"}));function Kd({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 YA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageInvestigateButton:Kd},Symbol.toStringTag,{value:"Module"}));function Jd({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 VA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRowSummary:Jd},Symbol.toStringTag,{value:"Module"}));function vw(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 jw({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.",vw(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 Xd(t){return t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}function Qd({page:t}){const[s,n]=l.useState(!1),{config:r}=gt(),a=rt(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(Jd,{displayName:t.displayName,path:t.path}),e.jsx(Kd,{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(_s,{chatName:`fix-unsurfaced-${Xd(t.path)}`,prompt:jw({path:t.path,reason:t.reason}),height:360,onClose:()=>n(!1)})})]})}const KA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRow:Qd,chatSlug:Xd},Symbol.toStringTag,{value:"Module"}));function Zd({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(Qd,{page:n},n.path))]})}const JA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageGroup:Zd},Symbol.toStringTag,{value:"Module"}));function eu({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 XA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSectionHeader:eu},Symbol.toStringTag,{value:"Module"})),ww=[{reason:"missing-from-glossary",label:"Missing from glossary"},{reason:"scaffold",label:"Marked as scaffold"}];function tu({pages:t}){const[s,n]=l.useState(!0);return t.length===0?null:e.jsxs("div",{className:"mt-8",children:[e.jsx(eu,{count:t.length,collapsed:s,onToggle:()=>n(r=>!r)}),!s&&e.jsx("div",{children:ww.map(({reason:r,label:a})=>e.jsx(Zd,{label:a,pages:t.filter(o=>o.reason===r)},r))})]})}const QA=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSection:tu},Symbol.toStringTag,{value:"Module"}));function su({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(Yd,{});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(cd,{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(Fa,{label:"Pages",routeEntities:c,onSelectRoute:r,onSelectScenario:a}),d.length>0&&e.jsx(Fa,{label:"Components",routeEntities:d,onSelectRoute:r,onSelectScenario:a,className:c.length>0?"mt-8":void 0}),e.jsx(tu,{pages:s})]})}const ZA=Object.freeze(Object.defineProperty({__proto__:null,RouteList:su},Symbol.toStringTag,{value:"Module"}));function zo({app:t=null,navContext:s=Ss,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 _=Q0(d&&!u?d:null);return n?i?e.jsx(Da,{}):c?e.jsx(Jn,{message:c}):u?e.jsx(Ud,{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(Da,{}):_.status==="not-found"?e.jsx(Jn,{message:"Entity not found. The dependency graph may need to be refreshed."}):_.status==="error"?e.jsx(Jn,{message:_.message}):e.jsx(kd,{app:t,navContext:s,routeEntity:u,entity:_.entity,selectedSlug:p,onSelectScenario:b,onNavigateToEntity:x??(()=>{}),onScenariosChanged:v}):e.jsx(su,{routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,onSelectRoute:g,onSelectScenario:b,tabbed:j,headerAccessory:w}):e.jsx(Td,{allScenarios:m,testGroups:h,onSelectScenario:b})}const eO=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContent:zo},Symbol.toStringTag,{value:"Module"}));function nu({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(od.Provider,{value:n,children:e.jsx("div",{className:"-mx-5",children:e.jsx(zo,{...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 tO=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreSection:nu},Symbol.toStringTag,{value:"Module"}));function ae({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 Zt({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 Ft({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 pe({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 sO=Object.freeze(Object.defineProperty({__proto__:null,SetupCompleteCta:pe,SetupDetailHeader:ae,SetupFlowBar:Ft,SetupSubCrumb:Zt},Symbol.toStringTag,{value:"Module"}));function Cr({initial:t,color:s}){return e.jsx("div",{className:"altmark",style:{background:s,width:46,height:46},children:t})}function $o({provider:t}){return e.jsxs("div",{className:"provcard"+(t.bestFit?" best":""),children:[e.jsx(Cr,{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 ru({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 Ue({items:t}){return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),e.jsx(au,{items:t})]})}function au({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 nO=Object.freeze(Object.defineProperty({__proto__:null,Alternatives:ru,FaqSection:Ue,ProviderCard:$o,ProviderMark:Cr,TopicFaq:au},Symbol.toStringTag,{value:"Module"}));function Bo({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(ae,{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(Ue,{items:h})]})}const rO=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPage:Bo},Symbol.toStringTag,{value:"Module"}));function gs({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 bs({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 xs({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 Zn({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 Yt({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 za({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 aO=Object.freeze(Object.defineProperty({__proto__:null,SetupBars:Zn,SetupChannels:za,SetupEmblem:Yt,SetupOrbit:xs,SetupSplit:gs,SetupStack:bs},Symbol.toStringTag,{value:"Module"}));function Vt({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 oO=Object.freeze(Object.defineProperty({__proto__:null,SetupJourney:Vt},Symbol.toStringTag,{value:"Module"}));function ou(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 iu(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 _w=5e3,Sl={headSha:null,branch:null};function kw(){const[t,s]=l.useState([]),[n,r]=l.useState(Sl),[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??Sl),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)},_w);return()=>clearInterval(p)},[u]),{reviews:t,repoState:n,loading:a,error:i,reload:h}}function Sw(t,s){var r;const n=(r=t.pr)==null?void 0:r.headRef;return!!n&&!!s.branch&&s.branch===n}const Nw=192;function Pr({children:t,variant:s="compact",maxHeight:n=Nw,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(Ht,{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 iO=Object.freeze(Object.defineProperty({__proto__:null,CollapsibleMarkdown:Pr},Symbol.toStringTag,{value:"Module"}));function Xt({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 lO=Object.freeze(Object.defineProperty({__proto__:null,LabeledSection:Xt},Symbol.toStringTag,{value:"Module"}));function Tr({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 cO=Object.freeze(Object.defineProperty({__proto__:null,FileStatusIndicator:Tr},Symbol.toStringTag,{value:"Module"}));function lu({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(Tr,{status:s.status})," ",s.path]},s.path))})}const dO=Object.freeze(Object.defineProperty({__proto__:null,ModifiedFilesList:lu},Symbol.toStringTag,{value:"Module"}));function Cw(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 cu({finding:t}){const s=Cw(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 uO=Object.freeze(Object.defineProperty({__proto__:null,ReviewFindingRow:cu},Symbol.toStringTag,{value:"Module"}));function Pw(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 $a({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(At,{screenshotPath:s,alt:r})})]})}function du({pair:t,walkable:s,headRef:n,prNumber:r,onPreviewImage:a}){const o=Pw(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($a,{label:"Before",path:t.beforePath,onPreview:a}),e.jsx($a,{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 hO=Object.freeze(Object.defineProperty({__proto__:null,CapturePane:$a,ScenarioComparisonRow:du},Symbol.toStringTag,{value:"Module"}));function uu({scenarios:t,walkable:s,headRef:n,prNumber:r,onPreviewImage:a}){const[o,i]=l.useState(!1),{changed:c,created:d,unchanged:u}=iu(t);if((t??[]).length===0)return e.jsx(Xt,{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(du,{pair:p,walkable:s,headRef:n,prNumber:r,onPreviewImage:a},p.slug);return e.jsx(Xt,{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 pO=Object.freeze(Object.defineProperty({__proto__:null,ScenarioImpactSection:uu},Symbol.toStringTag,{value:"Module"}));function Ar({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 mO=Object.freeze(Object.defineProperty({__proto__:null,TestResultsBadge:Ar},Symbol.toStringTag,{value:"Module"}));function hu({review:t,repoState:s,onPreviewImage:n}){var d,u,h,p,f,m,b,g,x;const r=ou(t),a=Sw(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(uu,{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(Xt,{label:"What this PR does",children:e.jsx(Pr,{children:t.narrative})}),e.jsx(Xt,{label:"Tests",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ar,{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(Xt,{label:`Findings (${o.length})`,children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((y,v)=>e.jsx(cu,{finding:y},`${y.file??"f"}-${v}`))})}),((x=t.alignment)==null?void 0:x.summary)&&e.jsx(Xt,{label:"Codeyam alignment",children:e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.alignment.summary})}),c.length>0&&e.jsx(Xt,{label:"Changed files",children:e.jsx(lu,{files:c})})]})}const fO=Object.freeze(Object.defineProperty({__proto__:null,ReviewDetailCard:hu},Symbol.toStringTag,{value:"Module"}));function Tw(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 Aw(t){return t==null?null:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function pu({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(He,{text:t.parseError,copyText:`${t.id}: could not read digest
8
+ ${t.parseError??""}`,className:"text-xs text-[var(--text-dim)]",rowClassName:"mt-1"})]});const a=iu(t.scenarios),o=Tw(t),i=ou(t),c=Aw(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(hu,{review:t,repoState:s})})]})}const gO=Object.freeze(Object.defineProperty({__proto__:null,ReviewCard:pu},Symbol.toStringTag,{value:"Module"}));function mu({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 bO=Object.freeze(Object.defineProperty({__proto__:null,WebFallbackNotice:mu},Symbol.toStringTag,{value:"Module"}));function fu({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 xO=Object.freeze(Object.defineProperty({__proto__:null,PreviewSignInNotice:fu},Symbol.toStringTag,{value:"Module"}));function qo(){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 yO=Object.freeze(Object.defineProperty({__proto__:null,MockupGridEmptyState:qo},Symbol.toStringTag,{value:"Module"}));function Ba({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 vO=Object.freeze(Object.defineProperty({__proto__:null,RunTestsButton:Ba},Symbol.toStringTag,{value:"Module"}));function gu({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 jO=Object.freeze(Object.defineProperty({__proto__:null,TestBar:gu},Symbol.toStringTag,{value:"Module"}));function Ho({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(gu,{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(Ba,{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(Ba,{onRunTests:r})]}):e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"No tests"})}const wO=Object.freeze(Object.defineProperty({__proto__:null,AppTestSummary:Ho},Symbol.toStringTag,{value:"Module"}));function bu({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(Ho,{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 _O=Object.freeze(Object.defineProperty({__proto__:null,AppCardFooter:bu},Symbol.toStringTag,{value:"Module"}));function Wo({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 kO=Object.freeze(Object.defineProperty({__proto__:null,AppTypeBadge:Wo},Symbol.toStringTag,{value:"Module"}));function xu({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(Wo,{type:t.type})]}),t.description?e.jsx("p",{className:"text-sm text-[var(--text-muted)] leading-relaxed",children:t.description}):null]})}const SO=Object.freeze(Object.defineProperty({__proto__:null,AppCardHeader:xu},Symbol.toStringTag,{value:"Module"}));function yu({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(At,{screenshotPath:s.path,cacheBuster:s.cacheBuster??void 0,alt:""})},`${s.path}:${n}`))})}const NO=Object.freeze(Object.defineProperty({__proto__:null,ThumbnailStrip:yu},Symbol.toStringTag,{value:"Module"}));function vu({thumbnails:t}){return e.jsx("div",{className:"px-5 py-3 flex-1",children:t.length>0?e.jsx(yu,{thumbnails:t.slice(0,4)}):e.jsx("div",{className:"h-20"})})}const CO=Object.freeze(Object.defineProperty({__proto__:null,AppCardScenarioStrip:vu},Symbol.toStringTag,{value:"Module"}));function ju({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(xu,{app:i}),e.jsx(vu,{thumbnails:d.thumbnails}),e.jsx(bu,{tests:c,loading:n,refreshing:r,onRunTests:a,currentRunner:o})]})}const PO=Object.freeze(Object.defineProperty({__proto__:null,AppCard:ju},Symbol.toStringTag,{value:"Module"}));function Go({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 TO=Object.freeze(Object.defineProperty({__proto__:null,CoverageBadge:Go},Symbol.toStringTag,{value:"Module"}));function wu({app:t,showDetail:s,navContext:n=Ss,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(Nr,{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(Wo,{type:t.type})]}),h?e.jsx(Go,{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(Ho,{tests:r.tests,loading:a,refreshing:o,onRunTests:i,currentRunner:c})}):null]})}const AO=Object.freeze(Object.defineProperty({__proto__:null,AppDetailHeader:wu},Symbol.toStringTag,{value:"Module"}));function _u({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 OO=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelSummary:_u},Symbol.toStringTag,{value:"Module"})),qa=["layout-web","interactions-click","interactions-touch-gestures","native-haptics","native-geolocation","native-clipboard","native-network","native-storage","routing","http-mocks","real-device"],ku={"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"}},Su={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 Ow(t){var s;return((s=ku[t])==null?void 0:s.label)??t}function Rw(t,s){var a,o;const n=(a=ku[t])==null?void 0:a.description,r=((o=Su[s])==null?void 0:o.meaning)??"";return n?`${n}. ${r}`:r}function Nu({capabilities:t,defaultExpanded:s=!1}){const[n,r]=l.useState(s),a=qa.filter(c=>c in t),o=Object.keys(t).filter(c=>!qa.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(Ha,{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(Ha,{token:c,state:t[c],unknown:!0},c))]}):null]}):null]})}function Ha({token:t,state:s,unknown:n}){const r=Su[s],a=n?"This token isn't recognized — may be a typo.":Rw(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:[Ow(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 RO=Object.freeze(Object.defineProperty({__proto__:null,AppCapabilitiesPanel:Nu,CapabilityRow:Ha},Symbol.toStringTag,{value:"Module"}));function Cu({capabilities:t}){return t&&Object.keys(t).length>0?e.jsx(Nu,{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 EO=Object.freeze(Object.defineProperty({__proto__:null,AppStackCapabilitiesSlot:Cu},Symbol.toStringTag,{value:"Module"}));function Pu({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(Cu,{capabilities:s})})]})}const MO=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelBody:Pu},Symbol.toStringTag,{value:"Module"}));function Tu({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 Ew=["dev","test","build"];function es(t){return typeof t=="string"&&t.length>0?t:null}function Au(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Mw(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Iw(t){const s=Au(t);if(!s)return[];const n=[];for(const r of Ew){const a=es(s[r]);a&&n.push({key:r,value:a})}return n}function Dw(t){const s=Au(t);if(!s)return null;const n=es(s.type);if(!n)return null;const r=es(s.pagesDir)??es(s.isolationRoute)??es(s.componentManifest);return r?`${n} (${r})`:n}function Lw(t){const s=t.capabilities;return!s||typeof s!="object"||Array.isArray(s)?null:s}function Fw(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 qa){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 zw(t){return t?{id:es(t.id),name:es(t.name),description:es(t.description),technologies:Mw(t.technologies),commands:Iw(t.commands),routingSummary:Dw(t.routing)}:{id:null,name:null,description:null,technologies:[],commands:[],routingSummary:null}}function Ou({stack:t,defaultExpanded:s=!1}){const n=t!==void 0,[r,a]=l.useState(s),o=Tu({skip:n}),i=n?t:o;if(!i||Object.keys(i).length===0)return null;const c=zw(i),d=Lw(i);return e.jsxs("div",{className:"px-5 py-2","data-testid":"stack-panel",children:[e.jsx(_u,{name:c.name,id:c.id,capabilitiesTally:Fw(d),expanded:r,onToggle:()=>a(u=>!u)}),r?e.jsx(Pu,{fields:c,capabilities:d}):null]})}const IO=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanel:Ou},Symbol.toStringTag,{value:"Module"}));function Ru({app:t,navContext:s=Ss,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:k,testsRefreshing:C,onRunTests:S,currentRunner:T}){const A=t.type==="web",E=!!j&&!d;return e.jsxs("div",{children:[E?e.jsx(Ou,{}):null,e.jsx(wu,{app:t,showDetail:!!(d||c),navContext:s,stats:_,testsLoading:k,testsRefreshing:C,onRunTests:S,currentRunner:T,coverage:E?v:void 0,onCoverageClick:w}),e.jsx(zo,{app:t,navContext:s,isWeb:A,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 DO=Object.freeze(Object.defineProperty({__proto__:null,AppDetail:Ru},Symbol.toStringTag,{value:"Module"}));function Eu(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 Mu(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 LO(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 Uo({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(At,{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 FO=Object.freeze(Object.defineProperty({__proto__:null,ScenarioThumbnailGrid:Uo},Symbol.toStringTag,{value:"Module"}));function ts({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 zO=Object.freeze(Object.defineProperty({__proto__:null,TabScrollPanel:ts},Symbol.toStringTag,{value:"Module"}));function Iu(){const{reviews:t,repoState:s,loading:n,error:r}=kw(),[a,o]=l.useState(null);return n?e.jsx(ts,{children:e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading reviews..."})}):r&&t.length===0?e.jsx(ts,{children:e.jsx("div",{className:"py-12",children:e.jsx(He,{text:`Failed to load reviews: ${r}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}):t.length===0?e.jsx(ts,{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(ts,{children:e.jsx("div",{className:"flex flex-col gap-3",children:t.map(i=>e.jsx(pu,{review:i,repoState:s,expanded:a===i.id,onToggle:()=>o(c=>c===i.id?null:i.id)},i.id))})})}const $O=Object.freeze(Object.defineProperty({__proto__:null,ReviewsTab:Iu},Symbol.toStringTag,{value:"Module"}));function Du({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 Lu({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 js({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 wn({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 Oe({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 Hs({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 Ie({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 Or({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 $s({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 $t({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 vt({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 Pe({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 Bt({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 nt({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 Yo({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 BO=Object.freeze(Object.defineProperty({__proto__:null,BellIcon:Yo,BoxIcon:nt,CardIcon:$t,ChartIcon:vt,CloudIcon:js,DatabaseIcon:wn,DocIcon:Pe,ExploreIcon:Du,GlobeIcon:Bt,LockIcon:Oe,MailIcon:Hs,PlansIcon:Lu,RocketIcon:Ie,SetupIcon:Or,TerminalIcon:$s},Symbol.toStringTag,{value:"Module"})),$w=[{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"}],Bw={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 Fu({intent:t="add",onSubmit:s,onCancel:n}){const r=Bw[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:$w.map(y=>e.jsx("option",{value:y.key,children:y.label},y.key))})]}),f?e.jsx("div",{className:"atf-error",children:e.jsx(He,{text:f,className:""})}):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 qO=Object.freeze(Object.defineProperty({__proto__:null,AddTopicForm:Fu},Symbol.toStringTag,{value:"Module"}));function zu({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 HO=Object.freeze(Object.defineProperty({__proto__:null,SetupAddTopicRow:zu},Symbol.toStringTag,{value:"Module"}));function qw(){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 Hw={concepts:[],byKey:()=>{}},Rr=l.createContext(Hw);function $u({children:t}){const s=qw();return e.jsx(Rr.Provider,{value:s,children:t})}function Bu(){return l.useContext(Rr)}function qu(t){return l.useContext(Rr).byKey(t)}const WO=Object.freeze(Object.defineProperty({__proto__:null,ConceptsContext:Rr,ConceptsProvider:$u,useConcept:qu,useConceptIndex:Bu},Symbol.toStringTag,{value:"Module"}));function er({k:t,children:s}){const n=qu(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?ys.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(Ht,{variant:"compact",children:n.body})})]}),document.body):null]}):e.jsx(e.Fragment,{children:s})}const GO=Object.freeze(Object.defineProperty({__proto__:null,ConceptTerm:er},Symbol.toStringTag,{value:"Module"}));function Hu(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 Wu({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:Hu(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 UO=Object.freeze(Object.defineProperty({__proto__:null,DetectedServiceRow:Wu,evidenceSummary:Hu},Symbol.toStringTag,{value:"Module"})),Ww={terminal:$s,cloud:js,database:wn,lock:Oe,mail:Hs,card:$t,chart:vt,doc:Pe,globe:Bt,box:nt,bell:Yo,rocket:Ie};function Gw(t){return Ww[t]??Or}function Uw(t){return t==="done"?"trow done":t==="next"||t==="in-progress"?"trow next":"trow soon"}function Yw(t){return t==="done"?"set up":t==="in-progress"?"in progress":t==="next"?"next":"explore"}function Wa({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(er,{k:"hosting",children:"hosting"}),", a"," ",e.jsx(er,{k:"domain",children:"domain"}),", or"," ",e.jsx(er,{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=Gw(g.icon),y=p.get(g.key)??[];return e.jsxs("div",{className:"trow-group",children:[e.jsxs("button",{type:"button",className:Uw(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:Yw(g.status)}),e.jsx("span",{className:"arrow",children:"→"})]}),y.length>0?e.jsx("div",{className:"detected-services",children:y.map(v=>e.jsx(Wu,{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(nt,{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(zu,{onAdd:()=>m("add"),onAsk:()=>m("ask")}):null,f&&d?e.jsx(Fu,{intent:f,onSubmit:b,onCancel:()=>m(null)}):null]})}const YO=Object.freeze(Object.defineProperty({__proto__:null,LearnSetupScreen:Wa},Symbol.toStringTag,{value:"Module"}));function on({command:t,writer:s}){const{copied:n,copy:r}=vn({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 VO=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyCommandRow:on},Symbol.toStringTag,{value:"Module"}));function Vw(t){return t==="dev"?"dev":t==="transitive"?"transitive":"direct"}function Gu({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:Vw(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(on,{command:t.updateCommand,writer:s})]})}const KO=Object.freeze(Object.defineProperty({__proto__:null,LibraryRow:Gu},Symbol.toStringTag,{value:"Module"}));function Kw(t,s){return s?`${t.name} ${t.description??""} ${t.category??""}`.toLowerCase().includes(s):!0}function Uu({group:t,query:s,forceOpen:n,copyWriter:r}){const[a,o]=l.useState(t.libraries.length<=8),i=t.libraries.filter(d=>Kw(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(nt,{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(Gu,{lib:d,copyWriter:r},d.name))})]})}const JO=Object.freeze(Object.defineProperty({__proto__:null,LibraryGroupSection:Uu},Symbol.toStringTag,{value:"Module"}));function Yu({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(Uu,{group:c,query:o,forceOpen:o.length>0,copyWriter:n},c.manifestPath))})]})]})}const XO=Object.freeze(Object.defineProperty({__proto__:null,LibrariesCatalogScreen:Yu},Symbol.toStringTag,{value:"Module"}));function Vo(t){switch(t){case"real-data":return e.jsx(gs,{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(gs,{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(gs,{before:{tag:"Cryptic",items:["Confusing errors","Guess the flags"]},after:{tag:"Polished",items:["Clear help & output","Helpful messages"]}});case"forms":return e.jsx(gs,{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(gs,{before:{tag:"Default link",items:["Generic address","Hard to remember"]},after:{tag:"Your domain",items:["yourname.com","Secure & trusted"]}});case"accounts":return e.jsx(xs,{center:{emoji:"🔑",label:"Sign-in"},satellites:["✉️ Email link","🔵 Google","🍎 Apple","🔒 Password"]});case"emails":return e.jsx(xs,{center:{emoji:"✉️",label:"Your app sends"},satellites:["👋 Welcome","🔑 Password reset","🧾 Receipt","🔔 Notification"]});case"api-auth":return e.jsx(xs,{center:{emoji:"🛡️",label:"Your API"},satellites:["🎟️ API key","🪪 Token","⛔ Revoke anytime"]});case"cors-origins":return e.jsx(xs,{center:{emoji:"🚦",label:"Your API"},satellites:["✅ your-site.com","✅ app.your-site.com","⛔ everyone else"]});case"comments-search":return e.jsx(xs,{center:{emoji:"📚",label:"Your content"},satellites:["🔍 Fast search","💬 Comments","🛡️ Moderation"]});case"analytics-monitoring":return e.jsx(Zn,{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(Zn,{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(Zn,{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(bs,{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(bs,{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(bs,{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(bs,{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(bs,{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(bs,{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(za,{channels:[{label:"Stable",dots:5},{label:"Beta",dots:5,on:!0}]});case"pre-release-versions":return e.jsx(za,{channels:[{label:"latest",dots:4},{label:"next",dots:4,on:!0}]});case"legal":return e.jsx(Yt,{emoji:"⚖️",caption:"Clear, honest, above board",chips:["Privacy policy","Terms of service","Plain language"]});case"data-safety":return e.jsx(Yt,{emoji:"🛡️",caption:"Collect less, protect the rest",chips:["Minimize","Encrypt","Declare clearly"]});case"supply-chain":return e.jsx(Yt,{emoji:"🔗",caption:"Trust the code you depend on",chips:["Scan for risk","Pin versions","Verify builds"]});case"secrets":return e.jsx(Yt,{emoji:"🔑",caption:"Out of the code, in a safe store",chips:["Never committed","Easy to rotate","Per-environment"]});case"readme-license":return e.jsx(Yt,{emoji:"📖",caption:"The first things visitors read",chips:["What it is","How to use it","What's allowed"]});case"install-docs":return e.jsx(Yt,{emoji:"📘",caption:"From zero to running, fast",chips:["Install","First example","Common task"]});case"examples":return e.jsx(Yt,{emoji:"🧩",caption:"Show it solving real tasks",chips:["Runnable","Real use cases","Copy & tweak"]});case"publish":return e.jsx(Vt,{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(Vt,{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(Vt,{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(Vt,{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(Vt,{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(Vt,{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(xs,{center:{emoji:"💳",label:"Secure checkout"},satellites:["💳 One-off","🔁 Subscriptions","🧾 Receipts","↩️ Refunds"]});case"shell-completions":return e.jsx(gs,{before:{tag:"Without",items:["Memorize flags","Typos & retries"]},after:{tag:"With completions",items:["Tab to complete","Commands & options"]}});default:return null}}const QO=Object.freeze(Object.defineProperty({__proto__:null,illustrationForTopic:Vo},Symbol.toStringTag,{value:"Module"})),Jw="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.",Xw=[{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."}],Qw=["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(`
9
+ `);function Vu({onBack:t,onChatWithAI:s}){return e.jsx(Bo,{icon:e.jsx(wn,{size:26}),title:"Use real data",crumbLabel:"Real data",meta:"Foundation · about 10 minutes",assistKey:"real-data",onBack:t,lead:Jw,illustration:Vo("real-data"),chatPrompt:Qw,onChatWithAI:s,faqs:Xw})}const ZO=Object.freeze(Object.defineProperty({__proto__:null,RealDataScreen:Vu},Symbol.toStringTag,{value:"Module"})),Er={entitySingular:"item",entityPlural:"items",savedThings:"saved items",purchaseNoun:"purchase"},Zw=800;function Nl(t){switch(t){case"ready":return"ready";case"error":return"error";case"connected":case"provisioning":return"provisioning";default:return"provisioning"}}function Ko(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=Nl(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),Nl(x.status)==="provisioning"&&(d.current=setInterval(()=>void p(),Zw))}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 e_="accounts";function t_(t){switch(t){case"clerk":return"Clerk";case"supabase_auth":return"Supabase Auth";default:return t}}function Ku({provider:t,app:s=Er,startedOn:n="recently",onComplete:r}){const{stage:a,result:o,error:i,connect:c,reset:d}=Ko(e_,t),[u,h]=l.useState(""),p=t_(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(si,{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:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"real-error-title",children:["Couldn’t connect ",p]}),e.jsx(dt,{variant:"icon",text:`Couldn’t connect ${p}: ${i}`})]}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{h(""),d()},children:"Try again"})]}):a==="connecting"||a==="provisioning"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsxs("div",{className:"deploy-t",children:["Setting up ",p]}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?`Connecting to ${p}…`:"Provisioning your sign-in keys…"})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]}):e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"ph",children:["Connect ",p]}),e.jsxs("div",{className:"psub",children:["Paste your ",p," secret key to wire real accounts into your app. CodeYam holds the key and injects it into the running app — you never touch a server."]}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("label",{className:"real-token-label",htmlFor:"accounts-secret-key",children:[p," secret key"]}),e.jsx("input",{id:"accounts-secret-key",type:"password",className:"real-token-input",placeholder:`Paste your ${p} secret key`,value:u,onChange: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 e6=Object.freeze(Object.defineProperty({__proto__:null,AccountsRealConnect:Ku},Symbol.toStringTag,{value:"Module"}));function Ot(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 Bs({size:t=16}){return Ot(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 Jo({size:t=16}){return Ot(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 Xo({size:t=16}){return Ot(t,1.8,e.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}))}function Qo({size:t=16}){return Ot(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 s_({size:t=16}){return Ot(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 n_({size:t=16}){return Ot(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 r_({size:t=16}){return Ot(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 a_({size:t=16}){return Ot(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 7v5l3 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"9"})]}))}function o_({size:t=13}){return Ot(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 ws({size:t=13}){return Ot(t,2.5,e.jsx("path",{d:"m5 12 5 5L20 6"}))}function Ju({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 t6=Object.freeze(Object.defineProperty({__proto__:null,ChatIcon:n_,CheckGlyph:ws,ClockIcon:a_,CubeIcon:r_,InfoCircleIcon:s_,LinkIcon:Jo,ListLinesIcon:Xo,ScreenIcon:Qo,ShieldCheckIcon:Bs,SpinnerIcon:Ju,XCircleIcon:o_},Symbol.toStringTag,{value:"Module"})),i_={"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."}]},l_={"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."}]},c_={"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."}]},d_={"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."}]},u_={"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."}]},h_={"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."}]},p_={"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.`}]},m_={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."}]},f_={"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)."}]},g_={...i_,...l_,...c_,...d_,...u_,...h_,...p_,...m_,...f_};function Xu(t){return g_[t]??[]}function b_({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(`
10
+ `)}function ss({assistKey:t,topicName:s,goalId:n,buttonLabel:r}){const a=Xu(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(_s,{chatName:`setup-${t}-${a.id}`,prompt:b_({topicName:s,goal:a}),height:360,onClose:()=>i(!1)})})]}):null}const s6=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssist:ss},Symbol.toStringTag,{value:"Module"}));function he({assistKey:t,topicName:s}){const n=Xu(t);return n.length===0?null:e.jsx(e.Fragment,{children:n.map(r=>e.jsx(ss,{assistKey:t,topicName:s,goalId:r.id,buttonLabel:`Ask AI to help: ${r.label}`},r.id))})}const n6=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssistList:he},Symbol.toStringTag,{value:"Module"})),x_=1800;function Mr({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,x_))},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(Bs,{size:15}),t.whyHeading]}),t.whyRows.map(h=>e.jsxs("div",{className:"su-whyrow",children:[e.jsx("span",{className:"su-wc",children:e.jsx(ws,{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(Ju,{size:16}),"Opening ",t.providerName,"…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Jo,{size:16}),t.connectButtonLabel]})}),e.jsx("div",{className:"su-reassure",children:t.reassure.map(h=>e.jsxs("span",{children:[e.jsx(ws,{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:[ue(h.factKey).value,e.jsx(ns,{fact:ue(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(Oe,{size:15})})]},h.title))}),t.faq&&t.faq.length>0?e.jsx(Ue,{items:t.faq}):null,t.assistKey?e.jsx(he,{assistKey:t.assistKey,topicName:t.title}):null]})}const r6=Object.freeze(Object.defineProperty({__proto__:null,SetupNotConnected:Mr},Symbol.toStringTag,{value:"Module"}));function Ir({children:t}){return e.jsx("div",{className:"su-steps",children:t})}function Pt({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(ws,{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 Zo({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 Qu({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(ws,{size:11})}),o.icon,o.label]},o.key))})}function Dr({children:t}){return e.jsxs("div",{className:"su-field",children:[e.jsx("span",{className:"su-edit",children:"Edit"}),t]})}function Zu({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 Lr({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(ws,{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 Fr({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 zr({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 a6=Object.freeze(Object.defineProperty({__proto__:null,BuildList:Lr,ControlNote:Fr,EditableField:Dr,ExampleChips:Zu,MethodChips:Qu,SetupAccountRow:Zo,SetupPlanFooter:zr,SetupStep:Pt,SetupStepper:Ir},Symbol.toStringTag,{value:"Module"}));function Ws(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 dr({size:t=16}){return Ws(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 eh({size:t=16}){return Ws(t,1.8,e.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"}))}function ei({size:t=16}){return Ws(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 th({size:t=16}){return Ws(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 Ga({size:t=16}){return Ws(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 sh({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 nh({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 rh({size:t=16}){return Ws(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 o6=Object.freeze(Object.defineProperty({__proto__:null,AppleGlyph:nh,ArrowRightIcon:eh,GoogleGlyph:sh,GraduationIcon:rh,MagicLinkIcon:Ga,PaperPlaneIcon:ei,PersonIcon:dr,WarningTriangleIcon:th},Symbol.toStringTag,{value:"Module"}));function ti(){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 $r({topic:t}){const{services:s}=ti();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 i6=Object.freeze(Object.defineProperty({__proto__:null,WiredProviderBanner:$r},Symbol.toStringTag,{value:"Module"}));function y_(t){return{accent:"blue",assistKey:"accounts",badge:e.jsx(dr,{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(dr,{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(eh,{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(Oe,{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(Xo,{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(Qo,{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 (${ue("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 v_=[{key:"google",label:"Google",icon:e.jsx(sh,{size:15})},{key:"apple",label:"Apple",icon:e.jsx(nh,{size:15})},{key:"email",label:"Email",icon:e.jsx(Ga,{size:15})},{key:"magic",label:"Magic link",icon:e.jsx(Ga,{size:15})}];function si({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(dr,{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(rh,{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(Ir,{children:[e.jsx(Pt,{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(Qu,{methods:v_,initialSelected:["google","apple","email"]})}),e.jsx(Pt,{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(Dr,{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(Pt,{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(Lr,{items:r})})]}),e.jsxs(Fr,{accent:"blue",icon:e.jsx(Oe,{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(zr,{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 ah({onBack:t,onComplete:s,app:n=Er,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($r,{topic:"accounts"}),i?e.jsx(si,{app:n,startedOn:a,onComplete:s}):d?e.jsx(Ku,{provider:o.provider,app:n,startedOn:a,onComplete:s}):e.jsx(Mr,{config:y_(n),onConnect:()=>c(!0)})]})}const l6=Object.freeze(Object.defineProperty({__proto__:null,AccountsConnected:si,AccountsScreen:ah},Symbol.toStringTag,{value:"Module"})),j_="hello@your-app.com",w_={monogram:"R",name:"Your app",detail:"you@your-app.com · re_live_…"};function __(t){return{accent:"amber",assistKey:"emails",badge:e.jsx(Hs,{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(ei,{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(Bs,{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(vt,{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 ${ue("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(Bs,{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(Xo,{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(Qo,{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 oh({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(Hs,{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(ws,{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(Bs,{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(Ir,{children:[e.jsx(Pt,{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(Zo,{monogram:n.monogram,name:n.name,detail:n.detail,monogramStyle:{background:"#ffd400",color:"#1a1a1a"}})}),e.jsxs(Pt,{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(Dr,{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(Zu,{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(Pt,{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(Lr,{items:a})})]}),e.jsxs(Fr,{accent:"amber",icon:e.jsx(ei,{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(zr,{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 ih({onBack:t,onComplete:s,app:n=Er,initialConnected:r=!1,verifiedAddress:a=j_,account:o=w_}){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($r,{topic:"emails"}),i?e.jsx(oh,{app:n,verifiedAddress:a,account:o,onComplete:s}):e.jsx(Mr,{config:__(n),onConnect:()=>c(!0)})]})}const c6=Object.freeze(Object.defineProperty({__proto__:null,EmailsConnected:oh,EmailsScreen:ih},Symbol.toStringTag,{value:"Module"}));function $n(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function ni({config:t,provider:s,onBack:n,onComplete:r,onRevert:a}){const{stage:o,result:i,error:c,connect:d,reset:u}=Ko(t.key,s),[h,p]=l.useState("");return o==="idle"?e.jsxs(e.Fragment,{children:[e.jsx(Zt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:n}),e.jsx(Ft,{steps:$n(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(Cr,{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(Zt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:n}),e.jsx(Ft,{steps:$n(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t connect"}),e.jsx(dt,{variant:"icon",text:`Couldn’t connect: ${c}`})]}),e.jsx("div",{className:"real-error-msg",children:c})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{p(""),u()},children:"Try again"})]})]}):o==="ready"?e.jsxs(e.Fragment,{children:[e.jsx(Zt,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(Ft,{steps:$n(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(Zt,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(Ft,{steps:$n(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 d6=Object.freeze(Object.defineProperty({__proto__:null,RealSetupFlow:ni},Symbol.toStringTag,{value:"Module"})),k_={monogram:"AC",name:"Your app",detail:"you@your-app.com · acct_…"};function S_(t){return{accent:"indigo",assistKey:"payments",badge:e.jsx($t,{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(Oe,{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($t,{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(vt,{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 (${ue("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(Bs,{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(Jo,{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($t,{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 N_(t){return{key:"payments",connector:{provider:"stripe"},Icon:$t,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 lh(){const[t,s]=l.useState("test");return e.jsxs("div",{className:"su-modebar",children:[e.jsx("div",{className:"su-widget-ic",children:e.jsx(th,{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 ch({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($t,{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(lh,{}),e.jsxs(Ir,{children:[e.jsx(Pt,{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(Zo,{monogram:s.monogram,name:s.name,detail:s.detail})}),e.jsx(Pt,{state:"done",num:2,title:"What are you selling?",desc:"Plain language is fine — this is what shapes the screens below.",children:e.jsxs(Dr,{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(Pt,{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(Lr,{items:r})})]}),e.jsxs(Fr,{accent:"amber",icon:e.jsx(Oe,{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(zr,{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 dh({onBack:t,onComplete:s,onRevert:n,app:r=Er,initialConnected:a=!1,account:o=k_,connector:i}){const[c,d]=l.useState(a);let u;return i&&c?u=e.jsx(ni,{config:N_(r),provider:i.provider,onBack:()=>d(!1),onComplete:s,onRevert:n}):c?u=e.jsx(ch,{app:r,account:o,onComplete:s}):u=e.jsx(Mr,{config:S_(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($r,{topic:"payments"}),u]})}const u6=Object.freeze(Object.defineProperty({__proto__:null,ModeBar:lh,PaymentsConnected:ch,PaymentsScreen:dh},Symbol.toStringTag,{value:"Module"}));function Qe({config:t,onBack:s,onComplete:n,status:r,onRevert:a}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{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($o,{provider:o},o.name))]}):null,e.jsx(Ue,{items:t.faq}),e.jsx(he,{assistKey:t.key,topicName:t.title}),e.jsx(pe,{label:t.doneLabel,note:t.doneNote??"You can revisit this anytime.",status:r,onComplete:()=>n==null?void 0:n(),onRevert:a,onBack:s})]})}const h6=Object.freeze(Object.defineProperty({__proto__:null,TeachSetupScreen:Qe},Symbol.toStringTag,{value:"Module"})),C_={key:"analytics-monitoring",Icon:vt,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 uh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:C_,onBack:t,onComplete:s,status:n,onRevert:r})}const p6=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsMonitoringScreen:uh},Symbol.toStringTag,{value:"Module"})),P_={key:"legal",Icon:Pe,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 hh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:P_,onBack:t,onComplete:s,status:n,onRevert:r})}const m6=Object.freeze(Object.defineProperty({__proto__:null,LegalScreen:hh},Symbol.toStringTag,{value:"Module"}));function ph({config:t,onBack:s,onSetup:n}){return e.jsxs(e.Fragment,{children:[e.jsx(ae,{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($o,{provider:t.recommended}),e.jsx(ru,{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(Ue,{items:t.faq}),e.jsx(he,{assistKey:t.key,topicName:t.title})]})}const f6=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupOverview:ph},Symbol.toStringTag,{value:"Module"})),Cl=1100,T_=700;function ri(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function mh({config:t,onBack:s,onContinue:n}){return e.jsxs(e.Fragment,{children:[e.jsx(Zt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:s}),e.jsx(Ft,{steps:ri(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(Cr,{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 fh({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*Cl));return c.push(setTimeout(()=>o.current(),n.length*Cl+T_)),()=>c.forEach(clearTimeout)},[n.length]);const i=Math.round(r/n.length*100);return e.jsxs(e.Fragment,{children:[e.jsx(Zt,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(Ft,{steps:ri(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 gh({config:t,onFinish:s,onRevert:n}){return e.jsxs(e.Fragment,{children:[e.jsx(Zt,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(Ft,{steps:ri(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 g6=Object.freeze(Object.defineProperty({__proto__:null,SimulatedConnect:mh,SimulatedProvision:fh,SimulatedReady:gh},Symbol.toStringTag,{value:"Module"}));function _n({config:t,onBack:s,onComplete:n,onRevert:r}){const[a,o]=l.useState("overview");let i;return a==="overview"?i=e.jsx(ph,{config:t,onBack:s,onSetup:()=>o("connect")}):t.connector?i=e.jsx(ni,{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(mh,{config:t,onBack:()=>o("overview"),onContinue:()=>o("provision")}):a==="provision"?i=e.jsx(fh,{config:t,onDone:()=>o("ready")}):i=e.jsx(gh,{config:t,onFinish:()=>{n==null||n(),s()},onRevert:r?()=>{r(),s()}:void 0}),e.jsx("div",{className:"hosting-screen",children:i})}const b6=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupScreen:_n},Symbol.toStringTag,{value:"Module"})),A_={key:"publish",Icon:js,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:`${ue("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. ${ue("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: ${ue("cloudflarePages.free").value.toLowerCase()}, so traffic spikes won't cost you. Netlify's free tier: ${ue("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 bh({onBack:t,onComplete:s,onRevert:n}){return e.jsx(_n,{config:A_,onBack:t,onComplete:s,onRevert:n})}const x6=Object.freeze(Object.defineProperty({__proto__:null,PublishScreen:bh},Symbol.toStringTag,{value:"Module"})),O_={key:"custom-domain",Icon:Bt,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 xh({onBack:t,onComplete:s,onRevert:n}){return e.jsx(_n,{config:O_,onBack:t,onComplete:s,onRevert:n})}const y6=Object.freeze(Object.defineProperty({__proto__:null,CustomDomainScreen:xh},Symbol.toStringTag,{value:"Module"})),R_={key:"data-safety",Icon:wn,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 yh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:R_,onBack:t,onComplete:s,status:n,onRevert:r})}const v6=Object.freeze(Object.defineProperty({__proto__:null,DataSafetyScreen:yh},Symbol.toStringTag,{value:"Module"})),E_={key:"forms",Icon:Hs,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 ${ue("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 vh({onBack:t,onComplete:s,onRevert:n}){return e.jsx(_n,{config:E_,onBack:t,onComplete:s,onRevert:n})}const j6=Object.freeze(Object.defineProperty({__proto__:null,FormsScreen:vh},Symbol.toStringTag,{value:"Module"})),M_={key:"analytics-seo",Icon:vt,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 jh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:M_,onBack:t,onComplete:s,status:n,onRevert:r})}const w6=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsSeoScreen:jh},Symbol.toStringTag,{value:"Module"})),I_={key:"redirects-404",Icon:Bt,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 wh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:I_,onBack:t,onComplete:s,status:n,onRevert:r})}const _6=Object.freeze(Object.defineProperty({__proto__:null,RedirectsNotFoundScreen:wh},Symbol.toStringTag,{value:"Module"})),D_={key:"performance-images",Icon:Ie,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 _h({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:D_,onBack:t,onComplete:s,status:n,onRevert:r})}const k6=Object.freeze(Object.defineProperty({__proto__:null,PerformanceImagesScreen:_h},Symbol.toStringTag,{value:"Module"})),L_={key:"comments-search",Icon:Pe,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 kh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:L_,onBack:t,onComplete:s,status:n,onRevert:r})}const S6=Object.freeze(Object.defineProperty({__proto__:null,CommentsSearchScreen:kh},Symbol.toStringTag,{value:"Module"})),Ms={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."}},F_=[Ms.crates,Ms.npm,Ms.pypi,Ms.rubygems,Ms.homebrew];function Sh(t){return Ms[t]}function Nh({registry:t,onBack:s,onComplete:n,status:r,onRevert:a}){const o=t?Sh(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(nt,{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(re,{children:[e.jsxs(O,{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(O,{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(O,{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(re,{children:[e.jsxs(O,{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(O,{lead:"Turn on two-factor auth — registries expect it.",children:[ue("registry.twoFactor").value,"."," ",e.jsx(ns,{fact:ue("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(re,{children:F_.map(i=>e.jsxs(O,{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(he,{assistKey:"publish-registry",topicName:"Publish to a registry"}),e.jsx(pe,{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 N6=Object.freeze(Object.defineProperty({__proto__:null,PublishRegistryScreen: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(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsx(O,{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(O,{lead:"MINOR (1.x.0) — new, backward-compatible features.",children:"Existing usage keeps working; there's just more available."}),e.jsx(O,{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(O,{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(Mo,{spaced:!0,children:e.jsxs(O,{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(he,{assistKey:"versioning-changelog",topicName:"Versioning & changelog"}),e.jsx(pe,{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 C6=Object.freeze(Object.defineProperty({__proto__:null,VersioningChangelogScreen:Ch},Symbol.toStringTag,{value:"Module"}));function Ph({registry:t,onBack:s,onComplete:n,status:r,onRevert:a}){const o=t?Sh(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(O,{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(he,{assistKey:"install-docs",topicName:"Install docs"}),e.jsx(pe,{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 P6=Object.freeze(Object.defineProperty({__proto__:null,InstallDocsScreen: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(ae,{icon:e.jsx(Ie,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(O,{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(he,{assistKey:"release-builds",topicName:"Release builds"}),e.jsx(pe,{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 T6=Object.freeze(Object.defineProperty({__proto__:null,ReleaseBuildsScreen:Th},Symbol.toStringTag,{value:"Module"}));function Ah({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx($s,{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(re,{children:[e.jsxs(O,{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(O,{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(O,{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(O,{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(he,{assistKey:"shell-completions",topicName:"Shell completions"}),e.jsx(pe,{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 A6=Object.freeze(Object.defineProperty({__proto__:null,ShellCompletionsScreen: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(ae,{icon:e.jsx($s,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(O,{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(he,{assistKey:"cli-ux",topicName:"Command-line UX"}),e.jsx(pe,{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 O6=Object.freeze(Object.defineProperty({__proto__:null,CliUxScreen: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(ae,{icon:e.jsx(Oe,{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(re,{children:[e.jsxs(O,{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(O,{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(O,{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(O,{lead:"Sign your releases so they can be verified.",children:[ue("supplyChain.signedReleases").value,"."," ",e.jsx(ns,{fact:ue("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(he,{assistKey:"supply-chain",topicName:"Security & supply chain"}),e.jsx(pe,{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 R6=Object.freeze(Object.defineProperty({__proto__:null,SupplyChainScreen: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(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsxs(O,{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(O,{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(O,{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(O,{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(he,{assistKey:"examples",topicName:"Examples & doctests"}),e.jsx(pe,{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 E6=Object.freeze(Object.defineProperty({__proto__:null,ExamplesScreen:Eh},Symbol.toStringTag,{value:"Module"}));function Mh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(he,{assistKey:"api-docs",topicName:"API docs"}),e.jsx(pe,{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 M6=Object.freeze(Object.defineProperty({__proto__:null,ApiDocsScreen:Mh},Symbol.toStringTag,{value:"Module"})),z_={key:"api-docs",Icon:Pe,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 Ih({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:z_,onBack:t,onComplete:s,status:n,onRevert:r})}const I6=Object.freeze(Object.defineProperty({__proto__:null,BackendApiDocsScreen:Ih},Symbol.toStringTag,{value:"Module"}));function Dh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(O,{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(he,{assistKey:"semver-policy",topicName:"Versioning policy"}),e.jsx(pe,{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 D6=Object.freeze(Object.defineProperty({__proto__:null,SemverPolicyScreen:Dh},Symbol.toStringTag,{value:"Module"}));function Lh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsx(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{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(re,{children:e.jsxs(O,{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(he,{assistKey:"readme-license",topicName:"Readme & license"}),e.jsx(pe,{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 L6=Object.freeze(Object.defineProperty({__proto__:null,ReadmeLicenseScreen:Lh},Symbol.toStringTag,{value:"Module"}));function Fh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(vt,{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(Mo,{}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Automate the release"}),e.jsxs(re,{children:[e.jsx(O,{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(O,{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(O,{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"}),": ",ue("registry.oidc").value,"."," ",e.jsx(ns,{fact:ue("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(he,{assistKey:"changelog-ci",topicName:"Changelog & CI"}),e.jsx(pe,{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 F6=Object.freeze(Object.defineProperty({__proto__:null,ChangelogCiScreen:Fh},Symbol.toStringTag,{value:"Module"})),$_=ue("flyio.pricing"),B_={key:"deploy-target",connector:{provider:"render"},Icon:js,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:$_.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 zh({onBack:t,onComplete:s,onRevert:n}){return e.jsx(_n,{config:B_,onBack:t,onComplete:s,onRevert:n})}const z6=Object.freeze(Object.defineProperty({__proto__:null,DeployTargetScreen:zh},Symbol.toStringTag,{value:"Module"})),q_={key:"database-backups",Icon:wn,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 $h({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:q_,onBack:t,onComplete:s,status:n,onRevert:r})}const $6=Object.freeze(Object.defineProperty({__proto__:null,DatabaseBackupsScreen:$h},Symbol.toStringTag,{value:"Module"}));function H_(){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 W_={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 Bh(t,s){const n=[...t,...s];return n.length===0?W_:{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 qh(t,s){return{key:"secrets",Icon:Oe,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:[Bh(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 Hh({onBack:t,onComplete:s,status:n,onRevert:r}){const{env:a}=H_(),o=qh((a==null?void 0:a.envKeys)??[],(a==null?void 0:a.serviceEnvVars)??[]);return e.jsx(Qe,{config:o,onBack:t,onComplete:s,status:n,onRevert:r})}const B6=Object.freeze(Object.defineProperty({__proto__:null,SecretsScreen:Hh,buildConfig:qh,secretsSection:Bh},Symbol.toStringTag,{value:"Module"})),G_={key:"api-auth",Icon:Oe,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 Wh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:G_,onBack:t,onComplete:s,status:n,onRevert:r})}const q6=Object.freeze(Object.defineProperty({__proto__:null,ApiAuthScreen:Wh},Symbol.toStringTag,{value:"Module"})),U_={key:"cors-origins",Icon:Bt,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 Gh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:U_,onBack:t,onComplete:s,status:n,onRevert:r})}const H6=Object.freeze(Object.defineProperty({__proto__:null,CorsOriginsScreen:Gh},Symbol.toStringTag,{value:"Module"})),Y_={key:"background-jobs",Icon:Ie,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 Uh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:Y_,onBack:t,onComplete:s,status:n,onRevert:r})}const W6=Object.freeze(Object.defineProperty({__proto__:null,BackgroundJobsScreen:Uh},Symbol.toStringTag,{value:"Module"})),V_={key:"logging-monitoring",Icon:vt,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 Yh({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsx(Qe,{config:V_,onBack:t,onComplete:s,status:n,onRevert:r})}const G6=Object.freeze(Object.defineProperty({__proto__:null,LoggingMonitoringScreen:Yh},Symbol.toStringTag,{value:"Module"}));function Ua({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(ae,{icon:e.jsx(Ie,{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(re,{children:[e.jsxs(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{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(Ue,{items:a}),e.jsx(he,{assistKey:"staging-preview",topicName:"Staging & preview deploys"}),e.jsx(pe,{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 U6=Object.freeze(Object.defineProperty({__proto__:null,StagingPreviewScreen:Ua},Symbol.toStringTag,{value:"Module"}));function Vh({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(ae,{icon:e.jsx(Ie,{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(re,{children:[e.jsx(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{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(re,{children:e.jsx(O,{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(Ue,{items:a}),e.jsx(he,{assistKey:"staging-environment",topicName:"Staging environment"}),e.jsx(pe,{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 Y6=Object.freeze(Object.defineProperty({__proto__:null,StagingEnvironmentScreen:Vh},Symbol.toStringTag,{value:"Module"}));function Ya({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(ae,{icon:e.jsx(Ie,{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(re,{children:[e.jsxs(O,{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(O,{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(re,{children:[e.jsxs(O,{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(O,{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(re,{children:e.jsxs(O,{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(Ue,{items:a}),e.jsx(he,{assistKey:"pre-release-channel",topicName:"Pre-release channel"}),e.jsx(pe,{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 V6=Object.freeze(Object.defineProperty({__proto__:null,PreReleaseScreen:Ya},Symbol.toStringTag,{value:"Module"}));function fe(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(`
11
+ `)}const K_={"staging-preview":{Icon:Ie,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:fe("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:Bt,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:fe("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:Oe,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:fe("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:Hs,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:fe("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:$t,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:fe("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:vt,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:fe("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:nt,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:fe("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:Pe,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:fe("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:Pe,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:fe("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:Oe,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:fe("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:Oe,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:fe("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:Ie,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:fe("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:Bt,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:fe("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:nt,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:fe("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:Ie,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:fe("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:nt,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:fe("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:vt,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:fe("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:Bt,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:fe("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:Oe,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:fe("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:js,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:fe("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:Ie,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:fe("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:js,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:fe("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:nt,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:fe("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:Pe,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:fe("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:nt,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:fe("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:Pe,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:fe("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:Pe,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:fe("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:Pe,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:fe("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:nt,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:fe("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:Ie,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:fe("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:$s,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:fe("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:$s,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:fe("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:Oe,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:fe("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:Ie,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:fe("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:Ie,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:fe("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."}]}},J_={"real-data":Vu,accounts:ah,emails:ih,payments:dh,"analytics-monitoring":uh,legal:hh,"data-safety":yh,publish:bh,"custom-domain":xh,forms:vh,"analytics-seo":jh,"redirects-404":wh,"performance-images":_h,"comments-search":kh,"publish-registry":Nh,"versioning-changelog":Ch,"install-docs":Ph,"release-builds":Th,"shell-completions":Ah,"cli-ux":Oh,"api-docs":Mh,examples:Eh,"semver-policy":Dh,"readme-license":Lh,"supply-chain":Rh,"changelog-ci":Fh,"deploy-target":zh,"database-backups":$h,secrets:Hh,"api-auth":Wh,"cors-origins":Gh,"background-jobs":Uh,"logging-monitoring":Yh,"staging-preview":Ua,"deploy-previews":Ua,"staging-environment":Vh,"pre-release-channel":Ya,"pre-release-versions":Ya};function Kh({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(ae,{icon:e.jsx(Or,{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 Jh({topicKey:t,topicName:s,topicDesc:n,isBackend:r=!1,onBack:a,onComplete:o,onChatWithAI:i}){const c=K_[t];if(c)return e.jsx(Bo,{icon:e.jsx(c.Icon,{size:26}),title:c.title,crumbLabel:c.crumbLabel,meta:c.meta,assistKey:t,onBack:a,lead:c.lead,illustration:Vo(t)??e.jsx(Vt,{nodes:c.journey}),chatPrompt:c.chatPrompt,onChatWithAI:i,faqs:c.faqs});const d=t==="api-docs"&&r?Ih:J_[t];return d?e.jsx(d,{onBack:a,onComplete:()=>o==null?void 0:o(t),onChatWithAI:i}):e.jsx(Kh,{onBack:a,topicKey:t,topicName:s,topicDesc:n})}const K6=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPlaceholder:Kh,SetupTopicRouter:Jh},Symbol.toStringTag,{value:"Module"}));function Xh({onBack:t}){const{concepts:s}=Bu(),[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(Ht,{variant:"compact",children:c.body})}):null]},c.key)})})]})}const J6=Object.freeze(Object.defineProperty({__proto__:null,ConceptsGlossaryScreen:Xh},Symbol.toStringTag,{value:"Module"})),Me=({children:t})=>e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t}),Pl={vercel:e.jsx(Me,{children:e.jsx("path",{d:"M12 4l8 14H4z",fill:"currentColor",stroke:"none"})}),netlify:e.jsxs(Me,{children:[e.jsx("path",{d:"M12 3l9 9-9 9-9-9z"}),e.jsx("path",{d:"M12 8v8M8 12h8"})]}),cloudflare:e.jsx(Me,{children:e.jsx("path",{d:"M6 16h11a3 3 0 0 0 .3-6A5 5 0 0 0 8 9.2 4 4 0 0 0 6 16z"})}),fly:e.jsxs(Me,{children:[e.jsx("circle",{cx:"12",cy:"10",r:"6"}),e.jsx("path",{d:"M9 15l-1 5 4-2 4 2-1-5"})]}),github:e.jsxs(Me,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M9 20v-3c0-1 .5-1.6 1-2-2.3-.3-3.8-1.2-3.8-4a3 3 0 0 1 .8-2 2.8 2.8 0 0 1 .1-2s.8-.2 2.2.9a8 8 0 0 1 4 0c1.4-1.1 2.2-.9 2.2-.9a2.8 2.8 0 0 1 .1 2 3 3 0 0 1 .8 2c0 2.8-1.5 3.7-3.8 4 .5.4 1 1 1 2v3"})]}),anthropic:e.jsx(Me,{children:e.jsx("path",{d:"M12 4v16M4 12h16M6.3 6.3l11.4 11.4M17.7 6.3L6.3 17.7"})}),neon:e.jsx(Me,{children:e.jsx("path",{d:"M5 19V5l14 14V5"})}),stripe:e.jsx(Me,{children:e.jsx("path",{d:"M6 8.5c0-1.4 1.5-2.5 3.5-2.5S13 6.8 13.4 8M6 15.5c0 1.4 1.5 2.5 3.5 2.5S13 17.2 13.4 16M9.5 6v12"})})},Tl={Domain:e.jsxs(Me,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8.5"}),e.jsx("path",{d:"M3.5 12h17M12 3.5c2.5 2.3 2.5 14.7 0 17M12 3.5c-2.5 2.3-2.5 14.7 0 17"})]}),Hosting:e.jsxs(Me,{children:[e.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"6",rx:"1.5"}),e.jsx("rect",{x:"3.5",y:"13.5",width:"17",height:"6",rx:"1.5"}),e.jsx("path",{d:"M7 7.5h.01M7 16.5h.01"})]}),Payments:e.jsxs(Me,{children:[e.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),e.jsx("path",{d:"M3 9.5h18"})]}),Database:e.jsxs(Me,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Database ORM":e.jsxs(Me,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Backend platform":e.jsxs(Me,{children:[e.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),e.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),e.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),Authentication:e.jsxs(Me,{children:[e.jsx("circle",{cx:"9",cy:"9",r:"4"}),e.jsx("path",{d:"M12 12l7 7M16 16l2-2M18.5 13.5l1.5 1.5"})]}),"Transactional email":e.jsxs(Me,{children:[e.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),e.jsx("path",{d:"M3.5 7l8.5 6 8.5-6"})]}),"Product analytics":e.jsxs(Me,{children:[e.jsx("path",{d:"M4 20V4M4 20h16"}),e.jsx("path",{d:"M8 16v-3M12 16V8M16 16v-6"})]}),"Error monitoring":e.jsxs(Me,{children:[e.jsx("path",{d:"M12 3l8 4v5c0 5-3.5 8-8 9-4.5-1-8-4-8-9V7z"}),e.jsx("path",{d:"M12 8.5v4M12 15.5h.01"})]})},X_={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 Qh(t){return t&&X_[t]||null}function Zh({providerId:t,category:s}){return t&&Pl[t]?Pl[t]:s&&Tl[s]?Tl[s]:null}const X6=Object.freeze(Object.defineProperty({__proto__:null,G:Me,ProviderLogo:Zh,providerBrand:Qh},Symbol.toStringTag,{value:"Module"})),Al=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"})}),Ol=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"})}),Q_=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"})]}),Z_=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 e1(t){return t.length<=10?"•".repeat(Math.max(t.length,6)):`${t.slice(0,6)}••••••••••${t.slice(-4)}`}function ep({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:e1(t)}),e.jsx("span",{className:"eye","aria-hidden":"true",children:s?Z_:Q_})]})]})}function tp({svc:t,expanded:s,onToggle:n,onAction:r}){var i,c,d;const a=Zh({providerId:t.providerId,category:t.category}),o=Qh(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(ep,{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 sp({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(tp,{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:[Ol,"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:Al})]}),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:Ol}),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:Al})]})]}):null]})}const Q6=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:ep,ExternalServicesScreen:sp,ServiceRow:tp},Symbol.toStringTag,{value:"Module"})),hn="your-app.vercel.app",t1=[{key:"connect",label:"Connect"},{key:"deploying",label:"Deploy"},{key:"live",label:"Go live"}];function ai({onBack:t}){return e.jsx(ae,{icon:e.jsx(js,{size:26}),title:"Hosting & going live",crumbLabel:"Hosting",meta:"Foundation · about 10 minutes",onBack:t,assistKey:"hosting"})}function qs({stage:t}){return e.jsx(Ft,{steps:t1,currentKey:t})}const Z6=Object.freeze(Object.defineProperty({__proto__:null,FlowBar:qs,HSHeader:ai,HS_URL:hn},Symbol.toStringTag,{value:"Module"}));function s1(){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 np({onBack:t,onSetup:s}){const{target:n}=s1(),r=(n==null?void 0:n.detectedHost)??null;return e.jsxs(e.Fragment,{children:[e.jsx(ai,{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(Qc,{}),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(_r,{}),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(Zc,{}),e.jsx(ed,{})]})]}),e.jsx(td,{}),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(sd,{}),e.jsx(nd,{}),e.jsx(he,{assistKey:"hosting",topicName:"Hosting & going live"})]})}const eR=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewGuided:np},Symbol.toStringTag,{value:"Module"}));function rp({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(qs,{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(_r,{}),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 tR=Object.freeze(Object.defineProperty({__proto__:null,HostingConnectStep:rp},Symbol.toStringTag,{value:"Module"})),Bn=["Packaging up your app","Uploading it to Vercel","Giving it a web address","Turning it on"],Rl=1100,n1=700;function ap({onDone:t}){const[s,n]=l.useState(0),r=l.useRef(t);r.current=t,l.useEffect(()=>{const o=[];for(let i=1;i<=Bn.length;i++)o.push(setTimeout(()=>n(i),i*Rl));return o.push(setTimeout(()=>r.current(),Bn.length*Rl+n1)),()=>o.forEach(clearTimeout)},[]);const a=Math.round(s/Bn.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(qs,{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:Bn.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 sR=Object.freeze(Object.defineProperty({__proto__:null,HostingDeployStep:ap},Symbol.toStringTag,{value:"Module"})),r1="hosting";function op({provider:t,credential:s,onDone:n,onRetry:r}){const{stage:a,result:o,error:i,connect:c}=Ko(r1,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(qs,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t put your app online"}),e.jsx(dt,{variant:"icon",text:`Couldn’t put your app online: ${i}`})]}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:r,children:"Try again"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(qs,{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 nR=Object.freeze(Object.defineProperty({__proto__:null,HostingRealDeployStep:op},Symbol.toStringTag,{value:"Module"})),a1=1600;function ip(t){const{copied:s,copy:n}=vn({resetMs:a1}),r=l.useCallback(()=>{n(t)},[n,t]);return{copied:s,copy:r}}function lp({onFinish:t,liveUrl:s}){const n=s??hn,r=s??"https://"+hn,{copied:a,copy:o}=ip(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(qs,{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 rR=Object.freeze(Object.defineProperty({__proto__:null,HostingLiveStep:lp},Symbol.toStringTag,{value:"Module"}));function cp({onBack:t,onRedeploy:s}){const{copied:n,copy:r}=ip("https://"+hn),[a,o]=l.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsx(ai,{onBack:t}),e.jsxs("div",{className:"conn-card",children:[e.jsx(_r,{}),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:hn})]}),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 aR=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewConnected:cp},Symbol.toStringTag,{value:"Module"}));function dp({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(cp,{onBack:s,onRedeploy:()=>i("deploying")}):e.jsx(np,{onBack:s,onSetup:()=>i("connect")}):o==="connect"?f=e.jsx(rp,{onBack:()=>i("overview"),tokenMode:p,onContinue:m=>{p&&d(m??""),i("deploying")}}):o==="deploying"?f=p?e.jsx(op,{provider:r.provider,credential:c,onDone:m=>{h(m),i(t==="connected"?"overview":"live")},onRetry:()=>i("connect")}):e.jsx(ap,{onDone:()=>i(t==="connected"?"overview":"live")}):f=e.jsx(lp,{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 oR=Object.freeze(Object.defineProperty({__proto__:null,HostingScreen:dp},Symbol.toStringTag,{value:"Module"}));function up({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(on,{command:t.install,writer:o})]}),e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:t.runLabel||"Run"}),e.jsx(on,{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(on,{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(he,{assistKey:"run-locally",topicName:"Run it locally"}),n&&e.jsx(pe,{label:"Got it — mark as done",note:"You can revisit these steps anytime.",status:r,onComplete:()=>n(),onRevert:a,onBack:s})]})]})}const iR=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyScreen: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(ae,{icon:e.jsx(Oe,{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(yt,{linkKey:"chrome.devConsole"}),e.jsx("div",{className:"seclabel",children:"What you'll do"}),e.jsxs(re,{children:[e.jsxs(O,{lead:"Pay the one-time developer fee.",children:["The Chrome Web Store charges a single"," ",e.jsx("b",{children:ue("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(O,{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(O,{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(O,{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(yt,{linkKey:"chrome.register",label:"Read the Chrome Web Store registration guide"}),e.jsx(kr,{}),e.jsx(he,{assistKey:"store-accounts",topicName:"Store accounts"}),e.jsx(pe,{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 lR=Object.freeze(Object.defineProperty({__proto__:null,StoreAccountsScreen: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(ae,{icon:e.jsx(nt,{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(re,{children:[e.jsx(O,{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(O,{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(re,{children:[e.jsx(O,{lead:"Small promo tile — 440×280.",children:"Shown in store listings and search results. A clean tile noticeably improves install rates."}),e.jsx(O,{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(yt,{linkKey:"chrome.devConsole",label:"Upload assets in the developer dashboard"}),e.jsx(he,{assistKey:"extension-store-assets",topicName:"Store assets"}),e.jsx(pe,{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 cR=Object.freeze(Object.defineProperty({__proto__:null,ExtensionAssetsScreen:pp},Symbol.toStringTag,{value:"Module"})),mp={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 pn(t){const s=t.trim();return s.includes("://")||s.startsWith("*")||s==="<all_urls>"}function o1(t){const s=t.trim();return s==="<all_urls>"?!0:pn(s)?s.replace(/^\*?:\/\//,"").split("/")[0]==="*":!1}function i1(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.":o1(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.`:pn(s)?`Run only on the specific sites this pattern matches (${s}).`:mp[s]??"Explain, in one plain sentence, exactly what this permission lets your extension do for the user."}function l1(t){const s=t.trim();return pn(s)||s in mp}const c1=["storage","activeTab","scripting","https://api.example.com/*"];function Va({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})})," ",i1(t),l1(t)?null:e.jsx("span",{className:"bestfit",style:{marginLeft:8},children:"needs your wording"})]})]},t)}function fp({permissions:t=c1,onBack:s,onComplete:n,status:r,onRevert:a}){const o=t.filter(pn),i=t.filter(c=>!pn(c));return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Oe,{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(Va,{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(Va,{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(yt,{linkKey:"chrome.devConsole",label:"Submit justifications in the developer dashboard"}),e.jsx(he,{assistKey:"permissions-justification",topicName:"Permissions"}),e.jsx(pe,{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 dR=Object.freeze(Object.defineProperty({__proto__:null,PermissionRow:Va,PermissionsJustificationScreen:fp},Symbol.toStringTag,{value:"Module"}));function gp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsx(O,{lead:"You don't sell or transfer data to third parties",children:"outside of approved use cases."}),e.jsx(O,{lead:"You don't use or transfer data for purposes unrelated",children:"to your extension's single purpose."}),e.jsx(O,{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(re,{children:[e.jsx(O,{lead:"What you collect.",children:"List the categories of data — settings, content the user enters, usage analytics — in plain terms."}),e.jsx(O,{lead:"Why you collect it.",children:"Tie each category to a feature. The store cross-checks this against your permission justifications."}),e.jsx(O,{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(O,{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(he,{assistKey:"privacy-policy",topicName:"Privacy policy"}),e.jsx(pe,{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 uR=Object.freeze(Object.defineProperty({__proto__:null,ExtensionPrivacyPolicyScreen:gp},Symbol.toStringTag,{value:"Module"}));function bp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Oe,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(yt,{linkKey:"google.oauthConsent"}),e.jsx(he,{assistKey:"oauth-verification",topicName:"OAuth & sign-in verification"}),e.jsx(pe,{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 hR=Object.freeze(Object.defineProperty({__proto__:null,OAuthVerificationScreen:bp},Symbol.toStringTag,{value:"Module"}));function xp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Pe,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{lead:"The right category.",children:"Pick the category that matches the purpose. A mismatched category is a flag and hurts discovery."}),e.jsx(O,{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(yt,{linkKey:"chrome.devConsole",label:"Edit the listing description in the developer dashboard"}),e.jsx(he,{assistKey:"single-purpose-listing",topicName:"Single purpose & listing quality"}),e.jsx(pe,{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 pR=Object.freeze(Object.defineProperty({__proto__:null,SinglePurposeListingScreen:xp},Symbol.toStringTag,{value:"Module"}));function yp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(nt,{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(re,{children:[e.jsxs(O,{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(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{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(he,{assistKey:"manifest-versioning",topicName:"Manifest & versioning"}),e.jsx(pe,{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 mR=Object.freeze(Object.defineProperty({__proto__:null,ManifestVersioningScreen:yp},Symbol.toStringTag,{value:"Module"}));function vp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(O,{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(O,{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(re,{children:[e.jsx(O,{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(O,{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(yt,{linkKey:"chrome.devConsole",label:"Upload and submit in the developer dashboard"}),e.jsx(kr,{}),e.jsx(he,{assistKey:"submit-review",topicName:"Submit for review"}),e.jsx(pe,{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 fR=Object.freeze(Object.defineProperty({__proto__:null,SubmitReviewScreen:vp},Symbol.toStringTag,{value:"Module"})),d1=[{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 ${ue("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 ${ue("chromeStore.fee").value} developer account if you want the unlisted-listing path (link-shareable, auto-updating, and trusted by Chrome).`}];function jp({onBack:t,onComplete:s,status:n,onRevert:r}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{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(re,{children:[e.jsx(O,{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(O,{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(O,{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(ss,{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(re,{children:[e.jsxs(O,{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(O,{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(O,{lead:"It still needs the one-time developer account.",children:["An unlisted listing requires the same"," ",e.jsx("b",{children:ue("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(yt,{linkKey:"chrome.devConsole",label:"Upload an unlisted build in the developer dashboard"}),e.jsx(ss,{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(re,{children:[e.jsxs(O,{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(O,{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(ss,{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(Ue,{items:d1}),e.jsx(kr,{}),e.jsx(pe,{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 gR=Object.freeze(Object.defineProperty({__proto__:null,ExtensionDistributionScreen:jp},Symbol.toStringTag,{value:"Module"}));function rs({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 ct({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 is({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 bR=Object.freeze(Object.defineProperty({__proto__:null,CheckList:is,CostCallout:rs,StoreCard:ct},Symbol.toStringTag,{value:"Module"}));function Cs(t){return t==="ios"||t==="both"}function Gs(t){return t==="android"||t==="both"}const El=["swift","swiftui","ios","uikit"],Ml=["kotlin","android","jetpack-compose"];function Il(t,s){return t&&!s?"ios":s&&!t?"android":null}function u1(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=Il(El.some(o=>n.includes(o)),Ml.some(o=>n.includes(o)));if(a)return a}const r=String(t.id??"").toLowerCase().split("-");if(r.some(Boolean)){const a=Il(El.some(o=>r.includes(o)),Ml.some(o=>r.includes(o)));if(a)return a}return"both"}function wp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=Cs(t),i=Gs(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(ae,{onBack:s,icon:e.jsx(Oe,{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(rs,{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(ct,{store:"ios",badge:ue("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(ct,{store:"android",badge:ue("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. ",ue("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(rs,{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(Ue,{items:c}),e.jsx(he,{assistKey:"dev-accounts",topicName:"Developer accounts"}),e.jsx(pe,{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 xR=Object.freeze(Object.defineProperty({__proto__:null,DevAccountsScreen:wp},Symbol.toStringTag,{value:"Module"}));function _p({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=Cs(t),i=Gs(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(ae,{onBack:s,icon:e.jsx(nt,{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(is,{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(ct,{store:"ios",badge:ue("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 ",ue("appleScreenshots.ipad").value," master. App previews (short videos) are optional but help conversion."]}):null,i?e.jsxs(ct,{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(Ue,{items:c}),e.jsx(he,{assistKey:"store-assets",topicName:"Store assets"}),e.jsx(pe,{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 yR=Object.freeze(Object.defineProperty({__proto__:null,StoreAssetsScreen:_p},Symbol.toStringTag,{value:"Module"}));function kp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=Cs(t),i=Gs(t);return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Pe,{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(is,{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(ct,{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(ct,{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(he,{assistKey:"store-listing",topicName:"Store listing"}),e.jsx(pe,{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 vR=Object.freeze(Object.defineProperty({__proto__:null,StoreListingScreen:kp},Symbol.toStringTag,{value:"Module"}));function Sp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=Cs(t),i=Gs(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:ue("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(ae,{onBack:s,icon:e.jsx(Ie,{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(rs,{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(ct,{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(ss,{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(ct,{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: ",ue("playStore.closedTestGate").value," ","(the 14-day clock resets below 12). Organisation accounts are generally not subject to this."]}),e.jsx(ss,{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(rs,{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(ss,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-store-review",buttonLabel:"Ask AI to help: Get ready for store review"}),e.jsx(Ue,{items:c}),e.jsx(pe,{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 jR=Object.freeze(Object.defineProperty({__proto__:null,TestingDistributionScreen:Sp},Symbol.toStringTag,{value:"Module"}));function Np({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=Cs(t),i=Gs(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(ae,{onBack:s,icon:e.jsx(Yo,{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(ct,{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(ct,{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(is,{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(Ue,{items:c}),e.jsx(he,{assistKey:"push-notifications",topicName:"Push notifications"}),e.jsx(pe,{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 wR=Object.freeze(Object.defineProperty({__proto__:null,PushNotificationsScreen:Np},Symbol.toStringTag,{value:"Module"}));function Cp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(vt,{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(is,{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(he,{assistKey:"crash-reporting",topicName:"Crash reporting"}),e.jsx(pe,{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 _R=Object.freeze(Object.defineProperty({__proto__:null,CrashReportingScreen:Cp},Symbol.toStringTag,{value:"Module"}));function Pp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=Cs(t),i=Gs(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(ae,{onBack:s,icon:e.jsx($t,{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(rs,{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(ct,{store:"ios",badge:ue("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 ",ue("appStore.commission").value,"."," ",e.jsx(ns,{fact:ue("appStore.commission")})]}):null,i?e.jsxs(ct,{store:"android",badge:ue("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"," ",ue("googlePlay.commission").value,"."," ",e.jsx(ns,{fact:ue("googlePlay.commission")})]}):null,e.jsx("div",{className:"seclabel",children:"The rule that gets apps rejected"}),e.jsx(is,{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(Ue,{items:c}),e.jsx(he,{assistKey:"in-app-purchases",topicName:"In-app purchases & subscriptions"}),e.jsx(pe,{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 kR=Object.freeze(Object.defineProperty({__proto__:null,InAppPurchasesScreen:Pp},Symbol.toStringTag,{value:"Module"}));function Tp({platform:t="both",onBack:s,onComplete:n,status:r,onRevert:a}){const o=Cs(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(ae,{onBack:s,icon:e.jsx(Oe,{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(is,{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(rs,{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(Ue,{items:i}),e.jsx(he,{assistKey:"app-privacy",topicName:"App privacy & tracking"}),e.jsx(pe,{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 SR=Object.freeze(Object.defineProperty({__proto__:null,AppPrivacyScreen:Tp},Symbol.toStringTag,{value:"Module"}));function Ap({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(ae,{onBack:s,icon:e.jsx(Pe,{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(rs,{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(is,{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(Ue,{items:o}),e.jsx(he,{assistKey:"app-review",topicName:"Getting through review"}),e.jsx(pe,{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 NR=Object.freeze(Object.defineProperty({__proto__:null,AppReviewScreen:Ap},Symbol.toStringTag,{value:"Module"})),h1=5e3,Dl=50;function p1(){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=${Dl}`);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(),k=new Set(m.current.map(S=>S.commit.sha)),C=(_.entries??[]).filter(S=>!k.has(S.commit.sha));C.length>0&&(s(S=>[...C,...S]),r(S=>S+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=${Dl}&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()},h1);return()=>clearInterval(v)},[g,x]),{rows:t,total:n,hasMore:a!==null,loading:i,loadingMore:d,error:h,loadMore:y,reload:g}}const ma={rows:[],total:0,truncated:!1,repo:null,screenshotsRepoRelDir:"",loading:!1,error:null};function m1(t){const[s,n]=l.useState(ma),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(ma);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({...ma,error:c instanceof Error?c.message:"Failed to load range"})}),()=>{o=!0}},[r,a]),s}function Op(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 f1=[/\.test\.[jt]sx?$/,/\.spec\.[jt]sx?$/,/__tests__\//,/tests?\//];function oi(t){return t.filter(s=>f1.some(n=>n.test(s.path)))}function g1(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 oi(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 b1=[{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"}],qn=864e5;function x1(t,s){const n=s.toISOString();switch(t){case"last-24h":return{from:new Date(s.getTime()-qn).toISOString(),to:n};case"last-3d":return{from:new Date(s.getTime()-3*qn).toISOString(),to:n};case"last-week":return{from:new Date(s.getTime()-7*qn).toISOString(),to:n};case"last-month":return{from:new Date(s.getTime()-30*qn).toISOString(),to:n};case"all-time":case"custom":return null}}function y1(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 Rp({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:Eu(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 CR=Object.freeze(Object.defineProperty({__proto__:null,CommitOnlyHistoryRow:Rp},Symbol.toStringTag,{value:"Module"}));function Br({entry:t,commit:s,onSelectScreenshot:n}){const r=oi(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 ${Mu(t.type)}`,children:t.type}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:Eu(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(Pr,{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(Uo,{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(Ar,{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(Tr,{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 PR=Object.freeze(Object.defineProperty({__proto__:null,HistoryEntryCard:Br},Symbol.toStringTag,{value:"Module"}));function Ep({selection:t,onChange:s,now:n=new Date}){const[r,a]=l.useState(""),[o,i]=l.useState(""),c=u=>{s({preset:u,range:x1(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:[b1.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 TR=Object.freeze(Object.defineProperty({__proto__:null,HistoryRangeSelector:Ep},Symbol.toStringTag,{value:"Module"}));function v1(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(j1(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=oi(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}",w1(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(`
12
+ `)}function j1(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 w1(t,s){const n=t.replace(/\/+$/,""),r=s.replace(/^\/+/,"");return n?`${n}/${r}`:r}function Mp({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:Mu(s),children:[n," ",s]},s)),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.testFilesTouched," test file",t.testFilesTouched===1?"":"s"]}),e.jsx(Ar,{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 AR=Object.freeze(Object.defineProperty({__proto__:null,HistoryDigestStatRow:Mp},Symbol.toStringTag,{value:"Module"}));function Ip({rangeLabel:t,summary:s,rows:n,repo:r,screenshotsRepoRelDir:a,truncated:o,onPreviewScreenshot:i}){const[c,d]=l.useState(!1),u=Op(n),h=async()=>{const p=v1({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(Ka,{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(Ka,{rangeLabel:t,onCopy:h,copied:c}),e.jsx(Mp,{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(Uo,{screenshots:s.screenshots,onSelect:i?p=>i({...p,isLatest:u.get(p.name)===_1(n,p.name)}):void 0})]}),e.jsx("div",{className:"flex flex-col gap-3",children:n.map((p,f)=>p.entry?e.jsx(Br,{entry:p.entry,commit:p.commit,onSelectScreenshot:i?m=>i({...m,isLatest:u.get(m.name)===f}):void 0},p.commit.sha):null)})]})}function Ka({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 _1(t,s){return t.findIndex(n=>{var r;return(((r=n.entry)==null?void 0:r.scenarioScreenshots)??[]).some(a=>a.name===s)})}const OR=Object.freeze(Object.defineProperty({__proto__:null,DigestHeader:Ka,HistoryDigest:Ip},Symbol.toStringTag,{value:"Module"}));function Dp({onPreviewScreenshot:t}={}){const[s,n]=l.useState({preset:"all-time",range:null});return e.jsxs(ts,{children:[e.jsx(Ep,{selection:s,onChange:n}),s.range?e.jsx(k1,{range:s.range,onPreviewScreenshot:t}):e.jsx(S1,{onPreviewScreenshot:t})]})}function k1({range:t,onPreviewScreenshot:s}){const{rows:n,truncated:r,repo:a,screenshotsRepoRelDir:o,loading:i,error:c}=m1(t);if(i)return e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading digest..."});if(c)return e.jsx("div",{className:"py-12",children:e.jsx(He,{text:`Failed to load digest: ${c}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});const d=g1(n);return e.jsx(Ip,{rangeLabel:y1(t),summary:d,rows:n,repo:a,screenshotsRepoRelDir:o,truncated:r,onPreviewScreenshot:s})}function S1({onPreviewScreenshot:t}){const{rows:s,total:n,hasMore:r,loading:a,loadingMore:o,error:i,loadMore:c}=p1();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.jsx("div",{className:"py-12",children:e.jsx(He,{text:`Failed to load history: ${i}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});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=Op(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(Br,{entry:h.entry,commit:h.commit,onSelectScreenshot:t?f=>t({...f,isLatest:u.get(f.name)===p}):void 0},h.commit.sha):e.jsx(Rp,{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 RR=Object.freeze(Object.defineProperty({__proto__:null,HistoryTab:Dp},Symbol.toStringTag,{value:"Module"})),N1="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 C1(){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 Ll(t){return t.length===0?"_(no events in window)_":`\`\`\`jsonl
13
+ ${t.map(n=>JSON.stringify(n)).join(`
14
+ `)}
15
+ \`\`\``}function fa(t,s){return t.trim().length===0?`_(${s} empty)_`:`\`\`\`
16
+ ${t}
17
+ \`\`\``}function P1(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)??Eo(),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??N1).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(`
18
+ `),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)","",Ll((s==null?void 0:s.uiTrace)??[]),"","## UI idle trace (in-memory ring buffer — may be ahead of persisted)","",fa(r,"in-memory buffer"),"","## Rust idle trace","",Ll((s==null?void 0:s.rustTrace)??[]),"","## editor-server.log (filtered to idle= within window)","",fa((s==null?void 0:s.editorServerLog)??"","editor-server.log"),"","## dev-server.log (last lines)","",fa((s==null?void 0:s.devServerLog)??"","dev-server.log"),""].filter(j=>j!==null).join(`
19
+ `)}async function T1(t={}){const s=encodeURIComponent(Eo());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=C1(),o=E0({agentName:t.agentName});return{markdown:P1({bundle:n,browser:a,uiBufferText:o,prompt:t.prompt,agentName:t.agentName}),bundle:n,error:r}}const A1=1500;function O1(t=A1){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 R1=2500;function Lp({agentName:t}){const[s,n]=l.useState(!1),{label:r,flash:a}=O1(R1),o=async()=>{n(!0);const{markdown:i,bundle:c,error:d}=await T1({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 ER=Object.freeze(Object.defineProperty({__proto__:null,DebugNotificationsButton:Lp},Symbol.toStringTag,{value:"Module"})),ga={sound:"soft-double-tap",systemNotification:!0,idleOnStop:!1,idleOnNotification:!0},E1=[{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"}],Fp="codeyam-editor-notifications";function zp(){try{const t=localStorage.getItem(Fp);if(!t)return ga;const s=JSON.parse(t);return{...ga,...s}}catch{return ga}}function $p(t){localStorage.setItem(Fp,JSON.stringify(t))}const M1={"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 ba(t,s){const n=s;X(t,{name:n==null?void 0:n.name,message:n==null?void 0:n.message})}function Bp(t){if(t==="off")return;X("audio-playsound-entered",{soundId:t});let s;try{s=new AudioContext}catch(r){ba("audio-context-failed",r);return}X("audio-context-created",{state:s.state});const n=()=>{let r;try{r=M1[t](s)}catch(a){ba("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=>{ba("audio-context-resume-failed",r),s.close().catch(()=>{})})):(X("audio-context-failed",{name:"UnexpectedState",message:`AudioContext state "${s.state}"`}),s.close().catch(()=>{}))}function Ja({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 MR=Object.freeze(Object.defineProperty({__proto__:null,IdleTriggerCheckbox:Ja},Symbol.toStringTag,{value:"Module"}));function ii({settings:t,onChange:s,providerLabel:n}){const r=t.idleOnStop??!1,a=t.idleOnNotification??!0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Notification sound"}),e.jsx("div",{className:"flex flex-col gap-0.5",children:E1.map(o=>e.jsx("button",{onClick:()=>{s({...t,sound:o.id}),o.id!=="off"&&Bp(o.id)},className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors",style:{background:t.sound===o.id?"var(--bg-input)":"transparent",color:t.sound===o.id?"var(--text-primary)":"var(--text-secondary)"},children:o.label},o.id))})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Trigger idle on"}),e.jsx(Ja,{label:`${n} stops`,checked:r,onChange:o=>s({...t,idleOnStop:o})}),e.jsx(Ja,{label:`${n} sends a notification`,checked:a,onChange:o=>s({...t,idleOnNotification:o}),className:"mt-1"})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.systemNotification,onChange:o=>{const i=o.target.checked;s({...t,systemNotification:i}),i&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"System notification"})]}),e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--text-dim)"},children:"Shows when tab is not visible"}),typeof Notification<"u"&&Notification.permission==="denied"&&e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--accent-red, #ef4444)"},children:"Notifications are blocked. Click the lock icon in your address bar → Site settings → Notifications → Allow"})]})]})}const IR=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsControls:ii},Symbol.toStringTag,{value:"Module"}));function qp({settings:t,onChange:s,agentName:n,providerLabel:r}){const[a,o]=l.useState(!1),i=l.useRef(null),c=t.idleOnStop??!1,d=t.idleOnNotification??!0,u=t.sound!=="off"||t.systemNotification||c||d;return l.useEffect(()=>{if(!a)return;const h=p=>{i.current&&!i.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[a]),e.jsxs("div",{className:"h-7 flex items-center px-3 text-xs shrink-0",style:{background:"var(--bg-nav)",borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",ref:i,children:[e.jsx("button",{onClick:()=>{o(!a),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"cursor-pointer transition-colors",style:{color:u?"var(--accent-green)":"var(--text-dim)",fontSize:"11px"},children:u?"Notifications On":"Notifications Off"}),a&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx(ii,{settings:t,onChange:s,providerLabel:r}),e.jsx("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:e.jsx(Lp,{agentName:n})})]})]})]})}const DR=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsPopover:qp},Symbol.toStringTag,{value:"Module"})),Hp="codeyam-editor-notifications-prompted",I1="codeyam-editor-notifications";function Wp(){try{localStorage.setItem(Hp,"1")}catch{}}function D1(){try{return localStorage.getItem(Hp)!==null||localStorage.getItem(I1)!==null}catch{return!0}}function Gp({settings:t,onChange:s,providerLabel:n}){const[r,a]=l.useState(()=>!D1());if(!r)return null;const o=()=>{Wp(),a(!1)},i=()=>{s({...t,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission(),o()};return e.jsxs("div",{className:"rounded-lg px-4 py-2.5 mb-3 flex items-center gap-3",style:{background:"var(--surface-card)",border:"1px solid var(--lime-300)"},children:[e.jsx("span",{"aria-hidden":"true",style:{fontSize:15,lineHeight:1,color:"var(--lime-300)"},children:"🔔"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-strong)"},children:["Get notified when ",n," finishes"]}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-faint)",marginLeft:8},children:"We'll ping you when the agent stops or pauses."})]}),e.jsx("button",{onClick:i,className:"shrink-0 cursor-pointer transition-colors",style:{background:"var(--action-bg)",color:"var(--action-fg)",fontSize:"12.5px",fontWeight:600,borderRadius:9,padding:"7px 14px"},children:"Enable"}),e.jsx("button",{onClick:o,className:"shrink-0 cursor-pointer",style:{color:"var(--text-faint)",fontSize:"12px"},children:"Not now"})]})}const LR=Object.freeze(Object.defineProperty({__proto__:null,NotificationSetupBanner:Gp},Symbol.toStringTag,{value:"Module"}));function Up(){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 Yp({appStatsLength:t,configLoading:s,scenariosLoading:n,setupAnswersSaved:r,hasStepState:a}){return t===0&&!s&&!n&&r===!1&&!a}function Vp({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 FR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateBuildingPanel:Vp},Symbol.toStringTag,{value:"Module"}));function Kp(){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 zR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateNoAppPanel:Kp},Symbol.toStringTag,{value:"Module"}));function Jp({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 $R=Object.freeze(Object.defineProperty({__proto__:null,OpenBuildTabButton:Jp},Symbol.toStringTag,{value:"Module"}));function Xp({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(Vp,{projectDescription:t}):e.jsx(Kp,{}),e.jsx(Jp,{onClick:s})]})}const BR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyState:Xp},Symbol.toStringTag,{value:"Module"}));function Qp({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(ju,{stats:i,onClick:()=>s(i.app.dir),testsLoading:n,testsRefreshing:r,onRunTests:a,currentRunner:o},i.app.dir))})}const qR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewGrid:Qp},Symbol.toStringTag,{value:"Module"}));function Zp({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(Go,{coverage:s,testId:"app-overview-coverage",onClick:n})]})}const HR=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewHeader:Zp},Symbol.toStringTag,{value:"Module"})),L1=28,F1=21,z1=4,$1=5,B1={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"},q1={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"},H1={1:"Triage",2:"Route",3:"Wrap Up",4:"Complete"},W1={1:"Ground",2:"Generate",3:"Iterate",4:"Resolve",5:"Return"},G1={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."},U1={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."},Y1={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."},V1={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."},K1={ui:B1,backend:q1,assist:H1,design:W1},J1={ui:G1,backend:U1,assist:Y1,design:V1},X1={ui:L1,backend:F1,assist:z1,design:$1},Q1={ui:"UI Flow",backend:"Backend Flow",assist:"Assist Flow",design:"Design Round"},Z1=["ui","backend","assist","design"];function Rt(t){return Z1.includes(t)?t:"ui"}function li(t,s){return K1[Rt(s)][t]??"?"}function ek(t,s){return J1[Rt(s)][t]??""}function ci(t){return X1[Rt(t)]}function em(t){return Q1[Rt(t)]}function tm(t,s){const n=Rt(s);return{description:ek(t,n),label:li(t,n),prefix:em(n),totalSteps:ci(n)}}const tk={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"},sk={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"},nk=[{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]}],rk=[{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 ak(t,s){return(Rt(s)==="backend"?sk:tk)[t]??""}function ok(t){return Rt(t)==="backend"?rk:nk}const ik={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 di({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=ik[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:em(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(Ie,{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 WR=Object.freeze(Object.defineProperty({__proto__:null,BuildingDoor:di},Symbol.toStringTag,{value:"Module"}));function sm({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(di,{isBuilding:t,buildingLabel:s,buildingStepLabel:n,buildingStepIndicator:r,buildingStatus:a,buildingProgress:o,buildingMode:i,onOpenBuilding:c,onStartNewFeature:c,onResetBuild:d})})})}):null}const GR=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildStatusSection:sm},Symbol.toStringTag,{value:"Module"}));async function lk(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 Fl=["product-type","description","tech-stack","notifications","design-approach"];function ck(t){return t==="files"||t==="chat"?[...Fl,"design-details"]:Fl}const nm="codeyam.questionnaire.draft";function ui(t){return`${nm}:${t}`}function dk(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 xa(t){try{const s=localStorage.getItem(ui(t));if(s===null)return null;const n=JSON.parse(s);return dk(n)?n:null}catch{return null}}function uk(t,s){try{localStorage.setItem(ui(t),JSON.stringify(s))}catch{}}function hk(t){try{localStorage.removeItem(ui(t))}catch{}}function pk(){try{localStorage.removeItem(nm)}catch{}}function mk(){const[t,s]=l.useState([]);return l.useEffect(()=>{fetch("/api/editor-stacks").then(n=>n.json()).then(s).catch(()=>{})},[]),{techStacks:t}}function fk(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 rm({dragActive:t,inputRef:s,folderInputRef:n,onDragOver:r,onDragLeave:a,onDrop:o,onFilePick:i,onFolderPick:c}){return e.jsxs(e.Fragment,{children:[e.jsxs("label",{onDragOver:r,onDragLeave:a,onDrop:o,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"var(--spacing-xl, 32px)",border:`2px dashed ${t?"var(--accent-active)":"var(--border-default)"}`,borderRadius:12,background:t?"var(--bg-elevated, rgba(255,255,255,0.03))":"var(--bg-input)",cursor:"pointer",textAlign:"center",gap:"var(--spacing-xs, 4px)"},children:[e.jsx("input",{ref:s,type:"file",multiple:!0,onChange:i,style:{display:"none"}}),e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500},children:"Drop files or a folder here, or click to choose files"}),e.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"PNG, JPG, PDF, Markdown — anything that describes your design"})]}),e.jsx(Yc,{folderInputRef:n,onFolderPick:c})]})}const UR=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropLabel:rm},Symbol.toStringTag,{value:"Module"}));function am({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,overflowWrap:"anywhere"},children:t.relativePath}),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 YR=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCard:am},Symbol.toStringTag,{value:"Module"}));function om({pending:t,onDescriptionChange:s,onRemove:n}){return t.length===0?null:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)",marginTop:"var(--spacing-md, 12px)"},children:[e.jsx(Uc,{count:t.length}),t.map(r=>e.jsx(am,{pending:r,onDescriptionChange:s,onRemove:n},r.id))]})}const VR=Object.freeze(Object.defineProperty({__proto__:null,PendingFileList:om},Symbol.toStringTag,{value:"Module"}));function gk(t){return new Promise(s=>{t.file(n=>s(n),()=>s(null))})}function bk(t){return new Promise(s=>{const n=[],r=()=>{t.readEntries(a=>{if(a.length===0){s(n);return}n.push(...a),r()},()=>s(n))};r()})}function xk(t){return t.split("/").some(s=>s.startsWith("."))}async function im(t,s,n){if(t.name.startsWith("."))return 0;const r=s?`${s}/${t.name}`:t.name;if(t.isFile){const a=await gk(t);return a?(n.push({file:a,relativePath:r}),0):1}if(t.isDirectory){const a=await bk(t.createReader());let o=0;for(const i of a)o+=await im(i,r,n);return o}return 0}async function yk(t){const s=t.items;if(!(!!s&&s.length>0&&typeof s[0].webkitGetAsEntry=="function"))return{files:Array.from(t.files).map(i=>({file:i,relativePath:i.name})),skipped:0,expandedViaEntryApi:!1};const r=[];for(const i of Array.from(s)){const c=i.webkitGetAsEntry();c&&r.push(c)}const a=[];let o=0;for(const i of r)o+=await im(i,"",a);return{files:a,skipped:o,expandedViaEntryApi:!0}}function vk(t){return Array.from(t).map(s=>({file:s,relativePath:s.webkitRelativePath||s.name})).filter(({relativePath:s})=>!xk(s))}function jk(t){return t.size===0&&t.type===""}const wk="Folders can't be read in this browser — open the folder and drop the files inside it.";function _k(t,s,n){const r=[];let a=null;for(const o of t){if(!s&&jk(o.file)){a=wk;continue}if(o.file.size>n){a=`${o.relativePath} is larger than the ${n/(1024*1024*1024)}GB safety ceiling`;continue}r.push(o)}return{valid:r,rejection:a}}function kk(t){const{files:s,skipped:n,expandedViaEntryApi:r}=t;return n>0&&s.length===0?"Couldn't read any of the files in that folder.":s.length===0&&r?"No files found in that folder.":n>0?`${n} item(s) couldn't be read and were skipped.`:null}async function Sk(t){const s=new FormData;for(const a of t)s.append("path",a.relativePath),s.append("description",a.description),s.append("file",a.file,a.file.name);const n=await fetch("/api/editor-design-assets",{method:"POST",body:s});if(!n.ok)throw new Error(n.status===413?"That file is too large to add.":`Could not save assets (status ${n.status}).`);return(await n.json()).written??t.map(a=>a.relativePath)}function lm({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 KR=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveErrorMessage:lm},Symbol.toStringTag,{value:"Module"}));function cm({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 JR=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveSuccessMessage:cm},Symbol.toStringTag,{value:"Module"}));function dm({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 XR=Object.freeze(Object.defineProperty({__proto__:null,SaveAssetsButton:dm},Symbol.toStringTag,{value:"Module"})),Nk=1024*1024*1024;function hi({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.useRef(null),m=l.useCallback((w,_)=>{const{valid:k,rejection:C}=_k(w,_,Nk);return d(C),n(S=>[...S,...k.map(({file:T,relativePath:A})=>({id:`${A}-${T.size}-${Math.random().toString(36).slice(2)}`,file:T,relativePath:A,description:""}))]),C!==null},[]),b=l.useCallback(async w=>{const _=await yk(w);if(m(_.files,_.expandedViaEntryApi))return;const k=kk(_);k&&d(k)},[m]),g=l.useCallback(w=>{w.target.files&&m(Array.from(w.target.files).map(_=>({file:_,relativePath:_.name})),!1),w.target.value=""},[m]),x=l.useCallback(w=>{if(w.target.files){const _=vk(w.target.files);m(_,!0),_.length===0&&d("No files found in that folder.")}w.target.value=""},[m]),y=l.useCallback((w,_)=>{n(k=>k.map(C=>C.id===w?{...C,description:_}:C))},[]),v=l.useCallback(w=>{n(_=>_.filter(k=>k.id!==w))},[]),j=l.useCallback(async()=>{if(s.length!==0){a(!0),d(null);try{const w=await Sk(s);i(w),n([]),t==null||t(w)}catch(w){d(w instanceof Error?w.message:String(w))}finally{a(!1)}}},[s,t]);return e.jsxs(e.Fragment,{children:[e.jsx(rm,{dragActive:u,inputRef:p,onDragOver:w=>{w.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:w=>{w.preventDefault(),h(!1),b(w.dataTransfer)},onFilePick:g,onFolderPick:x,folderInputRef:f}),e.jsx(om,{pending:s,onDescriptionChange:y,onRemove:v}),e.jsx(lm,{message:c}),e.jsx(cm,{filenames:o}),e.jsx(dm,{disabled:s.length===0||r,submitting:r,onClick:j})]})}const QR=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropZone:hi},Symbol.toStringTag,{value:"Module"}));function qt({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 ZR=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireStepPanel:qt},Symbol.toStringTag,{value:"Module"}));function um({onAssetsSaved:t}){return e.jsx(qt,{title:"Add your design files",subtitle:"Drop in anything: brand assets, mockups, references. Tell us briefly what each one shows.",children:e.jsx(hi,{onAssetsSaved:t})})}const eE=Object.freeze(Object.defineProperty({__proto__:null,DesignAddAssetsStep:um},Symbol.toStringTag,{value:"Module"}));function Ls({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(hm,{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 hm({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 tE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireOptionCard:Ls,QuestionnaireOptionIndicator:hm},Symbol.toStringTag,{value:"Module"})),Ck=[{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 pm({selected:t,onSelect:s}){return e.jsx(qt,{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:Ck.map(n=>e.jsx(Ls,{label:n.label,description:n.description,selected:t===n.id,onClick:()=>s(n.id)},n.id))})})}const sE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignApproachStep:pm},Symbol.toStringTag,{value:"Module"}));function mm({providerLabel:t}){const[s,n]=l.useState(()=>zp());l.useEffect(()=>{Wp()},[]);const r=o=>{n(o),$p(o)},a=()=>{r({...s,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()};return e.jsx(qt,{title:`Want to be notified when ${t} 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:a,className:"text-left px-3 py-2 rounded cursor-pointer transition-colors",style:{background:s.systemNotification?"var(--bg-input)":"var(--accent-green, #16a34a)",color:s.systemNotification?"var(--text-primary)":"#fff",fontSize:"var(--text-sm, 14px)",fontWeight:600,border:"1px solid var(--border-default)"},children:s.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(ii,{settings:s,onChange:r,providerLabel:t})}),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 nE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireNotificationsStep:mm},Symbol.toStringTag,{value:"Module"}));function Pk(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 fm({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 rE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatLaunchPanel:fm},Symbol.toStringTag,{value:"Module"}));function Xa({description:t,launched:s,onLaunched:n,onDesignSelected:r,onPreviewUrl:a,variant:o="chat"}){const[i,c]=l.useState({kind:"preparing"}),{config:d}=gt(),u=rt(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]),Pk(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(qt,{title:m,subtitle:b,children:s?e.jsx(_s,{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(fm,{providerLabel:u,preparing:f,onLaunch:n,variant:o})})}const aE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatStep:Xa},Symbol.toStringTag,{value:"Module"})),Tk=[{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 gm({selected:t,onSelect:s}){return e.jsx("div",{style:{marginTop:"var(--spacing-xl, 32px)"},children:e.jsx(qt,{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:Tk.map(n=>e.jsx(Ls,{label:n.label,description:n.description,selected:t===n.id,onClick:()=>s(n.id)},n.id))})})})}const oE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDeviceSelector:gm},Symbol.toStringTag,{value:"Module"}));function pi(){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 iE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireIntroBanner:pi},Symbol.toStringTag,{value:"Module"}));function bm({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 lE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireNavButtons:bm},Symbol.toStringTag,{value:"Module"}));function xm({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 cE=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireStepNav:xm},Symbol.toStringTag,{value:"Module"})),Ak=[{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"}],Ok={"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"},zl=560,Rk=960;function ym(t){const{projectDir:s,loaded:n}=Gc(),r=l.useRef(!1);return l.useEffect(()=>{n&&!r.current&&(r.current=!0,pk())},[n]),n?e.jsx(vm,{...t,projectDir:s}):e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:e.jsx(pi,{})})}function vm({onComplete:t,onPreviewUrl:s,projectDir:n}){const{config:r}=gt(),a=rt(r==null?void 0:r.provider),[o,i]=l.useState(()=>{const P=n?xa(n):null;return P?P.step:1}),[c,d]=l.useState(()=>{const P=n?xa(n):null;return(P==null?void 0:P.answers)??{appFormats:[],description:"",techStackId:null,designApproach:null,defaultDevice:null}}),[u,h]=l.useState(null),[p,f]=l.useState(!1),[m,b]=l.useState(()=>{const P=n?xa(n):null;return(P==null?void 0:P.designChatLaunched)??!1}),g=l.useRef(m),{techStacks:x}=mk(),y=ck(c.designApproach),v=y[o-1],j=o===y.length,w=y.map(P=>Ok[P]);l.useEffect(()=>{o>y.length&&i(y.length)},[o,y.length]);const _=l.useRef(!0);l.useEffect(()=>{if(_.current){_.current=!1;return}n!==null&&uk(n,{step:o,answers:c,designChatLaunched:m,savedAt:new Date().toISOString()})},[o,c,m,n]);const k=l.useCallback(()=>{b(!0)},[]),[C,S]=l.useState(g.current?{state:"pending"}:{state:"ready",active:null});l.useEffect(()=>{if(!g.current)return;let P=!1;return(async()=>{try{const M=await(await fetch("/api/editor-design-state")).json();P||S({state:"ready",active:M.active??null})}catch{P||S({state:"ready",active:null})}})(),()=>{P=!0}},[]);const T=l.useCallback(P=>{d($=>{const M=$.appFormats.includes(P),G=M?$.appFormats.filter(Q=>Q!==P):[...$.appFormats,P],Y=P==="web"&&M?null:$.defaultDevice;return{...$,appFormats:G,defaultDevice:Y}})},[]),A=l.useCallback(P=>{d($=>({...$,defaultDevice:P}))},[]),E=l.useCallback(P=>{d($=>({...$,designApproach:$.designApproach===P?null:P}))},[]),N=l.useCallback(async()=>{await lk(c),n!==null&&hk(n),t==null||t(c)},[c,t,n]),B=l.useRef(!1);l.useEffect(()=>{B.current||C.state==="ready"&&v==="design-details"&&(c.designApproach==="chat"||c.designApproach==="files")&&u!==null&&u!==C.active&&(B.current=!0,N())},[v,c.designApproach,u,N,C]);const q=l.useCallback(()=>{i(P=>P+1)},[]),H=c.appFormats.includes("web"),R=(()=>{switch(v){case"product-type":return c.appFormats.length>0&&(!H||c.defaultDevice!==null);case"description":return c.description.trim().length>0;case"notifications":return!0;case"design-approach":return c.designApproach!==null;case"design-details":return c.designApproach==="chat"?u!==null:!0;default:return!0}})(),F=v==="description"?Rk:v==="design-details"&&(c.designApproach==="chat"||c.designApproach==="files"&&m)?"100%":zl;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:[e.jsx(pi,{}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"var(--spacing-xl, 32px)"},children:[e.jsxs("div",{style:{maxWidth:F},children:[v==="product-type"&&e.jsxs(e.Fragment,{children:[e.jsx(qt,{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:Ak.map(P=>e.jsx(Ls,{label:P.label,selected:c.appFormats.includes(P.id),onClick:()=>T(P.id),multi:!0},P.id))})}),H&&e.jsx(gm,{selected:c.defaultDevice,onSelect:A})]}),v==="description"&&e.jsx(qt,{title:"Describe your product",subtitle:"What are you building? This helps us set up the right starting point.",children:e.jsx("textarea",{value:c.description,onChange:P=>d($=>({...$,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"}})}),v==="tech-stack"&&(()=>{const P=x.map(M=>{const G=fk(M,c.appFormats,c.description);let Y=M.name,Q=M.description;return G==="Strong"?Q=M.reasonStrong||M.description:G==="Adjacent"?(Y=`${M.name} (Recommended — Closest Fit)`,Q=M.reasonAdjacent||M.description):G==="Mismatch"&&(Y=`${M.name} (Mismatch — Pivot Required)`,Q=M.reasonMismatch||M.description),{stack:M,fit:G,label:Y,description:Q}}),$=P.filter(M=>M.fit!=="Mismatch"||p);return e.jsxs(qt,{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(Ls,{label:"Let CodeYam decide",description:"We'll pick the best stack based on your product",selected:c.techStackId===null,onClick:()=>d(M=>({...M,techStackId:null}))}),$.map(({stack:M,label:G,description:Y})=>e.jsx(Ls,{label:G,description:Y,selected:c.techStackId===M.id,onClick:()=>d(Q=>({...Q,techStackId:M.id}))},M.id))]}),P.some(M=>M.fit==="Mismatch")&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"var(--spacing-md, 12px)"},children:e.jsx("button",{type:"button",onClick:()=>f(M=>!M),style:{background:"none",border:"none",color:"var(--accent-active)",cursor:"pointer",fontSize:"var(--text-xs, 12px)",textDecoration:"underline",padding:0},children:p?"Hide incompatible stacks":"Show all stacks"})})]})})(),v==="notifications"&&e.jsx(mm,{providerLabel:a}),v==="design-approach"&&e.jsx(pm,{selected:c.designApproach,onSelect:E}),v==="design-details"&&c.designApproach==="files"&&e.jsxs(e.Fragment,{children:[e.jsx(um,{}),e.jsx(Xa,{description:c.description,launched:m,onLaunched:k,onDesignSelected:h,onPreviewUrl:s,variant:"files"})]}),v==="design-details"&&c.designApproach==="chat"&&e.jsx(Xa,{description:c.description,launched:m,onLaunched:k,onDesignSelected:h,onPreviewUrl:s})]}),e.jsxs("div",{style:{maxWidth:zl},children:[e.jsx(bm,{step:o,canAdvance:R,isFinalStep:j,onBack:()=>i(P=>P-1),onNext:()=>{R&&q()},onFinish:N}),e.jsx(xm,{currentStep:o,stepLabels:w,onStepClick:i})]})]})]})}const dE=Object.freeze(Object.defineProperty({__proto__:null,NewProjectQuestionnaire:ym,NewProjectQuestionnaireInner:vm},Symbol.toStringTag,{value:"Module"}));function jm({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:k}){const{saved:C}=Up();return n.length===0?o||i||C===null?null:Yp({appStatsLength:n.length,configLoading:!!o,scenariosLoading:!!i,setupAnswersSaved:C,hasStepState:!!p})?e.jsx(ym,{onPreviewUrl:f,onComplete:m}):e.jsx(Xp,{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(Zp,{projectTitle:t,coverage:r,onCoverageClick:g}),e.jsx(sm,{isBuilding:x,buildingLabel:y,buildingStepLabel:v,buildingStepIndicator:j,buildingStatus:w,buildingProgress:_,buildingMode:p==null?void 0:p.mode,onOpenBuilding:b??(()=>{}),onResetBuild:k??(()=>{})}),e.jsx(Qp,{stats:n,onSelectApp:a,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:h})]})})}const uE=Object.freeze(Object.defineProperty({__proto__:null,AppOverview:jm},Symbol.toStringTag,{value:"Module"}));function wm({sessionContent:t,stepIndicator:s}){return e.jsxs("div",{className:"flex flex-col h-full",children:[s,t]})}const hE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLayout:wm},Symbol.toStringTag,{value:"Module"}));function _m({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 pE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPaneLayout:_m},Symbol.toStringTag,{value:"Module"}));function Ek(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 Mk(t,s){const n=rt(t),r=rt(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 Ik({resumeMode:t,previousProvider:s,currentProvider:n,awaitingUserInput:r=!1}){return t!=="handoff"||s==null||n==null||s===n?Ek(r):Mk(s,n)}function km({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 mE=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryActionButton:km},Symbol.toStringTag,{value:"Module"}));function Sm({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 fE=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryDialog:Sm},Symbol.toStringTag,{value:"Module"}));function Nm({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 gE=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryHeader:Nm},Symbol.toStringTag,{value:"Module"}));function tr({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 bE=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummaryRow:tr},Symbol.toStringTag,{value:"Module"}));function Cm({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(tr,{label:"Feature",value:t,rowClassName:"mb-1"}),s!=null&&n&&e.jsx(tr,{label:"Step",value:`${s} (${n})`}),r&&e.jsx(tr,{label:"Providers",value:r,rowClassName:"mt-1"})]})}const xE=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummary:Cm},Symbol.toStringTag,{value:"Module"}));function Dk(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 Pm({featureName:t,editorStep:s,workflowMode:n,previousProvider:r,currentProvider:a,resumeMode:o,awaitingUserInput:i=!1,onContinue:c}){const d=Ik({resumeMode:o,previousProvider:r,currentProvider:a,awaitingUserInput:i}),u=s==null?null:li(s,n);return Dk(c),e.jsxs(Sm,{children:[e.jsx(Nm,{title:d.title,description:d.description}),e.jsx(Cm,{featureName:t,editorStep:s,editorStepLabel:u,providersLabel:d.providersLabel}),e.jsx(km,{label:d.buttonLabel,onContinue:c})]})}const yE=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecovery:Pm},Symbol.toStringTag,{value:"Module"}));function Tm({awaitingUserInput:t,currentProvider:s,editorStep:n,featureName:r,onContinue:a,previousProvider:o,resumeMode:i,workflowMode:c}){return e.jsx(Pm,{featureName:r,editorStep:n,workflowMode:c,previousProvider:o,currentProvider:s,resumeMode:i,awaitingUserInput:t,onContinue:a})}const vE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabRecoveryPanel:Tm},Symbol.toStringTag,{value:"Module"}));function Lk({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 sr=8e3,Fk="agent-banner-ready",zk="agent-auth-required";let ur=!1,hr=!1,zt=[],$l=!1,Kt=null,Qt=null,nr=!1;function $k(){$l||typeof window>"u"||($l=!0,window.addEventListener(Fk,()=>{const t=!hr;if(t){hr=!0;const s=zt;zt=[];for(const n of s)n("banner")}if(nr&&(nr=!1,Qt&&Kt===null)){X("dispatch-rename-after-auth",{label:Qt.label,reason:"first-observed-frame-after-auth"}),Kt=Qt,lr(Qt.label,Qt.send);return}Kt&&(X("dispatch-rename-reapply",{label:Kt.label,reason:t?"first-observed-frame":"second-observed-frame"}),lr(Kt.label,Kt.send))}),window.addEventListener(zk,()=>{nr=!0,X("agent-auth-required-observed",{});const t=zt;zt=[];for(const s of t)s("auth-required")}))}$k();function Bk(){return hr?Promise.resolve("banner"):new Promise(t=>{let s=!1;const n=a=>{s||(s=!0,clearTimeout(r),t(a))};zt.push(n);const r=setTimeout(()=>{if(s)return;s=!0;const a=zt.indexOf(n);a>=0&&zt.splice(a,1),t("fallback")},sr)})}async function Am(t,s,n=0,r=n0,a=!1){if(ur){X("dispatch-rename-suppressed",{caller:s,label:t});return}ur=!0,Qt={label:t,send:r},X("dispatch-rename",{phase:"queued",caller:s,label:t,fallbackMs:sr,postReadyDelayMs:n});const o=await Bk();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:sr});return}n>0&&await new Promise(i=>setTimeout(i,n)),o==="fallback"&&X("dispatch-rename-fallback",{caller:s,label:t,fallbackMs:sr}),X("dispatch-rename",{phase:"fired",caller:s,label:t,source:o,postReadyDelayMs:n}),Kt={label:t,send:r},lr(t,r)}function qk(){ur=!1,hr=!1,zt=[],Kt=null,Qt=null,nr=!1}function Hk(){ur=!1,zt=[],Qt=null}const Wk="Editor";function Gk({provider:t,agentStartMode:s,currentFeature:n}){const r=l.useRef(!1);l.useEffect(()=>{if(!(r.current||!r0(t)||s!=="fresh")){if(n!==null){r.current=!0;return}r.current=!0,Am(Wk,"build-session-seed",Wc,void 0,!0)}},[t,s,n])}function Om({snippet:t,onRetry:s,onDismiss:n,providerLabel:r}){return e.jsx("div",{"data-testid":"build-tab-startup-error",className:"border-b border-red-500/30 bg-red-950/40 text-red-100 px-4 py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm mb-1",children:[r," didn't start"]}),e.jsx("pre",{"data-testid":"build-tab-startup-error-snippet",className:"font-mono text-xs whitespace-pre-wrap break-words bg-black/40 text-red-50 px-2 py-1 rounded max-h-40 overflow-auto",children:t})]}),e.jsxs("div",{className:"flex items-start gap-2 shrink-0",children:[e.jsx(dt,{variant:"subtle",text:t,label:"Copy",className:"shrink-0 px-3 py-1.5 rounded border border-red-500/50 text-red-100 text-sm font-medium hover:bg-red-900/40 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"}),e.jsx("button",{type:"button",onClick: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 jE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabStartupError:Om},Symbol.toStringTag,{value:"Module"}));function mi(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 Rm(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 Em=[{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 Mm({defaultOpen:t=!1}){return Rm()?e.jsx(Im,{defaultOpen:t}):null}function Im({defaultOpen:t=!1}){const{config:s}=gt(),[n,r]=l.useState(t),a=l.useRef(null),o=l.useRef(null),i=l.useCallback(()=>r(!1),[]);mi(a,i,o);const c=s&&s.mobileTerminalCommands.length>0?s.mobileTerminalCommands:Em,d=l.useCallback(u=>{u.submit?Oa(u.send):Ra(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 wE=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MOBILE_TERMINAL_COMMANDS:Em,MobileTerminalCommandMenu:Mm,MobileTerminalCommandMenuPanel:Im},Symbol.toStringTag,{value:"Module"})),Uk=1e3;let Qa=0;function Hn(){Qa=Date.now()}function Yk(){return Qa===0?1/0:Date.now()-Qa}function Vk(){return Yk()<Uk}function fi(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 pr=20*1024*1024,Kk=3e4,Dm=3e3;function Lm(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 Jk(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`drop-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Fm(t){return/^[A-Za-z0-9._/\-]+$/.test(t)?t:`"${t.replace(/(["\\$`])/g,"\\$1")}"`}function zm(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 Xk({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),Dm);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>pr)throw new Error(`File too large (max ${pr/(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 Lm(j),k=Jk(),C=new Promise((S,T)=>{const A=window.setTimeout(()=>{i.current.delete(k)&&T(new Error("Timed out waiting for save to complete"))},Kk);i.current.set(k,{resolve:E=>{window.clearTimeout(A),S(E)},reject:E=>{window.clearTimeout(A),T(new Error(E))}})});return w.send(JSON.stringify({type:"drop",id:k,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(k){const C=k instanceof Error?k.message:String(k);d(`Attach failed: ${C}`);return}s(w.map(Fm).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),zm(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 k;const w=(k=j.clipboardData)==null?void 0:k.items;if(!w)return;const _=[];for(const C of Array.from(w))if(C.kind==="file"&&C.type.startsWith("image/")){const S=C.getAsFile();S&&_.push(S)}_.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 gi(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 Qk(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 Zk(t){return t>=200&&t<300?"valid":t===401?"stale":"unreachable"}async function $m(t=1500){try{const s=await fetch("/api/session-check",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(t)});return Zk(s.status)}catch{return"unreachable"}}async function eS(){try{await fetch("/build",{credentials:"same-origin",cache:"no-store"})}catch{return!1}return await $m()==="valid"}function tS({session:t,attempts:s,max:n}){return t!=="stale"?"check-transport":s<n?"reacquire":"give-up"}function Bm(){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 _E=Object.freeze(Object.defineProperty({__proto__:null,TerminalDropOverlay:Bm},Symbol.toStringTag,{value:"Module"}));function qm({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 kE=Object.freeze(Object.defineProperty({__proto__:null,TerminalDropToast:qm},Symbol.toStringTag,{value:"Module"}));function qr(){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 SE=Object.freeze(Object.defineProperty({__proto__:null,TerminalCopiedToast:qr},Symbol.toStringTag,{value:"Module"})),Bl=15,sS=3,nS=2;function Hm({provider:t,agentStartMode:s,sessionId:n,onAgentIdle:r,onAgentActive:a,onUserInput:o,onStartupFailed:i,onStartupFailedCleared:c,suppressReconnectOnStopBuilding:d=!1,launchIntent:u=!1}){if(wt())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),[k,C]=gi(1200);l.useEffect(()=>{g.current=s??"fresh",x.current=n??null,y.current=u},[s,n,u]);const S=l.useRef(r);S.current=r;const T=l.useRef(a);T.current=a;const A=l.useRef(o);A.current=o;const E=l.useRef(i);E.current=i;const N=l.useRef(c);N.current=c;const B=Xk({wsRef:m,insertInput:R=>{var F,P;((F=m.current)==null?void 0:F.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:R})),Hn(),(P=A.current)==null||P.call(A)}}),q=l.useRef(B);q.current=B;const H=l.useCallback(R=>{var F;return((F=m.current)==null?void 0:F.readyState)===WebSocket.OPEN?(m.current.send(JSON.stringify({type:"input",data:R})),!0):!1},[]);return a0(H,v.kind==="open"),fi(h,()=>{var R;f.current&&p.current&&(f.current.fit(),((R=m.current)==null?void 0:R.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 R=new Co.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),F=new Po.FitAddon;R.loadAddon(F),R.open(h.current),p.current=R,f.current=F;const P=To(R,h.current,{onError:W=>q.current.showError(W),onCopy:()=>C()}),$=Ao(R,{sendInput:W=>{var K,se;((K=m.current)==null?void 0:K.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:W})),Hn(),(se=A.current)==null||se.call(A)}});requestAnimationFrame(()=>{F.fit(),R.focus()});let M=!1,G=0,Y=!1,Q=0,oe=0,ne=null;function V(){Y=!1;try{const W=new WebSocket(l0({provider:t,mode:g.current,sessionId:x.current??void 0,launch:y.current,cols:R.cols,rows:R.rows}));m.current=W,W.binaryType="arraybuffer",W.onmessage=K=>{var se,ie,me,ye;if(K.data instanceof ArrayBuffer)R.write(new Uint8Array(K.data));else if(typeof K.data=="string")try{const U=JSON.parse(K.data);if(U.type==="error"){M=!0,j({kind:"server-error",message:c0(U)});return}if(U.type==="session-id")g.current="resume",x.current=U.sessionId??null;else if(U.type==="agent-idle"||U.type==="claude-idle"){const Te=typeof U.source=="string"?U.source:void 0;X("ws-message-received",{type:U.type,source:Te}),(se=S.current)==null||se.call(S,Te)}else if(U.type==="agent-active"||U.type==="claude-active")X("ws-message-received-active",{type:U.type}),(ie=T.current)==null||ie.call(T);else if(U.type==="idle-diag"){const{site:Te,event:de,...ve}=U;X(`rust:${de??"unknown"}`,{site:Te,...ve})}else U.type==="drop-complete"?q.current.resolveDrop(String(U.id??""),String(U.path??"")):U.type==="drop-error"?q.current.rejectDrop(String(U.id??""),String(U.message??"drop failed")):U.type==="startup-failed"?(me=E.current)==null||me.call(E,String(U.snippet??"")):U.type==="startup-failed-cleared"?(ye=N.current)==null||ye.call(N):U.type==="agent-banner-ready"?(X("agent-banner-ready",{}),window.dispatchEvent(new CustomEvent("agent-banner-ready"))):U.type==="agent-auth-required"?(X("agent-auth-required",{}),window.dispatchEvent(new CustomEvent("agent-auth-required"))):U.type==="agent-auth-resolved"&&(X("agent-auth-resolved",{}),window.dispatchEvent(new CustomEvent("agent-auth-resolved")))}catch{}},W.onopen=()=>{G=0,Y=!0,Q=0,oe=0,j({kind:"open"}),X("ws-open"),W.send(JSON.stringify({type:"resize",cols:R.cols,rows:R.rows}));try{typeof localStorage<"u"&&localStorage.getItem("codeyam.idleDebug")==="1"&&(W.send(JSON.stringify({type:"enable-idle-diag",sessionId:Eo()})),X("idle-diag-enabled"))}catch{}},W.onerror=()=>{},W.onclose=async()=>{if(X("ws-close",{reconnectAttempts:G}),q.current.cancelAllDrops("Not connected"),M){j(se=>se.kind==="server-error"?se:{kind:"ended"}),R.writeln(`\r
20
+ \x1B[90m[Terminal session ended]\x1B[0m`);return}const K=await d0();if(!M){if(!K){j({kind:"server-stopped"}),ne==null||ne(),ne=u0(2e3,()=>{M||window.location.reload()});return}if(Y)Q=0;else{Q++;const se=await $m();if(M)return;const ie=tS({session:se,attempts:oe,max:nS});if(ie==="reacquire"){oe++,j({kind:"session-stale"});const ye=await eS();if(M)return;if(ye){Q=0,V();return}j({kind:"session-stale",canRetry:!0});return}if(ie==="give-up"){j({kind:"session-stale",canRetry:!0});return}const me=await Qk();if(M)return;if(!me||Q>=sS){j({kind:"edge-unreachable"});return}}if(G<Bl){const se=G<4?1e3*Math.pow(2,G):1e4;G++,j({kind:"reconnecting",attempt:G,maxAttempts:Bl}),setTimeout(()=>{M||V()},se)}else j({kind:"failed"})}}}catch{j({kind:"failed"})}}try{F.fit()}catch{}V();let be=0;const le=1e3;function ce(){var K;const W=Date.now();W-be>=le&&((K=m.current)==null?void 0:K.readyState)===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"browser-activity"})),be=W)}document.addEventListener("mousemove",ce),document.addEventListener("keydown",ce),document.addEventListener("mousedown",ce),R.onData(W=>{var K,se;((K=m.current)==null?void 0:K.readyState)===WebSocket.OPEN?m.current.send(JSON.stringify({type:"input",data:W})):_(ie=>ie+1),Hn(),(se=A.current)==null||se.call(A)});const Z=h.current;function z(W){var U,Te,de,ve;const K=W,se=(U=K.clipboardData)==null?void 0:U.items;if(se){for(const ke of Array.from(se))if(ke.kind==="file"&&ke.type.startsWith("image/")){W.preventDefault(),W.stopPropagation(),q.current.pasteHandler(K);return}}const ie=((Te=K.clipboardData)==null?void 0:Te.getData("text"))??"";if(!ie)return;W.preventDefault(),W.stopPropagation();const me=ie.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),ye=R.modes.bracketedPasteMode?`\x1B[200~${me}\x1B[201~`:me;((de=m.current)==null?void 0:de.readyState)===WebSocket.OPEN?m.current.send(JSON.stringify({type:"input",data:ye})):_(ke=>ke+1),Hn(),(ve=A.current)==null||ve.call(A)}Z.addEventListener("paste",z,!0);function D(W){var ie,me;const K=W.detail;if(!K)return;((ie=m.current)==null?void 0:ie.readyState)===WebSocket.OPEN?((me=m.current)==null||me.send(JSON.stringify({type:"input",data:K})),X("terminal-send-input",{len:K.length,firstChars:K.slice(0,16),wsOpen:!0,dropped:!1})):X("terminal-send-input",{len:K.length,firstChars:K.slice(0,16),wsOpen:!1,dropped:!0})}window.addEventListener("terminal-send-input",D),o0();function L(){Oo(),R.focus()}window.addEventListener("terminal-focus",L);function te(){var W;M=!0,(W=m.current)==null||W.close(),j({kind:"ended"}),R.reset()}return d&&window.addEventListener("build-session-stopped",te),()=>{var W;M=!0,ne==null||ne(),ne=null,document.removeEventListener("mousemove",ce),document.removeEventListener("keydown",ce),document.removeEventListener("mousedown",ce),window.removeEventListener("terminal-send-input",D),h0(),window.removeEventListener("terminal-focus",L),d&&window.removeEventListener("build-session-stopped",te),Z.removeEventListener("paste",z,!0),$(),(W=m.current)==null||W.close(),P(),R.dispose(),b.current=!1}},[t]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},"data-terminal-emulator":!0,onDragEnter:B.dropHandlers.onDragEnter,onDragOver:B.dropHandlers.onDragOver,onDragLeave:B.dropHandlers.onDragLeave,onDrop:B.dropHandlers.onDrop,onPaste:B.pasteHandler,children:[e.jsx("div",{ref:h,className:"flex-1",tabIndex:-1,style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3,outline:"none"},onPointerDown:()=>{vl(h.current,()=>{var R;return(R=p.current)==null?void 0:R.focus()})},onClick:()=>{vl(h.current,()=>{var R;return(R=p.current)==null?void 0:R.focus()})}}),B.dragActive&&e.jsx(Bm,{}),B.errorToast&&e.jsx(qm,{message:B.errorToast}),k&&e.jsx(qr,{}),e.jsx(i0,{status:v,pulseKey:w,onRefresh:()=>window.location.reload()})]})}const NE=Object.freeze(Object.defineProperty({__proto__:null,TerminalEmulator:Hm},Symbol.toStringTag,{value:"Module"}));function Wm({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);Gk({provider:r,agentStartMode:o?"resume":"fresh",currentFeature:i}),l.useEffect(()=>()=>{qk()},[]);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(Om,{snippet:c,onRetry:m,onDismiss:f,providerLabel:rt(r)}),e.jsxs("div",{className:"relative flex flex-col flex-1 min-h-0",children:[e.jsx(Hm,{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(Mm,{}),e.jsx("div",{className:"absolute top-2 left-2 z-20 md:left-auto md:right-2",children:e.jsx(p0,{className:"rounded-full bg-gray-800/90 px-3 py-1.5 shadow-lg ring-1 ring-white/10 backdrop-blur"})})]})]})}const CE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabTerminalSession:Wm},Symbol.toStringTag,{value:"Module"}));function rS(){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 Hr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Us(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function bi(t){return"nodeType"in t}function at(t){var s,n;return t?Us(t)?t:bi(t)&&(s=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?s:window:window}function xi(t){const{Document:s}=at(t);return t instanceof s}function kn(t){return Us(t)?!1:t instanceof at(t).HTMLElement}function Gm(t){return t instanceof at(t).SVGElement}function Ys(t){return t?Us(t)?t.document:bi(t)?xi(t)?t:kn(t)||Gm(t)?t.ownerDocument:document:document:document}const Tt=Hr?l.useLayoutEffect:l.useEffect;function yi(t){const s=l.useRef(t);return Tt(()=>{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 aS(){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 mn(t,s){s===void 0&&(s=[t]);const n=l.useRef(t);return Tt(()=>{n.current!==t&&(n.current=t)},s),n}function Sn(t,s){const n=l.useRef();return l.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...s])}function mr(t){const s=yi(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 Za(t){const s=l.useRef();return l.useEffect(()=>{s.current=t},[t]),s.current}let ya={};function Nn(t,s){return l.useMemo(()=>{if(s)return s;const n=ya[t]==null?0:ya[t]+1;return ya[t]=n,t+"-"+n},[t,s])}function Um(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 Fs=Um(1),fn=Um(-1);function oS(t){return"clientX"in t&&"clientY"in t}function vi(t){if(!t)return!1;const{KeyboardEvent:s}=at(t.target);return s&&t instanceof s}function iS(t){if(!t)return!1;const{TouchEvent:s}=at(t.target);return s&&t instanceof s}function eo(t){if(iS(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 oS(t)?{x:t.clientX,y:t.clientY}:null}const gn=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[gn.Translate.toString(t),gn.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:n,easing:r}=t;return s+" "+n+"ms "+r}}}),ql="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function lS(t){return t.matches(ql)?t:t.querySelector(ql)}const cS={display:"none"};function dS(t){let{id:s,value:n}=t;return st.createElement("div",{id:s,style:cS},n)}function uS(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 st.createElement("div",{id:s,style:a,role:"status","aria-live":r,"aria-atomic":!0},n)}function hS(){const[t,s]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&s(r)},[]),announcement:t}}const Ym=l.createContext(null);function pS(t){const s=l.useContext(Ym);l.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(t)},[t,s])}function mS(){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 fS={draggable:`
21
+ To pick up a draggable item, press the space bar.
22
+ While dragging, use the arrow keys to move the item.
23
+ Press space again to drop the item in its new position, or press escape to cancel.
24
+ `},gS={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 bS(t){let{announcements:s=gS,container:n,hiddenTextDescribedById:r,screenReaderInstructions:a=fS}=t;const{announce:o,announcement:i}=hS(),c=Nn("DndLiveRegion"),[d,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),pS(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=st.createElement(st.Fragment,null,st.createElement(dS,{id:r,value:a.draggable}),st.createElement(uS,{id:c,announcement:i}));return n?ys.createPortal(h,n):h}var De;(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"})(De||(De={}));function fr(){}function Hl(t,s){return l.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function xS(){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 jt=Object.freeze({x:0,y:0});function Vm(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function Km(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return n-r}function yS(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return r-n}function Wl(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 Jm(t,s){if(!t||t.length===0)return null;const[n]=t;return n[s]}function Gl(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 vS=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=Gl(s,s.left,s.top),o=[];for(const i of r){const{id:c}=i,d=n.get(c);if(d){const u=Vm(Gl(d),a);o.push({id:c,data:{droppableContainer:i,value:u}})}}return o.sort(Km)},jS=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=Wl(s),o=[];for(const i of r){const{id:c}=i,d=n.get(c);if(d){const u=Wl(d),h=a.reduce((f,m,b)=>f+Vm(u[b],m),0),p=Number((h/4).toFixed(4));o.push({id:c,data:{droppableContainer:i,value:p}})}}return o.sort(Km)};function wS(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 _S=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=wS(c,s);d>0&&a.push({id:i,data:{droppableContainer:o,value:d}})}}return a.sort(yS)};function kS(t,s,n){return{...t,scaleX:s&&n?s.width/n.width:1,scaleY:s&&n?s.height/n.height:1}}function Xm(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:jt}function SS(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 NS=SS(1);function CS(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 PS(t,s,n){const r=CS(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 TS={ignoreTransform:!1};function Vs(t,s){s===void 0&&(s=TS);let n=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:h}=at(t).getComputedStyle(t);u&&(n=PS(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 Ul(t){return Vs(t,{ignoreTransform:!0})}function AS(t){const s=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:s,bottom:n,width:s,height:n}}function OS(t,s){return s===void 0&&(s=at(t).getComputedStyle(t)),s.position==="fixed"}function RS(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 Wr(t,s){const n=[];function r(a){if(s!=null&&n.length>=s||!a)return n;if(xi(a)&&a.scrollingElement!=null&&!n.includes(a.scrollingElement))return n.push(a.scrollingElement),n;if(!kn(a)||Gm(a)||n.includes(a))return n;const o=at(t).getComputedStyle(a);return a!==t&&RS(a,o)&&n.push(a),OS(a,o)?n:r(a.parentNode)}return t?r(t):n}function Qm(t){const[s]=Wr(t,1);return s??null}function va(t){return!Hr||!t?null:Us(t)?t:bi(t)?xi(t)||t===Ys(t).scrollingElement?window:kn(t)?t:null:null}function Zm(t){return Us(t)?t.scrollX:t.scrollLeft}function ef(t){return Us(t)?t.scrollY:t.scrollTop}function to(t){return{x:Zm(t),y:ef(t)}}var ze;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ze||(ze={}));function tf(t){return!Hr||!t?!1:t===document.scrollingElement}function sf(t){const s={x:0,y:0},n=tf(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 ES={x:.2,y:.2};function MS(t,s,n,r,a){let{top:o,left:i,right:c,bottom:d}=n;r===void 0&&(r=10),a===void 0&&(a=ES);const{isTop:u,isBottom:h,isLeft:p,isRight:f}=sf(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 IS(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 nf(t){return t.reduce((s,n)=>Fs(s,to(n)),jt)}function DS(t){return t.reduce((s,n)=>s+Zm(n),0)}function LS(t){return t.reduce((s,n)=>s+ef(n),0)}function FS(t,s){if(s===void 0&&(s=Vs),!t)return;const{top:n,left:r,bottom:a,right:o}=s(t);Qm(t)&&(a<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const zS=[["x",["left","right"],DS],["y",["top","bottom"],LS]];class ji{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=Wr(n),a=nf(r);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,i,c]of zS)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 ln{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 $S(t){const{EventTarget:s}=at(t);return t instanceof s?t:Ys(t)}function ja(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 ft;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ft||(ft={}));function Yl(t){t.preventDefault()}function BS(t){t.stopPropagation()}var ge;(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"})(ge||(ge={}));const rf={start:[ge.Space,ge.Enter],cancel:[ge.Esc],end:[ge.Space,ge.Enter,ge.Tab]},qS=(t,s)=>{let{currentCoordinates:n}=s;switch(t.code){case ge.Right:return{...n,x:n.x+25};case ge.Left:return{...n,x:n.x-25};case ge.Down:return{...n,y:n.y+25};case ge.Up:return{...n,y:n.y-25}}};class wi{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 ln(Ys(n)),this.windowListeners=new ln(at(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ft.Resize,this.handleCancel),this.windowListeners.add(ft.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ft.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:n}=this.props,r=s.node.current;r&&FS(r),n(jt)}handleKeyDown(s){if(vi(s)){const{active:n,context:r,options:a}=this.props,{keyboardCodes:o=rf,coordinateGetter:i=qS,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}:jt;this.referenceCoordinates||(this.referenceCoordinates=h);const p=i(s,{active:n,context:r.current,currentCoordinates:h});if(p){const f=fn(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:k}=sf(g),C=IS(g),S={x:Math.min(x===ge.Right?C.right-C.width/2:C.right,Math.max(x===ge.Right?C.left:C.left+C.width/2,p.x)),y:Math.min(x===ge.Down?C.bottom-C.height/2:C.bottom,Math.max(x===ge.Down?C.top:C.top+C.height/2,p.y))},T=x===ge.Right&&!v||x===ge.Left&&!j,A=x===ge.Down&&!w||x===ge.Up&&!y;if(T&&S.x!==p.x){const E=g.scrollLeft+f.x,N=x===ge.Right&&E<=_.x||x===ge.Left&&E>=k.x;if(N&&!f.y){g.scrollTo({left:E,behavior:c});return}N?m.x=g.scrollLeft-E:m.x=x===ge.Right?g.scrollLeft-_.x:g.scrollLeft-k.x,m.x&&g.scrollBy({left:-m.x,behavior:c});break}else if(A&&S.y!==p.y){const E=g.scrollTop+f.y,N=x===ge.Down&&E<=_.y||x===ge.Up&&E>=k.y;if(N&&!f.x){g.scrollTo({top:E,behavior:c});return}N?m.y=g.scrollTop-E:m.y=x===ge.Down?g.scrollTop-_.y:g.scrollTop-k.y,m.y&&g.scrollBy({top:-m.y,behavior:c});break}}this.handleMove(s,Fs(fn(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()}}wi.activators=[{eventName:"onKeyDown",handler:(t,s,n)=>{let{keyboardCodes:r=rf,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 Vl(t){return!!(t&&"distance"in t)}function Kl(t){return!!(t&&"delay"in t)}class _i{constructor(s,n,r){var a;r===void 0&&(r=$S(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=Ys(i),this.documentListeners=new ln(this.document),this.listeners=new ln(r),this.windowListeners=new ln(at(i)),this.initialCoordinates=(a=eo(o))!=null?a:jt,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(ft.Resize,this.handleCancel),this.windowListeners.add(ft.DragStart,Yl),this.windowListeners.add(ft.VisibilityChange,this.handleCancel),this.windowListeners.add(ft.ContextMenu,Yl),this.documentListeners.add(ft.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Kl(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Vl(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(ft.Click,BS,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ft.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=eo(s))!=null?n:jt,u=fn(a,d);if(!r&&c){if(Vl(c)){if(c.tolerance!=null&&ja(u,c.tolerance))return this.handleCancel();if(ja(u,c.distance))return this.handleStart()}if(Kl(c)&&ja(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===ge.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const HS={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ki extends _i{constructor(s){const{event:n}=s,r=Ys(n.target);super(s,HS,r)}}ki.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 WS={move:{name:"mousemove"},end:{name:"mouseup"}};var so;(function(t){t[t.RightClick=2]="RightClick"})(so||(so={}));class GS extends _i{constructor(s){super(s,WS,Ys(s.event.target))}}GS.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;return n.button===so.RightClick?!1:(r==null||r({event:n}),!0)}}];const wa={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class US extends _i{constructor(s){super(s,wa)}static setup(){return window.addEventListener(wa.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(wa.move.name,s)};function s(){}}}US.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 cn;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(cn||(cn={}));var gr;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(gr||(gr={}));function YS(t){let{acceleration:s,activator:n=cn.Pointer,canScroll:r,draggingRect:a,enabled:o,interval:i=5,order:c=gr.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:h,delta:p,threshold:f}=t;const m=KS({delta:p,disabled:!o}),[b,g]=aS(),x=l.useRef({x:0,y:0}),y=l.useRef({x:0,y:0}),v=l.useMemo(()=>{switch(n){case cn.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case cn.DraggableRect:return a}},[n,a,d]),j=l.useRef(null),w=l.useCallback(()=>{const k=j.current;if(!k)return;const C=x.current.x*y.current.x,S=x.current.y*y.current.y;k.scrollBy(C,S)},[]),_=l.useMemo(()=>c===gr.TreeOrder?[...u].reverse():u,[c,u]);l.useEffect(()=>{if(!o||!u.length||!v){g();return}for(const k of _){if((r==null?void 0:r(k))===!1)continue;const C=u.indexOf(k),S=h[C];if(!S)continue;const{direction:T,speed:A}=MS(k,S,v,s,f);for(const E of["x","y"])m[E][T[E]]||(A[E]=0,T[E]=0);if(A.x>0||A.y>0){g(),j.current=k,b(w,i),x.current=A,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 VS={x:{[ze.Backward]:!1,[ze.Forward]:!1},y:{[ze.Backward]:!1,[ze.Forward]:!1}};function KS(t){let{delta:s,disabled:n}=t;const r=Za(s);return Sn(a=>{if(n||!r||!a)return VS;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 JS(t,s){const n=s!=null?t.get(s):void 0,r=n?n.node.current:null;return Sn(a=>{var o;return s==null?null:(o=r??a)!=null?o:null},[r,s])}function XS(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 bn;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(bn||(bn={}));var no;(function(t){t.Optimized="optimized"})(no||(no={}));const Jl=new Map;function QS(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=mn(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=Sn(y=>{if(p&&!n)return Jl;if(!y||y===Jl||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 ji(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 bn.Always:return!1;case bn.BeforeDragging:return n;default:return!n}}}function af(t,s){return Sn(n=>t?n||(typeof s=="function"?s(t):t):null,[s,t])}function ZS(t,s){return af(t,s)}function eN(t){let{callback:s,disabled:n}=t;const r=yi(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 Gr(t){let{callback:s,disabled:n}=t;const r=yi(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 tN(t){return new ji(Vs(t),t)}function Xl(t,s,n){s===void 0&&(s=tN);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=eN({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=Gr({callback:o});return Tt(()=>{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 sN(t){const s=af(t);return Xm(t,s)}const Ql=[];function nN(t){const s=l.useRef(t),n=Sn(r=>t?r&&r!==Ql&&t&&s.current&&t.parentNode===s.current.parentNode?r:Wr(t):Ql,[t]);return l.useEffect(()=>{s.current=t},[t]),n}function rN(t){const[s,n]=l.useState(null),r=l.useRef(t),a=l.useCallback(o=>{const i=va(o.target);i&&n(c=>c?(c.set(i,to(i)),new Map(c)):null)},[]);return l.useEffect(()=>{const o=r.current;if(t!==o){i(o);const c=t.map(d=>{const u=va(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,to(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=va(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),l.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,i)=>Fs(o,i),jt):nf(t):jt,[t,s])}function Zl(t,s){s===void 0&&(s=[]);const n=l.useRef(null);return l.useEffect(()=>{n.current=null},s),l.useEffect(()=>{const r=t!==jt;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?fn(t,n.current):jt}function aN(t){l.useEffect(()=>{if(!Hr)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 oN(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 of(t){return l.useMemo(()=>t?AS(t):null,[t])}const ec=[];function iN(t,s){s===void 0&&(s=Vs);const[n]=t,r=of(n?at(n):null),[a,o]=l.useState(ec);function i(){o(()=>t.length?t.map(d=>tf(d)?r:new ji(s(d),d)):ec)}const c=Gr({callback:i});return Tt(()=>{c==null||c.disconnect(),i(),t.forEach(d=>c==null?void 0:c.observe(d))},[t]),a}function lN(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return kn(s)?s:t}function cN(t){let{measure:s}=t;const[n,r]=l.useState(null),a=l.useCallback(u=>{for(const{target:h}of u)if(kn(h)){r(p=>{const f=s(h);return p?{...p,width:f.width,height:f.height}:f});break}},[s]),o=Gr({callback:a}),i=l.useCallback(u=>{const h=lN(u);o==null||o.disconnect(),h&&(o==null||o.observe(h)),r(h?s(h):null)},[s,o]),[c,d]=mr(i);return l.useMemo(()=>({nodeRef:c,rect:n,setRef:d}),[n,c,d])}const dN=[{sensor:ki,options:{}},{sensor:wi,options:{}}],uN={current:{}},rr={draggable:{measure:Ul},droppable:{measure:Ul,strategy:bn.WhileDragging,frequency:no.Optimized},dragOverlay:{measure:Vs}};class dn 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 hN={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new dn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:fr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:rr,measureDroppableContainers:fr,windowRect:null,measuringScheduled:!1},pN={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:fr,draggableNodes:new Map,over:null,measureDroppableContainers:fr},Ur=l.createContext(pN),lf=l.createContext(hN);function mN(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new dn}}}function fN(t,s){switch(s.type){case De.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case De.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 De.DragEnd:case De.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case De.RegisterDroppable:{const{element:n}=s,{id:r}=n,a=new dn(t.droppable.containers);return a.set(r,n),{...t,droppable:{...t.droppable,containers:a}}}case De.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 dn(t.droppable.containers);return i.set(n,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:i}}}case De.UnregisterDroppable:{const{id:n,key:r}=s,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new dn(t.droppable.containers);return o.delete(n),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function gN(t){let{disabled:s}=t;const{active:n,activatorEvent:r,draggableNodes:a}=l.useContext(Ur),o=Za(r),i=Za(n==null?void 0:n.id);return l.useEffect(()=>{if(!s&&!r&&o&&i!=null){if(!vi(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=lS(h);if(p){p.focus();break}}})}},[r,s,a,i,o]),null}function bN(t,s){let{transform:n,...r}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...r}),n):n}function xN(t){return l.useMemo(()=>({draggable:{...rr.draggable,...t==null?void 0:t.draggable},droppable:{...rr.droppable,...t==null?void 0:t.droppable},dragOverlay:{...rr.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 yN(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;Tt(()=>{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=Xm(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=Qm(u);f&&f.scrollBy({top:p.y,left:p.x})}},[s,i,c,r,n])}const cf=l.createContext({...jt,scaleX:1,scaleY:1});var Jt;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Jt||(Jt={}));const vN=l.memo(function(s){var n,r,a,o;let{id:i,accessibility:c,autoScroll:d=!0,children:u,sensors:h=dN,collisionDetection:p=_S,measuring:f,modifiers:m,...b}=s;const g=l.useReducer(fN,void 0,mN),[x,y]=g,[v,j]=mS(),[w,_]=l.useState(Jt.Uninitialized),k=w===Jt.Initialized,{draggable:{active:C,nodes:S,translate:T},droppable:{containers:A}}=x,E=C!=null?S.get(C):null,N=l.useRef({initial:null,translated:null}),B=l.useMemo(()=>{var xe;return C!=null?{id:C,data:(xe=E==null?void 0:E.data)!=null?xe:uN,rect:N}:null},[C,E]),q=l.useRef(null),[H,R]=l.useState(null),[F,P]=l.useState(null),$=mn(b,Object.values(b)),M=Nn("DndDescribedBy",i),G=l.useMemo(()=>A.getEnabled(),[A]),Y=xN(f),{droppableRects:Q,measureDroppableContainers:oe,measuringScheduled:ne}=QS(G,{dragging:k,dependencies:[T.x,T.y],config:Y.droppable}),V=JS(S,C),be=l.useMemo(()=>F?eo(F):null,[F]),le=ds(),ce=ZS(V,Y.draggable.measure);yN({activeNode:C!=null?S.get(C):null,config:le.layoutShiftCompensation,initialRect:ce,measure:Y.draggable.measure});const Z=Xl(V,Y.draggable.measure,ce),z=Xl(V?V.parentElement:null),D=l.useRef({activatorEvent:null,active:null,activeNode:V,collisionRect:null,collisions:null,droppableRects:Q,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),L=A.getNodeFor((n=D.current.over)==null?void 0:n.id),te=cN({measure:Y.dragOverlay.measure}),W=(r=te.nodeRef.current)!=null?r:V,K=k?(a=te.rect)!=null?a:Z:null,se=!!(te.nodeRef.current&&te.rect),ie=sN(se?null:Z),me=of(W?at(W):null),ye=nN(k?L??V:null),U=iN(ye),Te=bN(m,{transform:{x:T.x-ie.x,y:T.y-ie.y,scaleX:1,scaleY:1},activatorEvent:F,active:B,activeNodeRect:Z,containerNodeRect:z,draggingNodeRect:K,over:D.current.over,overlayNodeRect:te.rect,scrollableAncestors:ye,scrollableAncestorRects:U,windowRect:me}),de=be?Fs(be,T):null,ve=rN(ye),ke=Zl(ve),we=Zl(ve,[Z]),Ae=Fs(Te,ke),Ze=K?NS(K,Te):null,We=B&&Ze?p({active:B,collisionRect:Ze,droppableRects:Q,droppableContainers:G,pointerCoordinates:de}):null,ut=Jm(We,"id"),[Re,_t]=l.useState(null),ot=se?Te:Fs(Te,we),Wt=kS(ot,(o=Re==null?void 0:Re.rect)!=null?o:null,Z),Et=l.useRef(null),ht=l.useCallback((xe,Se)=>{let{sensor:_e,options:Ne}=Se;if(q.current==null)return;const Ee=S.get(q.current);if(!Ee)return;const I=xe.nativeEvent,Ye=new _e({active:q.current,activeNode:Ee,event:I,options:Ne,context:D,onAbort(Ce){if(!S.get(Ce))return;const{onDragAbort:Be}=$.current,Le={id:Ce};Be==null||Be(Le),v({type:"onDragAbort",event:Le})},onPending(Ce,Ve,Be,Le){if(!S.get(Ce))return;const{onDragPending:Ke}=$.current,je={id:Ce,constraint:Ve,initialCoordinates:Be,offset:Le};Ke==null||Ke(je),v({type:"onDragPending",event:je})},onStart(Ce){const Ve=q.current;if(Ve==null)return;const Be=S.get(Ve);if(!Be)return;const{onDragStart:Le}=$.current,bt={activatorEvent:I,active:{id:Ve,data:Be.data,rect:N}};ys.unstable_batchedUpdates(()=>{Le==null||Le(bt),_(Jt.Initializing),y({type:De.DragStart,initialCoordinates:Ce,active:Ve}),v({type:"onDragStart",event:bt}),R(Et.current),P(I)})},onMove(Ce){y({type:De.DragMove,coordinates:Ce})},onEnd:pt(De.DragEnd),onCancel:pt(De.DragCancel)});Et.current=Ye;function pt(Ce){return async function(){const{active:Be,collisions:Le,over:bt,scrollAdjustedTranslate:Ke}=D.current;let je=null;if(Be&&Ke){const{cancelDrop:mt}=$.current;je={activatorEvent:I,active:Be,collisions:Le,delta:Ke,over:bt},Ce===De.DragEnd&&typeof mt=="function"&&await Promise.resolve(mt(je))&&(Ce=De.DragCancel)}q.current=null,ys.unstable_batchedUpdates(()=>{y({type:Ce}),_(Jt.Uninitialized),_t(null),R(null),P(null),Et.current=null;const mt=Ce===De.DragEnd?"onDragEnd":"onDragCancel";if(je){const qe=$.current[mt];qe==null||qe(je),v({type:mt,event:je})}})}}},[S]),it=l.useCallback((xe,Se)=>(_e,Ne)=>{const Ee=_e.nativeEvent,I=S.get(Ne);if(q.current!==null||!I||Ee.dndKit||Ee.defaultPrevented)return;const Ye={active:I};xe(_e,Se.options,Ye)===!0&&(Ee.dndKit={capturedBy:Se.sensor},q.current=Ne,ht(_e,Se))},[S,ht]),kt=XS(h,it);aN(h),Tt(()=>{Z&&w===Jt.Initializing&&_(Jt.Initialized)},[Z,w]),l.useEffect(()=>{const{onDragMove:xe}=$.current,{active:Se,activatorEvent:_e,collisions:Ne,over:Ee}=D.current;if(!Se||!_e)return;const I={active:Se,activatorEvent:_e,collisions:Ne,delta:{x:Ae.x,y:Ae.y},over:Ee};ys.unstable_batchedUpdates(()=>{xe==null||xe(I),v({type:"onDragMove",event:I})})},[Ae.x,Ae.y]),l.useEffect(()=>{const{active:xe,activatorEvent:Se,collisions:_e,droppableContainers:Ne,scrollAdjustedTranslate:Ee}=D.current;if(!xe||q.current==null||!Se||!Ee)return;const{onDragOver:I}=$.current,Ye=Ne.get(ut),pt=Ye&&Ye.rect.current?{id:Ye.id,rect:Ye.rect.current,data:Ye.data,disabled:Ye.disabled}:null,Ce={active:xe,activatorEvent:Se,collisions:_e,delta:{x:Ee.x,y:Ee.y},over:pt};ys.unstable_batchedUpdates(()=>{_t(pt),I==null||I(Ce),v({type:"onDragOver",event:Ce})})},[ut]),Tt(()=>{D.current={activatorEvent:F,active:B,activeNode:V,collisionRect:Ze,collisions:We,droppableRects:Q,draggableNodes:S,draggingNode:W,draggingNodeRect:K,droppableContainers:A,over:Re,scrollableAncestors:ye,scrollAdjustedTranslate:Ae},N.current={initial:K,translated:Ze}},[B,V,We,Ze,S,W,K,Q,A,Re,ye,Ae]),YS({...le,delta:T,draggingRect:Ze,pointerCoordinates:de,scrollableAncestors:ye,scrollableAncestorRects:U});const ls=l.useMemo(()=>({active:B,activeNode:V,activeNodeRect:Z,activatorEvent:F,collisions:We,containerNodeRect:z,dragOverlay:te,draggableNodes:S,droppableContainers:A,droppableRects:Q,over:Re,measureDroppableContainers:oe,scrollableAncestors:ye,scrollableAncestorRects:U,measuringConfiguration:Y,measuringScheduled:ne,windowRect:me}),[B,V,Z,F,We,z,te,S,A,Q,Re,oe,ye,U,Y,ne,me]),cs=l.useMemo(()=>({activatorEvent:F,activators:kt,active:B,activeNodeRect:Z,ariaDescribedById:{draggable:M},dispatch:y,draggableNodes:S,over:Re,measureDroppableContainers:oe}),[F,kt,B,Z,y,M,S,Re,oe]);return st.createElement(Ym.Provider,{value:j},st.createElement(Ur.Provider,{value:cs},st.createElement(lf.Provider,{value:ls},st.createElement(cf.Provider,{value:Wt},u)),st.createElement(gN,{disabled:(c==null?void 0:c.restoreFocus)===!1})),st.createElement(bS,{...c,hiddenTextDescribedById:M}));function ds(){const xe=(H==null?void 0:H.autoScrollEnabled)===!1,Se=typeof d=="object"?d.enabled===!1:d===!1,_e=k&&!xe&&!Se;return typeof d=="object"?{...d,enabled:_e}:{enabled:_e}}}),jN=l.createContext(null),tc="button",wN="Draggable";function _N(t){let{id:s,data:n,disabled:r=!1,attributes:a}=t;const o=Nn(wN),{activators:i,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:h,draggableNodes:p,over:f}=l.useContext(Ur),{role:m=tc,roleDescription:b="draggable",tabIndex:g=0}=a??{},x=(d==null?void 0:d.id)===s,y=l.useContext(x?cf:jN),[v,j]=mr(),[w,_]=mr(),k=oN(i,s),C=mn(n);Tt(()=>(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 S=l.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":r,"aria-pressed":x&&m===tc?!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:S,isDragging:x,listeners:r?void 0:k,node:v,over:f,setNodeRef:j,setActivatorNodeRef:_,transform:y}}function kN(){return l.useContext(lf)}const SN="Droppable",NN={timeout:25};function CN(t){let{data:s,disabled:n=!1,id:r,resizeObserverConfig:a}=t;const o=Nn(SN),{active:i,dispatch:c,over:d,measureDroppableContainers:u}=l.useContext(Ur),h=l.useRef({disabled:n}),p=l.useRef(!1),f=l.useRef(null),m=l.useRef(null),{disabled:b,updateMeasurementsFor:g,timeout:x}={...NN,...a},y=mn(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=Gr({callback:v,disabled:b||!i}),w=l.useCallback((S,T)=>{j&&(T&&(j.unobserve(T),p.current=!1),S&&j.observe(S))},[j]),[_,k]=mr(w),C=mn(s);return l.useEffect(()=>{!j||!_.current||(j.disconnect(),p.current=!1,j.observe(_.current))},[_,j]),l.useEffect(()=>(c({type:De.RegisterDroppable,element:{id:r,key:o,disabled:n,node:_,rect:f,data:C}}),()=>c({type:De.UnregisterDroppable,key:o,id:r})),[r]),l.useEffect(()=>{n!==h.current.disabled&&(c({type:De.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:k}}function xn(t,s,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(s,1)[0]),r}function PN(t,s){return t.reduce((n,r,a)=>{const o=s.get(r);return o&&(n[a]=o),n},Array(t.length))}function Wn(t){return t!==null&&t>=0}function TN(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 AN(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const df=t=>{let{rects:s,activeIndex:n,overIndex:r,index:a}=t;const o=xn(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}},Gn={scaleX:1,scaleY:1},ON=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,...Gn}:null}const d=RN(o,a,n);return a>n&&a<=i?{x:0,y:-c.height-d,...Gn}:a<n&&a>=i?{x:0,y:c.height+d,...Gn}:{x:0,y:0,...Gn}};function RN(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 uf="Sortable",hf=st.createContext({activeIndex:-1,containerId:uf,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:df,disabled:{draggable:!1,droppable:!1}});function EN(t){let{children:s,id:n,items:r,strategy:a=df,disabled:o=!1}=t;const{active:i,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:h}=kN(),p=Nn(uf,n),f=c.rect!==null,m=l.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),b=i!=null,g=i?m.indexOf(i.id):-1,x=u?m.indexOf(u.id):-1,y=l.useRef(m),v=!TN(m,y.current),j=x!==-1&&g===-1||v,w=AN(o);Tt(()=>{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:PN(m,d),strategy:a}),[g,p,w.draggable,w.droppable,j,m,x,d,f,a]);return st.createElement(hf.Provider,{value:_},s)}const MN=t=>{let{id:s,items:n,activeIndex:r,overIndex:a}=t;return xn(n,r,a).indexOf(s)},IN=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},DN={duration:200,easing:"ease"},pf="transform",LN=gn.Transition.toString({property:pf,duration:0,easing:"linear"}),FN={roleDescription:"sortable"};function zN(t){let{disabled:s,index:n,node:r,rect:a}=t;const[o,i]=l.useState(null),c=l.useRef(n);return Tt(()=>{if(!s&&n!==c.current&&r.current){const d=a.current;if(d){const u=Vs(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 $N(t){let{animateLayoutChanges:s=IN,attributes:n,disabled:r,data:a,getNewIndex:o=MN,id:i,strategy:c,resizeObserverConfig:d,transition:u=DN}=t;const{items:h,containerId:p,activeIndex:f,disabled:m,disableTransforms:b,sortedRects:g,overIndex:x,useDragOverlay:y,strategy:v}=l.useContext(hf),j=BN(r,m),w=h.indexOf(i),_=l.useMemo(()=>({sortable:{containerId:p,index:w,items:h},...a}),[p,a,w,h]),k=l.useMemo(()=>h.slice(h.indexOf(i)),[h,i]),{rect:C,node:S,isOver:T,setNodeRef:A}=CN({id:i,data:_,disabled:j.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...d}}),{active:E,activatorEvent:N,activeNodeRect:B,attributes:q,setNodeRef:H,listeners:R,isDragging:F,over:P,setActivatorNodeRef:$,transform:M}=_N({id:i,data:_,attributes:{...FN,...n},disabled:j.draggable}),G=rS(A,H),Y=!!E,Q=Y&&!b&&Wn(f)&&Wn(x),oe=!y&&F,ne=oe&&Q?M:null,be=Q?ne??(c??v)({rects:g,activeNodeRect:B,activeIndex:f,overIndex:x,index:w}):null,le=Wn(f)&&Wn(x)?o({id:i,items:h,activeIndex:f,overIndex:x}):w,ce=E==null?void 0:E.id,Z=l.useRef({activeId:ce,items:h,newIndex:le,containerId:p}),z=h!==Z.current.items,D=s({active:E,containerId:p,isDragging:F,isSorting:Y,id:i,index:w,items:h,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:u,wasDragging:Z.current.activeId!=null}),L=zN({disabled:!D,index:w,node:S,rect:C});return l.useEffect(()=>{Y&&Z.current.newIndex!==le&&(Z.current.newIndex=le),p!==Z.current.containerId&&(Z.current.containerId=p),h!==Z.current.items&&(Z.current.items=h)},[Y,le,p,h]),l.useEffect(()=>{if(ce===Z.current.activeId)return;if(ce!=null&&Z.current.activeId==null){Z.current.activeId=ce;return}const W=setTimeout(()=>{Z.current.activeId=ce},50);return()=>clearTimeout(W)},[ce]),{active:E,activeIndex:f,attributes:q,data:_,rect:C,index:w,newIndex:le,items:h,isOver:T,isSorting:Y,isDragging:F,listeners:R,node:S,overIndex:x,over:P,setNodeRef:G,setActivatorNodeRef:$,setDroppableNodeRef:A,setDraggableNodeRef:H,transform:L??be,transition:te()};function te(){if(L||z&&Z.current.newIndex===w)return LN;if(!(oe&&!vi(N)||!u)&&(Y||D))return gn.Transition.toString({...u,property:pf})}}function BN(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 br(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 qN=[ge.Down,ge.Right,ge.Up,ge.Left],HN=(t,s)=>{let{context:{active:n,collisionRect:r,droppableRects:a,droppableContainers:o,over:i,scrollableAncestors:c}}=s;if(qN.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 ge.Down:r.top<f.top&&d.push(p);break;case ge.Up:r.top>f.top&&d.push(p);break;case ge.Left:r.left>f.left&&d.push(p);break;case ge.Right:r.left<f.left&&d.push(p);break}});const u=jS({collisionRect:r,droppableRects:a,droppableContainers:d});let h=Jm(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=Wr(b).some((k,C)=>c[C]!==k),y=mf(p,f),v=WN(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:fn(w,j)}}}};function mf(t,s){return!br(t)||!br(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function WN(t,s){return!br(t)||!br(s)||!mf(t,s)?!1:t.data.current.sortable.index<s.data.current.sortable.index}function as(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 Si({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 PE=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedHeader:Si},Symbol.toStringTag,{value:"Module"}));function Ks(){const[t,s]=l.useState(()=>Date.now());return l.useEffect(()=>{const n=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(n)},[]),t}function ff(t){return{dead:t.sessionAlive===!1}}function gf({claim:t,staleFetch:s=!1}){const n=Ks(),{dead:r}=ff(t),a=t.claimedBy.agentProvider??"agent",o=r?" (inactive)":"",i=as(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 TE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowClaimBadge:gf},Symbol.toStringTag,{value:"Module"}));function GN(){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 bf({slug:t,onClose:s}){return e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:e.jsx(_s,{chatName:`edit-plan-${t}`,slashCommand:`/codeyam-edit-plan ${t}`,height:360,onClose:s})})}const AE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedChat:bf},Symbol.toStringTag,{value:"Module"}));function xf({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(`
25
+ `).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(He,{text:r,className:"text-xs text-[var(--accent-red)]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:c,disabled: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 OE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedEdit:xf},Symbol.toStringTag,{value:"Module"}));function yf({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 RE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditButton:yf},Symbol.toStringTag,{value:"Module"}));function vf({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 EE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditChatButton:vf},Symbol.toStringTag,{value:"Module"}));function jf({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 ME=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDependencyEntry:jf},Symbol.toStringTag,{value:"Module"}));function Ni({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(jf,{dep:s},s.slug))})]})}const IE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedDependencies:Ni},Symbol.toStringTag,{value:"Module"}));function wf({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(Si,{title:t,filePath:s}),i&&i.length>0&&e.jsx(Ni,{dependencies:i}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx(Ht,{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(yf,{onClick:a}),e.jsx(vf,{providerLabel:r,onClick:o})]})]})}const DE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedView:wf},Symbol.toStringTag,{value:"Module"}));function _f({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}=GN(),{config:p}=gt(),f=rt(p==null?void 0:p.provider);return l.useEffect(()=>{o(t.title),c(t.body),r("view")},[t.slug]),n==="chat"?e.jsx(bf,{slug:t.slug,onClose:()=>r("view")}):n==="edit"?e.jsx(xf,{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(wf,{title:t.title,filePath:t.filePath,body:t.body,providerLabel:f,onEdit:()=>r("edit"),onChat:()=>r("chat"),dependencies:s})}const LE=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedBody:_f},Symbol.toStringTag,{value:"Module"})),kf="Building is in progress, please wait for it to complete before starting a new build session.";function Sf({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?kf:void 0,className:o+(d?i:""),children:n?"Launching…":"Run"})}const FE=Object.freeze(Object.defineProperty({__proto__:null,PlanRunButton:Sf},Symbol.toStringTag,{value:"Module"}));function Ci({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(Sf,{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(gf,{claim:x,staleFetch:y}),e.jsx("span",{className:"text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:as(t.createdAt)})]}),s&&(v==="view"?e.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[e.jsx(Si,{title:t.title,filePath:t.filePath}),g&&g.length>0&&e.jsx(Ni,{dependencies:g}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx(Ht,{variant:"compact",children:t.body})})]}):e.jsx(_f,{plan:t,dependencies:g}))]})}const zE=Object.freeze(Object.defineProperty({__proto__:null,PlanRow:Ci},Symbol.toStringTag,{value:"Module"}));function Nf({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}=$N({id:t.slug,disabled:!c}),w={transform:gn.Transform.toString(y),transition:v};return e.jsx(Ci,{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 $E=Object.freeze(Object.defineProperty({__proto__:null,SortablePlanRow:Nf},Symbol.toStringTag,{value:"Module"}));function Yr({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.jsx(He,{text:`Failed to launch plan: ${o}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-2"}),x&&e.jsx(He,{text:`Failed to reorder plans: ${x}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-2"}),e.jsx(Cf,{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 Cf({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=xS(Hl(ki,{activationConstraint:{distance:4}}),Hl(wi,{coordinateGetter:HN})),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.jsx(He,{text:`Failed to load plans: ${n}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"});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(k=>k.slug===v.id),_=t.findIndex(k=>k.slug===j.id);w===-1||_===-1||d(xn(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(Nf,{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(vN,{sensors:m,collisionDetection:vS,onDragEnd:g,children:e.jsx(EN,{items:b,strategy:ON,children:x})}):x}const BE=Object.freeze(Object.defineProperty({__proto__:null,QueuedChangesBody:Cf,QueuedChangesSection:Yr},Symbol.toStringTag,{value:"Module"}));function Pf({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:k,showTerminal:C,shouldResumeSameProvider:S}=Lk({sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i});return r==="pending"?e.jsx(Tm,{featureName:w,editorStep:_,workflowMode:k,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(ts,{children:e.jsx(Yr,{plans:f,loading:m,error:b,onRun:T=>{var E;const A=((E=f.find(N=>N.slug===T))==null?void 0:E.title)??T;g(T,A)},launchingSlug:x,launchError:y,blocked:j,onReorder:v})}):C?e.jsx(Wm,{provider:c,shouldResumeSameProvider:S,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 qE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabSessionContent:Pf},Symbol.toStringTag,{value:"Module"}));function UN(t){return t?{step:t.step??0,feature:t.feature??null,startedAt:t.startedAt??"",mode:Rt(t.mode),slug:t.slug??null}:null}const YN=3e3;function Cn(){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=UN(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,YN),()=>{a.current&&clearInterval(a.current)}),[i]),{stepState:t,loading:n,refetch:i}}const tt={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 VN(t){return{hasSession:(t==null?void 0:t.hasSession)??tt.hasSession,resumeMode:(t==null?void 0:t.resumeMode)??tt.resumeMode,provider:(t==null?void 0:t.provider)??tt.provider,feature:(t==null?void 0:t.feature)??tt.feature,step:(t==null?void 0:t.step)??tt.step,mode:(t==null?void 0:t.mode)==null?tt.mode:Rt(t.mode),label:(t==null?void 0:t.label)??tt.label,sessionId:(t==null?void 0:t.sessionId)??tt.sessionId,awaitingUserInput:(t==null?void 0:t.awaitingUserInput)??tt.awaitingUserInput,reopenResults:(t==null?void 0:t.reopenResults)??tt.reopenResults,preview:(t==null?void 0:t.preview)??tt.preview,agentBrokerLive:(t==null?void 0:t.agentBrokerLive)??tt.agentBrokerLive,resultsShown:(t==null?void 0:t.resultsShown)??tt.resultsShown}}function Pi(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(VN(d))}catch{r(c=>c??tt)}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 KN=5e3;function JN(){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,KN),()=>{a.current&&clearInterval(a.current)}},[]),{prompt:t,loading:n}}function XN({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 ar=null;const QN=1e4;function ZN(){ar=Date.now()}function e2(){if(ar==null)return!1;const t=Date.now()-ar;return ar=null,t<=QN}const Ti="codeyam.buildTab.attachedSessionId";function t2(t){try{window.sessionStorage.setItem(Ti,t)}catch{}}function s2(){try{return window.sessionStorage.getItem(Ti)}catch{return null}}function n2(){try{window.sessionStorage.removeItem(Ti)}catch{}}function r2({sessionLoading:t,sessionInfo:s}){const n=l.useRef(void 0);n.current===void 0&&(n.current=s2());const[r,a]=l.useState(()=>e2()?"fresh":"no-session");l.useEffect(()=>{a(i=>XN({currentDecision:i,sessionInfo:s,sessionLoading:t,attachedSessionId:n.current??null}))},[t,s]),l.useEffect(()=>{if(s){if(!s.hasSession){n2(),n.current=null;return}s.sessionId&&(r==="continue"||r==="fresh")&&(t2(s.sessionId),n.current=s.sessionId)}},[r,s]);const o=l.useCallback(()=>{a("continue")},[]);return{sessionDecision:r,handleContinueSession:o}}function sc(){const t=document.activeElement;return t===null||t===document.body||t===document.documentElement||t instanceof HTMLElement&&t.dataset.navTab==="true"}function nc(t,s,n,r=0){return t>=n.left-r&&t<=n.right+r&&s>=n.top-r&&s<=n.bottom+r}function lt(){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 rc(t){ac(t,!0);let s=!1;const n=()=>{s||(s=!0,ac(t,!1))};typeof requestAnimationFrame=="function"?(requestAnimationFrame(n),setTimeout(n,100)):queueMicrotask(n)}function ac(t,s){const n=t;if(typeof n.inert=="boolean"){n.inert=s;return}s?t.setAttribute("inert",""):t.removeAttribute("inert")}function _a(t){Oo(),rc(t),t.blur(),lt(),queueMicrotask(()=>{document.activeElement===t&&(rc(t),t.blur(),lt())})}function a2(t){const s=l.useRef(!1),n=l.useRef(null);l.useEffect(()=>{if(!t)return;function r(){if(!s.current&&sc()){s.current=!0;try{Oo(),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;_a(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(nc(f.clientX,f.clientY,m,1))return}_a(p),d(p)}function c(u){const h=document.activeElement;if(!(h instanceof HTMLIFrameElement))return;n.current=h;const p=h.getBoundingClientRect();nc(u.clientX,u.clientY,p,1)||(_a(h),d(h))}function d(u){requestAnimationFrame(()=>{document.activeElement!==u&&(sc()||(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 o2({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 i2(t){const s=l.useRef(t);l.useEffect(()=>{t&&t!==s.current&&(lr(t),s.current=t)},[t])}function l2(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 Tf({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 HE=Object.freeze(Object.defineProperty({__proto__:null,FeatureNameButton:Tf},Symbol.toStringTag,{value:"Module"}));function Af({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(Ht,{variant:"compact",children:t})})}const WE=Object.freeze(Object.defineProperty({__proto__:null,PromptDropdownPanel:Af},Symbol.toStringTag,{value:"Module"}));function Of({currentStep:t,isExpanded:s,mode:n,onToggle:r=()=>{},stepNum:a}){const o=a===t,i=a<t,{description:c,label:d}=tm(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 GE=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorDropdownItem:Of},Symbol.toStringTag,{value:"Module"}));function Rf({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 S=()=>{var A;const T=(A=b.current)==null?void 0:A.getBoundingClientRect();T&&f({top:T.bottom+4,right:window.innerWidth-T.right})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[o]),l.useEffect(()=>{if(!o)return;const S=T=>{var E,N;const A=T.target;(E=m.current)!=null&&E.contains(A)||(N=g.current)!=null&&N.contains(A)||i(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[o]),l2(x,u,l.useCallback(()=>h(!1),[]));const y=s&&t>0,v=s||"New Working Session",j=Rt(n),w=tm(t,j),_=y?w.label:null,k=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(Tf,{displayName:v,hasPrompt:!!a,expanded:u,onToggle:()=>h(S=>!S)})]}),y&&e.jsxs("div",{className:"relative",ref:m,children:[e.jsxs("button",{ref:b,onClick:()=>i(S=>!S),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:[" / ",k]}),": ",_]}),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&&ys.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:k},(S,T)=>T+1).map(S=>{const T=c===S;return e.jsx(Of,{currentStep:t,isExpanded:T,mode:j,onToggle:()=>d(T?null:S),stepNum:S},S)})}),document.body)]})]}),u&&a&&e.jsx(Af,{prompt:a})]})}const UE=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorBar:Rf},Symbol.toStringTag,{value:"Module"}));function Ef({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}=Cn(),{config:y,loading:v}=gt(),{prompt:j}=JN(),{sessionInfo:w,loading:_}=Pi(),{sessionDecision:k,handleContinueSession:C}=r2({sessionLoading:_,sessionInfo:w});return a2(n),o2({sessionLoading:_,sessionInfo:w,onRestorePreview:c}),i2((x==null?void 0:x.feature)??null),e.jsx(wm,{stepIndicator:e.jsx(Rf,{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(Pf,{awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,configLoading:v,sessionLoading:_,sessionDecision:k,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 YE=Object.freeze(Object.defineProperty({__proto__:null,BuildTab:Ef},Symbol.toStringTag,{value:"Module"}));function Mf({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 VE=Object.freeze(Object.defineProperty({__proto__:null,SessionResultsPanelHeader:Mf},Symbol.toStringTag,{value:"Module"}));function nn(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]}:nn(t,{defaultSelection:!0,selectedIndex:s.selectedIndex})}const n=Math.min(s.selectedIndex??0,t.length-1);return{selectedIndex:n,scenario:t[n]}}function xr(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 Ai(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&typeof t.name=="string"?t.name:String(t)}function c2(t){if(t!=null&&typeof t=="object"){const{description:s}=t;if(typeof s=="string"&&s.trim()!=="")return s}}function Oi({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 KE=Object.freeze(Object.defineProperty({__proto__:null,FunctionChangeRow:Oi},Symbol.toStringTag,{value:"Module"})),d2="no-isolation-harness";function If(t){var s;return t.coverageStatus==="reason"&&((s=t.untestabilityReason)==null?void 0:s.kind)===d2}const u2="/api/editor-session-summary",h2=3e3;function Df(t=h2){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(u2);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 Lf({onClose:t,onSelectScenario:s,previewSlug:n=null,minimizeMode:r=!1}){var w;const{summary:a,loading:o,refreshing:i,refresh:c}=Df(),[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(k=>k.slug===p);_>=0&&_!==d&&u(_)},[h,p,d]);const m=l.useCallback(_=>{h.length!==0&&(document.activeElement instanceof HTMLIFrameElement||Vk()||(_.key==="ArrowRight"?(_.preventDefault(),u(k=>{const C=nn(h,{direction:"next",selectedIndex:k});return C.scenario&&(s==null||s(C.scenario.slug,C.scenario.url)),C.selectedIndex})):_.key==="ArrowLeft"&&(_.preventDefault(),u(k=>{const C=nn(h,{direction:"previous",selectedIndex:k});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 _=nn(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=xr(a.application,x),v=xr(a.components,x),j=(_,k)=>{var S,T;const C=nn(h,{slug:_,selectedIndex:d});C.selectedIndex>=0&&u(C.selectedIndex),s==null||s(((S=C.scenario)==null?void 0:S.slug)??_,((T=C.scenario)==null?void 0:T.url)??k)};return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-[var(--bg-deep)]",style:{borderTop:"2px solid #005c75"},children:[e.jsx(Mf,{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(Ff,{text:a.userPrompt}),e.jsxs(rn,{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($f,{scenarios:y.headline,selectedSlug:f,onSelect:j}),e.jsx(ro,{scenarios:y.collapsed,selectedSlug:f,onSelect:j})]}),e.jsxs(rn,{title:"Components",icon:"🧩",count:v.headline.length,impactedCount:v.collapsed.length,children:[v.headline.length>0&&e.jsx(zf,{scenarios:v.headline,selectedSlug:f,onSelect:j}),e.jsx(ro,{scenarios:v.collapsed,selectedSlug:f,onSelect:j})]}),e.jsx(rn,{title:"Functions",icon:"⚙️",count:a.functions.length,children:a.functions.length>0&&e.jsx(qf,{functions:a.functions})}),e.jsx(rn,{title:"Modified Files",icon:"📄",count:a.modifiedFiles.length,children:a.modifiedFiles.length>0&&e.jsx(Hf,{files:a.modifiedFiles})})]})]})}function Ff({text:t}){const[s,n]=l.useState(!1),r=t.split(`
26
+ `)[0],a=t.includes(`
27
+ `)||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(Ht,{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 rn({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 yn({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(Bf,{scenario:r,isSelected:r.slug===s,onSelect:n},r.slug))})})}function ro({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(yn,{scenarios:t,selectedSlug:s,onSelect:n})})]})}function zf({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(If);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(yn,{scenarios:r[i],selectedSlug:s,onSelect:n})]},i))]})}function $f({scenarios:t,selectedSlug:s,onSelect:n}){if(!t.some(i=>i.routeName))return e.jsx(yn,{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(yn,{scenarios:a[i],selectedSlug:s,onSelect:n})]},i))})}function Bf({scenario:t,isSelected:s,onSelect:n}){var o;const r=t.name.replace(/\s*\[.*\]\s*$/,"").trim(),a=If(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(At,{screenshotPath:t.screenshotPaths[0],cacheBuster:t.screenshotCapturedAtMs??void 0,alt:t.name}):t.coverageStatus==="needs-isolated-scenario"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:"Backed only by a unit test — capture an isolated scenario so this component is viewable in the editor.",children:[e.jsx("span",{className:"text-amber-500 text-lg leading-none",children:"⚠"}),e.jsx("span",{className:"text-[8px] leading-tight text-amber-700",children:"needs isolated scenario"})]}):t.coverageStatus==="reason"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:t.untestabilityReason?`${t.untestabilityReason.kind}: ${t.untestabilityReason.justification}`:"Covered by a recorded untestability reason.",children:[e.jsx("span",{className:"text-[var(--text-muted)] text-lg leading-none",children:"🧪"}),e.jsx("span",{className:"text-[8px] leading-tight text-[var(--text-muted)]",children:((o=t.untestabilityReason)==null?void 0:o.kind)??"test-backed"})]}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-[var(--text-muted)] text-lg",children:"📷"})}),e.jsx("div",{className:`mt-1 text-[10px] truncate w-24 ${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 qf({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(Oi,{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:Ai(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 Hf({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(Tr,{status:s.status}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono truncate",children:s.path})]},s.path))})}const JE=Object.freeze(Object.defineProperty({__proto__:null,ApplicationGroups:$f,CollapsedImpactedScenarios:ro,ComponentGroups:zf,FilesList:Hf,FunctionsList:qf,ScenarioThumbnail:Bf,ScenarioThumbnailStrip:yn,Section:rn,SessionResultsPanel:Lf,UserPrompt:Ff},Symbol.toStringTag,{value:"Module"}));function Wf({onExpand:t}){const{summary:s}=Df(),n=(s==null?void 0:s.hubDominated)??!1,r=xr((s==null?void 0:s.application)??[],n),a=xr((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 XE=Object.freeze(Object.defineProperty({__proto__:null,MinimizedSessionResults:Wf},Symbol.toStringTag,{value:"Module"}));function p2(t,s){return(t==null?void 0:t.mode)!=="ui"?!1:(t==null?void 0:t.slug)==="feature-complete"||!!s}const m2=new Set(["ui-present","backend-present"]);function Gf(t){return!!(t!=null&&t.slug)&&m2.has(t.slug)}function f2({stepState:t,resultsShown:s,featureCompleteActive:n,userExpanded:r}){return n?"hidden":Gf(t)?(t==null?void 0:t.mode)==="ui"?"full":"hidden":p2(t,s)?r?"full":"minimized":"hidden"}function Uf({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:k,featureCompleteActive:C}){const{stepState:S}=Cn(),{sessionInfo:T}=Pi({pollIntervalMs:15e3}),[A,E]=l.useState(!1),[N,B]=l.useState(!1),[q,H]=l.useState(0),R=(T==null?void 0:T.resultsShown)??!1;l.useEffect(()=>{R||(B(!1),E(!1))},[R]),l.useEffect(()=>{i&&(B(!1),E(!0),H(Y=>Y+1))},[i]),l.useEffect(()=>{c&&E(!1)},[c]);const F=Gf(S),P=f2({stepState:S,resultsShown:R,featureCompleteActive:C,userExpanded:A}),$=F&&N?"hidden":P,M=l.useCallback(()=>{F?B(!0):E(!1)},[F]),G=l.useCallback(()=>{E(!0),H(Y=>Y+1)},[]);return n?e.jsx(_m,{activeTab:r,resultsMode:$,buildTab:e.jsx(Ef,{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:k}),resultsPanel:e.jsx(Lf,{onClose:M,onSelectScenario:a,previewSlug:o,minimizeMode:!F},q),minimizedResults:e.jsx(Wf,{onExpand:G}),footer:e.jsx(qp,{settings:p,onChange:f,agentName:m,providerLabel:rt(m)})}):null}const QE=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPane:Uf},Symbol.toStringTag,{value:"Module"})),g2=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"})]}),b2=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 yr({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:[g2,!s&&b2]})}const ZE=Object.freeze(Object.defineProperty({__proto__:null,CyLogo:yr},Symbol.toStringTag,{value:"Module"}));function Yf({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 eM=Object.freeze(Object.defineProperty({__proto__:null,DeviceIcon:Yf},Symbol.toStringTag,{value:"Module"})),oc=["·","✢","✳","✶","✻","✽"],x2=160;function vr({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)%oc.length),x2);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:oc[n]})}const tM=Object.freeze(Object.defineProperty({__proto__:null,BuildSpinner:vr},Symbol.toStringTag,{value:"Module"}));function Vf({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 sM=Object.freeze(Object.defineProperty({__proto__:null,EnvelopeIcon:Vf},Symbol.toStringTag,{value:"Module"}));function Kf({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 nM=Object.freeze(Object.defineProperty({__proto__:null,GearIcon:Kf},Symbol.toStringTag,{value:"Module"}));function Jf({onNavigateToBuild:t,onDismiss:s,providerLabel:n}){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:[n," is waiting for you."," ",e.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]}),e.jsx("button",{type:"button",onClick:r=>{r.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 rM=Object.freeze(Object.defineProperty({__proto__:null,IdleBanner:Jf},Symbol.toStringTag,{value:"Module"})),y2=[{key:"home",label:"Home"},{key:"plan",label:"Plan"},{key:"build",label:"Build"},{key:"history",label:"History"}];function ka(){if(typeof document>"u")return;const t=document.activeElement;t instanceof HTMLElement&&t.blur()}function Xf({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,providerLabel:p}){const f=c&&t!=="build",m=r,b=a&&!r,g=b?"green":m?"orange":"none",x=l.useRef(g);l.useEffect(()=>{x.current!==g&&(X("build-tab-dot-change",{from:x.current,to:g}),x.current=g)},[g]);const y=o,v=i&&!o,j=v?"green":y?"orange":"none",w=l.useRef(j);return l.useEffect(()=>{w.current!==j&&(X("plan-tab-dot-change",{from:w.current,to:j}),w.current=j)},[j]),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(yr,{className:"h-5 text-white shrink-0 @max-[440px]:hidden"}),e.jsx(yr,{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:y2.map(_=>_.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"),ka()},className:"px-2.5 py-2.5 text-sm text-[#5A5A5A] cursor-not-allowed font-light whitespace-nowrap",children:_.label},_.key):e.jsxs(cr,{href:Ds(_.key),"data-nav-tab":"true",onNavigate:()=>{s(_.key),ka(),_.key==="build"&&lt()},className:`px-2.5 py-2.5 text-sm transition-colors cursor-pointer inline-flex items-center whitespace-nowrap ${t===_.key?"text-[#D7FF63] font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[_.key==="build"&&b&&e.jsx(vr,{}),_.key==="build"&&m&&e.jsx("span",{"data-testid":"nav-build-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),_.key==="plan"&&v&&e.jsx(vr,{testId:"nav-plan-dot-active",ariaLabel:"Planning in progress"}),_.key==="plan"&&y&&e.jsx("span",{"data-testid":"nav-plan-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),_.label]},_.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(Vf,{})}),e.jsx(cr,{href:Ds("settings"),"data-nav-tab":"true",onNavigate:()=>{s("settings"),ka()},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(Kf,{})})]}),f&&e.jsx(Jf,{onNavigateToBuild:()=>s("build"),onDismiss:d??(()=>{}),providerLabel:p})]})}const aM=Object.freeze(Object.defineProperty({__proto__:null,EditorNavBar:Xf},Symbol.toStringTag,{value:"Module"}));function Qf({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(yr,{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 oM=Object.freeze(Object.defineProperty({__proto__:null,DesktopTitleBar:Qf},Symbol.toStringTag,{value:"Module"}));function Vr({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(m0(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 iM=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialModal:Vr},Symbol.toStringTag,{value:"Module"}));function v2(t,s){for(const n of t.filesByDirectory)for(const r of n.files)if(r.filePath===s)return r;return null}function Zf(t){return t>=80?"#16a34a":t>=50?"#eab308":"#dc2626"}function Pn({coverage:t}){const s=Math.max(0,Math.min(100,t.percent)),n=Zf(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 lM=Object.freeze(Object.defineProperty({__proto__:null,CoverageBar:Pn},Symbol.toStringTag,{value:"Module"}));function eg({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(Pn,{coverage:t.coverage})]})}const cM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryFileRow:eg},Symbol.toStringTag,{value:"Module"}));function tg({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(eg,{file:n,onSelectFile:s},n.filePath))})]})}const dM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryGroup:tg},Symbol.toStringTag,{value:"Module"}));function sg({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(tg,{group:n,onSelectFile:s},n.directory||"(root)"))})]})}const uM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoriesSection:sg},Symbol.toStringTag,{value:"Module"}));function ng({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(Pn,{coverage:{percent:t.percent,hitLines:t.hitLines,totalLines:t.totalLines}})]})}const hM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntryRow:ng},Symbol.toStringTag,{value:"Module"}));function rg({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(ng,{entry:n,onSelectFile:s},`${n.filePath}::${n.name}`))})]})}const pM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntriesSection:rg},Symbol.toStringTag,{value:"Module"}));function ag({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(Pn,{coverage:t.coverage})]})}const mM=Object.freeze(Object.defineProperty({__proto__:null,OrphanedFileRow:ag},Symbol.toStringTag,{value:"Module"}));function og({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(ag,{file:n})},n.filePath))})]})}const fM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsOrphanedSection:og},Symbol.toStringTag,{value:"Module"}));function ig({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 gM=Object.freeze(Object.defineProperty({__proto__:null,CoverageLineRow:ig},Symbol.toStringTag,{value:"Module"}));function lg({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(Pn,{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(ig,{line:r,hits:a},r))})]})}const bM=Object.freeze(Object.defineProperty({__proto__:null,CoverageFileDrilldown:lg},Symbol.toStringTag,{value:"Module"}));function cg({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:Zf(s.percent)},"data-testid":n,children:[Math.round(s.percent),"% overall"]})]})]})}const xM=Object.freeze(Object.defineProperty({__proto__:null,CoverageSectionHeader:cg},Symbol.toStringTag,{value:"Module"}));function dg({warnings:t}){return t.length===0?null:e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"coverage-warnings-banner",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-amber-800 m-0",children:"Coverage Warnings"}),e.jsx(dt,{variant:"subtle",text:t.join(`
28
+ `),label:"Copy",className:"shrink-0 px-2 py-1 text-xs font-medium rounded border border-amber-300 text-amber-800 hover:bg-amber-100 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"})]}),e.jsx("ul",{className:"mt-1 space-y-1 text-sm text-amber-700 list-none p-0 m-0",children:t.map((s,n)=>e.jsx("li",{className:"break-words",children:s},n))})]})]})})}const yM=Object.freeze(Object.defineProperty({__proto__:null,CoverageWarningsBanner:dg},Symbol.toStringTag,{value:"Module"}));function ug({onClose:t,fetchDetails:s=j2,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=v2(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.jsx(He,{testId:"coverage-details-modal-error",text:`Failed to load coverage details: ${o}`,className:"text-sm text-red-700"}),!r&&!o&&e.jsx("p",{className:"text-sm text-[var(--text-muted)]","data-testid":"coverage-details-modal-loading",children:"Loading coverage details…"}),r&&c&&e.jsx(lg,{file:c,onBack:()=>d(null)}),r&&!c&&e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(cg,{title:"Overall",aggregate:r.projectWide,aggregateTestId:"coverage-details-modal-aggregate"}),r.coverageWarnings.length>0&&e.jsx(dg,{warnings:r.coverageWarnings}),e.jsx(rg,{entries:r.entries,onSelectFile:h}),e.jsx(og,{files:r.orphanedFiles,onSelectFile:h}),e.jsx(sg,{directories:r.filesByDirectory,onSelectFile:d})]})]})})}function j2(){return fetch("/api/coverage/details").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()})}const vM=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsModal:ug},Symbol.toStringTag,{value:"Module"}));function w2(t,s){const n=t.filter(r=>!an(r.route));if(n.length>0){if(n.length===1){const r=n[0],a=r.scenarios.filter(o=>!an(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=>!an(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 hg({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(Du,{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:os(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 jM=Object.freeze(Object.defineProperty({__proto__:null,ExploreRail:hg},Symbol.toStringTag,{value:"Module"})),or=5;function pg({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(or,u)),v=Array.from({length:or},(j,w)=>w<y);return e.jsxs("div",{className:"doorrows",children:[e.jsx(di,{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(Lu,{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(Or,{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 ",or," 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(Bt,{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 wM=Object.freeze(Object.defineProperty({__proto__:null,DoorRows:pg,LEARN_TOPIC_COUNT:or},Symbol.toStringTag,{value:"Module"}));function mg({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:k,launcherUrl:C,projectCount:S=0,showExploreRail:T=!0}){const A=l.useMemo(()=>w2(n,r),[n,r]),E=!!C||S>=2,[N,B]=l.useState(!1),q=async()=>{if(C){window.location.href=C;return}if(!N){B(!0);try{const F=await fetch("/api/launcher/ensure",{method:"POST"}),P=await F.json().catch(()=>({}));if(F.ok&&typeof P.url=="string"){window.location.href=P.url;return}B(!1)}catch{B(!1)}}},H=(t==null?void 0:t.trim())||s.name||"Your project",R=F=>{F.scenarioSlug?b(F.scenarioSlug):g()};return e.jsxs("div",{className:"home-landing",children:[k||E?e.jsxs("div",{className:"crumbs",children:[E?e.jsx("button",{type:"button",className:"back",disabled:N,onClick:()=>{q()},children:N?"Opening launcher…":"‹ All projects"}):null,k?e.jsx("button",{type:"button",className:"back",onClick:k,children:"‹ Projects"}):null]}):null,e.jsx("div",{className:"project",children:H}),e.jsx("div",{className:"seclabel",children:"Your project"}),e.jsx(pg,{admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:f,learnDoneCount:m,exploreSlot:T?e.jsx(hg,{items:A,showAll:!0,onSelect:R,onOpenAll:g}):null,onOpenBuilding:x,onStartNewFeature:y,onResetBuild:v,onOpenPlans:j,onOpenLearn:w,onExternalServices:_})]})}const _M=Object.freeze(Object.defineProperty({__proto__:null,HomeLanding:mg},Symbol.toStringTag,{value:"Module"})),_2={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"},ic=["Domain","Hosting","Database","Database ORM","Backend platform","Authentication","Payments","Transactional email","Product analytics","Error monitoring"];function k2(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 fg(t){return t.envVars.length>0&&!t.credentialPresent}function S2(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 N2(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 C2(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=fg(t);return{monogram:k2(t.name),providerId:t.key,category:t.category,tone:_2[t.category]??"lime",name:t.name,desc:S2(t),tags:s.length?s:void 0,actionLabel:r?"Add key":void 0,actionKey:r?t.key:void 0,attn:r,detail:N2(t)}}function lc(t){const s=ic.indexOf(t);return s===-1?ic.length:s}function P2(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])=>lc(c)-lc(d)||c.localeCompare(d)).map(([c,d])=>({label:c,items:d.slice().sort((u,h)=>u.name.localeCompare(h.name)).map(C2)})),a=s.filter(fg).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 T2(t){return t.credentialPresent?" (key configured)":t.envVars.length>0?" (needs a key)":""}function A2(t,s){const n=(t??[]).filter(o=>o.status!=="dismissed"),r=n.length?`
29
+
30
+ Detected in this project so far:
31
+ ${n.map(o=>`- ${o.name} (${o.category})${T2(o)}`).join(`
32
+ `)}`:`
33
+
34
+ No external services have been auto-detected in this project yet.`,a=s!=null&&s.trim()?`
35
+
36
+ The user opened this chat with the following message. Respond to it directly and helpfully as your FIRST reply, before anything else:
37
+ "${s.trim()}"`:`
38
+
39
+ 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,`
40
+
41
+ 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 gg({onBack:t}){const{services:s,refetch:n}=ti(),[r,a]=l.useState(!1),[o,i]=l.useState(void 0),[c,d]=l.useState(null),{groups:u,summary:h}=l.useMemo(()=>P2(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(sp,{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(_s,{chatName:"external-services",prompt:A2(s,o),height:380,onClose:()=>a(!1)})]}):null,c?e.jsx(Vr,{target:c,onStored:()=>{d(null),n()},onClose:()=>d(null)}):null]})}const kM=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesScreenConnected:gg},Symbol.toStringTag,{value:"Module"})),O2={provider:"vercel"},bg={"dev-accounts":wp,"store-assets":_p,"store-listing":kp,"testing-distribution":Sp,"push-notifications":Np,"crash-reporting":Cp,"in-app-purchases":Pp,"app-privacy":Tp,"app-review":Ap};function cc(t){return t in bg}function R2(){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 E2(){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 M2(){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 I2(t,s){if(s(),g0()){Oa(t);return}f0(jl).then(n=>{n?Oa(t):console.warn(`[setup-chat] Build terminal did not attach within ${jl}ms; prompt not sent`)})}const D2=new Set(["share-testing","store-accounts","store-assets","permissions-justification","oauth-verification","privacy-policy","single-purpose-listing","manifest-versioning","submit-review"]);function xg({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),k=()=>_(!0),C=()=>_(!1),[S,T]=l.useState("landing"),[A,E]=l.useState(null),[N,B]=l.useState(null),{topics:q,setStatus:H,addTopic:R}=R2(),F=(q==null?void 0:q.filter(L=>L.status==="done").length)??0,P=L=>{var te;return((te=q==null?void 0:q.find(W=>W.key===L))==null?void 0:te.status)??"available"},{services:$,dismiss:M,refetch:G}=ti(),[Y,Q]=l.useState(null),oe=l.useCallback(L=>{var W;const te=(W=L.envVars)==null?void 0:W[0];te&&Q({serviceName:L.name,envVar:te,topic:L.topic,docsUrl:L.docsUrl})},[]),{recipe:ne}=M2(),V=u1(Tu()),{groups:be}=E2(),le=(q==null?void 0:q.some(L=>L.key==="dev-accounts"))??!1,ce=(q==null?void 0:q.some(L=>L.key==="deploy-target"))??!1,Z=L=>{L==="run-locally"?T("run-locally"):le&&cc(L)?(B(L),T("mobile-setup")):D2.has(L)?T(L):cc(L)?(B(L),T("mobile-setup")):(E(L),T("topic"))},z=!!(t.selectedRouteEntity||t.selectedEntityHash);let D;if(!n)D=e.jsx(jm,{...s,onCoverageClick:k},"app-overview");else if(z||S==="detail"){const L=S==="detail"&&!z;D=e.jsxs(e.Fragment,{children:[L?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(Ru,{app:n,...t,onCoverageClick:k})]})}else if(S==="learn")D=e.jsx(Wa,{topics:q,detectedServices:$,onBack:()=>T("landing"),onOpenHosting:()=>T("hosting"),onOpenTopic:Z,onOpenLibraries:()=>T("libraries"),onDismissService:M,onAddCredential:oe,onCreateTopic:R,onOpenConcepts:()=>T("concepts")});else if(S==="libraries")D=e.jsx(Yu,{groups:be,onBack:()=>T("learn")});else if(S==="concepts")D=e.jsx(Xh,{onBack:()=>T("learn")});else if(S==="external-services")D=e.jsx(gg,{onBack:()=>T("landing")});else if(S==="hosting")D=e.jsx(dp,{connector:O2,onBack:()=>T("learn"),onComplete:()=>H("hosting","done"),onOpenSharedBrowser:j});else if(S==="run-locally")D=e.jsx(up,{recipe:ne,onBack:()=>T("learn"),status:P("run-locally"),onMarkDone:()=>H("run-locally","done"),onRevert:()=>H("run-locally","available")});else if(S==="share-testing")D=e.jsx(jp,{onBack:()=>T("learn"),status:P("share-testing"),onComplete:()=>H("share-testing","done"),onRevert:()=>H("share-testing","available")});else if(S==="store-accounts")D=e.jsx(hp,{onBack:()=>T("learn"),status:P("store-accounts"),onComplete:()=>H("store-accounts","done"),onRevert:()=>H("store-accounts","available")});else if(S==="store-assets")D=e.jsx(pp,{onBack:()=>T("learn"),status:P("store-assets"),onComplete:()=>H("store-assets","done"),onRevert:()=>H("store-assets","available")});else if(S==="permissions-justification")D=e.jsx(fp,{onBack:()=>T("learn"),status:P("permissions-justification"),onComplete:()=>H("permissions-justification","done"),onRevert:()=>H("permissions-justification","available")});else if(S==="oauth-verification")D=e.jsx(bp,{onBack:()=>T("learn"),status:P("oauth-verification"),onComplete:()=>H("oauth-verification","done"),onRevert:()=>H("oauth-verification","available")});else if(S==="privacy-policy")D=e.jsx(gp,{onBack:()=>T("learn"),status:P("privacy-policy"),onComplete:()=>H("privacy-policy","done"),onRevert:()=>H("privacy-policy","available")});else if(S==="single-purpose-listing")D=e.jsx(xp,{onBack:()=>T("learn"),status:P("single-purpose-listing"),onComplete:()=>H("single-purpose-listing","done"),onRevert:()=>H("single-purpose-listing","available")});else if(S==="manifest-versioning")D=e.jsx(yp,{onBack:()=>T("learn"),status:P("manifest-versioning"),onComplete:()=>H("manifest-versioning","done"),onRevert:()=>H("manifest-versioning","available")});else if(S==="submit-review")D=e.jsx(vp,{onBack:()=>T("learn"),status:P("submit-review"),onComplete:()=>H("submit-review","done"),onRevert:()=>H("submit-review","available")});else if(S==="topic"&&A){const L=(q==null?void 0:q.find(te=>te.key===A))??null;D=e.jsx(Jh,{topicKey:A,topicName:L==null?void 0:L.name,topicDesc:L==null?void 0:L.desc,isBackend:ce,onBack:()=>T("learn"),onComplete:te=>H(te,"done"),onChatWithAI:te=>I2(te,b)})}else if(S==="mobile-setup"&&N){const L=bg[N];D=L?e.jsx(L,{platform:V,onBack:()=>T("learn"),status:P(N),onComplete:()=>H(N,"done"),onRevert:()=>H(N,"available")}):e.jsx(Wa,{topics:q,detectedServices:$,onBack:()=>T("landing"),onOpenHosting:()=>T("hosting"),onOpenTopic:Z,onDismissService:M,onAddCredential:oe})}else D=e.jsxs(e.Fragment,{children:[e.jsx(mg,{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:F,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(nu,{appDetailProps:t,selectedApp:n})]});return e.jsxs($u,{children:[D,w&&e.jsx(ug,{onClose:C}),Y?e.jsx(Vr,{target:Y,onStored:()=>{Q(null),G()},onClose:()=>Q(null)}):null]})}const SM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellHomeTabContent:xg},Symbol.toStringTag,{value:"Module"}));function yg({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:k,featureCompleteActive:C}){return r?e.jsx(Uf,{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:k,featureCompleteActive:C}):null}const NM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellBuildLayer:yg},Symbol.toStringTag,{value:"Module"}));function vg({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 CM=Object.freeze(Object.defineProperty({__proto__:null,PanelDivider:vg},Symbol.toStringTag,{value:"Module"})),L2=[{key:"editor",label:"Editor"},{key:"preview",label:"Preview"}];function jg({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:L2.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(vr,{}),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 PM=Object.freeze(Object.defineProperty({__proto__:null,MobilePaneSwitcher:jg},Symbol.toStringTag,{value:"Module"}));function wg({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(jg,{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(vg,{onMouseDown:n})]}),r]})}const TM=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLayout:wg},Symbol.toStringTag,{value:"Module"}));function _g(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i}=Ns(),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 kg(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i,claimsVersion:c}=Ns(),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 Sg(){const[t,s]=l.useState(null),{claimsVersion:n}=Ns(),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 F2(){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 Sa="codeyam-editor editor plan-claims-status",z2="git push origin HEAD";function Ng(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:z2};case"network":return{message:"Plan tracking can't reach the remote (network failure). Check connectivity, then run the command below for details.",command:Sa};case"git-spawn":return{message:"Plan tracking can't launch git. Run the command below for the failing invocation.",command:Sa};default:return{message:`Plan tracking is failing (${s} failed ticks). Teammates' in-flight plans may not appear. Run the command below for details.`,command:Sa}}}function Cg({status:t}){const{copied:s,copy:n}=vn(),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}=Ng(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 AM=Object.freeze(Object.defineProperty({__proto__:null,PlanClaimSyncBanner:Cg,planClaimSyncBannerContent:Ng},Symbol.toStringTag,{value:"Module"})),dc="codeyam-editor editor restart-server";function Ri({staleness:t,backendOutOfDate:s=!1}){var i;const{copied:n,copy:r}=vn(),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:dc}),"."," ",e.jsx("button",{type:"button",className:"underline",style:{color:"var(--red-300)"},onClick:()=>void r(dc),children:n?"Copied":"Copy command"})]})]})})}const OM=Object.freeze(Object.defineProperty({__proto__:null,ServerStalenessBanner:Ri},Symbol.toStringTag,{value:"Module"}));function Pg(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 $2(t,s){return t.filter(n=>n.source==="local"||!s.has(n.slug))}function Tg(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 Ag(){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 B2(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 Og(t){return t.filter(s=>!s.satisfied)}function Rg(t){const{slugs:s}=Ag();return l.useMemo(()=>{const n={},r={};for(const a of t){const o=a.dependsOn??[];if(o.length===0)continue;const i=B2({...a,dependsOn:o},t,s);r[a.slug]=i;const c=Og(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 zs={hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null};function Kr(t){zs={...zs,...t}}function q2(){return zs}function H2(){return zs.hasActiveSession||zs.isAgentBuilding||!!zs.stepStateFeature}const W2=500;async function G2(){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 Ei(){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&&Kr({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),X("clear-editor-session",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function U2(){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&&Kr({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),X("stop-building",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function Y2(){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&&Kr({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),X("reset-everything",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function Mi(t={}){const s=q2(),n=t.caller??"unknown",r=t.bypassLiveGuard===!0;if(H2()&&!r){X("launch-editor-skill",{caller:n,suppressed:!0,snapshot:s,bypassLiveGuard:!1});return}Hk(),X("launch-editor-skill",{caller:n,suppressed:!1,snapshot:s,bypassLiveGuard:r}),!(t.provider==="gemini"||t.provider==="opencode")&&(Am(t.renameLabel??"Editor",n,Wc),Ra("/clear\r"),await new Promise(a=>setTimeout(()=>{Ra("/codeyam-editor\r"),a()},W2)))}async function V2(t={}){if(await Ei(),!await G2()){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 Mi(t)}function Ii(t,s=!1,n=s){const r=M0(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,"",Ds("home"))},[n,r]);const u=l.useCallback(f=>{if(s&&f==="build"){window.history.pushState(null,"",Ds("home"));return}window.history.pushState(null,"",Ds(f)),f==="build"&&i(!0),f==="plan"&&d(!0)},[s]),h=l.useCallback(()=>{s||(window.history.pushState(null,"",Ds("build")),i(!0))},[s]),p=l.useCallback(()=>{i(!1)},[]);return{activeTab:a,buildActivated:o,planActivated:c,navigateToTab:u,showBuildTab:h,deactivateBuild:p}}const K2=15e3;function Eg(t={}){const{launchAnchored:s=!1}=t,{showBuildTab:n}=Ii(typeof window>"u"?"/":window.location.pathname),{config:r}=gt(),[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 Ei(),ZN()}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)},K2),Mi({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 Mg({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:kf}),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 RM=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedModal:Mg},Symbol.toStringTag,{value:"Module"}));function Ig({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 EM=Object.freeze(Object.defineProperty({__proto__:null,PlanRunDependenciesModal:Ig},Symbol.toStringTag,{value:"Module"}));function Dg({claim:t,onCancel:s,onConfirm:n}){const r=Ks(),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 ",as(t.claimedBy.startedAt,r)]}),e.jsxs("span",{"data-testid":"plan-foreign-claim-step",children:["on step ",o," (",as(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 MM=Object.freeze(Object.defineProperty({__proto__:null,PlanRunForeignClaimModal:Dg},Symbol.toStringTag,{value:"Module"}));function Di({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=Og(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(Mg,{onClose:()=>o(!1)}),i&&e.jsx(Ig,{deps:i,onClose:()=>c(null)}),d&&e.jsx(Dg,{claim:d,onCancel:()=>u(null),onConfirm:p})]});return{requestRun:h,gateModals:f}}function Lg(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])}}function J2(t){return{describe:`${t} 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 Fg({subTab:t="describe",providerLabel:s}){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:J2(s)[t]})]})}const IM=Object.freeze(Object.defineProperty({__proto__:null,PlanTabHeader:Fg},Symbol.toStringTag,{value:"Module"})),X2=[{id:"describe",label:"Describe A Plan"},{id:"prototype",label:"Prototype A Plan"}];function zg({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:X2.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 DM=Object.freeze(Object.defineProperty({__proto__:null,PlanSubTabs:zg},Symbol.toStringTag,{value:"Module"}));function $g({onClose:t}){return e.jsx(_s,{chatName:"prototype",slashCommand:"/codeyam-prototype",height:480,onClose:t})}const LM=Object.freeze(Object.defineProperty({__proto__:null,PrototypeAgentChat:$g},Symbol.toStringTag,{value:"Module"})),Bg="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 qg(){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."})," ",Bg]})}const FM=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_BUILDING_IN_PROGRESS_MESSAGE:Bg,PrototypeBuildingInProgressBanner:qg},Symbol.toStringTag,{value:"Module"}));function ao({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 zM=Object.freeze(Object.defineProperty({__proto__:null,StartPrototypingButton:ao},Symbol.toStringTag,{value:"Module"})),oo=800;function un(t){window.dispatchEvent(new CustomEvent("miniagent-send-input",{detail:t}))}function Q2(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 Hg='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 Wg({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{un(Hg),await Q2(oo),un("\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 $M=Object.freeze(Object.defineProperty({__proto__:null,FINISH_AND_FORMALIZE_INSTRUCTION:Hg,FinishAndFormalizeButton:Wg},Symbol.toStringTag,{value:"Module"}));function Gg(t,s){return`Launches a chat window with ${t} to ${s==="describe"?"describe your plan":"start prototyping"}.`}function Li({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:Gg(t,s)})}const BM=Object.freeze(Object.defineProperty({__proto__:null,PlanChatLaunchCaption:Li,planChatLaunchCaptionText:Gg},Symbol.toStringTag,{value:"Module"}));function Ug({isAgentBuilding:t,onLaunched:s,launchSignal:n=0}){const[r,a]=l.useState(!1),[o,i]=l.useState(!1),{config:c}=gt(),d=rt(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&&lt(),a(m)},f=()=>{a(!1)};return t?e.jsxs("div",{"data-testid":"prototype-pane",children:[e.jsx(qg,{}),e.jsx(ao,{open:!1,disabled:!0,onToggle:()=>{}})]}):e.jsxs("div",{"data-testid":"prototype-pane",children:[e.jsx(ao,{open:r,onToggle:p}),!r&&e.jsx(Li,{providerLabel:d,kind:"prototype"}),r&&e.jsxs(e.Fragment,{children:[e.jsx($g,{onClose:f}),e.jsx(Wg,{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 qM=Object.freeze(Object.defineProperty({__proto__:null,PrototypePane:Ug},Symbol.toStringTag,{value:"Module"}));function Yg({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 HM=Object.freeze(Object.defineProperty({__proto__:null,PlanNextChangeButton:Yg},Symbol.toStringTag,{value:"Module"}));function Vg({onClose:t}){return e.jsx(_s,{chatName:"plan",slashCommand:"/codeyam-plan",height:360,onClose:t})}const WM=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthoringChat:Vg},Symbol.toStringTag,{value:"Module"}));function Kg({providerLabel:t,chatOpen:s,onChatToggle:n,onChatClose:r}){return e.jsxs("div",{"data-testid":"describe-pane",children:[e.jsx(Yg,{open:s,onToggle:n}),!s&&e.jsx(Li,{providerLabel:t,kind:"describe"}),s&&e.jsx(Vg,{onClose:r})]})}const GM=Object.freeze(Object.defineProperty({__proto__:null,DescribePane:Kg},Symbol.toStringTag,{value:"Module"}));function Jg({claim:t}){const s=Ks(),n=t.claimedBy.agentProvider??"agent",r=t.claimedBy.machine,a=t.claimedBy.currentStep??null,o=as(t.currentStepEnteredAt,s),i=as(t.claimedBy.startedAt,s),{dead:c}=ff(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 UM=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRow:Jg},Symbol.toStringTag,{value:"Module"}));function Xg({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(Jg,{claim:s},`${s.slug}:${s.claimedBy.machine}:${s.claimedBy.sessionId}:${s.claimedBy.pid}:${s.claimedBy.startedAt}`))})]})}const YM=Object.freeze(Object.defineProperty({__proto__:null,InFlightSection:Xg},Symbol.toStringTag,{value:"Module"})),Z2=5e3;function eC(){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()},Z2);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 tC(){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 sC(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 nC=new Set;function Na(t,s){return t??{order:[...s],releasedUuids:new Set}}function rC(){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=Na(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:xn(b.order,g,x)}})},[]),a=l.useCallback((h,p,f)=>{s(m=>{const b=Na(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:xn(b.order,g,x)}})},[]),o=l.useCallback((h,p)=>{s(f=>{const m=Na(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?sC(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)??nC,isDirty:d,reorderedCount:u,releasedCount:(t==null?void 0:t.releasedUuids.size)??0,moveByDrag:r,nudge:a,toggleRelease:o,reconcile:i,reset:c}}const aC=10;function oC(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)*aC;h.meta.priority!==p&&c.push({uuid:d.uuid,priority:p,expectedPriority:h.meta.priority})}),{releases:a,priorities:c}}function Qg({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 VM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueuePriorityChip:Qg},Symbol.toStringTag,{value:"Module"}));function Zg({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 KM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueReleaseButton:Zg},Symbol.toStringTag,{value:"Module"}));function eb({entry:t,isHead:s}){const n=Ks(),r=t.meta.agentProvider??"agent",a=t.meta.machine,o=t.meta.currentStep??null,i=as(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 JM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowIdentity:eb},Symbol.toStringTag,{value:"Module"}));function tb({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(eb,{entry:t,isHead:n}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Qg,{priority:t.meta.priority,uuid:t.uuid,onNudge:a}),e.jsx(Zg,{uuid:t.uuid,markedForRelease:r,onToggle:o})]})]})}const XM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRow:tb},Symbol.toStringTag,{value:"Module"}));function sb({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 QM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSaveBar:sb},Symbol.toStringTag,{value:"Module"}));function nb({entriesOverride:t,branchOverride:s}={}){const n=eC(),r=t!==void 0,a=t??n.entries,o=s??n.branch,i=tC(),c=rC(),{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,k=(C=m[w])==null?void 0:C.uuid;i.reset(),!(_===null||!k||_===k)&&c.moveByDrag(_,k,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:_}=oC(m,new Set(c.releasedUuids),a);h(null),f(!0);try{if(!r){for(const k of w)await n.release(k);for(const k of _)await n.setPriority(k.uuid,k.priority,k.expectedPriority);await n.refetch()}c.reset()}catch(k){h(k instanceof Error?k.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","data-testid":"commit-queue-error",children:e.jsx(He,{text:u,className:"text-xs text-[var(--accent-danger)]"})}),e.jsx("ol",{className:"mt-3 flex flex-col gap-2","data-testid":"commit-queue-list",children:m.map((w,_)=>e.jsx(tb,{entry:w,position:_+1,isHead:_===0,markedForRelease:c.releasedUuids.has(w.uuid),onPriorityNudge:k=>x(w,k),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(sb,{reorderedCount:c.reorderedCount(a),releasedCount:c.releasedCount,saving:p,onSave:j,onCancel:v})]})}const ZM=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSection:nb},Symbol.toStringTag,{value:"Module"}));function iC(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 rb({journalTimestamp:t}){const{entry:s,loading:n,error:r}=iC(t);return n?e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Loading journal entry…"}):r?e.jsx(He,{text:`Failed to load journal entry: ${r}`,className:"text-sm text-[var(--accent-red)]"}):s?e.jsx(Br,{entry:s}):e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No journal entry found for this plan yet."})}const eI=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanExpandedBody:rb},Symbol.toStringTag,{value:"Module"}));function ab({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:as(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(rb,{journalTimestamp:t.journalTimestamp})})]})}const tI=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanRow:ab},Symbol.toStringTag,{value:"Module"}));function ob({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(ib,{plans:t,loading:s,error:n,expandedSlug:r,onToggle:i=>a(c=>c===i?null:i)})]})}function ib({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.jsx(He,{text:`Failed to load completed plans: ${n}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):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(ab,{plan:o,expanded:r===o.slug,onToggle:()=>a(o.slug)},o.slug))})}const sI=Object.freeze(Object.defineProperty({__proto__:null,RecentPlansBody:ib,RecentPlansSection:ob},Symbol.toStringTag,{value:"Module"}));function lb({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}=_g(),{claims:m}=kg(),{slugs:b}=Ag(),{status:g}=Sg(),{staleness:x}=F2(),y=((g==null?void 0:g.consecutiveFailures)??0)>=3,{plans:v,loading:j,error:w}=Tg(),{config:_}=gt(),k=rt(_==null?void 0:_.provider),C=i!==void 0,S=Eg(),T=C?a??null:S.launchingSlug,A=C?o??null:S.error,[E,N]=l.useState(!1),B=l.useMemo(()=>Pg(m),[m]),q=l.useMemo(()=>$2(m,b),[m,b]),[H,R]=l.useState(c),F=t!==void 0,P=F?t:E,$=le=>{F||N(le),s==null||s(le)},M=()=>{$(!1),f()},G=()=>{const le=!P;le&&lt(),$(le)};l.useEffect(()=>{if(!(!n||!P))return lt()},[n,P]);const{annotationsBySlug:Y,dependenciesBySlug:Q}=Rg(u),oe=le=>{var Z;const ce=((Z=u.find(z=>z.slug===le))==null?void 0:Z.title)??le;if(i){i(le,ce);return}S.launchPlan(le,ce)},{requestRun:ne,gateModals:V}=Di({dependenciesBySlug:Q,claimsBySlug:B,isAgentBuilding:r,onLaunch:oe}),{reorderPlans:be}=Lg(f);return e.jsxs(ts,{testId:"plan-tab",children:[e.jsx(Fg,{subTab:H,providerLabel:k}),e.jsx(zg,{active:H,onChange:R}),H==="describe"&&e.jsx(Kg,{providerLabel:k,chatOpen:P,onChatToggle:G,onChatClose:M}),H==="prototype"&&e.jsx(Ug,{isAgentBuilding:r,onLaunched:()=>R("describe"),launchSignal:d}),e.jsx(Ri,{staleness:x}),e.jsx(Cg,{status:g}),e.jsx(Yr,{plans:u,loading:h,error:p,onRun:ne,launchingSlug:T,launchError:A,blocked:r,onReorder:be,depAnnotationsBySlug:Y,dependenciesBySlug:Q,claimsBySlug:B,staleFetch:y}),e.jsx(Xg,{claims:q}),e.jsx(nb,{}),e.jsx(ob,{plans:v,loading:j,error:w}),V]})}const nI=Object.freeze(Object.defineProperty({__proto__:null,PlanTab:lb},Symbol.toStringTag,{value:"Module"}));function cb({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(lb,{chatOpen:n,onChatOpenChange:r,isActive:t==="plan",isAgentBuilding:a,launchingSlug:o,launchError:i,onLaunchPlan:c,prototypeLaunchSignal:d})}):null}const rI=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPlanLayer:cb},Symbol.toStringTag,{value:"Module"})),lC="desktop",uc="codeyam:isDesktopApp";function cC(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(uc))==="1")return!0}catch{}const n=new URLSearchParams(((i=t.location)==null?void 0:i.search)??"").get(lC)==="1",r=typeof t.__TAURI__<"u",a=n||r;if(a)try{(c=t.sessionStorage)==null||c.setItem(uc,"1")}catch{}return a}function db({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 aI=Object.freeze(Object.defineProperty({__proto__:null,TabPane:db},Symbol.toStringTag,{value:"Module"}));function ub({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(db,{visible:t===r,children:s[r]},r))})}const oI=Object.freeze(Object.defineProperty({__proto__:null,LeftPanel:ub},Symbol.toStringTag,{value:"Module"}));function hb({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 iI=Object.freeze(Object.defineProperty({__proto__:null,CheckInToggleRow:hb},Symbol.toStringTag,{value:"Module"}));function Fi({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 lI=Object.freeze(Object.defineProperty({__proto__:null,SegmentedPicker:Fi},Symbol.toStringTag,{value:"Module"})),dC=[{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 pb({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(Fi,{options:dC,value:t,onChange:r,disabled:n,ariaLabel:"Autonomous commit action"})]})}const cI=Object.freeze(Object.defineProperty({__proto__:null,HardeningAutoAction:pb},Symbol.toStringTag,{value:"Module"})),mb={checkIns:{planAccepted:{pause:!0},prototypeCompleted:{pause:!0},hardeningCompleted:{pause:!0,autoAction:"commit"},push:{pause:!0}}};function hc(t){const s=(t==null?void 0:t.checkIns)??{},n=mb.checkIns;return{checkIns:{planAccepted:s.planAccepted??n.planAccepted,prototypeCompleted:s.prototypeCompleted??n.prototypeCompleted,hardeningCompleted:s.hardeningCompleted??n.hardeningCompleted,push:s.push??n.push}}}function uC(){const[t,s]=l.useState(mb),[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(hc(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(hc(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 hC=[{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."}],pC=[{value:"local",label:"This machine only"},{value:"project",label:"Whole project"}];function fb(){const[t,s]=l.useState("local"),{settings:n,branchState:r,loading:a,saving:o,error:i,save:c}=uC(),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(Fi,{options:pC,value:t,onChange:s})]}),e.jsx("div",{className:"mt-3",children:hC.map(u=>{const h=n.checkIns[u.key];return e.jsx(hb,{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(pb,{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 dI=Object.freeze(Object.defineProperty({__proto__:null,WorkflowSettingsSection:fb},Symbol.toStringTag,{value:"Module"}));function gb(){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(fb,{})]})}const uI=Object.freeze(Object.defineProperty({__proto__:null,SettingsTab:gb},Symbol.toStringTag,{value:"Module"}));function bb({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(ub,{activeTab:t,width:n,children:{home:s,build:null,plan:null,history:o?e.jsx(Dp,{onPreviewScreenshot:r}):null,reviews:c?e.jsx(Iu,{}):null,settings:u?e.jsx(gb,{}):null}})})}const hI=Object.freeze(Object.defineProperty({__proto__:null,EditorShellTabLayer:bb},Symbol.toStringTag,{value:"Module"}));function xb(t){const{annotationsBySlug:s,dependenciesBySlug:n}=Rg(t),{claims:r}=kg(),{status:a}=Sg(),o=l.useMemo(()=>Pg(r),[r]),i=((a==null?void 0:a.consecutiveFailures)??0)>=3;return{annotationsBySlug:s,dependenciesBySlug:n,claimsBySlug:o,staleFetch:i}}function yb({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}=xb(t),{requestRun:y,gateModals:v}=Di({dependenciesBySlug:b,claimsBySlug:g,isAgentBuilding:h,onLaunch:S=>{var A;const T=((A=t.find(E=>E.slug===S))==null?void 0:A.title)??S;s(S,T)}}),j=p.trim(),w=j.length>0,_=o||n!==null,k=()=>{_||(w?a(j):c())},C=S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),k())};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(Yr,{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:S=>f(S.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(He,{testId:"build-launch-modal-prompt-error",text:i,className:"text-xs text-[var(--text-danger)]",rowClassName:"mt-2"}),e.jsx("div",{className:"mt-4 flex items-center justify-end gap-2",children:e.jsx("button",{type:"button",onClick:k,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 pI=Object.freeze(Object.defineProperty({__proto__:null,BuildLaunchModal:yb},Symbol.toStringTag,{value:"Module"}));function vb({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 mI=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteDialog:vb},Symbol.toStringTag,{value:"Module"}));function jb({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(vb,{onCreateNewPlan:t,onContinueSession:s,onViewPlans:n})})}const fI=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteTransition:jb},Symbol.toStringTag,{value:"Module"}));function mC(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-terminal-emulator], .xterm")}function fC(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-post-push-modal]")}function wb({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 gI=Object.freeze(Object.defineProperty({__proto__:null,PostPushTransitionDialog:wb},Symbol.toStringTag,{value:"Module"}));function _b({onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o=0}){const i=l.useCallback(c=>{if(c.key!=="Enter"||mC(c.target))return;const d=c.target===document.body||c.target===document.documentElement||c.target===document;!fC(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(wb,{onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o})})}const bI=Object.freeze(Object.defineProperty({__proto__:null,PostPushTransition:_b},Symbol.toStringTag,{value:"Module"}));function kb({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}=xb(t),{requestRun:f,gateModals:m}=Di({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(Ci,{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(He,{testId:"select-plan-error",text:a,className:"text-xs text-[var(--text-danger)]",rowClassName:"mb-3"}),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 xI=Object.freeze(Object.defineProperty({__proto__:null,SelectPlanModal:kb},Symbol.toStringTag,{value:"Module"}));function Sb({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:k,onRestorePreview:C,onResultsScenarioSelect:S,previewSlug:T=null,onStartNextFeature:A,onStopBuilding:E,showPostPushModal:N,completionModalPermitted:B=!0,showResultsCommandKey:q,planChatOpen:H,onPlanChatOpenChange:R,showPlanCompleteModal:F,onCreateNewPlan:P,onContinueSession:$,onViewPlans:M,pendingPlans:G,onSelectPlan:Y,selectPlanOpen:Q,onPickPlan:oe,onCancelSelectPlan:ne,launchingPlanSlug:V,planLaunchError:be,prototypeLaunchSignal:le=0,showBuildLaunchModal:ce=!1,buildLaunchGateArmed:Z=!1,onSubmitBuildPrompt:z,submittingBuildPrompt:D=!1,buildPromptError:L=null,onStartBlankBuild:te,pendingPlansLoading:W,pendingPlansError:K,onReorderPlans:se,buildDisabled:ie=!1,onPreviewScreenshot:me,projectTitle:ye=null}){const U=cC();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:[U&&e.jsx(Qf,{projectTitle:ye}),e.jsx(Xf,{activeTab:t,onTabChange:g,onSendTranscript:s,buildIdle:i,isAgentBuilding:c,planActive:d,planIdle:u,bannerVisible:h,onDismissIdleBanner:p,buildDisabled:ie,showLogo:!U,providerLabel:rt(_)}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.jsx(yg,{awaitingPlanLaunchChoice:r,buildLaunchGateArmed:Z,buildActivated:a,activeTab:t,onSelectScenario:S,previewSlug:T,showResultsCommandKey:q,hideResultsCommandKey:f,onAgentIdle:y,onAgentActive:x,onUserInput:v,notifSettings:j,onSettingsChange:w,provider:_,onRestorePreview:C,pendingPlans:G,pendingPlansLoading:W,pendingPlansError:K,onLaunchPlan:oe,launchingSlug:V,launchError:be,onReorderPlans:se,isAgentBuilding:c,featureCompleteActive:N}),e.jsx(cb,{activeTab:t,planActivated:o,chatOpen:H,onChatOpenChange:R,isAgentBuilding:c,launchingPlanSlug:V,planLaunchError:be,onLaunchPlan:oe,prototypeLaunchSignal:le}),e.jsx(bb,{activeTab:t,appTabContent:n,leftWidth:m,onPreviewScreenshot:me}),N&&B&&t==="build"&&!Q?e.jsx(_b,{onStartNextFeature:A,onContinueInSession:k,onStopBuilding:E,onSendTranscript:s,onSelectPlan:Y,pendingPlanCount:G.length}):null,Q&&t==="build"?e.jsx(kb,{plans:G,onSelect:oe,onCancel:ne,launchingSlug:V,error:be}):null,ce&&t==="build"&&!N&&z&&te?e.jsx(yb,{plans:G,onPickPlan:oe,launchingSlug:V,planError:be,onSubmitPrompt:z,submittingPrompt:D,promptError:L,onStartBlank:te,pendingPlansLoading:W,pendingPlansError:K,isAgentBuilding:c}):null,F&&t==="plan"?e.jsx(jb,{onCreateNewPlan:P,onContinueSession:$,onViewPlans:M}):null]})]})}const yI=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLeftPane:Sb},Symbol.toStringTag,{value:"Module"})),pc=5173;function zi(t){if(t.startsWith("http"))try{return new URL(t).pathname}catch{return t}return t.split("?")[0]??t}function $i(t){return t?parseInt(t.port||(t.protocol==="https:"?"443":"80"),10):0}function Bi(t,{appPort:s,currentPort:n,previewOrigin:r}){return t.startsWith("http")?t:r?`${r}${t}`:n===s?t:`http://localhost:${s}${t}`}function Nb(t,s,n,r,a){if(n&&n.length>0)return Bi(n,{appPort:r,currentPort:s,previewOrigin:a});const o=`/scenario/${t}`;return a?`${a}${o}`:s===pc?o:`http://localhost:${pc}${o}`}const gC=["/apps","/entities","/app","/build","/history","/settings","/plan"];function Cb(t){if(!t)return!1;const s=zi(t);return gC.some(n=>s===n||s.startsWith(`${n}/`))}function Pb(t,s,n){const r=typeof window<"u"?$i(window.location):0;let a="";if(e0(t)==="component"?a=Nb(t.slug,r,t.url,s,n):t.url&&(a=Bi(t.url,{appPort:s,currentPort:r,previewOrigin:n})),a&&!Cb(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 mc(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 bC(t){try{await fetch("/api/editor-iframe-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({error:t})})}catch{}}async function xC(t){try{await fetch("/api/editor-iframe-banner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seedError:t})})}catch{}}async function yC(t){try{await fetch("/api/editor-iframe-auth-needed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({previewOrigin:t})})}catch{}}async function vC(t){try{await fetch("/api/editor-preview-escape",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({escapedPath:t})})}catch{}}function jC(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 wC=32;function _C({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:jC(r.width,r.height,s,t,wC);return{containerRef:d,containerSize:r,scale:u}}const kC={kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!1},fc=[400,800,1500,3e3];function Tb(){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=fc[Math.min(a,fc.length-1)];a+=1,r=setTimeout(c,d)},i=()=>{s(d=>d.loading?kC:d),o()},c=()=>{fetch("/api/project-stack").then(d=>d.ok?d.json():{}).then(d=>{n||(SC(d)?s(NC(d)):i())}).catch(()=>{n||i()})};return c(),()=>{n=!0,r&&clearTimeout(r)}},[]),t}function SC(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length>0}function NC(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:CC(n.kind),fallbackKind:PC(n.fallbackKind),fallbackPort:typeof n.fallbackPort=="number"?n.fallbackPort:null,loading:!1}}function CC(t){return t==="simulator-ios"?"simulator-ios":t==="simulator-android"?"simulator-android":"iframe"}function PC(t){return t==="iframe"||t==="simulator-ios"||t==="simulator-android"?t:null}const TC="codeyam:client-routing-detected";function AC(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)===TC&&n(!0)}return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[t]),s}const OC=700;function Ab({pollMs:t=OC,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 RC(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 RC(t){try{return await t.json()}catch{return null}}function EC(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 MC(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 io(){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 IC=50,DC={status:"loading",lastSuccessAt:null,lastErrorAt:null,lastErrorMessage:null,fetchCount:0,errorCount:0};function LC(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 FC(t,s){return{timestamp:s,success:t.ok,statusCode:t.statusCode,durationMs:t.durationMs,error:t.error}}function zC(t,s){return[s,...t].slice(0,IC)}function $C(){const[t,s]=l.useState(DC),[n,r]=l.useState([]),a=l.useCallback(i=>{const c=Date.now();r(d=>zC(d,FC(i,c))),s(d=>LC(d,i,c))},[]),o=l.useCallback(()=>{s(i=>({...i,status:"polling"}))},[]);return{connectionState:t,fetchLog:n,recordFetch:a,markPolling:o}}async function BC(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 qC(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 HC(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 io();if(c.ok&&c.data){const d=qC(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 WC(t){return!t||t<=0?3e4:Math.max(3e4,t*2)}function GC({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 BC(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=WC(s()),h=await HC(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 UC(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 Ob({state:t}){const s=Ks(),{dotClass:n,label:r,labelClass:a}=UC(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 ",Ea(t.lastSuccessAt,s)]})]})}const vI=Object.freeze(Object.defineProperty({__proto__:null,BackendConnectionStatusBadge:Ob},Symbol.toStringTag,{value:"Module"}));function Rb({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(Ob,{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(Pr,{maxHeight:90,moreLabel:"View More",lessLabel:"View Less",fadeColor:"var(--bg-input)",children:r})})]})]})}const jI=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsHeader:Rb},Symbol.toStringTag,{value:"Module"}));function YC(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=>Ai(o)===t.name)),example:t.example}}function Eb(t,s=[]){const n=[],r=[];let a=0;for(const o of t.tests){if(o.verified===!1){a+=1;continue}const i=YC(o,t,s);i.status==="passing"?n.push(i):r.push(i)}return{worksNow:n,inProgress:r,unverifiedCount:a}}function VC(t,s=[]){const n=[],r=[];let a=0;for(const o of t.changes){const i=Eb(o,s);n.push(...i.worksNow),r.push(...i.inProgress),a+=i.unverifiedCount}return{worksNow:n,inProgress:r,unverifiedCount:a}}function KC(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 JC(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 Mb({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 wI=Object.freeze(Object.defineProperty({__proto__:null,NarrativeTestStatusIcon:Mb},Symbol.toStringTag,{value:"Module"})),gc="font-mono text-[11px] text-[var(--text-primary)] whitespace-pre-wrap break-words min-w-0",bc="w-0 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] align-top pr-3 py-1 whitespace-nowrap";function Ib({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:bc,children:"Input"}),e.jsx("td",{className:`${gc} py-1`,"data-testid":"example-input",children:t.input})]}),e.jsxs("tr",{children:[e.jsx("td",{className:bc,children:"Output"}),e.jsx("td",{className:`${gc} 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 _I=Object.freeze(Object.defineProperty({__proto__:null,BehaviorExampleTable:Ib},Symbol.toStringTag,{value:"Module"})),XC="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function QC(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 Db({rerun:t={phase:"idle"},onRerun:s,disabled:n=!1,disabledReason:r}){const a=t.phase==="verifying",o=QC(t),i=t.phase==="error",c=n||a;return e.jsxs("div",{"data-testid":"evidence-rerun",children:[e.jsx("div",{className:XC,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 kI=Object.freeze(Object.defineProperty({__proto__:null,RerunSection:Db},Symbol.toStringTag,{value:"Module"}));function ZC(t){return t==="passing"?"passed":t==="failing"?"failed":"ran"}function e3(t){switch(t){case"full":return"full run";case"changed":return"changed-files run";case"targeted":return"targeted run"}}function Lb(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 en="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function Fb({behavior:t,rerun:s={phase:"idle"},onRerun:n,disabled:r=!1,disabledReason:a}){const o=Ks(),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:en,children:"Verified"}),e.jsxs("p",{className:"text-[11px] text-[var(--text-secondary)] m-0",children:[ZC(t.status)," ",Ea(Date.parse(t.lastRunAt),o),t.lastRunKind&&e.jsxs("span",{className:"text-[var(--text-muted)]",children:[" (",e3(t.lastRunKind),")"]})]})]}),t.example&&e.jsxs("div",{"data-testid":"evidence-example",children:[e.jsx("div",{className:en,children:"Example"}),e.jsx(Ib,{example:t.example})]}),t.recentStatuses&&t.recentStatuses.length>0&&e.jsxs("div",{"data-testid":"evidence-recent-runs",children:[e.jsx("div",{className:en,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} · ${Ea(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:en,children:"Exercises"}),e.jsx("ul",{className:"list-none p-0 m-0 space-y-1",children:t.exercises.map(c=>e.jsxs("li",{className:"text-[11px] text-[var(--text-secondary)] flex items-center gap-x-1.5",children:[e.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:c.name}),e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsx("span",{className:"font-mono text-[var(--text-dim)] min-w-0 truncate",children:c.filePath}),c.coverage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[Math.round(c.coverage.percent),"% covered"]})]})]},c.name))})]}),i&&e.jsxs("div",{"data-testid":"evidence-failure",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:en,children:"Failure"}),e.jsx(dt,{variant:"subtle",text:t.failureMessage??"",label:"Copy",className:"shrink-0 px-2 py-0.5 text-[11px] font-medium rounded border border-red-200 text-red-700 hover:bg-red-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"})]}),e.jsx("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-[11px] font-mono text-red-700 whitespace-pre-wrap overflow-x-auto","data-testid":"failure-message",children:t.failureMessage})]}),e.jsx(Db,{rerun:s,onRerun:n,disabled:r,disabledReason:a})]})}const SI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorEvidenceDrawer:Fb,hasDrawerContent:Lb},Symbol.toStringTag,{value:"Module"}));function zb({behavior:t,rerun:s}){var h,p;const[n,r]=l.useState(!1),a=Lb(t),o=KC(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(Mb,{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(Fb,{behavior:t,rerun:c,onRerun:s?()=>s.onRerun(t):void 0,disabled:u,disabledReason:"Verifying another behavior…"})]})]})})}const NI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorItem:zb},Symbol.toStringTag,{value:"Module"}));function lo({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(zb,{behavior:o,rerun:r},`${o.change}:${o.name}`))})]})}const CI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGroup:lo},Symbol.toStringTag,{value:"Module"}));function qi({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:t3(s)},n))})]})}function t3(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 PI=Object.freeze(Object.defineProperty({__proto__:null,WaysToTestList:qi},Symbol.toStringTag,{value:"Module"}));function $b({change:t,functions:s=[],rerun:n}){const{worksNow:r,inProgress:a}=Eb(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(qi,{ways:t.waysToTest??[]}),e.jsx(lo,{label:"Works now",behaviors:r,tone:"positive",rerun:n}),e.jsx(lo,{label:"In progress",behaviors:a,tone:"pending",rerun:n})]})}const TI=Object.freeze(Object.defineProperty({__proto__:null,ChangeCard:$b},Symbol.toStringTag,{value:"Module"}));function Bb({narrative:t,functions:s=[],rerun:n}){const{unverifiedCount:r}=VC(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($b,{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 AI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGallery:Bb},Symbol.toStringTag,{value:"Module"}));function qb({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 OI=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGalleryEmptyState:qb},Symbol.toStringTag,{value:"Module"}));function s3(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 Hb({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:s3(s)})]})}const RI=Object.freeze(Object.defineProperty({__proto__:null,BuildFileRow:Hb},Symbol.toStringTag,{value:"Module"}));function Wb({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=Ai(h);if(!p)continue;const f=c2(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(Oi,{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(Hb,{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(qi,{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 EI=Object.freeze(Object.defineProperty({__proto__:null,BuildProgressDetail:Wb},Symbol.toStringTag,{value:"Module"}));function n3(t){return t.filter(Boolean).join(" · ")}function r3(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 Gb({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=n3([`${r} runner${r===1?"":"s"}`,`${t.passed} passed`,t.failed>0?`${t.failed} failed`:"",...a,r3(s),JC(n)]);return e.jsx("p",{className:"text-[11px] text-[var(--text-muted)] font-mono m-0","data-testid":"run-evidence-line",children:o})}const MI=Object.freeze(Object.defineProperty({__proto__:null,RunEvidenceLine:Gb},Symbol.toStringTag,{value:"Module"})),a3=5e3;function Ub(){const[t,s]=l.useState(null),[n,r]=l.useState(!0),{connectionState:a,recordFetch:o,markPolling:i}=$C(),c=l.useRef(null),d=l.useRef(null);d.current=t;const u=GC({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 io();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 io();o(m),m.ok&&m.data&&s(m.data)},a3)),()=>{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=MC(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(Rb,{feature:t.feature,connectionState:a,statusChip:f,userPrompt:t.userPrompt}),e.jsx(Gb,{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(Bb,{narrative:t.narrative,functions:t.functions,rerun:u}):h>=3?e.jsx(Wb,{feature:t.feature,modifiedFiles:t.modifiedFiles,functions:t.functions,waysToTestBaseline:t.waysToTestBaseline,step:h}):e.jsx(qb,{step:h})})]})})}const II=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPage:Ub},Symbol.toStringTag,{value:"Module"}));function Yb(){return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx(Ub,{})})}const DI=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPanelView:Yb},Symbol.toStringTag,{value:"Module"}));function Vb({onClose:t,providerLabel:s}){const[n,r]=l.useState(""),a=l.useRef(null);return l.useEffect(()=>{var o;(o=a.current)==null||o.focus()},[]),l.useEffect(()=>{const o=i=>{i.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onMouseDown:o=>{o.target===o.currentTarget&&t()},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-1",children:"Create New State"}),e.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Describe the state you want ",s," to build."]}),e.jsx("textarea",{ref:a,value:n,onChange:o=>r(o.target.value),placeholder:"e.g. Empty inbox with a friendly empty-state illustration",rows:5,className:"w-full px-3 py-2 text-sm rounded mb-4 resize-none focus:outline-none",style:{background:"var(--bg-input)",border:"1px solid var(--border-default)",color:"var(--text-primary)"}}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-md text-sm transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Cancel"}),e.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"px-4 py-2 rounded-md text-sm font-medium opacity-50 cursor-not-allowed",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},children:["Send to ",s]})]})]})})}const LI=Object.freeze(Object.defineProperty({__proto__:null,CreateStatePlaceholderModal:Vb},Symbol.toStringTag,{value:"Module"}));function Kb(){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(hi,{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 FI=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetsView:Kb},Symbol.toStringTag,{value:"Module"}));function o3(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(`
42
+ `);n.push(`:root {
43
+ ${d}
44
+ }`)}if(s.primaryFont){const d=xc(s.primaryFont,s.primaryFontStack);n.push(`body, p, li, span, button, input, textarea, select, label { font-family: ${d} !important; }`)}if(s.secondaryFont){const d=xc(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">
45
+ ${n.join(`
46
+
47
+ `)}
48
+ </style>`:"",o=s.fontsHref?`<link rel="preconnect" href="https://fonts.googleapis.com">
49
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
50
+ <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}
51
+ ${a}
52
+ ${t}`;const u=d+(((c=t.match(/<body[^>]*>/i))==null?void 0:c[0].length)??0);return`${t.slice(0,u)}
53
+ ${o}
54
+ ${a}
55
+ ${t.slice(u)}`}return`${t.slice(0,i)}
56
+ ${o}
57
+ ${a}
58
+ ${t.slice(i)}`}function xc(t,s){const n=/\s/.test(t)?`"${t}"`:t,r=(s==null?void 0:s.trim())||"system-ui, sans-serif";return`${n}, ${r}`}const i3={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function Jr(t){return t.replace(/^\d{1,2}-/,"").replace(/-mockup\.html$/i,"").replace(/\.html$/i,"")}function l3(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 c3="\x1B[200~",d3="\x1B[201~";function u3(t,s=h3){const n=t.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),r=`${c3}${n}${d3}`;return s(r),new Promise(a=>{setTimeout(()=>{s("\r"),a()},b0)})}function h3(t){window.dispatchEvent(new CustomEvent("miniagent-send-input",{detail:t}))}function p3({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.
59
+
60
+ 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.
61
+
62
+ Per-card feedback (rating is 1-100 or null; comment may be empty):
63
+
64
+ \`\`\`json
65
+ `+JSON.stringify(n,null,2)+"\n```"}const m3=9e4;function f3(t){return!!(t.agentRespondedAfterDispatch||g3(t.snapshotFilenames,t.latestFilenames))}function g3(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 b3(t){const s={},n={},r=t.split(`
66
+ `);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)||!x3(p))continue;const f=o.filter(Boolean).join(" / "),m=Jb(f)?n:s;h in m||(m[h]=p)}return{light:s,dark:n}}function Jb(t){return/\bdark[\s-]?mode\b|\bdark\b\s*(palette|variant|theme)?/i.test(t)}function x3(t){return!!(/^#[0-9a-fA-F]{3,8}$/.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)||/^oklch\(/i.test(t))}const y3=["Background","Surface","Text","Primary","Secondary","Accent"],v3={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 j3(t){const s=[],n=t.split(`
67
+ `);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(`
68
+ `);for(const f of _3(p)){const m=c.filter(Boolean).join(" / "),b=w3(f.selector)||Jb(m);s.push({selector:f.selector,heading:i,isDark:b,vars:f.vars})}}r=!1,a=""}}return s}function w3(t){return/\[data-theme[~|*$^]?="?dark"?\]/.test(t)}function _3(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 k3(t,s){const n=v3[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 S3(t){const s=/\[data-palette[~|*$^]?="?([^"\]]+)"?\]/.exec(t);return s?s[1].split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):null}function N3(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 yc(t){const s=y3.map(n=>{const{cssVar:r,value:a}=k3(t,n);return{label:n,cssVar:r,value:a}});return{vars:t,slots:s}}function Hi(t){const s=j3(t),n=new Map,r=new Map,a=[];for(const o of s){const c=S3(o.selector)??N3(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=b3(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:yc(i),dark:c?yc(c):null}}).filter(o=>o!==null)}function C3(t){const s=Object.keys(t);if(s.length===0)return{};const n=Zb(t),r={};for(const a of s){const o=t[a];if(!o||!o.trim())continue;const i=n.get(a)??null;r[a]=A3(o,i)}return r}const Xb="#0f1115",P3="#181b21",Qb="#e8eaed";function T3(t){const s=Zb(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??Xb,text:r??Qb}}function Zb(t){var i;const n=["```css",":root {",Object.entries(t).map(([c,d])=>` ${c}: ${d};`).join(`
69
+ `),"}","```"].join(`
70
+ `),r=Hi(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 A3(t,s){switch(s){case"Background":return Xb;case"Surface":return P3;case"Text":return Qb;case"Primary":case"Secondary":case"Accent":return vc(t);default:return vc(t)}}function vc(t){const s=O3(t.trim());if(!s)return t;const{h:n,s:r,l:a}=R3(s.r,s.g,s.b),{r:o,g:i,b:c}=E3(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 O3(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:Ca(parseInt(n[1],10)),g:Ca(parseInt(n[2],10)),b:Ca(parseInt(n[3],10)),a:n[4]!=null?parseFloat(n[4]):void 0}:null}function Ca(t){return Math.max(0,Math.min(255,t))}function R3(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 E3(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 M3(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=>Jr(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=Hi(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?C3(b):null;r.current&&n(x=>({...x,[u]:g}))}catch{r.current&&n(h=>({...h,[u]:null}))}})()},[t,s]),s}function I3(){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 ex({round:t,onRestore:s,restoring:n=!1}){if(!t||!t.mockups||t.mockups.length===0)return e.jsx(qo,{});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 zI=Object.freeze(Object.defineProperty({__proto__:null,MockupArchivedRoundView:ex},Symbol.toStringTag,{value:"Module"})),Wi=[{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]}],D3={sans:"Sans-serif",serif:"Serif",display:"Display",mono:"Monospace"};function tx(t){const s=new Set,n=[];for(const r of t){if(!r||s.has(r))continue;s.add(r);const a=Wi.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 L3(t,s,n){const r={},a=jc(t,n),o=jc(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 jc(t,s){return t?s==="dark"&&t.dark?t.dark.slots:t.light.slots:[]}function F3(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 z3(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:Hi(d)})}catch(o){a||r({kind:"error",message:o instanceof Error?o.message:String(o)})}})(),()=>{a=!0}},[t,s]),n}function sx(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 Un(t,s,n){return{name:t,light:wc(s),dark:n?wc(n):null}}function wc(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 $3(){return[Un("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"}),Un("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"}),Un("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"}),Un("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 nx({palettes:t,activeName:s,theme:n,onApply:r}){const a=(()=>{const o=new Set(t.map(c=>c.name.toLowerCase())),i=$3().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 $I=Object.freeze(Object.defineProperty({__proto__:null,ColorPalettePicker:nx},Symbol.toStringTag,{value:"Module"}));function rx({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=B3(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 B3(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 BI=Object.freeze(Object.defineProperty({__proto__:null,ColorSwatchEditor:rx},Symbol.toStringTag,{value:"Module"}));function co({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 qI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePanelSectionHeading:co},Symbol.toStringTag,{value:"Module"}));function ax({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(co,{children:"Palettes"}),e.jsx(nx,{palettes:t,activeName:s,theme:n,onApply:o})]}),e.jsxs("div",{children:[e.jsx(co,{children:"Individual colors"}),e.jsx(rx,{slots:r,values:a,onChange:i})]})]})}const HI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeColorsPanel:ax},Symbol.toStringTag,{value:"Module"}));function ox({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 WI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeErrorBanner:ox},Symbol.toStringTag,{value:"Module"}));let _c=!1;function q3(){if(_c||typeof document>"u")return;_c=!0;const t=tx(Wi.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 uo({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(()=>{q3()},[]);const u=l.useCallback(()=>o(!1),[]);sx(a,d,u);const h={sans:[],serif:[],display:[],mono:[]};for(const p of Wi)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(ho,{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:D3[p]}),h[p].map(f=>e.jsx(ho,{family:f.family,label:f.family,isActive:s===f.family,onPick:()=>{n(f.family),o(!1)}},f.family))]},p))]})]})}function ho({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 GI=Object.freeze(Object.defineProperty({__proto__:null,FontOptionRow:ho,FontPicker:uo},Symbol.toStringTag,{value:"Module"}));function ix({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(uo,{label:"Headings",value:s,onChange:r}),e.jsx(uo,{label:"Body text",value:t,onChange:n})]})}const UI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeFontsPanel:ix},Symbol.toStringTag,{value:"Module"}));function Gi(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 H3(t,s){const{vars:n,bg:r,text:a}=W3(s),o=Object.entries(n).filter(([,p])=>p&&p.trim());if(o.length===0)return t;const i=[`:root {
71
+ `+o.map(([p,f])=>` ${p}: ${f};`).join(`
72
+ `)+`
73
+ }`,":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(`
74
+ `)}</style>`;if(t.search(/<\/head\s*>/i)===-1)return`${c}
75
+ ${t}`;const u=G3(t),h=u.search(/<\/head\s*>/i);return`${u.slice(0,h)}
76
+ ${c}
77
+ ${u.slice(h)}`}function W3(t){return t&&typeof t=="object"&&"vars"in t&&typeof t.vars=="object"?t:{vars:t}}function G3(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 lx({html:t,srcDoc:s,theme:n,mockupUrl:r,mockupName:a}){const o=Gi(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 YI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePreviewArea:lx},Symbol.toStringTag,{value:"Module"}));function Ui({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 VI=Object.freeze(Object.defineProperty({__proto__:null,MockupCardThemeToggleButton:Ui},Symbol.toStringTag,{value:"Module"}));function Yn(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 cx({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:{...Yn(!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:Yn(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:Yn(s==="colors"),children:["Colors ",e.jsx("span",{"aria-hidden":!0,style:{opacity:.7},children:"▾"})]}),e.jsx("button",{type:"button",onClick:u,style:{...Yn(!1),background:"transparent",color:"#9ca3af"},children:"Reset"}),e.jsx("div",{style:{flex:1}}),r&&e.jsx(Ui,{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 KI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeToolbar:cx},Symbol.toStringTag,{value:"Module"}));function dx({mockup:t,systemName:s,initial:n,onBack:r,onSave:a,saving:o=!1}){var T;const i=z3(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),[]);sx(m!==null,g,x);const y=l.useMemo(()=>{const A=[];return c.primaryFont&&A.push(c.primaryFont),c.secondaryFont&&A.push(c.secondaryFont),A.length===0?null:tx(A)},[c.primaryFont,c.secondaryFont]),v=l.useMemo(()=>i.kind!=="ready"?c.vars:F3(i.palettes,p,c.vars),[i,c.vars,p]),j=l.useMemo(()=>i.kind!=="ready"?"":o3(i.html,{...c,vars:v,fontsHref:y}),[i,c,v,y]),w=l.useCallback(A=>{h(A.name);const E=i.kind==="ready"?i.palettes[0]:void 0,N=L3(E,A,p);d(B=>({...B,vars:{...B.vars,...N}}))},[i,p]),_=l.useCallback((A,E)=>{h(null),d(N=>({...N,vars:{...N.vars,[A]:E}}))},[]),k=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 A=i.palettes[0];return p==="dark"&&A.dark?A.dark.slots:A.light.slots},[i,p]),S=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(cx,{systemName:s,openMenu:m,theme:p,hasDark:S,saving:o,toolbarRef:{current:null},onBack:()=>r(c),onToggleMenu:A=>b(E=>E===A?null:A),onToggleTheme:()=>f(A=>A==="light"?"dark":"light"),onReset:k,onSave:()=>a(c)}),m==="fonts"&&e.jsx(ix,{primaryFont:c.primaryFont,secondaryFont:c.secondaryFont,onPrimaryChange:A=>d(E=>({...E,primaryFont:A})),onSecondaryChange:A=>d(E=>({...E,secondaryFont:A}))}),m==="colors"&&e.jsx(ax,{palettes:i.kind==="ready"?i.palettes:[],activeName:u,theme:p,slots:C,vars:c.vars,onApplyPalette:w,onColorChange:_})]}),i.kind==="error"&&e.jsx(ox,{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(lx,{html:i.html,srcDoc:j,theme:p,mockupUrl:t.url,mockupName:t.name}):null]})}const JI=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeView:dx},Symbol.toStringTag,{value:"Module"})),U3={desktop:{w:1440,h:900},tablet:{w:834,h:1112},mobile:{w:390,h:844}},kc="desktop",Y3=1280,V3=1280,K3="#1a1a1a",J3="radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px)",X3="12px 12px";function Q3(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 ux(){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 hx({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(ux,{})})]}):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(Ui,{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 XI=Object.freeze(Object.defineProperty({__proto__:null,MockupCardFooter:hx,OpenInNewTabIcon:ux},Symbol.toStringTag,{value:"Module"})),Z3=700;function eP({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),Z3);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 Xe({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 QI=Object.freeze(Object.defineProperty({__proto__:null,SkeletonBar:Xe},Symbol.toStringTag,{value:"Module"}));function px(){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:`
78
+ @keyframes mockup-skeleton-shimmer {
79
+ 0% { background-position: -200% 0; }
80
+ 100% { background-position: 200% 0; }
81
+ }
82
+ `}),e.jsx(Xe,{widthPct:45,heightPx:14,variant:"overlay"}),e.jsx(Xe,{widthPct:70,heightPx:10,variant:"overlay"}),e.jsx("div",{style:{height:"6%"}}),e.jsx(Xe,{widthPct:100,heightPx:32,variant:"overlay"}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(Xe,{widthPct:48,heightPx:48,variant:"overlay"}),e.jsx(Xe,{widthPct:48,heightPx:48,variant:"overlay"})]}),e.jsx(Xe,{widthPct:88,heightPx:10,variant:"overlay"}),e.jsx(Xe,{widthPct:60,heightPx:10,variant:"overlay"})]})}const ZI=Object.freeze(Object.defineProperty({__proto__:null,MockupSkeletonOverlay:px},Symbol.toStringTag,{value:"Module"}));function Yi({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=U3[r];l.useEffect(()=>{const w=i.current;if(!w)return;const _=()=>{const C=w.clientWidth,S=w.clientHeight;C>0&&d(C),S>0&&h(S)};if(_(),typeof ResizeObserver>"u")return;const k=new ResizeObserver(_);return k.observe(w),()=>k.disconnect()},[]);const{scale:f,offsetX:m,offsetY:b}=Q3(c,u,p.w,p.h),g=t&&a==="dark"&&o?H3(t,{vars:o,...T3(o)}):t,{handleIframeLoad:x,visible:y,showSkeleton:v}=eP({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:`${Y3} / ${V3}`,overflow:"hidden",cursor:"pointer",backgroundColor:K3,backgroundImage:J3,backgroundSize:X3},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(px,{})]})}const e8=Object.freeze(Object.defineProperty({__proto__:null,MockupCardPreviewSlot:Yi},Symbol.toStringTag,{value:"Module"})),tP=`
83
+ .mockup-feedback-slider {
84
+ -webkit-appearance: none;
85
+ appearance: none;
86
+ background: transparent;
87
+ height: 18px;
88
+ padding: 0;
89
+ margin: 0;
90
+ cursor: pointer;
91
+ }
92
+ .mockup-feedback-slider:focus { outline: none; }
93
+ .mockup-feedback-slider::-webkit-slider-runnable-track {
94
+ height: 4px;
95
+ background: #4a4a4a;
96
+ border-radius: 2px;
97
+ }
98
+ .mockup-feedback-slider::-moz-range-track {
99
+ height: 4px;
100
+ background: #4a4a4a;
101
+ border-radius: 2px;
102
+ border: none;
103
+ }
104
+ .mockup-feedback-slider::-moz-range-progress {
105
+ background: #4a4a4a;
106
+ height: 4px;
107
+ border-radius: 2px;
108
+ }
109
+ .mockup-feedback-slider::-webkit-slider-thumb {
110
+ -webkit-appearance: none;
111
+ appearance: none;
112
+ width: 14px;
113
+ height: 14px;
114
+ border-radius: 50%;
115
+ background: #5a5a5a;
116
+ border: none;
117
+ margin-top: -5px;
118
+ cursor: pointer;
119
+ transition: background 120ms ease;
120
+ }
121
+ .mockup-feedback-slider::-moz-range-thumb {
122
+ width: 14px;
123
+ height: 14px;
124
+ border-radius: 50%;
125
+ background: #5a5a5a;
126
+ border: none;
127
+ cursor: pointer;
128
+ transition: background 120ms ease;
129
+ }
130
+ .mockup-feedback-slider[data-rated="true"]::-webkit-slider-runnable-track {
131
+ /* Two stacked layers: a grey overlay that masks the right portion of
132
+ * the track from progress% onward, and a full-width red-amber-keylime
133
+ * rainbow underneath. The visible filled portion is the slice of the
134
+ * rainbow up to the thumb position. */
135
+ background:
136
+ linear-gradient(
137
+ to right,
138
+ transparent 0%,
139
+ transparent var(--mockup-feedback-progress, 0%),
140
+ #4a4a4a var(--mockup-feedback-progress, 0%),
141
+ #4a4a4a 100%
142
+ ),
143
+ linear-gradient(
144
+ to right,
145
+ rgb(239, 68, 68) 0%,
146
+ rgb(251, 191, 36) 50%,
147
+ rgb(215, 255, 99) 100%
148
+ );
149
+ }
150
+ .mockup-feedback-slider[data-rated="true"]::-moz-range-track {
151
+ background: linear-gradient(
152
+ to right,
153
+ rgb(239, 68, 68) 0%,
154
+ rgb(251, 191, 36) 50%,
155
+ rgb(215, 255, 99) 100%
156
+ );
157
+ }
158
+ .mockup-feedback-slider[data-rated="true"]::-moz-range-progress {
159
+ /* Firefox draws ::-moz-range-progress on top of ::-moz-range-track,
160
+ * so the progress layer would otherwise hide the rainbow below it.
161
+ * Leave it transparent so the rainbow shows through up to the value. */
162
+ background: transparent;
163
+ }
164
+ .mockup-feedback-slider[data-rated="true"]::-webkit-slider-thumb {
165
+ background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
166
+ }
167
+ .mockup-feedback-slider[data-rated="true"]::-moz-range-thumb {
168
+ background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
169
+ }
170
+ `,sP=`
171
+ .mockup-feedback-comment {
172
+ width: 100%;
173
+ padding: var(--spacing-sm, 8px) var(--spacing-sm, 10px);
174
+ background: var(--bg-card, #1a1a1a);
175
+ color: var(--text-primary);
176
+ border: 1px solid var(--border-default);
177
+ border-radius: 6px;
178
+ font-size: var(--text-xs, 12px);
179
+ line-height: 1.4;
180
+ resize: vertical;
181
+ box-sizing: border-box;
182
+ min-height: 56px;
183
+ outline: none;
184
+ }
185
+ .mockup-feedback-comment:focus,
186
+ .mockup-feedback-comment:focus-visible {
187
+ border-color: var(--text-primary, #ffffff);
188
+ outline: none;
189
+ box-shadow: 0 0 0 1px var(--text-primary, #ffffff);
190
+ }
191
+ `;function mx({comment:t,onCommentChange:s}){return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:sP}),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 t8=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackCommentBox:mx},Symbol.toStringTag,{value:"Module"})),fx=[239,68,68],po=[251,191,36],gx=[215,255,99];function nP(t){const s=Math.max(1,Math.min(100,t));let n,r,a;s<=50?(n=fx,r=po,a=(s-1)/49):(n=po,r=gx,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})`}`${fx.join(", ")}${po.join(", ")}${gx.join(", ")}`;function bx(){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 xx(){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 s8=Object.freeze(Object.defineProperty({__proto__:null,ThumbDownIcon:bx,ThumbUpIcon:xx},Symbol.toStringTag,{value:"Module"}));function yx({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(bx,{})}),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?nP(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(xx,{})})]})}const n8=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackRatingSlider:yx},Symbol.toStringTag,{value:"Module"})),vx={rating:null,comment:""};function jx({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:tP}),e.jsx(yx,{rating:t.rating,onRatingChange:n=>s({...t,rating:n})}),e.jsx(mx,{comment:t.comment,onCommentChange:n=>s({...t,comment:n})})]})}const r8=Object.freeze(Object.defineProperty({__proto__:null,EMPTY_FEEDBACK:vx,MockupCardFeedback:jx},Symbol.toStringTag,{value:"Module"}));function wx({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(kc),[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(Gi(y)??kc)}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(hx,{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(Yi,{html:d,url:t.url,title:t.name,viewport:h,theme:f,darkVars:o}),c&&e.jsx(jx,{value:i??vx,onChange:c})]})}const a8=Object.freeze(Object.defineProperty({__proto__:null,MockupCard:wx},Symbol.toStringTag,{value:"Module"}));function _x({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:`
192
+ @keyframes mockup-skeleton-shimmer {
193
+ 0% { background-position: -200% 0; }
194
+ 100% { background-position: 200% 0; }
195
+ }
196
+ `}),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(Xe,{widthPct:45,heightPx:14}),e.jsx(Xe,{widthPct:70,heightPx:10}),e.jsx("div",{style:{height:"6%"}}),e.jsx(Xe,{widthPct:100,heightPx:32}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(Xe,{widthPct:48,heightPx:48}),e.jsx(Xe,{widthPct:48,heightPx:48})]}),e.jsx(Xe,{widthPct:88,heightPx:10}),e.jsx(Xe,{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 o8=Object.freeze(Object.defineProperty({__proto__:null,MockupPlaceholderCard:_x},Symbol.toStringTag,{value:"Module"}));function kx({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(wx,{mockup:c.mockup,displayNumber:c.number,onChoose:o,onCustomize:i,busy:n===c.mockup.filename,darkVars:s[Jr(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(_x,{displayNumber:c.number},`placeholder-${c.number}`))})}const i8=Object.freeze(Object.defineProperty({__proto__:null,MockupGrid:kx},Symbol.toStringTag,{value:"Module"}));function Sx(){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 l8=Object.freeze(Object.defineProperty({__proto__:null,MockupGridGeneratingOverlay:Sx},Symbol.toStringTag,{value:"Module"}));function Nx(){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 Cx(){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 Px({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(Nx,{})}),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(Cx,{})})]})}const c8=Object.freeze(Object.defineProperty({__proto__:null,CloseIcon:Cx,LightbulbIcon:Nx,MockupGridInfoBanner:Px},Symbol.toStringTag,{value:"Module"}));function Tx(){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 Ax({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(Tx,{})}),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 d8=Object.freeze(Object.defineProperty({__proto__:null,MockupGridIterateButton:Ax,RefreshCycleIcon:Tx},Symbol.toStringTag,{value:"Module"}));function Ox(){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 Rx(){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 Ex({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(mo,{ariaLabel:"Previous round",disabled:!u,onClick:()=>u&&n(a[c-1]),icon:e.jsx(Ox,{})}),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(mo,{ariaLabel:"Next round",disabled:!h,onClick:()=>h&&n(a[c+1]),icon:e.jsx(Rx,{})})]})}function mo({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 u8=Object.freeze(Object.defineProperty({__proto__:null,ChevronLeftIcon:Ox,ChevronRightIcon:Rx,MockupRoundPager:Ex,PagerArrowButton:mo},Symbol.toStringTag,{value:"Module"}));function Mx({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 h8=Object.freeze(Object.defineProperty({__proto__:null,StartBuildingConfirmModal:Mx},Symbol.toStringTag,{value:"Module"}));function Is(t,s){if(!s)return t;const n=t.includes("?")?"&":"?";return`${t}${n}round=${encodeURIComponent(s)}`}function Ix({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),k=l.useRef([]),C=l.useRef(!1),S=l.useRef(!1),[T,A]=l.useState(null),[E,N]=l.useState(()=>typeof window>"u"?!1:window.sessionStorage.getItem("mockup-grid-tip-dismissed")==="1"),[B,q]=l.useState("current"),H=I3(),R=l.useRef(null),F=M3(n),P=l.useRef(!0),$=l.useCallback(async()=>{try{const[z,D]=await Promise.all([fetch(Is("/api/editor-mockups",s)),fetch(Is("/api/editor-mockups-target",s))]),L=await z.json(),te=await D.json();P.current&&(r(W=>l3(W,L)||C.current&&L.length<k.current.length?W:L),o(W=>W===te.count?W:te.count))}catch(z){P.current&&c(z instanceof Error?z.message:String(z))}},[s]);l.useEffect(()=>{P.current=!0,$();const z=window.setInterval($,4e3);return()=>{P.current=!1,window.clearInterval(z)}},[$]),l.useEffect(()=>{let z=!1;return(async()=>{try{const D=await fetch(Is("/api/editor-mockups-feedback",s));if(!D.ok)return;const L=await D.json();if(z||!L||typeof L!="object"||Array.isArray(L))return;const te={};for(const[W,K]of Object.entries(L)){if(!K||typeof K!="object")continue;const se=K;se.rating!=null&&typeof se.rating!="number"||se.comment!=null&&typeof se.comment!="string"||(te[W]={rating:typeof se.rating=="number"?se.rating:null,comment:typeof se.comment=="string"?se.comment:""})}y(te)}catch{}})(),()=>{z=!0}},[]);const M=l.useCallback((z,D)=>{y(L=>{const te={...L,[z]:D};return R.current!=null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{fetch(Is("/api/editor-mockups-feedback",s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)}).catch(()=>{})},400),te})},[s]);l.useEffect(()=>()=>{R.current!=null&&window.clearTimeout(R.current)},[]);const G=l.useCallback(()=>{if(!n)return;const z=n.map(L=>L.filename);k.current=z,S.current=!1,_(!1),j(!0),q("current");const D=p3({feedbackByFilename:x,mockupFilenames:z});(async()=>{try{await fetch("/api/editor-mockups-archive",{method:"POST"})}catch{}await u3(D),P.current&&(S.current=!0,y({}),fetch(Is("/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 z=()=>{S.current&&_(!0)};return window.addEventListener("miniagent-output",z),()=>window.removeEventListener("miniagent-output",z)},[v]),l.useEffect(()=>{if(!v)return;const z=window.setTimeout(()=>{P.current&&j(!1)},m3);return()=>window.clearTimeout(z)},[v]),l.useEffect(()=>{v&&f3({snapshotFilenames:k.current,latestFilenames:(n??[]).map(z=>z.filename),agentRespondedAfterDispatch:w})&&j(!1)},[v,n,w]);const Y=l.useCallback(async z=>{A(z);try{const D=await fetch("/api/editor-mockups-restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({round:z})});if(!D.ok){const L=await D.text().catch(()=>`${D.status}`);throw new Error(L||`restore failed: ${D.status}`)}P.current&&(q("current"),$())}catch(D){P.current&&c(D instanceof Error?D.message:String(D))}finally{P.current&&A(null)}},[$]),Q=l.useCallback(z=>{m(z)},[]),oe=l.useCallback(async()=>{if(!f)return;const z=f;u(z.filename);try{const D=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:z.filename})});if(!D.ok){const L=await D.text().catch(()=>`${D.status}`);throw new Error(L||`select failed: ${D.status}`)}P.current&&(m(null),t==null||t({kind:"use",filename:z.filename}))}catch(D){c(D instanceof Error?D.message:String(D))}finally{P.current&&u(null)}},[f,t]),ne=l.useCallback(z=>{const D=Jr(z.filename);p({mockup:z,systemName:D})},[]),V=l.useCallback(z=>{h&&g(D=>({...D,[h.mockup.filename]:z})),p(null)},[h]),be=l.useCallback(async z=>{if(h){u(h.mockup.filename);try{const D=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:h.mockup.filename,overrides:{vars:z.vars,primaryFont:z.primaryFont,secondaryFont:z.secondaryFont}})});if(!D.ok){const L=await D.text().catch(()=>`${D.status}`);throw new Error(L||`select failed: ${D.status}`)}g(L=>({...L,[h.mockup.filename]:z})),p(null),t==null||t({kind:"use",filename:h.mockup.filename})}catch(D){c(D instanceof Error?D.message:String(D))}finally{P.current&&u(null)}}},[h,t]);if(h)return e.jsx(dx,{mockup:h.mockup,systemName:h.systemName,initial:b[h.mockup.filename]??i3,onBack:V,onSave:be,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 le=n.reduce((z,D)=>{const L=/^(\d{1,2})-/.exec(D.filename);return L?Math.max(z,parseInt(L[1],10)):z},0),ce=Math.max(a??0,le);if(ce===0)return e.jsx(qo,{});const Z=Array.from({length:ce},(z,D)=>{const L=D+1,te=String(L).padStart(2,"0"),W=n.find(K=>K.filename.startsWith(`${te}-`))??null;return{number:L,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:[!E&&e.jsx(Px,{onDismiss:()=>{N(!0),typeof window<"u"&&window.sessionStorage.setItem("mockup-grid-tip-dismissed","1")}}),e.jsx(Ex,{archivedRoundsNewestFirst:H.map(z=>z.round),selected:B,onSelect:q}),i&&e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderRadius:8,background:"var(--bg-danger-soft, rgba(248,113,113,0.12))",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:i}),B==="current"?e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[e.jsxs("div",{style:v?{opacity:.4,pointerEvents:"none"}:void 0,children:[e.jsx(kx,{slots:Z,darkVarsBySystem:F,busyFilename:d,feedbackByFilename:x,onFeedbackChange:M,onChoose:Q,onCustomize:ne}),n.length>0&&e.jsx("div",{style:{marginTop:"var(--spacing-md, 12px)"},children:e.jsx(Ax,{feedbackCount:Object.values(x).filter(z=>typeof z.rating=="number"||z.comment.trim().length>0).length,busy:v,onIterate:G})})]}),v&&e.jsx(Sx,{})]}):(()=>{const z=H.find(D=>D.round===B);return z?e.jsx(ex,{round:z,onRestore:()=>Y(z.round),restoring:T===z.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(Mx,{mockup:f,busy:d===f.filename,onCancel:()=>m(null),onConfirm:oe})]})}const p8=Object.freeze(Object.defineProperty({__proto__:null,DesignExplorationView:Ix,systemNameFromFilename:Jr,withRoundParam:Is},Symbol.toStringTag,{value:"Module"}));function Dx({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(Kb,{}):e.jsx(Ix,{onDesignConfirmed:t})]})}const m8=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPreviewPane:Dx},Symbol.toStringTag,{value:"Module"}));function Lx({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 f8=Object.freeze(Object.defineProperty({__proto__:null,NativeMirrorNotice:Lx},Symbol.toStringTag,{value:"Module"}));function Fx({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 g8=Object.freeze(Object.defineProperty({__proto__:null,CollapseToggleButton:Fx},Symbol.toStringTag,{value:"Module"}));function fo({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 b8=Object.freeze(Object.defineProperty({__proto__:null,DimensionInput:fo},Symbol.toStringTag,{value:"Module"}));function zx({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 x8=Object.freeze(Object.defineProperty({__proto__:null,FillPreviewButton:zx},Symbol.toStringTag,{value:"Module"}));function $x({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 y8=Object.freeze(Object.defineProperty({__proto__:null,OpenInNewTabButton:$x},Symbol.toStringTag,{value:"Module"})),go=new Set;function rP(t){return go.add(t),()=>{go.delete(t)}}function aP(){for(const t of go)t()}function Bx(){return e.jsx("button",{onClick:()=>aP(),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 v8=Object.freeze(Object.defineProperty({__proto__:null,RefreshPreviewButton:Bx},Symbol.toStringTag,{value:"Module"}));function Sc(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 qx(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=Sc(n)-Sc(r);return a!==0?a:n.route.localeCompare(r.route)})}function oP(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 Hx({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 j8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerEmptyMessage:Hx},Symbol.toStringTag,{value:"Module"}));function Wx({scenario:t,active:s,onClick:n}){const r=t.screenshotPaths[0],a=Sr(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:os(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 w8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerScenarioThumbnail:Wx},Symbol.toStringTag,{value:"Module"}));function Gx({group:t,currentSlug:s,onSelect:n}){const r=t.scenarios[0]?dd(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(Wx,{scenario:a,active:a.slug===s,onClick:()=>n(a.slug)},a.slug))})]})}const _8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerRouteSection:Gx},Symbol.toStringTag,{value:"Module"}));function bo({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 k8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerTabButton:bo},Symbol.toStringTag,{value:"Module"}));function Ux({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()},[]),mi(u,r,a);const p=l.useMemo(()=>t.flatMap(y=>y.scenarios),[t]),f=l.useMemo(()=>oP(p,c),[p,c]),m=l.useMemo(()=>f.filter(wr),[f]),b=l.useMemo(()=>f.filter(So),[f]),g=o==="pages"?m:b,x=l.useMemo(()=>qx(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(bo,{label:"PAGES",active:o==="pages",count:m.length,onClick:()=>i("pages")}),e.jsx(bo,{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(Hx,{tab:o,hasQuery:c.trim().length>0}):x.map(y=>e.jsx(Gx,{group:y,currentSlug:s,onSelect:v=>{n(v),r()}},y.route))})]})}const S8=Object.freeze(Object.defineProperty({__proto__:null,PagePickerDropdown:Ux},Symbol.toStringTag,{value:"Module"}));function Yx(){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 Vx(){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 Vi({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 N8=Object.freeze(Object.defineProperty({__proto__:null,ComponentGlyph:Vx,DropdownChevron:Vi,PageGlyph:Yx},Symbol.toStringTag,{value:"Module"}));function Kx({currentScenario:t,isOpen:s,onClick:n,buttonRef:r}){const a=t?So(t):!1,o=(t==null?void 0:t.screenshotPaths[0])??null,i=t?a?t.componentName??t.name:dd(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:os(o),alt:"",className:"w-full h-full object-cover"}):a?e.jsx(Vx,{}):e.jsx(Yx,{})}),e.jsx(Vi,{})]}),e.jsx("span",{className:"truncate",children:i})]})}const C8=Object.freeze(Object.defineProperty({__proto__:null,PagePill:Kx},Symbol.toStringTag,{value:"Module"}));function Jx({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:os(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:Sr(t)})]})}const P8=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdownRow:Jx},Symbol.toStringTag,{value:"Module"}));function Xx({currentScenario:t,scenarioGroups:s,onSelect:n,onCreateNew:r,onClose:a,triggerRef:o}){const i=l.useRef(null);mi(i,a,o);const c=l.useMemo(()=>Do(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(Jx,{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 T8=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdown:Xx},Symbol.toStringTag,{value:"Module"}));function Qx({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(Vi,{className:"opacity-70 shrink-0"})]})}const A8=Object.freeze(Object.defineProperty({__proto__:null,StatesPillButton:Qx},Symbol.toStringTag,{value:"Module"}));function Zx({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(Yf,{name:t.name})})}const O8=Object.freeze(Object.defineProperty({__proto__:null,ViewportPresetButton:Zx},Symbol.toStringTag,{value:"Module"}));function ey({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[k,C]=l.useState(!1),[S,T]=l.useState(!1),A=l.useRef(null),E=l.useRef(null),N=d&&h?Math.round(h):r,B=d&&p?Math.round(p):a,q=m?Sr(m):"No state",H=!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(Fx,{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(Kx,{currentScenario:m,isOpen:k,onClick:()=>{C(R=>!R),T(!1)},buttonRef:A}),k&&e.jsx(Ux,{scenarioGroups:b,currentSlug:(m==null?void 0:m.slug)??null,onSelect:g,onClose:()=>C(!1),triggerRef:A}),e.jsx("span",{className:"w-px h-5 bg-[#555] mx-1 shrink-0","aria-hidden":"true"}),t.map(R=>e.jsx(Zx,{viewport:R,isActive:!d&&s===R.name,onSelect:()=>{d&&u(),n(R.name)}},R.name)),e.jsx(zx,{isFilled:d,onToggle:u}),e.jsx(fo,{label:"H",value:B,disabled:d,onCommit:R=>f(r,R)}),e.jsx(fo,{label:"W",value:N,disabled:d,onCommit:R=>f(R,a)}),e.jsx(Bx,{}),e.jsx($x,{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(Qx,{label:q,disabled:H,isOpen:S,onClick:()=>{T(R=>!R),C(!1)},buttonRef:E}),S&&m&&e.jsx(Xx,{currentScenario:m,scenarioGroups:b,onSelect:g,onCreateNew:x,onClose:()=>T(!1),triggerRef:E})]})})})]}),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 R8=Object.freeze(Object.defineProperty({__proto__:null,NavigationBar:ey},Symbol.toStringTag,{value:"Module"}));function ty(){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 E8=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewEmptyState:ty},Symbol.toStringTag,{value:"Module"}));function sy({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 M8=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewHeader:sy},Symbol.toStringTag,{value:"Module"})),Nc={prompt:null,title:null};function ny(){const[t,s]=l.useState(Nc),[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(Nc)}finally{a||r(!1)}})(),()=>{a=!0}},[]),{...t,loading:n}}function ry(){const{prompt:t,title:s,loading:n}=ny();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(sy,{title:s}):null,e.jsx(Ht,{children:t})]}):e.jsx(ty,{})})})}const I8=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewPanelView:ry},Symbol.toStringTag,{value:"Module"}));function ay({message:t}){return e.jsx("span",{style:{color:"var(--text-dim)"},children:t})}const D8=Object.freeze(Object.defineProperty({__proto__:null,PreviewEmptyState:ay},Symbol.toStringTag,{value:"Module"}));function oy({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 L8=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingPlaceholder:oy},Symbol.toStringTag,{value:"Module"}));function iy(t,s,n){const r=[t];return s&&r.push(`reload:${s}`),n&&r.push(`command:${n}`),r.join("::")}function ly({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 cy=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(wt())return e.jsx(ly,{currentWidth:n,currentHeight:s,isFilled:r,scale:o});const f=d??iy(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)})}),F8=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedPreviewPlaceholder:ly,PreviewFrame:cy},Symbol.toStringTag,{value:"Module"}));function dy({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 z8=Object.freeze(Object.defineProperty({__proto__:null,PreviewLoadingSpinner:dy},Symbol.toStringTag,{value:"Module"}));function iP(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 lP(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===vs||n.startsWith(`${vs}/`)?null:n}function cP(t){return{type:"error",message:`The app navigated to "${t}", which is outside the Live Preview (everything the preview serves lives under ${vs}). 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: ${vs}`,"",`Why this happens: the Live Preview is served from the same-origin ${vs} 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(`
197
+ `),timestampMs:Date.now(),dedupeKey:`preview-escape:${t}`,count:1}}function dP({previewUrl:t,resetKey:s,capturedErrors:n}){const[r,a]=l.useState(null),o=t.startsWith(vs);l.useEffect(()=>{a(null)},[s,t]);const i=l.useCallback(u=>{const h=iP(u),p=lP(h,o);return a(p),p!==null&&vC(p),h},[o]),c=l.useCallback(()=>a(null),[]),d=l.useMemo(()=>r?[...n,cP(r)]:n,[n,r]);return{escaped:r!==null,overlayErrors:d,noteFrameLoad:i,clearEscape:c}}function uP(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 hP(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 pP(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 mP(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&&mc(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&&mc(t,h??c.current)},[t,s]),u=l.useCallback(h=>{s&&bC(h)},[s]);return{reloadNonce:o,handleIframeLoad:d,handleIframeError:u}}const fP=1500,gP=2e3,bP=3e3,xP=2;function yP(){return typeof window>"u"?!1:window.location.pathname.startsWith("/scenario/")?!0:wt()}function vP(t,s=!1){const n=yP(),[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 k=g.current;if(!k)return;m.current&&m.current.abort();const C=new AbortController;m.current=C;const S=setTimeout(()=>C.abort(),bP);let T=!1;try{await fetch(k,{mode:"no-cors",cache:"no-store",signal:C.signal}),T=!0}catch{T=!1}finally{clearTimeout(S)}if(!b.current){if(i(Date.now()),T){if(d(0),p.current!==!0){const A=p.current===!1;p.current=!0,a(!0),A&&h(E=>E+1)}}else d(A=>{const E=A+1;return E>=xP&&p.current!==!1&&(p.current=!1,a(!1)),E});j()}},[]),j=l.useCallback(()=>{if(b.current)return;y();const k=p.current===!0?gP:fP;f.current=setTimeout(()=>{f.current=null,v()},k)},[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 k=_.current;_.current=s,k&&!s&&v()},[s,v,n]),{healthy:r,lastProbeAt:o,failedProbeCount:c,reloadNonce:u,invalidate:w}}const Cc={loaded:!1,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:null};function jP(t){const{active:s,trigger:n}=t,[r,a]=l.useState(Cc),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(Cc),(c=o.current)==null||c.abort();return}return i(),()=>{var d;(d=o.current)==null||d.abort()}},[s,n,i]),r}function wP(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 _P({liveIframeHealthy:t,previewReachable:s}){return t===!0||s===!0}function kP({hasDevServerConfigured:t,hasServed:s}){return!t||s}const SP=2e3;function NP(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<SP||(i.current=m,r(b=>b+1))},[t,s]),n}const Vn={windowMs:1e4,threshold:4,ringBufferSize:16};function CP({pidNonce:t,probeNonce:s,draftNonce:n,windowMs:r=Vn.windowMs,threshold:a=Vn.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(k=>{const C=k.filter(S=>S.timestampMs>=j);return C.push({reason:y,timestampMs:v}),C.length>Vn.ringBufferSize&&C.splice(0,C.length-Vn.ringBufferSize),w=C,C});const _=w.filter(k=>k.timestampMs>=j).length;if(!p.current&&_>=a){p.current=!0,i(!0);return}p.current||h(k=>k+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 PP(t,s,n=Ro){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 Pc=20,TP="codeyam-error-capture";function AP(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!==TP)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>Pc?f.slice(f.length-Pc):f})}return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[t]),{errors:n,clear:a}}const Pa=[500,1e3,2e3];async function OP(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 RP(){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 EP(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+Pa.length;let i=null;for(let d=0;d<o;d++){if(a)return;const{status:u}=await OP(t);if(a)return;if(i=u,u===null||u<500){r({status:u,clickThroughBroken:!1,logLines:[],loading:!1});return}d<Pa.length&&await new Promise(h=>setTimeout(h,Pa[d]))}const c=await RP();a||r({status:i,clickThroughBroken:!0,logLines:c,loading:!1})})(),()=>{a=!0}},[t,s]),n}function uy({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.jsxs("div",{className:"flex-shrink-0 flex items-start gap-2",children:[e.jsx(dt,{variant:"subtle",text:`Scenario render failed (HTTP ${s})
198
+ ${t}
199
+
200
+ ${n.join(`
201
+ `)}`,label:"Copy",className:"px-2.5 py-1 text-xs rounded border border-gray-600 bg-gray-800 text-gray-200 hover:bg-gray-700 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:r,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"})]})]}),e.jsx("div",{className:"px-5 py-4 max-h-72 overflow-auto font-mono text-[11px] leading-snug text-zinc-300 whitespace-pre-wrap",children:n.length>0?n.join(`
202
+ `):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 $8=Object.freeze(Object.defineProperty({__proto__:null,IframeClickThroughErrorCard:uy},Symbol.toStringTag,{value:"Module"}));function MP(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 IP=20;function DP(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 LP(t){return t===null||t.status!=="running"?!1:t.liveIframeHealthy!==!1}const FP=5,zP=3;function $P(t,s){return t===null||t<=0?!1:t<=(s==="backend"?zP:FP)}const Tc="Setting up your project",Ac="Preparing your project — the preview will appear once it's ready.",BP={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."},qP={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Preparing the project environment."};function HP(t,s){return t===null?{title:Tc,body:Ac}:{title:Tc,body:(s==="backend"?qP:BP)[t]??Ac}}function hy({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 B8=Object.freeze(Object.defineProperty({__proto__:null,RestartSpinner:hy},Symbol.toStringTag,{value:"Module"})),WP={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 py({variant:t,restartCount:s=0,showRetry:n=!1,onRetry:r,bodyOverride:a}){const{title:o,body:i,spinner:c}=WP[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(hy,{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 q8=Object.freeze(Object.defineProperty({__proto__:null,PreviewUnhealthyOverlay:py},Symbol.toStringTag,{value:"Module"}));function GP(t){return t.slice().reverse().map(s=>{const n=s.filename!=null?`
203
+ at ${s.filename}${s.lineno!=null?`:${s.lineno}`:""}${s.colno!=null?`:${s.colno}`:""}`:"",r=s.stack?`
204
+ ${s.stack}`:"",a=s.count>1?` (×${s.count})`:"";return`[${s.type}]${a} ${s.message}${n}${r}`}).join(`
205
+
206
+ `)}function UP(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 my({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 H8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorBadge:my},Symbol.toStringTag,{value:"Module"}));function fy({headline:t,tripped:s,onClear:n,closeAriaLabel:r="Dismiss errors",providerLabel:a}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3 border-b border-red-200 dark:border-red-900",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:t}),e.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children: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 ${a}.`})]}),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 W8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayHeader:fy},Symbol.toStringTag,{value:"Module"}));function YP(t){const s=t.filename?`${t.filename}${t.lineno!=null?`:${t.lineno}`:""}${t.colno!=null?`:${t.colno}`:""}`:"";return[`${t.type}: ${t.message}`,s,t.stack??""].filter(Boolean).join(`
207
+ `)}function gy({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("div",{className:"flex items-start",children:[e.jsxs("button",{type:"button",onClick:n,className:"flex-1 min-w-0 flex items-start gap-2 text-left px-2 py-1.5 hover:bg-red-100/60 dark:hover:bg-red-900/30",children:[e.jsx("span",{className:"mt-0.5 text-red-500","aria-hidden":"true",children: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}`:""]})]})]}),e.jsx("div",{className:"shrink-0 px-1.5 py-1.5",children:e.jsx(dt,{variant:"icon",text:YP(t)})})]}),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 G8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorRow:gy},Symbol.toStringTag,{value:"Module"}));function by({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(gy,{error:a,expanded:n===a.dedupeKey,onToggle:()=>r(n===a.dedupeKey?null:a.dedupeKey)},a.dedupeKey))})}const U8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorList:by},Symbol.toStringTag,{value:"Module"}));function xy({canCopy:t,reasonsSummary:s,copyState:n,onCopy:r,onCopyForAgent:a,onRetry:o,providerLabel:i}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 border-t border-red-200 dark:border-red-900 bg-gray-50 dark:bg-gray-900/40",children:[e.jsx("button",{type:"button",onClick:r,disabled:!t,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:"Copy errors"}),e.jsxs("button",{type:"button",onClick:a,disabled:!t,className:"px-2.5 py-1 text-xs rounded bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:["Copy and ask ",i]}),e.jsx("button",{type:"button",onClick:o,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"}),e.jsxs("span",{className:"ml-auto text-[11px] text-gray-500",children:["Reloads in last 10s: ",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 Y8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayFooter:xy},Symbol.toStringTag,{value:"Module"})),VP=`Fix this error in the live preview. Here is what the captured runtime error reported:
208
+
209
+ `;function yy({tripped:t,errors:s,recentReloads:n,serverHealthy:r,onRetry:a,onClear:o,providerLabel:i}){const[c,d]=l.useState("idle"),[u,h]=l.useState(!0),p=l.useMemo(()=>GP(s),[s]),f=l.useMemo(()=>UP(n),[n]);if(l.useEffect(()=>{s.length===0&&h(!0)},[s.length]),!t&&s.length===0)return null;const m=r&&!t,b=m&&u&&s.length>0,g=t?`Live Preview paused — ${s.length} error${s.length===1?"":"s"} captured`:`${s.length} runtime error${s.length===1?"":"s"} captured`;async function x(y){const v=await D0(y+p);d(v?"copied":"failed"),setTimeout(()=>d("idle"),1500)}return b?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(my,{count:s.length,onExpand:()=>h(!1),onClear:o})}):e.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":t?"true":"false","data-collapsed":"false",className:"absolute inset-0 z-50 flex flex-col items-stretch p-4 pointer-events-none",children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl rounded-lg shadow-lg pointer-events-auto flex flex-col",style:{background:"var(--bg-surface, rgba(255,255,255,0.97))",border:"1px solid var(--border-default, #ef4444)",maxHeight:"100%"},children:[e.jsx(fy,{headline:g,tripped:t,onClear:m?()=>h(!0):o,closeAriaLabel:m?"Minimize errors":"Dismiss errors",providerLabel:i}),e.jsx(by,{errors:s,emptyHint:t?`Breaker tripped before any runtime error was reported. Reasons in window: ${f}.`:null}),e.jsx(xy,{canCopy:s.length>0,reasonsSummary:f,copyState:c,onCopy:()=>x(""),onCopyForAgent:()=>x(VP),onRetry:a,providerLabel:i})]})})}const V8=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlay:yy},Symbol.toStringTag,{value:"Module"}));function KP(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 vy({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(()=>KP(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 K8=Object.freeze(Object.defineProperty({__proto__:null,ActiveScenarioOverlay:vy},Symbol.toStringTag,{value:"Module"}));function jy(){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 J8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogHeader:jy},Symbol.toStringTag,{value:"Module"}));function wy({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 X8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogViewer:wy},Symbol.toStringTag,{value:"Module"}));function _y({providerLabel:t}){return e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-red-800 dark:text-red-300 font-medium mb-1",children:"CodeYam was unable to restart the dev server after several attempts."}),e.jsxs("p",{className:"text-xs text-red-700/80 dark:text-red-400/80",children:["Copy the logs and share them with ",t," to investigate the underlying bug."]})]})}const Q8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooterMessage:_y},Symbol.toStringTag,{value:"Module"}));function ky({logs:t,copyWriter:s,providerLabel:n}){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(_y,{providerLabel:n}),e.jsx(dt,{text:t.join(`
210
+ `),label:"Copy logs",writer:s})]})})}const Z8=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooter:ky},Symbol.toStringTag,{value:"Module"}));function Sy({logs:t,providerLabel:s}){return e.jsxs("div",{className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[e.jsx(jy,{}),e.jsx(wy,{logs:t}),e.jsx(ky,{logs:t,providerLabel:s})]})}const e7=Object.freeze(Object.defineProperty({__proto__:null,DevServerCrashLog:Sy},Symbol.toStringTag,{value:"Module"})),Oc=20;function JP(t){if(!t)return null;try{return new Date(t).toLocaleTimeString()}catch{return null}}function Ny({lastError:t,failureCount:s,failedAtMs:n,holder:r,onRetry:a,onReap:o}){const[i,c]=l.useState(!1),d=t.split(`
211
+ `),u=d.length>Oc,h=i||!u?d:d.slice(d.length-Oc),p=JP(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(`
212
+ `)}),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:[e.jsx(dt,{variant:"subtle",text:t,label:"Copy error",className:"shrink-0 px-3 py-1.5 text-sm font-medium rounded border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"}),r&&o&&e.jsx("button",{type:"button","data-testid":"dev-server-failed-reap",onClick:o,className:"px-4 py-1.5 text-sm font-medium rounded border border-amber-500 text-amber-700 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-900/50",children:"Kill orphan and retry"}),e.jsx("button",{type:"button","data-testid":"dev-server-failed-retry",onClick:a,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})]})]})]})}const t7=Object.freeze(Object.defineProperty({__proto__:null,DevServerFailedPanel:Ny},Symbol.toStringTag,{value:"Module"}));function Cy({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 s7=Object.freeze(Object.defineProperty({__proto__:null,PreviewPortMismatchCard:Cy},Symbol.toStringTag,{value:"Module"})),Rc=48,XP=100,QP=320,ZP=192;function e5({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:QP,height:ZP,hasViewport:!1};const o=s-Rc*2,i=t-Rc*2-XP,c=Math.min(1,o/r,i/n);return{width:Math.round(r*c),height:Math.round(n*c),hasViewport:!0}}function xo({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}=e5({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(At,{screenshotPath:o??void 0,alt:a??"Scenario preview",className:p?"w-full h-auto":"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children: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 n7=Object.freeze(Object.defineProperty({__proto__:null,BuildingPreviewOverlay:xo},Symbol.toStringTag,{value:"Module"}));function Py({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 r7=Object.freeze(Object.defineProperty({__proto__:null,DebugModeButton:Py},Symbol.toStringTag,{value:"Module"}));function t5(){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 Ty({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 a7=Object.freeze(Object.defineProperty({__proto__:null,DebugModalElementPreview:Ty},Symbol.toStringTag,{value:"Module"}));function Ay({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 o7=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestryList:Ay},Symbol.toStringTag,{value:"Module"}));function Oy({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(Ay,{ancestors:t,onOpenInEditor:s})]})}const i7=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestrySection:Oy},Symbol.toStringTag,{value:"Module"}));function Ry({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 l7=Object.freeze(Object.defineProperty({__proto__:null,DebugPropsChips:Ry},Symbol.toStringTag,{value:"Module"}));function Ey({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(Ry,{propsNames:h}),e.jsx(Oy,{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 c7=Object.freeze(Object.defineProperty({__proto__:null,DebugModalInfoPanel:Ey},Symbol.toStringTag,{value:"Module"}));function My({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 d7=Object.freeze(Object.defineProperty({__proto__:null,OpenInEditorErrorToast:My},Symbol.toStringTag,{value:"Module"}));function Iy({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}=t5(),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(Ty,{tag:t.element.tag,id:t.element.id,className:t.element.className,text:t.element.text,detectionMethod:t.detectionMethod,previewUrl:s}),e.jsx(Ey,{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(My,{error:h,onDismiss:p})]})}const u7=Object.freeze(Object.defineProperty({__proto__:null,DebugModal:Iy},Symbol.toStringTag,{value:"Module"}));function Dy(){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 h7=Object.freeze(Object.defineProperty({__proto__:null,DebugFreezePill:Dy},Symbol.toStringTag,{value:"Module"}));function Ly({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(Dy,{})]})}const p7=Object.freeze(Object.defineProperty({__proto__:null,DebugOverlay:Ly},Symbol.toStringTag,{value:"Module"}));function Fy(){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 m7=Object.freeze(Object.defineProperty({__proto__:null,InspectModeRibbon:Fy},Symbol.toStringTag,{value:"Module"}));function s5(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 zy({onDismiss:t}){return e.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:999998,background:"transparent"}})}const f7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBackdrop:zy},Symbol.toStringTag,{value:"Module"}));function $y({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 g7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchButton:$y},Symbol.toStringTag,{value:"Module"}));function By({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($y,{match:n,onOpen:s})},`${n.endpoint}${n.jsonPath}${r}`))})}const b7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchList:By},Symbol.toStringTag,{value:"Module"}));function qy({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:Hy(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(By,{matches:s,onOpen:r})]})}function Hy(t,s){return t.length<=s?t:t.slice(0,s-1)+"…"}const x7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBody:qy,truncate:Hy},Symbol.toStringTag,{value:"Module"}));function Wy({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 y7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardHeader:Wy},Symbol.toStringTag,{value:"Module"})),Ec=320,Mc=320,n5=8;function Gy({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}=s5(n,{width:c,height:i},{width:Ec,maxHeight:Mc,gap:n5});return e.jsxs(e.Fragment,{children:[e.jsx(zy,{onDismiss:a}),e.jsxs("div",{style:{position:"fixed",top:d,left:u,width:Ec,maxHeight:Mc,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(Wy,{onDismiss:a}),e.jsx(qy,{clickedText:t,matches:s,corpusEmpty:o,onOpenInPanel:r})]})]})}const v7=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCard:Gy},Symbol.toStringTag,{value:"Module"}));function Uy({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 j7=Object.freeze(Object.defineProperty({__proto__:null,LiveIframeHealthPill:Uy},Symbol.toStringTag,{value:"Module"}));function Yy(){const{projectDir:t,inContainer:s,loaded:n}=Gc();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 w7=Object.freeze(Object.defineProperty({__proto__:null,ConnectionIdentityLine:Yy},Symbol.toStringTag,{value:"Module"}));function Vy({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(Yy,{})]})})}const _7=Object.freeze(Object.defineProperty({__proto__:null,PreviewForwardPortNotice:Vy},Symbol.toStringTag,{value:"Module"}));function Ky(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 Ic(t,s){return(s==null?void 0:s.previewOrigin)??(t==null?void 0:t.previewOrigin)??null}function Jy(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 r5(t,s){if(Jy(t))return"unknown";try{return(await fetch(t,{credentials:"include",redirect:"manual",mode:"no-cors"})).type==="opaqueredirect"?"needs-signin":"authed"}catch{return Ky(t)?"unreachable":"unknown"}}function a5(t,s){const[n,r]=l.useState("unknown"),[a,o]=l.useState(0),i=l.useCallback(async()=>{const d=await r5(t);r(u=>(u==="needs-signin"&&d==="authed"&&o(h=>h+1),d)),d!=="unknown"&&!wt()&&yC(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 Dc(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 o5(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(Dc(m.data.payload)):m.data.type==="codeyam:debug:selected"&&i(Dc(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 i5=/^\/api\/mock-panel(\/.*)?$/;function l5(t,s){return t.toUpperCase()!=="GET"?!1:i5.test(s)}function c5(t){return Array.isArray(t)?t.filter(s=>s.consumedThisPageLoad&&!l5(s.method,s.pathPattern)).map(s=>({endpoint:`${s.method} ${s.pathPattern}`,body:s.body})):[]}async function d5(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 u5=12;function h5(t,s,n){if(s.length===0)return[];const r=[];return yo(t,s,n,"$",0,new Set,r),r}function p5(t,s){const n=[];for(const o of t)for(const i of h5(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 yo(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>=u5)&&!o.has(t)){if(o.add(t),Array.isArray(t))for(let d=0;d<t.length;d++)yo(t[d],s,n,`${r}[${d}]`,a+1,o,i);else if(c==="object")for(const[d,u]of Object.entries(t))yo(u,s,n,`${r}.${d}`,a+1,o,i);o.delete(t)}}const m5={backgroundColor:"#1e1e1e",backgroundImage:"conic-gradient(#262626 25%, #1e1e1e 0 50%, #262626 0 75%, #1e1e1e 0)",backgroundSize:"16px 16px"};function Xy({providerLabel:t,buildingScenarioName:s,buildingScenarioSlug:n,buildingScenarioDescription:r,buildingScreenshotPath:a,containerHeight:o,containerRef:i,containerWidth:c,currentHeight:d,currentWidth:u,emptyStateMessage:h,isFilled:p,onDismissBuildingOverlay:f,historicalScreenshotPath:m,historicalScenarioName:b,historicalHeading:g,historicalSubtext:x,onDismissHistoricalPreview:y,previewSlug:v,previewUrl:j,previewOrigin:w,scale:_,commandNonce:k}){var Je,Gt;const C=!!b&&!n,S=!!n||C,T=l.useRef(null),A=i??T,E=l.useRef(null),{status:N,restart:B}=x0();uP(N,B);const{isRestarting:q,isFailed:H,isStarting:R,isStopped:F}=MP(N),{stepState:P}=Cn(),$=$P((P==null?void 0:P.step)??null,(P==null?void 0:P.mode)??"ui"),M=(N==null?void 0:N.liveIframeHealthy)!==void 0,{reloadNonce:G,handleIframeLoad:Y,handleIframeError:Q}=mP((N==null?void 0:N.pid)??null,M,N==null?void 0:N.status),oe=(N==null?void 0:N.status)==="failed",{healthy:ne,failedProbeCount:V,reloadNonce:be,invalidate:le}=vP(j,oe),ce=pP(N==null?void 0:N.liveIframeHealthy,750),Z=NP(ne,ce),[z,D]=l.useState(0);l.useEffect(()=>y0(()=>{D(Fe=>Fe+1)}),[]),PP(N==null?void 0:N.sourceVersion,N==null?void 0:N.liveReloadEnabled);const{authState:L,recheck:te,remountNonce:W}=a5(w,j),K=l.useMemo(()=>Ky(w),[w]),se=CP({pidNonce:G,probeNonce:be+Z,draftNonce:z+W}),ie=se.gatedNonce,{errors:me,clear:ye}=AP(E,ie),{escaped:U,overlayErrors:Te,noteFrameLoad:de,clearEscape:ve}=dP({previewUrl:j,resetKey:ie,capturedErrors:me}),ke=EP(j,ie),we=l.useCallback(()=>{se.reset(),ye(),ve(),le()},[se,ye,ve,le]),Ae=l.useCallback(()=>{ye(),ve()},[ye,ve]),Ze=l.useCallback(()=>Ro(),[]),We=(N==null?void 0:N.devServerStartedSecsAgo)??null,ut=We!==null&&We<IP,Re=!!(N!=null&&N.startCommand),_t=_P({liveIframeHealthy:ce,previewReachable:(Je=N==null?void 0:N.previewProbe)==null?void 0:Je.reachable}),[ot,Wt]=l.useState(!1);l.useEffect(()=>{_t&&!ot&&Wt(!0)},[_t,ot]);const Et=_t||ot,ht=kP({hasDevServerConfigured:Re,hasServed:Et}),it=ht?j:"about:blank",kt=iy(it,ie,k),[ls,cs]=l.useState(null),ds=ht&&ls!==kt,xe=DP({hasDevServerConfigured:Re,probeHealthy:ne,backendRunning:(N==null?void 0:N.status)==="running",backendIframeHealthy:ce,isStarting:R,isRestarting:q,isFailed:H,isStopped:F,isPrePrototype:$,withinStartupGrace:ut,previewReachable:((Gt=N==null?void 0:N.previewProbe)==null?void 0:Gt.reachable)===!0,hasEverServed:Et}),Se=l.useRef(void 0);l.useEffect(()=>{var Ut;if(Se.current===xe)return;const Fe=Se.current;Se.current=xe,console.debug(`[preview-overlay] ${Fe===void 0?"(init)":Fe??"none"} → ${xe??"none"}`,{status:N==null?void 0:N.status,intendedRunning:N==null?void 0:N.intendedRunning,restartCount:N==null?void 0:N.restartCount,pid:N==null?void 0:N.pid,liveIframeHealthy:N==null?void 0:N.liveIframeHealthy,previewProbeReachable:(Ut=N==null?void 0:N.previewProbe)==null?void 0:Ut.reachable,devServerStartedSecsAgo:We,withinStartupGrace:ut,probeHealthy:ne,isStarting:R,isRestarting:q,isFailed:H,isStopped:F})},[xe,N,We,ut,ne,R,q,H,F]);const _e=N==null?void 0:N.portDiagnostic,Ne=(_e==null?void 0:_e.conflict)===!0,Ee=xe==="scaffolding"?HP((P==null?void 0:P.step)??null,(P==null?void 0:P.mode)??"ui").body:void 0,I=jP({active:xe==="reconnecting",trigger:V}),Ye=xe==="reconnecting"?wP(I):null,pt=Ee??Ye??void 0,Ce=V>=10,{isActive:Ve,hoveredElement:Be,selectedElement:Le,activate:bt,deactivate:Ke,clearSelection:je}=o5(E),mt=l.useCallback(()=>{Ve?Ke():bt()},[Ve,bt,Ke]),{entries:qe}=v0(v??null),{isActive:St,toggle:Ps}=hP({activate:bt,deactivate:Ke,clearSelection:je},G);l.useEffect(()=>(wl({isActive:St,previewSlug:v??null}),()=>{wl({isActive:!1,previewSlug:null})}),[St,v]),l.useEffect(()=>j0(()=>{Ps()}),[Ps]);const us=St&&Le?Le.element.text.trim():"",Ts=l.useMemo(()=>c5(qe),[qe]),Tn=l.useMemo(()=>!St||!us?[]:p5(Ts,us),[St,us,Ts]),An=l.useCallback(async Fe=>{je(),Ke();try{const As=await(await fetch("/api/scenarios")).json(),Os=Array.isArray(As)?As.find(Js=>Js.componentName===Fe):null;if(Os!=null&&Os.slug){const Js=$i(window.location),Xr=Nb(Os.slug,Js,null,0,w);window.history.pushState(null,"",Xr);return}}catch{}window.history.pushState(null,"","/entities")},[je,Ke,w]),On=l.useCallback(async(Fe,Ut)=>{try{await d5(Fe,Ut,j),je(),Ke()}catch(As){console.error("Failed to create debug plan:",As)}},[j,je,Ke]);return e.jsx("div",{ref:A,className:`relative flex-1 flex overflow-hidden ${p?"":"items-center justify-center p-8"}`,style:p?{backgroundColor:"#fff"}:m5,children:j?e.jsxs(e.Fragment,{children:[e.jsx(cy,{ref:E,currentHeight:d,currentWidth:u,isFilled:p,previewUrl:it,scale:_,iframeKey:kt,onLoad:()=>{if(ht){const Fe=de(E.current);Y(Fe??j),cs(kt)}},onError:Q}),!ht&&e.jsx(oy,{hasDevServerConfigured:Re}),ds&&e.jsx(dy,{}),!p&&e.jsx(vy,{previewUrl:j,description:r}),!p&&e.jsx(Uy,{healthy:ce,reason:(N==null?void 0:N.iframeLastError)??null,authNeeded:L==="needs-signin"}),L==="needs-signin"&&w&&e.jsx(fu,{previewOrigin:w,onRecheck:te}),L==="unreachable"&&K&&e.jsx(Vy,{hint:K,onRecheck:te}),Ve&&e.jsx(Ly,{hoveredElement:Be}),St&&e.jsx(Fy,{}),Le&&!St&&e.jsx(Iy,{element:Le,previewUrl:j,onClose:je,onGoToIsolated:An,onCreatePlan:On}),Le&&St&&e.jsx(Gy,{clickedText:us,matches:Tn,anchor:Le.element.boundingBox,corpusEmpty:Ts.length===0,onOpenInPanel:Fe=>{w0({routeKey:Fe.endpoint,jsonPath:Fe.jsonPath}),je()},onDismiss:je}),!S&&e.jsx(Py,{isActive:Ve,onToggle:mt,interactionAvailable:Jy(w)}),oe?e.jsx(Ny,{lastError:(N==null?void 0:N.lastError)??(N==null?void 0:N.lastExit)??"(no error message captured)",failureCount:(N==null?void 0:N.failureCount)??0,failedAtMs:N==null?void 0:N.failedAtMs,holder:N==null?void 0:N.holder,onRetry:B,onReap:async()=>{await fetch("/api/editor-dev-server/reap",{method:"POST",headers:{"Content-Type":"application/json"}})}}):Ne&&_e?e.jsx(Cy,{diagnostic:_e,onRetry:B}):xe&&(xe==="crashed"?e.jsx(Sy,{logs:(N==null?void 0:N.logs)??[],providerLabel:t}):e.jsx(py,{variant:xe,restartCount:(N==null?void 0:N.restartCount)??0,showRetry:Ce,onRetry:xe==="disconnected"?Ze:le,bodyOverride:pt})),e.jsx(yy,{tripped:se.tripped||U,errors:Te,recentReloads:se.recentReloads,serverHealthy:LP(N),onRetry:we,onClear:Ae,providerLabel:t}),ke.clickThroughBroken&&ke.status!==null&&e.jsx(uy,{url:j,status:ke.status,logLines:ke.logLines,onRetry:we}),n&&f&&e.jsx(xo,{containerHeight:o,containerWidth:c,onDismiss:f,scenarioName:s??null,screenshotPath:a??null,viewportHeight:d,viewportWidth:u}),C&&y&&e.jsx(xo,{containerHeight:o,containerWidth:c,heading:g??void 0,subtext:x??void 0,onDismiss:y,scenarioName:b??null,screenshotPath:m??null,viewportHeight:d,viewportWidth:u})]}):e.jsx(ay,{message:h})})}const k7=Object.freeze(Object.defineProperty({__proto__:null,PreviewCanvas:Xy},Symbol.toStringTag,{value:"Module"}));function Qy({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(Ht,{children:t})}):null]})}const S7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDescriptionCard:Qy},Symbol.toStringTag,{value:"Module"}));function Zy({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(Yi,{html:t,url:"",title:"Chosen design",viewport:s,theme:"light",darkVars:null})})]})}const N7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupChosenMockup:Zy},Symbol.toStringTag,{value:"Module"}));function ev({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:ev},Symbol.toStringTag,{value:"Module"}));function tv({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(Zy,{html:t,viewport:s})}),a&&e.jsx(ev,{assets:n})]})}const P7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignCard:tv},Symbol.toStringTag,{value:"Module"}));function sv(){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 T7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupHeader:sv},Symbol.toStringTag,{value:"Module"}));function f5(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 vo="#D7FF63",g5="var(--text-muted)";function nv({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:vo,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:vo,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:g5,strokeWidth:"1.5"})})}function rv({phase:t,status:s}){const n=s==="active"?vo: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(nv,{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 A7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressRow:rv,StatusIndicator:nv},Symbol.toStringTag,{value:"Module"}));function av({currentStep:t,mode:s}){const n=ok(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=f5(r,t);return e.jsx(rv,{phase:r,status:a},r.phaseId)})})})}const O7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressList:av},Symbol.toStringTag,{value:"Module"}));function b5(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(`
213
+ `)&&(s=s.slice(0,-1)),s}function ov({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(sv,{}),e.jsx(Qy,{prompt:b5(t)}),e.jsx(tv,{mockupHtml:r,mockupViewport:a,assets:o}),e.jsx(av,{currentStep:s,mode:n})]})}const R7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewView:ov},Symbol.toStringTag,{value:"Module"}));function x5(){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(Gi(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 iv(){const{prompt:t}=ny(),{stepState:s}=Cn(),{mockupHtml:n,mockupViewport:r,assets:a}=x5();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(ov,{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 E7=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewPane:iv},Symbol.toStringTag,{value:"Module"}));function y5(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-terminal`}function v5(t,s,n=1500){if(t<=0)return!1;const r=s-t;return r>=0&&r<=n}function lv({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 M7=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalHeader:lv},Symbol.toStringTag,{value:"Module"})),j5=1200,w5=1e3,_5=["\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
214
+ `);function cv(){const t=wt(),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]=gi(1200);function f(m){const b=a.current;(b==null?void 0:b.readyState)===WebSocket.OPEN&&b.send(new TextEncoder().encode(m))}return fi(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(v5(y.lastInjectMs??0,Date.now()))}catch{}};b();const g=window.setInterval(b,w5);return()=>{m=!0,window.clearInterval(g)}},[t]),l.useEffect(()=>{if(!s.current||o.current)return;o.current=!0,i.current=!1;const m=new Co.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),b=new Po.FitAddon;m.loadAddon(b),m.open(s.current),n.current=m,r.current=b;const g=To(m,s.current,{onCopy:()=>p()}),x=Ao(m,{sendInput:f});if(requestAnimationFrame(()=>{b.fit(),m.focus()}),t)return m.write(_5),u(!0),()=>{x(),g(),m.dispose(),o.current=!1};const y=()=>{if(i.current)return;const v=new WebSocket(y5());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,j5))}};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(lv,{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(qr,{})]})}const I7=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalPane:cv},Symbol.toStringTag,{value:"Module"}));function k5(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-browser`}function S5(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 N5(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 C5(t,s,n=1500){if(t<=0)return!1;const r=s-t;return r>=0&&r<=n}function tn(t,s){const n=`<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800" viewBox="0 0 1280 800">
215
+ <rect width="1280" height="800" fill="#0b0d12"/>
216
+ <rect width="1280" height="56" fill="#11141b"/>
217
+ <text x="28" y="35" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="20" font-weight="700">${s}</text>
218
+ ${t}
219
+ </svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(n)}`}function xt(t,s,n,r,a){return`
220
+ <text x="${t}" y="${s}" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">${r}</text>
221
+ <rect x="${t}" y="${s+10}" width="${n}" height="40" rx="6" fill="#171b24" stroke="#2a303c"/>
222
+ <text x="${t+14}" y="${s+36}" fill="#e7e9ee" font-family="ui-monospace, monospace" font-size="15">${a}</text>`}const P5={hosting:tn(`
223
+ <text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="28" font-weight="700">Production Deployment</text>
224
+ <rect x="28" y="160" width="1224" height="120" rx="10" fill="#12161f" stroke="#232a36"/>
225
+ <circle cx="60" cy="220" r="8" fill="#3ecf8e"/>
226
+ <text x="82" y="212" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="17">my-app.vercel.app</text>
227
+ <text x="82" y="238" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">Ready · deployed 2m ago · main@a1b2c3d</text>
228
+ <rect x="28" y="320" width="360" height="44" rx="8" fill="#D7FF63"/>
229
+ <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:tn(`
230
+ <text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">DNS Records — codeyam.com</text>
231
+ ${xt(28,180,300,"Type","CNAME")}
232
+ ${xt(360,180,420,"Name","www")}
233
+ ${xt(812,180,440,"Value","cname.vercel-dns.com")}
234
+ ${xt(28,280,300,"Type","A")}
235
+ ${xt(360,280,420,"Name","@")}
236
+ ${xt(812,280,440,"Value","76.76.21.21")}
237
+ <rect x="28" y="380" width="220" height="44" rx="8" fill="#D7FF63"/>
238
+ <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:tn(`
239
+ <rect x="440" y="200" width="400" height="380" rx="14" fill="#12161f" stroke="#232a36"/>
240
+ <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>
241
+ ${xt(472,300,336,"Email","you@example.com")}
242
+ ${xt(472,380,336,"Password","••••••••••")}
243
+ <rect x="472" y="470" width="336" height="44" rx="8" fill="#4c7fff"/>
244
+ <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:tn(`
245
+ <text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">App Information</text>
246
+ ${xt(28,180,560,"Name","CodeYam")}
247
+ ${xt(620,180,632,"Subtitle","Build code and data scenarios together")}
248
+ ${xt(28,280,1224,"Promotional Text","See your app in every state, before you ship it.")}
249
+ <rect x="28" y="400" width="200" height="44" rx="8" fill="#4c7fff"/>
250
+ <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:tn(`
251
+ <rect x="0" y="56" width="1280" height="3" fill="#D7FF63"/>
252
+ <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")},T5={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 A5(t){return P5[t]}function O5(t){return T5[t]}function dv({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 D7=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserHeader:dv},Symbol.toStringTag,{value:"Module"})),R5=1200,E5=1e3;function uv({demo:t="hosting",address:s,assistantNavigating:n,disconnected:r=!1}={}){const o=wt()||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?A5(t):null),[m,b]=l.useState(s??(o?O5(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 S=await C.json();if(w)return;x(C5(S.lastActMs??0,Date.now()))}catch{}};_();const k=window.setInterval(_,E5);return()=>{w=!0,window.clearInterval(k)}},[o]),l.useEffect(()=>{if(o)return;d.current=!1;const w=()=>{if(d.current)return;const _=new WebSocket(k5());c.current=_,_.onopen=()=>v(!0),_.onmessage=k=>{if(typeof k.data!="string")return;const C=S5(k.data);C&&(h.current={width:C.width,height:C.height},f(C.src))},_.onclose=()=>{v(!1),!d.current&&(u.current=window.setTimeout(w,R5))}};return w(),()=>{var _;d.current=!0,u.current!==null&&window.clearTimeout(u.current),(_=c.current)==null||_.close()}},[o]);function j(w,_){const k=c.current;if(!k||k.readyState!==WebSocket.OPEN)return;const C=_.currentTarget.getBoundingClientRect();k.send(N5({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(dv,{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 L7=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserPane:uv},Symbol.toStringTag,{value:"Module"}));function hv({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 F7=Object.freeze(Object.defineProperty({__proto__:null,ClientRoutingAdvisory:hv},Symbol.toStringTag,{value:"Module"})),M5="Seed failed — DB state is unknown",I5="Preview capture failed — the app's data was seeded";function pv({error:t,kind:s,onRetry:n}){const r=s==="device"?I5:M5;return e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 border-b border-[var(--accent-red)] bg-[var(--accent-red)]/10 px-4 py-2 text-sm text-[var(--accent-red)]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold",children:r}),e.jsx("div",{className:"truncate text-xs opacity-90",children:t})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(dt,{variant:"subtle",text:`${r}
253
+ ${t}`,label:"Copy",className:"shrink-0 rounded border border-[var(--accent-red)] px-2 py-1 text-xs hover:bg-[var(--accent-red)] hover:text-white disabled:opacity-50 disabled:cursor-not-allowed"}),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 z7=Object.freeze(Object.defineProperty({__proto__:null,SeedErrorBanner:pv},Symbol.toStringTag,{value:"Module"}));function mv({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 $7=Object.freeze(Object.defineProperty({__proto__:null,SeedLoadingOverlay:mv},Symbol.toStringTag,{value:"Module"}));function fv(t){return t.state==="preflight-running"||t.state==="booting-simulator"||t.state==="simulator-booted"||t.state==="building-app"}const D5=1500;function gv({stackId:t,pollMs:s=D5,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||fv(r);return{status:r,posting:o,buttonDisabled:u,start:d}}function bv({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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dt,{variant:"subtle",text:t,label:"Copy"}),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 B7=Object.freeze(Object.defineProperty({__proto__:null,BuildLogsModal:bv},Symbol.toStringTag,{value:"Module"}));function jo({stackId:t,pollMs:s,onStateChange:n}){const[r,a]=l.useState(!1),{status:o,start:i,buttonDisabled:c}=gv({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(xv,{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(bv,{stderrTail:o.stderrTail,onClose:()=>a(!1)}):null]})}function xv({status:t}){const s=Ki(t);return e.jsx("span",{className:"text-xs opacity-80","data-testid":"simulator-status-pill",children:s})}function Ki(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 (${yv(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 yv(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 q7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorLauncherControls:jo,StatusPill:xv,formatElapsed:yv,pillText:Ki},Symbol.toStringTag,{value:"Module"}));function vv({stackId:t,pollMs:s,onStateChange:n}){const{status:r,start:a,buttonDisabled:o}=gv({stackId:t,pollMs:s,onStateChange:n}),i=fv(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?Ki(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 H7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorNotBootedPrompt:vv},Symbol.toStringTag,{value:"Module"}));function ir({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 W7=Object.freeze(Object.defineProperty({__proto__:null,DeviceFrameImage:ir},Symbol.toStringTag,{value:"Module"}));function jr({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 G7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorFrameNotice:jr},Symbol.toStringTag,{value:"Module"}));function jv({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(jr,{currentWidth:t,currentHeight:s,isFilled:n,scale:r,title:o,hint:i})}const U7=Object.freeze(Object.defineProperty({__proto__:null,NoBootedSimulatorPlaceholder:jv},Symbol.toStringTag,{value:"Module"})),L5=1500;function wv(t=L5){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 F5=700;function _v({currentHeight:t,currentWidth:s,isFilled:n,scale:r,pollMs:a=F5,onError:o,deviceLabel:i="iOS Simulator",scenarioScreenshotSrc:c=null,bootState:d}){const u=Ab({pollMs:a,paused:!!c||!!d,onError:o}),{state:h,frameToken:p}=d??u,f=wv();if(c)return e.jsx(ir,{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(ir,{src:b,currentWidth:s,currentHeight:t,isFilled:n,scale:r})}return e.jsx(jv,{currentWidth:s,currentHeight:t,isFilled:n,scale:r,variant:h.kind})}if(h.kind==="loading")return e.jsx(jr,{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(jr,{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(ir,{src:m,currentWidth:s,currentHeight:t,isFilled:n,scale:r})}const Y7=Object.freeze(Object.defineProperty({__proto__:null,SimulatorPreviewFrame:_v},Symbol.toStringTag,{value:"Module"}));function kv({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:k,onDismissHistoricalPreview:C,previewSeeding:S,previewSeedError:T,previewSeedErrorKind:A,onRetrySeed:E,currentScenario:N,scenarioGroups:B,onShowScenarioPreview:q,commandNonce:H,previewOrigin:R,isNarrow:F=!1,onBack:P,onPlanChange:$,onDesignConfirmed:M}){const{config:G}=gt(),Y=rt(G==null?void 0:G.provider),[Q,oe]=l.useState(!1),ne=!!P,be=(N?Do(N,B??[]):[]).length>1,[le,ce]=l.useState(!0),[Z,z]=l.useState(!1),D=ne?le:Z,L=ne?ce:z,te=ne||be,W=D&&!!N&&(ne||be),[K,se]=l.useState({state:"idle"}),{containerRef:ie,containerSize:me,scale:ye}=_C({currentHeight:f,currentWidth:p,isFilled:u}),U=Tb(),de=AC(R===vs),[ve,ke]=l.useState(!1);l.useEffect(()=>{wt()||xC(T??null)},[T]);const we=EC(N,o),Ae=we?os(we,N==null?void 0:N.screenshotCapturedAtMs):null,Ze=da(U.kind),We=!!Ae,ut=Ab({paused:!Ze||We}),Re=ut.state.kind==="no-device"||ut.state.kind==="xcode-missing",_t=U.fallbackKind==="iframe"&&U.fallbackPort!==null,ot=Ze&&!We&&_t&&Re,Wt=U.fallbackPort??0,ht=(N?Pb(N,Wt,R):"")||Bi("/",{appPort:Wt,currentPort:typeof window<"u"?$i(window.location):0,previewOrigin:R}),it=r?zi(r):"",kt=it==="/results"||it.startsWith("/results/"),ls=it==="/plan-preview",cs=it==="/design-exploration",ds=it==="/setup-terminal",xe=it==="/setup-browser";if(ds)return e.jsx(cv,{});if(xe)return e.jsx(uv,{});if(ls)return e.jsx(ry,{});if(kt)return e.jsx(Yb,{});if(cs)return e.jsx(Dx,{onDesignConfirmed:M});if(s&&!r&&!U.loading&&!da(U.kind))return e.jsx(iv,{});const Se=K.state==="app-launched";return e.jsxs("div",{"data-preview-pane":"true",className:"flex-1 flex flex-col min-w-0",children:[e.jsx(ey,{viewports:a,active:o,onChange:i,currentWidth:p,currentHeight:f,previewUrl:r,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:h,containerWidth:(me==null?void 0:me.width)??null,containerHeight:(me==null?void 0:me.height)??null,onCustomSizeChange:m,currentScenario:N??null,scenarioGroups:B??[],onShowScenarioPreview:q??(()=>{}),onCreateStateRequest:()=>oe(!0),isNarrow:F,onBack:P,onPlanChange:$,onToggleStatesModal:te?()=>L(_e=>!_e):void 0,statesModalOpen:D}),T?e.jsx(pv,{error:T,kind:A,onRetry:E}):null,de&&!ve?e.jsx(hv,{onDismiss:()=>ke(!0)}):null,W&&N?e.jsx(ud,{currentScenario:N,scenarioGroups:B??[],onSelect:_e=>(q??(()=>{}))(_e),onCreateNew:()=>oe(!0),onClose:()=>L(!1)}):null,e.jsxs("div",{className:"relative flex-1 flex flex-col min-h-0",children:[Ze&&!ot?e.jsxs(e.Fragment,{children:[e.jsx(Lx,{deviceLabel:ua(U.kind),actions:e.jsx(jo,{onStateChange:se})}),e.jsx("div",{ref:ie,className:"relative flex-1 flex overflow-hidden items-center justify-center p-8",style:{backgroundColor:"#1e1e1e"},children:Se?e.jsx(_v,{currentHeight:f,currentWidth:p,isFilled:u,scale:ye,deviceLabel:ua(U.kind),scenarioScreenshotSrc:Ae,bootState:ut}):e.jsx(vv,{onStateChange:se})})]}):e.jsxs(e.Fragment,{children:[ot?e.jsx(mu,{deviceLabel:ua(U.kind),actions:e.jsx(jo,{})}):null,e.jsx(Xy,{providerLabel:Y,containerRef:ie,containerHeight:me==null?void 0:me.height,containerWidth:me==null?void 0:me.width,currentHeight:f,currentWidth:p,emptyStateMessage:t??"Select a scenario to preview",isFilled:u,previewSlug:ot?(N==null?void 0:N.slug)??n:n,previewUrl:ot?ht:r,previewOrigin:R,scale:ye,buildingScenarioSlug:b,buildingScreenshotPath:g,buildingScenarioName:x,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:j,historicalScenarioName:w,historicalHeading:_,historicalSubtext:k,onDismissHistoricalPreview:C,commandNonce:H})]}),S?e.jsx(mv,{label:da(U.kind)?"Loading scenario on device…":void 0}):null]}),Q?e.jsx(Vb,{onClose:()=>oe(!1),providerLabel:Y}):null]})}const V7=Object.freeze(Object.defineProperty({__proto__:null,PreviewPanel:kv},Symbol.toStringTag,{value:"Module"})),wo="reset";function Sv({busy:t,onCancel:s,onConfirm:n}){const[r,a]=l.useState(""),o=r.trim().toLowerCase()===wo;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:wo})," 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 K7=Object.freeze(Object.defineProperty({__proto__:null,RESET_CONFIRM_WORD:wo,ResetBuildConfirmModal:Sv},Symbol.toStringTag,{value:"Module"}));function z5(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{scenariosVersion:i}=Ns(),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(No);s(qx(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:B5(s.componentSurfaceReason)}}return{entities:[],unsurfacedPages:[],componentSurfaceReason:null}}function B5(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 q5(){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}=Ns(),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(No):[]}))),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 Lc(t){const s=new Map;for(const n of t){const r=H5(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 H5(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 Nv(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 Cv(t,s,n){return n==="backend"?[]:t.map(r=>({...r,scenarios:r.scenarios.filter(wr)})).filter(r=>r.scenarios.length>0)}function Pv(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 W5(t){return t.reduce((s,n)=>s+n.scenarios.length,0)}const G5=3e3;function U5(){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}=Ns(),_=l.useCallback(async(N=!1)=>{var R;(R=x.current)==null||R.abort();const B=new AbortController;x.current=B;const{signal:q}=B;N&&(v.current=!0,o(!0));const H=!N&&j.current!==null;H||(r(!0),c(null));try{if(!N&&!H)try{const M=await fetch("/api/test-results/summary",{signal:q});if(M.ok){const G=await M.json();G.running?p(G.currentRunner??null):G.stats&&(m(G.stats),g(G.coverage??null))}}catch{}let F,P;if(H){F=j.current;const M=await fetch("/api/test-results",{signal:q});if(!M.ok)throw new Error(`test-results: HTTP ${M.status}`);P=await M.json()}else if(N){const M=await fetch("/api/test-results/refresh",{method:"POST",signal:q});if(!M.ok)throw new Error(`test-results: HTTP ${M.status}`);P=await M.json(),F=j.current??[]}else{const[M,G]=await Promise.all([fetch("/api/tests",{signal:q}),fetch("/api/test-results",{signal:q})]);if(!M.ok)throw new Error(`tests: HTTP ${M.status}`);if(!G.ok)throw new Error(`test-results: HTTP ${G.status}`);F=Lc(await M.json()),P=await G.json(),j.current=F}if(p(P.currentRunner??null),P.running&&v.current){y.current=setTimeout(()=>_(!1),G5);return}const $=v.current;if(v.current=!1,$){const M=await fetch("/api/tests",{signal:q});M.ok&&(F=Lc(await M.json()),j.current=F)}s(F),u(P.cached??!1),g(P.coverage??null),m(null),r(!1),o(!1)}catch(F){if(F instanceof DOMException&&F.name==="AbortError")return;v.current=!1,c(F instanceof Error?F.message:"Failed to load tests"),r(!1),o(!1)}},[]);l.useEffect(()=>(j.current=null,_(),()=>{var N;(N=x.current)==null||N.abort(),y.current&&clearTimeout(y.current)}),[_,w]);const{total:k,passed:C,failed:S,ignored:T,discovered:A}=l.useMemo(()=>Pv(t),[t]),E=l.useCallback(()=>{v.current||_(!0)},[_]);return{groups:t,loading:n,refreshing:a,error:i,cached:d,currentRunner:h,summaryStats:f,coverage:b,totalTests:k,passedTests:C,failedTests:S,ignoredTests:T,discoveredTests:A,reload:_,refresh:E}}function Ji(t,s){return t.filter(n=>n.appDir===s)}function Tv(t,s){return s?t.find(n=>n.route===s)??null:null}function Av(t,s,n,r=null){const a=Cv(t,s,n);return K5(a,r)}function Y5(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=>_o(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 V5(t){return(t==null?void 0:t.defaultScenarioSlug)??null}function Ov(t,s,n=null){const r=t.find(a=>a.type==="web");return r?Av(s,r.dir,r.type,n):null}function K5(t,s){const n=t.flatMap(d=>d.scenarios.filter(u=>wr(u)).map(u=>({route:d.route,scenario:u})));if(n.length===0)return null;const r=Kn(n.filter(({route:d,scenario:u})=>d==="/"&&_o(u)),s);if(r)return r.scenario.slug;const a=Kn(n.filter(({route:d})=>d==="/"),s);if(a)return a.scenario.slug;const o=Kn(n.filter(({scenario:d})=>_o(d)),s);if(o)return o.scenario.slug;const i=Math.min(...n.map(({route:d})=>d.length)),c=Kn(n.filter(({route:d})=>d.length===i),s);return(c==null?void 0:c.scenario.slug)??null}function Kn(t,s){return t.find(({scenario:n})=>J5(n,s))??t[0]??null}function J5(t,s){return s?t.dimensions.length===0||t.dimensions.includes(s):!0}function _o(t){return/\bhome\b/i.test(t.name)}function Fc(t){return new Set(t.flatMap(s=>s.scenarios.map(n=>n.slug)))}function Ta({selectedApp:t,appRouteEntities:s,scenarioGroups:n,defaultScreenSize:r=null}){return t?Y5(s)??Av(n,t.dir,t.type,r):null}function X5({apps:t,hasExplicitAppSelection:s,scenarioGroups:n,defaultScreenSize:r=null}){return s||t.length===0||n.length===0?null:Ov(t,n,r)}function zc(t){return V5(t)}function Q5({apps:t,routeEntities:s,selectedApp:n,appRouteEntities:r}){if(n)return r;const a=t.find(o=>o.type==="web");return a?Ji(s,a.dir):[]}function Z5({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 e4({previewRouteEntities:t,path:s}){var r;const n=zi(s);return((r=Tv(t,n))==null?void 0:r.defaultScenarioSlug)??null}function t4(t){return t.startsWith("/scenario/")||an(t)}function s4(t){return t4(t)?!1:t==="/"||t==="/apps"||t==="/apps/"}function n4(t,s,n=""){const r=ha(n),[a,o]=l.useState(r.selectedAppDir),[i,c]=l.useState(r.selectedEntityHash);l.useEffect(()=>{const v=ha(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=ha(n);if(v.selectedAppDir||v.selectedEntityHash||!s4(n))return;const j=pa(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=>Ma(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?Ji(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(pa(v))}function b(){o(null),c(null),f("/apps")}function g(v){const j=h.find(k=>k.route===v);if(!j)return;const w=Ma(j),_=rd(j);!w||!_||(c(w),f(_))}function x(v){c(v),f(`/entities/${v}`)}function y(){c(null),f(a?pa(a):"/apps")}return{selectedApp:u,appRouteEntities:h,selectedEntityHash:i,selectedRouteEntity:p,selectApp:m,deselectApp:b,selectRoute:g,selectEntity:x,deselectRoute:y}}function r4(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}=n4(t,s,a),_=l.useMemo(()=>Fc(m),[m]),k=l.useMemo(()=>Fc(g?[g]:[]),[g]),C=l.useMemo(()=>Ta({selectedApp:f,appRouteEntities:m,scenarioGroups:n,defaultScreenSize:o}),[m,o,n,f]),S=l.useMemo(()=>zc(g),[g]),T=l.useMemo(()=>f?Nv(r,f.dir):[],[r,f]);l.useEffect(()=>{if(h.current)return;if(c!=null&&c.current){h.current=!0;return}if(!i)return;const R=X5({apps:t,scenarioGroups:n,hasExplicitAppSelection:!!f,defaultScreenSize:o});R&&(u(R),h.current=!0)},[t,o,n,f,i,c]),l.useEffect(()=>{if(f){if(p.current){p.current=!1;return}if(g){if(!S||d&&k.has(d))return;u(S);return}C&&(d&&_.has(d)||u(C))}},[C,S,d,f,_,g,k]);function A(R){x(R);const F=t.find($=>$.dir===R);if(!F)return;const P=Ta({selectedApp:F,appRouteEntities:Ji(s,F.dir),scenarioGroups:n,defaultScreenSize:o});u(P)}function E(){y(),u(Ov(t,n,o))}function N(R){v(R);const F=zc(Tv(m,R));u(F)}const B=l.useCallback(R=>{p.current=!0,u(R)},[]);function q(){if(w(),!f)return;const R=Ta({selectedApp:f,appRouteEntities:m,scenarioGroups:n,defaultScreenSize:o});R&&u(R)}function H(R){j(R)}return{selectedApp:f,appRouteEntities:m,appTestGroups:T,selectedEntityHash:b,selectedRouteEntity:g,previewSlug:d,setPreviewSlug:u,setPreviewSlugExplicit:B,selectApp:A,deselectApp:E,selectRoute:N,selectEntity:H,deselectRoute:q}}const a4=1e3;function o4(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,a4)}}return c(),()=>{i=!1}},[])}function i4(){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(()=>gw(t),[t]);return{graph:t,entityLookup:i,loading:n,error:a}}function l4(t){return t==="/design-exploration"}function c4(t,s,n){return t.startsWith("http")||t?t:n?`${n}/results`:`http://127.0.0.1:${s}/results`}function d4(t,s,n){return t.startsWith("http")||t?t:n?`${n}/plan-preview`:`http://127.0.0.1:${s}/plan-preview`}function Rv(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 u4({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"?c4(t,a,o):n==="plan-preview"?d4(t,a,o):t.startsWith("http")||l4(t)?t:o?`${o}${t}`:`http://127.0.0.1:${a}${t}`:r?Pb({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 h4(t,s=Date.now()){const n=t.includes("?")?"&":"?";return`${t}${n}_cb=${s}`}function ko(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 p4({apps:t,appRouteEntities:s,directPreviewPath:n,fallbackPort:r,previewKind:a,previewOrigin:o,previewSlug:i,routeEntities:c,scenarioGroups:d,selectedApp:u,selectedRouteEntity:h}){const p=Rv(d,i),f=Q5({apps:t,routeEntities:c,selectedApp:u,appRouteEntities:s}),m=Z5({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=wr(p)?"application":"component":m&&(b="application");const g=u4({directPreviewPath:n,fallbackPreviewPath:m,previewKind:b,selectedScenario:p,port:r,previewOrigin:o});return{selectedScenario:p,previewRouteEntities:f,fallbackPreviewPath:m,resolvedPreviewKind:b,basePreviewUrl:g}}function m4({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=Rv(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=Cb(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=e4({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 f4(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 g4=[{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 b4(t,s){const n=Object.entries(t);if(n.length===0)return g4;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 x4=1500;function y4({enabled:t,pollMs:s=x4}){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 v4({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 j4({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(t0({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 w4=3;function _4({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),[k,C]=l.useState(null),[S,T]=l.useState(null),[A,E]=l.useState(null),[N,B]=l.useState(()=>Date.now()),[q,H]=l.useState(0),R=l.useRef(null),F=l.useRef(!1),P=l.useMemo(()=>b4(m,r),[r,m]);l.useEffect(()=>{j.current||r&&(v(r),j.current=!0)},[r]);const $=l.useMemo(()=>w!==null&&k!==null?{name:"Custom",width:w,height:k}:P.find(de=>de.name===y)??P[0]??{name:"Desktop",width:1440,height:900},[y,k,w,P]),M=wt(),G=d==="CodeYam Editor",{basePreviewUrl:Y,fallbackPreviewPath:Q,previewRouteEntities:oe,resolvedPreviewKind:ne,selectedScenario:V}=l.useMemo(()=>p4({apps:t,appRouteEntities:s,directPreviewPath:S,fallbackPort:o,previewKind:A,previewOrigin:c,previewSlug:u,routeEntities:h,scenarioGroups:p,selectedApp:b,selectedRouteEntity:g}),[t,s,S,o,A,c,u,h,p,b,g]),be=l.useMemo(()=>Y?h4(Y,N):"",[Y,N]),le=l.useCallback(de=>{v(de),_(null),C(null)},[]),ce=l.useCallback((de,ve)=>{_(de),C(ve)},[]),Z=l.useCallback(de=>{x(de),T(null),E(null),B(Date.now());const ve=ko(de,p);if(!ve)return;const ke=f4(y,w,k,ve,P);ke!==null&&(v(ke),_(null),C(null))},[y,k,w,p,x,P]),z=l.useCallback((de,ve)=>{const ke=(ve==null?void 0:ve.retriesLeft)??w4,we=m4({allowEditorRoutePreview:G,command:de,configLoaded:n,previewRouteEntities:oe,scenarioGroups:p,scenarioDeferAvailable:ke>0});if(we.viewportName&&v(we.viewportName),we.clearCustomSize&&(_(null),C(null)),we.type==="show-scenario"){Z(we.scenarioSlug),H(Ae=>Ae+1);return}if(we.type==="defer"){R.current={command:de,retriesLeft:ke};return}if(we.type==="refresh"){B(Date.now()),H(Ae=>Ae+1);return}we.type!=="ignore"&&(we.type==="show-path"&&(E(we.previewKind),T(we.path),F.current=we.preserveDirectPreviewPathOnSlugChange,typeof we.previewSlug=="string"?x(we.previewSlug):we.previewSlug===null&&x(null)),B(Date.now()),H(Ae=>Ae+1))},[n,G,oe,p,x,Z]);l.useEffect(()=>{if(!n)return;const de=R.current;de&&(R.current=null,z(de.command,{retriesLeft:de.retriesLeft-1}))},[n,p,z]),l.useEffect(()=>{if(!(!u||S===null)){if(F.current){F.current=!1;return}T(null),E(null),B(Date.now())}},[S,u]);const D=l.useMemo(()=>ne==="results"||ne==="plan-preview"?S:ne==="application"?S??(V==null?void 0:V.url)??Q:null,[S,Q,ne,V==null?void 0:V.url]),L=l.useCallback(()=>{B(Date.now())},[]),[te,W]=l.useState(0),K=l.useCallback(()=>{W(de=>de+1)},[]);v4({isInIframe:M,hydrated:a,persistedPath:D,previewKind:ne,resolvedViewport:$,selectedScenario:V?{id:V.id??null,slug:V.slug}:null});const ie=y4({enabled:i==="simulator-ios"||i==="simulator-android"}),{seeding:me,seedError:ye,seedErrorKind:U}=j4({deviceLaunchGeneration:ie,seedRetryToken:te,isInIframe:M,onActivated:L,previewKind:ne,previewMedium:i,scenariosLoaded:f,selectedScenario:V?{slug:V.slug,scenarioType:V.scenarioType,componentName:V.componentName??null}:null}),Te=l.useCallback(de=>{T(de),E(de?"application":null),B(Date.now())},[]);return{viewports:P,resolvedViewport:$,previewUrl:be,handleViewportChange:le,handleCustomSizeChange:ce,showScenarioPreview:Z,handlePreviewCommand:z,setPreviewPath:Te,previewSeeding:me,previewSeedError:ye,previewSeedErrorKind:U,retrySeed:K,commandNonce:q}}function k4({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 S4({isInIframe:t,onConverge:s}){const n=l.useRef(s);n.current=s,l.useEffect(()=>{if(!t)return rP(()=>{fetch("/api/editor-preview-state").then(r=>r.json()).then(r=>{r&&(r.scenarioSlug||r.path)&&n.current(r)}).catch(()=>{}).finally(()=>{Ro()})})},[t])}function N4({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 C4(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 P4(){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 Ev(t){return t===null||t.slug===null||t.slug==="feature-complete"}function T4({showPostPushModal:t,stepState:s,dismissModal:n}){const r=l.useRef(!1);l.useEffect(()=>{if(!t){r.current=!1;return}if(Ev(s)){r.current=!0;return}r.current&&(s==null?void 0:s.slug)!=null&&(n(),r.current=!1)},[t,s,n])}function A4(){const[t,s]=l.useState(!1),n=l.useCallback(()=>{s(!0)},[]),r=l.useCallback(()=>{s(!1)},[]);return{showPlanCompleteModal:t,onPlanCompleteCommand:n,dismissPlanCompleteModal:r}}function O4(){const{showBuildTab:t}=Ii(typeof window>"u"?"/":window.location.pathname),{config:s}=gt(),[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 Ei()}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 Mi({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 R4({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 E4({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 M4(t,s,n){return t.map(r=>{const a=Nv(s,r.dir),o=Cv(n,r.dir,r.type),{total:i,passed:c,failed:d,ignored:u,discovered:h}=Pv(a),p=W5(o);return{app:r,tests:{total:i,passed:c,failed:d,ignored:u,discovered:h},scenarios:{total:p,thumbnails:I4(o)}}})}function I4(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 D4(t,s){return t==null?null:Math.min(1,Math.max(.04,t/ci(s)))}function L4(t,s){return t==null||t===0?null:`${t} / ${ci(s)}: ${li(t,s)}`}const F4="Your app will display here once set up.",z4="Loading your app…",$4="Setting up your project…",B4="Select a scenario to preview",q4="No preview is available for this project.";function H4({configLoading:t,hasNoApps:s,hasStepState:n,hasPreviewableApp:r,setupInProgress:a,hasCaptureFrame:o}){return t?z4:a&&!o?$4:s&&!n?F4:r?B4:q4}const W4=["web","mobile"];function G4(t){return W4.includes(t)}function U4(t,s){return s?{scenarioSlug:t,path:s}:{scenarioSlug:t}}function Y4(t,s){return t==="needs-login"&&!s}function V4(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 K4="The app is being edited",J4="Live preview will load when the build agent is idle",X4="Showing a saved version",Q4="This is a past version of this scenario";function Z4({shot:t,isLatest:s,liveScenario:n,isAgentBuilding:r}){if(s&&n&&!r)return{kind:"live",slug:n.slug};const[a,o]=r?[K4,J4]:[X4,Q4];return{kind:"historical",screenshotPath:t.screenshotPath??null,scenarioName:t.name,heading:a,subtext:o}}function Mv(t){return!t.hasActiveSession&&!t.isAgentBuilding&&!t.showPostPushModal&&t.launchingPlanSlug===null&&!t.submittingBuildPrompt&&!t.stepStateFeature&&!t.buildLaunchModalDismissed}function eT(t){return t.activeTab==="build"&&Mv(t)}const tT=900*1e3;function sT(){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(),tT);return()=>clearInterval(r)},[n]),{update:t}}function nT(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 rT=4e3,aT=2;function Iv({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=rt(s),[v,j]=l.useState(!1);l.useEffect(()=>{if(t!=="unknown"){j(!1);return}const C=window.setTimeout(()=>j(!0),rT);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 k=m?e.jsx(k0,{provider:s,onAuthenticated:w,onClose:()=>b(!1)}):null;if(t==="unknown"){const C=o==="probe-timeout"&&d>=aT,S=r===!1||o==="cli-not-found";return!C&&!S&&(c||!v)||u?null:S?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"})]}),k]})}return e.jsx(_0,{provider:s,credsPresent:n,reason:o,expiresAt:i,sessionOngoing:h,onAuthenticated:p,onAuthorized:f})}const J7=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthGate:Iv},Symbol.toStringTag,{value:"Module"}));function Dv({update:t}){const{copied:s,copy:n}=vn();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 X7=Object.freeze(Object.defineProperty({__proto__:null,UpdateAvailableBanner:Dv},Symbol.toStringTag,{value:"Module"})),oT=300,$c=150;function iT(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<$c?n(0):m>b-$c?n(b):n(Math.max(oT,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 lT=3e3;function cT({hot:t,isInIframe:s,reload:n=()=>window.location.reload(),sustainedDisconnectMs:r=lT}){return()=>{}}function dT(){l.useEffect(()=>cT({hot:void 0,isInIframe:wt()}),[])}const uT=5e3;function Bc(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 hT(t){return S0()?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 qc(){await hT(uT),un("\x1B"),await Bc(oo),un("/clear\r"),await Bc(oo),un("/codeyam-plan\r")}function pT(){fetch("/api/clear-build-agent-session",{method:"POST"}).catch(()=>{})}function mT(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 fT=120*1e3,Lv=1500;class gT{constructor(s,n,r=X){Ct(this,"deferred",!1);Ct(this,"userActiveSinceLastOutput",!1);Ct(this,"lastActivitySource",null);Ct(this,"lastActivityAt",null);Ct(this,"lastNotificationTime",null);Ct(this,"actions");Ct(this,"env");Ct(this,"now");Ct(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<Lv;if(n&&r&&c)return this.userActiveSinceLastOutput=!1,this.log("suppressed-user-active",i),"suppressed";if(a!==null&&a<fT)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 bT(t,s){return new gT({playSound:Bp,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 xT(t,s){return t==="hook-stop"?s.idleOnStop:s.idleOnNotification}const yT=600*1e3,vT=3e3;function jT({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(zp),[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),k=l.useRef(null),C=l.useRef(r??!1);C.current=r??!1,mT(b),w.current||(w.current=bT(d,j));const S=l.useCallback(P=>{m(P),$p(P)},[]),T=l.useCallback(P=>{v.current!==null&&(clearTimeout(v.current),v.current=null,X("debounce-cancelled",{trigger:P}))},[]),A=l.useCallback(P=>{x.current&&X("idle-cleared",{trigger:P}),g(!1),x.current=!1,k.current=null,j.current&&(j.current.close(),j.current=null)},[]),E=l.useCallback(P=>{var $;if(!xT(P,f)){X("idle-suppressed-by-pref",{source:P});return}X("ws-idle-received",{buildTabActive:u.current,source:P}),($=h.current)==null||$.call(h),T("re-arm-on-idle"),v.current=setTimeout(()=>{var Q;v.current=null;const M=_.current,G=M===null?null:Date.now()-M,Y=M!==null&&Date.now()-M>yT;X("debounce-resolved",{suppressedForOvernight:Y,msHidden:G,buildTabActive:u.current}),Y||(Q=w.current)==null||Q.onIdle(f,u.current),g(!0),x.current=!0,k.current=Date.now(),y.current=!1,X("agent-currently-idle-set",{suppressedForOvernight:Y}),u.current&&lt()},Lv)},[f,T]),N=l.useCallback(()=>{var P,$,M;(P=p.current)==null||P.call(p),T("agent-active"),($=w.current)==null||$.onActive(),(M=w.current)==null||M.resetActivityFlag(),x.current&&C.current&&k.current!==null&&Date.now()-k.current>vT&&A("remote-resume")},[T,A]),B=l.useCallback(()=>{var P,$;T("user-input"),x.current&&((P=w.current)==null||P.onUserEngagement(),($=w.current)==null||$.reportUserActivity("terminal-input"),y.current=!0,A("user-input"))},[T,A]),q=l.useCallback(P=>{var $;P==="build"&&(T("navigate-build"),x.current&&(($=w.current)==null||$.onUserEngagement(),y.current=!0,A("navigate-build"))),o(P)},[o,T,A]),H=l.useCallback(()=>{var P;T("dismiss-banner"),(P=w.current)==null||P.onUserEngagement(),y.current=!0,A("dismiss-banner")},[T,A]),R=l.useCallback(()=>{var P;T("stop-building"),(P=w.current)==null||P.onUserEngagement(),y.current=!0,A("stop-building")},[T,A]);l.useEffect(()=>{function P(){var V;x.current&&(y.current||(T("ack-notification"),(V=w.current)==null||V.onUserEngagement(),y.current=!0,X("notification-acknowledged",{trigger:"user-return"})))}function $(V){var be;x.current&&u.current&&document.hasFocus()&&(document.hidden||((be=w.current)==null||be.onUserEngagement(),y.current=!0,A(V)))}function M(V){var be;document.hasFocus()&&P(),(be=w.current)==null||be.reportUserActivity(V)}const G=()=>M("mousemove"),Y=()=>M("mousedown"),Q=()=>M("keydown");function oe(){document.hidden?_.current===null&&(_.current=Date.now()):(_.current=null,P(),$("tab-visible-on-build"))}function ne(){var V;P(),$("window-focus-on-build"),(V=w.current)==null||V.reportUserActivity("focus")}return window.addEventListener("focus",ne),document.addEventListener("visibilitychange",oe),document.addEventListener("mousemove",G),document.addEventListener("mousedown",Y),document.addEventListener("keydown",Q),()=>{T("unmount"),window.removeEventListener("focus",ne),document.removeEventListener("visibilitychange",oe),document.removeEventListener("mousemove",G),document.removeEventListener("mousedown",Y),document.removeEventListener("keydown",Q)}},[T,A]);const F=l.useRef(a??0);return l.useEffect(()=>{var M;const P=a??0;if(P===F.current)return;F.current=P;const $=u.current&&document.hasFocus();X("feature-complete-fast-path",{skipBecauseWatching:$}),!$&&((M=w.current)==null||M.onIdle(f,!1),g(!0),x.current=!0,k.current=Date.now(),y.current=!1)},[a,f]),l.useEffect(()=>{var P,$;if((P=w.current)==null||P.onBuildTabChange(s,f),s)return x.current&&typeof document<"u"&&document.hasFocus()&&!document.hidden&&(($=w.current)==null||$.onUserEngagement(),y.current=!0,A("build-tab-active-on-focus")),lt()},[s,f,A]),{buildIdle:b,bannerVisible:b,notifSettings:f,handleSettingsChange:S,handleAgentIdle:E,handleAgentActive:N,handleUserInput:B,handleNavigateToTab:q,dismissIdleBanner:H,clearIdleForStopBuilding:R}}const wT=1e4;function _T(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()},wT);return()=>clearInterval(f)},[c,i]),{buildSessionLive:c,agentActivelyBuilding:c&&(!!o||s||n||r!==null),transitionBuildSessionLive:h}}function Hc(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 kT=new Set(["ui-confirm-plan","backend-confirm-plan","present-live","backend-confirm","ui-present","backend-review"]);function ST(t,s){return t&&kT.has(t)?"needs-input":s?"waiting":"building"}function NT(){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
254
+
255
+ ${a.trim()}
256
+
257
+ ${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 CT(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(`
258
+
259
+ `));return`mailto:${n}?subject=${r}&body=${a}`}const PT=["bug","suggestion","question","praise"];function Fv({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}=NT(),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:PT.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(He,{text:u,className:"text-sm text-red-400",rowClassName:"mb-3"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-green-400 text-center",children:"Transcript downloaded!"}),e.jsx("a",{href:CT(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 Q7=Object.freeze(Object.defineProperty({__proto__:null,SendTranscriptModal:Fv},Symbol.toStringTag,{value:"Module"}));function zv({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 Z7=Object.freeze(Object.defineProperty({__proto__:null,BuildShaBadge:zv},Symbol.toStringTag,{value:"Module"}));function TT(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/raw-terminal`}function $v(){if(wt())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]=gi(1200);function u(h){const p=r.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&p.send(new TextEncoder().encode(h))}return fi(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 Co.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),p=new Po.FitAddon;h.loadAddon(p),h.open(t.current),s.current=h,n.current=p;const f=To(h,t.current,{onCopy:()=>d()}),m=Ao(h,{sendInput:u});requestAnimationFrame(()=>{p.fit(),h.focus()});const b=new WebSocket(TT());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
260
+ \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(qr,{})]})}const eD=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalEmulator:$v},Symbol.toStringTag,{value:"Module"}));function Bv({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($v,{})})]})}):null}const tD=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalModal:Bv},Symbol.toStringTag,{value:"Module"}));function AT(){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),Dm);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>pr){o(`${m.name} is larger than the ${pr/(1024*1024)} MB cap`);return}try{const m=await Promise.all(f.map(async y=>({filename:y.name||"unnamed",contentBase64:await Lm(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&&zm(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 qv({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 sD=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropOverlay:qv},Symbol.toStringTag,{value:"Module"}));function Hv({message:t}){return e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-[80] px-4 py-2 rounded-md text-sm",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",color:"var(--text-danger, #ff6b6b)"},"data-testid":"global-file-drop-error",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:t}),e.jsx(dt,{variant:"icon",text:t})]})})}const nD=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropToast:Hv},Symbol.toStringTag,{value:"Module"}));function Wv({paths:t,onClose:s}){const{sendToAgent:n,agentReady:r}=N0(),[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(Fm).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 rD=Object.freeze(Object.defineProperty({__proto__:null,FileDropConfirmModal:Wv},Symbol.toStringTag,{value:"Module"}));let Aa=null;function OT(t){if(typeof t!="object"||t===null)return null;const s=t.buildCommitSha;return typeof s!="string"||s===""||s==="unknown"?null:s}async function RT(){try{const t=await fetch("/api/health");return t.ok?OT(await t.json()):null}catch{return null}}function ET(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!0;return Aa||(Aa=RT()),Aa.then(r=>{n&&s(r)}),()=>{n=!1}},[]),{sha:t}}function MT(){var bl,xl,yl;dT();const{sha:t}=ET(),s=I0(),{state:n,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,probeInFlight:u,probeAttempts:h,backendFieldAbsent:p,refresh:f}=C0(),{update:m}=sT(),{sessionInfo:b,refetch:g}=Pi({pollIntervalMs:15e3}),x=(b==null?void 0:b.agentBrokerLive)??!1,y=Y4(n,x),{activeTab:v,buildActivated:j,planActivated:w,navigateToTab:_,deactivateBuild:k}=Ii(s,y,n==="needs-login"&&!x),[C,S]=l.useState(!1),T=l.useCallback(()=>{S(!0)},[]),{arm:A,navigateToTabUser:E}=nT(y,_,T),N=l.useCallback(()=>E("build"),[E]),[B,q]=l.useState(!1),[H,R]=l.useState(!1),F=wt(),[P,$]=l.useState(F),M=l.useRef(!1),G=l.useCallback(()=>$(!0),[]),[Y,Q]=l.useState(F),[oe,ne]=l.useState(0),[V,be]=l.useState(0),[le,ce]=l.useState(0),[Z,z]=l.useState(0),[D,L]=l.useState(null),{showPostPushModal:te,onFeatureCompleteCommand:W,onAgentIdle:K,onAgentActive:se,dismissModal:ie}=P4(),{showPlanCompleteModal:me,onPlanCompleteCommand:ye,dismissPlanCompleteModal:U}=A4(),[Te,de]=l.useState(!1),[ve,ke]=l.useState(!1),[we,Ae]=l.useState(!1),[Ze,We]=l.useState(!1),[ut,Re]=l.useState(!1),[_t,ot]=l.useState(!1),Wt=l.useCallback(()=>{Ae(!0)},[]),Et=l.useCallback(()=>{Ae(!1)},[]),{plans:ht,loading:it,error:kt,refetch:ls}=_g(),{plans:cs}=Tg(),{reorderPlans:ds}=Lg(ls),{launchPrompt:xe,launching:Se,error:_e}=O4(),[Ne,Ee]=l.useState(null),{stepState:I,refetch:Ye}=Cn();T4({showPostPushModal:te,stepState:I,dismissModal:ie});const pt=l.useRef(null),{leftWidth:Ce,handleMouseDown:Ve}=iT(pt),Be=Rm(768),[Le,bt]=l.useState("editor"),Ke=l.useCallback(J=>{bt(J),J==="editor"&&(lt(),typeof window<"u"&&window.dispatchEvent(new Event("resize")))},[]),[je,mt]=l.useState(!1),qe=v==="home";l.useEffect(()=>{!qe&&je&&mt(!1)},[qe,je]);const{entityLookup:St}=i4(),{groups:Ps,loading:us,refreshing:Ts,currentRunner:Tn,coverage:An,refresh:On}=U5(),{groups:Je,loading:Gt,reload:Fe}=z5(),{routeEntities:Ut,unsurfacedPages:As,componentSurfaceReason:Os,loading:Js,error:Xr}=q5(),{config:ee,apps:Mt,loading:Rn,refetch:Rs}=gt(),Gv=Tb(),hs=l.useMemo(()=>M4(Mt,Ps,Je),[Mt,Je,Ps]),{saved:Uv}=Up(),Yv=Yp({appStatsLength:hs.length,configLoading:Rn,scenariosLoading:Gt,setupAnswersSaved:Uv,hasStepState:!!I}),Qr=qe&&!je&&!Yv,Vv=Be||Qr?((bl=pt.current)==null?void 0:bl.clientWidth)??(typeof window<"u"?window.innerWidth:Ce):Ce,Kv=l.useCallback(()=>{q(J=>!J)},[]),Jv=l.useCallback(()=>{R(J=>!J)},[]),{selectedApp:ps,appRouteEntities:Xi,appTestGroups:Xv,selectedEntityHash:Qv,selectedRouteEntity:Qi,previewSlug:Xs,setPreviewSlugExplicit:Zv,selectApp:Zr,deselectApp:ea,selectRoute:ta,selectEntity:ej,deselectRoute:tj}=r4(Mt,Ut,Je,Ps,s,(ee==null?void 0:ee.defaultScreenSize)??null,Y,M),{viewports:sj,resolvedViewport:Qs,previewUrl:nj,handleViewportChange:rj,handleCustomSizeChange:sa,showScenarioPreview:Zs,handlePreviewCommand:et,setPreviewPath:na,previewSeeding:aj,previewSeedError:oj,previewSeedErrorKind:ij,retrySeed:lj,commandNonce:cj}=_4({apps:Mt,appRouteEntities:Xi,configLoaded:!Rn,hydrated:P,port:(ee==null?void 0:ee.port)??5173,previewMedium:Gv.kind,previewOrigin:Ic(ee,ps),projectTitle:(ee==null?void 0:ee.projectTitle)??null,routeEntities:Ut,screenSizes:(ee==null?void 0:ee.screenSizes)??{},defaultScreenSize:(ee==null?void 0:ee.defaultScreenSize)??null,scenarioGroups:Je,scenariosLoaded:!Gt,selectedApp:ps,selectedRouteEntity:Qi,previewSlug:Xs,setPreviewSlug:Zv});l.useEffect(()=>{qe&&je&&Qs.name==="Desktop"&&R(!0)},[qe,je,Qs.name]);const{isAgentBuilding:It,isAgentBuildingRef:ra,buildingScenarioSlug:aa,onAgentIdle:Zi,onAgentActive:el,guardScenarioSelect:tl,clearBuildingOverlay:Nt,forceIdle:sl}=R4({onTransitionToLive:Zs}),{planActive:dj,planIdle:uj}=E4({chatOpen:Te}),En=(b==null?void 0:b.resumeMode)==="resume"||(b==null?void 0:b.resumeMode)==="handoff",{launchPlan:Mn,launchingSlug:oa,error:hj}=Eg({launchAnchored:En||!!(I!=null&&I.feature)}),{buildSessionLive:pj,agentActivelyBuilding:In,transitionBuildSessionLive:ms}=_T({isAgentBuilding:It,submittingBuildPrompt:Se,launchingPlanSlug:oa,sessionInfo:b,stepFeature:(I==null?void 0:I.feature)??null,refetchSessionInfo:g});l.useEffect(()=>{It&&b&&!b.hasSession&&!b.agentBrokerLive&&sl()},[It,b,sl]),l.useEffect(()=>{Kr({hasActiveSession:En,isAgentBuilding:It,stepStateFeature:(I==null?void 0:I.feature)??null})},[En,It,I==null?void 0:I.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 mj=l.useCallback(()=>{K(),Zi()},[K,Zi]),fj=l.useCallback(()=>{se(),el()},[se,el]),Dn=(ee==null?void 0:ee.provider)??P0,nl=rt(Dn),{buildIdle:Ln,bannerVisible:gj,notifSettings:rl,handleSettingsChange:al,handleAgentIdle:bj,handleAgentActive:xj,handleUserInput:yj,handleNavigateToTab:ol,dismissIdleBanner:vj,clearIdleForStopBuilding:Fn}=jT({agentName:nl,isBuildTabActive:v==="build",isAgentBuilding:It,buildSessionLive:pj,featureCompleteKey:le,navigateToTab:E,onAgentIdleImmediate:mj,onAgentActiveImmediate:fj}),il=l.useMemo(()=>ST(I==null?void 0:I.slug,Ln),[I==null?void 0:I.slug,Ln]),ll=I?ak(I.step,I.mode):null,cl=l.useMemo(()=>D4(I==null?void 0:I.step,I==null?void 0:I.mode),[I==null?void 0:I.step,I==null?void 0:I.mode]),dl=I?L4(I.step,I.mode):null,jj=((xl=cs[0])==null?void 0:xl.title)??null,ul=l.useCallback(J=>{Ee(null),!tl(J)&&(Zs(J),qe&&mt(!0))},[tl,Zs,qe]),wj=l.useCallback(J=>{const Ge=V4(J.name,Je),fs=Z4({shot:{name:J.name,screenshotPath:J.screenshotPath},isLatest:J.isLatest,liveScenario:Ge,isAgentBuilding:It});if(fs.kind==="live"){Ee(null),Zs(fs.slug);return}Ee({screenshotPath:fs.screenshotPath,scenarioName:fs.scenarioName,heading:fs.heading,subtext:fs.subtext})},[It,Je,Zs]),_j=l.useCallback(()=>{Ee(null)},[]),Dt=l.useMemo(()=>ko(aa,Je),[aa,Je]),kj=((yl=Dt==null?void 0:Dt.screenshotPaths)==null?void 0:yl[0])??null,Sj=(Dt==null?void 0:Dt.name)??null,Nj=(Dt==null?void 0:Dt.description)??null,Cj=l.useCallback(J=>{switch(J.type){case"preview":("scenarioSlug"in J||"scenarioId"in J)&&Fe(),et(J);break;case"showResults":Nt(),Fe(),ne(Ge=>Ge+1),(I==null?void 0:I.mode)==="backend"&&et({path:"/results",dimension:"Desktop"});break;case"hideResults":be(Ge=>Ge+1);break;case"featureComplete":Nt(),W(),ce(Ge=>Ge+1),Rs(),Ye(),Hc({isAgentBuilding:ra.current,trigger:"feature-complete",transitionBuildSessionLive:ms});break;case"planComplete":ye(),Rs(),Hc({isAgentBuilding:ra.current,trigger:"plan-complete",transitionBuildSessionLive:ms});break;case"launchPlan":Mn(J.slug,J.title),z(Ge=>Ge+1);break;case"requestCredential":L({serviceName:J.serviceName,envVar:J.envVar,topic:J.topic,docsUrl:J.docsUrl});break}},[Nt,et,ra,Mn,W,ye,Rs,Ye,Fe,I,ms]);o4(Cj,l.useCallback(()=>{window.location.reload()},[]));const zn=(I==null?void 0:I.slug)==="ui-confirm-plan"||(I==null?void 0:I.slug)==="backend-confirm-plan",ia=l.useRef(null);l.useEffect(()=>{if(!I||!zn){ia.current=null;return}ia.current!==I.step&&(ia.current=I.step,et({path:"/plan-preview",dimension:"Desktop"}))},[I,zn,et]);const la=l.useRef(null);l.useEffect(()=>{if(!I||I.mode!=="backend"||I.step<2||zn){la.current=null;return}la.current!==I.step&&(la.current=I.step,et({path:"/results",dimension:"Desktop"}))},[I,zn,et]);const ca=l.useRef(!1);l.useEffect(()=>{(I==null?void 0:I.slug)==="ui-confirm-plan"?ca.current=!0:ca.current&&(ca.current=!1,na(null))},[I,na]);const Pj=l.useCallback(async()=>{ie(),S(!0),await V2({provider:Dn,renameLabel:(I==null?void 0:I.feature)??void 0,caller:"post-push-modal",bypassLiveGuard:!0}),lt()},[ie,Dn,I]),Tj=l.useCallback(()=>{ie(),lt()},[ie]),Aj=l.useCallback(async()=>{window.dispatchEvent(new CustomEvent("build-session-stopped")),await U2(),ie(),_("home"),k(),ms(!1,"stop-building"),Nt(),Fn(),S(!1),g()},[ie,_,k,ms,Nt,Fn,g]),Oj=l.useCallback(async()=>{ot(!0),window.dispatchEvent(new CustomEvent("build-session-stopped")),await Y2(),ot(!1),Re(!1),_("home"),k(),ms(!1,"reset-everything"),Nt(),Fn(),S(!1),g()},[_,k,ms,Nt,Fn,g]),Rj=l.useCallback(()=>{de(!0),qc(),U(),lt()},[U]),Ej=l.useCallback(()=>{de(!0),U(),lt()},[U]),Mj=l.useCallback(()=>{U(),qc().finally(()=>{de(!1),pT()})},[U]),Ij=l.useCallback(()=>{ke(!0)},[]),Dj=l.useCallback(()=>{ke(!1)},[]),Lj=l.useCallback(async(J,Ge)=>{await Mn(J,Ge)&&(ke(!1),S(!0),ie(),g())},[Mn,ie,g]),Fj=l.useCallback(async J=>{await xe(J)&&(S(!0),g())},[xe,g]),zj=l.useCallback(()=>{S(!0)},[]),hl={hasActiveSession:En,isAgentBuilding:It,showPostPushModal:te,launchingPlanSlug:oa,submittingBuildPrompt:Se,stepStateFeature:(I==null?void 0:I.feature)??null,buildLaunchModalDismissed:C},$j=Mv(hl),pl=eT({activeTab:v,...hl}),Bj=pl||ve;l.useEffect(()=>{v==="build"&&g()},[v,g]),l.useEffect(()=>{v==="home"&&(Rs(),f())},[v,Rs,f]);const qj=l.useCallback(async(J,Ge)=>{Nt(),et(U4(J,Ge))},[Nt,et]),Hj=l.useCallback(J=>{et({...J.scenarioSlug?{scenarioSlug:J.scenarioSlug}:{},...J.path?{path:J.path}:{},...J.dimension?{dimension:J.dimension}:{}})},[et]),{requestRestore:Wj,onAdoptSettledEmpty:ml}=N4({restoredRef:M,initiallySettled:F,apply:Hj}),fl=l.useCallback(J=>{C4(J,{handlePreviewCommand:et,handleCustomSizeChange:sa})},[sa,et]),Gj=l.useCallback(()=>{ml(),Q(!0)},[ml]);k4({isInIframe:F,scenariosLoaded:!Gt,restoredRef:M,onAdopt:fl,onHydrated:G,onSettledEmpty:Gj}),S4({isInIframe:F,onConverge:fl});const Uj=l.useMemo(()=>({apps:Mt,isSingleApp:Mt.length===1,onSelectApps:ea,onSelectApp:Zr,onSelectRoute:ta}),[Mt,ea,Zr,ta]),Yj=l.useMemo(()=>ps?hs.find(J=>J.app.dir===ps.dir)??null:null,[hs,ps]),Vj=e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"12px 28px 0"},children:e.jsx(Ri,{staleness:null,backendOutOfDate:p})}),e.jsx("div",{style:{padding:"12px 28px 0"},children:e.jsx(Dv,{update:m})}),e.jsx(Iv,{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:N}),hs.length>0&&e.jsx("div",{style:{padding:"10px 28px 0"},children:e.jsx("div",{style:{width:"100%",maxWidth:1e3,marginInline:"auto"},children:e.jsx(Gp,{settings:rl,onChange:al,providerLabel:nl})})}),e.jsx(xg,{selectedApp:ps,projectTitle:(ee==null?void 0:ee.projectTitle)??null,admin:(ee==null?void 0:ee.admin)??!1,isBuilding:In,buildingLabel:(I==null?void 0:I.feature)??null,buildingStepLabel:ll,buildingStepIndicator:dl,buildingStatus:il,buildingProgress:cl,lastBuiltLabel:jj,plansCount:ht.length,onNavigateToPlan:()=>_("plan"),onNavigateToBuild:()=>E("build"),onResetBuild:()=>Re(!0),onBackToProjects:Mt.length>1?ea:void 0,launcherUrl:(ee==null?void 0:ee.launcherUrl)??null,projectCount:(ee==null?void 0:ee.projectCount)??0,onOpenSetupBrowser:ee!=null&&ee.setupBrowserEnabled?()=>et({path:"/setup-browser",dimension:"Desktop"}):void 0,appDetailProps:{navContext:Uj,routeEntities:Xi,unsurfacedPages:As,componentSurfaceReason:Os,routesLoading:Js,routesError:Xr,selectedEntityHash:Qv,selectedRouteEntity:Qi,testGroups:Xv,selectedSlug:Xs,entityLookup:St,allScenarios:Je.flatMap(J=>J.scenarios),onSelectScenario:ul,onSelectRoute:ta,onSelectEntity:ej,onBackToRoutes:tj,onScenariosChanged:Fe,coverage:An,showProjectBand:Mt.length===1,stats:Yj,testsLoading:us,testsRefreshing:Ts,onRunTests:On,currentRunner:Tn},appOverviewProps:{projectTitle:(ee==null?void 0:ee.projectTitle)??"Project",projectDescription:(ee==null?void 0:ee.projectDescription)??null,stats:hs,coverage:An,onSelectApp:Zr,configLoading:Rn,scenariosLoading:Gt,testsLoading:us,testsRefreshing:Ts,onRunTests:On,currentRunner:Tn,stepState:I,onPreviewUrl:na,onComplete:async()=>{await Rs(),console.info("[EditorShell] questionnaire complete; arming pending build-nav",{providerAuthState:n,buildBlocked:y}),A()},onOpenBuildTab:()=>E("build"),isBuilding:In,buildingLabel:(I==null?void 0:I.feature)??null,buildingStepLabel:ll,buildingStepIndicator:dl,buildingStatus:il,buildingProgress:cl,onResetBuild:()=>Re(!0)}})]}),Kj=hs.some(J=>G4(J.app.type)),Jj=Je.reduce((J,Ge)=>J+Ge.scenarios.length,0),gl=!!I&&!Gt&&Jj===0,Xj=wv(),Lt=AT();return e.jsx(T0,{children:e.jsxs(A0,{openPicker:Lt.openPicker,children:[e.jsx(wg,{splitRef:pt,isCollapsed:B,hidePreview:Qr,onHomeLivePageBack:qe&&je?()=>mt(!1):void 0,onResizeStart:Ve,isNarrow:Be,mobilePane:Le,onMobilePaneChange:Ke,isAgentBuilding:In,buildIdle:Ln,leftPane:e.jsx(Sb,{activeTab:v,onSendTranscript:Wt,appTabContent:Vj,awaitingPlanLaunchChoice:Bj,buildActivated:j,planActivated:w,buildIdle:Ln,isAgentBuilding:In,planActive:dj,planIdle:uj,bannerVisible:gj,onDismissIdleBanner:vj,hideResultsCommandKey:V,leftWidth:Vv,fullWidth:Be||Qr,navigateToTab:ol,onAgentActive:xj,onAgentIdle:bj,onUserInput:yj,notifSettings:rl,onSettingsChange:al,provider:Dn,onRestorePreview:Wj,onResultsScenarioSelect:qj,previewSlug:Xs,showPostPushModal:te,completionModalPermitted:Ev(I),onStartNextFeature:Pj,onContinueInSession:Tj,onStopBuilding:Aj,showResultsCommandKey:oe,planChatOpen:Te,onPlanChatOpenChange:de,showPlanCompleteModal:me,onCreateNewPlan:Rj,onContinueSession:Ej,onViewPlans:Mj,pendingPlans:ht,onSelectPlan:Ij,selectPlanOpen:ve,onPickPlan:Lj,onCancelSelectPlan:Dj,launchingPlanSlug:oa,planLaunchError:hj,prototypeLaunchSignal:Z,showBuildLaunchModal:pl,buildLaunchGateArmed:$j,onSubmitBuildPrompt:Fj,submittingBuildPrompt:Se,buildPromptError:_e,onStartBlankBuild:zj,pendingPlansLoading:it,pendingPlansError:kt,onReorderPlans:ds,buildDisabled:y,onPreviewScreenshot:wj,projectTitle:(ee==null?void 0:ee.projectTitle)??null}),previewPane:e.jsx(kv,{emptyStateMessage:H4({configLoading:Rn,hasNoApps:hs.length===0,hasStepState:!!I,hasPreviewableApp:Kj,setupInProgress:gl,hasCaptureFrame:Xj.available}),projectSetupInProgress:gl,previewSlug:Xs,previewUrl:nj,viewports:sj,activeViewport:Qs.name,onViewportChange:rj,isCollapsed:B,onToggleCollapsed:Kv,isNarrow:Be,onBack:qe&&je?()=>mt(!1):void 0,onPlanChange:qe&&je?()=>ol("plan"):void 0,isFilled:H,onToggleFilled:Jv,currentWidth:Qs.width,currentHeight:Qs.height,onCustomSizeChange:sa,buildingScenarioSlug:aa,buildingScreenshotPath:kj,buildingScenarioName:Sj,buildingScenarioDescription:Nj,onDismissBuildingOverlay:Nt,historicalScreenshotPath:(Ne==null?void 0:Ne.screenshotPath)??null,historicalScenarioName:(Ne==null?void 0:Ne.scenarioName)??null,historicalHeading:(Ne==null?void 0:Ne.heading)??null,historicalSubtext:(Ne==null?void 0:Ne.subtext)??null,onDismissHistoricalPreview:_j,previewSeeding:aj,previewSeedError:oj,previewSeedErrorKind:ij,onRetrySeed:lj,currentScenario:ko(Xs,Je),scenarioGroups:Je,onShowScenarioPreview:ul,commandNonce:cj,previewOrigin:Ic(ee,ps),onDesignConfirmed:()=>E("build")})}),we?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(Fv,{featureName:(I==null?void 0:I.feature)??null,onClose:Et})}):null,e.jsx(Bv,{isOpen:Ze,onClose:()=>We(!1)}),e.jsx(zv,{sha:t,onClick:()=>We(!0)}),e.jsx(qv,{visible:Lt.dragActive}),e.jsx("input",{ref:Lt.fileInputRef,type:"file",multiple:!0,onChange:Lt.handlePickerChange,style:{display:"none"},"data-testid":"global-file-picker-input"}),Lt.error?e.jsx(Hv,{message:Lt.error}):null,Lt.pendingPaths?e.jsx(Wv,{paths:Lt.pendingPaths,onClose:Lt.clearPending}):null,ut?e.jsx(Sv,{busy:_t,onCancel:()=>Re(!1),onConfirm:()=>void Oj()}):null,D?e.jsx(Vr,{target:D,onStored:()=>L(null),onClose:()=>L(null)}):null]})})}const aD=Object.freeze(Object.defineProperty({__proto__:null,EditorShell:MT},Symbol.toStringTag,{value:"Module"}));export{Yt as $,Xo as A,au as B,Pr as C,Ix as D,he as E,Wv as F,Uc as G,Yc as H,s_ as I,Vc as J,Kc as K,Xt as L,lu as M,cr as N,Jc as O,fu as P,cd as Q,hy as R,Uo as S,Ar as T,ud as U,nu as V,ld as W,o_ as X,id as Y,Bo as Z,za as _,Rr as a,Ue as a$,Zn as a0,xs as a1,bs as a2,gs as a3,Vt as a4,yt as a5,pu as a6,uu as a7,La as a8,Td as a9,mo as aA,kx as aB,dx as aC,cx as aD,lx as aE,ix as aF,ax as aG,Ui as aH,hx as aI,mg as aJ,qf as aK,uo as aL,ho as aM,qs as aN,Hf as aO,Ny as aP,Dx as aQ,Kb as aR,hi as aS,rs as aT,zf as aU,rx as aV,nx as aW,ro as aX,is as aY,$f as aZ,Mo as a_,mu as aa,qo as ab,Ff as ac,ct as ad,xv as ae,nv as af,gh as ag,fh as ah,mh as ai,Kh as aj,Zt as ak,Ft as al,ae as am,pe as an,ss as ao,Dv as ap,Ri as aq,rn as ar,yn as as,Bf as at,on as au,O as av,ib as aw,Cf as ax,Cy as ay,Cg as az,Wa as b,pv as b$,$o as b0,ns as b1,ru as b2,vy as b3,_r as b4,xx as b5,bx as b6,$s as b7,qr as b8,Qe as b9,sn as bA,ly as bB,Pe as bC,js as bD,Cx as bE,ed as bF,Rx as bG,Ox as bH,$e as bI,vt as bJ,$t as bK,nt as bL,Yo as bM,nd as bN,td as bO,oy as bP,Xe as bQ,By as bR,$y as bS,Wy as bT,qy as bU,zy as bV,Gy as bW,uy as bX,Fy as bY,dy as bZ,mv as b_,kr as ba,_n as bb,ph as bc,Or as bd,Ie as be,re as bf,Bx as bg,Tx as bh,Zc as bi,hm as bj,Cr as bk,Lu as bl,ux as bm,Hs as bn,Nx as bo,Qc as bp,np as bq,cp as br,lp as bs,op as bt,ap as bu,rp as bv,ai as bw,Bt as bx,sd as by,Du as bz,LO as c,qi as c$,Vf as c0,bd as c1,xd as c2,gd as c3,pd as c4,fd as c5,At as c6,di as c7,pg as c8,vd as c9,Xp as cA,vu as cB,xu as cC,gu as cD,Ba as cE,bu as cF,ig as cG,eg as cH,tg as cI,sg as cJ,og as cK,ng as cL,rg as cM,lg as cN,ug as cO,ag as cP,cg as cQ,dg as cR,Pn as cS,Mb as cT,Gb as cU,qb as cV,Ib as cW,Db as cX,Fb as cY,zb as cZ,lo as c_,Vd as ca,Fa as cb,Yd as cc,Io as cd,zv as ce,vr as cf,my as cg,gy as ch,by as ci,xy as cj,fy as ck,yy as cl,hv as cm,py as cn,Sy as co,wy as cp,jy as cq,_y as cr,ky as cs,hg as ct,sm as cu,Zp as cv,Qp as cw,Jp as cx,Kp as cy,Vp as cz,Xh as d,Sf as d$,$b as d0,Bb as d1,Ob as d2,Oi as d3,Hb as d4,Wb as d5,Rb as d6,Ub as d7,Wf as d8,Mf as d9,Bv as dA,Hm as dB,jb as dC,vb as dD,kb as dE,wb as dF,_b as dG,Hv as dH,qv as dI,yb as dJ,ts as dK,rb as dL,ab as dM,ob as dN,Nf as dO,eb as dP,sb as dQ,Zg as dR,Qg as dS,tb as dT,nb as dU,Jg as dV,Xg as dW,Yr as dX,Ig as dY,Dg as dZ,Mg as d_,Lf as da,Yx as db,Vi as dc,Vx as dd,Jx as de,Gx as df,Wx as dg,Hx as dh,bo as di,Zx as dj,Qx as dk,Vb as dl,Xx as dm,Ux as dn,Kx as dp,ey as dq,Im as dr,Mm as ds,qm as dt,Bm as du,dv,uv as dw,lv as dx,cv as dy,$v as dz,Mu as e,Id as e$,wf as e0,xf as e1,Ni as e2,bf as e3,_f as e4,vf as e5,yf as e6,jf as e7,gf as e8,Ci as e9,fo as eA,Fx as eB,yu as eC,zd as eD,Cd as eE,Pd as eF,Nd as eG,db as eH,Of as eI,Rf as eJ,yd as eK,Lo as eL,ad as eM,Kd as eN,Jd as eO,Qd as eP,Zd as eQ,eu as eR,tu as eS,su as eT,Fo as eU,Gd as eV,Hd as eW,qd as eX,Bd as eY,Wd as eZ,Ud as e_,Si as ea,Li as eb,qg as ec,Wg as ed,ao as ee,$g as ef,Ug as eg,Kg as eh,zg as ei,Vg as ej,Yg as ek,Fg as el,lb as em,Fi as en,pb as eo,fb as ep,hb as eq,gb as er,$x as es,zx as et,Xn as eu,hd as ev,_d as ew,jd as ex,kd as ey,MT as ez,Eu as f,pm as f$,Fd as f0,Ld as f1,Md as f2,Dd as f3,Od as f4,Ad as f5,Ho as f6,Ha as f7,Cu as f8,Pu as f9,sy as fA,ty as fB,ry as fC,Yb as fD,cy as fE,ay as fF,Xy as fG,Af as fH,vg as fI,Ls as fJ,bm as fK,gm as fL,pi as fM,Ex as fN,_x as fO,Ax as fP,Px as fQ,Sx as fR,yx as fS,mx as fT,jx as fU,Yi as fV,wx as fW,ex as fX,fm as fY,Xa as fZ,mm as f_,_u as fa,Ou as fb,Nu as fc,wu as fd,Da as fe,Jn as ff,zo as fg,qt as fh,xm as fi,Lx as fj,jr as fk,jv as fl,jo as fm,bv as fn,Uy as fo,rv as fp,av as fq,ev as fr,Zy as fs,tv as ft,Qy as fu,sv as fv,Sv as fw,Mx as fx,iv as fy,ov as fz,er as g,sp as g$,um as g0,vm as g1,ym as g2,ub as g3,Ap as g4,Tp as g5,Pp as g6,Cp as g7,Np as g8,Sp as g9,dh as gA,ih as gB,ah as gC,Yh as gD,Uh as gE,Gh as gF,Wh as gG,Hh as gH,$h as gI,zh as gJ,Vu as gK,Ya as gL,Vh as gM,Ua as gN,jp as gO,vp as gP,yp as gQ,xp as gR,bp as gS,gp as gT,Va as gU,fp as gV,pp as gW,hp as gX,$r as gY,up as gZ,dp as g_,kp as ga,_p as gb,wp as gc,Fh as gd,Lh as ge,Dh as gf,Ih as gg,Mh as gh,Eh as gi,Rh as gj,Oh as gk,Ah as gl,Th as gm,Ph as gn,Ch as go,Nh as gp,kh as gq,_h as gr,wh as gs,jh as gt,vh as gu,xh as gv,bh as gw,yh as gx,hh as gy,uh as gz,pa as h,Uf as h$,Jh as h0,zu as h1,Fu as h2,Gu as h3,Uu as h4,Yu as h5,cu as h6,$a as h7,du as h8,hu as h9,Nm as hA,Sm as hB,km as hC,Jf as hD,Qf as hE,Xf as hF,Yf as hG,yr as hH,My as hI,Dy as hJ,Ry as hK,Oy as hL,Ay as hM,Ly as hN,Ey as hO,Ty as hP,Iy as hQ,Py as hR,xo as hS,Nr as hT,wd as hU,Wo as hV,Wm as hW,Om as hX,Pf as hY,Tm as hZ,_m as h_,Iu as ha,Ja as hb,Lp as hc,Gp as hd,ii as he,qp as hf,Rp as hg,Ka as hh,Ep as hi,Mp as hj,Ip as hk,Br as hl,Dp as hm,Tr as hn,Tf as ho,Kf as hp,jg as hq,bb as hr,cb as hs,Sb as ht,wg as hu,yg as hv,xg as hw,Cm as hx,tr as hy,Pm as hz,kv as i,KA as i$,wm as i0,Ef as i1,jm as i2,Ru as i3,ju as i4,Vy as i5,Yy as i6,gg as i7,Me as i8,Zh as i9,Pt as iA,Ir as iB,th as iC,dr as iD,ei as iE,Ga as iF,rh as iG,sh as iH,eh as iI,nh as iJ,ir as iK,vv as iL,_v as iM,QO as iN,o6 as iO,nO as iP,t6 as iQ,dI as iR,i6 as iS,bO as iT,PI as iU,O8 as iV,C6 as iW,X7 as iX,XA as iY,QA as iZ,VA as i_,ep as ia,tp as ib,Wu as ic,Vr as id,Iv as ie,cm as ig,lm as ih,dm as ii,om as ij,am as ik,rm as il,Mr as im,ni as io,lh as ip,ch as iq,oh as ir,si as is,zr as it,Fr as iu,Lr as iv,Zu as iw,Dr as ix,Qu as iy,Zo as iz,$d as j,D6 as j$,YA as j0,JA as j1,NO as j2,jR as j3,DA as j4,mO as j5,LA as j6,NA as j7,CA as j8,SA as j9,H7 as jA,q7 as jB,G7 as jC,b6 as jD,f6 as jE,g6 as jF,A6 as jG,K6 as jH,rO as jI,I7 as jJ,M7 as jK,a6 as jL,r6 as jM,oO as jN,aO as jO,n6 as jP,s6 as jQ,XT as jR,sO as jS,L7 as jT,D7 as jU,HO as jV,uI as jW,VE as jX,JE as jY,OM as jZ,Q7 as j_,jO as ja,NE as jb,kE as jc,_E as jd,SE as je,h6 as jf,zO as jg,aI as jh,R6 as ji,fR as jj,vR as jk,yR as jl,lR as jm,GE as jn,UE as jo,A8 as jp,P8 as jq,T8 as jr,zM as js,h8 as jt,U6 as ju,Y6 as jv,$E as jw,QI as jx,pR as jy,Y7 as jz,Sd as k,tE as k$,xI as k0,lI as k1,$7 as k2,z7 as k3,B6 as k4,kA as k5,FO as k6,uA as k7,cA as k8,dA as k9,qA as kA,BA as kB,HA as kC,RA as kD,IA as kE,MA as kF,OA as kG,EA as kH,$O as kI,uO as kJ,fO as kK,gO as kL,B8 as kM,K7 as kN,kI as kO,T6 as kP,v8 as kQ,_6 as kR,sI as kS,d6 as kT,ZO as kU,L6 as kV,tD as kW,eD as kX,BE as kY,ZR as kZ,cE as k_,hA as ka,mA as kb,pA as kc,pO as kd,YT as ke,hO as kf,_A as kg,XR as kh,UT as ki,vO as kj,iR as kk,VO as kl,MI as km,gA as kn,fA as ko,nA as kp,GA as kq,UA as kr,WA as ks,ZT as kt,eA as ku,ZA as kv,$A as kw,zA as kx,FA as ky,jA as kz,u3 as l,E8 as l$,nE as l0,lE as l1,iE as l2,oE as l3,aE as l4,rE as l5,sE as l6,wR as l7,x6 as l8,N6 as l9,V8 as lA,U8 as lB,H8 as lC,D8 as lD,k7 as lE,V6 as lF,gI as lG,bI as lH,IM as lI,nI as lJ,DM as lK,MM as lL,EM as lM,FE as lN,RM as lO,DE as lP,OE as lQ,IE as lR,AE as lS,LE as lT,EE as lU,RE as lV,ME as lW,TE as lX,zE as lY,I8 as lZ,M8 as l_,X6 as la,J7 as lb,qM as lc,FM as ld,LM as le,WE as lf,A7 as lg,O7 as lh,R7 as li,E7 as lj,T7 as lk,P7 as ll,C7 as lm,S7 as ln,N7 as lo,L8 as lp,q8 as lq,xO as lr,s7 as ls,V7 as lt,z8 as lu,F8 as lv,_7 as lw,G8 as lx,W8 as ly,Y8 as lz,Go as m,PM as m$,HM as m0,PE as m1,fI as m2,mI as m3,AM as m4,BM as m5,WM as m6,dR as m7,k6 as m8,VR as m9,dO as mA,ZI as mB,u8 as mC,o8 as mD,d8 as mE,c8 as mF,l8 as mG,yO as mH,i8 as mI,s8 as mJ,n8 as mK,t8 as mL,JI as mM,KI as mN,YI as mO,qI as mP,UI as mQ,WI as mR,HI as mS,VI as mT,e8 as mU,XI as mV,r8 as mW,a8 as mX,zI as mY,wE as mZ,bR as m_,HT as ma,YR as mb,u6 as mc,CM as md,N8 as me,C8 as mf,k8 as mg,w8 as mh,_8 as mi,j8 as mj,S8 as mk,mM as ml,y8 as mm,d7 as mn,$R as mo,hR as mp,LR as mq,DR as mr,IR as ms,PA as mt,U7 as mu,dE as mv,R8 as mw,QT as mx,f8 as my,wI as mz,Fv as n,Q6 as n$,XE as n0,mR as n1,G6 as n2,rA as n3,j7 as n4,KO as n5,JO as n6,XO as n7,m6 as n8,oI as n9,tR as nA,BO as nB,_M as nC,tO as nD,GR as nE,RR as nF,TR as nG,PR as nH,AR as nI,OR as nJ,cI as nK,sA as nL,tA as nM,nD as nN,sD as nO,nM as nP,KE as nQ,GT as nR,j6 as nS,GI as nT,$M as nU,x8 as nV,cO as nW,rD as nX,HE as nY,KT as nZ,kM as n_,YO as na,AA as nb,TA as nc,lO as nd,P6 as ne,b7 as nf,g7 as ng,y7 as nh,x7 as ni,f7 as nj,v7 as nk,m7 as nl,YM as nm,UM as nn,kR as no,$8 as np,MR as nq,rM as nr,JT as ns,Z6 as nt,oR as nu,nR as nv,eR as nw,aR as nx,rR as ny,sR as nz,wn as o,Z8 as o$,uR as o0,gR as o1,cR as o2,jM as o3,E6 as o4,sM as o5,lA as o6,iA as o7,vA as o8,bA as o9,p8 as oA,m8 as oB,FI as oC,QR as oD,UR as oE,eE as oF,GM as oG,z6 as oH,l7 as oI,p7 as oJ,ER as oK,r7 as oL,c7 as oM,a7 as oN,u7 as oO,h7 as oP,i7 as oQ,o7 as oR,$6 as oS,v6 as oT,ZE as oU,y6 as oV,LI as oW,_R as oX,X8 as oY,J8 as oZ,Q8 as o_,wA as oa,yA as ob,c6 as oc,hI as od,rI as oe,yI as of,TM as og,SM as oh,NM as oi,aD as oj,bE as ok,xE as ol,gE as om,fE as on,mE as oo,yE as op,aM as oq,wM as or,b8 as os,eM as ot,W7 as ou,t7 as ov,e7 as ow,xR as ox,UO as oy,oM as oz,Ed as p,DI as p$,yM as p0,xM as p1,gM as p2,bM as p3,fM as p4,vM as p5,hM as p6,pM as p7,dM as p8,cM as p9,iI as pA,F6 as pB,TI as pC,n7 as pD,WR as pE,CE as pF,jE as pG,qE as pH,vE as pI,pE as pJ,QE as pK,hE as pL,YE as pM,tM as pN,Z7 as pO,EI as pP,B7 as pQ,pI as pR,RI as pS,xA as pT,NI as pU,CI as pV,OI as pW,AI as pX,_I as pY,SI as pZ,W6 as p_,uM as pa,lM as pb,TO as pc,H6 as pd,w7 as pe,J6 as pf,WO as pg,GO as ph,VT as pi,tI as pj,eI as pk,ZM as pl,QM as pm,JM as pn,XM as po,KM as pp,VM as pq,CR as pr,S6 as ps,BI as pt,$I as pu,iO as pv,g8 as pw,F7 as px,O6 as py,WT as pz,ws as q,II as q0,jI as q1,vI as q2,I6 as q3,JR as q4,KR as q5,kO as q6,wO as q7,OO as q8,MO as q9,K8 as qA,l6 as qB,e6 as qC,Er as qD,IO as qa,EO as qb,iM as qc,NR as qd,SR as qe,HR as qf,qR as qg,zR as qh,FR as qi,BR as qj,uE as qk,AO as ql,oA as qm,aA as qn,eO as qo,DO as qp,CO as qq,SO as qr,_O as qs,PO as qt,RO as qu,M6 as qv,q6 as qw,w6 as qx,p6 as qy,qO as qz,n_ as r,r_ as s,a_ as t,Oe as u,Qo as v,Bs as w,ue as x,Ju as y,Jo as z};