@codeyam/codeyam-cli 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +6 -6
- package/analyzer-template/log.txt +3 -3
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js +93 -1
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -1
- package/codeyam-cli/src/utils/devServerState.js +32 -0
- package/codeyam-cli/src/utils/devServerState.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +239 -1
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{editor.entity.(_sha)-DOXe0Qx7.js → editor.entity.(_sha)-DhtVC4aI.js} +23 -23
- package/codeyam-cli/src/webserver/build/client/assets/{manifest-30c44d84.js → manifest-b0d69c06.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{analysisRunner-CuR5TvUx.js → analysisRunner-DPUEhrWo.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-D4MWAsqb.js → index-oF2amaGI.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{init-JObA4lXD.js → init-C42BvUGp.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{server-build-i8OXK4oL.js → server-build-DiCdDL5d.js} +221 -133
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/editorProxy.js +178 -16
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-SqjQKTdH.js","assets/jsx-runtime-D_zvdyIk.js","assets/chunk-UVKPFVEO-Bmq2apuh.js","assets/MiniClaudeChat-Bs2_Oua4.js","assets/preload-helper-ckwbz45p.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var dn=Object.defineProperty;var xn=(t,s,n)=>s in t?dn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var As=(t,s,n)=>xn(t,typeof s!="symbol"?s+"":s,n);import{r,f as pn,w as hn,u as un,i as mn,b as gn,a as fn,c as bn,O as yn}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as jn,C as vn}from"./useCustomSizes-Dk0Tciqg.js";import{g as ut,s as Nn,r as zt,b as et,c as wn,l as kn,d as Sn,e as Rs,f as Cn,a as Fn,T as Dn,D as Pn}from"./editorPreview-C6fEYHrh.js";import{C as $e}from"./CopyButton-DTBZZfSk.js";import{MiniClaudeChat as Me}from"./MiniClaudeChat-Bs2_Oua4.js";import{_ as cr}from"./preload-helper-ckwbz45p.js";import{c as En}from"./cy-logo-cli-Coe5NhbS.js";import{u as Tn,S as Vt}from"./Spinner-CIil5-gb.js";import"./copy-DXEmO0TD.js";import"./createLucideIcon-BwyFiRot.js";import"./useLastLogLine-C8QvIe05.js";function rt(t){var d;if(!t.startsWith("app/")&&!t.startsWith("("))return"/";const n=t.replace(/^app\//,"").split("/"),a=n.pop(),l=((d=a.match(/\.(tsx?|jsx?|js)$/))==null?void 0:d[0])||"",o=a.slice(0,-l.length);let i;return o==="page"||o==="index"?i=n:i=[...n,o],i=i.filter(x=>!x.startsWith("(")),i.length===0?"/":"/"+i.join("/")}function nt(t){return t==="/"?"Home":t.replace(/^\//,"").split("/").map(n=>n.startsWith("[")?n:n.charAt(0).toUpperCase()+n.slice(1)).join(" / ")}function kt(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const n=s.split("/")[0].replace(/\.[^.]+$/,"");return n.charAt(0).toUpperCase()+n.slice(1)}function dr(t){return t?t.includes("/isolated-components")||t.includes("/codeyam-isolate"):!1}function Ln(t,s){return!s||Object.keys(s).length===0?t:t.filter(n=>s[n.name])}function vt(t){const s=t.name.toLowerCase();if(t.name==="Desktop"||t.name==="Full HD"||t.name==="HD")return"desktop";if(t.name==="Laptop"||t.name==="Small Laptop")return"laptop";if(t.name==="Tablet")return"tablet";if(t.name==="Mobile"||s.includes("iphone")||s.includes("pixel")||s.includes("galaxy")||s.includes("phone"))return"mobile";if(s.includes("ipad")||s.includes("tablet"))return"tablet";if(s.includes("laptop"))return"laptop";if(s.includes("desktop"))return"desktop";const n=t.height>t.width;return n&&t.width>=700?"tablet":n?"mobile":t.width>1200?"desktop":"laptop"}const Mn=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}],$n=[{name:"iPhone 16",width:393,height:852},{name:"iPhone 16 Pro Max",width:430,height:932},{name:"iPhone SE",width:375,height:667},{name:"Pixel 8",width:412,height:915},{name:"iPad mini",width:744,height:1133}],xr=[{category:"Desktop",presets:[{name:"Full HD",width:1920,height:1080},{name:"Desktop",width:1440,height:900},{name:"HD",width:1280,height:720}]},{category:"Laptop",presets:[{name:"Laptop",width:1366,height:768},{name:"Small Laptop",width:1024,height:768}]},{category:"Tablet",presets:[{name:'iPad Pro 12.9"',width:1024,height:1366},{name:"iPad Air",width:820,height:1180},{name:"Tablet",width:768,height:1024},{name:"iPad mini",width:744,height:1133}]},{category:"Mobile",presets:[{name:"iPhone 16 Pro Max",width:430,height:932},{name:"iPhone 16",width:393,height:852},{name:"iPhone 14",width:390,height:844},{name:"Mobile",width:375,height:667},{name:"Pixel 8",width:412,height:915},{name:"Galaxy S",width:360,height:800}]}];function pr(t,s){if(t&&Object.keys(t).length>0&&Object.values(t).some(d=>"default"in d))return Object.entries(t).map(([d,x])=>({name:d,width:x.width,height:x.height}));const n=(s==null?void 0:s.includes("mobile-app"))??!1,a=n?$n:Mn,l=a.map(d=>{const x=t==null?void 0:t[d.name];return x?{...d,width:x.width,height:x.height}:d});if(!t||n)return l;const o=new Set(a.map(d=>d.name)),i=Object.entries(t).filter(([d])=>!o.has(d)).map(([d,x])=>({name:d,width:x.width,height:x.height}));return[...l,...i]}const mt={width:24,height:76};function In({width:t,height:s,enabled:n=!0,children:a}){if(!n)return e.jsx(e.Fragment,{children:a});const l=12,o=48,i=28,d=t+l*2,x=s+o+i;return e.jsxs("div",{style:{width:`${d}px`,height:`${x}px`,background:"#1a1a1a",borderRadius:"44px",padding:`${o}px ${l}px ${i}px`,position:"relative",boxShadow:"0 0 0 1px rgba(255,255,255,0.08), 0 8px 32px rgba(0,0,0,0.4)"},children:[e.jsx("div",{style:{position:"absolute",top:"14px",left:"50%",transform:"translateX(-50%)",width:"100px",height:"24px",background:"#000",borderRadius:"12px"}}),e.jsx("div",{style:{width:`${t}px`,height:`${s}px`,borderRadius:"6px",overflow:"hidden",position:"relative"},children:a}),e.jsx("div",{style:{position:"absolute",bottom:"10px",left:"50%",transform:"translateX(-50%)",width:"120px",height:"4px",background:"rgba(255,255,255,0.25)",borderRadius:"2px"}})]})}function gt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function An({from:t,to:s,lastStep:n,lastStepLabel:a,handoffSummary:l,featureName:o,onContinue:i,onStartFresh:d}){const x=r.useCallback(b=>{b.key==="Enter"&&(b.preventDefault(),i())},[i]);return r.useEffect(()=>(window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)),[x]),e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-400"}),e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Provider Changed"})]}),e.jsxs("p",{className:"text-sm text-amber-300 mb-4",children:[gt(t)," → ",gt(s)]}),e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-4 text-sm space-y-1",children:[o&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Feature:"})," ",e.jsx("span",{className:"text-white",children:o})]}),n!=null&&a&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Last step:"})," ",e.jsxs("span",{className:"text-white",children:[n," of 18 — ",a]})]})]}),l&&e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-4 text-sm",children:[e.jsx("div",{className:"text-[#999] mb-1",children:"Previous provider's notes:"}),e.jsx("div",{className:"text-[#ccc] italic",children:l})]}),e.jsxs("p",{className:"text-xs text-[#999] mb-4",children:["Continuing will generate a handoff context with uncommitted changes and progress history for ",gt(s)," to review."]}),e.jsxs("button",{onClick:i,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-amber-600 text-white font-medium hover:bg-amber-700 ring-2 ring-amber-400/50",children:["Continue with ",gt(s)]}),e.jsx("button",{onClick:d,className:"w-full mt-2 px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-transparent text-[#999] hover:text-white hover:bg-[#3d3d3d] border border-[#3d3d3d]",children:"Start Fresh"})]})})}function Rn({featureName:t,editorStep:s,editorStepLabel:n,onContinue:a,onStartFresh:l}){const o=r.useCallback(i=>{i.key==="Enter"&&(i.preventDefault(),a())},[a]);return r.useEffect(()=>(window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)),[o]),e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsxs("div",{className:"flex flex-col items-center max-w-lg w-full mx-4",children:[e.jsx("h2",{className:"text-2xl font-bold mb-2 text-white",children:"Resume Previous Session?"}),e.jsx("p",{className:"text-sm text-[#999] mb-6",children:"An editor session is still in progress:"}),e.jsxs("div",{className:"bg-[#2a2a1e] border border-[#D7FF63]/30 rounded-lg px-12 py-5 mb-6 text-center w-full max-w-sm",children:[t&&e.jsx("div",{className:"text-white font-medium text-base mb-1",children:t}),s!=null&&n&&e.jsxs("div",{className:"font-['IBM_Plex_Mono'] text-sm",children:[e.jsxs("span",{className:"text-[#D7FF63] font-bold",children:["STEP ",s]})," ",e.jsxs("span",{className:"text-[#D7FF63]/70",children:["(",n.toUpperCase(),")"]})]})]}),e.jsx("button",{onClick:a,className:"px-12 py-2.5 text-sm rounded-md transition-colors cursor-pointer bg-[#D7FF63] text-black font-bold tracking-wider uppercase font-['IBM_Plex_Mono'] hover:bg-[#c5ee52]",children:"Continue Session"}),l&&e.jsx("button",{onClick:l,className:"mt-4 px-4 py-2 text-xs rounded transition-colors cursor-pointer bg-transparent text-[#666] hover:text-white tracking-wider uppercase font-['IBM_Plex_Mono']",children:"Start Over"})]})})}function On({onStartNextFeature:t,onContinueInSession:s}){const n=r.useCallback(a=>{a.key==="Enter"&&(a.preventDefault(),t())},[t]);return r.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1e1e1e]/90 z-10",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Feature Complete!"}),e.jsx("p",{className:"text-sm text-[#999] mb-5",children:"Your feature has been pushed. What would you like to do next?"}),e.jsx("button",{onClick:t,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-[#005c75] text-white font-medium hover:bg-[#004d63] ring-2 ring-white/50",children:"Start Next Feature"}),e.jsx("button",{onClick:s,className:"w-full mt-2 px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-transparent text-[#999] hover:text-white hover:bg-[#3d3d3d] border border-[#3d3d3d]",children:"Continue in Current Session"}),e.jsx("p",{className:"text-xs text-[#666] mt-3 text-center",children:"Press Enter to start a new feature with a fresh context"})]})})}const _n={1:"Plan",2:"Prepare",3:"Prototype",4:"Verify Prototype",5:"Confirm",6:"Deconstruct",7:"Extract",8:"Glossary",9:"Analyze",10:"App Scenarios",11:"User Scenarios",12:"Verify",13:"Journal",14:"Review",15:"Present",16:"Commit",17:"Finalize",18:"Push"},Bn={1:"Plan the feature and confirm the approach with the user before writing any code.",2:"Prepare the project environment and dependencies for prototyping.",3:"Build a working prototype quickly to validate the concept.",4:"Verify the prototype works correctly and fix any issues.",5:"Confirm the prototype looks right and get user approval to proceed.",6:"Read the code and plan all component and function extractions.",7:"Extract components and functions via TDD — components first, then functions.",8:"Record all extracted functions and components in the glossary.",9:"Analyze imports and verify all components are captured correctly.",10:"Create app-level scenarios that show full pages with realistic data.",11:"Create user-persona scenarios that exercise the app from different perspectives.",12:"Review all screenshots and check for visual errors or regressions.",13:"Create or update the journal entry documenting what was built.",14:"Final review of screenshots, audit for completeness.",15:"Present a summary of all work to the user for approval.",16:"Commit all changes to git.",17:"Update the journal with final details and amend the commit.",18:"Push the branch to the remote repository."},Wn={1:"Survey",2:"App Scenarios",3:"Component Scenarios",4:"Preview",5:"Discuss",6:"Decompose",7:"Extract",8:"Recapture",9:"Journal",10:"Present"},Hn={1:"Survey the existing codebase to understand pages, components, and dependencies.",2:"Create app-level scenarios showing full pages with realistic data.",3:"Create component-level scenarios for isolated component previews.",4:"Preview all captured scenarios and verify they look correct.",5:"Discuss the migration plan and prioritize which pages to decompose.",6:"Plan the decomposition of pages into clean, reusable components.",7:"Extract components and functions with tests via TDD.",8:"Recapture scenarios after extraction to verify nothing broke.",9:"Document the migration progress in a journal entry.",10:"Present the migration results for review and approval."},Un=18,zn=10;function Vn({projectTitle:t,featureName:s,editorStep:n,editorStepLabel:a,migrationMode:l}){const[o,i]=r.useState(!1),[d,x]=r.useState(null),b=r.useRef(null);r.useEffect(()=>{if(!o)return;const k=A=>{b.current&&!b.current.contains(A.target)&&i(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[o]);const f=s&&n!=null,c=l==="active",y=c?Wn:_n,M=c?Hn:Bn,D=c?zn:Un,p=f?a||y[n]||"?":null,w=s||"New Working Session";return e.jsxs("div",{className:"h-8 shrink-0 flex items-center justify-between px-3 bg-[#2a2a2a] border-b border-[#333] text-xs select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[#888] truncate",children:t||"New Project"}),e.jsx("span",{className:"text-[#555]",children:">"}),e.jsx("span",{className:"text-[#ccc] font-medium truncate",children:w})]}),f&&e.jsxs("div",{className:"relative",ref:b,children:[e.jsxs("button",{onClick:()=>i(k=>!k),className:"flex items-center gap-1.5 text-[#ccc] hover:text-white transition-colors cursor-pointer",children:[e.jsx("span",{className:"text-[#555]",children:"::"}),e.jsxs("span",{children:["Step ",n,e.jsxs("span",{className:"text-[#888]",children:[" / ",D]}),":"," ",p]}),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&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-lg z-30 py-1",children:Array.from({length:D},(k,A)=>A+1).map(k=>{const A=k===n,_=k<n,H=d===k,z=M[k];return e.jsxs("div",{onClick:()=>x(H?null:k),className:"cursor-pointer",children:[e.jsxs("div",{className:`w-full px-3 py-1 flex items-center gap-2 text-left transition-colors hover:bg-[#383838] ${A?"text-cygreen font-medium":_?"text-[#ccc]":"text-[#999]"}`,children:[e.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[k,"."]}),e.jsx("span",{className:"flex-1",children:y[k]||`Step ${k}`}),z&&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 ${H?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),H&&z&&e.jsx("div",{className:"px-3 pb-1.5 pl-10",children:e.jsx("p",{className:"text-[10px] text-[#888] m-0 leading-relaxed",children:z})})]},k)})})]})]})}function Xt(t,s){const[n,a]=r.useState(s??null),[l,o]=r.useState(!1),[i,d]=r.useState((s==null?void 0:s.stale)??!1),x=r.useCallback(()=>{t&&(o(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(b=>b.json()).then(b=>{a(b),d(!1),o(!1)}).catch(()=>{a({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),d(!1),o(!1)}))},[t]);return{results:n,isRunning:l,runTests:x,stale:i}}function Je({scenarioId:t,screenshotPath:s,updatedAt:n,alt:a,className:l="",imgClassName:o=""}){const[i,d]=r.useState(!1),b=`/api/editor-scenario-image/${s?s.replace(/^screenshots\//,""):`${t}.png`}${n?`?v=${encodeURIComponent(n)}`:""}`;return r.useEffect(()=>{d(!1)},[t,s]),i?e.jsx("div",{className:`flex items-center justify-center ${l}`,children:e.jsx("span",{className:"text-[8px] text-gray-500",children:"No img"})}):e.jsx("div",{className:l,children:e.jsx("img",{src:b,alt:a,className:o,loading:"lazy",onError:()=>d(!0)})})}function De(t){return t.flatMap(s=>{const n=s.screenshotPaths;return n&&Object.keys(n).length>1?Object.entries(n).map(([a,l])=>({scenario:s,dimensionLabel:a,screenshotPath:l,key:`${s.id}--${a}`})):[{scenario:s,dimensionLabel:null,screenshotPath:s.screenshotPath,key:s.id}]})}function tt({scenarioId:t,screenshotPath:s,updatedAt:n,hasScreenshot:a,imgSrc:l,name:o,dimensionLabel:i,isActive:d,onSelect:x}){const b=t&&a,f=!t&&l;return e.jsxs("button",{onClick:x,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:i?`${o} (${i})`:o,children:[e.jsxs("div",{className:`w-full aspect-[16/10] rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] relative ${d?"border-[#D7FF63]/40 ring-1 ring-[#D7FF63]/20":"border-transparent hover:border-[#4d4d4d]"}`,children:[b?e.jsx(Je,{scenarioId:t,screenshotPath:s,updatedAt:n,alt:i?`${o} (${i})`:o,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):f?e.jsx("img",{src:l,alt:o,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})}),i&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:i})]}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${d?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:i?`${o} (${i})`:o})]})}function Gt({testFile:t,entityName:s,cachedResult:n}){const{results:a,isRunning:l,runTests:o,stale:i}=Xt(t,n);if(l&&!a)return e.jsxs("div",{className:"px-2 pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:a.errorMessage})});const d=s?a.testCases.filter(f=>f.fullName.startsWith(s)):a.testCases,x=d.length>0?d:a.testCases;if(x.length===0)return null;const b=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[x.map(f=>{var y;const c=b&&f.fullName.startsWith(b)?f.fullName.slice(b.length):f.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[f.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):f.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${f.status==="passed"?"text-green-400":f.status==="failed"?"text-red-400":"text-gray-500"}`,children:c})]}),f.status==="failed"&&((y=f.failureMessages)==null?void 0:y.map((M,D)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:M,children:M.split(`
|
|
3
|
-
`)[0]},D)))]},f.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:o,disabled:l,className:"text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":i?"Re-run (stale)":"Re-run"}),i&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}function st({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 px-2 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx($e,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Gn({scenarios:t,projectRoot:s,activeScenarioId:n,onScenarioSelect:a,zoomComponent:l,focusedEntity:o,onZoomChange:i,analyzedEntities:d=[],glossaryFunctions:x=[],cachedTestResults:b={},activeAnalyzedScenarioId:f,onAnalyzedScenarioSelect:c,entityImports:y,pageFilePaths:M={},onSwitchToBuild:D,entityShaMap:p,structureTab:w="application",onStructureTabChange:k}){const[A,_]=r.useState(""),[H,z]=r.useState(w),P=k?w:H,J=k||z,{pageGroups:G,componentGroups:V}=r.useMemo(()=>{var T;const m=new Map,C=new Map;for(const j of t)if(j.componentName){const $=C.get(j.componentName)||[];$.push(j),C.set(j.componentName,$)}else if(dr(j.url)){const $=(T=j.url)==null?void 0:T.match(/[?&]c=([^&]+)/),I=$?decodeURIComponent($[1]):"Isolated",ee=C.get(I)||[];ee.push(j),C.set(I,ee)}else{const $=j.pageFilePath?nt(rt(j.pageFilePath)):kt(j.url),I=m.get($)||[];I.push(j),m.set($,I)}const g=new Map([...C.entries()].sort(([j],[$])=>j.localeCompare($)));return{pageGroups:m,componentGroups:g}},[t]),S=r.useMemo(()=>{const m=new Set((d||[]).filter(g=>g.entityType==="visual").map(g=>g.name)),C=new Map;for(const[g,T]of V)m.has(g)||C.set(g,T);return C},[V,d]),{visualEntities:v,libraryEntities:B}=r.useMemo(()=>{const m=d.filter(g=>g.entityType==="visual").sort((g,T)=>g.name.localeCompare(T.name)),C=d.filter(g=>g.entityType==="library"||g.entityType==="functionCall").sort((g,T)=>g.name.localeCompare(T.name));return{visualEntities:m,libraryEntities:C}},[d]),O=r.useMemo(()=>{const m=new Set(B.map(C=>C.name));return x.filter(C=>!m.has(C.name)).sort((C,g)=>C.name.localeCompare(g.name))},[x,B]),Y=d.some(m=>m.isAnalyzing),Z=r.useRef(null),E=r.useRef(0),U=r.useCallback(()=>{Z.current&&(E.current=Z.current.scrollTop)},[]);if(r.useEffect(()=>{Z.current&&E.current>0&&(Z.current.scrollTop=E.current)}),t.length===0&&d.length===0&&O.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No scenarios yet"}),e.jsx("p",{className:"text-xs",children:"Scenarios will appear here as Claude creates them alongside your code. Each scenario represents a different state of your app's data."})]})});if(l&&o){const m=o.name,C=o.filePath,g=o.sha,T=t.filter(K=>K.componentName===m||K.componentPath===C||!K.componentName&&(K.pageFilePath===C||g&&K.entitySha===g)),j=new Set((y==null?void 0:y[m])||[]),$=j.size>0,I=$?v.filter(K=>j.has(K.name)):[],ee=$?B.filter(K=>j.has(K.name)):[];return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsxs("button",{onClick:()=>i(void 0),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-400 hover:text-white transition-colors cursor-pointer",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M7.5 9L4.5 6L7.5 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"All scenarios"]}),e.jsx("div",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-xs font-semibold text-white uppercase tracking-wider",children:o.displayName})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:T.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):De(T).map(({scenario:K,dimensionLabel:re,screenshotPath:me,key:se})=>e.jsx(tt,{scenarioId:K.id,screenshotPath:me,updatedAt:K.updatedAt,hasScreenshot:!!me,name:K.name,dimensionLabel:re,isActive:K.id===n,onSelect:()=>a(K,re??void 0)},se))}),I.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),I.map(K=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center gap-2 px-2 py-1",children:e.jsx("button",{onClick:()=>i(K.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:K.name})}),e.jsx(st,{filePath:K.filePath,projectRoot:s}),(K.scenarios.length>0||K.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:K.scenarios.map(re=>e.jsx(tt,{imgSrc:re.screenshotPath?`/api/screenshot/${re.screenshotPath}`:null,name:re.name,isActive:re.id===f,onSelect:()=>c==null?void 0:c({analysisId:K.analysisId,scenarioId:re.id,scenarioName:re.name,entitySha:K.sha,entityName:K.name})},re.id))})]},K.sha))]}),ee.length>0&&e.jsxs("div",{className:"pt-2 mt-1",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),ee.map(K=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:K.name})}),e.jsx(st,{filePath:K.filePath,projectRoot:s}),K.testFile&&e.jsx(Gt,{testFile:K.testFile,entityName:K.name,cachedResult:b[K.testFile]})]},K.sha))]})]})})}return e.jsx("div",{ref:Z,onScroll:U,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 font-['IBM_Plex_Mono']",children:[e.jsx("button",{onClick:()=>J("application"),className:`text-xs font-bold uppercase tracking-wider shrink-0 bg-transparent border-none cursor-pointer p-0 transition-colors ${P==="application"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:"Application"}),e.jsx("button",{onClick:()=>J("components"),className:`text-xs font-bold uppercase tracking-wider shrink-0 bg-transparent border-none cursor-pointer p-0 transition-colors ${P==="components"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:"Components"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",style:{width:170},children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"text",placeholder:"SEARCH...",value:A,onChange:m=>_(m.target.value),className:"w-full pl-9 pr-3 py-2 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors tracking-wider"})]}),D&&e.jsxs("button",{onClick:D,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-semibold text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer shrink-0 uppercase tracking-wider",children:[e.jsx("span",{children:"+"})," New Feature"]})]}),e.jsx("div",{className:"border-b border-[#2d2d2d]"}),P==="application"&&G.size>0&&e.jsx("div",{children:[...G.entries()].sort(([m],[C])=>m==="Home"?-1:C==="Home"?1:m.localeCompare(C)).filter(([m])=>A.trim()?m.toLowerCase().includes(A.trim().toLowerCase()):!0).map(([m,C])=>{const g=C.some(T=>T.id===n&&!f);return e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[e.jsxs("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${g?"text-[#D7FF63]":"text-gray-300"}`,children:[m,e.jsxs("span",{className:`text-xs ${g?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",C.length,")"]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:g?"text-[#D7FF63]/60":"text-gray-500",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),g&&e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Edit scenarios",children:e.jsxs("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:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),D&&e.jsx("button",{onClick:D,className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Add scenario",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(C).map(({scenario:T,dimensionLabel:j,screenshotPath:$,key:I})=>e.jsx(tt,{scenarioId:T.id,screenshotPath:$,updatedAt:T.updatedAt,hasScreenshot:!!$,name:T.name,dimensionLabel:j,isActive:T.id===n&&!f,onSelect:()=>a(T,j??void 0)},I))})]},m)})}),P==="components"&&S.size>0&&e.jsx("div",{children:[...S.entries()].filter(([m])=>A.trim()?m.toLowerCase().includes(A.trim().toLowerCase()):!0).map(([m,C])=>{const g=C.some(T=>T.id===n&&!f);return e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[e.jsxs("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${g?"text-[#D7FF63]":"text-gray-300"}`,children:[m,e.jsxs("span",{className:`text-xs ${g?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",C.length,")"]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:g?"text-[#D7FF63]/60":"text-gray-500",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),g&&e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Edit scenarios",children:e.jsxs("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:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),D&&e.jsx("button",{onClick:D,className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Add scenario",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(C).map(({scenario:T,dimensionLabel:j,screenshotPath:$,key:I})=>e.jsx(tt,{scenarioId:T.id,screenshotPath:$,updatedAt:T.updatedAt,hasScreenshot:!!$,name:T.name,dimensionLabel:j,isActive:T.id===n&&!f,onSelect:()=>a(T,j??void 0)},I))})]},m)})}),v.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),Y&&t.length===0&&d.every(m=>m.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),v.map(m=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx("button",{onClick:()=>i(m.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:m.name}),m.isAnalyzing&&m.scenarioCount===0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(st,{filePath:m.filePath,projectRoot:s}),(m.scenarios.length>0||m.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[m.scenarios.map(C=>e.jsx(tt,{imgSrc:C.screenshotPath?`/api/screenshot/${C.screenshotPath}`:null,name:C.name,isActive:C.id===f,onSelect:()=>c==null?void 0:c({analysisId:m.analysisId,scenarioId:C.id,scenarioName:C.name,entitySha:m.sha,entityName:m.name})},C.id)),m.pendingScenarios.map(C=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:C,children:C},C))]})]},m.sha))]}),(B.length>0||O.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${v.length>0?"":"border-t border-[#3d3d3d]"}`,children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),B.map(m=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:m.name}),m.isAnalyzing&&m.scenarioCount===0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(st,{filePath:m.filePath,projectRoot:s}),m.testFile?e.jsx(Gt,{testFile:m.testFile,entityName:m.name,cachedResult:b[m.testFile]}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},m.sha)),O.map(m=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:m.name})}),e.jsx(st,{filePath:m.filePath,projectRoot:s}),e.jsx(Gt,{testFile:m.testFile,entityName:m.name,cachedResult:b[m.testFile]})]},m.name))]})]})})}function hr(t){const s={};for(const[n,a]of Object.entries(t))if(typeof a=="string")try{const l=JSON.parse(a);Array.isArray(l)?s[n]=l:typeof l=="object"&&l!==null&&(s[n]=[l])}catch{}else Array.isArray(a)&&(s[n]=a);return s}function ur(t,s){return t.length===0||s.length===0?!1:t.filter(a=>s.includes(a)).length>=Math.min(t.length,s.length)*.5}function Jn(t,s){const{_metadata:n,...a}=s,l=a.localStorage&&typeof a.localStorage=="object"&&!Array.isArray(a.localStorage)?hr(a.localStorage):{},o={};if(a.seed&&typeof a.seed=="object"&&!Array.isArray(a.seed))for(const[c,y]of Object.entries(a.seed))Array.isArray(y)&&(o[c]=y);const i={},d=[],x=new Set,b=new Set,f=new Set;for(const c of t){const y=c.fields.filter(k=>!k.isRelation),M=y.map(k=>k.name),D=c.name.charAt(0).toLowerCase()+c.name.slice(1);let p=null,w=[];for(const k of[c.name,D,`${D}s`])if(k in a&&Array.isArray(a[k])){p=k,w=a[k],b.add(k);break}if(!p){for(const k of[c.name,D,`${D}s`])if(k in o){p=k,w=o[k],f.add(k),k in l&&x.add(k);break}}if(!p){for(const k of[c.name,D,`${D}s`])if(k in l){p=D,w=l[k],x.add(k);break}}if(!p){for(const[k,A]of Object.entries(l))if(!x.has(k)&&A.length>0&&ur(M,Object.keys(A[0]))){p=D,w=A,x.add(k);break}}p||(p=D),i[p]=w,d.push({label:c.name,dataKey:p,schemaFields:y.map(k=>({name:k.name,type:k.type,isId:k.isId}))})}for(const[c,y]of Object.entries(a))c==="_metadata"||c==="localStorage"||c==="seed"||c==="type"||b.has(c)||Array.isArray(y)&&(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(o))f.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(l))x.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));return{data:i,tabs:d}}function Kn(t){return t==null?"null":typeof t=="number"?Number.isInteger(t)?"int4":"float":typeof t=="boolean"?"bool":typeof t=="object"?Array.isArray(t)?"array":"json":"text"}function Yn(t,s){return t.length>0?Object.keys(t[0]):s?s.map(n=>n.name):[]}function qn(t,s,n){const a=new Map((n||[]).map(o=>[o.name,o.type])),l={};for(const o of t)l[o]=a.get(o)||(s.length>0?Kn(s[0][o]):"text");return l}function Qn(t,s){var n;return((n=s==null?void 0:s.find(a=>a.isId))==null?void 0:n.name)||t.find(a=>a==="id")||null}function Xn(t,s){const{_metadata:n,...a}=s,l=a.localStorage&&typeof a.localStorage=="object"&&!Array.isArray(a.localStorage)?hr(a.localStorage):{},o={};if(a.seed&&typeof a.seed=="object"&&!Array.isArray(a.seed))for(const[c,y]of Object.entries(a.seed))Array.isArray(y)&&(o[c]=y);const i={},d=[],x=new Set,b=new Set,f=new Set;for(const c of t){const y=c.name.charAt(0).toLowerCase()+c.name.slice(1),M=c.fields.map(w=>w.name);let D=null,p=[];for(const w of[c.name,y,`${y}s`])if(w in a&&Array.isArray(a[w])){D=w,p=a[w],b.add(w);break}if(!D){for(const w of[c.name,y,`${y}s`])if(w in o){D=w,p=o[w],f.add(w),w in l&&x.add(w);break}}if(!D){for(const w of[c.name,y,`${y}s`])if(w in l){D=y,p=l[w],x.add(w);break}}if(!D){for(const[w,k]of Object.entries(l))if(!x.has(w)&&k.length>0&&ur(M,Object.keys(k[0]))){D=y,p=k,x.add(w);break}}D||(D=y),i[D]=p,d.push({label:c.name,dataKey:D,category:c.category,description:c.description,schemaFields:c.fields.map(w=>({name:w.name,type:w.type,isId:w.isId??!1}))})}for(const[c,y]of Object.entries(a))c==="_metadata"||c==="localStorage"||c==="seed"||c==="type"||b.has(c)||Array.isArray(y)&&(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(o))f.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(l))x.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));return{data:i,tabs:d}}function Zt(t){var l,o;const s=new Map,n=new Map;for(const i of t)if(i.componentName){const d=n.get(i.componentName)||[];d.push(i),n.set(i.componentName,d)}else if(dr(i.url)){const d=(l=i.url)==null?void 0:l.match(/[?&]c=([^&]+)/),x=d?decodeURIComponent(d[1]):"Isolated",b=n.get(x)||[];b.push(i),n.set(x,b)}else{const d=i.displayName||((o=i.pageFilePath)!=null&&o.startsWith("app/")?nt(rt(i.pageFilePath)):kt(i.url)),x=s.get(d)||[];x.push(i),s.set(d,x)}const a=new Map([...n.entries()].sort(([i],[d])=>i.localeCompare(d)));return{pageGroups:s,componentGroups:a}}function mr(t,s){var a,l;const n=new Map;for(const[o,i]of t){const d=(a=i.find(x=>x.entitySha))==null?void 0:a.entitySha;d&&n.set(o,d)}for(const[o,i]of s){const d=(l=i.find(x=>x.entitySha))==null?void 0:l.entitySha;d&&n.set(o,d)}return n}function Zn(t){const s=new Set;for(const[n,a]of Object.entries(t)){s.add(n);for(const l of a)s.add(l)}return s}function ea(t,s,n,a){if(s.has(t))return!0;const l=n.find(o=>o.sha===t);return l?a.has(l.name):!1}function ta(t,s,n,a){const l=[];for(const[o,i]of t){const d=n.get(o);d?a(d)||l.push({name:o,scenarios:i,reason:"incomplete"}):l.push({name:o,scenarios:i,reason:"missing"})}for(const[o,i]of s){const d=n.get(o);d?a(d)||l.push({name:o,scenarios:i,reason:"incomplete"}):l.push({name:o,scenarios:i,reason:"missing"})}return l}function Os(t,s,n){if(!t)return null;const a=s.find(l=>l.sha===t);return a?{sha:t,name:a.name,filePath:a.filePath,entityType:a.entityType,displayName:a.name}:null}const _s=120;function gr({text:t,theme:s}){const[n,a]=r.useState(!1),l=t.length>_s,o=l&&!n?t.slice(0,_s)+"…":t,i=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${i?"border-b border-gray-200 bg-gray-50":"border-b border-[#3d3d3d] bg-[#252525]"}`,children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-gray-500",children:"User Prompt"}),e.jsxs("p",{className:`text-[11px] mt-0.5 mb-0 leading-relaxed ${i?"text-gray-600":"text-gray-400"}`,children:[o,l&&e.jsx("button",{onClick:()=>a(!n),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${i?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:n?"Show less":"Read more…"})]})]})}const Bs={new:0,edited:1,impacted:2};function Ws({status:t,onClick:s}){const n={new:{label:"New",bg:"bg-green-100",text:"text-green-700",border:"border-green-200"},edited:{label:"Edited",bg:"bg-blue-100",text:"text-blue-700",border:"border-blue-200"},impacted:{label:"Impacted",bg:"bg-amber-100",text:"text-amber-700",border:"border-amber-200"}}[t.status],a=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:a?s:void 0,className:`${n.bg} ${n.text} ${n.border} border text-[9px] font-bold px-1.5 py-0.5 rounded-full uppercase tracking-wider shrink-0 ${a?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:n.label})}function Hs({filePath:t}){const[s,n]=r.useState(null),[a,l]=r.useState(!0),[o,i]=r.useState(null);return r.useEffect(()=>{cr(()=>import("./index-SqjQKTdH.js"),__vite__mapDeps([0,1,2])).then(d=>{i(()=>d.default)})},[]),r.useEffect(()=>{l(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(d=>d.json()).then(d=>{n({oldContent:d.oldContent,newContent:d.newContent})}).catch(()=>{n(null)}).finally(()=>l(!1))},[t]),a?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!o?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Could not load diff"}):e.jsx("div",{className:"mt-2 border border-gray-200 rounded-lg overflow-hidden max-h-[300px] overflow-auto text-xs",children:e.jsx(o,{oldValue:s.oldContent,newValue:s.newContent,splitView:!1,useDarkTheme:!1,showDiffOnly:!0,styles:{contentText:{fontSize:"11px",lineHeight:"1.4"},line:{padding:"1px 8px",fontSize:"11px"}}})})}function Us({impactedBy:t,changedEntities:s}){return e.jsx("div",{className:"mt-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5",children:t&&t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Re-captured because these dependencies changed"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:t.map(n=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${n.changeType==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.changeType==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name}),e.jsx("span",{className:"text-[9px] text-amber-500 truncate",children:n.filePath})]},n.filePath))})]}):s&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Unchanged — these entities were modified in this session"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:s.map(n=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${n.status==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.status==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name})]},n.name))})]}):e.jsx("span",{className:"text-[10px] text-amber-600",children:"This component was re-captured because a dependency changed"})})}function zs({scenarioId:t,screenshotPath:s,name:n,dimensionLabel:a,isActive:l,onSelect:o,updatedAt:i}){const d=r.useRef(null);return r.useEffect(()=>{l&&d.current&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[l]),e.jsxs("button",{ref:d,onClick:o,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:a?`${n} (${a})`:n,children:[e.jsxs("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all relative ${l?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:[e.jsx(Je,{scenarioId:t,screenshotPath:s,updatedAt:i,alt:a?`${n} (${a})`:n,className:"w-full h-full bg-white",imgClassName:"w-full h-full object-contain bg-white"}),a&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[9px] font-medium bg-black/60 text-white px-1.5 py-0.5 rounded",children:a})]}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${l?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:a?`${n} (${a})`:n})]})}function sa({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-400 hover:text-gray-600 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx($e,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function qt({testFile:t,entityName:s,cachedResult:n}){const{results:a,isRunning:l,runTests:o,stale:i}=Xt(t,n);if(l&&!a)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#0ea5e9] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-500",children:a.errorMessage})});const d=s?a.testCases.filter(f=>f.fullName.startsWith(s)):a.testCases,x=d.length>0?d:a.testCases;if(x.length===0)return null;const b=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[x.map(f=>{var y;const c=b&&f.fullName.startsWith(b)?f.fullName.slice(b.length):f.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[f.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):f.status==="failed"?e.jsx("span",{className:"text-red-500 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-400 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${f.status==="passed"?"text-green-600":f.status==="failed"?"text-red-500":"text-gray-400"}`,children:c})]}),f.status==="failed"&&((y=f.failureMessages)==null?void 0:y.map((M,D)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:M,children:M.split(`
|
|
4
|
-
`)[0]},D)))]},
|
|
5
|
-
`):"(no scenarios yet)",o=s.endsWith("/page.tsx")||s.endsWith("/page.js"),i=((x=a.find(
|
|
6
|
-
`)}function
|
|
2
|
+
var pn=Object.defineProperty;var hn=(t,s,n)=>s in t?pn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var _s=(t,s,n)=>hn(t,typeof s!="symbol"?s+"":s,n);import{r,f as un,w as mn,u as fn,i as gn,b as bn,a as yn,c as jn,O as vn}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as Nn,C as wn}from"./useCustomSizes-Dk0Tciqg.js";import{g as mt,s as kn,r as Gt,b as et,c as Sn,l as Cn,d as Fn,e as Bs,f as Dn,a as Pn,T as En,D as Tn}from"./editorPreview-C6fEYHrh.js";import{C as Re}from"./CopyButton-DTBZZfSk.js";import{MiniClaudeChat as $e}from"./MiniClaudeChat-Bs2_Oua4.js";import{_ as pr}from"./preload-helper-ckwbz45p.js";import{c as Ln}from"./cy-logo-cli-Coe5NhbS.js";import{u as Mn,S as Jt}from"./Spinner-CIil5-gb.js";import"./copy-DXEmO0TD.js";import"./createLucideIcon-BwyFiRot.js";import"./useLastLogLine-C8QvIe05.js";function rt(t){var d;if(!t.startsWith("app/")&&!t.startsWith("("))return"/";const n=t.replace(/^app\//,"").split("/"),a=n.pop(),l=((d=a.match(/\.(tsx?|jsx?|js)$/))==null?void 0:d[0])||"",o=a.slice(0,-l.length);let i;return o==="page"||o==="index"?i=n:i=[...n,o],i=i.filter(x=>!x.startsWith("(")),i.length===0?"/":"/"+i.join("/")}function nt(t){return t==="/"?"Home":t.replace(/^\//,"").split("/").map(n=>n.startsWith("[")?n:n.charAt(0).toUpperCase()+n.slice(1)).join(" / ")}function St(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const n=s.split("/")[0].replace(/\.[^.]+$/,"");return n.charAt(0).toUpperCase()+n.slice(1)}function hr(t){return t?t.includes("/isolated-components")||t.includes("/codeyam-isolate"):!1}function $n(t,s){return!s||Object.keys(s).length===0?t:t.filter(n=>s[n.name])}function Nt(t){const s=t.name.toLowerCase();if(t.name==="Desktop"||t.name==="Full HD"||t.name==="HD")return"desktop";if(t.name==="Laptop"||t.name==="Small Laptop")return"laptop";if(t.name==="Tablet")return"tablet";if(t.name==="Mobile"||s.includes("iphone")||s.includes("pixel")||s.includes("galaxy")||s.includes("phone"))return"mobile";if(s.includes("ipad")||s.includes("tablet"))return"tablet";if(s.includes("laptop"))return"laptop";if(s.includes("desktop"))return"desktop";const n=t.height>t.width;return n&&t.width>=700?"tablet":n?"mobile":t.width>1200?"desktop":"laptop"}const Rn=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}],In=[{name:"iPhone 16",width:393,height:852},{name:"iPhone 16 Pro Max",width:430,height:932},{name:"iPhone SE",width:375,height:667},{name:"Pixel 8",width:412,height:915},{name:"iPad mini",width:744,height:1133}],ur=[{category:"Desktop",presets:[{name:"Full HD",width:1920,height:1080},{name:"Desktop",width:1440,height:900},{name:"HD",width:1280,height:720}]},{category:"Laptop",presets:[{name:"Laptop",width:1366,height:768},{name:"Small Laptop",width:1024,height:768}]},{category:"Tablet",presets:[{name:'iPad Pro 12.9"',width:1024,height:1366},{name:"iPad Air",width:820,height:1180},{name:"Tablet",width:768,height:1024},{name:"iPad mini",width:744,height:1133}]},{category:"Mobile",presets:[{name:"iPhone 16 Pro Max",width:430,height:932},{name:"iPhone 16",width:393,height:852},{name:"iPhone 14",width:390,height:844},{name:"Mobile",width:375,height:667},{name:"Pixel 8",width:412,height:915},{name:"Galaxy S",width:360,height:800}]}];function mr(t,s){if(t&&Object.keys(t).length>0&&Object.values(t).some(d=>"default"in d))return Object.entries(t).map(([d,x])=>({name:d,width:x.width,height:x.height}));const n=(s==null?void 0:s.includes("mobile-app"))??!1,a=n?In:Rn,l=a.map(d=>{const x=t==null?void 0:t[d.name];return x?{...d,width:x.width,height:x.height}:d});if(!t||n)return l;const o=new Set(a.map(d=>d.name)),i=Object.entries(t).filter(([d])=>!o.has(d)).map(([d,x])=>({name:d,width:x.width,height:x.height}));return[...l,...i]}const ft={width:24,height:76};function An({width:t,height:s,enabled:n=!0,children:a}){if(!n)return e.jsx(e.Fragment,{children:a});const l=12,o=48,i=28,d=t+l*2,x=s+o+i;return e.jsxs("div",{style:{width:`${d}px`,height:`${x}px`,background:"#1a1a1a",borderRadius:"44px",padding:`${o}px ${l}px ${i}px`,position:"relative",boxShadow:"0 0 0 1px rgba(255,255,255,0.08), 0 8px 32px rgba(0,0,0,0.4)"},children:[e.jsx("div",{style:{position:"absolute",top:"14px",left:"50%",transform:"translateX(-50%)",width:"100px",height:"24px",background:"#000",borderRadius:"12px"}}),e.jsx("div",{style:{width:`${t}px`,height:`${s}px`,borderRadius:"6px",overflow:"hidden",position:"relative"},children:a}),e.jsx("div",{style:{position:"absolute",bottom:"10px",left:"50%",transform:"translateX(-50%)",width:"120px",height:"4px",background:"rgba(255,255,255,0.25)",borderRadius:"2px"}})]})}function gt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function On({from:t,to:s,lastStep:n,lastStepLabel:a,handoffSummary:l,featureName:o,onContinue:i,onStartFresh:d}){const x=r.useCallback(g=>{g.key==="Enter"&&(g.preventDefault(),i())},[i]);return r.useEffect(()=>(window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)),[x]),e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-400"}),e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Provider Changed"})]}),e.jsxs("p",{className:"text-sm text-amber-300 mb-4",children:[gt(t)," → ",gt(s)]}),e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-4 text-sm space-y-1",children:[o&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Feature:"})," ",e.jsx("span",{className:"text-white",children:o})]}),n!=null&&a&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Last step:"})," ",e.jsxs("span",{className:"text-white",children:[n," of 18 — ",a]})]})]}),l&&e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-4 text-sm",children:[e.jsx("div",{className:"text-[#999] mb-1",children:"Previous provider's notes:"}),e.jsx("div",{className:"text-[#ccc] italic",children:l})]}),e.jsxs("p",{className:"text-xs text-[#999] mb-4",children:["Continuing will generate a handoff context with uncommitted changes and progress history for ",gt(s)," to review."]}),e.jsxs("button",{onClick:i,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-amber-600 text-white font-medium hover:bg-amber-700 ring-2 ring-amber-400/50",children:["Continue with ",gt(s)]}),e.jsx("button",{onClick:d,className:"w-full mt-2 px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-transparent text-[#999] hover:text-white hover:bg-[#3d3d3d] border border-[#3d3d3d]",children:"Start Fresh"})]})})}function _n({featureName:t,editorStep:s,editorStepLabel:n,onContinue:a,onStartFresh:l}){const o=r.useCallback(i=>{i.key==="Enter"&&(i.preventDefault(),a())},[a]);return r.useEffect(()=>(window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)),[o]),e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsxs("div",{className:"flex flex-col items-center max-w-lg w-full mx-4",children:[e.jsx("h2",{className:"text-2xl font-bold mb-2 text-white",children:"Resume Previous Session?"}),e.jsx("p",{className:"text-sm text-[#999] mb-6",children:"An editor session is still in progress:"}),e.jsxs("div",{className:"bg-[#2a2a1e] border border-[#D7FF63]/30 rounded-lg px-12 py-5 mb-6 text-center w-full max-w-sm",children:[t&&e.jsx("div",{className:"text-white font-medium text-base mb-1",children:t}),s!=null&&n&&e.jsxs("div",{className:"font-['IBM_Plex_Mono'] text-sm",children:[e.jsxs("span",{className:"text-[#D7FF63] font-bold",children:["STEP ",s]})," ",e.jsxs("span",{className:"text-[#D7FF63]/70",children:["(",n.toUpperCase(),")"]})]})]}),e.jsx("button",{onClick:a,className:"px-12 py-2.5 text-sm rounded-md transition-colors cursor-pointer bg-[#D7FF63] text-black font-bold tracking-wider uppercase font-['IBM_Plex_Mono'] hover:bg-[#c5ee52]",children:"Continue Session"}),l&&e.jsx("button",{onClick:l,className:"mt-4 px-4 py-2 text-xs rounded transition-colors cursor-pointer bg-transparent text-[#666] hover:text-white tracking-wider uppercase font-['IBM_Plex_Mono']",children:"Start Over"})]})})}function Bn({onStartNextFeature:t,onContinueInSession:s}){const n=r.useCallback(a=>{a.key==="Enter"&&(a.preventDefault(),t())},[t]);return r.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1e1e1e]/90 z-10",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Feature Complete!"}),e.jsx("p",{className:"text-sm text-[#999] mb-5",children:"Your feature has been pushed. What would you like to do next?"}),e.jsx("button",{onClick:t,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-[#005c75] text-white font-medium hover:bg-[#004d63] ring-2 ring-white/50",children:"Start Next Feature"}),e.jsx("button",{onClick:s,className:"w-full mt-2 px-4 py-2 text-sm rounded transition-colors cursor-pointer bg-transparent text-[#999] hover:text-white hover:bg-[#3d3d3d] border border-[#3d3d3d]",children:"Continue in Current Session"}),e.jsx("p",{className:"text-xs text-[#666] mt-3 text-center",children:"Press Enter to start a new feature with a fresh context"})]})})}const Wn={1:"Plan",2:"Prepare",3:"Prototype",4:"Verify Prototype",5:"Confirm",6:"Deconstruct",7:"Extract",8:"Glossary",9:"Analyze",10:"App Scenarios",11:"User Scenarios",12:"Verify",13:"Journal",14:"Review",15:"Present",16:"Commit",17:"Finalize",18:"Push"},Hn={1:"Plan the feature and confirm the approach with the user before writing any code.",2:"Prepare the project environment and dependencies for prototyping.",3:"Build a working prototype quickly to validate the concept.",4:"Verify the prototype works correctly and fix any issues.",5:"Confirm the prototype looks right and get user approval to proceed.",6:"Read the code and plan all component and function extractions.",7:"Extract components and functions via TDD — components first, then functions.",8:"Record all extracted functions and components in the glossary.",9:"Analyze imports and verify all components are captured correctly.",10:"Create app-level scenarios that show full pages with realistic data.",11:"Create user-persona scenarios that exercise the app from different perspectives.",12:"Review all screenshots and check for visual errors or regressions.",13:"Create or update the journal entry documenting what was built.",14:"Final review of screenshots, audit for completeness.",15:"Present a summary of all work to the user for approval.",16:"Commit all changes to git.",17:"Update the journal with final details and amend the commit.",18:"Push the branch to the remote repository."},Un={1:"Survey",2:"App Scenarios",3:"Component Scenarios",4:"Preview",5:"Discuss",6:"Decompose",7:"Extract",8:"Recapture",9:"Journal",10:"Present"},zn={1:"Survey the existing codebase to understand pages, components, and dependencies.",2:"Create app-level scenarios showing full pages with realistic data.",3:"Create component-level scenarios for isolated component previews.",4:"Preview all captured scenarios and verify they look correct.",5:"Discuss the migration plan and prioritize which pages to decompose.",6:"Plan the decomposition of pages into clean, reusable components.",7:"Extract components and functions with tests via TDD.",8:"Recapture scenarios after extraction to verify nothing broke.",9:"Document the migration progress in a journal entry.",10:"Present the migration results for review and approval."},Vn=18,Gn=10;function Jn({projectTitle:t,featureName:s,editorStep:n,editorStepLabel:a,migrationMode:l}){const[o,i]=r.useState(!1),[d,x]=r.useState(null),g=r.useRef(null);r.useEffect(()=>{if(!o)return;const k=I=>{g.current&&!g.current.contains(I.target)&&i(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[o]);const b=s&&n!=null,c=l==="active",y=c?Un:Wn,M=c?zn:Hn,D=c?Gn:Vn,p=b?a||y[n]||"?":null,w=s||"New Working Session";return e.jsxs("div",{className:"h-8 shrink-0 flex items-center justify-between px-3 bg-[#2a2a2a] border-b border-[#333] text-xs select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[#888] truncate",children:t||"New Project"}),e.jsx("span",{className:"text-[#555]",children:">"}),e.jsx("span",{className:"text-[#ccc] font-medium truncate",children:w})]}),b&&e.jsxs("div",{className:"relative",ref:g,children:[e.jsxs("button",{onClick:()=>i(k=>!k),className:"flex items-center gap-1.5 text-[#ccc] hover:text-white transition-colors cursor-pointer",children:[e.jsx("span",{className:"text-[#555]",children:"::"}),e.jsxs("span",{children:["Step ",n,e.jsxs("span",{className:"text-[#888]",children:[" / ",D]}),":"," ",p]}),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&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-lg z-30 py-1",children:Array.from({length:D},(k,I)=>I+1).map(k=>{const I=k===n,_=k<n,H=d===k,z=M[k];return e.jsxs("div",{onClick:()=>x(H?null:k),className:"cursor-pointer",children:[e.jsxs("div",{className:`w-full px-3 py-1 flex items-center gap-2 text-left transition-colors hover:bg-[#383838] ${I?"text-cygreen font-medium":_?"text-[#ccc]":"text-[#999]"}`,children:[e.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[k,"."]}),e.jsx("span",{className:"flex-1",children:y[k]||`Step ${k}`}),z&&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 ${H?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),H&&z&&e.jsx("div",{className:"px-3 pb-1.5 pl-10",children:e.jsx("p",{className:"text-[10px] text-[#888] m-0 leading-relaxed",children:z})})]},k)})})]})]})}function es(t,s){const[n,a]=r.useState(s??null),[l,o]=r.useState(!1),[i,d]=r.useState((s==null?void 0:s.stale)??!1),x=r.useCallback(()=>{t&&(o(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(g=>g.json()).then(g=>{a(g),d(!1),o(!1)}).catch(()=>{a({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),d(!1),o(!1)}))},[t]);return{results:n,isRunning:l,runTests:x,stale:i}}function Je({scenarioId:t,screenshotPath:s,updatedAt:n,alt:a,className:l="",imgClassName:o=""}){const[i,d]=r.useState(!1),g=`/api/editor-scenario-image/${s?s.replace(/^screenshots\//,""):`${t}.png`}${n?`?v=${encodeURIComponent(n)}`:""}`;return r.useEffect(()=>{d(!1)},[t,s]),i?e.jsx("div",{className:`flex items-center justify-center ${l}`,children:e.jsx("span",{className:"text-[8px] text-gray-500",children:"No img"})}):e.jsx("div",{className:l,children:e.jsx("img",{src:g,alt:a,className:o,loading:"lazy",onError:()=>d(!0)})})}function De(t){return t.flatMap(s=>{const n=s.screenshotPaths;return n&&Object.keys(n).length>1?Object.entries(n).map(([a,l])=>({scenario:s,dimensionLabel:a,screenshotPath:l,key:`${s.id}--${a}`})):[{scenario:s,dimensionLabel:null,screenshotPath:s.screenshotPath,key:s.id}]})}function tt({scenarioId:t,screenshotPath:s,updatedAt:n,hasScreenshot:a,imgSrc:l,name:o,dimensionLabel:i,isActive:d,onSelect:x}){const g=t&&a,b=!t&&l;return e.jsxs("button",{onClick:x,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:i?`${o} (${i})`:o,children:[e.jsxs("div",{className:`w-full aspect-[16/10] rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] relative ${d?"border-[#D7FF63]/40 ring-1 ring-[#D7FF63]/20":"border-transparent hover:border-[#4d4d4d]"}`,children:[g?e.jsx(Je,{scenarioId:t,screenshotPath:s,updatedAt:n,alt:i?`${o} (${i})`:o,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):b?e.jsx("img",{src:l,alt:o,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})}),i&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:i})]}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${d?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:i?`${o} (${i})`:o})]})}function Kt({testFile:t,entityName:s,cachedResult:n}){const{results:a,isRunning:l,runTests:o,stale:i}=es(t,n);if(l&&!a)return e.jsxs("div",{className:"px-2 pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:a.errorMessage})});const d=s?a.testCases.filter(b=>b.fullName.startsWith(s)):a.testCases,x=d.length>0?d:a.testCases;if(x.length===0)return null;const g=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[x.map(b=>{var y;const c=g&&b.fullName.startsWith(g)?b.fullName.slice(g.length):b.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[b.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):b.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${b.status==="passed"?"text-green-400":b.status==="failed"?"text-red-400":"text-gray-500"}`,children:c})]}),b.status==="failed"&&((y=b.failureMessages)==null?void 0:y.map((M,D)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:M,children:M.split(`
|
|
3
|
+
`)[0]},D)))]},b.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:o,disabled:l,className:"text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":i?"Re-run (stale)":"Re-run"}),i&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}function st({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 px-2 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Re,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Kn({scenarios:t,projectRoot:s,activeScenarioId:n,onScenarioSelect:a,zoomComponent:l,focusedEntity:o,onZoomChange:i,analyzedEntities:d=[],glossaryFunctions:x=[],cachedTestResults:g={},activeAnalyzedScenarioId:b,onAnalyzedScenarioSelect:c,entityImports:y,pageFilePaths:M={},onSwitchToBuild:D,entityShaMap:p,structureTab:w="application",onStructureTabChange:k}){const[I,_]=r.useState(""),[H,z]=r.useState(w),P=k?w:H,J=k||z,{pageGroups:G,componentGroups:V}=r.useMemo(()=>{var T;const m=new Map,F=new Map;for(const j of t)if(j.componentName){const $=F.get(j.componentName)||[];$.push(j),F.set(j.componentName,$)}else if(hr(j.url)){const $=(T=j.url)==null?void 0:T.match(/[?&]c=([^&]+)/),R=$?decodeURIComponent($[1]):"Isolated",ee=F.get(R)||[];ee.push(j),F.set(R,ee)}else{const $=j.pageFilePath?nt(rt(j.pageFilePath)):St(j.url),R=m.get($)||[];R.push(j),m.set($,R)}const f=new Map([...F.entries()].sort(([j],[$])=>j.localeCompare($)));return{pageGroups:m,componentGroups:f}},[t]),S=r.useMemo(()=>{const m=new Set((d||[]).filter(f=>f.entityType==="visual").map(f=>f.name)),F=new Map;for(const[f,T]of V)m.has(f)||F.set(f,T);return F},[V,d]),{visualEntities:v,libraryEntities:B}=r.useMemo(()=>{const m=d.filter(f=>f.entityType==="visual").sort((f,T)=>f.name.localeCompare(T.name)),F=d.filter(f=>f.entityType==="library"||f.entityType==="functionCall").sort((f,T)=>f.name.localeCompare(T.name));return{visualEntities:m,libraryEntities:F}},[d]),O=r.useMemo(()=>{const m=new Set(B.map(F=>F.name));return x.filter(F=>!m.has(F.name)).sort((F,f)=>F.name.localeCompare(f.name))},[x,B]),Y=d.some(m=>m.isAnalyzing),Z=r.useRef(null),E=r.useRef(0),U=r.useCallback(()=>{Z.current&&(E.current=Z.current.scrollTop)},[]);if(r.useEffect(()=>{Z.current&&E.current>0&&(Z.current.scrollTop=E.current)}),t.length===0&&d.length===0&&O.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No scenarios yet"}),e.jsx("p",{className:"text-xs",children:"Scenarios will appear here as Claude creates them alongside your code. Each scenario represents a different state of your app's data."})]})});if(l&&o){const m=o.name,F=o.filePath,f=o.sha,T=t.filter(K=>K.componentName===m||K.componentPath===F||!K.componentName&&(K.pageFilePath===F||f&&K.entitySha===f)),j=new Set((y==null?void 0:y[m])||[]),$=j.size>0,R=$?v.filter(K=>j.has(K.name)):[],ee=$?B.filter(K=>j.has(K.name)):[];return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsxs("button",{onClick:()=>i(void 0),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-gray-400 hover:text-white transition-colors cursor-pointer",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M7.5 9L4.5 6L7.5 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"All scenarios"]}),e.jsx("div",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-xs font-semibold text-white uppercase tracking-wider",children:o.displayName})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:T.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):De(T).map(({scenario:K,dimensionLabel:re,screenshotPath:me,key:se})=>e.jsx(tt,{scenarioId:K.id,screenshotPath:me,updatedAt:K.updatedAt,hasScreenshot:!!me,name:K.name,dimensionLabel:re,isActive:K.id===n,onSelect:()=>a(K,re??void 0)},se))}),R.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),R.map(K=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center gap-2 px-2 py-1",children:e.jsx("button",{onClick:()=>i(K.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:K.name})}),e.jsx(st,{filePath:K.filePath,projectRoot:s}),(K.scenarios.length>0||K.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:K.scenarios.map(re=>e.jsx(tt,{imgSrc:re.screenshotPath?`/api/screenshot/${re.screenshotPath}`:null,name:re.name,isActive:re.id===b,onSelect:()=>c==null?void 0:c({analysisId:K.analysisId,scenarioId:re.id,scenarioName:re.name,entitySha:K.sha,entityName:K.name})},re.id))})]},K.sha))]}),ee.length>0&&e.jsxs("div",{className:"pt-2 mt-1",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),ee.map(K=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:K.name})}),e.jsx(st,{filePath:K.filePath,projectRoot:s}),K.testFile&&e.jsx(Kt,{testFile:K.testFile,entityName:K.name,cachedResult:g[K.testFile]})]},K.sha))]})]})})}return e.jsx("div",{ref:Z,onScroll:U,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 font-['IBM_Plex_Mono']",children:[e.jsx("button",{onClick:()=>J("application"),className:`text-xs font-bold uppercase tracking-wider shrink-0 bg-transparent border-none cursor-pointer p-0 transition-colors ${P==="application"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:"Application"}),e.jsx("button",{onClick:()=>J("components"),className:`text-xs font-bold uppercase tracking-wider shrink-0 bg-transparent border-none cursor-pointer p-0 transition-colors ${P==="components"?"text-white":"text-gray-500 hover:text-gray-300"}`,children:"Components"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",style:{width:170},children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"text",placeholder:"SEARCH...",value:I,onChange:m=>_(m.target.value),className:"w-full pl-9 pr-3 py-2 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors tracking-wider"})]}),D&&e.jsxs("button",{onClick:D,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-semibold text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer shrink-0 uppercase tracking-wider",children:[e.jsx("span",{children:"+"})," New Feature"]})]}),e.jsx("div",{className:"border-b border-[#2d2d2d]"}),P==="application"&&G.size>0&&e.jsx("div",{children:[...G.entries()].sort(([m],[F])=>m==="Home"?-1:F==="Home"?1:m.localeCompare(F)).filter(([m])=>I.trim()?m.toLowerCase().includes(I.trim().toLowerCase()):!0).map(([m,F])=>{const f=F.some(T=>T.id===n&&!b);return e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[e.jsxs("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${f?"text-[#D7FF63]":"text-gray-300"}`,children:[m,e.jsxs("span",{className:`text-xs ${f?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",F.length,")"]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:f?"text-[#D7FF63]/60":"text-gray-500",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),f&&e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Edit scenarios",children:e.jsxs("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:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),D&&e.jsx("button",{onClick:D,className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Add scenario",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(F).map(({scenario:T,dimensionLabel:j,screenshotPath:$,key:R})=>e.jsx(tt,{scenarioId:T.id,screenshotPath:$,updatedAt:T.updatedAt,hasScreenshot:!!$,name:T.name,dimensionLabel:j,isActive:T.id===n&&!b,onSelect:()=>a(T,j??void 0)},R))})]},m)})}),P==="components"&&S.size>0&&e.jsx("div",{children:[...S.entries()].filter(([m])=>I.trim()?m.toLowerCase().includes(I.trim().toLowerCase()):!0).map(([m,F])=>{const f=F.some(T=>T.id===n&&!b);return e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[e.jsxs("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${f?"text-[#D7FF63]":"text-gray-300"}`,children:[m,e.jsxs("span",{className:`text-xs ${f?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",F.length,")"]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:f?"text-[#D7FF63]/60":"text-gray-500",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),f&&e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx("button",{onClick:()=>i(m,p==null?void 0:p.get(m)),className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Edit scenarios",children:e.jsxs("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:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),D&&e.jsx("button",{onClick:D,className:"p-1.5 rounded-md bg-[#3d3d3d] hover:bg-[#4d4d4d] text-gray-300 hover:text-white transition-colors cursor-pointer border-none",title:"Add scenario",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(F).map(({scenario:T,dimensionLabel:j,screenshotPath:$,key:R})=>e.jsx(tt,{scenarioId:T.id,screenshotPath:$,updatedAt:T.updatedAt,hasScreenshot:!!$,name:T.name,dimensionLabel:j,isActive:T.id===n&&!b,onSelect:()=>a(T,j??void 0)},R))})]},m)})}),v.length>0&&e.jsxs("div",{className:"pt-2 mt-1 border-t border-[#3d3d3d]",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),Y&&t.length===0&&d.every(m=>m.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),v.map(m=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx("button",{onClick:()=>i(m.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:m.name}),m.isAnalyzing&&m.scenarioCount===0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(st,{filePath:m.filePath,projectRoot:s}),(m.scenarios.length>0||m.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[m.scenarios.map(F=>e.jsx(tt,{imgSrc:F.screenshotPath?`/api/screenshot/${F.screenshotPath}`:null,name:F.name,isActive:F.id===b,onSelect:()=>c==null?void 0:c({analysisId:m.analysisId,scenarioId:F.id,scenarioName:F.name,entitySha:m.sha,entityName:m.name})},F.id)),m.pendingScenarios.map(F=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:F,children:F},F))]})]},m.sha))]}),(B.length>0||O.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${v.length>0?"":"border-t border-[#3d3d3d]"}`,children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),B.map(m=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:m.name}),m.isAnalyzing&&m.scenarioCount===0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5 text-[10px] text-gray-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#005c75] animate-pulse"}),"Analyzing..."]})]}),e.jsx(st,{filePath:m.filePath,projectRoot:s}),m.testFile?e.jsx(Kt,{testFile:m.testFile,entityName:m.name,cachedResult:g[m.testFile]}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},m.sha)),O.map(m=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-2 py-1",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-300",children:m.name})}),e.jsx(st,{filePath:m.filePath,projectRoot:s}),e.jsx(Kt,{testFile:m.testFile,entityName:m.name,cachedResult:g[m.testFile]})]},m.name))]})]})})}function fr(t){const s={};for(const[n,a]of Object.entries(t))if(typeof a=="string")try{const l=JSON.parse(a);Array.isArray(l)?s[n]=l:typeof l=="object"&&l!==null&&(s[n]=[l])}catch{}else Array.isArray(a)&&(s[n]=a);return s}function gr(t,s){return t.length===0||s.length===0?!1:t.filter(a=>s.includes(a)).length>=Math.min(t.length,s.length)*.5}function Yn(t,s){const{_metadata:n,...a}=s,l=a.localStorage&&typeof a.localStorage=="object"&&!Array.isArray(a.localStorage)?fr(a.localStorage):{},o={};if(a.seed&&typeof a.seed=="object"&&!Array.isArray(a.seed))for(const[c,y]of Object.entries(a.seed))Array.isArray(y)&&(o[c]=y);const i={},d=[],x=new Set,g=new Set,b=new Set;for(const c of t){const y=c.fields.filter(k=>!k.isRelation),M=y.map(k=>k.name),D=c.name.charAt(0).toLowerCase()+c.name.slice(1);let p=null,w=[];for(const k of[c.name,D,`${D}s`])if(k in a&&Array.isArray(a[k])){p=k,w=a[k],g.add(k);break}if(!p){for(const k of[c.name,D,`${D}s`])if(k in o){p=k,w=o[k],b.add(k),k in l&&x.add(k);break}}if(!p){for(const k of[c.name,D,`${D}s`])if(k in l){p=D,w=l[k],x.add(k);break}}if(!p){for(const[k,I]of Object.entries(l))if(!x.has(k)&&I.length>0&&gr(M,Object.keys(I[0]))){p=D,w=I,x.add(k);break}}p||(p=D),i[p]=w,d.push({label:c.name,dataKey:p,schemaFields:y.map(k=>({name:k.name,type:k.type,isId:k.isId}))})}for(const[c,y]of Object.entries(a))c==="_metadata"||c==="localStorage"||c==="seed"||c==="type"||g.has(c)||Array.isArray(y)&&(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(o))b.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(l))x.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));return{data:i,tabs:d}}function qn(t){return t==null?"null":typeof t=="number"?Number.isInteger(t)?"int4":"float":typeof t=="boolean"?"bool":typeof t=="object"?Array.isArray(t)?"array":"json":"text"}function Qn(t,s){return t.length>0?Object.keys(t[0]):s?s.map(n=>n.name):[]}function Xn(t,s,n){const a=new Map((n||[]).map(o=>[o.name,o.type])),l={};for(const o of t)l[o]=a.get(o)||(s.length>0?qn(s[0][o]):"text");return l}function Zn(t,s){var n;return((n=s==null?void 0:s.find(a=>a.isId))==null?void 0:n.name)||t.find(a=>a==="id")||null}function ea(t,s){const{_metadata:n,...a}=s,l=a.localStorage&&typeof a.localStorage=="object"&&!Array.isArray(a.localStorage)?fr(a.localStorage):{},o={};if(a.seed&&typeof a.seed=="object"&&!Array.isArray(a.seed))for(const[c,y]of Object.entries(a.seed))Array.isArray(y)&&(o[c]=y);const i={},d=[],x=new Set,g=new Set,b=new Set;for(const c of t){const y=c.name.charAt(0).toLowerCase()+c.name.slice(1),M=c.fields.map(w=>w.name);let D=null,p=[];for(const w of[c.name,y,`${y}s`])if(w in a&&Array.isArray(a[w])){D=w,p=a[w],g.add(w);break}if(!D){for(const w of[c.name,y,`${y}s`])if(w in o){D=w,p=o[w],b.add(w),w in l&&x.add(w);break}}if(!D){for(const w of[c.name,y,`${y}s`])if(w in l){D=y,p=l[w],x.add(w);break}}if(!D){for(const[w,k]of Object.entries(l))if(!x.has(w)&&k.length>0&&gr(M,Object.keys(k[0]))){D=y,p=k,x.add(w);break}}D||(D=y),i[D]=p,d.push({label:c.name,dataKey:D,category:c.category,description:c.description,schemaFields:c.fields.map(w=>({name:w.name,type:w.type,isId:w.isId??!1}))})}for(const[c,y]of Object.entries(a))c==="_metadata"||c==="localStorage"||c==="seed"||c==="type"||g.has(c)||Array.isArray(y)&&(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(o))b.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));for(const[c,y]of Object.entries(l))x.has(c)||(i[c]=y,d.push({label:c,dataKey:c}));return{data:i,tabs:d}}function ts(t){var l,o;const s=new Map,n=new Map;for(const i of t)if(i.componentName){const d=n.get(i.componentName)||[];d.push(i),n.set(i.componentName,d)}else if(hr(i.url)){const d=(l=i.url)==null?void 0:l.match(/[?&]c=([^&]+)/),x=d?decodeURIComponent(d[1]):"Isolated",g=n.get(x)||[];g.push(i),n.set(x,g)}else{const d=i.displayName||((o=i.pageFilePath)!=null&&o.startsWith("app/")?nt(rt(i.pageFilePath)):St(i.url)),x=s.get(d)||[];x.push(i),s.set(d,x)}const a=new Map([...n.entries()].sort(([i],[d])=>i.localeCompare(d)));return{pageGroups:s,componentGroups:a}}function br(t,s){var a,l;const n=new Map;for(const[o,i]of t){const d=(a=i.find(x=>x.entitySha))==null?void 0:a.entitySha;d&&n.set(o,d)}for(const[o,i]of s){const d=(l=i.find(x=>x.entitySha))==null?void 0:l.entitySha;d&&n.set(o,d)}return n}function ta(t){const s=new Set;for(const[n,a]of Object.entries(t)){s.add(n);for(const l of a)s.add(l)}return s}function sa(t,s,n,a){if(s.has(t))return!0;const l=n.find(o=>o.sha===t);return l?a.has(l.name):!1}function ra(t,s,n,a){const l=[];for(const[o,i]of t){const d=n.get(o);d?a(d)||l.push({name:o,scenarios:i,reason:"incomplete"}):l.push({name:o,scenarios:i,reason:"missing"})}for(const[o,i]of s){const d=n.get(o);d?a(d)||l.push({name:o,scenarios:i,reason:"incomplete"}):l.push({name:o,scenarios:i,reason:"missing"})}return l}function Ws(t,s,n){if(!t)return null;const a=s.find(l=>l.sha===t);return a?{sha:t,name:a.name,filePath:a.filePath,entityType:a.entityType,displayName:a.name}:null}const Hs=120;function yr({text:t,theme:s}){const[n,a]=r.useState(!1),l=t.length>Hs,o=l&&!n?t.slice(0,Hs)+"…":t,i=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${i?"border-b border-gray-200 bg-gray-50":"border-b border-[#3d3d3d] bg-[#252525]"}`,children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-gray-500",children:"User Prompt"}),e.jsxs("p",{className:`text-[11px] mt-0.5 mb-0 leading-relaxed ${i?"text-gray-600":"text-gray-400"}`,children:[o,l&&e.jsx("button",{onClick:()=>a(!n),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${i?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:n?"Show less":"Read more…"})]})]})}const Us={new:0,edited:1,impacted:2};function zs({status:t,onClick:s}){const n={new:{label:"New",bg:"bg-green-100",text:"text-green-700",border:"border-green-200"},edited:{label:"Edited",bg:"bg-blue-100",text:"text-blue-700",border:"border-blue-200"},impacted:{label:"Impacted",bg:"bg-amber-100",text:"text-amber-700",border:"border-amber-200"}}[t.status],a=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:a?s:void 0,className:`${n.bg} ${n.text} ${n.border} border text-[9px] font-bold px-1.5 py-0.5 rounded-full uppercase tracking-wider shrink-0 ${a?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:n.label})}function Vs({filePath:t}){const[s,n]=r.useState(null),[a,l]=r.useState(!0),[o,i]=r.useState(null);return r.useEffect(()=>{pr(()=>import("./index-SqjQKTdH.js"),__vite__mapDeps([0,1,2])).then(d=>{i(()=>d.default)})},[]),r.useEffect(()=>{l(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(d=>d.json()).then(d=>{n({oldContent:d.oldContent,newContent:d.newContent})}).catch(()=>{n(null)}).finally(()=>l(!1))},[t]),a?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!o?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Could not load diff"}):e.jsx("div",{className:"mt-2 border border-gray-200 rounded-lg overflow-hidden max-h-[300px] overflow-auto text-xs",children:e.jsx(o,{oldValue:s.oldContent,newValue:s.newContent,splitView:!1,useDarkTheme:!1,showDiffOnly:!0,styles:{contentText:{fontSize:"11px",lineHeight:"1.4"},line:{padding:"1px 8px",fontSize:"11px"}}})})}function Gs({impactedBy:t,changedEntities:s}){return e.jsx("div",{className:"mt-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5",children:t&&t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Re-captured because these dependencies changed"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:t.map(n=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${n.changeType==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.changeType==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name}),e.jsx("span",{className:"text-[9px] text-amber-500 truncate",children:n.filePath})]},n.filePath))})]}):s&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"Unchanged — these entities were modified in this session"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:s.map(n=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold px-1 py-0 rounded-full uppercase tracking-wider border ${n.status==="new"?"bg-green-100 text-green-700 border-green-200":"bg-blue-100 text-blue-700 border-blue-200"}`,children:n.status==="new"?"New":"Edited"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-800",children:n.name})]},n.name))})]}):e.jsx("span",{className:"text-[10px] text-amber-600",children:"This component was re-captured because a dependency changed"})})}function Js({scenarioId:t,screenshotPath:s,name:n,dimensionLabel:a,isActive:l,onSelect:o,updatedAt:i}){const d=r.useRef(null);return r.useEffect(()=>{l&&d.current&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[l]),e.jsxs("button",{ref:d,onClick:o,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:a?`${n} (${a})`:n,children:[e.jsxs("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all relative ${l?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:[e.jsx(Je,{scenarioId:t,screenshotPath:s,updatedAt:i,alt:a?`${n} (${a})`:n,className:"w-full h-full bg-white",imgClassName:"w-full h-full object-contain bg-white"}),a&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[9px] font-medium bg-black/60 text-white px-1.5 py-0.5 rounded",children:a})]}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${l?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:a?`${n} (${a})`:n})]})}function na({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1 text-gray-400 hover:text-gray-600 transition-colors min-w-0",children:[e.jsx("span",{className:"text-[9px] truncate",children:t}),e.jsx("svg",{className:"shrink-0",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Re,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function Xt({testFile:t,entityName:s,cachedResult:n}){const{results:a,isRunning:l,runTests:o,stale:i}=es(t,n);if(l&&!a)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#0ea5e9] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-500",children:a.errorMessage})});const d=s?a.testCases.filter(b=>b.fullName.startsWith(s)):a.testCases,x=d.length>0?d:a.testCases;if(x.length===0)return null;const g=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[x.map(b=>{var y;const c=g&&b.fullName.startsWith(g)?b.fullName.slice(g.length):b.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[b.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):b.status==="failed"?e.jsx("span",{className:"text-red-500 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-400 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${b.status==="passed"?"text-green-600":b.status==="failed"?"text-red-500":"text-gray-400"}`,children:c})]}),b.status==="failed"&&((y=b.failureMessages)==null?void 0:y.map((M,D)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:M,children:M.split(`
|
|
4
|
+
`)[0]},D)))]},b.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:o,disabled:l,className:"text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":i?"Re-run (stale)":"Re-run"}),i&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}function Ks(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function Ys(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([n],[a])=>{var d,x;const l=((d=s[n])==null?void 0:d.status)||"impacted",o=((x=s[a])==null?void 0:x.status)||"impacted",i=(Us[l]??2)-(Us[o]??2);return i!==0?i:n.localeCompare(a)})}function aa({scenarios:t,allScenarios:s=[],glossaryFunctions:n=[],cachedTestResults:a={},projectRoot:l,activeScenarioId:o,onScenarioSelect:i,onClose:d,entityChangeStatus:x={},modifiedFiles:g=[],featureName:b,userPrompt:c}){const y=r.useMemo(()=>{if(s.length===0||Object.keys(x).length===0)return t;const S=new Set(t.map(B=>B.id)),v=s.filter(B=>{var Y,Z;if(S.has(B.id))return!1;const O=B.componentName||B.displayName||((Y=B.pageFilePath)!=null&&Y.startsWith("app/")?nt(rt(B.pageFilePath)):St(B.url));return((Z=x[O])==null?void 0:Z.status)==="impacted"});return v.length===0?t:[...t,...v]},[t,s,x]),M=r.useMemo(()=>Object.entries(x).filter(([,S])=>S.status==="new"||S.status==="edited").map(([S,v])=>({name:S,status:v.status})),[x]),[D,p]=r.useState(null),w=r.useCallback(S=>{p(v=>v===S?null:S)},[]),{pageGroups:k,componentGroups:I}=r.useMemo(()=>ts(y),[y]),_=r.useMemo(()=>Ys([...k.entries()],x),[k,x]),H=r.useMemo(()=>Ys([...I.entries()],x),[I,x]),z=_,P=H,J=r.useMemo(()=>$n(n,x),[n,x]),G=r.useMemo(()=>{const S=[];for(const[,v]of z)S.push(...v);for(const[,v]of P)S.push(...v);return S},[z,P]),V=r.useRef(!1);return r.useEffect(()=>{V.current||G.length!==0&&(V.current=!0,console.log("[ResultsPanel] Auto-selecting first scenario: %s",G[0].name),i(G[0]))},[G,i]),r.useEffect(()=>{if(G.length===0)return;const S=v=>{if(v.key!=="ArrowLeft"&&v.key!=="ArrowRight")return;const B=v.target,O=B==null?void 0:B.tagName;if(O==="INPUT"||O==="SELECT"||O==="TEXTAREA"&&!B.classList.contains("xterm-helper-textarea"))return;v.preventDefault();const Y=G.findIndex(E=>E.id===o);let Z;v.key==="ArrowLeft"?Z=Y<=0?G.length-1:Y-1:Z=Y>=G.length-1?0:Y+1,i(G[Z])};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[G,o,i]),y.length===0&&n.length===0?e.jsxs("div",{className:"h-full bg-white flex items-center justify-center relative",children:[e.jsx("button",{onClick:d,className:"absolute top-2 right-3 text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none",title:"Close results",children:"×"}),e.jsx("span",{className:"text-sm text-gray-400",children:"No scenarios registered yet"})]}):e.jsxs("div",{className:"h-full bg-white flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-gray-200 shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Working Session Results"}),b&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:b,children:b})]}),e.jsx("button",{onClick:d,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),c&&e.jsx(yr,{text:c,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[z.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"})}),e.jsx("div",{className:"space-y-3 pl-1",children:z.map(([S,v])=>{var Z;const B=x[S],O=D===S,Y=(Z=v[0])==null?void 0:Z.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:S}),B&&e.jsx(zs,{status:B,onClick:()=>w(S)})]}),O&&(B==null?void 0:B.status)==="edited"&&Y&&e.jsx(Vs,{filePath:Y}),O&&(B==null?void 0:B.status)==="impacted"&&e.jsx(Gs,{impactedBy:B.impactedBy,changedEntities:M}),e.jsx("div",{className:"flex flex-wrap gap-3",children:De(v).map(({scenario:E,dimensionLabel:U,screenshotPath:m,key:F})=>e.jsx(Js,{scenarioId:E.id,screenshotPath:m,name:Ks(E.name),dimensionLabel:U,isActive:E.id===o,onSelect:()=>i(E,U??void 0),updatedAt:E.updatedAt},F))})]},S)})})]}),P.length>0&&e.jsxs("div",{className:z.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"})}),e.jsx("div",{className:"space-y-3 pl-1",children:P.map(([S,v])=>{var Z;const B=x[S],O=D===S,Y=(Z=v[0])==null?void 0:Z.componentPath;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-600",children:S}),B&&e.jsx(zs,{status:B,onClick:()=>w(S)})]}),O&&(B==null?void 0:B.status)==="edited"&&Y&&e.jsx(Vs,{filePath:Y}),O&&(B==null?void 0:B.status)==="impacted"&&e.jsx(Gs,{impactedBy:B.impactedBy,changedEntities:M}),e.jsx("div",{className:"flex flex-wrap gap-3",children:De(v).map(({scenario:E,dimensionLabel:U,screenshotPath:m,key:F})=>e.jsx(Js,{scenarioId:E.id,screenshotPath:m,name:Ks(E.name),dimensionLabel:U,isActive:E.id===o,onSelect:()=>i(E,U??void 0),updatedAt:E.updatedAt},F))})]},S)})})]}),J.length>0&&e.jsxs("div",{className:z.length>0||P.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"})}),e.jsx("div",{className:"space-y-2 pl-1",children:J.map(S=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-700",children:S.name})}),e.jsx(na,{filePath:S.filePath,projectRoot:l}),S.testFile?e.jsx(Xt,{testFile:S.testFile,entityName:S.name,cachedResult:a[S.testFile]}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},S.name))})]}),g.length>0&&e.jsxs("div",{className:z.length>0||P.length>0||J.length>0?"pt-3 border-t border-gray-200":"",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",g.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:g.map(S=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${S.status==="added"||S.status==="untracked"?"text-green-600":S.status==="modified"?"text-blue-600":S.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:S.status==="added"||S.status==="untracked"?"A":S.status==="modified"?"M":S.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:S.path})]},S.path))})]})]})})]})}function qs(t,s,n,a){var x;const l=a.length>0?a.map(g=>`- "${g.name}" (ID: ${g.id})${g.url?` — URL: ${g.url}`:""}`).join(`
|
|
5
|
+
`):"(no scenarios yet)",o=s.endsWith("/page.tsx")||s.endsWith("/page.js"),i=((x=a.find(g=>g.url))==null?void 0:x.url)||"/",d=[`You are helping edit scenarios for the "${t}" entity in a CodeYam project.`,"","## Entity",`- **Name:** ${t}`,`- **File:** ${s}`,`- **Type:** ${o?"Page (application scenario with seed data)":"Component (component scenario with mock props)"}`,"","## Existing Scenarios",l,""];return o?d.push("## How Seed Data Works","","Application scenarios use `seed` data to populate the database before the page is captured.","The seed is a JSON object where each key is a Prisma model name in camelCase singular (matching the Prisma client accessor name) and the value is an array of records.","","### Seed Key Naming Convention","The key must be the camelCase singular form of the Prisma model name:",'- `model User` → key `"user"`','- `model BlogPost` → key `"blogPost"`','- `model Feedback` → key `"feedback"`',"",'**WARNING:** Do NOT use plural forms like "users", "blogPosts", or "feedbacks" — the seed adapter will silently fail to match them.',"","To understand the data models, read the Prisma schema at `prisma/schema.prisma`.","To see examples of existing seed data, look at `.codeyam/editor-scenarios/*.seed.json` files.","",`Also read the source file at \`${s}\` to understand what data the page queries and renders.`,"","## Registering a Scenario","","For small seed data, pass it inline:","```",`codeyam editor register '{"name":"Scenario Name","type":"application","url":"${i}","dimensions":["Laptop"],"seed":{"user":[...],"feedback":[...]}}'`,"```","","For large seed data, write it to a temp file and use @file syntax:","```","# Write JSON to a temp file","cat > .codeyam/tmp/scenario.json << 'SCENARIO_EOF'",`{"name":"Scenario Name","type":"application","url":"${i}","dimensions":["Laptop"],"seed":{"user":[...],"feedback":[...]}}`,"SCENARIO_EOF","codeyam editor register @.codeyam/tmp/scenario.json","```"):d.push("## Registering a Scenario","",`Read the source file at \`${s}\` to understand what props the component expects.`,"","```",`codeyam editor register '{"name":"Scenario Name","type":"component","componentName":"${t}","componentPath":"${s}","dimensions":["Laptop"],"mockData":{"propName":"value"}}'`,"```"),d.push("","## Deleting a Scenario","","To delete a scenario, use its ID from the list above:","```","codeyam editor delete <scenarioId>","```","","## Validating Seed Data","","Before registering, you can validate seed data structure and check that keys match Prisma models:","```",`codeyam editor validate-seed '{"user":[...]}'`,"```"),d.push("","## Recapturing Scenarios After Code Changes","",`If the user asks you to modify the code for this ${o?"page":"component"} (CSS, layout, logic, etc.), you MUST re-register all existing scenarios after the code change so their screenshots are updated.`,"","Re-registering a scenario with the same name overwrites it and captures a fresh screenshot.","","To recapture, re-register each existing scenario using `codeyam editor register` with its current configuration. You can read the scenario JSON files in `.codeyam/editor-scenarios/` to get the exact registration data for each scenario."),d.push("","## Important","- DO NOT take any action until the user tells you what they want","- Start by briefly listing the existing scenarios",'- Then ask: "Would you like to modify an existing scenario or add a new one?"',"- Wait for the user's answer before proceeding",'- Keep scenario names descriptive: "Empty State", "With Comments", "Admin View", etc.',`- Each scenario should capture a distinct, meaningful state of the ${o?"page":"component"}`),d.join(`
|
|
6
|
+
`)}function jr(t,s){var l;const n=s.some(o=>!o.componentName),a=s.map(o=>`'${o.id}'`).join(", ");if(n){const o=((l=s.find(d=>d.url))==null?void 0:l.url)||null,i=s.map(d=>`.codeyam/editor-scenarios/${d.id}.json`).join(", ");return[`### Page: "${t}" (${s.length} scenario(s))`,...o?["",`Scenario URL: \`${o}\``]:[],"",...o?["Step A: Find the source file that renders this page. In Next.js App Router, URLs map to page.tsx files:"," - `/` → `app/page.tsx`"," - `/about` → `app/about/page.tsx`"," - `/c/my-slug` → `app/c/[slug]/page.tsx` (dynamic segment)","",`Based on the URL \`${o}\`, find the corresponding page.tsx file. Confirm it exists with \`cat <filepath> | head -5\`.`]:["Step A: Find the source file that renders this page by running:",' find src app -name "App.tsx" -o -name "App.jsx" -o -name "page.tsx" -o -name "page.jsx" -o -name "index.tsx" 2>/dev/null',"","Pick the file that is the main app entry point or the page component for this route. Confirm it exists with `cat <filepath> | head -5`."],"","Step B: Set page_file_path on all scenarios for this page (replace PAGE_FILE_PATH with the path from Step A):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET page_file_path = 'PAGE_FILE_PATH' WHERE id IN (${a});"`,"","Step C: Get the entity SHA (after running analyze-imports in the shared step above):",` sqlite3 .codeyam/db.sqlite3 "SELECT sha FROM entities WHERE file_path = 'PAGE_FILE_PATH' ORDER BY created_at DESC LIMIT 1;"`,"","If no rows appear, the path was wrong — go back to Step A.","","Step D: Set entity_sha and display_name on all scenarios (replace ENTITY_SHA with the SHA from Step C):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET entity_sha = 'ENTITY_SHA', display_name = '${t}' WHERE id IN (${a});"`,"","Step E: Add pageFilePath to the scenario JSON files so this fix persists across clones.",`For each file (${i}), read it and add \`"pageFilePath": "PAGE_FILE_PATH"\` to the \`_metadata\` object (after the \`"type"\` field). Then commit the updated JSON files.`].join(`
|
|
7
7
|
`)}else return[`### Component: "${t}" (${s.length} scenario(s))`,"","Step A: Get the entity SHA (after running analyze-imports in the shared step above):",` sqlite3 .codeyam/db.sqlite3 "SELECT sha FROM entities WHERE name = '${t}' ORDER BY created_at DESC LIMIT 1;"`,"","If no rows appear, check that .codeyam/glossary.json contains an entry for this component.","","Step B: Set entity_sha and display_name on all scenarios (replace ENTITY_SHA with the SHA from Step A):",` sqlite3 .codeyam/db.sqlite3 "UPDATE editor_scenarios SET entity_sha = 'ENTITY_SHA', display_name = '${t}' WHERE id IN (${a});"`].join(`
|
|
8
|
-
`)}function
|
|
9
|
-
`):[`The "${t}" ${s.some(d=>!d.componentName)?"page":"component"} is missing entity data in the CodeYam database. Its scenarios are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Instead, update the database and scenario JSON files directly.","","Follow these steps EXACTLY:","","Step 1: Run: codeyam editor analyze-imports","","Step 2: Fix this entity:","",
|
|
10
|
-
`);return e.jsx(
|
|
11
|
-
`);return e.jsx("div",{className:"p-4 rounded-lg border border-[#E0D400]/40 bg-[#E0D400]/8",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#E0D400",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsxs("p",{className:"flex-1 min-w-0 text-sm text-[#E0D400]/90 m-0 leading-snug font-['IBM_Plex_Sans']",children:[t.length," ",t.length===1?"entity is":"entities are"," missing data, resulting in ",l," hidden scenario",l!==1?"s":"","."," ",e.jsx("button",{type:"button",className:"font-bold underline bg-transparent border-none text-[#E0D400] cursor-pointer p-0 text-sm inline hover:text-[#E0D400]/70 transition-colors",onClick:()=>a(d),children:s?e.jsxs("span",{className:"inline-flex items-center gap-1",children:["Copied",e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"inline",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]}):"Copy this prompt"})," ","into Claude to fix them all at once."]}),e.jsx(
|
|
12
|
-
`);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{if(s.length>1){const q=s[s.length-2];n(q.componentName,q.entitySha)}else n()},className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 shrink-0 text-lg",title:"Go back",children:"←"}),e.jsx("h2",{className:"text-lg font-medium text-white m-0 font-['IBM_Plex_Sans']",children:t.displayName})]}),_&&e.jsx(
|
|
13
|
-
`)},[t.displayName,t.entityType,_,he]),L=new Set((f==null?void 0:f[H])||[]),xe=$?[...p.entries()].filter(([h])=>L.has(h)):[],ie=$?w.filter(h=>L.has(h.name)&&!xe.some(([R])=>R===h.name)):[],de=$?M.filter(h=>L.has(h.name)&&h.returnType!=="JSX.Element"&&h.returnType!=="React.ReactNode").map(h=>({name:h.name,filePath:h.filePath,description:h.description||"",testFile:h.testFile,feature:h.feature})):[],ne=xe.length>0||ie.length>0,N=de.length>0;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("button",{onClick:()=>{if(s.length>1){const h=s[s.length-2];n(h.componentName,h.entitySha)}else n()},className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 shrink-0 text-xl",title:"Go back",children:"←"}),e.jsx("h2",{className:"text-xl font-medium text-white m-0 font-['IBM_Plex_Sans']",children:t.displayName})]}),t.filePath&&e.jsx("div",{className:"mt-1.5 ml-7",children:e.jsx(ft,{filePath:t.filePath,projectRoot:a})})]}),e.jsx("div",{className:"-mx-5 px-5 border-t border-b border-[#3d3d3d] flex items-center gap-6",children:[["scenarios","Scenarios"],["components","Components"],["functions","Functions"],["data-structure","Data Structure"]].map(([h,R])=>e.jsx("button",{onClick:()=>P(h),className:`text-xs font-normal uppercase tracking-wider transition-colors bg-transparent border-none cursor-pointer px-0 font-['IBM_Plex_Mono'] border-b-2 leading-none ${z===h?"text-[#D7FF63] border-b-[#D7FF63]":"text-gray-500 hover:text-gray-300 border-b-transparent"}`,style:{marginBottom:-1,paddingTop:16,paddingBottom:14},children:R},h))}),z==="scenarios"&&e.jsxs("div",{className:"space-y-3 mt-5",children:[he.map(h=>{const R=h.id===i,q=J===h.id;return e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>{q||d(h)},className:`flex items-center gap-4 p-3 rounded-lg cursor-pointer transition-colors ${R?"bg-[#1a2e1a] border border-[#D7FF63]/40":"bg-[#252525] hover:bg-[#2a2a2a] border border-transparent"}`,style:{opacity:O===h.id?.4:1},children:[h.screenshotPaths&&Object.keys(h.screenshotPaths).length>1?e.jsx("div",{className:"flex gap-2 shrink-0",children:Object.entries(h.screenshotPaths).map(([te,ae])=>e.jsxs("div",{className:"relative",children:[e.jsx(Je,{scenarioId:h.id,screenshotPath:ae,updatedAt:h.updatedAt,alt:te,className:"rounded w-[120px] h-[75px] overflow-hidden border border-[#3d3d3d]",imgClassName:"w-full h-full object-cover"}),e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:te})]},te))}):h.screenshotPath?e.jsx(Je,{scenarioId:h.id,screenshotPath:h.screenshotPath,updatedAt:h.updatedAt,alt:"",className:"rounded w-[160px] h-[100px] shrink-0 overflow-hidden border border-[#3d3d3d]",imgClassName:"w-full h-full object-cover"}):e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[160px] h-[100px] shrink-0 flex items-center justify-center border border-[#3d3d3d]",children:e.jsx("span",{className:"text-[10px] text-gray-600",children:"No image"})}),e.jsx("div",{className:"flex-1 min-w-0",children:q?e.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:te=>{te.preventDefault(),I(h.id)},onClick:te=>te.stopPropagation(),children:[e.jsx("input",{type:"text",value:V,onChange:te=>S(te.target.value),className:"flex-1 px-2 py-1 text-xs bg-[#1e1e1e] text-white border border-[#3d3d3d] rounded outline-none focus:border-[#005c75] min-w-0",autoFocus:!0,disabled:v}),e.jsx("button",{type:"submit",disabled:v||!V.trim(),className:"px-2 py-1 text-[10px] bg-[#005c75] text-white rounded hover:bg-[#004d63] disabled:opacity-40 cursor-pointer border-none",children:v?"...":"Save"}),e.jsx("button",{type:"button",onClick:()=>G(null),className:"px-2 py-1 text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-gray-300 truncate block",children:h.name}),R&&e.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[e.jsx("button",{onClick:te=>{te.stopPropagation(),g(C===h.id?null:h.id)},className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 cursor-pointer bg-transparent border-none p-0",children:"View Data"}),e.jsx("button",{onClick:te=>{te.stopPropagation(),m(!1),E(!0)},className:"text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none p-0",children:"Edit with Claude"}),e.jsx("button",{onClick:te=>{te.stopPropagation(),G(h.id),S(h.name)},className:"text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none p-0",children:"Rename"}),e.jsx("button",{onClick:te=>{te.stopPropagation(),ee(h)},disabled:O===h.id,className:"text-[10px] text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none p-0",children:"Delete"})]})]})})]}),C===h.id&&e.jsx(aa,{scenarioId:h.id,onClose:()=>g(null),editPrompt:Js(t.displayName,t.filePath,t.entityType,he),onReseedPreview:A})]},h.id)}),se&&(se.scenarios.length>0||se.pendingScenarios.length>0)&&e.jsxs("div",{className:"space-y-1 mt-2",children:[se.scenarios.map(h=>e.jsxs("div",{onClick:()=>x({analysisId:se.analysisId,scenarioId:h.id,scenarioName:h.name,entitySha:se.sha,entityName:se.name}),className:"flex items-center gap-3 p-2 rounded cursor-pointer transition-colors hover:bg-[#252525] border border-transparent",children:[h.screenshotPath?e.jsx("img",{src:`/api/screenshot/${h.screenshotPath}`,alt:h.name,className:"rounded w-[48px] h-[48px] shrink-0 object-cover",loading:"lazy"}):e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[48px] h-[48px] shrink-0 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})}),e.jsx("span",{className:"text-xs text-gray-300 truncate",children:h.name})]},h.id)),se.pendingScenarios.map(h=>e.jsxs("div",{className:"flex items-center gap-3 p-2",children:[e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[48px] h-[48px] shrink-0 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"..."})}),e.jsx("span",{className:"text-xs text-gray-500 truncate",children:h})]},h))]}),he.length===0&&!se&&!pe&&e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No scenarios for this entity"}),e.jsxs("button",{onClick:()=>{E(!1),m(!0)},className:"flex items-center gap-2.5 mt-4 text-xs text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none cursor-pointer p-0 font-normal uppercase tracking-wider font-['IBM_Plex_Mono'] transition-colors",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),"Create New Scenario"]}),U&&e.jsx("div",{className:"mt-2 border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(Me,{prompt:ge,height:500,onClose:()=>m(!1)})}),Z&&he.length>0&&e.jsx("div",{className:"mt-2 border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(Me,{prompt:Js(t.displayName,t.filePath,t.entityType,he),height:500,onClose:()=>E(!1)})})]}),z==="components"&&e.jsx("div",{className:"space-y-3",children:ne?e.jsxs(e.Fragment,{children:[xe.map(([h,R])=>e.jsx("div",{children:D.has(h)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>n(h,D.get(h)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:h})}),R.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(R).map(({scenario:q,dimensionLabel:te,screenshotPath:ae,key:oe})=>e.jsx(Nt,{scenarioId:q.id,screenshotPath:ae,updatedAt:q.updatedAt,hasScreenshot:!!ae,name:q.name,dimensionLabel:te,isActive:q.id===i,onSelect:()=>d(q,te??void 0)},oe))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-500",children:h}),e.jsx("p",{className:"text-[10px] text-amber-400/80 m-0 mt-1.5 leading-relaxed",children:"There is data missing that is required to show the scenarios for this component. Please copy and paste this prompt into Claude to ask Claude to fix the data."}),e.jsx("div",{className:"mt-1.5",children:e.jsx(br,{name:h,scenarios:R})})]})},h)),ie.map(h=>e.jsxs("div",{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>n(h.name,h.sha),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:h.name})}),(h.scenarios.length>0||h.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[h.scenarios.map(R=>e.jsx(Nt,{imgSrc:R.screenshotPath?`/api/screenshot/${R.screenshotPath}`:null,name:R.name,isActive:!1,onSelect:()=>x({analysisId:h.analysisId,scenarioId:R.id,scenarioName:R.name,entitySha:h.sha,entityName:h.name})},R.id)),h.pendingScenarios.map(R=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:R,children:R},R))]})]},h.sha))]}):e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No component dependencies"})}),z==="functions"&&e.jsxs("div",{className:"space-y-3",children:[pe&&pe.testFile&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(ft,{filePath:pe.testFile,projectRoot:a})]}),e.jsx(qt,{testFile:pe.testFile,entityName:H,cachedResult:y[pe.testFile]})]}),N?e.jsx("div",{children:de.map(h=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>n(h.name,D.get(h.name)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:h.name})}),e.jsx(ft,{filePath:h.filePath,projectRoot:a}),h.testFile&&e.jsxs("div",{className:"mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[9px] text-gray-600",children:"test:"}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate",children:h.testFile})]}),e.jsx(qt,{testFile:h.testFile,entityName:h.name,cachedResult:y[h.testFile]})]})]},h.name))}):pe!=null&&pe.testFile?null:e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No function dependencies"})]}),z==="data-structure"&&e.jsx(oa,{})]})})}function aa({scenarioId:t,onClose:s,editPrompt:n,onReseedPreview:a}){const[l,o]=r.useState(null),[i,d]=r.useState([]),[x,b]=r.useState(!0),[f,c]=r.useState(null),[y,M]=r.useState(null),[D,p]=r.useState(!1),[w,k]=r.useState(null),[A,_]=r.useState(""),[H,z]=r.useState(""),[P,J]=r.useState(0),[G,V]=r.useState(!1),[S,v]=r.useState(!1),B=r.useRef(null);if(r.useEffect(()=>{b(!0),c(null),Promise.all([fetch("/api/editor-schema").then(g=>g.json()).catch(()=>({models:[]})),fetch(`/api/editor-scenario-data?scenarioId=${t}`).then(g=>g.json())]).then(([g,T])=>{const j=g.source==="explicit"?Xn(g.dataStructures||[],T):Jn(g.models||[],T);o(j.data),d(j.tabs),j.tabs.length>0&&!y&&M(j.tabs[0].dataKey)}).catch(()=>c("Failed to load scenario data")).finally(()=>b(!1))},[t,P]),x)return e.jsx("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-gray-400",children:"Loading mock data..."});if(f||!l)return e.jsx("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-red-400",children:f||"No data available"});if(i.length===0)return e.jsxs("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-gray-500",children:["No mock data found for this scenario.",e.jsx("button",{onClick:s,className:"ml-2 text-gray-400 hover:text-white bg-transparent border-none cursor-pointer text-[10px]",children:"Dismiss"})]});const O=i.find(g=>g.dataKey===y)||i[0],Y=y?l[y]||[]:[],Z=Yn(Y,O.schemaFields),E=qn(Z,Y,O.schemaFields),U=Qn(Z,O.schemaFields);return e.jsxs("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 bg-[#252525] border-b border-[#3d3d3d] flex-wrap",children:[i.map(g=>{const T=y===g.dataKey,j=g.category==="datastore"?T?"text-[#D7FF63] bg-[#D7FF63]/15 border-[#D7FF63]/40":"text-[#D7FF63]/60 bg-transparent border-transparent hover:text-[#D7FF63]/80":g.category==="mock-api"?T?"text-blue-400 bg-blue-400/15 border-blue-400/40":"text-blue-400/60 bg-transparent border-transparent hover:text-blue-400/80":T?"text-white bg-[#3d3d3d] border-[#4d4d4d]":"text-gray-500 bg-transparent border-transparent hover:text-gray-300";return e.jsx("button",{onClick:()=>M(g.dataKey),className:`px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider rounded cursor-pointer border transition-colors ${j}`,children:g.label},g.dataKey)}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"w-5 h-5 flex items-center justify-center text-gray-500 hover:text-white bg-[#3d3d3d] hover:bg-[#4d4d4d] rounded-full border-none cursor-pointer text-xs transition-colors",title:"Close",children:"×"})]}),(O.description||O.category)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#1e1e1e] border-b border-[#2d2d2d]",children:[O.category&&e.jsx("span",{className:`text-[9px] rounded px-1.5 py-0 border ${O.category==="datastore"?"text-[#D7FF63]/80 bg-[#D7FF63]/10 border-[#D7FF63]/30":O.category==="mock-api"?"text-blue-400/80 bg-blue-400/10 border-blue-400/30":"text-gray-400 bg-gray-700/30 border-gray-600/30"}`,children:O.category==="mock-api"?"API Mock":O.category}),O.description&&e.jsx("span",{className:"text-[10px] text-gray-500",children:O.description})]}),Z.length===0?e.jsx("div",{className:"px-3 py-4 text-[10px] text-gray-500 text-center",children:"No columns defined for this table"}):e.jsx("div",{className:"overflow-x-auto max-h-[300px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-[10px] border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#1e1e1e] sticky top-0 z-10",children:[e.jsx("th",{className:"text-right text-gray-600 font-normal px-2 py-1.5 border-b border-[#3d3d3d] w-8",children:"#"}),Z.map(g=>e.jsxs("th",{className:"text-left px-2 py-1.5 border-b border-[#3d3d3d] whitespace-nowrap overflow-hidden",children:[g===U&&e.jsx("span",{className:"inline-block text-[8px] font-bold text-white bg-[#D7FF63] rounded px-1 py-0 mr-1.5 align-middle",children:"PK"}),e.jsx("span",{className:"text-gray-300 font-medium",children:g}),e.jsx("span",{className:"text-gray-600 font-normal ml-1",children:E[g]})]},g))]})}),e.jsx("tbody",{children:Y.map((g,T)=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] hover:bg-[#252525] group/row",children:[e.jsx("td",{className:"text-right text-gray-600 px-2 py-1.5 w-8 select-none",children:T+1}),Z.map(j=>e.jsxs("td",{className:`px-2 py-1.5 overflow-hidden relative group/cell ${j===U?"text-[#D7FF63] font-medium":"text-gray-300"}`,title:String(g[j]??""),children:[e.jsx("span",{className:"truncate block whitespace-nowrap",children:g[j]===null?e.jsx("span",{className:"text-gray-600 italic",children:"null"}):typeof g[j]=="object"?e.jsx("span",{className:"text-gray-500",children:JSON.stringify(g[j])}):typeof g[j]=="number"?e.jsx("span",{className:"text-amber-400",children:String(g[j])}):String(g[j])}),e.jsx("button",{onClick:$=>{$.stopPropagation(),k({row:T,col:j});const I=g[j]===null?"":typeof g[j]=="object"?JSON.stringify(g[j]):String(g[j]);_(I),z(I)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover/cell:opacity-100 text-gray-500 hover:text-white bg-[#252525] border border-[#4d4d4d] rounded cursor-pointer p-0.5 transition-opacity",title:"Edit",children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]},j))]},T))})]})}),w&&e.jsxs("div",{className:"border-t border-[#3d3d3d] bg-[#1e1e1e] px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1.5",children:e.jsxs("span",{className:"text-[10px] text-gray-400",children:["Editing"," ",e.jsx("strong",{className:"text-gray-200",children:w.col})," in row ",w.row+1]})}),e.jsx("textarea",{value:A,onChange:g=>{const T=g.target.value;_(T),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{C(O.dataKey,w.row,w.col,T)},600)},className:"w-full px-2 py-1.5 text-[11px] bg-[#252525] text-white border border-[#4d4d4d] rounded outline-none focus:border-[#D7FF63]/50 resize-y min-h-[60px] max-h-[200px] font-mono",autoFocus:!0,rows:A.length>100?4:2,onKeyDown:g=>{g.key==="Escape"&&m(),g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&(B.current&&clearTimeout(B.current),C(O.dataKey,w.row,w.col,A),k(null))}}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("button",{onClick:()=>{B.current&&clearTimeout(B.current),C(O.dataKey,w.row,w.col,A),k(null)},className:"px-3 py-1 text-[10px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded cursor-pointer border-none hover:bg-[#D7FF63]/80 transition-colors",children:"Save"}),e.jsx("button",{onClick:()=>m(),className:"px-3 py-1 text-[10px] text-gray-400 hover:text-white bg-transparent border-none cursor-pointer",children:"Cancel"}),e.jsxs("span",{className:"text-[9px] text-gray-600 ml-auto",children:["⌘","+Enter to save, Esc to cancel"]})]})]}),G&&!w&&e.jsxs("div",{className:"border-t border-[#3d3d3d] bg-amber-500/5 px-3 py-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-amber-400/80",children:"Data modified — recapture to update the screenshot"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>{v(!0),Promise.resolve().then(()=>(a&&a(),new Promise(g=>setTimeout(g,2e3)))).then(()=>fetch("/api/editor-capture-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t})})).then(()=>V(!1)).catch(()=>{}).finally(()=>v(!1))},disabled:S,className:"px-3 py-1 text-[10px] font-medium text-white bg-amber-600 rounded cursor-pointer border-none hover:bg-amber-500 disabled:opacity-50 transition-colors",children:S?"Recapturing...":"Recapture Screenshot"})]}),n&&e.jsxs("div",{className:"border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"flex justify-center py-2",children:e.jsx("button",{onClick:()=>p(!D),className:"px-3 py-1 text-[10px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:D?"Hide Claude":"Edit with Claude"})}),D&&e.jsx("div",{className:"border-t border-[#3d3d3d]",children:e.jsx(Me,{prompt:n,height:400,onClose:()=>{p(!1),J(g=>g+1)}})})]})]});function m(){if(B.current&&clearTimeout(B.current),!!w){if(A!==H){if(l&&y){const g=l[y];if(g&&g[w.row]){let T=H;H===""?T="":H==="null"?T=null:H==="true"?T=!0:H==="false"?T=!1:isNaN(Number(H))||(T=Number(H));const j=[...g];j[w.row]={...j[w.row],[w.col]:T},o({...l,[y]:j})}}fetch("/api/editor-save-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t,table:O.dataKey,rowIndex:w.row,column:w.col,value:H})}).then(()=>{a&&a()}).catch(()=>{})}k(null),V(!1)}}async function C(g,T,j,$){if(l&&y){const I=l[y];if(I&&I[T]){let ee=$;$==="null"?ee=null:$==="true"?ee=!0:$==="false"?ee=!1:$!==""&&!isNaN(Number($))&&(ee=Number($));const K=[...I];K[T]={...K[T],[j]:ee},o({...l,[y]:K})}}V(!0);try{await fetch("/api/editor-save-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t,table:g,rowIndex:T,column:j,value:$})}),a&&a()}catch{}}}function oa(){const[t,s]=r.useState([]),[n,a]=r.useState([]),[l,o]=r.useState(!0),[i,d]=r.useState(null),[x,b]=r.useState(!1),[f,c]=r.useState(null);if(r.useEffect(()=>{fetch("/api/editor-schema").then(p=>p.json()).then(p=>{var w,k;c(p.source||null),p.source==="explicit"?(a(p.dataStructures||[]),((w=p.dataStructures)==null?void 0:w.length)>0&&d(p.dataStructures[0].name)):(s(p.models||[]),((k=p.models)==null?void 0:k.length)>0&&d(p.models[0].name))}).catch(()=>{}).finally(()=>o(!1))},[]),l)return e.jsx("div",{className:"text-xs text-gray-400 py-4",children:"Loading schema..."});if(!(f==="explicit"?n.length>0:t.length>0))return e.jsx("div",{className:"text-xs text-gray-500 py-4",children:"No data structure found. Use the chat below to have Claude analyze your codebase and generate one."});const M=f==="explicit"?ca(n):la(t,f);return f==="explicit"?e.jsxs("div",{className:"space-y-2",children:[n.map(p=>{const w=i===p.name,k=p.category==="datastore"?"text-[#D7FF63]/80 bg-[#D7FF63]/10 border border-[#D7FF63]/30":p.category==="mock-api"?"text-blue-400/80 bg-blue-400/10 border border-blue-400/30":"text-gray-400 bg-gray-700/30 border border-gray-600/30";return e.jsxs("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(w?null:p.name),className:"w-full flex items-center gap-2 px-3 py-2 bg-[#252525] text-left cursor-pointer border-none transition-colors hover:bg-[#2a2a2a]",children:[e.jsx("svg",{className:`text-gray-500 transition-transform shrink-0 ${w?"rotate-90":""}`,width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsx("span",{className:"text-xs font-semibold text-gray-200",children:p.name}),p.order===1&&e.jsx("span",{className:"text-[9px] text-amber-400/70",children:"Primary"}),e.jsx("span",{className:`text-[9px] rounded px-1.5 py-0 ${k}`,children:p.category==="mock-api"?"API Mock":p.category}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:[p.fields.length," fields"]})]}),w&&e.jsxs("div",{className:"border-t border-[#3d3d3d]",children:[p.description&&e.jsx("div",{className:"px-3 py-1.5 text-[10px] text-gray-400 border-b border-[#2d2d2d]",children:p.description}),e.jsx("table",{className:"w-full text-[10px]",children:e.jsx("tbody",{children:p.fields.map(A=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] last:border-b-0",children:[e.jsxs("td",{className:"px-3 py-1.5 text-gray-300 font-medium w-1/3",children:[A.isId&&e.jsx("span",{className:"text-amber-400 mr-1",title:"Primary key",children:"•"}),A.name]}),e.jsx("td",{className:"px-3 py-1.5 text-gray-500",children:A.type}),e.jsx("td",{className:"px-3 py-1.5 text-gray-600 w-16 text-right",children:A.required===!1?"optional":""})]},A.name))})})]})]},p.name)}),e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx("button",{onClick:()=>b(!x),className:"px-4 py-1.5 text-[11px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded-lg cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:x?"Hide Chat":"Chat with Claude about the Data Structure"})}),x&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(Me,{prompt:M,height:500,onClose:()=>b(!1)})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ia,{prompt:`Analyze this codebase and generate a .codeyam/data-structure.json file that describes the app's data structures.
|
|
8
|
+
`)}function wt({scenarioId:t,screenshotPath:s,updatedAt:n,hasScreenshot:a,imgSrc:l,name:o,dimensionLabel:i,isActive:d,onSelect:x}){const g=t&&a,b=!t&&l;return e.jsxs("button",{onClick:x,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:i?`${o} (${i})`:o,children:[e.jsxs("div",{className:`w-full aspect-[16/10] rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] relative ${d?"border-[#D7FF63]/40 ring-1 ring-[#D7FF63]/20":"border-transparent hover:border-[#4d4d4d]"}`,children:[g?e.jsx(Je,{scenarioId:t,screenshotPath:s,updatedAt:n,alt:i?`${o} (${i})`:o,className:"w-full h-full",imgClassName:"w-full h-full object-contain"}):b?e.jsx("img",{src:l,alt:o,className:"w-full h-full object-contain",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-[#1a1a1a] flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})}),i&&e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:i})]}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${d?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:i?`${o} (${i})`:o})]})}function bt({filePath:t}){return t?e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsxs("a",{href:`/api/editor-file?path=${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",title:"Open file",className:"flex items-center gap-1.5 text-gray-500 hover:text-gray-300 transition-colors min-w-0",children:[e.jsx("span",{className:"text-sm truncate font-['IBM_Plex_Mono']",children:t}),e.jsx("svg",{className:"shrink-0",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M4.5 1.5H2.5C1.95 1.5 1.5 1.95 1.5 2.5V9.5C1.5 10.05 1.95 10.5 2.5 10.5H9.5C10.05 10.5 10.5 10.05 10.5 9.5V7.5M7.5 1.5H10.5M10.5 1.5V4.5M10.5 1.5L5 7",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsx(Re,{content:t,icon:!0,iconSize:12,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function vr({name:t,scenarios:s,reason:n="missing"}){var o,i;const a=((o=s[0])==null?void 0:o.componentPath)||((i=s[0])==null?void 0:i.pageFilePath)||null,l=n==="incomplete"?[`The "${t}" entity exists but has not been fully analyzed — its components and functions cannot be displayed.`,"","Follow these steps:","",`Step 1: Check if "${t}" is in the glossary:`,` cat .codeyam/glossary.json | grep "${t}"`,"","If not found, add an entry to .codeyam/glossary.json:",` { "name": "${t}", "filePath": "${a||"FILL_IN_PATH"}", "description": "...", "returnType": "JSX.Element" }`,"","Step 2: Run: codeyam editor analyze-imports","","Step 3: Reload the editor page and verify components/functions appear."].join(`
|
|
9
|
+
`):[`The "${t}" ${s.some(d=>!d.componentName)?"page":"component"} is missing entity data in the CodeYam database. Its scenarios are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Instead, update the database and scenario JSON files directly.","","Follow these steps EXACTLY:","","Step 1: Run: codeyam editor analyze-imports","","Step 2: Fix this entity:","",jr(t,s),"","Step 3: Reload the editor page in the browser and verify the scenarios appear."].join(`
|
|
10
|
+
`);return e.jsx(Re,{content:l,label:"Copy Fix Prompt",copiedLabel:"Copied!",className:"text-[10px] text-[#E0D400] hover:text-[#E0D400]/80 bg-transparent border border-[#E0D400]/30 rounded px-2 py-0.5 cursor-pointer transition-colors ml-2"})}function oa({brokenEntities:t}){const[s,n]=r.useState(!1),a=r.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[]);if(t.length===0)return null;const l=t.reduce((x,g)=>x+g.scenarios.length,0),o=t.filter(x=>x.reason==="incomplete"),i=t.filter(x=>x.reason==="missing"),d=[`${t.length} entities are missing data in the CodeYam database. ${l} total scenario(s) are hidden until this is fixed.`,"","IMPORTANT: Do NOT re-register scenarios — that would overwrite their screenshots. Instead, update the database and scenario JSON files directly.","","Follow these steps EXACTLY:","",...o.length>0?["## Step 1: Add missing entries to the glossary","","Read `.codeyam/glossary.json` and check if these entities have entries. For each one that is missing, add an entry:","",...o.map(x=>{var b,c;const g=((b=x.scenarios[0])==null?void 0:b.componentPath)||((c=x.scenarios[0])==null?void 0:c.pageFilePath)||"FILL_IN_PATH";return`- "${x.name}" (filePath: "${g}")`}),"",'Each glossary entry needs: name, filePath, description, returnType (use "JSX.Element" for components/pages).',""]:["## Step 1: No glossary changes needed",""],"## Step 2: Run import analysis"," codeyam editor analyze-imports","",...i.length>0?["## Step 3: Fix missing entity associations","",...i.map(x=>jr(x.name,x.scenarios)),""]:[],`## Step ${i.length>0?"4":"3"}: Reload the editor page in the browser and verify all scenarios appear. Then commit the updated scenario JSON files so the fix persists across clones.`].join(`
|
|
11
|
+
`);return e.jsx("div",{className:"p-4 rounded-lg border border-[#E0D400]/40 bg-[#E0D400]/8",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#E0D400",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsxs("p",{className:"flex-1 min-w-0 text-sm text-[#E0D400]/90 m-0 leading-snug font-['IBM_Plex_Sans']",children:[t.length," ",t.length===1?"entity is":"entities are"," missing data, resulting in ",l," hidden scenario",l!==1?"s":"","."," ",e.jsx("button",{type:"button",className:"font-bold underline bg-transparent border-none text-[#E0D400] cursor-pointer p-0 text-sm inline hover:text-[#E0D400]/70 transition-colors",onClick:()=>a(d),children:s?e.jsxs("span",{className:"inline-flex items-center gap-1",children:["Copied",e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"inline",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]}):"Copy this prompt"})," ","into Claude to fix them all at once."]}),e.jsx(Re,{content:d,label:e.jsxs("span",{className:"flex items-center gap-2",children:["COPY PROMPT",e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]}),copiedLabel:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"invisible",children:"COPY PROMPT"}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:"COPIED!"}),e.jsx("span",{className:"invisible",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",children:e.jsx("rect",{x:"9",y:"9",width:"13",height:"13"})})})]}),className:"relative text-xs font-semibold text-[#1e1e1e] bg-[#E0D400] hover:bg-[#E0D400]/80 border-none rounded px-4 py-2 cursor-pointer transition-colors shrink-0 tracking-wide font-['IBM_Plex_Mono']"})]})})}function Nr({focusedEntity:t,breadcrumbItems:s,onZoomChange:n,projectRoot:a,scenarios:l,analyzedEntities:o,activeScenarioId:i,onScenarioSelect:d,onAnalyzedScenarioSelect:x,onSwitchToBuild:g,entityImports:b,glossaryFunctions:c,cachedTestResults:y={},glossaryEntries:M,entityShaMap:D,componentGroups:p,visualEntities:w,isEntityComplete:k,onReseedPreview:I}){var Q;const _=t.filePath,H=t.name,[z,P]=r.useState("scenarios"),[J,G]=r.useState(null),[V,S]=r.useState(""),[v,B]=r.useState(!1),[O,Y]=r.useState(null),[Z,E]=r.useState(!1),[U,m]=r.useState(!1),[F,f]=r.useState(null);r.useEffect(()=>{P("scenarios"),G(null),E(!1),m(!1),f(null)},[t.sha]);const T=r.useMemo(()=>{const u=new Map;for(const A of c)u.set(A.name,A);return u},[c]),j=o.some(u=>u.sha===t.sha||u.filePath===_),$=!!((Q=b==null?void 0:b[H])!=null&&Q.length),R=r.useCallback(async u=>{if(!(!V.trim()||v)){B(!0);try{(await fetch("/api/editor-rename-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:u,name:V.trim()})})).ok&&G(null)}catch{}finally{B(!1)}}},[V,v]),ee=r.useCallback(async u=>{if(confirm(`Delete scenario "${u.name}"?`)){Y(u.id);try{const A=u.screenshotPaths?Object.values(u.screenshotPaths):u.screenshotPath?[u.screenshotPath]:[];await fetch("/api/delete-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:u.id,screenshotPaths:A})})}catch{}finally{Y(null)}}},[]);if(!j&&!$){const u=l.filter(q=>q.entitySha===t.sha),A=[`The "${t.displayName}" entity (${_}) exists in the database but has not been fully analyzed. Its components and functions cannot be shown until it has import metadata.`,"","Follow these steps:","",`Step 1: Add "${H}" to the glossary if it's not already there:`,` Check: cat .codeyam/glossary.json | grep "${H}"`,"",` If not found, add an entry with name "${H}" and filePath "${_}" to .codeyam/glossary.json`,"","Step 2: Run import analysis:"," codeyam editor analyze-imports","","Step 3: Reload the editor page and verify components/functions appear."].join(`
|
|
12
|
+
`);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{if(s.length>1){const q=s[s.length-2];n(q.componentName,q.entitySha)}else n()},className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 shrink-0 text-lg",title:"Go back",children:"←"}),e.jsx("h2",{className:"text-lg font-medium text-white m-0 font-['IBM_Plex_Sans']",children:t.displayName})]}),_&&e.jsx(bt,{filePath:_,projectRoot:a}),e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"text-[11px] text-amber-400/80 m-0 leading-relaxed",children:"This entity has not been fully analyzed. Its components and functions cannot be displayed. Please copy and paste this prompt into Claude to fix the data."}),e.jsx("div",{className:"mt-2",children:e.jsx(Re,{content:A,label:"Copy Fix Prompt",copiedLabel:"Copied!",className:"text-[10px] text-amber-400 hover:text-amber-300 bg-transparent border border-amber-400/30 rounded px-2 py-1 cursor-pointer transition-colors"})})]}),u.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:De(u).map(({scenario:q,dimensionLabel:te,screenshotPath:ae,key:oe})=>e.jsx(wt,{scenarioId:q.id,screenshotPath:ae,updatedAt:q.updatedAt,hasScreenshot:!!ae,name:q.name,dimensionLabel:te,isActive:q.id===i,onSelect:()=>d(q,te??void 0)},oe))})]})})}const K=t.sha,re=l.filter(u=>!u.componentName&&(u.pageFilePath===_||K&&u.entitySha===K)),me=l.filter(u=>u.componentName===H||u.componentPath===_),se=w.find(u=>u.filePath===_||u.name===H),pe=T.get(H)||c.find(u=>u.filePath===_),he=[...re,...me],fe=r.useMemo(()=>{const u=[];if(u.push(`# Create a New Scenario for "${t.displayName}"`),u.push(""),u.push(`**Entity**: ${t.displayName}`),u.push(`**Type**: ${t.entityType}`),u.push(`**File**: ${_}`),u.push(""),he.length>0){u.push("## Existing Scenarios");for(const A of he)u.push(`- **${A.name}**${A.url?` — URL: ${A.url}`:""}`);u.push("")}return u.push("## Your Task"),u.push("Ask the user what scenario they would like to create. Offer two options:"),u.push("1. **Describe a scenario** — the user tells you what they want and you create it"),u.push("2. **Analyze gaps** — you review the existing scenarios and source code to suggest scenarios that would improve coverage"),u.push(""),u.push("Once you know what scenario to create, use the `codeyam editor register` CLI command to register it. Write the scenario JSON to `.codeyam/tmp/scenario.json` first, then run `codeyam editor register @.codeyam/tmp/scenario.json`."),u.join(`
|
|
13
|
+
`)},[t.displayName,t.entityType,_,he]),L=new Set((b==null?void 0:b[H])||[]),xe=$?[...p.entries()].filter(([u])=>L.has(u)):[],ie=$?w.filter(u=>L.has(u.name)&&!xe.some(([A])=>A===u.name)):[],de=$?M.filter(u=>L.has(u.name)&&u.returnType!=="JSX.Element"&&u.returnType!=="React.ReactNode").map(u=>({name:u.name,filePath:u.filePath,description:u.description||"",testFile:u.testFile,feature:u.feature})):[],ne=xe.length>0||ie.length>0,N=de.length>0;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("button",{onClick:()=>{if(s.length>1){const u=s[s.length-2];n(u.componentName,u.entitySha)}else n()},className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 shrink-0 text-xl",title:"Go back",children:"←"}),e.jsx("h2",{className:"text-xl font-medium text-white m-0 font-['IBM_Plex_Sans']",children:t.displayName})]}),t.filePath&&e.jsx("div",{className:"mt-1.5 ml-7",children:e.jsx(bt,{filePath:t.filePath,projectRoot:a})})]}),e.jsx("div",{className:"-mx-5 px-5 border-t border-b border-[#3d3d3d] flex items-center gap-6",children:[["scenarios","Scenarios"],["components","Components"],["functions","Functions"],["data-structure","Data Structure"]].map(([u,A])=>e.jsx("button",{onClick:()=>P(u),className:`text-xs font-normal uppercase tracking-wider transition-colors bg-transparent border-none cursor-pointer px-0 font-['IBM_Plex_Mono'] border-b-2 leading-none ${z===u?"text-[#D7FF63] border-b-[#D7FF63]":"text-gray-500 hover:text-gray-300 border-b-transparent"}`,style:{marginBottom:-1,paddingTop:16,paddingBottom:14},children:A},u))}),z==="scenarios"&&e.jsxs("div",{className:"space-y-3 mt-5",children:[he.map(u=>{const A=u.id===i,q=J===u.id;return e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>{q||d(u)},className:`flex items-center gap-4 p-3 rounded-lg cursor-pointer transition-colors ${A?"bg-[#1a2e1a] border border-[#D7FF63]/40":"bg-[#252525] hover:bg-[#2a2a2a] border border-transparent"}`,style:{opacity:O===u.id?.4:1},children:[u.screenshotPaths&&Object.keys(u.screenshotPaths).length>1?e.jsx("div",{className:"flex gap-2 shrink-0",children:Object.entries(u.screenshotPaths).map(([te,ae])=>e.jsxs("div",{className:"relative",children:[e.jsx(Je,{scenarioId:u.id,screenshotPath:ae,updatedAt:u.updatedAt,alt:te,className:"rounded w-[120px] h-[75px] overflow-hidden border border-[#3d3d3d]",imgClassName:"w-full h-full object-cover"}),e.jsx("span",{className:"absolute bottom-1 right-1 text-[8px] font-medium bg-black/60 text-white px-1 py-0.5 rounded",children:te})]},te))}):u.screenshotPath?e.jsx(Je,{scenarioId:u.id,screenshotPath:u.screenshotPath,updatedAt:u.updatedAt,alt:"",className:"rounded w-[160px] h-[100px] shrink-0 overflow-hidden border border-[#3d3d3d]",imgClassName:"w-full h-full object-cover"}):e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[160px] h-[100px] shrink-0 flex items-center justify-center border border-[#3d3d3d]",children:e.jsx("span",{className:"text-[10px] text-gray-600",children:"No image"})}),e.jsx("div",{className:"flex-1 min-w-0",children:q?e.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:te=>{te.preventDefault(),R(u.id)},onClick:te=>te.stopPropagation(),children:[e.jsx("input",{type:"text",value:V,onChange:te=>S(te.target.value),className:"flex-1 px-2 py-1 text-xs bg-[#1e1e1e] text-white border border-[#3d3d3d] rounded outline-none focus:border-[#005c75] min-w-0",autoFocus:!0,disabled:v}),e.jsx("button",{type:"submit",disabled:v||!V.trim(),className:"px-2 py-1 text-[10px] bg-[#005c75] text-white rounded hover:bg-[#004d63] disabled:opacity-40 cursor-pointer border-none",children:v?"...":"Save"}),e.jsx("button",{type:"button",onClick:()=>G(null),className:"px-2 py-1 text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-gray-300 truncate block",children:u.name}),A&&e.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[e.jsx("button",{onClick:te=>{te.stopPropagation(),f(F===u.id?null:u.id)},className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 cursor-pointer bg-transparent border-none p-0",children:"View Data"}),e.jsx("button",{onClick:te=>{te.stopPropagation(),m(!1),E(!0)},className:"text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none p-0",children:"Edit with Claude"}),e.jsx("button",{onClick:te=>{te.stopPropagation(),G(u.id),S(u.name)},className:"text-[10px] text-gray-400 hover:text-white cursor-pointer bg-transparent border-none p-0",children:"Rename"}),e.jsx("button",{onClick:te=>{te.stopPropagation(),ee(u)},disabled:O===u.id,className:"text-[10px] text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none p-0",children:"Delete"})]})]})})]}),F===u.id&&e.jsx(ia,{scenarioId:u.id,onClose:()=>f(null),editPrompt:qs(t.displayName,t.filePath,t.entityType,he),onReseedPreview:I})]},u.id)}),se&&(se.scenarios.length>0||se.pendingScenarios.length>0)&&e.jsxs("div",{className:"space-y-1 mt-2",children:[se.scenarios.map(u=>e.jsxs("div",{onClick:()=>x({analysisId:se.analysisId,scenarioId:u.id,scenarioName:u.name,entitySha:se.sha,entityName:se.name}),className:"flex items-center gap-3 p-2 rounded cursor-pointer transition-colors hover:bg-[#252525] border border-transparent",children:[u.screenshotPath?e.jsx("img",{src:`/api/screenshot/${u.screenshotPath}`,alt:u.name,className:"rounded w-[48px] h-[48px] shrink-0 object-cover",loading:"lazy"}):e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[48px] h-[48px] shrink-0 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"No img"})}),e.jsx("span",{className:"text-xs text-gray-300 truncate",children:u.name})]},u.id)),se.pendingScenarios.map(u=>e.jsxs("div",{className:"flex items-center gap-3 p-2",children:[e.jsx("div",{className:"rounded bg-[#1a1a1a] w-[48px] h-[48px] shrink-0 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] text-gray-600",children:"..."})}),e.jsx("span",{className:"text-xs text-gray-500 truncate",children:u})]},u))]}),he.length===0&&!se&&!pe&&e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No scenarios for this entity"}),e.jsxs("button",{onClick:()=>{E(!1),m(!0)},className:"flex items-center gap-2.5 mt-4 text-xs text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none cursor-pointer p-0 font-normal uppercase tracking-wider font-['IBM_Plex_Mono'] transition-colors",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),"Create New Scenario"]}),U&&e.jsx("div",{className:"mt-2 border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx($e,{prompt:fe,height:500,onClose:()=>m(!1)})}),Z&&he.length>0&&e.jsx("div",{className:"mt-2 border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx($e,{prompt:qs(t.displayName,t.filePath,t.entityType,he),height:500,onClose:()=>E(!1)})})]}),z==="components"&&e.jsx("div",{className:"space-y-3",children:ne?e.jsxs(e.Fragment,{children:[xe.map(([u,A])=>e.jsx("div",{children:D.has(u)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>n(u,D.get(u)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u})}),A.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(A).map(({scenario:q,dimensionLabel:te,screenshotPath:ae,key:oe})=>e.jsx(wt,{scenarioId:q.id,screenshotPath:ae,updatedAt:q.updatedAt,hasScreenshot:!!ae,name:q.name,dimensionLabel:te,isActive:q.id===i,onSelect:()=>d(q,te??void 0)},oe))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-500",children:u}),e.jsx("p",{className:"text-[10px] text-amber-400/80 m-0 mt-1.5 leading-relaxed",children:"There is data missing that is required to show the scenarios for this component. Please copy and paste this prompt into Claude to ask Claude to fix the data."}),e.jsx("div",{className:"mt-1.5",children:e.jsx(vr,{name:u,scenarios:A})})]})},u)),ie.map(u=>e.jsxs("div",{children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>n(u.name,u.sha),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u.name})}),(u.scenarios.length>0||u.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[u.scenarios.map(A=>e.jsx(wt,{imgSrc:A.screenshotPath?`/api/screenshot/${A.screenshotPath}`:null,name:A.name,isActive:!1,onSelect:()=>x({analysisId:u.analysisId,scenarioId:A.id,scenarioName:A.name,entitySha:u.sha,entityName:u.name})},A.id)),u.pendingScenarios.map(A=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:A,children:A},A))]})]},u.sha))]}):e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No component dependencies"})}),z==="functions"&&e.jsxs("div",{className:"space-y-3",children:[pe&&pe.testFile&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(bt,{filePath:pe.testFile,projectRoot:a})]}),e.jsx(Xt,{testFile:pe.testFile,entityName:H,cachedResult:y[pe.testFile]})]}),N?e.jsx("div",{children:de.map(u=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>n(u.name,D.get(u.name)),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u.name})}),e.jsx(bt,{filePath:u.filePath,projectRoot:a}),u.testFile&&e.jsxs("div",{className:"mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[9px] text-gray-600",children:"test:"}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate",children:u.testFile})]}),e.jsx(Xt,{testFile:u.testFile,entityName:u.name,cachedResult:y[u.testFile]})]})]},u.name))}):pe!=null&&pe.testFile?null:e.jsx("div",{className:"text-xs text-gray-500 py-2",children:"No function dependencies"})]}),z==="data-structure"&&e.jsx(la,{})]})})}function ia({scenarioId:t,onClose:s,editPrompt:n,onReseedPreview:a}){const[l,o]=r.useState(null),[i,d]=r.useState([]),[x,g]=r.useState(!0),[b,c]=r.useState(null),[y,M]=r.useState(null),[D,p]=r.useState(!1),[w,k]=r.useState(null),[I,_]=r.useState(""),[H,z]=r.useState(""),[P,J]=r.useState(0),[G,V]=r.useState(!1),[S,v]=r.useState(!1),B=r.useRef(null);if(r.useEffect(()=>{g(!0),c(null),Promise.all([fetch("/api/editor-schema").then(f=>f.json()).catch(()=>({models:[]})),fetch(`/api/editor-scenario-data?scenarioId=${t}`).then(f=>f.json())]).then(([f,T])=>{const j=f.source==="explicit"?ea(f.dataStructures||[],T):Yn(f.models||[],T);o(j.data),d(j.tabs),j.tabs.length>0&&!y&&M(j.tabs[0].dataKey)}).catch(()=>c("Failed to load scenario data")).finally(()=>g(!1))},[t,P]),x)return e.jsx("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-gray-400",children:"Loading mock data..."});if(b||!l)return e.jsx("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-red-400",children:b||"No data available"});if(i.length===0)return e.jsxs("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg p-4 text-xs text-gray-500",children:["No mock data found for this scenario.",e.jsx("button",{onClick:s,className:"ml-2 text-gray-400 hover:text-white bg-transparent border-none cursor-pointer text-[10px]",children:"Dismiss"})]});const O=i.find(f=>f.dataKey===y)||i[0],Y=y?l[y]||[]:[],Z=Qn(Y,O.schemaFields),E=Xn(Z,Y,O.schemaFields),U=Zn(Z,O.schemaFields);return e.jsxs("div",{className:"mt-1 mb-1 border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 bg-[#252525] border-b border-[#3d3d3d] flex-wrap",children:[i.map(f=>{const T=y===f.dataKey,j=f.category==="datastore"?T?"text-[#D7FF63] bg-[#D7FF63]/15 border-[#D7FF63]/40":"text-[#D7FF63]/60 bg-transparent border-transparent hover:text-[#D7FF63]/80":f.category==="mock-api"?T?"text-blue-400 bg-blue-400/15 border-blue-400/40":"text-blue-400/60 bg-transparent border-transparent hover:text-blue-400/80":T?"text-white bg-[#3d3d3d] border-[#4d4d4d]":"text-gray-500 bg-transparent border-transparent hover:text-gray-300";return e.jsx("button",{onClick:()=>M(f.dataKey),className:`px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider rounded cursor-pointer border transition-colors ${j}`,children:f.label},f.dataKey)}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"w-5 h-5 flex items-center justify-center text-gray-500 hover:text-white bg-[#3d3d3d] hover:bg-[#4d4d4d] rounded-full border-none cursor-pointer text-xs transition-colors",title:"Close",children:"×"})]}),(O.description||O.category)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#1e1e1e] border-b border-[#2d2d2d]",children:[O.category&&e.jsx("span",{className:`text-[9px] rounded px-1.5 py-0 border ${O.category==="datastore"?"text-[#D7FF63]/80 bg-[#D7FF63]/10 border-[#D7FF63]/30":O.category==="mock-api"?"text-blue-400/80 bg-blue-400/10 border-blue-400/30":"text-gray-400 bg-gray-700/30 border-gray-600/30"}`,children:O.category==="mock-api"?"API Mock":O.category}),O.description&&e.jsx("span",{className:"text-[10px] text-gray-500",children:O.description})]}),Z.length===0?e.jsx("div",{className:"px-3 py-4 text-[10px] text-gray-500 text-center",children:"No columns defined for this table"}):e.jsx("div",{className:"overflow-x-auto max-h-[300px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-[10px] border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#1e1e1e] sticky top-0 z-10",children:[e.jsx("th",{className:"text-right text-gray-600 font-normal px-2 py-1.5 border-b border-[#3d3d3d] w-8",children:"#"}),Z.map(f=>e.jsxs("th",{className:"text-left px-2 py-1.5 border-b border-[#3d3d3d] whitespace-nowrap overflow-hidden",children:[f===U&&e.jsx("span",{className:"inline-block text-[8px] font-bold text-white bg-[#D7FF63] rounded px-1 py-0 mr-1.5 align-middle",children:"PK"}),e.jsx("span",{className:"text-gray-300 font-medium",children:f}),e.jsx("span",{className:"text-gray-600 font-normal ml-1",children:E[f]})]},f))]})}),e.jsx("tbody",{children:Y.map((f,T)=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] hover:bg-[#252525] group/row",children:[e.jsx("td",{className:"text-right text-gray-600 px-2 py-1.5 w-8 select-none",children:T+1}),Z.map(j=>e.jsxs("td",{className:`px-2 py-1.5 overflow-hidden relative group/cell ${j===U?"text-[#D7FF63] font-medium":"text-gray-300"}`,title:String(f[j]??""),children:[e.jsx("span",{className:"truncate block whitespace-nowrap",children:f[j]===null?e.jsx("span",{className:"text-gray-600 italic",children:"null"}):typeof f[j]=="object"?e.jsx("span",{className:"text-gray-500",children:JSON.stringify(f[j])}):typeof f[j]=="number"?e.jsx("span",{className:"text-amber-400",children:String(f[j])}):String(f[j])}),e.jsx("button",{onClick:$=>{$.stopPropagation(),k({row:T,col:j});const R=f[j]===null?"":typeof f[j]=="object"?JSON.stringify(f[j]):String(f[j]);_(R),z(R)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover/cell:opacity-100 text-gray-500 hover:text-white bg-[#252525] border border-[#4d4d4d] rounded cursor-pointer p-0.5 transition-opacity",title:"Edit",children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]},j))]},T))})]})}),w&&e.jsxs("div",{className:"border-t border-[#3d3d3d] bg-[#1e1e1e] px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1.5",children:e.jsxs("span",{className:"text-[10px] text-gray-400",children:["Editing"," ",e.jsx("strong",{className:"text-gray-200",children:w.col})," in row ",w.row+1]})}),e.jsx("textarea",{value:I,onChange:f=>{const T=f.target.value;_(T),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{F(O.dataKey,w.row,w.col,T)},600)},className:"w-full px-2 py-1.5 text-[11px] bg-[#252525] text-white border border-[#4d4d4d] rounded outline-none focus:border-[#D7FF63]/50 resize-y min-h-[60px] max-h-[200px] font-mono",autoFocus:!0,rows:I.length>100?4:2,onKeyDown:f=>{f.key==="Escape"&&m(),f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&(B.current&&clearTimeout(B.current),F(O.dataKey,w.row,w.col,I),k(null))}}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("button",{onClick:()=>{B.current&&clearTimeout(B.current),F(O.dataKey,w.row,w.col,I),k(null)},className:"px-3 py-1 text-[10px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded cursor-pointer border-none hover:bg-[#D7FF63]/80 transition-colors",children:"Save"}),e.jsx("button",{onClick:()=>m(),className:"px-3 py-1 text-[10px] text-gray-400 hover:text-white bg-transparent border-none cursor-pointer",children:"Cancel"}),e.jsxs("span",{className:"text-[9px] text-gray-600 ml-auto",children:["⌘","+Enter to save, Esc to cancel"]})]})]}),G&&!w&&e.jsxs("div",{className:"border-t border-[#3d3d3d] bg-amber-500/5 px-3 py-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-amber-400/80",children:"Data modified — recapture to update the screenshot"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>{v(!0),Promise.resolve().then(()=>(a&&a(),new Promise(f=>setTimeout(f,2e3)))).then(()=>fetch("/api/editor-capture-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t})})).then(()=>V(!1)).catch(()=>{}).finally(()=>v(!1))},disabled:S,className:"px-3 py-1 text-[10px] font-medium text-white bg-amber-600 rounded cursor-pointer border-none hover:bg-amber-500 disabled:opacity-50 transition-colors",children:S?"Recapturing...":"Recapture Screenshot"})]}),n&&e.jsxs("div",{className:"border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"flex justify-center py-2",children:e.jsx("button",{onClick:()=>p(!D),className:"px-3 py-1 text-[10px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:D?"Hide Claude":"Edit with Claude"})}),D&&e.jsx("div",{className:"border-t border-[#3d3d3d]",children:e.jsx($e,{prompt:n,height:400,onClose:()=>{p(!1),J(f=>f+1)}})})]})]});function m(){if(B.current&&clearTimeout(B.current),!!w){if(I!==H){if(l&&y){const f=l[y];if(f&&f[w.row]){let T=H;H===""?T="":H==="null"?T=null:H==="true"?T=!0:H==="false"?T=!1:isNaN(Number(H))||(T=Number(H));const j=[...f];j[w.row]={...j[w.row],[w.col]:T},o({...l,[y]:j})}}fetch("/api/editor-save-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t,table:O.dataKey,rowIndex:w.row,column:w.col,value:H})}).then(()=>{a&&a()}).catch(()=>{})}k(null),V(!1)}}async function F(f,T,j,$){if(l&&y){const R=l[y];if(R&&R[T]){let ee=$;$==="null"?ee=null:$==="true"?ee=!0:$==="false"?ee=!1:$!==""&&!isNaN(Number($))&&(ee=Number($));const K=[...R];K[T]={...K[T],[j]:ee},o({...l,[y]:K})}}V(!0);try{await fetch("/api/editor-save-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioId:t,table:f,rowIndex:T,column:j,value:$})}),a&&a()}catch{}}}function la(){const[t,s]=r.useState([]),[n,a]=r.useState([]),[l,o]=r.useState(!0),[i,d]=r.useState(null),[x,g]=r.useState(!1),[b,c]=r.useState(null);if(r.useEffect(()=>{fetch("/api/editor-schema").then(p=>p.json()).then(p=>{var w,k;c(p.source||null),p.source==="explicit"?(a(p.dataStructures||[]),((w=p.dataStructures)==null?void 0:w.length)>0&&d(p.dataStructures[0].name)):(s(p.models||[]),((k=p.models)==null?void 0:k.length)>0&&d(p.models[0].name))}).catch(()=>{}).finally(()=>o(!1))},[]),l)return e.jsx("div",{className:"text-xs text-gray-400 py-4",children:"Loading schema..."});if(!(b==="explicit"?n.length>0:t.length>0))return e.jsx("div",{className:"text-xs text-gray-500 py-4",children:"No data structure found. Use the chat below to have Claude analyze your codebase and generate one."});const M=b==="explicit"?xa(n):da(t,b);return b==="explicit"?e.jsxs("div",{className:"space-y-2",children:[n.map(p=>{const w=i===p.name,k=p.category==="datastore"?"text-[#D7FF63]/80 bg-[#D7FF63]/10 border border-[#D7FF63]/30":p.category==="mock-api"?"text-blue-400/80 bg-blue-400/10 border border-blue-400/30":"text-gray-400 bg-gray-700/30 border border-gray-600/30";return e.jsxs("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(w?null:p.name),className:"w-full flex items-center gap-2 px-3 py-2 bg-[#252525] text-left cursor-pointer border-none transition-colors hover:bg-[#2a2a2a]",children:[e.jsx("svg",{className:`text-gray-500 transition-transform shrink-0 ${w?"rotate-90":""}`,width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsx("span",{className:"text-xs font-semibold text-gray-200",children:p.name}),p.order===1&&e.jsx("span",{className:"text-[9px] text-amber-400/70",children:"Primary"}),e.jsx("span",{className:`text-[9px] rounded px-1.5 py-0 ${k}`,children:p.category==="mock-api"?"API Mock":p.category}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:[p.fields.length," fields"]})]}),w&&e.jsxs("div",{className:"border-t border-[#3d3d3d]",children:[p.description&&e.jsx("div",{className:"px-3 py-1.5 text-[10px] text-gray-400 border-b border-[#2d2d2d]",children:p.description}),e.jsx("table",{className:"w-full text-[10px]",children:e.jsx("tbody",{children:p.fields.map(I=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] last:border-b-0",children:[e.jsxs("td",{className:"px-3 py-1.5 text-gray-300 font-medium w-1/3",children:[I.isId&&e.jsx("span",{className:"text-amber-400 mr-1",title:"Primary key",children:"•"}),I.name]}),e.jsx("td",{className:"px-3 py-1.5 text-gray-500",children:I.type}),e.jsx("td",{className:"px-3 py-1.5 text-gray-600 w-16 text-right",children:I.required===!1?"optional":""})]},I.name))})})]})]},p.name)}),e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx("button",{onClick:()=>g(!x),className:"px-4 py-1.5 text-[11px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded-lg cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:x?"Hide Chat":"Chat with Claude about the Data Structure"})}),x&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx($e,{prompt:M,height:500,onClose:()=>g(!1)})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ca,{prompt:`Analyze this codebase and generate a .codeyam/data-structure.json file that describes the app's data structures.
|
|
14
14
|
|
|
15
15
|
The file should be a JSON array where each entry has:
|
|
16
16
|
- "name": display name for the data structure
|
|
@@ -26,7 +26,7 @@ Look at:
|
|
|
26
26
|
- API response types that need mocking
|
|
27
27
|
- Do NOT include types that are only used as component props
|
|
28
28
|
|
|
29
|
-
Write the file to .codeyam/data-structure.json.`}),t.map(p=>{const w=i===p.name,k=p.fields.filter(_=>_.isRelation),
|
|
29
|
+
Write the file to .codeyam/data-structure.json.`}),t.map(p=>{const w=i===p.name,k=p.fields.filter(_=>_.isRelation),I=p.fields.filter(_=>!_.isRelation);return e.jsxs("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(w?null:p.name),className:"w-full flex items-center gap-2 px-3 py-2 bg-[#252525] text-left cursor-pointer border-none transition-colors hover:bg-[#2a2a2a]",children:[e.jsx("svg",{className:`text-gray-500 transition-transform ${w?"rotate-90":""}`,width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsx("span",{className:"text-xs font-semibold text-gray-200",children:p.name}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:[I.length," fields"]}),k.length>0&&e.jsxs("span",{className:"text-[10px] text-[#D7FF63]/70",children:[k.length," relation",k.length>1?"s":""]})]}),w&&e.jsx("div",{className:"border-t border-[#3d3d3d]",children:e.jsx("table",{className:"w-full text-[10px]",children:e.jsxs("tbody",{children:[I.map(_=>e.jsxs("tr",{className:"border-b border-[#2d2d2d] last:border-b-0",children:[e.jsxs("td",{className:"px-3 py-1.5 text-gray-300 font-medium w-1/3",children:[_.isId&&e.jsx("span",{className:"text-amber-400 mr-1",title:"Primary key",children:"•"}),_.name]}),e.jsxs("td",{className:"px-3 py-1.5 text-gray-500",children:[_.type,_.isOptional&&"?",_.isList&&"[]"]})]},_.name)),k.length>0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:2,className:"px-3 py-1.5 border-t border-[#3d3d3d]",children:[e.jsx("span",{className:"text-[9px] text-gray-500 uppercase tracking-wider",children:"Relations"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1.5",children:k.map(_=>e.jsx("button",{onClick:()=>d(_.relatedModel??null),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/80 bg-[#D7FF63]/10 border border-[#D7FF63]/30 rounded px-1.5 py-0.5 cursor-pointer transition-colors",children:_.isList?`${_.relatedModel}[]`:_.relatedModel},_.name))})]})})]})})})]},p.name)}),e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx("button",{onClick:()=>g(!x),className:"px-4 py-1.5 text-[11px] font-medium text-[#D7FF63] border border-[#D7FF63]/40 rounded-lg cursor-pointer transition-colors hover:bg-[#D7FF63]/10 bg-transparent",children:x?"Hide Chat":"Chat with Claude about the Data Structure"})}),x&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx($e,{prompt:M,height:500,onClose:()=>g(!1)})})]})}function ca({prompt:t}){const[s,n]=r.useState(!1),[a,l]=r.useState(()=>typeof window>"u"?!1:localStorage.getItem("codeyam-ds-migration-dismissed")==="1");return a?null:e.jsxs("div",{className:"relative border border-amber-500/30 bg-amber-500/5 rounded-lg p-3 pr-8",children:[e.jsx("button",{onClick:()=>{l(!0),localStorage.setItem("codeyam-ds-migration-dismissed","1")},className:"absolute top-2 right-2 text-gray-500 hover:text-white bg-transparent border-none cursor-pointer p-0.5",title:"Dismiss",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("p",{className:"text-[11px] text-amber-400/90 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"This data structure was auto-detected. For better results, ask Claude to generate an explicit data structure config."}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),2e3)},className:"mt-2 px-3 py-1 text-[10px] font-medium text-amber-400 border border-amber-500/40 rounded cursor-pointer transition-colors hover:bg-amber-500/10 bg-transparent",children:s?"Copied!":"Copy prompt for Claude"})]})}function da(t,s){const n=t.map(l=>{const o=l.fields.map(i=>{let d=` ${i.name}: ${i.type}`;return i.isList&&(d+="[]"),i.isOptional&&(d+=" (optional)"),i.isId&&(d+=" [PK]"),i.isRelation&&(d+=` → ${i.relatedModel}`),d}).join(`
|
|
30
30
|
`);return`${l.name}:
|
|
31
31
|
${o}`}).join(`
|
|
32
32
|
|
|
@@ -50,7 +50,7 @@ ${s==="prisma"?"- Edit `prisma/schema.prisma` directly":"- Edit the TypeScript i
|
|
|
50
50
|
- After schema changes, update any affected scenario seed data
|
|
51
51
|
- Explain the impact of changes on existing data
|
|
52
52
|
|
|
53
|
-
Do NOT start making changes until the user tells you what they want.`}function
|
|
53
|
+
Do NOT start making changes until the user tells you what they want.`}function xa(t){return`You are helping the user understand and modify the data structure of their application.
|
|
54
54
|
|
|
55
55
|
The data structure is explicitly defined in \`.codeyam/data-structure.json\`.
|
|
56
56
|
|
|
@@ -82,25 +82,25 @@ When making changes:
|
|
|
82
82
|
- Update descriptions to reflect changes
|
|
83
83
|
- After data structure changes, update affected scenario seed data
|
|
84
84
|
|
|
85
|
-
Do NOT start making changes until the user tells you what they want.`}function
|
|
86
|
-
`)[0]},D)))]},f.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:o,disabled:l,className:"text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":i?"Re-run (stale)":"Re-run"}),i&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}const ua={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function ma({files:t}){return e.jsxs("div",{className:"border-t border-[#3d3d3d] pt-2 mt-1",children:[e.jsxs("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",t.length,")"]}),e.jsx("div",{className:"mt-1 space-y-0.5 max-h-[150px] overflow-auto",children:t.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${ua[s.status]||"text-gray-500"}`,children:s.status==="added"||s.status==="untracked"?"A":s.status==="modified"?"M":s.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-400 truncate font-mono",children:s.path})]},s.path))})]})}const ga={feature:{label:"Feature",color:"bg-[#005c75]"},fix:{label:"Fix",color:"bg-amber-700"},refactor:{label:"Refactor",color:"bg-purple-700"},scaffold:{label:"Scaffold",color:"bg-green-700"},data:{label:"Data",color:"bg-blue-700"},milestone:{label:"Milestone",color:"bg-yellow-600"}};function fa(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function ba(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const ya=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function ja({entries:t,onScreenshotClick:s}){const[n,a]=r.useState(!1),[l,o]=r.useState("7d"),i=r.useMemo(()=>da(t,l),[t,l]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between px-3 py-2.5 cursor-pointer bg-transparent border-none text-left hover:bg-[#333] transition-colors",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Timeframe Summary"}),e.jsx("span",{className:`text-gray-500 text-[10px] transition-transform ${n?"rotate-180":""}`,children:"▼"})]}),n&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"flex gap-1 pt-2.5",children:ya.map(d=>e.jsx("button",{onClick:()=>o(d.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${l===d.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:d.label},d.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.commitCount})," ",i.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.totalScenarios})," ",i.totalScenarios===1?"scenario changed":"scenarios changed"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.entryCount})," ",i.entryCount===1?"entry":"entries"]})]}),i.totalScenarios===0?e.jsx("p",{className:"text-[11px] text-gray-500 italic m-0",children:"No scenario changes in this period."}):e.jsxs("div",{className:"space-y-3",children:[i.appScenarios.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),i.appScenarios.map(d=>e.jsx(Ys,{scenario:d,onScreenshotClick:s},d.name))]}),i.componentGroups.size>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),[...i.componentGroups.entries()].sort(([d],[x])=>d.localeCompare(x)).map(([d,x])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:d}),x.map(b=>e.jsx(Ys,{scenario:b,onScreenshotClick:s},b.name))]},d))]})]})]})]})}function Ys({scenario:t,onScreenshotClick:s}){const n=t.name.indexOf(" - "),a=n!==-1?t.name.slice(n+3):t.name;return e.jsxs("div",{className:"pl-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500 block mb-1",children:a}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((l,o)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[o>0&&e.jsx("span",{className:"text-[8px] text-gray-600 mx-0.5",children:"→"}),e.jsx("button",{type:"button",className:"w-16 h-16 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",title:`${t.name} (${new Date(l.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${l.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${l.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},l.path))})]})}function va({isActive:t,onScreenshotClick:s,glossaryFunctions:n=[],cachedTestResults:a={}}){const[l,o]=r.useState([]),[i,d]=r.useState(!0),[x,b]=r.useState(new Set),f=r.useCallback(M=>{b(D=>{const p=new Set(D);return p.has(M)?p.delete(M):p.add(M),p})},[]),c=r.useCallback(async()=>{try{const M=await fetch("/api/editor-journal");if(M.ok){const D=await M.json();o(D.entries||[])}}catch{}finally{d(!1)}},[]);if(r.useEffect(()=>{c()},[c]),r.useEffect(()=>{t&&c()},[t,c]),r.useEffect(()=>{if(!t)return;const M=setInterval(()=>void c(),5e3);return()=>clearInterval(M)},[t,c]),i)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-gray-500 text-sm",children:"Loading journal..."})});if(l.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No journal entries yet"}),e.jsx("p",{className:"text-xs",children:"Journal entries will appear as you build. Claude records features, screenshots, and commits as the project evolves."})]})});const y=xa(l);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(ja,{entries:l,onScreenshotClick:s}),[...y.entries()].map(([M,D])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 sticky top-0 bg-[#1e1e1e] z-10",children:e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:ba(M)})}),e.jsx("div",{className:"space-y-2",children:D.map((p,w)=>{const k=ga[p.type]||{label:p.type,color:"bg-gray-600"},A=`${p.time}-${w}`,_=x.has(A);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${_?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>f(A),children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white truncate",children:p.title}),e.jsx("span",{className:`${k.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:k.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:fa(p.time)}),p.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:p.featureName,children:p.featureName})]})}),p.userPrompt&&e.jsx(gr,{text:p.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:p.description}),p.screenshot&&e.jsx("button",{type:"button",className:"rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] flex items-center justify-center p-1 cursor-pointer transition-colors w-full",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${p.screenshot.replace("screenshots/","")}`,commitSha:p.commitSha,commitMessage:p.commitMessage,scenarioName:p.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${p.screenshot.replace("screenshots/","")}`,alt:p.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),p.scenarioScreenshots&&p.scenarioScreenshots.length>0&&(()=>{const H=pa(p.scenarioScreenshots),z=p.entityChangeStatus,P=H.filter(([v])=>v==="App").flatMap(([,v])=>v),J=H.filter(([v])=>v!=="App"),G=new Map;for(const v of P){const B=v,O=B.pageFilePath?nt(rt(B.pageFilePath)):kt(B.url??null),Y=G.get(O)||[];Y.push(v),G.set(O,Y)}const V=[...G.entries()],S=v=>e.jsx("button",{type:"button",className:"w-[4.5rem] h-[4.5rem] rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${v.path.replace("screenshots/","")}`,commitSha:p.commitSha,commitMessage:p.commitMessage,scenarioName:v.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${v.path.replace("screenshots/","")}`,alt:v.name,title:v.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},v.path);return e.jsxs("div",{className:"space-y-2",children:[V.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),V.map(([v,B])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:v}),(z==null?void 0:z[v])&&e.jsx(Ks,{status:z[v]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:B.map(S)})]},v))]}),J.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),J.map(([v,B])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:v}),(z==null?void 0:z[v])&&e.jsx(Ks,{status:z[v]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:B.map(S)})]},v))]})]})})(),n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),e.jsx("div",{className:"space-y-2",children:n.map(H=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:H.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:H.filePath}),H.testFile?e.jsx(ha,{testFile:H.testFile,entityName:H.name,cachedResult:a[H.testFile]}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},H.name))})]}),p.commitSha&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("span",{className:"font-mono text-[#00a0c4] bg-[#00a0c4]/10 px-1.5 py-0.5 rounded",children:p.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:p.commitMessage})]}),_&&p.modifiedFiles&&p.modifiedFiles.length>0&&e.jsx(ma,{files:p.modifiedFiles})]}),e.jsxs("button",{onClick:()=>f(A),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",_?"Collapse":"Expand"," ———"]})]},A)})})]},M))]})})}function wt({className:t="",color:s="currentColor",dotSize:n=3,interval:a=180}){const[l,o]=r.useState(0);r.useEffect(()=>{const x=setInterval(()=>{o(b=>(b+1)%6)},a);return()=>clearInterval(x)},[a]);const i=[0,1,2,3,4,5],d=Math.max(1,Math.round(n*.4));return e.jsx("span",{className:`inline-grid shrink-0 ${t}`,style:{gridTemplateColumns:`${n}px ${n}px`,gridTemplateRows:`${n}px ${n}px ${n}px`,gap:`${d}px`},children:i.map(x=>e.jsx("span",{style:{width:n,height:n,borderRadius:"50%",backgroundColor:s,opacity:x===l||x===(l+1)%6?1:.25,transition:"opacity 0.15s ease"}},x))})}function Jt({title:t,completedCount:s,totalCount:n,subtitle:a,onClick:l,previewItems:o}){return e.jsxs("button",{type:"button",onClick:l,className:"bg-[#1e1e1e] border border-[#3d3d3d] rounded-lg p-3 flex flex-col gap-2 cursor-pointer hover:border-[#555] transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:t}),e.jsx("div",{className:"flex-1"}),n!=null&&n>0?e.jsxs("span",{className:"text-xs text-gray-500",children:[s,"/",n]}):null,a&&e.jsx("span",{className:"text-xs text-gray-500",children:a})]}),o&&o.length>0&&e.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(i=>e.jsxs("div",{className:"flex items-center gap-2 bg-[#2a2a2a] rounded-md px-2.5 py-1.5",children:[i.status==="active"&&i.buildIdle&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#FF8B43] shrink-0"}),i.status==="active"&&!i.buildIdle&&e.jsx(wt,{color:"#5ce0d2",dotSize:2}),e.jsx("span",{className:`text-[11px] truncate flex-1 ${i.status==="completed"?"text-gray-400":i.status==="active"?"text-white":"text-gray-300"}`,children:i.label}),i.status==="completed"&&e.jsx("span",{className:"shrink-0 w-3 h-3 rounded-full border border-gray-500 flex items-center justify-center",children:e.jsx("svg",{width:"6",height:"6",viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}),i.status==="pending"&&e.jsx("span",{className:"text-[8px] font-bold text-[#FFFF36] uppercase tracking-wider font-['IBM_Plex_Mono'] shrink-0",children:"Pending"}),i.status==="active"&&i.step&&e.jsx("span",{className:"text-[10px] text-[#5ce0d2] font-['IBM_Plex_Mono'] shrink-0",children:i.step})]},i.label))})]})}function Na({onNavigateToRoadmap:t,onSwitchToBuild:s,buildIdle:n=!1}){const[a,l]=r.useState(null),o=r.useCallback(()=>{fetch("/api/editor-roadmap").then(p=>p.json()).then(p=>l(p)).catch(()=>{})},[]);if(r.useEffect(()=>{o();const p=setInterval(o,5e3);return()=>clearInterval(p)},[o]),!a)return null;const i=a.plan.filter(p=>p.completed).length,d=a.plan.length,x=a.deploy.filter(p=>p.completed).length,b=a.deploy.length,f=[],c=a.plan.find(p=>!p.completed);c&&f.push({label:c.label,status:"pending"});const y=a.plan.find(p=>p.completed);y&&f.push({label:y.label,status:"completed"});const M=[];a.editorStep!=null&&a.editorStep<18&&M.push({label:a.featureName||"New Feature",status:"active",step:`${a.editorStep}/18`,buildIdle:n}),a.recentEntries.length>0&&M.push({label:a.recentEntries[0].title,status:"completed"});const D=a.deploy.filter(p=>!p.completed).slice(0,2).map(p=>({label:p.label,status:"pending"}));return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 bg-transparent border-none p-0 cursor-pointer group",children:[e.jsx("span",{className:"text-base font-medium text-gray-300 group-hover:text-white transition-colors",children:"Roadmap"}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-500 group-hover:text-white transition-colors",children:e.jsx("path",{d:"M3 1l4 4-4 4"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2",children:[e.jsx(Jt,{title:"Setup",completedCount:i,totalCount:d,onClick:t,previewItems:f}),e.jsx(Jt,{title:"Build",subtitle:a.buildSessionCount>0?`${a.buildSessionCount} features completed.`:void 0,onClick:t,previewItems:M}),e.jsx(Jt,{title:"Deploy",completedCount:x,totalCount:b,onClick:t,previewItems:D})]})]})}function Qt(t){return{name:wa(t),description:ka(t),colors:Sa(t),fonts:Ca(t),typographyScale:Fa(t),radiusTokens:Da(t)}}function wa(t){const s=t.match(/^# (.+)$/m);return s?s[1].trim():"Design System"}function ka(t){const s=t.match(/^> (.+)$/m);return s?s[1].trim():""}function Sa(t){const s=[],n=es(t,"Colors");if(!n)return s;const a=Ta(n);for(const{heading:l,content:o}of a){const i=jr(o);for(const d of i){const x=/--([a-zA-Z0-9_-]+):\s*([^;]+);(?:\s*\/\*\s*(.+?)\s*\*\/)?/g;let b;for(;(b=x.exec(d))!==null;){const f=b[2].trim();La(f)&&s.push({name:b[1],value:f,group:l,...b[3]?{comment:b[3]}:{}})}}}return s}function Ca(t){const s=t.match(/\*\*Font stack:\*\*\s*`([^`]+)`(?:\s*\([^)]*\))?(?:,\s*`([^`]+)`)?/);if(!s)return[];const n=[];if(s[1]){const l=Kt(s[1]);l&&n.push(l)}if(s[2]){const l=Kt(s[2]);l&&!n.includes(l)&&n.push(l)}const a=t.match(/\*\*Font stack:\*\*\s*`[^`]+`[^`]*`[^`]+`[^`]*`([^`]+)`/);if(a){const l=Kt(a[1]);l&&!n.includes(l)&&n.push(l)}return n}function Kt(t){return t.split(",")[0].trim().replace(/'/g,"")||null}function Fa(t){const s=[],n=es(t,"Typography");if(!n)return s;const a=n.split(`
|
|
87
|
-
`).filter(l=>l.startsWith("|"));if(a.length<3)return s;for(let l=2;l<a.length;l++){const o=a[l].split("|").map(i=>i.trim()).filter(Boolean);o.length>=3&&s.push({style:o[0],size:o[1],weight:o[2],notes:o.slice(3).join(" | ")})}return s}function
|
|
88
|
-
## `,l);return o===-1?t.slice(l):t.slice(l,o)}function
|
|
89
|
-
`);l===-1?s.push({heading:n[a].trim(),content:""}):s.push({heading:n[a].slice(0,l).trim(),content:n[a].slice(l+1)})}return s}function jr(t){const s=[],n=/```css\n([\s\S]*?)```/g;let a;for(;(a=n.exec(t))!==null;)s.push(a[1]);return s}function La(t){return!!(t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||t.startsWith("var(--"))}const qs=[{key:"languages",label:"Languages"},{key:"frameworks",label:"Frameworks"},{key:"databases",label:"Databases"},{key:"services",label:"External Services"},{key:"libraries",label:"Key Libraries"},{key:"infrastructure",label:"Infrastructure"}];function Qs({todo:t,expanded:s,onToggle:n,onRemove:a,children:l}){return e.jsxs("div",{className:"mx-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 group cursor-pointer bg-[#2a2a2a] rounded-lg hover:bg-[#303030] transition-colors",onClick:n,children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-gray-500 transition-transform ${s?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsxs("span",{className:`text-sm flex-1 ${t.completed?"text-gray-400":"text-white"}`,children:[t.label,t.autoDetect&&!t.userCreated&&e.jsx("span",{className:"text-[10px] text-gray-600 ml-1.5",children:"(auto)"})]}),t.completed?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-gray-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"text-[9px] font-bold text-[#FFFF36] uppercase tracking-wider font-['IBM_Plex_Mono'] shrink-0",children:"Pending"}),t.userCreated&&a&&e.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),a()},className:"opacity-0 group-hover:opacity-100 text-gray-600 hover:text-red-400 bg-transparent border-none cursor-pointer p-0 transition-opacity",title:"Remove",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})})]}),s&&e.jsx("div",{className:"px-4 pb-3 pt-1",children:l})]})}function bt({title:t,completedCount:s,totalCount:n,subtitle:a,subtitleAccent:l=!1,subtitleLink:o,collapsed:i,onToggleCollapse:d,onAction:x,actionLabel:b="Select"}){return e.jsxs("div",{className:`flex items-center gap-2 py-3 px-3 ${d?"cursor-pointer":""}`,onClick:d,children:[d&&e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-gray-400 transition-transform ${i?"":"rotate-90"}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("h3",{className:"text-base font-medium text-white m-0",children:t}),n!=null&&n>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500",children:"/"}),e.jsxs("span",{className:"text-sm text-gray-400",children:[s,"/",n]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500",children:"/"}),e.jsx("span",{className:`text-sm ${l?"text-[#5ce0d2]":"text-gray-400"}`,children:a})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500",children:"/"}),e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),o.onClick()},className:"text-sm text-[#D7FF63] hover:text-[#D7FF63]/70 underline bg-transparent border-none p-0 cursor-pointer transition-colors",children:o.label})]}),e.jsx("div",{className:"flex-1"}),x&&e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),x()},className:"text-[10px] font-bold text-gray-500 hover:text-white uppercase tracking-wider bg-transparent border-none p-0 cursor-pointer transition-colors font-['IBM_Plex_Mono']",children:b})]})}const Ma={feature:"text-gray-300 border-gray-500/40 bg-gray-500/15",fix:"text-amber-400 border-amber-400/40 bg-amber-400/10",refactor:"text-purple-400 border-purple-400/40 bg-purple-400/10",scaffold:"text-emerald-400 border-emerald-400/40 bg-emerald-400/10",data:"text-blue-400 border-blue-400/40 bg-blue-400/10",milestone:"text-yellow-400 border-yellow-400/40 bg-yellow-400/10"},$a="text-gray-400 border-gray-400/40 bg-gray-400/10";function Ia(t){const s=new Map;for(const a of t){const l=a.componentName||"App";s.has(l)||s.set(l,[]),s.get(l).push(a)}return[...s.entries()].sort(([a],[l])=>a==="App"?-1:l==="App"?1:a.localeCompare(l))}const Aa={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400",deleted:"text-red-400"};function Ra({entry:t,expandedSections:s,onToggleSection:n,onScreenshotClick:a}){var f;const l=t.scenarioScreenshots?Ia(t.scenarioScreenshots):[],o=((f=l.find(([c])=>c==="App"))==null?void 0:f[1])||[],i=l.filter(([c])=>c!=="App"),d=(t.modifiedFiles||[]).filter(c=>!c.path.startsWith(".codeyam/")&&!c.path.includes("node_modules")&&!c.path.endsWith(".log")),x=c=>`${t.time}-${c}`,b=(o.length>0?o:t.scenarioScreenshots||[]).slice(0,3);return e.jsxs("div",{className:"px-4 py-4 space-y-4",children:[t.description&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono']",children:"Description"}),e.jsx("p",{className:"text-sm text-white m-0 mt-1.5 leading-relaxed",children:t.description})]}),t.userPrompt&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] mr-2",children:"User Prompt"}),e.jsxs("span",{className:"text-sm text-gray-400 leading-relaxed",children:[t.userPrompt.length>150?t.userPrompt.slice(0,150)+"... ":t.userPrompt,t.userPrompt.length>150&&e.jsx("span",{className:"text-[#5ce0d2] cursor-pointer hover:underline text-sm",children:"Read More"})]})]}),b.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono']",children:"Preview"}),e.jsx("div",{className:"flex gap-3 mt-2",children:b.map(c=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>a==null?void 0:a({screenshotUrl:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,commitSha:t.commitSha||null,commitMessage:t.commitMessage||null,scenarioName:c.name}),className:"w-[7rem] h-[5.5rem] rounded-lg overflow-hidden border border-[#3d3d3d] hover:border-[#5ce0d2] bg-[#1e1e1e] flex items-center justify-center cursor-pointer transition-colors p-0",children:e.jsx("img",{src:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,alt:c.name,title:c.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),e.jsx("span",{className:"text-[11px] text-gray-500 truncate w-[7rem]",children:c.name.includes(" - ")?c.name.split(" - ")[0]:c.name})]},c.path))})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>n(x("files")),className:"flex items-center gap-2 text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${s.has(x("files"))?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),"Modified Files (",d.length,")"]}),s.has(x("files"))&&e.jsx("div",{className:"mt-1.5 max-h-[120px] overflow-auto space-y-0.5",children:d.map(c=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:`shrink-0 text-[9px] font-bold uppercase ${Aa[c.status]||"text-gray-500"}`,children:c.status==="untracked"?"A":c.status.charAt(0).toUpperCase()}),e.jsx("span",{className:"text-gray-500 truncate",children:c.path})]},c.path))})]}),o.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>n(x("app")),className:"flex items-center gap-2 text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${s.has(x("app"))?"":"rotate-90"}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),"App"]}),!s.has(x("app"))&&e.jsx("div",{className:"flex gap-2 mt-1.5 flex-wrap",children:o.map(c=>e.jsx("button",{type:"button",onClick:()=>a==null?void 0:a({screenshotUrl:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,commitSha:t.commitSha||null,commitMessage:t.commitMessage||null,scenarioName:c.name}),className:"w-[4.5rem] h-[4.5rem] rounded overflow-hidden border border-[#3d3d3d] hover:border-[#5ce0d2] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors p-0",children:e.jsx("img",{src:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,alt:c.name,title:c.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},c.path))})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>n(x("components")),className:"flex items-center gap-2 text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${s.has(x("components"))?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),"Components (",i.length,")"]}),s.has(x("components"))&&e.jsx("div",{className:"mt-1.5 space-y-2",children:i.map(([c,y])=>e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>onZoomChange==null?void 0:onZoomChange(c),className:"text-[11px] text-gray-400 hover:text-[#5ce0d2] font-medium bg-transparent border-none p-0 cursor-pointer transition-colors",children:c}),e.jsx("div",{className:"flex gap-1.5 mt-1 flex-wrap",children:y.map(M=>e.jsx("button",{type:"button",onClick:()=>a==null?void 0:a({screenshotUrl:`/api/editor-journal-image/${M.path.replace("screenshots/","")}`,commitSha:t.commitSha||null,commitMessage:t.commitMessage||null,scenarioName:M.name}),className:"w-14 h-14 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#5ce0d2] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors p-0",children:e.jsx("img",{src:`/api/editor-journal-image/${M.path.replace("screenshots/","")}`,alt:M.name,title:M.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},M.path))})]},c))})]})]})}function Oa(t){try{return new Date(t).toLocaleDateString([],{month:"short",day:"numeric"})}catch{return""}}function _a({designSystem:t,onEdit:s}){const n=t.colors.filter(a=>a.value.startsWith("#")).slice(0,10);return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs font-medium text-gray-200 mb-2",children:t.name}),n.length>0&&e.jsx("div",{className:"flex gap-1.5 mb-2 flex-wrap",children:n.map(a=>e.jsx("div",{className:"w-5 h-5 rounded border border-[#444]",style:{backgroundColor:a.value},title:`--${a.name}: ${a.value}`},`${a.group}-${a.name}`))}),t.fonts.length>0&&e.jsxs("div",{className:"text-[10px] text-gray-500 mb-2",children:["Font: ",t.fonts.join(", ")]}),s&&e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors font-medium",children:"View & Edit >"})]})}function Xs({projectTitle:t,projectDescription:s,onSave:n,onEditNavigate:a,defaultEditing:l=!1}){const[o,i]=r.useState(l),[d,x]=r.useState(t||""),[b,f]=r.useState(s||""),[c,y]=r.useState(!1);r.useEffect(()=>{x(t||""),f(s||"")},[t,s]);const M=()=>{y(!0),n(d,b),y(!1),i(!1)},D=()=>{x(t||""),f(s||""),i(!1)};return o?e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Project Name"}),e.jsx("input",{type:"text",value:d,onChange:p=>x(p.target.value),placeholder:"My App",className:"w-full px-2.5 py-1.5 text-sm bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Description"}),e.jsx("textarea",{value:b,onChange:p=>f(p.target.value),placeholder:"A brief description of your project...",rows:2,className:"w-full px-2.5 py-1.5 text-sm bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors resize-none"})]}),e.jsxs("div",{className:"flex gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:M,disabled:c,className:"px-3 py-1 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium disabled:opacity-50",children:c?"Saving...":"Save"}),e.jsx("button",{type:"button",onClick:D,className:"px-3 py-1 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]})}):e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[t?e.jsx("div",{className:"text-xs font-medium text-gray-200 mb-0.5",children:t}):e.jsx("div",{className:"text-xs text-gray-500 italic mb-0.5",children:"No name set"}),s&&e.jsx("div",{className:"text-[11px] text-gray-400 leading-relaxed",children:s}),e.jsx("button",{type:"button",onClick:a??(()=>i(!0)),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-1.5 cursor-pointer transition-colors font-medium",children:"Edit >"})]})}function Ba({techStack:t,onNavigate:s}){if(!(t&&qs.some(({key:i})=>t[i]&&t[i].length>0)))return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs text-gray-400 mb-2",children:"No tech stack configured yet"}),s&&e.jsx("button",{type:"button",onClick:s,className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Set up with Claude >"})]});const a=[];for(const{key:i}of qs){const d=t[i];if(d)for(const x of d)a.push(x)}const l=a.slice(0,5),o=a.length-5;return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[l.map((i,d)=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-300 bg-[#2a2a2a] px-2 py-0.5 rounded",children:[i.name,i.version&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["v",i.version]})]},d)),o>0&&e.jsxs("span",{className:"text-[10px] text-gray-500 self-center",children:["+",o," more"]})]}),s&&e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"View all >"})]})}function Yt({iconType:t,size:s=14,className:n=""}){const a={width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:n};switch(t){case"desktop":return e.jsxs("svg",{...a,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]});case"laptop":return e.jsxs("svg",{...a,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"})]});case"tablet":return e.jsxs("svg",{...a,children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]});case"mobile":return e.jsxs("svg",{...a,children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})}}function Zs({open:t,size:s=12}){return t?e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}):e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),e.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),e.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),e.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}const Wa=new Set(xr.flatMap(t=>t.presets.map(s=>s.name)));function er({screenSizes:t,projectScreenSizes:s,defaultScreenSize:n,appFormats:a,onSave:l,onEditNavigate:o,defaultEditing:i=!1}){const d=r.useMemo(()=>pr(t,a),[t,a]),x=r.useMemo(()=>{if(t){for(const[E,U]of Object.entries(t))if(U.default)return E}return(n==null?void 0:n.name)||""},[t,n]),[b,f]=r.useState(i),[c,y]=r.useState({}),[M,D]=r.useState(new Set),[p,w]=r.useState(""),[k,A]=r.useState(""),[_,H]=r.useState(""),[z,P]=r.useState(""),J=()=>{const E={};for(const C of d)E[C.name]={width:C.width,height:C.height};y(E);const U=new Set,m=s||t;if(m)for(const C of Object.keys(m)){const g=m[C];(s||!g||!("default"in g))&&U.add(C)}D(U),w(x),A(""),H(""),P(""),f(!0)};r.useEffect(()=>{i&&J()},[]);const G=(E,U,m)=>{y(C=>{const g={...C};if(g[E]){if(delete g[E],D(T=>{const j=new Set(T);return j.delete(E),j}),E===p){const T=Object.keys(g);w(T[0]||"")}}else g[E]={width:U,height:m},Object.keys(C).length===0&&w(E);return g})},V=E=>{D(U=>{const m=new Set(U);return m.has(E)?m.delete(E):m.add(E),m})},S=E=>{c[E]&&w(E)},v=()=>{const E=k.trim(),U=parseInt(_,10),m=parseInt(z,10);!E||isNaN(U)||isNaN(m)||U<=0||m<=0||(y(C=>(Object.keys(C).length===0&&w(E),{...C,[E]:{width:U,height:m}})),A(""),H(""),P(""))},B=E=>{y(U=>{const m={...U};return delete m[E],E===p&&w(Object.keys(m)[0]||""),m}),D(U=>{const m=new Set(U);return m.delete(E),m})},O=()=>{const E={};for(const[m,C]of Object.entries(c))E[m]={width:C.width,height:C.height,...m===p?{default:!0}:{}};const U={};for(const m of M)c[m]&&(U[m]={...c[m]});l(E,U),f(!1)};if(b){const E=Object.entries(c).filter(([U])=>!Wa.has(U));return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-0.5",children:[e.jsx("div",{className:"w-3.5"}),e.jsx("div",{className:"w-3.5"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider flex-1",children:"Size"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[72px] text-right",children:"Dimensions"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[50px] text-center",title:"Include in project screenshot sizes",children:"Project"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[54px] text-center",children:"Default"})]}),e.jsxs("div",{className:"space-y-3",children:[xr.map(U=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:U.category}),e.jsx("div",{className:"space-y-0.5",children:U.presets.map(m=>{const C=!!c[m.name],g=p===m.name,T=M.has(m.name),j=vt(m);return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("button",{type:"button",onClick:()=>G(m.name,m.width,m.height),className:`w-3.5 h-3.5 rounded-sm border flex items-center justify-center shrink-0 cursor-pointer transition-colors ${C?"bg-[#D7FF63] border-[#D7FF63]":"bg-transparent border-[#555] hover:border-[#888]"}`,children:C&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#1e1e1e",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}),e.jsx(Yt,{iconType:j,size:14,className:C?"text-gray-300":"text-gray-600"}),e.jsx("span",{className:`text-xs flex-1 ${C?"text-gray-300":"text-gray-500"}`,children:m.name}),e.jsxs("span",{className:"text-[10px] text-gray-500 tabular-nums w-[72px] text-right",children:[m.width," × ",m.height]}),e.jsx("div",{className:"w-[50px] flex justify-center",children:C?e.jsx("button",{type:"button",onClick:()=>V(m.name),className:`p-1 rounded cursor-pointer transition-colors ${T?"text-[#D7FF63] hover:text-[#D7FF63]/70":"text-gray-600 hover:text-gray-400"}`,title:T?"In project screenshots":"Not in project screenshots",children:e.jsx(Zs,{open:T})}):e.jsx("span",{className:"w-3"})}),e.jsx("div",{className:"w-[54px] flex justify-center",children:C?e.jsx("button",{type:"button",onClick:()=>S(m.name),className:`text-[10px] px-1.5 py-0.5 rounded border cursor-pointer transition-colors ${g?"text-[#1e1e1e] bg-[#D7FF63] border-[#D7FF63]":"text-gray-500 bg-transparent border-[#444] hover:border-[#666] hover:text-gray-300"}`,title:g?"Default size":"Set as default",children:g?"★":"☆"}):e.jsx("span",{className:"w-3"})})]},m.name)})})]},U.category)),E.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Custom"}),e.jsx("div",{className:"space-y-0.5",children:E.map(([U,m])=>{const C=p===U,g=M.has(U),T=vt({name:U,width:m.width,height:m.height});return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("div",{className:"w-3.5"}),e.jsx(Yt,{iconType:T,size:14,className:"text-gray-300"}),e.jsx("span",{className:"text-xs text-gray-300 flex-1",children:U}),e.jsxs("span",{className:"text-[10px] text-gray-500 tabular-nums w-[72px] text-right",children:[m.width," × ",m.height]}),e.jsx("div",{className:"w-[50px] flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>V(U),className:`p-1 rounded cursor-pointer transition-colors ${g?"text-[#D7FF63] hover:text-[#D7FF63]/70":"text-gray-600 hover:text-gray-400"}`,title:g?"In project screenshots":"Not in project screenshots",children:e.jsx(Zs,{open:g})})}),e.jsx("div",{className:"w-[54px] flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>S(U),className:`text-[10px] px-1.5 py-0.5 rounded border cursor-pointer transition-colors ${C?"text-[#1e1e1e] bg-[#D7FF63] border-[#D7FF63]":"text-gray-500 bg-transparent border-[#444] hover:border-[#666] hover:text-gray-300"}`,title:C?"Default size":"Set as default",children:C?"★":"☆"})}),e.jsx("button",{type:"button",onClick:()=>B(U),className:"text-gray-600 hover:text-red-400 bg-transparent border-none p-0.5 cursor-pointer transition-colors text-xs leading-none",children:"×"})]},U)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Add Custom Size"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:k,onChange:U=>A(U.target.value),placeholder:"Name",className:"flex-1 min-w-0 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"number",value:_,onChange:U=>H(U.target.value),placeholder:"W",className:"w-14 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"×"}),e.jsx("input",{type:"number",value:z,onChange:U=>P(U.target.value),placeholder:"H",className:"w-14 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("button",{type:"button",onClick:v,className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors font-medium",children:"+ Add"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2.5",children:[e.jsx("button",{type:"button",onClick:O,className:"px-3 py-1 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>f(!1),className:"px-3 py-1 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]})}if(d.length===0)return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs text-gray-500 italic",children:"No screen sizes configured"}),e.jsx("button",{type:"button",onClick:o??J,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-1.5 cursor-pointer transition-colors font-medium",children:"Edit >"})]});const Y=E=>x===E,Z=E=>{var U;return!!((U=s||t)!=null&&U[E])};return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.map(E=>{const U=vt(E);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs bg-[#2a2a2a] px-2 py-1 rounded text-gray-300",children:[e.jsx(Yt,{iconType:U,size:12,className:"text-gray-400"}),E.name,e.jsxs("span",{className:"text-[10px] text-gray-500",children:[E.width,"×",E.height]}),Y(E.name)&&e.jsx("span",{className:"text-[10px] text-[#D7FF63]",children:"★"}),Z(E.name)&&e.jsx("span",{className:"text-[10px] text-[#D7FF63]",title:"Project screenshot size",children:"P"})]},E.name)})}),e.jsx("button",{type:"button",onClick:o??J,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"Edit >"})]})}const tr=[{id:"vercel",name:"Vercel",services:["Hosting"],description:"Frontend-optimized hosting"},{id:"railway",name:"Railway",services:["Hosting","Database","Storage"],description:"Full-stack infrastructure"},{id:"runloop",name:"Runloop",services:["Sandboxes","Hosting"],description:"Sandbox-first deployment"}];function Ne({step:t,done:s,active:n}){return e.jsx("span",{className:`shrink-0 w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold ${s?"bg-green-600 text-white":n?"bg-[#D7FF63] text-black":"bg-[#333] text-gray-500"}`,children:s?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):t})}function Ha({hosting:t,onSave:s}){var ge;const[n,a]=r.useState(null),[l,o]=r.useState(!0),[i,d]=r.useState(""),[x,b]=r.useState(!1),[f,c]=r.useState([]),[y,M]=r.useState(null),[D,p]=r.useState(!1),[w,k]=r.useState(!1),[A,_]=r.useState(!1),[H,z]=r.useState(!1),[P,J]=r.useState(null),[G,V]=r.useState(null),[S,v]=r.useState(null),[B,O]=r.useState(null),[Y,Z]=r.useState(null),E=r.useCallback(()=>{o(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"full-status"})}).then(L=>L.json()).then(L=>{a(L),v(null)}).catch(()=>v("Failed to check status")).finally(()=>o(!1))},[]);r.useEffect(()=>{E()},[E]);const U=()=>{i.trim()&&(b(!0),v(null),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save-token",token:i.trim()})}).then(L=>L.json()).then(L=>{L.ok?(d(""),E()):v(L.error||"Token verification failed")}).catch(()=>v("Failed to save token")).finally(()=>b(!1)))},[m,C]=r.useState(!1),g=r.useCallback(()=>{p(!0),v(null),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-projects"})}).then(L=>L.json()).then(L=>{L.ok?(c(L.projects||[]),M(L.suggestedProjectId||null),V(L.gitHubRepo||null)):v(L.error||"Failed to load projects"),C(!0)}).catch(L=>{v(`Failed to load projects: ${L.message||"network error"}`),C(!0)}).finally(()=>p(!1))},[]),T=()=>{_(!0),v(null),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create-project"})}).then(L=>L.json()).then(L=>{L.ok?(s({provider:"vercel",vercelProjectId:L.project.id,vercelProjectName:L.project.name}),E()):v(L.error||"Failed to create project")}).catch(()=>v("Failed to create project")).finally(()=>_(!1))},j=(L,xe)=>{k(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"link-project",projectId:L,projectName:xe})}).then(ie=>ie.json()).then(ie=>{ie.ok&&(s({provider:"vercel",vercelProjectId:L,vercelProjectName:xe}),E())}).catch(()=>{}).finally(()=>k(!1))},$=n||{hasToken:!1,tokenVerified:!1,user:null,projectLinked:!1,projectName:null,dashboardUrl:null,productionUrl:null,lastDeployment:null,envVarsChecked:!1,envVars:[]},I=$.tokenVerified,ee=$.projectLinked,K=$.envVars.filter(L=>L.configuredOnVercel).length,re=$.envVars.length,me=$.envVarsChecked&&(re===0||K===re),se=I?ee?3:2:1,pe=r.useCallback(L=>{var de;const xe=[`Step 1 (Account & Token): ${$.tokenVerified?`Connected as ${(de=$.user)==null?void 0:de.username}`:$.hasToken?"Token found but verification failed":"Not started"}`,`Step 2 (Link Project): ${$.projectLinked?`Linked to "${$.projectName}"`:"Not linked"}`,`Step 3 (Environment Variables): ${$.envVarsChecked?$.envVars.length===0?"No env vars needed":`${$.envVars.filter(ne=>ne.configuredOnVercel).length}/${$.envVars.length} configured`:"Not checked yet"}`];$.lastDeployment&&xe.push(`Last deployment: ${$.lastDeployment.state} (${$.lastDeployment.commitsSince} commits since)`);const ie=["# Vercel Setup Help","","The user is setting up Vercel hosting for their project and needs help.","","## Current Status",...xe.map(ne=>`- ${ne}`),S?`
|
|
85
|
+
Do NOT start making changes until the user tells you what they want.`}function pa(t,s,n=new Date){const a={"1d":1,"3d":3,"7d":7,"30d":30}[s],l=new Date(n);l.setDate(l.getDate()-a);const o=l.toISOString().split("T")[0],i=t.filter(c=>c.date>=o),d=new Set(i.map(c=>c.commitSha).filter(Boolean)),x=new Map;for(const c of i)if(c.scenarioScreenshots)for(const y of c.scenarioScreenshots){x.has(y.name)||x.set(y.name,[]);const M=x.get(y.name);M.some(D=>D.path===y.path)||M.push({path:y.path,time:c.time})}for(const c of x.values())c.sort((y,M)=>y.time.localeCompare(M.time));const g=[],b=new Map;for(const[c,y]of x){const M=c.indexOf(" - ");if(M!==-1){const D=c.slice(0,M);b.has(D)||b.set(D,[]),b.get(D).push({name:c,screenshots:y})}else g.push({name:c,screenshots:y})}return{commitCount:d.size,entryCount:i.length,appScenarios:g,componentGroups:b,totalScenarios:x.size}}function ha(t){const s=new Map;for(const n of[...t].reverse()){const a=s.get(n.date)||[];a.push(n),s.set(n.date,a)}return s}function ua(t){const s=new Map;for(const n of t){let a;if("componentName"in n&&n.componentName)a=n.componentName;else if("componentName"in n&&n.componentName===null)a="App";else{const o=n.name.indexOf(" - ");a=o!==-1?n.name.slice(0,o):"App"}const l=s.get(a)||[];l.push(n),s.set(a,l)}return[...s.entries()].sort(([n],[a])=>n==="App"?-1:a==="App"?1:n.localeCompare(a))}function Qs({status:t}){const s={new:{label:"New",bg:"bg-green-900/40",text:"text-green-400",border:"border-green-700/50"},edited:{label:"Edited",bg:"bg-blue-900/40",text:"text-blue-400",border:"border-blue-700/50"},impacted:{label:"Impacted",bg:"bg-amber-900/40",text:"text-amber-400",border:"border-amber-700/50"}}[t.status];return e.jsx("span",{className:`${s.bg} ${s.text} ${s.border} border text-[8px] font-bold px-1 py-0 rounded-full uppercase tracking-wider`,children:s.label})}function ma({testFile:t,entityName:s,cachedResult:n}){const{results:a,isRunning:l,runTests:o,stale:i}=es(t,n);if(l&&!a)return e.jsxs("div",{className:"pt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#00a0c4] animate-pulse"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"Running tests..."})]});if(!a)return null;if(a.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:a.errorMessage})});const d=s?a.testCases.filter(b=>b.fullName.startsWith(s)):a.testCases,x=d.length>0?d:a.testCases;if(x.length===0)return null;const g=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[x.map(b=>{var y;const c=g&&b.fullName.startsWith(g)?b.fullName.slice(g.length):b.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[b.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):b.status==="failed"?e.jsx("span",{className:"text-red-400 text-[10px]",children:"✗"}):e.jsx("span",{className:"text-gray-500 text-[10px]",children:"—"}),e.jsx("span",{className:`text-[10px] ${b.status==="passed"?"text-green-400":b.status==="failed"?"text-red-400":"text-gray-500"}`,children:c})]}),b.status==="failed"&&((y=b.failureMessages)==null?void 0:y.map((M,D)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:M,children:M.split(`
|
|
86
|
+
`)[0]},D)))]},b.fullName)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("button",{onClick:o,disabled:l,className:"text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":i?"Re-run (stale)":"Re-run"}),i&&!l&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",title:"Source or test file changed since last run"})]})]})}const fa={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function ga({files:t}){return e.jsxs("div",{className:"border-t border-[#3d3d3d] pt-2 mt-1",children:[e.jsxs("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:["Modified Files (",t.length,")"]}),e.jsx("div",{className:"mt-1 space-y-0.5 max-h-[150px] overflow-auto",children:t.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${fa[s.status]||"text-gray-500"}`,children:s.status==="added"||s.status==="untracked"?"A":s.status==="modified"?"M":s.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-400 truncate font-mono",children:s.path})]},s.path))})]})}const ba={feature:{label:"Feature",color:"bg-[#005c75]"},fix:{label:"Fix",color:"bg-amber-700"},refactor:{label:"Refactor",color:"bg-purple-700"},scaffold:{label:"Scaffold",color:"bg-green-700"},data:{label:"Data",color:"bg-blue-700"},milestone:{label:"Milestone",color:"bg-yellow-600"}};function ya(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function ja(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const va=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function Na({entries:t,onScreenshotClick:s}){const[n,a]=r.useState(!1),[l,o]=r.useState("7d"),i=r.useMemo(()=>pa(t,l),[t,l]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between px-3 py-2.5 cursor-pointer bg-transparent border-none text-left hover:bg-[#333] transition-colors",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Timeframe Summary"}),e.jsx("span",{className:`text-gray-500 text-[10px] transition-transform ${n?"rotate-180":""}`,children:"▼"})]}),n&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-[#3d3d3d]",children:[e.jsx("div",{className:"flex gap-1 pt-2.5",children:va.map(d=>e.jsx("button",{onClick:()=>o(d.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${l===d.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:d.label},d.value))}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.commitCount})," ",i.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.totalScenarios})," ",i.totalScenarios===1?"scenario changed":"scenarios changed"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:i.entryCount})," ",i.entryCount===1?"entry":"entries"]})]}),i.totalScenarios===0?e.jsx("p",{className:"text-[11px] text-gray-500 italic m-0",children:"No scenario changes in this period."}):e.jsxs("div",{className:"space-y-3",children:[i.appScenarios.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),i.appScenarios.map(d=>e.jsx(Xs,{scenario:d,onScreenshotClick:s},d.name))]}),i.componentGroups.size>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),[...i.componentGroups.entries()].sort(([d],[x])=>d.localeCompare(x)).map(([d,x])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:d}),x.map(g=>e.jsx(Xs,{scenario:g,onScreenshotClick:s},g.name))]},d))]})]})]})]})}function Xs({scenario:t,onScreenshotClick:s}){const n=t.name.indexOf(" - "),a=n!==-1?t.name.slice(n+3):t.name;return e.jsxs("div",{className:"pl-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500 block mb-1",children:a}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((l,o)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[o>0&&e.jsx("span",{className:"text-[8px] text-gray-600 mx-0.5",children:"→"}),e.jsx("button",{type:"button",className:"w-16 h-16 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",title:`${t.name} (${new Date(l.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${l.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${l.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},l.path))})]})}function wa({isActive:t,onScreenshotClick:s,glossaryFunctions:n=[],cachedTestResults:a={}}){const[l,o]=r.useState([]),[i,d]=r.useState(!0),[x,g]=r.useState(new Set),b=r.useCallback(M=>{g(D=>{const p=new Set(D);return p.has(M)?p.delete(M):p.add(M),p})},[]),c=r.useCallback(async()=>{try{const M=await fetch("/api/editor-journal");if(M.ok){const D=await M.json();o(D.entries||[])}}catch{}finally{d(!1)}},[]);if(r.useEffect(()=>{c()},[c]),r.useEffect(()=>{t&&c()},[t,c]),r.useEffect(()=>{if(!t)return;const M=setInterval(()=>void c(),5e3);return()=>clearInterval(M)},[t,c]),i)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-gray-500 text-sm",children:"Loading journal..."})});if(l.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 px-8",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"No journal entries yet"}),e.jsx("p",{className:"text-xs",children:"Journal entries will appear as you build. Claude records features, screenshots, and commits as the project evolves."})]})});const y=ha(l);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(Na,{entries:l,onScreenshotClick:s}),[...y.entries()].map(([M,D])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 sticky top-0 bg-[#1e1e1e] z-10",children:e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:ja(M)})}),e.jsx("div",{className:"space-y-2",children:D.map((p,w)=>{const k=ba[p.type]||{label:p.type,color:"bg-gray-600"},I=`${p.time}-${w}`,_=x.has(I);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${_?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>b(I),children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white truncate",children:p.title}),e.jsx("span",{className:`${k.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:k.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:ya(p.time)}),p.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:p.featureName,children:p.featureName})]})}),p.userPrompt&&e.jsx(yr,{text:p.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:p.description}),p.screenshot&&e.jsx("button",{type:"button",className:"rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] flex items-center justify-center p-1 cursor-pointer transition-colors w-full",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${p.screenshot.replace("screenshots/","")}`,commitSha:p.commitSha,commitMessage:p.commitMessage,scenarioName:p.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${p.screenshot.replace("screenshots/","")}`,alt:p.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),p.scenarioScreenshots&&p.scenarioScreenshots.length>0&&(()=>{const H=ua(p.scenarioScreenshots),z=p.entityChangeStatus,P=H.filter(([v])=>v==="App").flatMap(([,v])=>v),J=H.filter(([v])=>v!=="App"),G=new Map;for(const v of P){const B=v,O=B.pageFilePath?nt(rt(B.pageFilePath)):St(B.url??null),Y=G.get(O)||[];Y.push(v),G.set(O,Y)}const V=[...G.entries()],S=v=>e.jsx("button",{type:"button",className:"w-[4.5rem] h-[4.5rem] rounded overflow-hidden border border-[#3d3d3d] hover:border-[#00a0c4] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors",onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${v.path.replace("screenshots/","")}`,commitSha:p.commitSha,commitMessage:p.commitMessage,scenarioName:v.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${v.path.replace("screenshots/","")}`,alt:v.name,title:v.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},v.path);return e.jsxs("div",{className:"space-y-2",children:[V.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),V.map(([v,B])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:v}),(z==null?void 0:z[v])&&e.jsx(Qs,{status:z[v]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:B.map(S)})]},v))]}),J.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),J.map(([v,B])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:v}),(z==null?void 0:z[v])&&e.jsx(Qs,{status:z[v]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:B.map(S)})]},v))]})]})})(),n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),e.jsx("div",{className:"space-y-2",children:n.map(H=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:H.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:H.filePath}),H.testFile?e.jsx(ma,{testFile:H.testFile,entityName:H.name,cachedResult:a[H.testFile]}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},H.name))})]}),p.commitSha&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("span",{className:"font-mono text-[#00a0c4] bg-[#00a0c4]/10 px-1.5 py-0.5 rounded",children:p.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:p.commitMessage})]}),_&&p.modifiedFiles&&p.modifiedFiles.length>0&&e.jsx(ga,{files:p.modifiedFiles})]}),e.jsxs("button",{onClick:()=>b(I),className:"w-full py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-t border-[#3d3d3d] transition-colors cursor-pointer",children:["——— ",_?"Collapse":"Expand"," ———"]})]},I)})})]},M))]})})}function kt({className:t="",color:s="currentColor",dotSize:n=3,interval:a=180}){const[l,o]=r.useState(0);r.useEffect(()=>{const x=setInterval(()=>{o(g=>(g+1)%6)},a);return()=>clearInterval(x)},[a]);const i=[0,1,2,3,4,5],d=Math.max(1,Math.round(n*.4));return e.jsx("span",{className:`inline-grid shrink-0 ${t}`,style:{gridTemplateColumns:`${n}px ${n}px`,gridTemplateRows:`${n}px ${n}px ${n}px`,gap:`${d}px`},children:i.map(x=>e.jsx("span",{style:{width:n,height:n,borderRadius:"50%",backgroundColor:s,opacity:x===l||x===(l+1)%6?1:.25,transition:"opacity 0.15s ease"}},x))})}function Yt({title:t,completedCount:s,totalCount:n,subtitle:a,onClick:l,previewItems:o}){return e.jsxs("button",{type:"button",onClick:l,className:"bg-[#1e1e1e] border border-[#3d3d3d] rounded-lg p-3 flex flex-col gap-2 cursor-pointer hover:border-[#555] transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:t}),e.jsx("div",{className:"flex-1"}),n!=null&&n>0?e.jsxs("span",{className:"text-xs text-gray-500",children:[s,"/",n]}):null,a&&e.jsx("span",{className:"text-xs text-gray-500",children:a})]}),o&&o.length>0&&e.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(i=>e.jsxs("div",{className:"flex items-center gap-2 bg-[#2a2a2a] rounded-md px-2.5 py-1.5",children:[i.status==="active"&&i.buildIdle&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#FF8B43] shrink-0"}),i.status==="active"&&!i.buildIdle&&e.jsx(kt,{color:"#5ce0d2",dotSize:2}),e.jsx("span",{className:`text-[11px] truncate flex-1 ${i.status==="completed"?"text-gray-400":i.status==="active"?"text-white":"text-gray-300"}`,children:i.label}),i.status==="completed"&&e.jsx("span",{className:"shrink-0 w-3 h-3 rounded-full border border-gray-500 flex items-center justify-center",children:e.jsx("svg",{width:"6",height:"6",viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}),i.status==="pending"&&e.jsx("span",{className:"text-[8px] font-bold text-[#FFFF36] uppercase tracking-wider font-['IBM_Plex_Mono'] shrink-0",children:"Pending"}),i.status==="active"&&i.step&&e.jsx("span",{className:"text-[10px] text-[#5ce0d2] font-['IBM_Plex_Mono'] shrink-0",children:i.step})]},i.label))})]})}function ka({onNavigateToRoadmap:t,onSwitchToBuild:s,buildIdle:n=!1}){const[a,l]=r.useState(null),o=r.useCallback(()=>{fetch("/api/editor-roadmap").then(p=>p.json()).then(p=>l(p)).catch(()=>{})},[]);if(r.useEffect(()=>{o();const p=setInterval(o,5e3);return()=>clearInterval(p)},[o]),!a)return null;const i=a.plan.filter(p=>p.completed).length,d=a.plan.length,x=a.deploy.filter(p=>p.completed).length,g=a.deploy.length,b=[],c=a.plan.find(p=>!p.completed);c&&b.push({label:c.label,status:"pending"});const y=a.plan.find(p=>p.completed);y&&b.push({label:y.label,status:"completed"});const M=[];a.editorStep!=null&&a.editorStep<18&&M.push({label:a.featureName||"New Feature",status:"active",step:`${a.editorStep}/18`,buildIdle:n}),a.recentEntries.length>0&&M.push({label:a.recentEntries[0].title,status:"completed"});const D=a.deploy.filter(p=>!p.completed).slice(0,2).map(p=>({label:p.label,status:"pending"}));return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 bg-transparent border-none p-0 cursor-pointer group",children:[e.jsx("span",{className:"text-base font-medium text-gray-300 group-hover:text-white transition-colors",children:"Roadmap"}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-500 group-hover:text-white transition-colors",children:e.jsx("path",{d:"M3 1l4 4-4 4"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2",children:[e.jsx(Yt,{title:"Setup",completedCount:i,totalCount:d,onClick:t,previewItems:b}),e.jsx(Yt,{title:"Build",subtitle:a.buildSessionCount>0?`${a.buildSessionCount} features completed.`:void 0,onClick:t,previewItems:M}),e.jsx(Yt,{title:"Deploy",completedCount:x,totalCount:g,onClick:t,previewItems:D})]})]})}function Zt(t){return{name:Sa(t),description:Ca(t),colors:Fa(t),fonts:Da(t),typographyScale:Pa(t),radiusTokens:Ea(t)}}function Sa(t){const s=t.match(/^# (.+)$/m);return s?s[1].trim():"Design System"}function Ca(t){const s=t.match(/^> (.+)$/m);return s?s[1].trim():""}function Fa(t){const s=[],n=ss(t,"Colors");if(!n)return s;const a=Ma(n);for(const{heading:l,content:o}of a){const i=wr(o);for(const d of i){const x=/--([a-zA-Z0-9_-]+):\s*([^;]+);(?:\s*\/\*\s*(.+?)\s*\*\/)?/g;let g;for(;(g=x.exec(d))!==null;){const b=g[2].trim();$a(b)&&s.push({name:g[1],value:b,group:l,...g[3]?{comment:g[3]}:{}})}}}return s}function Da(t){const s=t.match(/\*\*Font stack:\*\*\s*`([^`]+)`(?:\s*\([^)]*\))?(?:,\s*`([^`]+)`)?/);if(!s)return[];const n=[];if(s[1]){const l=qt(s[1]);l&&n.push(l)}if(s[2]){const l=qt(s[2]);l&&!n.includes(l)&&n.push(l)}const a=t.match(/\*\*Font stack:\*\*\s*`[^`]+`[^`]*`[^`]+`[^`]*`([^`]+)`/);if(a){const l=qt(a[1]);l&&!n.includes(l)&&n.push(l)}return n}function qt(t){return t.split(",")[0].trim().replace(/'/g,"")||null}function Pa(t){const s=[],n=ss(t,"Typography");if(!n)return s;const a=n.split(`
|
|
87
|
+
`).filter(l=>l.startsWith("|"));if(a.length<3)return s;for(let l=2;l<a.length;l++){const o=a[l].split("|").map(i=>i.trim()).filter(Boolean);o.length>=3&&s.push({style:o[0],size:o[1],weight:o[2],notes:o.slice(3).join(" | ")})}return s}function Ea(t){const s=[],n=ss(t,"Spacing");if(!n)return s;const a=wr(n);for(const l of a){const o=/--radius-([a-zA-Z0-9_-]+):\s*([^;]+);(?:\s*\/\*\s*(.+?)\s*\*\/)?/g;let i;for(;(i=o.exec(l))!==null;)s.push({name:`radius-${i[1]}`,value:i[2].trim(),...i[3]?{comment:i[3]}:{}})}return s}function Ta(t,s,n){const a=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=new RegExp(`(--${a}:\\s*)([^;]+)(;.*)`,"g");return t.replace(l,`$1${n}$3`)}function La(t,s){return t.replace(/(\*\*Font stack:\*\*\s*`)([^`]+)(`)/,`$1${s}$3`)}function ss(t,s){const a=new RegExp(`^## .*${s}.*$`,"im").exec(t);if(!a)return null;const l=a.index+a[0].length,o=t.indexOf(`
|
|
88
|
+
## `,l);return o===-1?t.slice(l):t.slice(l,o)}function Ma(t){const s=[],n=t.split(/^### /m);for(let a=0;a<n.length;a++){if(a===0){const o=n[a].trim();o&&s.push({heading:"General",content:o});continue}const l=n[a].indexOf(`
|
|
89
|
+
`);l===-1?s.push({heading:n[a].trim(),content:""}):s.push({heading:n[a].slice(0,l).trim(),content:n[a].slice(l+1)})}return s}function wr(t){const s=[],n=/```css\n([\s\S]*?)```/g;let a;for(;(a=n.exec(t))!==null;)s.push(a[1]);return s}function $a(t){return!!(t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||t.startsWith("var(--"))}const Zs=[{key:"languages",label:"Languages"},{key:"frameworks",label:"Frameworks"},{key:"databases",label:"Databases"},{key:"services",label:"External Services"},{key:"libraries",label:"Key Libraries"},{key:"infrastructure",label:"Infrastructure"}];function er({todo:t,expanded:s,onToggle:n,onRemove:a,children:l}){return e.jsxs("div",{className:"mx-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 group cursor-pointer bg-[#2a2a2a] rounded-lg hover:bg-[#303030] transition-colors",onClick:n,children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-gray-500 transition-transform ${s?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsxs("span",{className:`text-sm flex-1 ${t.completed?"text-gray-400":"text-white"}`,children:[t.label,t.autoDetect&&!t.userCreated&&e.jsx("span",{className:"text-[10px] text-gray-600 ml-1.5",children:"(auto)"})]}),t.completed?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-gray-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"text-[9px] font-bold text-[#FFFF36] uppercase tracking-wider font-['IBM_Plex_Mono'] shrink-0",children:"Pending"}),t.userCreated&&a&&e.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),a()},className:"opacity-0 group-hover:opacity-100 text-gray-600 hover:text-red-400 bg-transparent border-none cursor-pointer p-0 transition-opacity",title:"Remove",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})})]}),s&&e.jsx("div",{className:"px-4 pb-3 pt-1",children:l})]})}function yt({title:t,completedCount:s,totalCount:n,subtitle:a,subtitleAccent:l=!1,subtitleLink:o,collapsed:i,onToggleCollapse:d,onAction:x,actionLabel:g="Select"}){return e.jsxs("div",{className:`flex items-center gap-2 py-3 px-3 ${d?"cursor-pointer":""}`,onClick:d,children:[d&&e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-gray-400 transition-transform ${i?"":"rotate-90"}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("h3",{className:"text-base font-medium text-white m-0",children:t}),n!=null&&n>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500",children:"/"}),e.jsxs("span",{className:"text-sm text-gray-400",children:[s,"/",n]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500",children:"/"}),e.jsx("span",{className:`text-sm ${l?"text-[#5ce0d2]":"text-gray-400"}`,children:a})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500",children:"/"}),e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),o.onClick()},className:"text-sm text-[#D7FF63] hover:text-[#D7FF63]/70 underline bg-transparent border-none p-0 cursor-pointer transition-colors",children:o.label})]}),e.jsx("div",{className:"flex-1"}),x&&e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),x()},className:"text-[10px] font-bold text-gray-500 hover:text-white uppercase tracking-wider bg-transparent border-none p-0 cursor-pointer transition-colors font-['IBM_Plex_Mono']",children:g})]})}const Ra={feature:"text-gray-300 border-gray-500/40 bg-gray-500/15",fix:"text-amber-400 border-amber-400/40 bg-amber-400/10",refactor:"text-purple-400 border-purple-400/40 bg-purple-400/10",scaffold:"text-emerald-400 border-emerald-400/40 bg-emerald-400/10",data:"text-blue-400 border-blue-400/40 bg-blue-400/10",milestone:"text-yellow-400 border-yellow-400/40 bg-yellow-400/10"},Ia="text-gray-400 border-gray-400/40 bg-gray-400/10";function Aa(t){const s=new Map;for(const a of t){const l=a.componentName||"App";s.has(l)||s.set(l,[]),s.get(l).push(a)}return[...s.entries()].sort(([a],[l])=>a==="App"?-1:l==="App"?1:a.localeCompare(l))}const Oa={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400",deleted:"text-red-400"};function _a({entry:t,expandedSections:s,onToggleSection:n,onScreenshotClick:a}){var b;const l=t.scenarioScreenshots?Aa(t.scenarioScreenshots):[],o=((b=l.find(([c])=>c==="App"))==null?void 0:b[1])||[],i=l.filter(([c])=>c!=="App"),d=(t.modifiedFiles||[]).filter(c=>!c.path.startsWith(".codeyam/")&&!c.path.includes("node_modules")&&!c.path.endsWith(".log")),x=c=>`${t.time}-${c}`,g=(o.length>0?o:t.scenarioScreenshots||[]).slice(0,3);return e.jsxs("div",{className:"px-4 py-4 space-y-4",children:[t.description&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono']",children:"Description"}),e.jsx("p",{className:"text-sm text-white m-0 mt-1.5 leading-relaxed",children:t.description})]}),t.userPrompt&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] mr-2",children:"User Prompt"}),e.jsxs("span",{className:"text-sm text-gray-400 leading-relaxed",children:[t.userPrompt.length>150?t.userPrompt.slice(0,150)+"... ":t.userPrompt,t.userPrompt.length>150&&e.jsx("span",{className:"text-[#5ce0d2] cursor-pointer hover:underline text-sm",children:"Read More"})]})]}),g.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono']",children:"Preview"}),e.jsx("div",{className:"flex gap-3 mt-2",children:g.map(c=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>a==null?void 0:a({screenshotUrl:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,commitSha:t.commitSha||null,commitMessage:t.commitMessage||null,scenarioName:c.name}),className:"w-[7rem] h-[5.5rem] rounded-lg overflow-hidden border border-[#3d3d3d] hover:border-[#5ce0d2] bg-[#1e1e1e] flex items-center justify-center cursor-pointer transition-colors p-0",children:e.jsx("img",{src:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,alt:c.name,title:c.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),e.jsx("span",{className:"text-[11px] text-gray-500 truncate w-[7rem]",children:c.name.includes(" - ")?c.name.split(" - ")[0]:c.name})]},c.path))})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>n(x("files")),className:"flex items-center gap-2 text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${s.has(x("files"))?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),"Modified Files (",d.length,")"]}),s.has(x("files"))&&e.jsx("div",{className:"mt-1.5 max-h-[120px] overflow-auto space-y-0.5",children:d.map(c=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:`shrink-0 text-[9px] font-bold uppercase ${Oa[c.status]||"text-gray-500"}`,children:c.status==="untracked"?"A":c.status.charAt(0).toUpperCase()}),e.jsx("span",{className:"text-gray-500 truncate",children:c.path})]},c.path))})]}),o.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>n(x("app")),className:"flex items-center gap-2 text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${s.has(x("app"))?"":"rotate-90"}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),"App"]}),!s.has(x("app"))&&e.jsx("div",{className:"flex gap-2 mt-1.5 flex-wrap",children:o.map(c=>e.jsx("button",{type:"button",onClick:()=>a==null?void 0:a({screenshotUrl:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,commitSha:t.commitSha||null,commitMessage:t.commitMessage||null,scenarioName:c.name}),className:"w-[4.5rem] h-[4.5rem] rounded overflow-hidden border border-[#3d3d3d] hover:border-[#5ce0d2] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors p-0",children:e.jsx("img",{src:`/api/editor-journal-image/${c.path.replace("screenshots/","")}`,alt:c.name,title:c.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},c.path))})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>n(x("components")),className:"flex items-center gap-2 text-[10px] font-bold text-[#646464] uppercase tracking-wider font-['IBM_Plex_Mono'] bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${s.has(x("components"))?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),"Components (",i.length,")"]}),s.has(x("components"))&&e.jsx("div",{className:"mt-1.5 space-y-2",children:i.map(([c,y])=>e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>onZoomChange==null?void 0:onZoomChange(c),className:"text-[11px] text-gray-400 hover:text-[#5ce0d2] font-medium bg-transparent border-none p-0 cursor-pointer transition-colors",children:c}),e.jsx("div",{className:"flex gap-1.5 mt-1 flex-wrap",children:y.map(M=>e.jsx("button",{type:"button",onClick:()=>a==null?void 0:a({screenshotUrl:`/api/editor-journal-image/${M.path.replace("screenshots/","")}`,commitSha:t.commitSha||null,commitMessage:t.commitMessage||null,scenarioName:M.name}),className:"w-14 h-14 rounded overflow-hidden border border-[#3d3d3d] hover:border-[#5ce0d2] bg-[#1e1e1e] shrink-0 flex items-center justify-center cursor-pointer transition-colors p-0",children:e.jsx("img",{src:`/api/editor-journal-image/${M.path.replace("screenshots/","")}`,alt:M.name,title:M.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})},M.path))})]},c))})]})]})}function Ba(t){try{return new Date(t).toLocaleDateString([],{month:"short",day:"numeric"})}catch{return""}}function Wa({designSystem:t,onEdit:s}){const n=t.colors.filter(a=>a.value.startsWith("#")).slice(0,10);return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs font-medium text-gray-200 mb-2",children:t.name}),n.length>0&&e.jsx("div",{className:"flex gap-1.5 mb-2 flex-wrap",children:n.map(a=>e.jsx("div",{className:"w-5 h-5 rounded border border-[#444]",style:{backgroundColor:a.value},title:`--${a.name}: ${a.value}`},`${a.group}-${a.name}`))}),t.fonts.length>0&&e.jsxs("div",{className:"text-[10px] text-gray-500 mb-2",children:["Font: ",t.fonts.join(", ")]}),s&&e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors font-medium",children:"View & Edit >"})]})}function tr({projectTitle:t,projectDescription:s,onSave:n,onEditNavigate:a,defaultEditing:l=!1}){const[o,i]=r.useState(l),[d,x]=r.useState(t||""),[g,b]=r.useState(s||""),[c,y]=r.useState(!1);r.useEffect(()=>{x(t||""),b(s||"")},[t,s]);const M=()=>{y(!0),n(d,g),y(!1),i(!1)},D=()=>{x(t||""),b(s||""),i(!1)};return o?e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Project Name"}),e.jsx("input",{type:"text",value:d,onChange:p=>x(p.target.value),placeholder:"My App",className:"w-full px-2.5 py-1.5 text-sm bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Description"}),e.jsx("textarea",{value:g,onChange:p=>b(p.target.value),placeholder:"A brief description of your project...",rows:2,className:"w-full px-2.5 py-1.5 text-sm bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors resize-none"})]}),e.jsxs("div",{className:"flex gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:M,disabled:c,className:"px-3 py-1 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium disabled:opacity-50",children:c?"Saving...":"Save"}),e.jsx("button",{type:"button",onClick:D,className:"px-3 py-1 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]})}):e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[t?e.jsx("div",{className:"text-xs font-medium text-gray-200 mb-0.5",children:t}):e.jsx("div",{className:"text-xs text-gray-500 italic mb-0.5",children:"No name set"}),s&&e.jsx("div",{className:"text-[11px] text-gray-400 leading-relaxed",children:s}),e.jsx("button",{type:"button",onClick:a??(()=>i(!0)),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-1.5 cursor-pointer transition-colors font-medium",children:"Edit >"})]})}function Ha({techStack:t,onNavigate:s}){if(!(t&&Zs.some(({key:i})=>t[i]&&t[i].length>0)))return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs text-gray-400 mb-2",children:"No tech stack configured yet"}),s&&e.jsx("button",{type:"button",onClick:s,className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Set up with Claude >"})]});const a=[];for(const{key:i}of Zs){const d=t[i];if(d)for(const x of d)a.push(x)}const l=a.slice(0,5),o=a.length-5;return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[l.map((i,d)=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-300 bg-[#2a2a2a] px-2 py-0.5 rounded",children:[i.name,i.version&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["v",i.version]})]},d)),o>0&&e.jsxs("span",{className:"text-[10px] text-gray-500 self-center",children:["+",o," more"]})]}),s&&e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"View all >"})]})}function Qt({iconType:t,size:s=14,className:n=""}){const a={width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:n};switch(t){case"desktop":return e.jsxs("svg",{...a,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]});case"laptop":return e.jsxs("svg",{...a,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"})]});case"tablet":return e.jsxs("svg",{...a,children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]});case"mobile":return e.jsxs("svg",{...a,children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})}}function sr({open:t,size:s=12}){return t?e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}):e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),e.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),e.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),e.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}const Ua=new Set(ur.flatMap(t=>t.presets.map(s=>s.name)));function rr({screenSizes:t,projectScreenSizes:s,defaultScreenSize:n,appFormats:a,onSave:l,onEditNavigate:o,defaultEditing:i=!1}){const d=r.useMemo(()=>mr(t,a),[t,a]),x=r.useMemo(()=>{if(t){for(const[E,U]of Object.entries(t))if(U.default)return E}return(n==null?void 0:n.name)||""},[t,n]),[g,b]=r.useState(i),[c,y]=r.useState({}),[M,D]=r.useState(new Set),[p,w]=r.useState(""),[k,I]=r.useState(""),[_,H]=r.useState(""),[z,P]=r.useState(""),J=()=>{const E={};for(const F of d)E[F.name]={width:F.width,height:F.height};y(E);const U=new Set,m=s||t;if(m)for(const F of Object.keys(m)){const f=m[F];(s||!f||!("default"in f))&&U.add(F)}D(U),w(x),I(""),H(""),P(""),b(!0)};r.useEffect(()=>{i&&J()},[]);const G=(E,U,m)=>{y(F=>{const f={...F};if(f[E]){if(delete f[E],D(T=>{const j=new Set(T);return j.delete(E),j}),E===p){const T=Object.keys(f);w(T[0]||"")}}else f[E]={width:U,height:m},Object.keys(F).length===0&&w(E);return f})},V=E=>{D(U=>{const m=new Set(U);return m.has(E)?m.delete(E):m.add(E),m})},S=E=>{c[E]&&w(E)},v=()=>{const E=k.trim(),U=parseInt(_,10),m=parseInt(z,10);!E||isNaN(U)||isNaN(m)||U<=0||m<=0||(y(F=>(Object.keys(F).length===0&&w(E),{...F,[E]:{width:U,height:m}})),I(""),H(""),P(""))},B=E=>{y(U=>{const m={...U};return delete m[E],E===p&&w(Object.keys(m)[0]||""),m}),D(U=>{const m=new Set(U);return m.delete(E),m})},O=()=>{const E={};for(const[m,F]of Object.entries(c))E[m]={width:F.width,height:F.height,...m===p?{default:!0}:{}};const U={};for(const m of M)c[m]&&(U[m]={...c[m]});l(E,U),b(!1)};if(g){const E=Object.entries(c).filter(([U])=>!Ua.has(U));return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-0.5",children:[e.jsx("div",{className:"w-3.5"}),e.jsx("div",{className:"w-3.5"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider flex-1",children:"Size"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[72px] text-right",children:"Dimensions"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[50px] text-center",title:"Include in project screenshot sizes",children:"Project"}),e.jsx("span",{className:"text-[9px] font-semibold text-gray-600 uppercase tracking-wider w-[54px] text-center",children:"Default"})]}),e.jsxs("div",{className:"space-y-3",children:[ur.map(U=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:U.category}),e.jsx("div",{className:"space-y-0.5",children:U.presets.map(m=>{const F=!!c[m.name],f=p===m.name,T=M.has(m.name),j=Nt(m);return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("button",{type:"button",onClick:()=>G(m.name,m.width,m.height),className:`w-3.5 h-3.5 rounded-sm border flex items-center justify-center shrink-0 cursor-pointer transition-colors ${F?"bg-[#D7FF63] border-[#D7FF63]":"bg-transparent border-[#555] hover:border-[#888]"}`,children:F&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#1e1e1e",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}),e.jsx(Qt,{iconType:j,size:14,className:F?"text-gray-300":"text-gray-600"}),e.jsx("span",{className:`text-xs flex-1 ${F?"text-gray-300":"text-gray-500"}`,children:m.name}),e.jsxs("span",{className:"text-[10px] text-gray-500 tabular-nums w-[72px] text-right",children:[m.width," × ",m.height]}),e.jsx("div",{className:"w-[50px] flex justify-center",children:F?e.jsx("button",{type:"button",onClick:()=>V(m.name),className:`p-1 rounded cursor-pointer transition-colors ${T?"text-[#D7FF63] hover:text-[#D7FF63]/70":"text-gray-600 hover:text-gray-400"}`,title:T?"In project screenshots":"Not in project screenshots",children:e.jsx(sr,{open:T})}):e.jsx("span",{className:"w-3"})}),e.jsx("div",{className:"w-[54px] flex justify-center",children:F?e.jsx("button",{type:"button",onClick:()=>S(m.name),className:`text-[10px] px-1.5 py-0.5 rounded border cursor-pointer transition-colors ${f?"text-[#1e1e1e] bg-[#D7FF63] border-[#D7FF63]":"text-gray-500 bg-transparent border-[#444] hover:border-[#666] hover:text-gray-300"}`,title:f?"Default size":"Set as default",children:f?"★":"☆"}):e.jsx("span",{className:"w-3"})})]},m.name)})})]},U.category)),E.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Custom"}),e.jsx("div",{className:"space-y-0.5",children:E.map(([U,m])=>{const F=p===U,f=M.has(U),T=Nt({name:U,width:m.width,height:m.height});return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("div",{className:"w-3.5"}),e.jsx(Qt,{iconType:T,size:14,className:"text-gray-300"}),e.jsx("span",{className:"text-xs text-gray-300 flex-1",children:U}),e.jsxs("span",{className:"text-[10px] text-gray-500 tabular-nums w-[72px] text-right",children:[m.width," × ",m.height]}),e.jsx("div",{className:"w-[50px] flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>V(U),className:`p-1 rounded cursor-pointer transition-colors ${f?"text-[#D7FF63] hover:text-[#D7FF63]/70":"text-gray-600 hover:text-gray-400"}`,title:f?"In project screenshots":"Not in project screenshots",children:e.jsx(sr,{open:f})})}),e.jsx("div",{className:"w-[54px] flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>S(U),className:`text-[10px] px-1.5 py-0.5 rounded border cursor-pointer transition-colors ${F?"text-[#1e1e1e] bg-[#D7FF63] border-[#D7FF63]":"text-gray-500 bg-transparent border-[#444] hover:border-[#666] hover:text-gray-300"}`,title:F?"Default size":"Set as default",children:F?"★":"☆"})}),e.jsx("button",{type:"button",onClick:()=>B(U),className:"text-gray-600 hover:text-red-400 bg-transparent border-none p-0.5 cursor-pointer transition-colors text-xs leading-none",children:"×"})]},U)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Add Custom Size"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:k,onChange:U=>I(U.target.value),placeholder:"Name",className:"flex-1 min-w-0 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"number",value:_,onChange:U=>H(U.target.value),placeholder:"W",className:"w-14 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"×"}),e.jsx("input",{type:"number",value:z,onChange:U=>P(U.target.value),placeholder:"H",className:"w-14 px-2 py-1 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("button",{type:"button",onClick:v,className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors font-medium",children:"+ Add"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2.5",children:[e.jsx("button",{type:"button",onClick:O,className:"px-3 py-1 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>b(!1),className:"px-3 py-1 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]})}if(d.length===0)return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-xs text-gray-500 italic",children:"No screen sizes configured"}),e.jsx("button",{type:"button",onClick:o??J,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-1.5 cursor-pointer transition-colors font-medium",children:"Edit >"})]});const Y=E=>x===E,Z=E=>{var U;return!!((U=s||t)!=null&&U[E])};return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.map(E=>{const U=Nt(E);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs bg-[#2a2a2a] px-2 py-1 rounded text-gray-300",children:[e.jsx(Qt,{iconType:U,size:12,className:"text-gray-400"}),E.name,e.jsxs("span",{className:"text-[10px] text-gray-500",children:[E.width,"×",E.height]}),Y(E.name)&&e.jsx("span",{className:"text-[10px] text-[#D7FF63]",children:"★"}),Z(E.name)&&e.jsx("span",{className:"text-[10px] text-[#D7FF63]",title:"Project screenshot size",children:"P"})]},E.name)})}),e.jsx("button",{type:"button",onClick:o??J,className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"Edit >"})]})}const nr=[{id:"vercel",name:"Vercel",services:["Hosting"],description:"Frontend-optimized hosting"},{id:"railway",name:"Railway",services:["Hosting","Database","Storage"],description:"Full-stack infrastructure"},{id:"runloop",name:"Runloop",services:["Sandboxes","Hosting"],description:"Sandbox-first deployment"}];function we({step:t,done:s,active:n}){return e.jsx("span",{className:`shrink-0 w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold ${s?"bg-green-600 text-white":n?"bg-[#D7FF63] text-black":"bg-[#333] text-gray-500"}`,children:s?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):t})}function za({hosting:t,onSave:s}){var fe;const[n,a]=r.useState(null),[l,o]=r.useState(!0),[i,d]=r.useState(""),[x,g]=r.useState(!1),[b,c]=r.useState([]),[y,M]=r.useState(null),[D,p]=r.useState(!1),[w,k]=r.useState(!1),[I,_]=r.useState(!1),[H,z]=r.useState(!1),[P,J]=r.useState(null),[G,V]=r.useState(null),[S,v]=r.useState(null),[B,O]=r.useState(null),[Y,Z]=r.useState(null),E=r.useCallback(()=>{o(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"full-status"})}).then(L=>L.json()).then(L=>{a(L),v(null)}).catch(()=>v("Failed to check status")).finally(()=>o(!1))},[]);r.useEffect(()=>{E()},[E]);const U=()=>{i.trim()&&(g(!0),v(null),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save-token",token:i.trim()})}).then(L=>L.json()).then(L=>{L.ok?(d(""),E()):v(L.error||"Token verification failed")}).catch(()=>v("Failed to save token")).finally(()=>g(!1)))},[m,F]=r.useState(!1),f=r.useCallback(()=>{p(!0),v(null),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-projects"})}).then(L=>L.json()).then(L=>{L.ok?(c(L.projects||[]),M(L.suggestedProjectId||null),V(L.gitHubRepo||null)):v(L.error||"Failed to load projects"),F(!0)}).catch(L=>{v(`Failed to load projects: ${L.message||"network error"}`),F(!0)}).finally(()=>p(!1))},[]),T=()=>{_(!0),v(null),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create-project"})}).then(L=>L.json()).then(L=>{L.ok?(s({provider:"vercel",vercelProjectId:L.project.id,vercelProjectName:L.project.name}),E()):v(L.error||"Failed to create project")}).catch(()=>v("Failed to create project")).finally(()=>_(!1))},j=(L,xe)=>{k(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"link-project",projectId:L,projectName:xe})}).then(ie=>ie.json()).then(ie=>{ie.ok&&(s({provider:"vercel",vercelProjectId:L,vercelProjectName:xe}),E())}).catch(()=>{}).finally(()=>k(!1))},$=n||{hasToken:!1,tokenVerified:!1,user:null,projectLinked:!1,projectName:null,dashboardUrl:null,productionUrl:null,lastDeployment:null,envVarsChecked:!1,envVars:[]},R=$.tokenVerified,ee=$.projectLinked,K=$.envVars.filter(L=>L.configuredOnVercel).length,re=$.envVars.length,me=$.envVarsChecked&&(re===0||K===re),se=R?ee?3:2:1,pe=r.useCallback(L=>{var de;const xe=[`Step 1 (Account & Token): ${$.tokenVerified?`Connected as ${(de=$.user)==null?void 0:de.username}`:$.hasToken?"Token found but verification failed":"Not started"}`,`Step 2 (Link Project): ${$.projectLinked?`Linked to "${$.projectName}"`:"Not linked"}`,`Step 3 (Environment Variables): ${$.envVarsChecked?$.envVars.length===0?"No env vars needed":`${$.envVars.filter(ne=>ne.configuredOnVercel).length}/${$.envVars.length} configured`:"Not checked yet"}`];$.lastDeployment&&xe.push(`Last deployment: ${$.lastDeployment.state} (${$.lastDeployment.commitsSince} commits since)`);const ie=["# Vercel Setup Help","","The user is setting up Vercel hosting for their project and needs help.","","## Current Status",...xe.map(ne=>`- ${ne}`),S?`
|
|
90
90
|
## Current Error
|
|
91
91
|
\`\`\`
|
|
92
92
|
${S}
|
|
93
93
|
\`\`\``:"",L?`
|
|
94
94
|
## Additional Context
|
|
95
95
|
${L}`:"","","## What You Can Do","- Help the user understand what they need to do next","- If there is a deployment error, help them debug it","- You can read project files to understand the setup (package.json, next.config.ts, etc.)","- Guide them to the right Vercel documentation or settings pages","- If the issue is about GitHub permissions, guide them to vercel.com/account/login-connections","","Start by acknowledging what step they are on and ask what they need help with."].filter(Boolean).join(`
|
|
96
|
-
`);O(ie),cr(()=>import("./MiniClaudeChat-Bs2_Oua4.js"),__vite__mapDeps([3,4,1,2])).then(ne=>{Z(()=>ne.MiniClaudeChat)})},[$,S]),he=r.useRef(!1);return r.useEffect(()=>{se===2&&!he.current&&f.length===0&&!D&&(he.current=!0,g())},[se,f.length,D,g]),r.useEffect(()=>{if(!P)return;const L=["READY","ERROR","CANCELED"];if(L.includes(P.state))return;const xe=setInterval(()=>{fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"check-deployment",deploymentId:P.id})}).then(ie=>ie.json()).then(ie=>{ie.ok&&(J(de=>de?{...de,state:ie.state,url:ie.url||de.url,errorMessage:ie.errorMessage,logsUrl:ie.logsUrl}:null),L.includes(ie.state)&&E())}).catch(()=>{})},5e3);return()=>clearInterval(xe)},[P,E]),l&&!n?e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsx("span",{className:"text-xs text-gray-500",children:"Checking Vercel setup..."})}):e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333] space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Vercel Setup"}),e.jsx("p",{className:"text-[11px] text-gray-400 m-0 leading-relaxed",children:"Vercel deploys your app to the web. Push your code and Vercel automatically builds and hosts it at a public URL — no server setup required. Free for personal projects."})]}),S&&e.jsxs("div",{className:"text-[11px] bg-red-400/10 rounded px-2.5 py-2 space-y-1.5",children:[e.jsx("p",{className:"text-red-400 m-0",children:S}),S.toLowerCase().includes("login connection")&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-400 m-0 text-[10px] leading-relaxed",children:"Vercel needs permission to access your GitHub repositories. Connect your GitHub account, then come back and try again."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://vercel.com/account/login-connections",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Connect GitHub →"}),e.jsx("button",{type:"button",onClick:()=>{v(null),T()},className:"text-[11px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] rounded px-2.5 py-1 cursor-pointer transition-colors",children:"Retry"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{step:1,done:I,active:se===1}),e.jsx("span",{className:"text-xs font-medium text-white",children:"Create Account & Connect"}),I&&$.user&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:$.user.username})]}),se===1&&e.jsxs("div",{className:"ml-7 space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"a) Create a free Vercel account"}),e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Sign up with GitHub, GitLab, or email. The free Hobby plan includes unlimited deployments and custom domains."}),e.jsx("a",{href:"https://vercel.com/signup",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Sign up at vercel.com →"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"b) Create an API token"}),e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"This lets CodeYam verify your setup and check your project configuration. Go to Account Settings → Tokens → Create."}),e.jsx("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"Open token settings →"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"c) Paste your token here"}),$.hasToken&&!$.tokenVerified&&e.jsx("p",{className:"text-[11px] text-amber-400 m-0",children:"A token was found but it didn't work. Try creating a new one and pasting it below."}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"Paste your Vercel token",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>{L.key==="Enter"&&U()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",onClick:U,disabled:x||!i.trim(),className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:x?"Verifying...":"Connect"})]}),e.jsx("p",{className:"text-[10px] text-gray-600 m-0",children:"Stored in .env.local (gitignored — never committed)"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{step:2,done:ee,active:se===2}),e.jsx("span",{className:`text-xs font-medium ${se>=2?"text-white":"text-gray-600"}`,children:"Link Project"}),ee&&$.projectName&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:$.projectName})]}),ee&&e.jsxs("div",{className:"ml-7 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[$.dashboardUrl&&e.jsx("a",{href:$.dashboardUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"Dashboard →"}),((ge=$.lastDeployment)==null?void 0:ge.url)&&e.jsxs("a",{href:$.lastDeployment.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:[$.lastDeployment.url.replace("https://","")," →"]})]}),$.lastDeployment&&!P&&e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-500",children:[e.jsxs("span",{children:["Deployed"," ",(()=>{const L=Date.now()-$.lastDeployment.createdAt,xe=Math.floor(L/6e4);if(xe<1)return"just now";if(xe<60)return`${xe}m ago`;const ie=Math.floor(xe/60);return ie<24?`${ie}h ago`:`${Math.floor(ie/24)}d ago`})()]}),e.jsx("span",{className:"text-gray-600",children:"·"}),e.jsxs("span",{className:$.lastDeployment.commitsSince>0?"text-amber-400":"text-gray-500",children:[$.lastDeployment.commitsSince," commit",$.lastDeployment.commitsSince===1?"":"s"," since"]}),e.jsx("button",{type:"button",disabled:H,onClick:()=>{v(null),z(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"deploy"})}).then(L=>L.json()).then(L=>{L.ok&&L.deployment?J({id:L.deployment.id,state:L.deployment.state||"QUEUED",url:L.deployment.url,errorMessage:null,logsUrl:null}):v(L.error||"Deployment failed")}).catch(()=>v("Failed to trigger deployment")).finally(()=>z(!1))},className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors underline",children:H?"Starting...":"Redeploy"})]}),P&&e.jsxs("div",{className:`bg-[#2a2a2a] border rounded-md px-3 py-2 space-y-1.5 ${P.state==="ERROR"?"border-red-500/40":P.state==="READY"?"border-green-500/40":"border-[#D7FF63]/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[P.state==="READY"?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):P.state==="ERROR"||P.state==="CANCELED"?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-red-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 12 12",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-[#D7FF63]/30 flex items-center justify-center animate-pulse",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#D7FF63]"})}),e.jsx("span",{className:"text-[11px] text-white font-medium",children:P.state==="READY"?"Deployed successfully":P.state==="ERROR"?"Deployment failed":P.state==="CANCELED"?"Deployment canceled":P.state==="BUILDING"?"Building...":"Deploying..."})]}),P.state==="READY"&&P.url&&e.jsxs("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors block",children:[P.url.replace("https://","")," →"]}),P.state==="ERROR"&&e.jsxs("div",{className:"space-y-1",children:[P.errorMessage&&e.jsx("pre",{className:"text-[10px] text-red-300 bg-[#1a1a1a] rounded px-2 py-1.5 m-0 whitespace-pre-wrap font-mono overflow-x-auto max-h-24 overflow-y-auto",children:P.errorMessage}),e.jsxs("div",{className:"flex items-center gap-2",children:[P.logsUrl&&e.jsx("a",{href:P.logsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"View full logs →"}),e.jsx("button",{type:"button",onClick:()=>{J(null),v(null),z(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"deploy"})}).then(L=>L.json()).then(L=>{L.ok&&L.deployment?J({id:L.deployment.id,state:L.deployment.state||"QUEUED",url:L.deployment.url,errorMessage:null,logsUrl:null}):v(L.error||"Deployment failed")}).catch(()=>v("Failed to trigger deployment")).finally(()=>z(!1))},className:"text-[10px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] rounded px-2 py-0.5 cursor-pointer transition-colors",children:"Retry"}),e.jsx("button",{type:"button",onClick:()=>pe(`## Deployment Error
|
|
96
|
+
`);O(ie),pr(()=>import("./MiniClaudeChat-Bs2_Oua4.js"),__vite__mapDeps([3,4,1,2])).then(ne=>{Z(()=>ne.MiniClaudeChat)})},[$,S]),he=r.useRef(!1);return r.useEffect(()=>{se===2&&!he.current&&b.length===0&&!D&&(he.current=!0,f())},[se,b.length,D,f]),r.useEffect(()=>{if(!P)return;const L=["READY","ERROR","CANCELED"];if(L.includes(P.state))return;const xe=setInterval(()=>{fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"check-deployment",deploymentId:P.id})}).then(ie=>ie.json()).then(ie=>{ie.ok&&(J(de=>de?{...de,state:ie.state,url:ie.url||de.url,errorMessage:ie.errorMessage,logsUrl:ie.logsUrl}:null),L.includes(ie.state)&&E())}).catch(()=>{})},5e3);return()=>clearInterval(xe)},[P,E]),l&&!n?e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsx("span",{className:"text-xs text-gray-500",children:"Checking Vercel setup..."})}):e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333] space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Vercel Setup"}),e.jsx("p",{className:"text-[11px] text-gray-400 m-0 leading-relaxed",children:"Vercel deploys your app to the web. Push your code and Vercel automatically builds and hosts it at a public URL — no server setup required. Free for personal projects."})]}),S&&e.jsxs("div",{className:"text-[11px] bg-red-400/10 rounded px-2.5 py-2 space-y-1.5",children:[e.jsx("p",{className:"text-red-400 m-0",children:S}),S.toLowerCase().includes("login connection")&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-400 m-0 text-[10px] leading-relaxed",children:"Vercel needs permission to access your GitHub repositories. Connect your GitHub account, then come back and try again."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://vercel.com/account/login-connections",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Connect GitHub →"}),e.jsx("button",{type:"button",onClick:()=>{v(null),T()},className:"text-[11px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] rounded px-2.5 py-1 cursor-pointer transition-colors",children:"Retry"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{step:1,done:R,active:se===1}),e.jsx("span",{className:"text-xs font-medium text-white",children:"Create Account & Connect"}),R&&$.user&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:$.user.username})]}),se===1&&e.jsxs("div",{className:"ml-7 space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"a) Create a free Vercel account"}),e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Sign up with GitHub, GitLab, or email. The free Hobby plan includes unlimited deployments and custom domains."}),e.jsx("a",{href:"https://vercel.com/signup",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Sign up at vercel.com →"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"b) Create an API token"}),e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"This lets CodeYam verify your setup and check your project configuration. Go to Account Settings → Tokens → Create."}),e.jsx("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"Open token settings →"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"c) Paste your token here"}),$.hasToken&&!$.tokenVerified&&e.jsx("p",{className:"text-[11px] text-amber-400 m-0",children:"A token was found but it didn't work. Try creating a new one and pasting it below."}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"Paste your Vercel token",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>{L.key==="Enter"&&U()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",onClick:U,disabled:x||!i.trim(),className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:x?"Verifying...":"Connect"})]}),e.jsx("p",{className:"text-[10px] text-gray-600 m-0",children:"Stored in .env.local (gitignored — never committed)"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{step:2,done:ee,active:se===2}),e.jsx("span",{className:`text-xs font-medium ${se>=2?"text-white":"text-gray-600"}`,children:"Link Project"}),ee&&$.projectName&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:$.projectName})]}),ee&&e.jsxs("div",{className:"ml-7 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[$.dashboardUrl&&e.jsx("a",{href:$.dashboardUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"Dashboard →"}),((fe=$.lastDeployment)==null?void 0:fe.url)&&e.jsxs("a",{href:$.lastDeployment.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:[$.lastDeployment.url.replace("https://","")," →"]})]}),$.lastDeployment&&!P&&e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-500",children:[e.jsxs("span",{children:["Deployed"," ",(()=>{const L=Date.now()-$.lastDeployment.createdAt,xe=Math.floor(L/6e4);if(xe<1)return"just now";if(xe<60)return`${xe}m ago`;const ie=Math.floor(xe/60);return ie<24?`${ie}h ago`:`${Math.floor(ie/24)}d ago`})()]}),e.jsx("span",{className:"text-gray-600",children:"·"}),e.jsxs("span",{className:$.lastDeployment.commitsSince>0?"text-amber-400":"text-gray-500",children:[$.lastDeployment.commitsSince," commit",$.lastDeployment.commitsSince===1?"":"s"," since"]}),e.jsx("button",{type:"button",disabled:H,onClick:()=>{v(null),z(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"deploy"})}).then(L=>L.json()).then(L=>{L.ok&&L.deployment?J({id:L.deployment.id,state:L.deployment.state||"QUEUED",url:L.deployment.url,errorMessage:null,logsUrl:null}):v(L.error||"Deployment failed")}).catch(()=>v("Failed to trigger deployment")).finally(()=>z(!1))},className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors underline",children:H?"Starting...":"Redeploy"})]}),P&&e.jsxs("div",{className:`bg-[#2a2a2a] border rounded-md px-3 py-2 space-y-1.5 ${P.state==="ERROR"?"border-red-500/40":P.state==="READY"?"border-green-500/40":"border-[#D7FF63]/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[P.state==="READY"?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):P.state==="ERROR"||P.state==="CANCELED"?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-red-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 12 12",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-[#D7FF63]/30 flex items-center justify-center animate-pulse",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#D7FF63]"})}),e.jsx("span",{className:"text-[11px] text-white font-medium",children:P.state==="READY"?"Deployed successfully":P.state==="ERROR"?"Deployment failed":P.state==="CANCELED"?"Deployment canceled":P.state==="BUILDING"?"Building...":"Deploying..."})]}),P.state==="READY"&&P.url&&e.jsxs("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors block",children:[P.url.replace("https://","")," →"]}),P.state==="ERROR"&&e.jsxs("div",{className:"space-y-1",children:[P.errorMessage&&e.jsx("pre",{className:"text-[10px] text-red-300 bg-[#1a1a1a] rounded px-2 py-1.5 m-0 whitespace-pre-wrap font-mono overflow-x-auto max-h-24 overflow-y-auto",children:P.errorMessage}),e.jsxs("div",{className:"flex items-center gap-2",children:[P.logsUrl&&e.jsx("a",{href:P.logsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"View full logs →"}),e.jsx("button",{type:"button",onClick:()=>{J(null),v(null),z(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"deploy"})}).then(L=>L.json()).then(L=>{L.ok&&L.deployment?J({id:L.deployment.id,state:L.deployment.state||"QUEUED",url:L.deployment.url,errorMessage:null,logsUrl:null}):v(L.error||"Deployment failed")}).catch(()=>v("Failed to trigger deployment")).finally(()=>z(!1))},className:"text-[10px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] rounded px-2 py-0.5 cursor-pointer transition-colors",children:"Retry"}),e.jsx("button",{type:"button",onClick:()=>pe(`## Deployment Error
|
|
97
97
|
The deployment failed with this error:
|
|
98
98
|
\`\`\`
|
|
99
99
|
${P.errorMessage||"Unknown error"}
|
|
100
100
|
\`\`\`
|
|
101
101
|
${P.logsUrl?`Full logs: ${P.logsUrl}`:""}
|
|
102
102
|
|
|
103
|
-
Help the user understand what went wrong and how to fix it. Read their project config files (package.json, next.config.ts, prisma/schema.prisma) if needed to diagnose the issue.`),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2 py-0.5 cursor-pointer transition-colors",children:"Debug with AI"})]})]})]}),$.lastDeployment===null&&!P&&e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-amber-400 m-0",children:"Not deployed yet"}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your project is linked but hasn't been deployed. Push your code to GitHub to trigger an automatic deploy, or deploy now directly."}),e.jsx("button",{type:"button",disabled:H,onClick:()=>{v(null),z(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"deploy"})}).then(L=>L.json()).then(L=>{L.ok&&L.deployment?J({id:L.deployment.id,state:L.deployment.state||"QUEUED",url:L.deployment.url,errorMessage:null,logsUrl:null}):v(L.error||"Deployment failed")}).catch(()=>v("Failed to trigger deployment")).finally(()=>z(!1))},className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:H?"Starting...":"Deploy now"})]})]}),se===2&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"A Vercel project is where your app lives once deployed. If you signed up with GitHub, Vercel can import the repo directly. Otherwise, create a new project and connect your repository."}),D?e.jsx("div",{children:e.jsx("span",{className:"text-[11px] text-gray-500",children:"Loading your Vercel projects..."})}):m&&f.length===0?e.jsx("div",{className:"space-y-2",children:G?e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"No Vercel projects found on your account."}),e.jsxs("p",{className:"text-[10px] text-gray-500 m-0",children:["Create one linked to"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:G}),"? Vercel will auto-deploy when you push."]}),e.jsx("button",{type:"button",onClick:T,disabled:A,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:A?"Creating...":"Create Vercel project"})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-400 m-0",children:"No Vercel projects found. Create one and import your repository:"}),e.jsx("a",{href:"https://vercel.com/new",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Create at vercel.com/new →"}),e.jsxs("p",{className:"text-[10px] text-gray-600 m-0",children:["Then"," ",e.jsx("button",{type:"button",onClick:()=>{C(!1),he.current=!1,g()},className:"text-[#D7FF63]/60 hover:text-[#D7FF63] bg-transparent border-none p-0 cursor-pointer text-[10px] underline",children:"re-check"})," ","to find it."]})]})}):f.length>0?e.jsxs("div",{className:"space-y-2",children:[G&&!y&&e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"No existing project matches this repo."}),e.jsxs("p",{className:"text-[10px] text-gray-500 m-0",children:["Create a new Vercel project linked to"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:G}),"? Vercel will auto-deploy when you push."]}),e.jsx("button",{type:"button",onClick:T,disabled:A,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:A?"Creating...":"Create Vercel project"})]}),f.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:y?"Select the project for this app:":"Or select an existing project:"}),e.jsx("div",{className:"space-y-1",children:f.map(L=>e.jsxs("button",{type:"button",onClick:()=>j(L.id,L.name),disabled:w,className:`w-full text-left rounded px-2.5 py-1.5 border transition-colors cursor-pointer flex items-center gap-2 ${L.id===y?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:[e.jsx("span",{className:"text-xs text-white flex-1",children:L.name}),L.framework&&e.jsx("span",{className:"text-[10px] text-gray-500",children:L.framework}),L.id===y&&e.jsx("span",{className:"text-[9px] text-[#D7FF63] bg-[#D7FF63]/10 px-1 py-px rounded",children:"matches repo"})]},L.id))})]})]}):null]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{step:3,done:me,active:se===3}),e.jsx("span",{className:`text-xs font-medium ${se>=3?"text-white":"text-gray-600"}`,children:"Environment Variables"}),se===3&&re>0&&e.jsxs("span",{className:"text-[10px] text-gray-400 ml-auto",children:[K,"/",re," on Vercel"]})]}),se===3&&$.envVarsChecked&&e.jsx("div",{className:"ml-7 space-y-1.5",children:re===0?e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Your app doesn't use any third-party services that need secrets yet. When you add services like a database or payment provider, their required keys will appear here."}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"These are the secrets your app needs to run in production. They must be added to your Vercel project so deployed builds can access them."}),e.jsx("div",{className:"space-y-1 mt-1",children:$.envVars.map(L=>e.jsxs("div",{className:"flex items-center gap-2",children:[L.configuredOnVercel?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-amber-500/30 flex items-center justify-center",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"})}),e.jsx("span",{className:"text-xs text-gray-300 font-mono flex-1 truncate",children:L.key}),e.jsx("span",{className:"text-[10px] text-gray-500",children:L.service})]},L.key))}),K<re&&e.jsxs("p",{className:"text-[10px] text-gray-500 m-0 mt-1.5 leading-relaxed",children:["Add missing variables in your"," ",e.jsx("a",{href:`https://vercel.com/~/project/${$.projectName||""}/settings/environment-variables`,target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/60 hover:text-[#D7FF63] no-underline",children:"Vercel project settings"})," ","→ Environment Variables. Then"," ",e.jsx("button",{type:"button",onClick:E,className:"text-[#D7FF63]/60 hover:text-[#D7FF63] bg-transparent border-none p-0 cursor-pointer text-[10px] underline",children:"re-check"}),"."]})]})}),se===3&&!$.envVarsChecked&&e.jsxs("div",{className:"ml-7 space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Check which secrets your app needs and whether they're configured on Vercel."}),e.jsx("button",{type:"button",onClick:E,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:"Check environment variables"})]})]}),Y&&B?e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(Y,{prompt:B,height:400,onClose:()=>{Z(null),O(null),E()}})}):e.jsx("button",{type:"button",onClick:()=>pe(),className:"text-[11px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] hover:border-[#555] rounded px-2.5 py-1.5 cursor-pointer transition-colors w-full mt-1",children:"I'm stuck — chat with AI"})]})}function sr({github:t,onSave:s,onShowChat:n}){const[a,l]=r.useState(null),[o,i]=r.useState(!0),[d,x]=r.useState(""),[b,f]=r.useState(!1),[c,y]=r.useState(!1),[M,D]=r.useState([]),[p,w]=r.useState(!1),[k,A]=r.useState(!1),[_,H]=r.useState(!1),[z,P]=r.useState(null),[J,G]=r.useState(!1),[V,S]=r.useState(null),v=r.useCallback(()=>{i(!0),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"full-status"})}).then(I=>I.json()).then(I=>{l(I),S(null)}).catch(()=>S("Failed to check status")).finally(()=>i(!1))},[]);r.useEffect(()=>{v()},[v]);const B=()=>{y(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"init-git"})}).then(I=>I.json()).then(I=>{I.ok?v():S(I.error||"Failed to initialize git")}).catch(()=>S("Failed to initialize git")).finally(()=>y(!1))},O=()=>{d.trim()&&(f(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save-token",token:d.trim()})}).then(I=>I.json()).then(I=>{I.ok?(x(""),v()):S(I.error||"Token verification failed")}).catch(()=>S("Failed to save token")).finally(()=>f(!1)))},Y=()=>{w(!0),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-repos"})}).then(I=>I.json()).then(I=>{I.ok&&(D(I.repos||[]),P(I.suggestedRepoName||null))}).catch(()=>{}).finally(()=>w(!1))},Z=()=>{A(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create-repo"})}).then(I=>I.json()).then(I=>{I.ok?(s({owner:I.repo.owner,repo:I.repo.name,repoUrl:I.repo.url}),v()):S(I.error||"Failed to create repository")}).catch(()=>S("Failed to create repository")).finally(()=>A(!1))},E=I=>{H(!0),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"link-repo",repoUrl:I.cloneUrl,owner:I.fullName.split("/")[0],repo:I.name})}).then(ee=>ee.json()).then(ee=>{ee.ok&&(s({owner:I.fullName.split("/")[0],repo:I.name,repoUrl:I.url}),v())}).catch(()=>{}).finally(()=>H(!1))},U=()=>{G(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"push"})}).then(I=>I.json()).then(I=>{I.ok?v():S(I.error||"Push failed")}).catch(()=>S("Push failed")).finally(()=>G(!1))},m=a||{gitInitialized:!1,hasGitignore:!1,hasRemote:!1,isGitHub:!1,ghCliInstalled:!1,ghCliAuthenticated:!1,hasToken:!1,tokenVerified:!1,user:null,githubRepo:null,hasCommits:!1,pushed:!1},C=m.gitInitialized,g=m.ghCliAuthenticated||m.tokenVerified,T=m.hasRemote&&m.isGitHub,j=C?g?3:2:1,$=r.useRef(!1);return r.useEffect(()=>{j===3&&!T&&!$.current&&M.length===0&&!p&&($.current=!0,Y())},[j,T]),o&&!a?e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsx("span",{className:"text-xs text-gray-500",children:"Checking GitHub setup..."})}):e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333] space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"GitHub Setup"}),e.jsx("p",{className:"text-[11px] text-gray-400 m-0 leading-relaxed",children:"GitHub stores your code and tracks changes. Push your code to a repository so it’s backed up, versioned, and ready for collaboration or deployment."})]}),V&&e.jsx("div",{className:"text-[11px] text-red-400 bg-red-400/10 rounded px-2 py-1.5",children:V}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{step:1,done:C,active:j===1}),e.jsx("span",{className:"text-xs font-medium text-white",children:"Initialize Git"}),C&&m.hasGitignore&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:"ready"})]}),j===1&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:["Git tracks every change to your code so you can undo mistakes, see history, and collaborate. This initializes a local git repository and creates a ",e.jsx("code",{children:".gitignore"})," file to keep sensitive files out of version control."]}),e.jsx("button",{type:"button",onClick:B,disabled:c,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:c?"Initializing...":"Initialize Git"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{step:2,done:g,active:j===2}),e.jsx("span",{className:`text-xs font-medium ${j>=2?"text-white":"text-gray-600"}`,children:"Connect to GitHub"}),g&&m.user&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:m.user.username})]}),j===2&&e.jsxs("div",{className:"ml-7 space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:["a) Install & authenticate with GitHub CLI",m.ghCliInstalled&&!m.ghCliAuthenticated&&e.jsx("span",{className:"text-[10px] text-green-400 ml-1.5",children:"(installed)"})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:["The GitHub CLI (",e.jsx("code",{children:"gh"}),") is the easiest way to authenticate. Install it, then run ",e.jsx("code",{children:"gh auth login"})," in your terminal."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!m.ghCliInstalled&&e.jsx("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Install GitHub CLI →"}),e.jsx("button",{type:"button",onClick:v,disabled:o,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:o?"Checking...":"Check Authentication"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"b) Or paste a Personal Access Token"}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:["Create a token with ",e.jsx("strong",{children:"repo"})," scope. This is stored in .env.local (never committed)."]}),e.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=CodeYam",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"Create token on GitHub →"}),m.hasToken&&!m.tokenVerified&&e.jsx("p",{className:"text-[11px] text-amber-400 m-0",children:"A token was found but it didn't work. Try creating a new one."}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"Paste your GitHub token",value:d,onChange:I=>x(I.target.value),onKeyDown:I=>{I.key==="Enter"&&O()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",onClick:O,disabled:b||!d.trim(),className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:b?"Verifying...":"Connect"})]}),e.jsx("p",{className:"text-[10px] text-gray-600 m-0",children:"Stored in .env.local (gitignored — never committed)"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{step:3,done:T,active:j===3}),e.jsx("span",{className:`text-xs font-medium ${j>=3?"text-white":"text-gray-600"}`,children:"Create or Link Repository"}),T&&m.githubRepo&&e.jsxs("span",{className:"text-[10px] text-gray-400 ml-auto",children:[m.githubRepo.owner,"/",m.githubRepo.repo]})]}),j===3&&T&&m.githubRepo&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-gray-400 m-0 leading-relaxed",children:["Connected to"," ",e.jsxs("a",{href:`https://github.com/${m.githubRepo.owner}/${m.githubRepo.repo}`,target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:[m.githubRepo.owner,"/",m.githubRepo.repo]})]}),m.hasCommits&&!m.pushed&&e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"Push your code to GitHub"}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"Your local commits haven't been pushed yet. Push now to back up your code and make it available on GitHub."}),e.jsx("button",{type:"button",onClick:U,disabled:J,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:J?"Pushing...":"Push to GitHub"})]}),m.pushed&&e.jsx("p",{className:"text-[10px] text-green-400 m-0",children:"Code is pushed and up to date."})]}),j===3&&!T&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Create a new GitHub repository for this project or link to an existing one."}),e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"Create a new private repository"}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"Creates a repository on GitHub and sets it as the remote for this project."}),e.jsx("button",{type:"button",onClick:Z,disabled:k,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:k?"Creating...":"Create repository"})]}),M.length===0&&p&&e.jsx("span",{className:"text-[11px] text-gray-500",children:"Loading your repositories..."}),M.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"Or link an existing repository:"}),e.jsx("div",{className:"space-y-1",children:M.map(I=>e.jsxs("button",{type:"button",onClick:()=>E(I),disabled:_,className:`w-full text-left rounded px-2.5 py-1.5 border transition-colors cursor-pointer flex items-center gap-2 ${I.name===z?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:[e.jsx("span",{className:"text-xs text-white flex-1",children:I.fullName}),I.private&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"private"}),I.name===z&&e.jsx("span",{className:"text-[9px] text-[#D7FF63] bg-[#D7FF63]/10 px-1 py-px rounded",children:"matches project"})]},I.fullName))})]})]})]}),n&&e.jsx("button",{type:"button",onClick:n,className:"text-[11px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] hover:border-[#555] rounded px-2.5 py-1.5 cursor-pointer transition-colors w-full mt-1",children:"Need help? Ask Claude about GitHub setup"})]})}function rr({hosting:t,onSave:s,onEditNavigate:n,defaultEditing:a=!1,onShowChat:l}){const o=(t==null?void 0:t.provider)||null,[i,d]=r.useState(a&&!o),x=b=>{s({provider:b}),d(!1)};if(o==="vercel")return e.jsx(Ha,{hosting:t,onSave:s});if(!i&&o){const b=tr.find(f=>f.id===o);return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Hosting"}),b?e.jsx("div",{className:"flex items-center gap-2 bg-[#2a2a2a] border border-[#D7FF63]/40 rounded-md px-3 py-2",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:b.name}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:b.description})]})}):e.jsx("div",{className:"text-xs text-gray-400",children:o}),e.jsx("button",{type:"button",onClick:n??(()=>d(!0)),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"Change >"})]})}return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Choose a hosting provider"}),e.jsx("div",{className:"space-y-2",children:tr.map(b=>e.jsxs("button",{type:"button",onClick:()=>x(b.id),className:`w-full text-left rounded-md px-3 py-2.5 border transition-colors cursor-pointer ${o===b.id?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:[e.jsx("div",{className:"text-sm font-medium text-white",children:b.name}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:b.description}),e.jsx("div",{className:"flex gap-1.5 mt-1.5",children:b.services.map(f=>e.jsx("span",{className:"text-[10px] text-gray-300 bg-[#333] px-1.5 py-0.5 rounded",children:f},f))})]},b.id))}),o&&e.jsx("button",{type:"button",onClick:()=>d(!1),className:"text-[11px] text-gray-400 hover:text-white bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors",children:"Cancel"})]})}const nr=[{id:"supabase",name:"Supabase",services:["PostgreSQL","Auth","Storage","Realtime"],description:"Open-source Firebase alternative"},{id:"neon",name:"Neon",services:["PostgreSQL"],description:"Serverless Postgres",disabled:!0},{id:"planetscale",name:"PlanetScale",services:["MySQL"],description:"Serverless MySQL",disabled:!0}];function Ua({database:t,onSave:s}){const[n,a]=r.useState(null),[l,o]=r.useState(!0),[i,d]=r.useState(""),[x,b]=r.useState(!1),[f,c]=r.useState([]),[y,M]=r.useState(null),[D,p]=r.useState(!1),[w,k]=r.useState(!1),[A,_]=r.useState(!1),[H,z]=r.useState(""),[P,J]=r.useState(!1),[G,V]=r.useState(!1),[S,v]=r.useState(null),[B,O]=r.useState(null),Y=r.useCallback(()=>{o(!0),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"full-status"})}).then(j=>j.json()).then(j=>{a(j),O(null)}).catch(()=>O("Failed to check status")).finally(()=>o(!1))},[]);r.useEffect(()=>{Y()},[Y]);const Z=()=>{i.trim()&&(b(!0),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save-token",token:i.trim()})}).then(j=>j.json()).then(j=>{j.ok?(d(""),Y()):O(j.error||"Token verification failed")}).catch(()=>O("Failed to save token")).finally(()=>b(!1)))},E=r.useCallback(()=>{p(!0),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-projects"})}).then(j=>j.json()).then(j=>{j.ok?(c(j.projects||[]),M(j.suggestedProjectId||null),k(!0)):O(j.error||"Failed to load projects")}).catch(()=>O("Failed to load projects")).finally(()=>p(!1))},[]);r.useEffect(()=>{n!=null&&n.tokenVerified&&!(n!=null&&n.projectLinked)&&!w&&E()},[n==null?void 0:n.tokenVerified,n==null?void 0:n.projectLinked,w,E]);const U=j=>{const $=f.find(I=>I.id===j);_(!0),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"link-project",projectId:j,projectName:$==null?void 0:$.name})}).then(I=>I.json()).then(I=>{I.ok?Y():O(I.error||"Failed to link project")}).catch(()=>O("Failed to link project")).finally(()=>_(!1))},m=()=>{H.trim()&&(J(!0),O(null),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addEnvironmentVariable:{key:"DATABASE_URL",value:H.trim()}})}).then(j=>j.json()).then(j=>{j.success?(z(""),Y()):O(j.error||"Failed to save DATABASE_URL")}).catch(()=>O("Failed to save DATABASE_URL")).finally(()=>J(!1)))},C=()=>{V(!0),v(null),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify-connection"})}).then(j=>j.json()).then(j=>{j.ok&&j.connected?v(!0):(v(!1),O(j.error||"Connection test failed"))}).catch(()=>{v(!1),O("Failed to test connection")}).finally(()=>V(!1))};if(l&&!n)return e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsx("span",{className:"text-[11px] text-gray-500",children:"Checking Supabase status..."})});const g=n||{tokenVerified:!1,projectLinked:!1,projectName:null,projectRef:null,dashboardUrl:null,envVarsConfigured:!1,envVars:[],currentDbProvider:null,migrationNeeded:!1};let T=1;return g.tokenVerified&&g.projectLinked&&g.envVarsConfigured?T=(g.migrationNeeded,4):g.tokenVerified&&g.projectLinked?T=3:g.tokenVerified&&(T=2),e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333] space-y-3",children:[T===1&&!g.tokenVerified&&e.jsxs("div",{className:"bg-[#1a1a1a] rounded-md px-3 py-2.5 border border-[#333]",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 leading-relaxed",children:"Supabase gives you a hosted PostgreSQL database with built-in auth, storage, and realtime. The free tier includes 2 projects with 500MB of database storage."}),e.jsxs("p",{className:"text-[10px] text-gray-500 m-0 mt-1.5 leading-relaxed",children:["If you don't have an account yet, sign up at"," ",e.jsx("a",{href:"https://supabase.com/dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"supabase.com"})," ","(GitHub sign-in is fastest), then come back here to connect."]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ne,{step:1,done:g.tokenVerified,active:T===1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Connect your Supabase account"}),g.tokenVerified?e.jsx("p",{className:"text-[10px] text-green-400 m-0 mt-0.5",children:"Connected"}):e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.jsxs("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:["We need a"," ",e.jsx("span",{className:"text-gray-400",children:"personal access token"})," ","(not a project API key) to list your projects and fetch credentials automatically."]}),e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-1",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["1. Go to"," ",e.jsx("a",{href:"https://supabase.com/dashboard/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Account → Access Tokens"})]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["2. Click"," ",e.jsx("span",{className:"text-gray-300",children:'"Generate new token"'}),', name it anything (e.g. "CodeYam")']}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["3. Copy the token (starts with"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:"sbp_"}),") and paste it below"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"sbp_...",value:i,onChange:j=>d(j.target.value),onKeyDown:j=>{j.key==="Enter"&&Z()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",disabled:x||!i.trim(),onClick:Z,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:x?"Verifying...":"Connect"})]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ne,{step:2,done:g.projectLinked,active:T===2}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Select a Supabase project"}),g.projectLinked?e.jsx("div",{className:"mt-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-gray-300",children:g.projectName||g.projectRef}),g.dashboardUrl&&e.jsx("a",{href:g.dashboardUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/60 hover:text-[#D7FF63] no-underline",children:"dashboard →"})]})}):T>=2?e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Each Supabase project is an isolated PostgreSQL database. Select the project for this app, or create a new one first."}),D?e.jsx("span",{className:"text-[11px] text-gray-500",children:"Loading your Supabase projects..."}):f.length>0?e.jsxs("div",{className:"space-y-1",children:[f.map(j=>e.jsx("button",{type:"button",disabled:A,onClick:()=>U(j.id),className:`w-full text-left rounded-md px-2.5 py-1.5 border transition-colors cursor-pointer ${j.id===y?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-white font-medium",children:j.name}),e.jsx("span",{className:"text-[10px] text-gray-500",children:j.region}),j.id===y&&e.jsx("span",{className:"text-[10px] text-[#D7FF63] ml-auto",children:"suggested"})]})},j.id)),e.jsxs("p",{className:"text-[10px] text-gray-600 m-0 mt-1",children:["Don't see the right project?"," ",e.jsx("a",{href:"https://supabase.com/dashboard/projects",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Open your dashboard"})," ",`and click "New project" (you'll pick an organization first), then`," ",e.jsx("button",{type:"button",onClick:E,className:"text-[#D7FF63]/70 hover:text-[#D7FF63] bg-transparent border-none p-0 cursor-pointer transition-colors underline",children:"refresh this list"}),"."]})]}):w?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"No projects found on your Supabase account."}),e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-1",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["1. Open your"," ",e.jsx("a",{href:"https://supabase.com/dashboard/projects",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Supabase dashboard"})," ","and click"," ",e.jsx("span",{className:"text-gray-300",children:'"New project"'})]}),e.jsx("p",{className:"text-[10px] text-gray-400 m-0",children:"2. Select an organization (or create one — this is just a billing group for your projects)"}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["3. Pick a name, set a"," ",e.jsx("span",{className:"text-gray-300",children:"database password"})," ","(save this — you'll need it for the connection string), and choose a region"]}),e.jsx("p",{className:"text-[10px] text-gray-400 m-0",children:"4. Wait for the project to finish provisioning (~2 min), then come back and refresh"})]}),e.jsx("button",{type:"button",onClick:E,className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors",children:"Refresh project list"})]}):null]}):e.jsx("p",{className:"text-[10px] text-gray-500 m-0 mt-0.5",children:"Connect your account first"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ne,{step:3,done:g.envVarsConfigured,active:T===3}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Configure database connection"}),g.envVarsConfigured?e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsx("p",{className:"text-[10px] text-green-400 m-0",children:"All credentials configured"}),S===!0&&e.jsx("p",{className:"text-[10px] text-green-400 m-0",children:"Connection verified"}),S===!1&&e.jsx("p",{className:"text-[10px] text-red-300 m-0",children:"Connection test failed — check your credentials"}),e.jsx("button",{type:"button",disabled:G,onClick:C,className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors underline",children:G?"Testing...":S===!0?"Test again":"Test connection"})]}):T>=3?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your Supabase URL and anon key were auto-filled when you linked the project. You still need to add the database connection string (which includes your database password)."}),e.jsx("div",{className:"space-y-1",children:g.envVars.map(j=>e.jsxs("div",{className:"flex items-center gap-2",children:[j.configured?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-amber-500/30 flex items-center justify-center",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"})}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:j.key}),j.configured&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"configured"})]},j.key))}),g.envVars.some(j=>j.key==="DATABASE_URL"&&!j.configured)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-1",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["1. Open"," ",g.projectRef?e.jsx("a",{href:`https://supabase.com/dashboard/project/${g.projectRef}/database/settings?showConnect=true`,target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Database Settings → Connect"}):e.jsx("span",{className:"text-gray-300",children:"Database Settings → Connect"})]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["2. Select"," ",e.jsx("span",{className:"text-gray-300",children:'"Session pooler"'})," ","mode (port 5432) — this gives the best performance for CodeYam's scenario data seeding"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["3. Copy the ",e.jsx("span",{className:"text-gray-300",children:"URI"})," ","connection string and replace"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:"[YOUR-PASSWORD]"})," ","with the database password you set when creating the project"]})]}),e.jsxs("p",{className:"text-[10px] text-gray-600 m-0",children:["Forgot your password? Reset it in"," ",g.projectRef?e.jsx("a",{href:`https://supabase.com/dashboard/project/${g.projectRef}/database/settings`,target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-400 no-underline",children:"Database Settings"}):"Database Settings"," ",'under "Database password".']}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"postgresql://postgres.xxxxx:password@aws-0-region.pooler.supabase.com:5432/postgres",value:H,onChange:j=>z(j.target.value),onKeyDown:j=>{j.key==="Enter"&&m()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",disabled:P||!H.trim(),onClick:m,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:P?"Saving...":"Save"})]})]})]}):e.jsx("p",{className:"text-[10px] text-gray-500 m-0 mt-0.5",children:"Link a project first"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ne,{step:4,done:!g.migrationNeeded,active:T===4&&g.migrationNeeded}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Migrate to PostgreSQL"}),g.migrationNeeded?T===4?e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your project currently uses SQLite for local development. To use your Supabase database, Claude needs to update several files:"}),e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-0.5",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:"prisma/schema.prisma"})," ","— switch provider from sqlite to postgresql"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:"app/lib/prisma.ts"})," ","— swap the database adapter"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:"package.json"})," ","— replace sqlite packages with pg + supabase-js"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:".codeyam/seed-adapter.ts"})," ","— switch to Supabase seed adapter"]})]}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your Prisma models and app code stay the same — only the database connection layer changes. After migration, use the Live Preview to verify everything loads correctly."}),e.jsxs("div",{className:"bg-[#D7FF63]/5 border border-[#D7FF63]/20 rounded px-2.5 py-2",children:[e.jsxs("p",{className:"text-[10px] text-[#D7FF63]/90 m-0 leading-relaxed",children:["Ask Claude in the chat:"," ",e.jsx("span",{className:"font-medium",children:'"Migrate my project from SQLite to Supabase"'})]}),e.jsx("p",{className:"text-[10px] text-[#D7FF63]/60 m-0 mt-0.5",children:"Claude will make the changes, run npm install, push the schema to Supabase, and help you verify it works."})]})]}):e.jsx("p",{className:"text-[10px] text-gray-500 m-0 mt-0.5",children:"Configure credentials first"}):e.jsx("p",{className:"text-[10px] text-green-400 m-0 mt-0.5",children:g.currentDbProvider==="postgresql"?"Already using PostgreSQL":"No migration needed"})]})]}),B&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded px-2.5 py-1.5",children:e.jsx("p",{className:"text-[10px] text-red-300 m-0",children:B})})]})}function ar({database:t,onSave:s,onEditNavigate:n,defaultEditing:a=!1}){const l=(t==null?void 0:t.provider)||null,[o,i]=r.useState(a&&!l),d=x=>{s({provider:x}),i(!1)};if(l==="supabase")return e.jsx(Ua,{database:t,onSave:s});if(!o&&l){const x=nr.find(b=>b.id===l);return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Database"}),x?e.jsx("div",{className:"flex items-center gap-2 bg-[#2a2a2a] border border-[#D7FF63]/40 rounded-md px-3 py-2",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:x.name}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:x.description})]})}):e.jsx("div",{className:"text-xs text-gray-400",children:l}),e.jsx("button",{type:"button",onClick:n??(()=>i(!0)),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"Change >"})]})}return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Choose a database provider"}),e.jsx("div",{className:"space-y-2",children:nr.map(x=>e.jsxs("button",{type:"button",disabled:x.disabled,onClick:()=>d(x.id),className:`w-full text-left rounded-md px-3 py-2.5 border transition-colors ${x.disabled?"bg-[#2a2a2a] border-[#333] opacity-40 cursor-not-allowed":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555] cursor-pointer"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:x.name}),x.disabled&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"coming soon"})]}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:x.description}),e.jsx("div",{className:"flex gap-1.5 mt-1.5",children:x.services.map(b=>e.jsx("span",{className:"text-[10px] text-gray-300 bg-[#333] px-1.5 py-0.5 rounded",children:b},b))})]},x.id))}),l&&e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-[11px] text-gray-400 hover:text-white bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors",children:"Cancel"})]})}function or({serviceName:t,serviceUrl:s,envKeys:n,environmentVariables:a,onSaveEnvVar:l,onEditNavigate:o,defaultEditing:i=!1}){const[d,x]=r.useState(i),[b,f]=r.useState({}),c=r.useMemo(()=>{const p=new Set;for(const w of a){const k=w.key||w.name;k&&w.value&&p.add(k)}return p},[a]),y=n.filter(p=>c.has(p)).length,M=y===n.length,D=p=>{const w=b[p];w!==void 0&&w!==""&&(l(p,w),f(k=>{const A={...k};return delete A[p],A}))};return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Credentials"}),s&&e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/60 hover:text-[#D7FF63] no-underline",children:"docs →"})]}),e.jsx("div",{className:"space-y-1.5",children:n.map(p=>{const w=c.has(p),k=b[p]!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[w?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-amber-500/30 flex items-center justify-center",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"})}),e.jsx("span",{className:"text-xs text-gray-300 font-mono flex-1 truncate",children:p}),w&&!k?e.jsx("span",{className:"text-[10px] text-gray-500",children:"configured"}):d||k?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",placeholder:"value",value:b[p]||"",onChange:A=>f(_=>({..._,[p]:A.target.value})),onKeyDown:A=>{A.key==="Enter"&&D(p)},className:"bg-[#1a1a1a] border border-[#444] rounded px-1.5 py-0.5 text-xs text-white w-32 outline-none focus:border-[#D7FF63]/50"}),e.jsx("button",{type:"button",onClick:()=>D(p),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none cursor-pointer p-0 transition-colors",children:"Save"})]}):e.jsx("button",{type:"button",onClick:()=>f(A=>({...A,[p]:""})),className:"text-[10px] text-amber-400 hover:text-amber-300 bg-transparent border-none cursor-pointer p-0 transition-colors",children:"add"})]},p)})}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:M?"All keys configured":`${y} of ${n.length} keys configured`}),!d&&!M&&e.jsx("button",{type:"button",onClick:o??(()=>x(!0)),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none cursor-pointer p-0 transition-colors",children:"Configure all >"})]})]})}function za({onBack:t,onSwitchToBuild:s,onSwitchToHistory:n,onNavigateToDesignSystem:a,onNavigateToTechStack:l,expandedTasks:o,onExpandedTasksChange:i,buildIdle:d=!1,onScreenshotClick:x,onZoomChange:b}){const{revalidate:f}=pn(),[c,y]=r.useState(null),[M,D]=r.useState(!1),[p,w]=r.useState(null),k=r.useCallback(()=>{fetch("/api/editor-roadmap").then(N=>N.json()).then(N=>y(N)).catch(()=>{})},[]);r.useEffect(()=>{k()},[k]);const A=(c==null?void 0:c.plan.some(N=>N.id==="plan-design-system"&&N.completed))??!1;r.useEffect(()=>{if(!A){w(null);return}fetch("/api/editor-design-system").then(N=>N.json()).then(N=>{N.exists&&N.content?w(Qt(N.content)):w(null)}).catch(()=>w(null))},[A]);const _=r.useCallback(N=>{D(!0),fetch("/api/editor-roadmap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}).then(Q=>Q.json()).then(()=>k()).catch(()=>{}).finally(()=>D(!1))},[k]),H=r.useCallback((N,Q)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectTitle:N,projectDescription:Q})}).then(()=>k()).catch(()=>{})},[k]),z=r.useCallback((N,Q)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({screenSizes:N,projectScreenSizes:Q})}).then(()=>{k(),f()}).catch(()=>{})},[k,f]),P=r.useCallback(N=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hosting:N})}).then(()=>k()).catch(()=>{})},[k]),J=r.useCallback(N=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({database:N})}).then(()=>k()).catch(()=>{})},[k]),G=r.useCallback(N=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({github:N})}).then(()=>k()).catch(()=>{})},[k]),V=r.useCallback((N,Q)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addEnvironmentVariable:{key:N,value:Q}})}).then(()=>k()).catch(()=>{})},[k]),S=r.useCallback((N,Q)=>{if(!c)return;const h=c[N].filter(R=>R.id!==Q);y({...c,[N]:h}),_({[N]:h})},[c,_]),[v,B]=r.useState(null),[O,Y]=r.useState(()=>new Set),[Z,E]=r.useState(()=>new Set),[U,m]=r.useState(()=>new Set),C=r.useCallback(N=>{m(Q=>{const h=new Set(Q);return h.has(N)?h.delete(N):h.add(N),h})},[]),[g,T]=r.useState(()=>new Set),[j,$]=r.useState(!1),[I,ee]=r.useState(null),K=r.useRef(null),re=r.useRef(null),me=r.useRef(0),se=r.useCallback(N=>{Y(Q=>{const h=new Set(Q);return h.has(N)?h.delete(N):h.add(N),h})},[]),pe=r.useCallback(N=>{T(Q=>{const h=new Set(Q);return h.has(N)?h.delete(N):h.add(N),h})},[]);r.useEffect(()=>{if(!j||typeof document>"u")return;const N=Q=>{K.current&&!K.current.contains(Q.target)&&($(!1),ee(null))};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[j]);const he=[{key:"plan",label:"Setup"},{key:"build",label:"Build"},{key:"deploy",label:"Deploy"},{key:"gtm",label:"Go To Market"}],ge=r.useCallback(N=>{const Q=new Set(o);Q.has(N)?Q.delete(N):Q.add(N),i(Q)},[o,i]),L=r.useCallback(N=>{re.current&&(me.current=re.current.scrollTop),B(N)},[]),xe=r.useCallback(()=>{B(null),requestAnimationFrame(()=>{re.current&&(re.current.scrollTop=me.current)})},[]);if(!c)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsx("span",{className:"text-sm text-gray-500",children:"Loading roadmap..."})});const ie=c.plan.filter(N=>N.completed).length,de=c.deploy.filter(N=>N.completed).length,ne=v&&([...c.plan,...c.deploy].find(N=>N.id===v)??null);if(ne){const N=ne.id==="plan-project-name"&&ne.completed?e.jsx(Xs,{projectTitle:c.projectTitle,projectDescription:c.projectDescription,onSave:H,defaultEditing:!0}):ne.id==="plan-screen-sizes"&&ne.completed?e.jsx(er,{screenSizes:c.screenSizes,projectScreenSizes:c.projectScreenSizes,defaultScreenSize:c.defaultScreenSize,appFormats:c.appFormats,onSave:z,defaultEditing:!0}):ne.id==="plan-github"?e.jsx(sr,{github:c.github,onSave:G}):ne.id==="deploy-hosting"?e.jsx(rr,{hosting:c.hosting,onSave:P,defaultEditing:!0}):ne.id==="deploy-database"?e.jsx(ar,{database:c.database,onSave:J,defaultEditing:!0}):ne.serviceRef&&c.techStack?(()=>{var R;const Q=c.techStack[ne.serviceRef.category],h=Q==null?void 0:Q.find(q=>q.name===ne.serviceRef.name);return(R=h==null?void 0:h.envKeys)!=null&&R.length?e.jsx(or,{serviceName:h.name,serviceUrl:h.url,envKeys:h.envKeys,environmentVariables:c.environmentVariables,onSaveEnvVar:V,defaultEditing:!0}):null})():null;return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:xe,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("h2",{className:"text-lg font-medium text-white mt-0 mb-0",children:ne.label}),ne.completed&&e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-green-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]}),N?e.jsx("div",{children:N}):e.jsx("p",{className:"text-sm text-gray-500",children:ne.completed?"This task has been completed.":"This task has not been started yet."}),M&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}return e.jsx("div",{ref:re,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-5",children:[e.jsx("div",{className:"flex items-center px-0 -mx-4 bg-[#161616] border-b border-[#2d2d2d]",style:{marginTop:"-1rem",paddingLeft:"1rem",paddingRight:"1rem",paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Home"]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx("h2",{className:"text-xl font-medium text-white m-0",children:"Roadmap"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",ref:K,children:[e.jsx("button",{type:"button",onClick:()=>{$(!j),ee(null)},className:"p-1 text-gray-500 hover:text-white bg-transparent border-none cursor-pointer transition-colors",title:"Options",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"5",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}),j&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 flex items-start gap-0",children:[I&&e.jsx("div",{className:"bg-[#2d2d2d] border border-[#3d3d3d] rounded-lg shadow-lg py-1 min-w-[150px]",children:(I==="hide"?he.filter(N=>!g.has(N.key)):he.filter(N=>g.has(N.key))).map(N=>e.jsx("button",{type:"button",onClick:()=>{pe(N.key),$(!1),ee(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-300 hover:text-white hover:bg-[#3d3d3d] bg-transparent border-none cursor-pointer transition-colors",children:N.label},N.key))}),e.jsxs("div",{className:"bg-[#2d2d2d] border border-[#3d3d3d] rounded-lg shadow-lg py-1 min-w-[130px]",children:[he.some(N=>!g.has(N.key))&&e.jsxs("button",{type:"button",onMouseEnter:()=>ee("hide"),className:"w-full flex items-center justify-between px-4 py-2 text-sm text-gray-300 hover:text-white hover:bg-[#3d3d3d] bg-transparent border-none cursor-pointer transition-colors",children:["Hide",e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})})]}),g.size>0&&e.jsxs("button",{type:"button",onMouseEnter:()=>ee("show"),className:"w-full flex items-center justify-between px-4 py-2 text-sm text-gray-300 hover:text-white hover:bg-[#3d3d3d] bg-transparent border-none cursor-pointer transition-colors",children:["Show",e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})})]})]})]})]})]}),!g.has("plan")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(bt,{title:"Setup",completedCount:ie,totalCount:c.plan.length,collapsed:O.has("plan"),onToggleCollapse:()=>se("plan")}),!O.has("plan")&&c.plan.map(N=>e.jsxs(Qs,{todo:N,expanded:o.has(N.id),onToggle:()=>ge(N.id),onRemove:N.userCreated?()=>S("plan",N.id):void 0,children:[N.id==="plan-project-name"&&N.completed&&e.jsx(Xs,{projectTitle:c.projectTitle,projectDescription:c.projectDescription,onSave:H,onEditNavigate:()=>L(N.id)}),N.id==="plan-tech-stack"&&e.jsx(Ba,{techStack:c.techStack,onNavigate:l}),N.id==="plan-design-system"&&N.completed&&p&&e.jsx(_a,{designSystem:p,onEdit:a}),N.id==="plan-screen-sizes"&&N.completed&&e.jsx(er,{screenSizes:c.screenSizes,projectScreenSizes:c.projectScreenSizes,defaultScreenSize:c.defaultScreenSize,appFormats:c.appFormats,onSave:z,onEditNavigate:()=>L(N.id)}),N.id==="plan-github"&&e.jsx(sr,{github:c.github,onSave:G})]},N.id))]}),!g.has("build")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(bt,{title:"Build",subtitle:c.editorStep!=null&&c.editorStep<18?"Building...":void 0,subtitleAccent:c.editorStep!=null&&c.editorStep<18,collapsed:O.has("build"),onToggleCollapse:()=>se("build"),subtitleLink:c.editorStep==null||c.editorStep>=18?{label:"Start New Feature",onClick:s}:void 0}),!O.has("build")&&e.jsxs(e.Fragment,{children:[c.editorStep!=null&&c.editorStep>=18?e.jsx("div",{className:"mx-3 mb-2",children:e.jsxs("button",{type:"button",onClick:s,className:"w-full flex items-center gap-2 py-3 px-4 bg-[#2a2a2a] rounded-lg border-none cursor-pointer text-left group hover:bg-[#303030] transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("span",{className:"text-sm text-white group-hover:text-white transition-colors truncate flex-1 font-medium",children:c.featureName||"New Feature"}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded uppercase tracking-wider shrink-0 font-['IBM_Plex_Mono'] bg-[#5ce0d2]/20 text-[#5ce0d2]",children:"New"}),e.jsx("span",{className:"text-[10px] text-gray-500 shrink-0 uppercase font-['IBM_Plex_Mono']",children:"Just now"}),e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-green-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]})}):c.editorStep!=null?e.jsx("div",{className:"mx-3 mb-2",children:e.jsxs("button",{type:"button",onClick:s,className:"w-full flex flex-col gap-2 py-3 px-4 bg-[#1a3a3a] border border-[#2a5a5a] rounded-lg cursor-pointer text-left hover:bg-[#1e4242] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[d?e.jsx("span",{className:"w-3 h-3 rounded-full bg-[#FF8B43] shrink-0"}):e.jsx(wt,{color:"#5ce0d2",dotSize:3}),e.jsx("span",{className:"text-sm text-white font-medium",children:c.featureName||"New Feature"}),d&&e.jsx("span",{className:"text-xs text-[#FF8B43] underline cursor-pointer hover:text-[#FF8B43]/70",onClick:N=>{N.stopPropagation(),s()},children:"Go to build"}),e.jsx("span",{className:"flex-1"}),c.editorStep!=null&&c.editorStepLabel&&e.jsxs("span",{className:"text-xs font-['IBM_Plex_Mono'] text-[#5ce0d2] tracking-wider shrink-0",children:[c.editorStepLabel.toUpperCase()," (",c.editorStep,"/18)"]})]}),c.editorStep!=null&&e.jsx("div",{className:"flex items-center gap-2 w-full",children:e.jsx("div",{className:"flex-1 h-[6px] bg-[#0d2626] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#5ce0d2] to-[#5ce0d2] rounded-full transition-all",style:{width:`${c.editorStep/18*100}%`}})})})]})}):null,c.recentEntries.map(N=>{const Q=Z.has(N.time);return e.jsxs("div",{className:"mx-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 bg-[#2a2a2a] rounded-lg cursor-pointer hover:bg-[#303030] transition-colors",onClick:()=>{E(h=>{const R=new Set(h);return R.has(N.time)?R.delete(N.time):R.add(N.time),R})},children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-gray-500 transition-transform ${Q?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("span",{className:"text-sm text-gray-300 truncate flex-1",children:N.title}),e.jsx("span",{className:`${Ma[N.type]||$a} text-[10px] font-bold px-2.5 py-0.5 rounded-full border uppercase tracking-wider shrink-0 font-['IBM_Plex_Mono']`,children:N.type}),e.jsx("span",{className:"text-[10px] text-gray-500 shrink-0 uppercase font-['IBM_Plex_Mono']",children:Oa(N.time)}),e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-green-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]}),Q&&e.jsx("div",{className:"mt-1 bg-[#222] rounded-lg",children:e.jsx(Ra,{entry:N,expandedSections:U,onToggleSection:C,onScreenshotClick:x,onZoomChange:b})})]},N.time)}),!c.featureName&&c.buildSessionCount===0&&e.jsx("div",{className:"mx-3 mb-2 py-3 px-4 bg-[#2a2a2a] rounded-lg",children:e.jsx("p",{className:"text-xs text-gray-500 m-0",children:"No sessions yet."})}),e.jsxs("div",{className:"mx-3 mb-2 flex items-center gap-2 px-4 py-2.5 bg-[#2a2a2a] rounded-lg",children:[e.jsx("input",{type:"text",placeholder:"Plan next feature",className:"flex-1 text-sm bg-transparent border-none text-gray-300 placeholder-gray-600 outline-none",onKeyDown:N=>{N.key==="Enter"&&N.currentTarget.value.trim()&&s()}}),e.jsx("button",{type:"button",onClick:s,className:"text-[10px] font-bold text-black bg-[#D7FF63] hover:bg-[#c5ee52] px-2.5 py-1 rounded cursor-pointer transition-colors font-['IBM_Plex_Mono'] tracking-wider",children:"ADD"})]})]})]}),!g.has("deploy")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(bt,{title:"Deploy",completedCount:de,totalCount:c.deploy.length>0?c.deploy.length:void 0,collapsed:O.has("deploy"),onToggleCollapse:()=>se("deploy")}),!O.has("deploy")&&(c.deploy.length>0?c.deploy.map(N=>e.jsx(Qs,{todo:N,expanded:o.has(N.id),onToggle:()=>ge(N.id),onRemove:N.userCreated?()=>S("deploy",N.id):void 0,children:N.id==="deploy-hosting"?e.jsx(rr,{hosting:c.hosting,onSave:P,onEditNavigate:()=>L(N.id)}):N.id==="deploy-database"?e.jsx(ar,{database:c.database,onSave:J,onEditNavigate:()=>L(N.id)}):N.serviceRef&&c.techStack?(()=>{var R;const Q=c.techStack[N.serviceRef.category],h=Q==null?void 0:Q.find(q=>q.name===N.serviceRef.name);return(R=h==null?void 0:h.envKeys)!=null&&R.length?e.jsx(or,{serviceName:h.name,serviceUrl:h.url,envKeys:h.envKeys,environmentVariables:c.environmentVariables,onSaveEnvVar:V,onEditNavigate:()=>L(N.id)}):e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-1 mb-2",children:N.completed?"Completed":"Not started yet"})})():e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-1 mb-2",children:N.completed?"Completed":"Not started yet"})},N.id)):e.jsx("div",{className:"mx-3 mb-2 py-3 px-4 bg-[#2a2a2a] rounded-lg",children:e.jsx("span",{className:"text-sm text-gray-500",children:"-"})}))]}),!g.has("gtm")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(bt,{title:"Go To Market",collapsed:O.has("gtm"),onToggleCollapse:()=>se("gtm")}),!O.has("gtm")&&e.jsx(e.Fragment,{children:["Blog Post","Demo","One Liner"].map(N=>e.jsx("div",{className:"mx-3 mb-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 bg-[#2a2a2a] rounded-lg",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("span",{className:"text-sm text-gray-500 flex-1",children:N})]})},N))})]}),M&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}function Va({color:t,onColorChange:s}){const n=r.useRef(null),a=Ga(t.value),l=t.value.startsWith("#");return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("button",{type:"button",className:"w-full h-10 rounded-md border border-[#444] cursor-pointer relative group",style:{backgroundColor:t.value},onClick:()=>{var o;return l&&((o=n.current)==null?void 0:o.click())},title:`--${t.name}: ${t.value}${t.comment?` (${t.comment})`:""}`,children:l&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/30 rounded-md",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})}),l&&e.jsx("input",{ref:n,type:"color",value:a,onChange:o=>s(t.name,o.target.value),className:"sr-only"}),e.jsxs("div",{className:"text-[9px] font-mono text-gray-500 truncate",title:`--${t.name}`,children:["--",t.name]}),e.jsx("div",{className:"text-[9px] font-mono text-gray-600 truncate",children:t.value})]})}function Ga(t){if(!t.startsWith("#"))return"#000000";const s=t.slice(1);return s.length===3?`#${s[0]}${s[0]}${s[1]}${s[1]}${s[2]}${s[2]}`:s.length===6||s.length===8?`#${s.slice(0,6)}`:"#000000"}function Ja({group:t,colors:s,onColorChange:n}){const[a,l]=r.useState(!1);return e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{type:"button",onClick:()=>l(!a),className:"flex items-center gap-1.5 text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-2 bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${a?"":"rotate-90"}`,children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),t,e.jsxs("span",{className:"text-gray-600 font-normal",children:["(",s.length,")"]})]}),!a&&e.jsx("div",{className:"grid grid-cols-5 gap-2",children:s.map(o=>e.jsx(Va,{color:o,onColorChange:n},`${o.group}-${o.name}`))})]})}function Ka({designSystem:t,rawMarkdown:s,onSave:n}){const a=t.colors.reduce((x,b)=>(x[b.group]||(x[b.group]=[]),x[b.group].push(b),x),{}),l=r.useCallback((x,b)=>{const f=Pa(s,x,b);n(f)},[s,n]),[o,i]=r.useState(t.fonts.length>0?t.fonts.join(", "):""),d=r.useCallback(()=>{if(!o.trim())return;const x=Ea(s,`'${o.trim()}', sans-serif`);n(x)},[s,o,n]);return e.jsxs("div",{className:"space-y-6",children:[Object.keys(a).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Colors"}),Object.entries(a).map(([x,b])=>e.jsx(Ja,{group:x,colors:b,onColorChange:l},x))]}),t.fonts.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Typography"}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider shrink-0",children:"Font"}),e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),onBlur:d,onKeyDown:x=>x.key==="Enter"&&d(),className:"flex-1 px-2 py-1 text-xs bg-[#222] border border-[#3d3d3d] rounded text-gray-300 outline-none focus:border-[#D7FF63]/50"})]}),t.typographyScale.length>0&&e.jsx("div",{className:"bg-[#222] rounded border border-[#333] overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#333]",children:[e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Style"}),e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Size"}),e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Weight"})]})}),e.jsx("tbody",{children:t.typographyScale.map(x=>e.jsxs("tr",{className:"border-b border-[#333] last:border-b-0",children:[e.jsx("td",{className:"px-3 py-1.5 text-xs text-gray-300",children:x.style}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-gray-400",children:x.size}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-gray-400",children:x.weight})]},x.style))})]})})]}),t.radiusTokens.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Border Radius"}),e.jsx("div",{className:"flex gap-3 flex-wrap",children:t.radiusTokens.map(x=>e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"w-10 h-10 bg-[#D7FF63]/20 border border-[#D7FF63]/40",style:{borderRadius:x.value}}),e.jsxs("div",{className:"text-[9px] font-mono text-gray-500",children:["--",x.name]}),e.jsx("div",{className:"text-[9px] font-mono text-gray-600",children:x.value})]},x.name))})]})]})}function Ya({content:t,onSave:s}){const[n,a]=r.useState(t),[l,o]=r.useState(!1);r.useEffect(()=>{a(t),o(!1)},[t]);const i=r.useCallback(()=>{s(n),o(!1)},[n,s]);return e.jsxs("div",{className:"flex flex-col gap-2 h-full",children:[e.jsx("textarea",{value:n,onChange:d=>{a(d.target.value),o(!0)},className:"flex-1 min-h-[400px] p-3 text-xs font-mono bg-[#1a1a1a] border border-[#3d3d3d] rounded-lg text-gray-300 outline-none focus:border-[#D7FF63]/50 resize-none leading-relaxed",spellCheck:!1}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:i,disabled:!l,className:`px-4 py-1.5 text-xs rounded-md font-medium transition-colors cursor-pointer ${l?"text-[#1e1e1e] bg-[#D7FF63] hover:bg-[#D7FF63]/80":"text-gray-500 bg-[#333] cursor-not-allowed"}`,children:"Save"}),l&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"Unsaved changes"})]})]})}function qa({onClose:t}){return e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(Me,{prompt:`# Edit Design System
|
|
103
|
+
Help the user understand what went wrong and how to fix it. Read their project config files (package.json, next.config.ts, prisma/schema.prisma) if needed to diagnose the issue.`),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2 py-0.5 cursor-pointer transition-colors",children:"Debug with AI"})]})]})]}),$.lastDeployment===null&&!P&&e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-amber-400 m-0",children:"Not deployed yet"}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your project is linked but hasn't been deployed. Push your code to GitHub to trigger an automatic deploy, or deploy now directly."}),e.jsx("button",{type:"button",disabled:H,onClick:()=>{v(null),z(!0),fetch("/api/editor-hosting-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"deploy"})}).then(L=>L.json()).then(L=>{L.ok&&L.deployment?J({id:L.deployment.id,state:L.deployment.state||"QUEUED",url:L.deployment.url,errorMessage:null,logsUrl:null}):v(L.error||"Deployment failed")}).catch(()=>v("Failed to trigger deployment")).finally(()=>z(!1))},className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:H?"Starting...":"Deploy now"})]})]}),se===2&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"A Vercel project is where your app lives once deployed. If you signed up with GitHub, Vercel can import the repo directly. Otherwise, create a new project and connect your repository."}),D?e.jsx("div",{children:e.jsx("span",{className:"text-[11px] text-gray-500",children:"Loading your Vercel projects..."})}):m&&b.length===0?e.jsx("div",{className:"space-y-2",children:G?e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"No Vercel projects found on your account."}),e.jsxs("p",{className:"text-[10px] text-gray-500 m-0",children:["Create one linked to"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:G}),"? Vercel will auto-deploy when you push."]}),e.jsx("button",{type:"button",onClick:T,disabled:I,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:I?"Creating...":"Create Vercel project"})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-400 m-0",children:"No Vercel projects found. Create one and import your repository:"}),e.jsx("a",{href:"https://vercel.com/new",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Create at vercel.com/new →"}),e.jsxs("p",{className:"text-[10px] text-gray-600 m-0",children:["Then"," ",e.jsx("button",{type:"button",onClick:()=>{F(!1),he.current=!1,f()},className:"text-[#D7FF63]/60 hover:text-[#D7FF63] bg-transparent border-none p-0 cursor-pointer text-[10px] underline",children:"re-check"})," ","to find it."]})]})}):b.length>0?e.jsxs("div",{className:"space-y-2",children:[G&&!y&&e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"No existing project matches this repo."}),e.jsxs("p",{className:"text-[10px] text-gray-500 m-0",children:["Create a new Vercel project linked to"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:G}),"? Vercel will auto-deploy when you push."]}),e.jsx("button",{type:"button",onClick:T,disabled:I,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:I?"Creating...":"Create Vercel project"})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:y?"Select the project for this app:":"Or select an existing project:"}),e.jsx("div",{className:"space-y-1",children:b.map(L=>e.jsxs("button",{type:"button",onClick:()=>j(L.id,L.name),disabled:w,className:`w-full text-left rounded px-2.5 py-1.5 border transition-colors cursor-pointer flex items-center gap-2 ${L.id===y?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:[e.jsx("span",{className:"text-xs text-white flex-1",children:L.name}),L.framework&&e.jsx("span",{className:"text-[10px] text-gray-500",children:L.framework}),L.id===y&&e.jsx("span",{className:"text-[9px] text-[#D7FF63] bg-[#D7FF63]/10 px-1 py-px rounded",children:"matches repo"})]},L.id))})]})]}):null]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{step:3,done:me,active:se===3}),e.jsx("span",{className:`text-xs font-medium ${se>=3?"text-white":"text-gray-600"}`,children:"Environment Variables"}),se===3&&re>0&&e.jsxs("span",{className:"text-[10px] text-gray-400 ml-auto",children:[K,"/",re," on Vercel"]})]}),se===3&&$.envVarsChecked&&e.jsx("div",{className:"ml-7 space-y-1.5",children:re===0?e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Your app doesn't use any third-party services that need secrets yet. When you add services like a database or payment provider, their required keys will appear here."}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"These are the secrets your app needs to run in production. They must be added to your Vercel project so deployed builds can access them."}),e.jsx("div",{className:"space-y-1 mt-1",children:$.envVars.map(L=>e.jsxs("div",{className:"flex items-center gap-2",children:[L.configuredOnVercel?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-amber-500/30 flex items-center justify-center",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"})}),e.jsx("span",{className:"text-xs text-gray-300 font-mono flex-1 truncate",children:L.key}),e.jsx("span",{className:"text-[10px] text-gray-500",children:L.service})]},L.key))}),K<re&&e.jsxs("p",{className:"text-[10px] text-gray-500 m-0 mt-1.5 leading-relaxed",children:["Add missing variables in your"," ",e.jsx("a",{href:`https://vercel.com/~/project/${$.projectName||""}/settings/environment-variables`,target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/60 hover:text-[#D7FF63] no-underline",children:"Vercel project settings"})," ","→ Environment Variables. Then"," ",e.jsx("button",{type:"button",onClick:E,className:"text-[#D7FF63]/60 hover:text-[#D7FF63] bg-transparent border-none p-0 cursor-pointer text-[10px] underline",children:"re-check"}),"."]})]})}),se===3&&!$.envVarsChecked&&e.jsxs("div",{className:"ml-7 space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Check which secrets your app needs and whether they're configured on Vercel."}),e.jsx("button",{type:"button",onClick:E,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:"Check environment variables"})]})]}),Y&&B?e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(Y,{prompt:B,height:400,onClose:()=>{Z(null),O(null),E()}})}):e.jsx("button",{type:"button",onClick:()=>pe(),className:"text-[11px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] hover:border-[#555] rounded px-2.5 py-1.5 cursor-pointer transition-colors w-full mt-1",children:"I'm stuck — chat with AI"})]})}function ar({github:t,onSave:s,onShowChat:n}){const[a,l]=r.useState(null),[o,i]=r.useState(!0),[d,x]=r.useState(""),[g,b]=r.useState(!1),[c,y]=r.useState(!1),[M,D]=r.useState([]),[p,w]=r.useState(!1),[k,I]=r.useState(!1),[_,H]=r.useState(!1),[z,P]=r.useState(null),[J,G]=r.useState(!1),[V,S]=r.useState(null),v=r.useCallback(()=>{i(!0),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"full-status"})}).then(R=>R.json()).then(R=>{l(R),S(null)}).catch(()=>S("Failed to check status")).finally(()=>i(!1))},[]);r.useEffect(()=>{v()},[v]);const B=()=>{y(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"init-git"})}).then(R=>R.json()).then(R=>{R.ok?v():S(R.error||"Failed to initialize git")}).catch(()=>S("Failed to initialize git")).finally(()=>y(!1))},O=()=>{d.trim()&&(b(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save-token",token:d.trim()})}).then(R=>R.json()).then(R=>{R.ok?(x(""),v()):S(R.error||"Token verification failed")}).catch(()=>S("Failed to save token")).finally(()=>b(!1)))},Y=()=>{w(!0),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-repos"})}).then(R=>R.json()).then(R=>{R.ok&&(D(R.repos||[]),P(R.suggestedRepoName||null))}).catch(()=>{}).finally(()=>w(!1))},Z=()=>{I(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create-repo"})}).then(R=>R.json()).then(R=>{R.ok?(s({owner:R.repo.owner,repo:R.repo.name,repoUrl:R.repo.url}),v()):S(R.error||"Failed to create repository")}).catch(()=>S("Failed to create repository")).finally(()=>I(!1))},E=R=>{H(!0),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"link-repo",repoUrl:R.cloneUrl,owner:R.fullName.split("/")[0],repo:R.name})}).then(ee=>ee.json()).then(ee=>{ee.ok&&(s({owner:R.fullName.split("/")[0],repo:R.name,repoUrl:R.url}),v())}).catch(()=>{}).finally(()=>H(!1))},U=()=>{G(!0),S(null),fetch("/api/editor-github-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"push"})}).then(R=>R.json()).then(R=>{R.ok?v():S(R.error||"Push failed")}).catch(()=>S("Push failed")).finally(()=>G(!1))},m=a||{gitInitialized:!1,hasGitignore:!1,hasRemote:!1,isGitHub:!1,ghCliInstalled:!1,ghCliAuthenticated:!1,hasToken:!1,tokenVerified:!1,user:null,githubRepo:null,hasCommits:!1,pushed:!1},F=m.gitInitialized,f=m.ghCliAuthenticated||m.tokenVerified,T=m.hasRemote&&m.isGitHub,j=F?f?3:2:1,$=r.useRef(!1);return r.useEffect(()=>{j===3&&!T&&!$.current&&M.length===0&&!p&&($.current=!0,Y())},[j,T]),o&&!a?e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsx("span",{className:"text-xs text-gray-500",children:"Checking GitHub setup..."})}):e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333] space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"GitHub Setup"}),e.jsx("p",{className:"text-[11px] text-gray-400 m-0 leading-relaxed",children:"GitHub stores your code and tracks changes. Push your code to a repository so it’s backed up, versioned, and ready for collaboration or deployment."})]}),V&&e.jsx("div",{className:"text-[11px] text-red-400 bg-red-400/10 rounded px-2 py-1.5",children:V}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{step:1,done:F,active:j===1}),e.jsx("span",{className:"text-xs font-medium text-white",children:"Initialize Git"}),F&&m.hasGitignore&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:"ready"})]}),j===1&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:["Git tracks every change to your code so you can undo mistakes, see history, and collaborate. This initializes a local git repository and creates a ",e.jsx("code",{children:".gitignore"})," file to keep sensitive files out of version control."]}),e.jsx("button",{type:"button",onClick:B,disabled:c,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:c?"Initializing...":"Initialize Git"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{step:2,done:f,active:j===2}),e.jsx("span",{className:`text-xs font-medium ${j>=2?"text-white":"text-gray-600"}`,children:"Connect to GitHub"}),f&&m.user&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-auto",children:m.user.username})]}),j===2&&e.jsxs("div",{className:"ml-7 space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:["a) Install & authenticate with GitHub CLI",m.ghCliInstalled&&!m.ghCliAuthenticated&&e.jsx("span",{className:"text-[10px] text-green-400 ml-1.5",children:"(installed)"})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:["The GitHub CLI (",e.jsx("code",{children:"gh"}),") is the easiest way to authenticate. Install it, then run ",e.jsx("code",{children:"gh auth login"})," in your terminal."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!m.ghCliInstalled&&e.jsx("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border border-[#D7FF63]/30 rounded px-2.5 py-1 no-underline transition-colors",children:"Install GitHub CLI →"}),e.jsx("button",{type:"button",onClick:v,disabled:o,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:o?"Checking...":"Check Authentication"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"b) Or paste a Personal Access Token"}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:["Create a token with ",e.jsx("strong",{children:"repo"})," scope. This is stored in .env.local (never committed)."]}),e.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=CodeYam",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-[11px] text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline transition-colors",children:"Create token on GitHub →"}),m.hasToken&&!m.tokenVerified&&e.jsx("p",{className:"text-[11px] text-amber-400 m-0",children:"A token was found but it didn't work. Try creating a new one."}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"Paste your GitHub token",value:d,onChange:R=>x(R.target.value),onKeyDown:R=>{R.key==="Enter"&&O()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",onClick:O,disabled:g||!d.trim(),className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:g?"Verifying...":"Connect"})]}),e.jsx("p",{className:"text-[10px] text-gray-600 m-0",children:"Stored in .env.local (gitignored — never committed)"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{step:3,done:T,active:j===3}),e.jsx("span",{className:`text-xs font-medium ${j>=3?"text-white":"text-gray-600"}`,children:"Create or Link Repository"}),T&&m.githubRepo&&e.jsxs("span",{className:"text-[10px] text-gray-400 ml-auto",children:[m.githubRepo.owner,"/",m.githubRepo.repo]})]}),j===3&&T&&m.githubRepo&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-gray-400 m-0 leading-relaxed",children:["Connected to"," ",e.jsxs("a",{href:`https://github.com/${m.githubRepo.owner}/${m.githubRepo.repo}`,target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:[m.githubRepo.owner,"/",m.githubRepo.repo]})]}),m.hasCommits&&!m.pushed&&e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"Push your code to GitHub"}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"Your local commits haven't been pushed yet. Push now to back up your code and make it available on GitHub."}),e.jsx("button",{type:"button",onClick:U,disabled:J,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:J?"Pushing...":"Push to GitHub"})]}),m.pushed&&e.jsx("p",{className:"text-[10px] text-green-400 m-0",children:"Code is pushed and up to date."})]}),j===3&&!T&&e.jsxs("div",{className:"ml-7 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-gray-500 m-0 leading-relaxed",children:"Create a new GitHub repository for this project or link to an existing one."}),e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-md px-3 py-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 font-medium",children:"Create a new private repository"}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"Creates a repository on GitHub and sets it as the remote for this project."}),e.jsx("button",{type:"button",onClick:Z,disabled:k,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium mt-0.5",children:k?"Creating...":"Create repository"})]}),M.length===0&&p&&e.jsx("span",{className:"text-[11px] text-gray-500",children:"Loading your repositories..."}),M.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"Or link an existing repository:"}),e.jsx("div",{className:"space-y-1",children:M.map(R=>e.jsxs("button",{type:"button",onClick:()=>E(R),disabled:_,className:`w-full text-left rounded px-2.5 py-1.5 border transition-colors cursor-pointer flex items-center gap-2 ${R.name===z?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:[e.jsx("span",{className:"text-xs text-white flex-1",children:R.fullName}),R.private&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"private"}),R.name===z&&e.jsx("span",{className:"text-[9px] text-[#D7FF63] bg-[#D7FF63]/10 px-1 py-px rounded",children:"matches project"})]},R.fullName))})]})]})]}),n&&e.jsx("button",{type:"button",onClick:n,className:"text-[11px] text-gray-400 hover:text-white bg-transparent border border-[#3d3d3d] hover:border-[#555] rounded px-2.5 py-1.5 cursor-pointer transition-colors w-full mt-1",children:"Need help? Ask Claude about GitHub setup"})]})}function or({hosting:t,onSave:s,onEditNavigate:n,defaultEditing:a=!1,onShowChat:l}){const o=(t==null?void 0:t.provider)||null,[i,d]=r.useState(a&&!o),x=g=>{s({provider:g}),d(!1)};if(o==="vercel")return e.jsx(za,{hosting:t,onSave:s});if(!i&&o){const g=nr.find(b=>b.id===o);return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Hosting"}),g?e.jsx("div",{className:"flex items-center gap-2 bg-[#2a2a2a] border border-[#D7FF63]/40 rounded-md px-3 py-2",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:g.name}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:g.description})]})}):e.jsx("div",{className:"text-xs text-gray-400",children:o}),e.jsx("button",{type:"button",onClick:n??(()=>d(!0)),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"Change >"})]})}return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Choose a hosting provider"}),e.jsx("div",{className:"space-y-2",children:nr.map(g=>e.jsxs("button",{type:"button",onClick:()=>x(g.id),className:`w-full text-left rounded-md px-3 py-2.5 border transition-colors cursor-pointer ${o===g.id?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:[e.jsx("div",{className:"text-sm font-medium text-white",children:g.name}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:g.description}),e.jsx("div",{className:"flex gap-1.5 mt-1.5",children:g.services.map(b=>e.jsx("span",{className:"text-[10px] text-gray-300 bg-[#333] px-1.5 py-0.5 rounded",children:b},b))})]},g.id))}),o&&e.jsx("button",{type:"button",onClick:()=>d(!1),className:"text-[11px] text-gray-400 hover:text-white bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors",children:"Cancel"})]})}const ir=[{id:"supabase",name:"Supabase",services:["PostgreSQL","Auth","Storage","Realtime"],description:"Open-source Firebase alternative"},{id:"neon",name:"Neon",services:["PostgreSQL"],description:"Serverless Postgres",disabled:!0},{id:"planetscale",name:"PlanetScale",services:["MySQL"],description:"Serverless MySQL",disabled:!0}];function Va({database:t,onSave:s}){const[n,a]=r.useState(null),[l,o]=r.useState(!0),[i,d]=r.useState(""),[x,g]=r.useState(!1),[b,c]=r.useState([]),[y,M]=r.useState(null),[D,p]=r.useState(!1),[w,k]=r.useState(!1),[I,_]=r.useState(!1),[H,z]=r.useState(""),[P,J]=r.useState(!1),[G,V]=r.useState(!1),[S,v]=r.useState(null),[B,O]=r.useState(null),Y=r.useCallback(()=>{o(!0),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"full-status"})}).then(j=>j.json()).then(j=>{a(j),O(null)}).catch(()=>O("Failed to check status")).finally(()=>o(!1))},[]);r.useEffect(()=>{Y()},[Y]);const Z=()=>{i.trim()&&(g(!0),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save-token",token:i.trim()})}).then(j=>j.json()).then(j=>{j.ok?(d(""),Y()):O(j.error||"Token verification failed")}).catch(()=>O("Failed to save token")).finally(()=>g(!1)))},E=r.useCallback(()=>{p(!0),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-projects"})}).then(j=>j.json()).then(j=>{j.ok?(c(j.projects||[]),M(j.suggestedProjectId||null),k(!0)):O(j.error||"Failed to load projects")}).catch(()=>O("Failed to load projects")).finally(()=>p(!1))},[]);r.useEffect(()=>{n!=null&&n.tokenVerified&&!(n!=null&&n.projectLinked)&&!w&&E()},[n==null?void 0:n.tokenVerified,n==null?void 0:n.projectLinked,w,E]);const U=j=>{const $=b.find(R=>R.id===j);_(!0),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"link-project",projectId:j,projectName:$==null?void 0:$.name})}).then(R=>R.json()).then(R=>{R.ok?Y():O(R.error||"Failed to link project")}).catch(()=>O("Failed to link project")).finally(()=>_(!1))},m=()=>{H.trim()&&(J(!0),O(null),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addEnvironmentVariable:{key:"DATABASE_URL",value:H.trim()}})}).then(j=>j.json()).then(j=>{j.success?(z(""),Y()):O(j.error||"Failed to save DATABASE_URL")}).catch(()=>O("Failed to save DATABASE_URL")).finally(()=>J(!1)))},F=()=>{V(!0),v(null),O(null),fetch("/api/editor-database-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify-connection"})}).then(j=>j.json()).then(j=>{j.ok&&j.connected?v(!0):(v(!1),O(j.error||"Connection test failed"))}).catch(()=>{v(!1),O("Failed to test connection")}).finally(()=>V(!1))};if(l&&!n)return e.jsx("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:e.jsx("span",{className:"text-[11px] text-gray-500",children:"Checking Supabase status..."})});const f=n||{tokenVerified:!1,projectLinked:!1,projectName:null,projectRef:null,dashboardUrl:null,envVarsConfigured:!1,envVars:[],currentDbProvider:null,migrationNeeded:!1};let T=1;return f.tokenVerified&&f.projectLinked&&f.envVarsConfigured?T=(f.migrationNeeded,4):f.tokenVerified&&f.projectLinked?T=3:f.tokenVerified&&(T=2),e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333] space-y-3",children:[T===1&&!f.tokenVerified&&e.jsxs("div",{className:"bg-[#1a1a1a] rounded-md px-3 py-2.5 border border-[#333]",children:[e.jsx("p",{className:"text-[11px] text-gray-300 m-0 leading-relaxed",children:"Supabase gives you a hosted PostgreSQL database with built-in auth, storage, and realtime. The free tier includes 2 projects with 500MB of database storage."}),e.jsxs("p",{className:"text-[10px] text-gray-500 m-0 mt-1.5 leading-relaxed",children:["If you don't have an account yet, sign up at"," ",e.jsx("a",{href:"https://supabase.com/dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"supabase.com"})," ","(GitHub sign-in is fastest), then come back here to connect."]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{step:1,done:f.tokenVerified,active:T===1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Connect your Supabase account"}),f.tokenVerified?e.jsx("p",{className:"text-[10px] text-green-400 m-0 mt-0.5",children:"Connected"}):e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.jsxs("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:["We need a"," ",e.jsx("span",{className:"text-gray-400",children:"personal access token"})," ","(not a project API key) to list your projects and fetch credentials automatically."]}),e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-1",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["1. Go to"," ",e.jsx("a",{href:"https://supabase.com/dashboard/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Account → Access Tokens"})]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["2. Click"," ",e.jsx("span",{className:"text-gray-300",children:'"Generate new token"'}),', name it anything (e.g. "CodeYam")']}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["3. Copy the token (starts with"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:"sbp_"}),") and paste it below"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"sbp_...",value:i,onChange:j=>d(j.target.value),onKeyDown:j=>{j.key==="Enter"&&Z()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",disabled:x||!i.trim(),onClick:Z,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:x?"Verifying...":"Connect"})]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{step:2,done:f.projectLinked,active:T===2}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Select a Supabase project"}),f.projectLinked?e.jsx("div",{className:"mt-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-gray-300",children:f.projectName||f.projectRef}),f.dashboardUrl&&e.jsx("a",{href:f.dashboardUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/60 hover:text-[#D7FF63] no-underline",children:"dashboard →"})]})}):T>=2?e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Each Supabase project is an isolated PostgreSQL database. Select the project for this app, or create a new one first."}),D?e.jsx("span",{className:"text-[11px] text-gray-500",children:"Loading your Supabase projects..."}):b.length>0?e.jsxs("div",{className:"space-y-1",children:[b.map(j=>e.jsx("button",{type:"button",disabled:I,onClick:()=>U(j.id),className:`w-full text-left rounded-md px-2.5 py-1.5 border transition-colors cursor-pointer ${j.id===y?"bg-[#2a2a2a] border-[#D7FF63]/40":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555]"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-white font-medium",children:j.name}),e.jsx("span",{className:"text-[10px] text-gray-500",children:j.region}),j.id===y&&e.jsx("span",{className:"text-[10px] text-[#D7FF63] ml-auto",children:"suggested"})]})},j.id)),e.jsxs("p",{className:"text-[10px] text-gray-600 m-0 mt-1",children:["Don't see the right project?"," ",e.jsx("a",{href:"https://supabase.com/dashboard/projects",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Open your dashboard"})," ",`and click "New project" (you'll pick an organization first), then`," ",e.jsx("button",{type:"button",onClick:E,className:"text-[#D7FF63]/70 hover:text-[#D7FF63] bg-transparent border-none p-0 cursor-pointer transition-colors underline",children:"refresh this list"}),"."]})]}):w?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0",children:"No projects found on your Supabase account."}),e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-1",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["1. Open your"," ",e.jsx("a",{href:"https://supabase.com/dashboard/projects",target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Supabase dashboard"})," ","and click"," ",e.jsx("span",{className:"text-gray-300",children:'"New project"'})]}),e.jsx("p",{className:"text-[10px] text-gray-400 m-0",children:"2. Select an organization (or create one — this is just a billing group for your projects)"}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["3. Pick a name, set a"," ",e.jsx("span",{className:"text-gray-300",children:"database password"})," ","(save this — you'll need it for the connection string), and choose a region"]}),e.jsx("p",{className:"text-[10px] text-gray-400 m-0",children:"4. Wait for the project to finish provisioning (~2 min), then come back and refresh"})]}),e.jsx("button",{type:"button",onClick:E,className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors",children:"Refresh project list"})]}):null]}):e.jsx("p",{className:"text-[10px] text-gray-500 m-0 mt-0.5",children:"Connect your account first"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{step:3,done:f.envVarsConfigured,active:T===3}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Configure database connection"}),f.envVarsConfigured?e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsx("p",{className:"text-[10px] text-green-400 m-0",children:"All credentials configured"}),S===!0&&e.jsx("p",{className:"text-[10px] text-green-400 m-0",children:"Connection verified"}),S===!1&&e.jsx("p",{className:"text-[10px] text-red-300 m-0",children:"Connection test failed — check your credentials"}),e.jsx("button",{type:"button",disabled:G,onClick:F,className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors underline",children:G?"Testing...":S===!0?"Test again":"Test connection"})]}):T>=3?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your Supabase URL and anon key were auto-filled when you linked the project. You still need to add the database connection string (which includes your database password)."}),e.jsx("div",{className:"space-y-1",children:f.envVars.map(j=>e.jsxs("div",{className:"flex items-center gap-2",children:[j.configured?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-amber-500/30 flex items-center justify-center",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"})}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:j.key}),j.configured&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"configured"})]},j.key))}),f.envVars.some(j=>j.key==="DATABASE_URL"&&!j.configured)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-1",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["1. Open"," ",f.projectRef?e.jsx("a",{href:`https://supabase.com/dashboard/project/${f.projectRef}/database/settings?showConnect=true`,target:"_blank",rel:"noopener noreferrer",className:"text-[#D7FF63]/70 hover:text-[#D7FF63] no-underline",children:"Database Settings → Connect"}):e.jsx("span",{className:"text-gray-300",children:"Database Settings → Connect"})]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["2. Select"," ",e.jsx("span",{className:"text-gray-300",children:'"Session pooler"'})," ","mode (port 5432) — this gives the best performance for CodeYam's scenario data seeding"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:["3. Copy the ",e.jsx("span",{className:"text-gray-300",children:"URI"})," ","connection string and replace"," ",e.jsx("span",{className:"text-gray-300 font-mono",children:"[YOUR-PASSWORD]"})," ","with the database password you set when creating the project"]})]}),e.jsxs("p",{className:"text-[10px] text-gray-600 m-0",children:["Forgot your password? Reset it in"," ",f.projectRef?e.jsx("a",{href:`https://supabase.com/dashboard/project/${f.projectRef}/database/settings`,target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-400 no-underline",children:"Database Settings"}):"Database Settings"," ",'under "Database password".']}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"password",placeholder:"postgresql://postgres.xxxxx:password@aws-0-region.pooler.supabase.com:5432/postgres",value:H,onChange:j=>z(j.target.value),onKeyDown:j=>{j.key==="Enter"&&m()},className:"bg-[#1a1a1a] border border-[#444] rounded px-2 py-1 text-xs text-white flex-1 outline-none focus:border-[#D7FF63]/50 font-mono"}),e.jsx("button",{type:"button",disabled:P||!H.trim(),onClick:m,className:"text-[11px] text-black bg-[#D7FF63] hover:bg-[#D7FF63]/80 disabled:opacity-40 rounded px-2.5 py-1 border-none cursor-pointer transition-colors font-medium",children:P?"Saving...":"Save"})]})]})]}):e.jsx("p",{className:"text-[10px] text-gray-500 m-0 mt-0.5",children:"Link a project first"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{step:4,done:!f.migrationNeeded,active:T===4&&f.migrationNeeded}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-white",children:"Migrate to PostgreSQL"}),f.migrationNeeded?T===4?e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your project currently uses SQLite for local development. To use your Supabase database, Claude needs to update several files:"}),e.jsxs("div",{className:"bg-[#1a1a1a] rounded px-2.5 py-2 border border-[#333] space-y-0.5",children:[e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:"prisma/schema.prisma"})," ","— switch provider from sqlite to postgresql"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:"app/lib/prisma.ts"})," ","— swap the database adapter"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:"package.json"})," ","— replace sqlite packages with pg + supabase-js"]}),e.jsxs("p",{className:"text-[10px] text-gray-400 m-0",children:[e.jsx("span",{className:"text-gray-300 font-mono",children:".codeyam/seed-adapter.ts"})," ","— switch to Supabase seed adapter"]})]}),e.jsx("p",{className:"text-[10px] text-gray-500 m-0 leading-relaxed",children:"Your Prisma models and app code stay the same — only the database connection layer changes. After migration, use the Live Preview to verify everything loads correctly."}),e.jsxs("div",{className:"bg-[#D7FF63]/5 border border-[#D7FF63]/20 rounded px-2.5 py-2",children:[e.jsxs("p",{className:"text-[10px] text-[#D7FF63]/90 m-0 leading-relaxed",children:["Ask Claude in the chat:"," ",e.jsx("span",{className:"font-medium",children:'"Migrate my project from SQLite to Supabase"'})]}),e.jsx("p",{className:"text-[10px] text-[#D7FF63]/60 m-0 mt-0.5",children:"Claude will make the changes, run npm install, push the schema to Supabase, and help you verify it works."})]})]}):e.jsx("p",{className:"text-[10px] text-gray-500 m-0 mt-0.5",children:"Configure credentials first"}):e.jsx("p",{className:"text-[10px] text-green-400 m-0 mt-0.5",children:f.currentDbProvider==="postgresql"?"Already using PostgreSQL":"No migration needed"})]})]}),B&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded px-2.5 py-1.5",children:e.jsx("p",{className:"text-[10px] text-red-300 m-0",children:B})})]})}function lr({database:t,onSave:s,onEditNavigate:n,defaultEditing:a=!1}){const l=(t==null?void 0:t.provider)||null,[o,i]=r.useState(a&&!l),d=x=>{s({provider:x}),i(!1)};if(l==="supabase")return e.jsx(Va,{database:t,onSave:s});if(!o&&l){const x=ir.find(g=>g.id===l);return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Database"}),x?e.jsx("div",{className:"flex items-center gap-2 bg-[#2a2a2a] border border-[#D7FF63]/40 rounded-md px-3 py-2",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:x.name}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:x.description})]})}):e.jsx("div",{className:"text-xs text-gray-400",children:l}),e.jsx("button",{type:"button",onClick:n??(()=>i(!0)),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors font-medium",children:"Change >"})]})}return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Choose a database provider"}),e.jsx("div",{className:"space-y-2",children:ir.map(x=>e.jsxs("button",{type:"button",disabled:x.disabled,onClick:()=>d(x.id),className:`w-full text-left rounded-md px-3 py-2.5 border transition-colors ${x.disabled?"bg-[#2a2a2a] border-[#333] opacity-40 cursor-not-allowed":"bg-[#2a2a2a] border-[#3d3d3d] hover:border-[#555] cursor-pointer"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:x.name}),x.disabled&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"coming soon"})]}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:x.description}),e.jsx("div",{className:"flex gap-1.5 mt-1.5",children:x.services.map(g=>e.jsx("span",{className:"text-[10px] text-gray-300 bg-[#333] px-1.5 py-0.5 rounded",children:g},g))})]},x.id))}),l&&e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-[11px] text-gray-400 hover:text-white bg-transparent border-none p-0 mt-2 cursor-pointer transition-colors",children:"Cancel"})]})}function cr({serviceName:t,serviceUrl:s,envKeys:n,environmentVariables:a,onSaveEnvVar:l,onEditNavigate:o,defaultEditing:i=!1}){const[d,x]=r.useState(i),[g,b]=r.useState({}),c=r.useMemo(()=>{const p=new Set;for(const w of a){const k=w.key||w.name;k&&w.value&&p.add(k)}return p},[a]),y=n.filter(p=>c.has(p)).length,M=y===n.length,D=p=>{const w=g[p];w!==void 0&&w!==""&&(l(p,w),b(k=>{const I={...k};return delete I[p],I}))};return e.jsxs("div",{className:"mt-1 mb-2 bg-[#222] rounded-lg p-3 border border-[#333]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Credentials"}),s&&e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-[#D7FF63]/60 hover:text-[#D7FF63] no-underline",children:"docs →"})]}),e.jsx("div",{className:"space-y-1.5",children:n.map(p=>{const w=c.has(p),k=g[p]!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[w?e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-green-600 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}):e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full bg-amber-500/30 flex items-center justify-center",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"})}),e.jsx("span",{className:"text-xs text-gray-300 font-mono flex-1 truncate",children:p}),w&&!k?e.jsx("span",{className:"text-[10px] text-gray-500",children:"configured"}):d||k?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",placeholder:"value",value:g[p]||"",onChange:I=>b(_=>({..._,[p]:I.target.value})),onKeyDown:I=>{I.key==="Enter"&&D(p)},className:"bg-[#1a1a1a] border border-[#444] rounded px-1.5 py-0.5 text-xs text-white w-32 outline-none focus:border-[#D7FF63]/50"}),e.jsx("button",{type:"button",onClick:()=>D(p),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none cursor-pointer p-0 transition-colors",children:"Save"})]}):e.jsx("button",{type:"button",onClick:()=>b(I=>({...I,[p]:""})),className:"text-[10px] text-amber-400 hover:text-amber-300 bg-transparent border-none cursor-pointer p-0 transition-colors",children:"add"})]},p)})}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:M?"All keys configured":`${y} of ${n.length} keys configured`}),!d&&!M&&e.jsx("button",{type:"button",onClick:o??(()=>x(!0)),className:"text-[10px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none cursor-pointer p-0 transition-colors",children:"Configure all >"})]})]})}function Ga({onBack:t,onSwitchToBuild:s,onSwitchToHistory:n,onNavigateToDesignSystem:a,onNavigateToTechStack:l,expandedTasks:o,onExpandedTasksChange:i,buildIdle:d=!1,onScreenshotClick:x,onZoomChange:g}){const{revalidate:b}=un(),[c,y]=r.useState(null),[M,D]=r.useState(!1),[p,w]=r.useState(null),k=r.useCallback(()=>{fetch("/api/editor-roadmap").then(N=>N.json()).then(N=>y(N)).catch(()=>{})},[]);r.useEffect(()=>{k()},[k]);const I=(c==null?void 0:c.plan.some(N=>N.id==="plan-design-system"&&N.completed))??!1;r.useEffect(()=>{if(!I){w(null);return}fetch("/api/editor-design-system").then(N=>N.json()).then(N=>{N.exists&&N.content?w(Zt(N.content)):w(null)}).catch(()=>w(null))},[I]);const _=r.useCallback(N=>{D(!0),fetch("/api/editor-roadmap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}).then(Q=>Q.json()).then(()=>k()).catch(()=>{}).finally(()=>D(!1))},[k]),H=r.useCallback((N,Q)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectTitle:N,projectDescription:Q})}).then(()=>k()).catch(()=>{})},[k]),z=r.useCallback((N,Q)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({screenSizes:N,projectScreenSizes:Q})}).then(()=>{k(),b()}).catch(()=>{})},[k,b]),P=r.useCallback(N=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hosting:N})}).then(()=>k()).catch(()=>{})},[k]),J=r.useCallback(N=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({database:N})}).then(()=>k()).catch(()=>{})},[k]),G=r.useCallback(N=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({github:N})}).then(()=>k()).catch(()=>{})},[k]),V=r.useCallback((N,Q)=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addEnvironmentVariable:{key:N,value:Q}})}).then(()=>k()).catch(()=>{})},[k]),S=r.useCallback((N,Q)=>{if(!c)return;const u=c[N].filter(A=>A.id!==Q);y({...c,[N]:u}),_({[N]:u})},[c,_]),[v,B]=r.useState(null),[O,Y]=r.useState(()=>new Set),[Z,E]=r.useState(()=>new Set),[U,m]=r.useState(()=>new Set),F=r.useCallback(N=>{m(Q=>{const u=new Set(Q);return u.has(N)?u.delete(N):u.add(N),u})},[]),[f,T]=r.useState(()=>new Set),[j,$]=r.useState(!1),[R,ee]=r.useState(null),K=r.useRef(null),re=r.useRef(null),me=r.useRef(0),se=r.useCallback(N=>{Y(Q=>{const u=new Set(Q);return u.has(N)?u.delete(N):u.add(N),u})},[]),pe=r.useCallback(N=>{T(Q=>{const u=new Set(Q);return u.has(N)?u.delete(N):u.add(N),u})},[]);r.useEffect(()=>{if(!j||typeof document>"u")return;const N=Q=>{K.current&&!K.current.contains(Q.target)&&($(!1),ee(null))};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[j]);const he=[{key:"plan",label:"Setup"},{key:"build",label:"Build"},{key:"deploy",label:"Deploy"},{key:"gtm",label:"Go To Market"}],fe=r.useCallback(N=>{const Q=new Set(o);Q.has(N)?Q.delete(N):Q.add(N),i(Q)},[o,i]),L=r.useCallback(N=>{re.current&&(me.current=re.current.scrollTop),B(N)},[]),xe=r.useCallback(()=>{B(null),requestAnimationFrame(()=>{re.current&&(re.current.scrollTop=me.current)})},[]);if(!c)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsx("span",{className:"text-sm text-gray-500",children:"Loading roadmap..."})});const ie=c.plan.filter(N=>N.completed).length,de=c.deploy.filter(N=>N.completed).length,ne=v&&([...c.plan,...c.deploy].find(N=>N.id===v)??null);if(ne){const N=ne.id==="plan-project-name"&&ne.completed?e.jsx(tr,{projectTitle:c.projectTitle,projectDescription:c.projectDescription,onSave:H,defaultEditing:!0}):ne.id==="plan-screen-sizes"&&ne.completed?e.jsx(rr,{screenSizes:c.screenSizes,projectScreenSizes:c.projectScreenSizes,defaultScreenSize:c.defaultScreenSize,appFormats:c.appFormats,onSave:z,defaultEditing:!0}):ne.id==="plan-github"?e.jsx(ar,{github:c.github,onSave:G}):ne.id==="deploy-hosting"?e.jsx(or,{hosting:c.hosting,onSave:P,defaultEditing:!0}):ne.id==="deploy-database"?e.jsx(lr,{database:c.database,onSave:J,defaultEditing:!0}):ne.serviceRef&&c.techStack?(()=>{var A;const Q=c.techStack[ne.serviceRef.category],u=Q==null?void 0:Q.find(q=>q.name===ne.serviceRef.name);return(A=u==null?void 0:u.envKeys)!=null&&A.length?e.jsx(cr,{serviceName:u.name,serviceUrl:u.url,envKeys:u.envKeys,environmentVariables:c.environmentVariables,onSaveEnvVar:V,defaultEditing:!0}):null})():null;return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:xe,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("h2",{className:"text-lg font-medium text-white mt-0 mb-0",children:ne.label}),ne.completed&&e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-green-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]}),N?e.jsx("div",{children:N}):e.jsx("p",{className:"text-sm text-gray-500",children:ne.completed?"This task has been completed.":"This task has not been started yet."}),M&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}return e.jsx("div",{ref:re,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-5",children:[e.jsx("div",{className:"flex items-center px-0 -mx-4 bg-[#161616] border-b border-[#2d2d2d]",style:{marginTop:"-1rem",paddingLeft:"1rem",paddingRight:"1rem",paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Home"]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx("h2",{className:"text-xl font-medium text-white m-0",children:"Roadmap"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",ref:K,children:[e.jsx("button",{type:"button",onClick:()=>{$(!j),ee(null)},className:"p-1 text-gray-500 hover:text-white bg-transparent border-none cursor-pointer transition-colors",title:"Options",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"5",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}),j&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 flex items-start gap-0",children:[R&&e.jsx("div",{className:"bg-[#2d2d2d] border border-[#3d3d3d] rounded-lg shadow-lg py-1 min-w-[150px]",children:(R==="hide"?he.filter(N=>!f.has(N.key)):he.filter(N=>f.has(N.key))).map(N=>e.jsx("button",{type:"button",onClick:()=>{pe(N.key),$(!1),ee(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-300 hover:text-white hover:bg-[#3d3d3d] bg-transparent border-none cursor-pointer transition-colors",children:N.label},N.key))}),e.jsxs("div",{className:"bg-[#2d2d2d] border border-[#3d3d3d] rounded-lg shadow-lg py-1 min-w-[130px]",children:[he.some(N=>!f.has(N.key))&&e.jsxs("button",{type:"button",onMouseEnter:()=>ee("hide"),className:"w-full flex items-center justify-between px-4 py-2 text-sm text-gray-300 hover:text-white hover:bg-[#3d3d3d] bg-transparent border-none cursor-pointer transition-colors",children:["Hide",e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})})]}),f.size>0&&e.jsxs("button",{type:"button",onMouseEnter:()=>ee("show"),className:"w-full flex items-center justify-between px-4 py-2 text-sm text-gray-300 hover:text-white hover:bg-[#3d3d3d] bg-transparent border-none cursor-pointer transition-colors",children:["Show",e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})})]})]})]})]})]}),!f.has("plan")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(yt,{title:"Setup",completedCount:ie,totalCount:c.plan.length,collapsed:O.has("plan"),onToggleCollapse:()=>se("plan")}),!O.has("plan")&&c.plan.map(N=>e.jsxs(er,{todo:N,expanded:o.has(N.id),onToggle:()=>fe(N.id),onRemove:N.userCreated?()=>S("plan",N.id):void 0,children:[N.id==="plan-project-name"&&N.completed&&e.jsx(tr,{projectTitle:c.projectTitle,projectDescription:c.projectDescription,onSave:H,onEditNavigate:()=>L(N.id)}),N.id==="plan-tech-stack"&&e.jsx(Ha,{techStack:c.techStack,onNavigate:l}),N.id==="plan-design-system"&&N.completed&&p&&e.jsx(Wa,{designSystem:p,onEdit:a}),N.id==="plan-screen-sizes"&&N.completed&&e.jsx(rr,{screenSizes:c.screenSizes,projectScreenSizes:c.projectScreenSizes,defaultScreenSize:c.defaultScreenSize,appFormats:c.appFormats,onSave:z,onEditNavigate:()=>L(N.id)}),N.id==="plan-github"&&e.jsx(ar,{github:c.github,onSave:G})]},N.id))]}),!f.has("build")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(yt,{title:"Build",subtitle:c.editorStep!=null&&c.editorStep<18?"Building...":void 0,subtitleAccent:c.editorStep!=null&&c.editorStep<18,collapsed:O.has("build"),onToggleCollapse:()=>se("build"),subtitleLink:c.editorStep==null||c.editorStep>=18?{label:"Start New Feature",onClick:s}:void 0}),!O.has("build")&&e.jsxs(e.Fragment,{children:[c.editorStep!=null&&c.editorStep>=18?e.jsx("div",{className:"mx-3 mb-2",children:e.jsxs("button",{type:"button",onClick:s,className:"w-full flex items-center gap-2 py-3 px-4 bg-[#2a2a2a] rounded-lg border-none cursor-pointer text-left group hover:bg-[#303030] transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("span",{className:"text-sm text-white group-hover:text-white transition-colors truncate flex-1 font-medium",children:c.featureName||"New Feature"}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded uppercase tracking-wider shrink-0 font-['IBM_Plex_Mono'] bg-[#5ce0d2]/20 text-[#5ce0d2]",children:"New"}),e.jsx("span",{className:"text-[10px] text-gray-500 shrink-0 uppercase font-['IBM_Plex_Mono']",children:"Just now"}),e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-green-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]})}):c.editorStep!=null?e.jsx("div",{className:"mx-3 mb-2",children:e.jsxs("button",{type:"button",onClick:s,className:"w-full flex flex-col gap-2 py-3 px-4 bg-[#1a3a3a] border border-[#2a5a5a] rounded-lg cursor-pointer text-left hover:bg-[#1e4242] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[d?e.jsx("span",{className:"w-3 h-3 rounded-full bg-[#FF8B43] shrink-0"}):e.jsx(kt,{color:"#5ce0d2",dotSize:3}),e.jsx("span",{className:"text-sm text-white font-medium",children:c.featureName||"New Feature"}),d&&e.jsx("span",{className:"text-xs text-[#FF8B43] underline cursor-pointer hover:text-[#FF8B43]/70",onClick:N=>{N.stopPropagation(),s()},children:"Go to build"}),e.jsx("span",{className:"flex-1"}),c.editorStep!=null&&c.editorStepLabel&&e.jsxs("span",{className:"text-xs font-['IBM_Plex_Mono'] text-[#5ce0d2] tracking-wider shrink-0",children:[c.editorStepLabel.toUpperCase()," (",c.editorStep,"/18)"]})]}),c.editorStep!=null&&e.jsx("div",{className:"flex items-center gap-2 w-full",children:e.jsx("div",{className:"flex-1 h-[6px] bg-[#0d2626] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#5ce0d2] to-[#5ce0d2] rounded-full transition-all",style:{width:`${c.editorStep/18*100}%`}})})})]})}):null,c.recentEntries.map(N=>{const Q=Z.has(N.time);return e.jsxs("div",{className:"mx-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 bg-[#2a2a2a] rounded-lg cursor-pointer hover:bg-[#303030] transition-colors",onClick:()=>{E(u=>{const A=new Set(u);return A.has(N.time)?A.delete(N.time):A.add(N.time),A})},children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-gray-500 transition-transform ${Q?"rotate-90":""}`,children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("span",{className:"text-sm text-gray-300 truncate flex-1",children:N.title}),e.jsx("span",{className:`${Ra[N.type]||Ia} text-[10px] font-bold px-2.5 py-0.5 rounded-full border uppercase tracking-wider shrink-0 font-['IBM_Plex_Mono']`,children:N.type}),e.jsx("span",{className:"text-[10px] text-gray-500 shrink-0 uppercase font-['IBM_Plex_Mono']",children:Ba(N.time)}),e.jsx("span",{className:"shrink-0 w-4 h-4 rounded-full border border-green-500 flex items-center justify-center",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})})]}),Q&&e.jsx("div",{className:"mt-1 bg-[#222] rounded-lg",children:e.jsx(_a,{entry:N,expandedSections:U,onToggleSection:F,onScreenshotClick:x,onZoomChange:g})})]},N.time)}),!c.featureName&&c.buildSessionCount===0&&e.jsx("div",{className:"mx-3 mb-2 py-3 px-4 bg-[#2a2a2a] rounded-lg",children:e.jsx("p",{className:"text-xs text-gray-500 m-0",children:"No sessions yet."})}),e.jsxs("div",{className:"mx-3 mb-2 flex items-center gap-2 px-4 py-2.5 bg-[#2a2a2a] rounded-lg",children:[e.jsx("input",{type:"text",placeholder:"Plan next feature",className:"flex-1 text-sm bg-transparent border-none text-gray-300 placeholder-gray-600 outline-none",onKeyDown:N=>{N.key==="Enter"&&N.currentTarget.value.trim()&&s()}}),e.jsx("button",{type:"button",onClick:s,className:"text-[10px] font-bold text-black bg-[#D7FF63] hover:bg-[#c5ee52] px-2.5 py-1 rounded cursor-pointer transition-colors font-['IBM_Plex_Mono'] tracking-wider",children:"ADD"})]})]})]}),!f.has("deploy")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(yt,{title:"Deploy",completedCount:de,totalCount:c.deploy.length>0?c.deploy.length:void 0,collapsed:O.has("deploy"),onToggleCollapse:()=>se("deploy")}),!O.has("deploy")&&(c.deploy.length>0?c.deploy.map(N=>e.jsx(er,{todo:N,expanded:o.has(N.id),onToggle:()=>fe(N.id),onRemove:N.userCreated?()=>S("deploy",N.id):void 0,children:N.id==="deploy-hosting"?e.jsx(or,{hosting:c.hosting,onSave:P,onEditNavigate:()=>L(N.id)}):N.id==="deploy-database"?e.jsx(lr,{database:c.database,onSave:J,onEditNavigate:()=>L(N.id)}):N.serviceRef&&c.techStack?(()=>{var A;const Q=c.techStack[N.serviceRef.category],u=Q==null?void 0:Q.find(q=>q.name===N.serviceRef.name);return(A=u==null?void 0:u.envKeys)!=null&&A.length?e.jsx(cr,{serviceName:u.name,serviceUrl:u.url,envKeys:u.envKeys,environmentVariables:c.environmentVariables,onSaveEnvVar:V,onEditNavigate:()=>L(N.id)}):e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-1 mb-2",children:N.completed?"Completed":"Not started yet"})})():e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-1 mb-2",children:N.completed?"Completed":"Not started yet"})},N.id)):e.jsx("div",{className:"mx-3 mb-2 py-3 px-4 bg-[#2a2a2a] rounded-lg",children:e.jsx("span",{className:"text-sm text-gray-500",children:"-"})}))]}),!f.has("gtm")&&e.jsxs("div",{className:"border border-[#2D2D2D] rounded-lg pb-1 bg-[#171717]",children:[e.jsx(yt,{title:"Go To Market",collapsed:O.has("gtm"),onToggleCollapse:()=>se("gtm")}),!O.has("gtm")&&e.jsx(e.Fragment,{children:["Blog Post","Demo","One Liner"].map(N=>e.jsx("div",{className:"mx-3 mb-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 bg-[#2a2a2a] rounded-lg",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-gray-500",children:e.jsx("path",{d:"M3 1l4 4-4 4"})}),e.jsx("span",{className:"text-sm text-gray-500 flex-1",children:N})]})},N))})]}),M&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}function Ja({color:t,onColorChange:s}){const n=r.useRef(null),a=Ka(t.value),l=t.value.startsWith("#");return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("button",{type:"button",className:"w-full h-10 rounded-md border border-[#444] cursor-pointer relative group",style:{backgroundColor:t.value},onClick:()=>{var o;return l&&((o=n.current)==null?void 0:o.click())},title:`--${t.name}: ${t.value}${t.comment?` (${t.comment})`:""}`,children:l&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/30 rounded-md",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})}),l&&e.jsx("input",{ref:n,type:"color",value:a,onChange:o=>s(t.name,o.target.value),className:"sr-only"}),e.jsxs("div",{className:"text-[9px] font-mono text-gray-500 truncate",title:`--${t.name}`,children:["--",t.name]}),e.jsx("div",{className:"text-[9px] font-mono text-gray-600 truncate",children:t.value})]})}function Ka(t){if(!t.startsWith("#"))return"#000000";const s=t.slice(1);return s.length===3?`#${s[0]}${s[0]}${s[1]}${s[1]}${s[2]}${s[2]}`:s.length===6||s.length===8?`#${s.slice(0,6)}`:"#000000"}function Ya({group:t,colors:s,onColorChange:n}){const[a,l]=r.useState(!1);return e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{type:"button",onClick:()=>l(!a),className:"flex items-center gap-1.5 text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-2 bg-transparent border-none p-0 cursor-pointer hover:text-gray-300 transition-colors",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${a?"":"rotate-90"}`,children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),t,e.jsxs("span",{className:"text-gray-600 font-normal",children:["(",s.length,")"]})]}),!a&&e.jsx("div",{className:"grid grid-cols-5 gap-2",children:s.map(o=>e.jsx(Ja,{color:o,onColorChange:n},`${o.group}-${o.name}`))})]})}function qa({designSystem:t,rawMarkdown:s,onSave:n}){const a=t.colors.reduce((x,g)=>(x[g.group]||(x[g.group]=[]),x[g.group].push(g),x),{}),l=r.useCallback((x,g)=>{const b=Ta(s,x,g);n(b)},[s,n]),[o,i]=r.useState(t.fonts.length>0?t.fonts.join(", "):""),d=r.useCallback(()=>{if(!o.trim())return;const x=La(s,`'${o.trim()}', sans-serif`);n(x)},[s,o,n]);return e.jsxs("div",{className:"space-y-6",children:[Object.keys(a).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Colors"}),Object.entries(a).map(([x,g])=>e.jsx(Ya,{group:x,colors:g,onColorChange:l},x))]}),t.fonts.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Typography"}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider shrink-0",children:"Font"}),e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),onBlur:d,onKeyDown:x=>x.key==="Enter"&&d(),className:"flex-1 px-2 py-1 text-xs bg-[#222] border border-[#3d3d3d] rounded text-gray-300 outline-none focus:border-[#D7FF63]/50"})]}),t.typographyScale.length>0&&e.jsx("div",{className:"bg-[#222] rounded border border-[#333] overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#333]",children:[e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Style"}),e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Size"}),e.jsx("th",{className:"text-left px-3 py-1.5 text-[9px] font-semibold text-gray-500 uppercase tracking-wider",children:"Weight"})]})}),e.jsx("tbody",{children:t.typographyScale.map(x=>e.jsxs("tr",{className:"border-b border-[#333] last:border-b-0",children:[e.jsx("td",{className:"px-3 py-1.5 text-xs text-gray-300",children:x.style}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-gray-400",children:x.size}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-gray-400",children:x.weight})]},x.style))})]})})]}),t.radiusTokens.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-white mb-3",children:"Border Radius"}),e.jsx("div",{className:"flex gap-3 flex-wrap",children:t.radiusTokens.map(x=>e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"w-10 h-10 bg-[#D7FF63]/20 border border-[#D7FF63]/40",style:{borderRadius:x.value}}),e.jsxs("div",{className:"text-[9px] font-mono text-gray-500",children:["--",x.name]}),e.jsx("div",{className:"text-[9px] font-mono text-gray-600",children:x.value})]},x.name))})]})]})}function Qa({content:t,onSave:s}){const[n,a]=r.useState(t),[l,o]=r.useState(!1);r.useEffect(()=>{a(t),o(!1)},[t]);const i=r.useCallback(()=>{s(n),o(!1)},[n,s]);return e.jsxs("div",{className:"flex flex-col gap-2 h-full",children:[e.jsx("textarea",{value:n,onChange:d=>{a(d.target.value),o(!0)},className:"flex-1 min-h-[400px] p-3 text-xs font-mono bg-[#1a1a1a] border border-[#3d3d3d] rounded-lg text-gray-300 outline-none focus:border-[#D7FF63]/50 resize-none leading-relaxed",spellCheck:!1}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:i,disabled:!l,className:`px-4 py-1.5 text-xs rounded-md font-medium transition-colors cursor-pointer ${l?"text-[#1e1e1e] bg-[#D7FF63] hover:bg-[#D7FF63]/80":"text-gray-500 bg-[#333] cursor-not-allowed"}`,children:"Save"}),l&&e.jsx("span",{className:"text-[10px] text-gray-500",children:"Unsaved changes"})]})]})}function Xa({onClose:t}){return e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx($e,{prompt:`# Edit Design System
|
|
104
104
|
|
|
105
105
|
You are helping the user edit their design system file at \`.codeyam/design-system.md\`.
|
|
106
106
|
|
|
@@ -111,7 +111,7 @@ Read the current design system file first, then ask the user what they'd like to
|
|
|
111
111
|
- Adding or removing theme modes (light/dark)
|
|
112
112
|
- Changing the overall aesthetic (minimal, bold, editorial, etc.)
|
|
113
113
|
|
|
114
|
-
After making changes, briefly summarize what was updated.`,height:500,onClose:t})})}function
|
|
114
|
+
After making changes, briefly summarize what was updated.`,height:500,onClose:t})})}function Za({onBack:t,onPreviewShowcase:s}){const[n,a]=r.useState("visual"),[l,o]=r.useState(null),[i,d]=r.useState(null),[x,g]=r.useState(!1),[b,c]=r.useState(!1),y=r.useCallback(()=>{fetch("/api/editor-design-system").then(p=>p.json()).then(p=>{p.exists&&p.content&&(o(p.content),d(Zt(p.content)))}).catch(()=>{})},[]);r.useEffect(()=>{y()},[y]),r.useEffect(()=>{if(n!=="claude"||!b)return;const p=setInterval(y,3e3);return()=>clearInterval(p)},[n,b,y]);const M=r.useCallback(p=>{g(!0),o(p),d(Zt(p)),fetch("/api/editor-design-system",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:p})}).then(()=>{s()}).catch(()=>{}).finally(()=>g(!1))},[s]);if(!l||!i)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsx("span",{className:"text-sm text-gray-500",children:"Loading design system..."})});const D=[{id:"visual",label:"Visual"},{id:"markdown",label:"Markdown"},{id:"claude",label:"Claude"}];return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:i.name}),i.description&&e.jsx("p",{className:"text-xs text-gray-500 m-0 mt-1 max-w-md",children:i.description})]}),e.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:[e.jsxs("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:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Preview Components"]})]}),e.jsx("div",{className:"flex gap-1 bg-[#222] rounded-lg p-0.5 w-fit border border-[#333]",children:D.map(p=>e.jsx("button",{type:"button",onClick:()=>{a(p.id),p.id==="claude"&&c(!0)},className:`px-3 py-1 text-xs rounded-md transition-colors cursor-pointer border-none ${n===p.id?"bg-[#3a3a3a] text-white font-medium":"bg-transparent text-gray-500 hover:text-gray-300"}`,children:p.label},p.id))}),e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-4",children:[n==="visual"&&e.jsx(qa,{designSystem:i,rawMarkdown:l,onSave:M}),n==="markdown"&&e.jsx(Qa,{content:l,onSave:M}),n==="claude"&&b&&e.jsx(Xa,{onClose:()=>{c(!1),y()}}),n==="claude"&&!b&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Use Claude to make design system changes with natural language."}),e.jsx("button",{type:"button",onClick:()=>c(!0),className:"px-4 py-2 text-xs text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Start Claude Chat"})]})]}),x&&e.jsx("span",{className:"text-[10px] text-gray-600",children:"Saving..."})]})})}const jt=[{key:"languages",label:"Languages"},{key:"frameworks",label:"Frameworks"},{key:"databases",label:"Databases"},{key:"services",label:"External Services"},{key:"libraries",label:"Key Libraries"},{key:"infrastructure",label:"Infrastructure"}];function eo({onBack:t}){const[s,n]=r.useState(null),[a,l]=r.useState(!1),[o,i]=r.useState(!1),[d,x]=r.useState({}),[g,b]=r.useState(!1),c=typeof window<"u"?window.location.origin:"",y=r.useCallback(()=>{fetch("/api/editor-project-info").then(P=>P.json()).then(P=>{n(P.techStack||null),l(!0)}).catch(()=>l(!0))},[]);r.useEffect(()=>{y()},[y]);const M=r.useCallback(P=>{fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({techStack:P})}).then(()=>y()).catch(()=>{})},[y]),D=()=>{x(s?JSON.parse(JSON.stringify(s)):{}),i(!0)},p=()=>{const P={};for(const{key:J}of jt){const G=d[J];G&&G.length>0&&(P[J]=G.filter(V=>V.name.trim()!==""))}M(P),i(!1)},w=P=>{x(J=>({...J,[P]:[...J[P]||[],{name:"",url:"",description:""}]}))},k=(P,J)=>{x(G=>({...G,[P]:(G[P]||[]).filter((V,S)=>S!==J)}))},I=(P,J,G,V)=>{x(S=>({...S,[P]:(S[P]||[]).map((v,B)=>B===J?{...v,[G]:V}:v)}))},_=(P,J,G)=>{const V=G.split(",").map(S=>S.trim()).filter(Boolean);x(S=>({...S,[P]:(S[P]||[]).map((v,B)=>B===J?{...v,envKeys:V}:v)}))},H=r.useMemo(()=>`# Detect and Set Up Tech Stack
|
|
115
115
|
|
|
116
116
|
You are helping the user configure their project's tech stack in CodeYam.
|
|
117
117
|
|
|
@@ -148,7 +148,7 @@ Replace the example values with what you actually detect. For each item:
|
|
|
148
148
|
- \`version\` (optional): Version number
|
|
149
149
|
- \`envKeys\` (optional): Array of environment variable names associated with this tech
|
|
150
150
|
|
|
151
|
-
Omit empty categories. After posting, briefly summarize what was detected.`,[c]),z=s&&yt.some(({key:P})=>s[P]&&s[P].length>0);return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Tech Stack"}),e.jsx("div",{className:"flex items-center gap-2",children:a&&!o&&!b&&(z?e.jsx("button",{type:"button",onClick:D,className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Edit"}):e.jsx("button",{type:"button",onClick:()=>f(!0),className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Set up with Claude"}))})]}),b&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx(Me,{prompt:H,height:400,onClose:()=>{f(!1),y()}})}),o&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("button",{type:"button",onClick:()=>{i(!1),f(!0)},className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Re-detect with Claude"}),yt.map(({key:P,label:J})=>{const G=d[P]||[];return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wider",children:J}),e.jsx("button",{type:"button",onClick:()=>w(P),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors",children:"+ Add"})]}),G.map((V,S)=>e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-2.5 mb-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:V.name,onChange:v=>A(P,S,"name",v.target.value),placeholder:"Name *",className:"flex-1 min-w-0 px-2 py-1 text-xs bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors font-medium"}),e.jsx("input",{type:"text",value:V.version||"",onChange:v=>A(P,S,"version",v.target.value),placeholder:"Version",className:"w-20 px-2 py-1 text-xs bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("button",{type:"button",onClick:()=>k(P,S),className:"text-gray-600 hover:text-red-400 bg-transparent border-none p-0.5 cursor-pointer transition-colors text-xs leading-none",children:"×"})]}),e.jsx("input",{type:"text",value:V.url||"",onChange:v=>A(P,S,"url",v.target.value),placeholder:"URL * (e.g. https://stripe.com)",className:"w-full px-2 py-1 text-[11px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"text",value:V.description||"",onChange:v=>A(P,S,"description",v.target.value),placeholder:"Description * (e.g. Payment processing and billing)",className:"w-full px-2 py-1 text-[11px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"text",value:(V.envKeys||[]).join(", "),onChange:v=>_(P,S,v.target.value),placeholder:"ENV_KEYS (comma-separated, e.g. STRIPE_SECRET_KEY, STRIPE_PUBLISHABLE_KEY)",className:"w-full px-2 py-1 text-[10px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-400 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors font-mono"})]},S)),G.length===0&&e.jsx("div",{className:"text-[11px] text-gray-600 italic py-1",children:"No items"})]},P)}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:p,className:"px-4 py-1.5 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"px-4 py-1.5 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]}),!o&&!b&&e.jsx(e.Fragment,{children:z?e.jsx("div",{className:"space-y-4",children:yt.map(({key:P,label:J})=>{const G=s[P];return!G||G.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:J}),e.jsx("div",{className:"space-y-2",children:G.map((V,S)=>e.jsxs("div",{className:"bg-[#2a2a2a] rounded-lg px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[V.url?e.jsx("a",{href:V.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-gray-200 hover:text-[#D7FF63] transition-colors",children:V.name}):e.jsx("span",{className:"text-sm font-medium text-gray-200",children:V.name}),V.version&&e.jsxs("span",{className:"text-[11px] text-gray-500",children:["v",V.version]}),V.url&&e.jsx("a",{href:V.url,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-gray-600 hover:text-gray-400 transition-colors truncate",children:V.url.replace(/^https?:\/\//,"")})]}),V.description&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:V.description}),V.envKeys&&V.envKeys.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:V.envKeys.map((v,B)=>e.jsx("span",{className:"text-[10px] text-[#D7FF63]/60 bg-[#D7FF63]/10 px-1.5 py-0.5 rounded font-mono",children:v},B))})]},S))})]},P)})}):e.jsx("div",{className:"text-xs text-gray-500 italic py-4",children:"No tech stack configured yet. Use the buttons above to set up your project's tech stack."})})]})})}function Za({hasProject:t,scenarios:s,analyzedEntities:n,allEntities:a=[],glossaryFunctions:l=[],cachedTestResults:o={},glossaryEntries:i=[],projectRoot:d,activeScenarioId:x,onScenarioSelect:b,onAnalyzedScenarioSelect:f,onSwitchToBuild:c,onSwitchToHistory:y,zoomComponent:M,focusedEntity:D,onZoomChange:p,entityImports:w,pageFilePaths:k={},projectTitle:A,projectDescription:_,migrationMode:H="none",migrationState:z,onStartMigration:P,breadcrumbItems:J=[],onReseedPreview:G,isAdmin:V=!1,roadmapView:S=!1,onRoadmapViewChange:v,designSystemView:B=!1,onDesignSystemViewChange:O,onPreviewDesignSystem:Y,techStackView:Z=!1,onTechStackViewChange:E,buildIdle:U=!1,onScreenshotClick:m,onNavigateToComponent:C}){const{pageGroups:g,componentGroups:T}=r.useMemo(()=>Zt(s),[s]),j=r.useMemo(()=>mr(g,T),[g,T]),$=r.useMemo(()=>new Set(n.map(R=>R.sha)),[n]),I=r.useMemo(()=>Zn(w||{}),[w]),ee=r.useCallback(R=>ea(R,$,a,I),[$,a,I]),K=r.useMemo(()=>{const R=new Map;for(const q of a)R.set(q.sha,q.name);return R},[a]),re=r.useMemo(()=>ta(g,T,j,ee),[g,T,j,ee]),me=r.useMemo(()=>n.filter(R=>R.entityType==="visual").sort((R,q)=>R.name.localeCompare(q.name)),[n]),[se,pe]=r.useState(()=>{try{return localStorage.getItem("codeyam-app-banner-dismissed")==="true"}catch{return!1}}),he=r.useCallback(()=>{pe(!0);try{localStorage.setItem("codeyam-app-banner-dismissed","true")}catch{}},[]),[ge,L]=r.useState(""),[xe,ie]=r.useState(()=>new Set),de=r.useRef(null),ne=r.useRef(0),N=r.useCallback(()=>{de.current&&(ne.current=de.current.scrollTop)},[]);r.useEffect(()=>{de.current&&ne.current>0&&(de.current.scrollTop=ne.current)});const Q=(D==null?void 0:D.sha)??"overview";if(!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:c,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(H==="candidate")return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-5 px-8 text-center max-w-[420px]",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Migrate Your Project"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:"It looks like you have an existing project. Claude can survey your codebase and systematically migrate it — deconstructing pages into clean components, extracting functions with tests, and creating scenarios. One page per session."}),e.jsx("button",{onClick:P,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Get Started"}),e.jsx("button",{onClick:c,className:"text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none p-0 cursor-pointer underline",children:"Skip — build a new feature instead"})]})});if(H==="active"&&z){const R=z.pages||[],q=R.filter(oe=>oe.status==="complete").length,te=R.length,ae=te>0?Math.round(q/te*100):0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-auto p-4 font-['IBM_Plex_Sans']",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0 mb-3",children:"Project Migration"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsxs("span",{className:"text-xs text-gray-400",children:[q,"/",te," pages (",ae,"%)"]})}),e.jsx("div",{className:"w-full h-1.5 bg-[#2d2d2d] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#005c75] rounded-full transition-all",style:{width:`${ae}%`}})})]}),e.jsx("div",{className:"space-y-1.5",children:R.map((oe,we)=>{const Pe=oe.status==="complete"?"✓":oe.status==="in-progress"?"→":"○",St=oe.status==="complete"?"text-green-400":oe.status==="in-progress"?"text-cyan-400":"text-gray-600";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs ${St} w-3 text-center`,children:Pe}),e.jsx("span",{className:`text-xs ${oe.status==="in-progress"?"text-white font-medium":oe.status==="complete"?"text-gray-400":"text-gray-600"}`,children:oe.name}),e.jsx("span",{className:"text-[10px] text-gray-600",children:oe.route}),oe.status==="complete"&&e.jsxs("span",{className:"text-[10px] text-gray-600",children:[(oe.extractedComponents||[]).length,"c"," ",(oe.extractedFunctions||[]).length,"f"," ",oe.scenarioCount||0,"s"]})]},we)})}),(z.sharedComponents||[]).length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-xs font-medium text-gray-400 mb-1.5",children:"Shared Components"}),(z.sharedComponents||[]).map((oe,we)=>e.jsxs("div",{className:"text-[10px] text-gray-500 mb-0.5",children:[oe.name," ",e.jsxs("span",{className:"text-gray-600",children:["— used in: ",(oe.usedInPages||[]).join(", ")]})]},we))]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:c,className:"px-4 py-2 bg-[#005c75] text-white text-xs font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Continue in Chat"})})]})}return s.length>0||me.length>0?D?e.jsx(yr,{focusedEntity:D,breadcrumbItems:J,onZoomChange:p,projectRoot:d,scenarios:s,analyzedEntities:n,activeScenarioId:x,onScenarioSelect:b,onAnalyzedScenarioSelect:f,onSwitchToBuild:c,entityImports:w,glossaryFunctions:l,cachedTestResults:o,glossaryEntries:i,entityShaMap:j,componentGroups:T,visualEntities:me,isEntityComplete:ee,onReseedPreview:G}):Z?e.jsx(Xa,{onBack:()=>{E==null||E(!1),v==null||v(!0)}}):B?e.jsx(Qa,{onBack:()=>{O==null||O(!1),v==null||v(!0)},onPreviewShowcase:()=>Y==null?void 0:Y()}):V&&S?e.jsx(za,{onBack:()=>v==null?void 0:v(!1),onSwitchToBuild:c,onSwitchToHistory:y,onNavigateToDesignSystem:()=>{v==null||v(!1),O==null||O(!0)},onNavigateToTechStack:()=>{v==null||v(!1),E==null||E(!0)},expandedTasks:xe,onExpandedTasksChange:ie,buildIdle:U,onScreenshotClick:m,onZoomChange:C}):e.jsxs("div",{ref:de,onScroll:N,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:[V&&e.jsx("div",{className:"px-4 py-4 bg-[#141414] border-b border-[#2D2D2D]",children:e.jsx(Na,{onNavigateToRoadmap:()=>v==null?void 0:v(!0),onSwitchToBuild:c,buildIdle:U})}),e.jsxs("div",{className:"p-4 space-y-4 flex flex-col gap-12",children:[re.length>1&&e.jsx(na,{brokenEntities:re}),!se&&e.jsxs("div",{className:"relative border border-[#2e7d32]/40 bg-cybg rounded-lg p-4 pr-10",children:[e.jsx("button",{onClick:he,className:"absolute top-3 right-3 text-[#D7FF63] hover:text-white bg-transparent border-none cursor-pointer p-0.5",title:"Dismiss",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("p",{className:"text-sm text-white font-medium m-0 leading-snug",children:"These are all the pages in your project."}),e.jsxs("p",{className:"text-sm text-gray-400 m-0 leading-snug mt-0.5",children:["(1) Select a scenario below and switch to"," ",e.jsx("button",{type:"button",onClick:c,className:"underline text-[#D7FF63] bg-transparent border-none cursor-pointer p-0 text-sm inline hover:text-[#D7FF63]/70 transition-colors",children:"build"})," ","to change or enhance an existing page."]}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-snug mt-0.5",children:"(2) Select a page to see all of its sub-components and edit scenarios."})]}),g.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 font-['IBM_Plex_Mono']",children:[e.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider shrink-0",children:"Pages"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",style:{width:170},children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"text",placeholder:"SEARCH...",value:ge,onChange:R=>L(R.target.value),className:"w-full pl-9 pr-3 py-2 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors tracking-wider"})]}),e.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-semibold text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer shrink-0 uppercase tracking-wider",children:[e.jsx("span",{children:"+"})," New Page"]})]}),e.jsx("div",{className:"border-b border-[#2d2d2d] mt-3"}),[...g.entries()].sort(([R],[q])=>R==="Home"?-1:q==="Home"?1:R.localeCompare(q)).filter(([R])=>{if(!ge.trim())return!0;const q=j.get(R);return((q?K.get(q):void 0)||R).toLowerCase().includes(ge.trim().toLowerCase())}).map(([R,q])=>{const te=q.some(ae=>ae.id===x);return e.jsx("div",{className:"mt-2",children:j.has(R)&&ee(j.get(R))?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-1.5 py-1",children:e.jsxs("button",{onClick:()=>p(R,j.get(R)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${te?"text-[#D7FF63]":"text-gray-300"}`,children:[(()=>{const ae=j.get(R);return(ae?K.get(ae):void 0)||R})(),e.jsxs("span",{className:`font-normal text-sm ${te?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",q.length,")"]}),e.jsx("svg",{className:te?"text-[#D7FF63]/60":"text-gray-500",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(q).map(({scenario:ae,dimensionLabel:oe,screenshotPath:we,key:Pe})=>e.jsx(Nt,{scenarioId:ae.id,screenshotPath:we,updatedAt:ae.updatedAt,hasScreenshot:!!we,name:ae.name,dimensionLabel:oe,isActive:ae.id===x,onSelect:()=>b(ae,oe??void 0)},Pe))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-sm font-normal text-gray-500",children:(()=>{const ae=j.get(R);return ae&&K.get(ae)||R})()}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#E0D400",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("p",{className:"text-xs text-[#E0D400]/80 m-0 leading-relaxed",children:"Data missing for this page."}),e.jsx(br,{name:R,scenarios:q,reason:j.has(R)?"incomplete":"missing"})]})]})},R)})]})]})]},Q):e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[A?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:A}),_&&e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:_})]}):e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Your project is ready"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:"Describe what you want to build in the Chat and your pages and components will appear here."}),e.jsx("button",{onClick:c,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})})}const ir=[{key:"app",label:"Home"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"history",label:"History"}],eo=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"text-[#8E8E8E] shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function to({activeTab:t,onTabChange:s,buildIdle:n,claudeBuilding:a=!1,buildReady:l=!1,projectTitle:o,breadcrumbItems:i,onBreadcrumbNavigate:d}){const[x,b]=r.useState(!1),f=r.useRef(null);r.useEffect(()=>{if(!x)return;const y=M=>{f.current&&!f.current.contains(M.target)&&b(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[x]);const c=i&&i.length>0;return e.jsxs("div",{className:"shrink-0 z-20 @container",children:[e.jsxs("div",{className:"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:[e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("img",{src:En,alt:"CodeYam",className:"h-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-white whitespace-nowrap hidden @min-[500px]:inline",children:"CodeYam"})]}),e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),e.jsx("div",{className:"hidden @min-[350px]:flex items-center gap-1",children:ir.map(y=>e.jsxs("button",{onClick:()=>s(y.key),className:`px-2.5 py-2.5 text-sm transition-colors cursor-pointer ${t===y.key?"text-[#D7FF63] font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[y.key==="build"&&a&&e.jsx("span",{className:"mr-1 inline-flex items-center",style:{verticalAlign:"middle"},children:e.jsx(wt,{color:"#5ce0d2",dotSize:2})}),y.key==="build"&&n&&!a&&t!=="build"&&e.jsx("span",{className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),y.label,y.key==="build"&&l&&!a&&!n&&e.jsx("span",{className:"ml-1 inline-block w-2 h-2 rounded-full bg-[#D7FF63]"})]},y.key))})]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>s("settings"),className:`hidden @min-[350px]:block p-1.5 rounded-md transition-colors cursor-pointer ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white"}`,title:"Settings",children:e.jsxs("svg",{width:"16",height:"16",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"})]})}),e.jsxs("div",{className:"@min-[350px]:hidden relative",ref:f,children:[e.jsx("button",{onClick:()=>b(!x),className:"p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white",title:"Menu",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),x&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-[#2d2d2d] border border-[#3d3d3d] rounded-lg shadow-lg py-1 min-w-[140px] z-50",children:[ir.map(y=>e.jsxs("button",{onClick:()=>{s(y.key),b(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors cursor-pointer bg-transparent border-none ${t===y.key?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white hover:bg-[#3d3d3d]"}`,children:[y.key==="build"&&a&&e.jsx("span",{className:"mr-1 inline-flex items-center",style:{verticalAlign:"middle"},children:e.jsx(wt,{color:"#5ce0d2",dotSize:2})}),y.key==="build"&&n&&!a&&t!=="build"&&e.jsx("span",{className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),y.label]},y.key)),e.jsx("div",{className:"border-t border-[#3d3d3d] my-1"}),e.jsx("button",{onClick:()=>{s("settings"),b(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors cursor-pointer bg-transparent border-none ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white hover:bg-[#3d3d3d]"}`,children:"Settings"})]})]})]}),e.jsxs("div",{className:`bg-[#161616] flex items-center px-4 border-b border-[#2d2d2d]${t==="build"?" hidden":""}`,style:{height:41},children:[e.jsx("nav",{className:"flex items-center gap-2 text-sm min-w-0 flex-1",children:c?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>d==null?void 0:d(),className:"text-[#8E8E8E] hover:text-white transition-colors bg-transparent border-none p-0 cursor-pointer shrink-0",children:o||"Untitled Project"}),i.slice(1).map((y,M)=>{const D=M===i.length-2;return e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(eo,{}),D?e.jsx("span",{className:"text-white truncate",children:y.name}):e.jsx("button",{type:"button",onClick:()=>d==null?void 0:d(y.componentName,y.entitySha),className:"text-[#8E8E8E] hover:text-white transition-colors bg-transparent border-none p-0 cursor-pointer truncate",children:y.name})]},y.componentName||y.name)})]}):e.jsx("span",{className:"text-[#8E8E8E]",children:o||"Untitled Project"})}),n&&t!=="build"&&e.jsxs("button",{type:"button",onClick:()=>s("build"),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg border border-[#FF8B43]/60 bg-[#2a1500] cursor-pointer transition-colors hover:bg-[#3a2000] ml-auto shrink-0",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#FF8B43] shrink-0"}),e.jsxs("span",{className:"text-sm text-[#FF8B43]",children:["Claude is waiting for you."," ",e.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]})]})]})}function so({onMouseDown:t,onDoubleClick:s,isDragging:n}){return e.jsxs("div",{className:"shrink-0 relative cursor-col-resize group",style:{width:2},onMouseDown:t,onDoubleClick:s,children:[e.jsx("div",{className:`absolute inset-0 transition-colors ${n?"bg-[#D7FF63]":"bg-[#646464] group-hover:bg-[#D7FF63]"}`}),e.jsx("div",{className:"absolute inset-y-0 -left-[5px] -right-[5px]"})]})}const lr=300,jt=150;function ro(t){const[s,n]=r.useState(null),[a,l]=r.useState(!1),o=r.useRef(0),i=r.useRef(null);r.useEffect(()=>{t.current&&n(Math.round(t.current.offsetWidth*.5))},[t]);const d=r.useCallback(()=>{var w;return((w=t.current)==null?void 0:w.offsetWidth)??(typeof window<"u"?window.innerWidth:1024)},[t]),x=r.useCallback(w=>{w.preventDefault(),l(!0)},[]),b=r.useCallback(()=>{n(Math.round(d()*.5))},[d]),f=r.useCallback(()=>{n(w=>(w&&w>0&&(i.current=w),0))},[]),c=r.useCallback(()=>{const w=i.current;i.current=null,n(w&&w>=lr?w:Math.round(d()*.5))},[d]),y=r.useCallback(()=>{n(Math.round(d()*.5))},[d]);r.useEffect(()=>{if(!a)return;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const w=A=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{var V;const _=(V=t.current)==null?void 0:V.getBoundingClientRect(),H=(_==null?void 0:_.left)??0,P=((_==null?void 0:_.width)??window.innerWidth)-jt,J=A.clientX-H,G=Math.min(Math.max(J,lr),P);n(G)})},k=A=>{var J;cancelAnimationFrame(o.current),l(!1);const _=(J=t.current)==null?void 0:J.getBoundingClientRect(),H=(_==null?void 0:_.left)??0,z=(_==null?void 0:_.width)??window.innerWidth,P=A.clientX-H;P<jt?n(0):z-P<jt&&n(z)};return document.addEventListener("mousemove",w),document.addEventListener("mouseup",k),()=>{cancelAnimationFrame(o.current),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k),document.body.style.cursor="",document.body.style.userSelect=""}},[a,t]),r.useEffect(()=>{const w=()=>{n(k=>{if(k===null||k===0)return k;const A=d();return k>=A?A:Math.min(k,A-jt)})};if(!(typeof window>"u"))return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[d]);const M=d(),D=s===0,p=s!==null&&s>=M;return{editorWidth:s,isDragging:a,isEditorCollapsed:D,isPreviewCollapsed:p,handleMouseDown:x,handleDoubleClick:b,collapseEditor:f,expandEditor:c,expandPreview:y}}function no({preview:t,viewportWidth:s,scale:n,onDismiss:a,onLoadCommit:l}){const o=s*n;return e.jsxs("div",{className:"flex flex-col items-center w-full h-full",children:[e.jsxs("div",{className:"w-full bg-[#2a2200] border-b border-amber-600/40 px-4 py-2 flex items-center justify-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-sm text-[#FFBD09]",children:"This is a snapshot from a previous version — not a live preview."}),t.commitSha&&l&&e.jsx(ao,{commitSha:t.commitSha,onLoadCommit:l}),e.jsx("button",{type:"button",onClick:a,className:"ml-2 text-gray-500 hover:text-white bg-transparent border-none cursor-pointer p-0.5 transition-colors",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})})]}),e.jsx("div",{className:"flex-1 overflow-auto flex justify-center py-6",children:e.jsx("div",{className:"rounded-lg border border-[#3d3d3d] shadow-md overflow-hidden shrink-0",style:{width:`${o}px`},children:e.jsx("img",{src:t.screenshotUrl,alt:t.scenarioName,className:"block",style:{width:`${o}px`}})})})]})}function ao({commitSha:t,onLoadCommit:s}){const[n,a]=r.useState(!1),[l,o]=r.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{a(!0),o(null),s(t).then(i=>{i.success||o(i.error||"Failed")}).catch(i=>{o(i instanceof Error?i.message:"Network error")}).finally(()=>a(!1))},disabled:n,className:"text-sm text-[#D7FF63] hover:text-[#D7FF63]/70 underline bg-transparent border-none p-0 cursor-pointer transition-colors disabled:opacity-50",children:n?"Reverting...":"Revert to this code and load this version."}),l&&e.jsx("span",{className:"text-xs text-red-400 ml-1",children:l})]})}function oo({preview:t,viewportWidth:s,viewportHeight:n,scale:a,onDismiss:l}){const o=s*a,i=n*a;return e.jsxs("div",{className:"flex flex-col items-center gap-4 w-full",style:{maxWidth:`${o}px`},children:[e.jsxs("div",{className:"text-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 m-0 font-['IBM_Plex_Sans']",children:t.scenarioName}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("p",{className:"text-sm text-amber-400/90 m-0 font-['IBM_Plex_Sans']",children:"The app is being edited - you can control the live preview when building is paused or complete."})]})]}),t.hasScreenshot?e.jsx("div",{className:"rounded-lg border-2 border-[#4d4d4d] shadow-md overflow-y-auto overflow-x-hidden shrink",style:{width:`${o}px`,maxHeight:`${i}px`},children:e.jsx(Je,{scenarioId:t.scenarioId,screenshotPath:t.screenshotPath,updatedAt:t.updatedAt,alt:t.scenarioName,imgClassName:"block w-full",className:""})}):e.jsx("div",{className:"rounded-lg border-2 border-[#4d4d4d] bg-[#1a1a1a] flex items-center justify-center w-[400px] h-[300px]",children:e.jsx("span",{className:"text-sm text-gray-500",children:"No screenshot available"})}),e.jsx("button",{onClick:l,className:"text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none cursor-pointer transition-colors shrink-0",children:"Dismiss"})]})}function io({analysisId:t,scenarioId:s,scenarioName:n,entityName:a,projectSlug:l,onStateChange:o}){const{interactiveServerUrl:i,isStarting:d,isLoading:x}=Tn({analysisId:t,scenarioId:s,scenarioName:n,entityName:a,projectSlug:l,enabled:!0});return r.useEffect(()=>{o(i,d||x)},[i,d,x,o]),null}function lo({onSaveToCurrent:t,onSaveAsNew:s,onDismiss:n,isSaving:a,scenarioName:l}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-emerald-900/60 border-b border-emerald-700/50 text-emerald-200 text-xs",children:[e.jsx("span",{className:"font-medium",children:l?e.jsxs(e.Fragment,{children:["Data modified in “",l,"”."]}):"Data modified."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:t,disabled:a,className:"px-2.5 py-0.5 bg-emerald-600 hover:bg-emerald-500 disabled:opacity-50 text-white text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:a?"Saving...":"Save to Scenario"}),e.jsx("button",{onClick:s,disabled:a,className:"px-2.5 py-0.5 bg-emerald-800 hover:bg-emerald-700 disabled:opacity-50 text-emerald-200 text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:"Save as New"}),e.jsx("button",{onClick:n,disabled:a,className:"text-emerald-400 hover:text-emerald-200 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",title:"Dismiss",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}function co({latestVersion:t}){const[s,n]=r.useState(!1);if(s)return null;const a=`npm install -g @codeyam/codeyam-cli@${t}`;return e.jsxs("div",{className:"shrink-0 w-full bg-[#D7FF63] px-4 py-1.5 flex items-center text-xs text-black font-['IBM_Plex_Sans']",children:[e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2",children:[e.jsx("span",{children:"An update to the codeyam editor is available."}),e.jsx("code",{className:"bg-[#2d2d2d] text-white font-mono text-xs px-3 py-0.5 rounded-full",children:a}),e.jsx($e,{content:a,icon:!0,iconSize:12,className:"text-black hover:text-gray-700 transition-colors"})]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"shrink-0 p-0.5 rounded text-black/60 hover:text-black hover:bg-black/10 transition-colors cursor-pointer bg-transparent border-none","aria-label":"Dismiss upgrade banner",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})})]})}function xo(t,s){return s.status==="error"?{url:null,proxyUrl:null,isStarting:!1,error:s.errorMessage||"Dev server crashed",canStartServer:t.canStartServer,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.url?{url:s.url,proxyUrl:s.proxyUrl||null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.status==="starting"?{...t,isStarting:!0,error:null,canStartServer:!0,shouldAutoStart:!1}:s.status==="stopped"?t.url?{...t,url:null,isStarting:!1,shouldAutoStart:!1}:t.autoStartAttempted?{...t,isStarting:!1,shouldAutoStart:!1}:{...t,autoStartAttempted:!0,shouldAutoStart:!0}:{...t,shouldAutoStart:!1}}function po(t){const[s,n]=r.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),a=r.useRef(s);a.current=s,r.useEffect(()=>{let i=!1,d=null;const x=async()=>{try{const b=await fetch("/api/editor-dev-server");if(i)return;const f=await b.json(),c=xo(a.current,f),{shouldAutoStart:y,...M}=c;if(n(M),y&&!(t!=null&&t.skipAutoStart))try{const D=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(i)return;D.ok?n(p=>({...p,isStarting:!0})):n(p=>({...p,canStartServer:!1}))}catch{}}catch{}};return x(),d=setInterval(()=>void x(),2e3),()=>{i=!0,d&&clearInterval(d)}},[s.url]);const l=r.useCallback(()=>{n(i=>({...i,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),o=r.useCallback(()=>{n(i=>({...i,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:s.url,proxyUrl:s.proxyUrl,isStarting:s.isStarting,error:s.error,canStartServer:s.canStartServer,retryServer:l,startServer:o}}function ho(t){const s=r.useRef(null),n=r.useRef(null);r.useEffect(()=>{if(typeof document>"u")return;n.current||(n.current=document.createElement("canvas"),n.current.width=64,n.current.height=64);const a=document.querySelector('link[rel="icon"]');if(!a)return;if(s.current||(s.current=a.href),!t){a.href=s.current;return}const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{const o=n.current,i=o.getContext("2d");i.clearRect(0,0,64,64);const d=56,x=(64-d)/2;i.drawImage(l,x,x,d,d);const b=12,f=64-b-1,c=b+1;i.beginPath(),i.arc(f,c,b,0,2*Math.PI),i.fillStyle="#ef4444",i.fill(),a.href=o.toDataURL("image/png")},l.src=s.current},[t]),r.useEffect(()=>()=>{if(typeof document>"u")return;const a=document.querySelector('link[rel="icon"]');a&&s.current&&(a.href=s.current)},[])}function Po({currentUrl:t,nextUrl:s,formMethod:n,defaultShouldRevalidate:a}){return n||t.pathname===s.pathname?a:t.pathname.startsWith("/editor")&&s.pathname.startsWith("/editor")?!1:a}const Eo=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class uo extends r.Component{constructor(){super(...arguments);As(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(n){return{error:n,errorInfo:null}}componentDidCatch(n,a){console.error("[EditorErrorBoundary] Error:",n.message),console.error("[EditorErrorBoundary] Component stack:",a.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:a})}render(){var n;return this.state.error?e.jsx("div",{className:"fixed inset-0 bg-[#1e1e1e] flex items-center justify-center p-8",children:e.jsxs("div",{className:"max-w-[600px] w-full space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 font-['IBM_Plex_Sans'] m-0",children:"Something went wrong"}),e.jsx("pre",{className:"text-xs text-gray-300 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[120px]",children:this.state.error.message}),((n=this.state.errorInfo)==null?void 0:n.componentStack)&&e.jsxs("details",{className:"text-xs text-gray-500",children:[e.jsx("summary",{className:"cursor-pointer hover:text-gray-300 transition-colors",children:"Component stack"}),e.jsx("pre",{className:"mt-2 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[200px] text-yellow-300",children:this.state.errorInfo.componentStack})]}),e.jsx("p",{className:"text-xs text-gray-500 m-0",children:"Full diagnostics are in the browser console."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-[#005c75] text-white text-sm rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Reload"})]})}):this.props.children}}const To=hn(function(){var Ls,Ms;const{projectSlug:s,projectRoot:n,hasProject:a,scenarios:l,allScenarios:o,analyzedEntities:i,allEntities:d,glossaryFunctions:x,glossaryEntries:b,entityImports:f,pageFilePaths:c,entityChangeStatus:y,modifiedFiles:M,featureName:D,userPrompt:p,projectTitle:w,projectDescription:k,defaultScreenSize:A,screenSizes:_,appFormats:H,editorStep:z,editorStepLabel:P,claudeSessionId:J,focusedEntitySha:G,newerEntitySha:V,focusedEntity:S,migrationMode:v,migrationState:B,cachedTestResults:O,providerSwitch:Y,currentProvider:Z}=un(),E=mn("root"),U=(E==null?void 0:E.npmUpdate)??null,m=(E==null?void 0:E.isAdmin)??!1,[C,g]=gn(),T=fn(),j=r.useRef(null),$=r.useRef(null),I=r.useRef(null),ee=r.useRef(null),[K,re]=r.useState(G),[me,se]=r.useState(!1),[pe,he]=r.useState(!1),[ge,L]=r.useState(!1),[xe,ie]=r.useState(0);r.useEffect(()=>{re(G)},[G]),r.useEffect(()=>{const u=F=>{const W=F.target;(W.tagName==="BUTTON"||W.closest("button"))&&(W.closest("button")??W).blur()};return document.addEventListener("mouseup",u),()=>document.removeEventListener("mouseup",u)},[]);const de=r.useMemo(()=>Os(K,d),[K,d,o]),ne=(de==null?void 0:de.displayName)??void 0,N=C.get("scenario")||((Ls=ut(o))==null?void 0:Ls.id)||void 0,[Q,h]=r.useState(()=>ne?[ne]:[]),R=r.useRef(null),q=r.useRef([]),te=r.useRef(null);r.useEffect(()=>{var ce;const u=N||((ce=ut(o))==null?void 0:ce.id);if(!Nn(u,R.current))return;const F=o.find(ue=>ue.id===u);if(!F)return;R.current=u;const W=zt(F,q.current,te.current);W&&Ae(W);const X=et(F.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:X,scenarioId:F.id,scenarioName:F.name,scenarioType:F.type})}).catch(()=>{})},[N,o]),r.useEffect(()=>{const u=new BroadcastChannel("codeyam-editor");return u.onmessage=F=>{var W;if(((W=F.data)==null?void 0:W.type)==="switch-scenario"&&F.data.scenarioId){const X=F.data.scenarioId,ce=o.find(Ge=>Ge.id===X);if(!ce)return;R.current=X;const ue=new URLSearchParams(C);ue.set("scenario",X),ue.delete("zoom"),g(ue),Ct(null),ot(null),Ee(null),Ce(!0);const Fe=et(ce.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:Fe,scenarioId:X,scenarioType:ce.type})}).then(()=>{ye(!1),_e(Ge=>Ge+1)}).catch(()=>{Ce(!1)})}},()=>u.close()},[C,g,o]),r.useEffect(()=>{if(C.get("ref")!=="link"||!N)return;const u=new BroadcastChannel("codeyam-editor");u.postMessage({type:"switch-scenario",scenarioId:N}),u.close(),window.close()},[]);const{devServerUrl:ae,proxyUrl:oe,isStarting:we,error:Pe,canStartServer:St,retryServer:vr,startServer:Nr}=po({skipAutoStart:v==="candidate"||v==="active"}),[at,ye]=r.useState(!1),[be,Ct]=r.useState(null),[ts,ot]=r.useState(null),[Ft,ss]=r.useState(!1),[Ke,Ee]=r.useState(null),[it,Ie]=r.useState(null),wr=r.useCallback(async u=>{const W=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:u})})).json();return W.success&&(Ee(null),ye(!1)),W},[]),kr=r.useCallback((u,F)=>{ot(W=>(u&&u!==W&&ye(!1),u)),!F&&u&&ye(!0),ss(F)},[]),Dt=r.useCallback(u=>{Ee(null),Ct(W=>(W&&W.analysisId===u.analysisId||(ot(null),_e(ce=>ce+1)),u)),ss(!0),ye(!1);const F=new URLSearchParams(C);F.delete("scenario"),F.delete("zoom"),g(F)},[C,g]),[le,Ae]=r.useState(A?{name:A.name,width:A.width,height:A.height}:{name:"Desktop",width:1440,height:900}),[rs,ns]=r.useState(!1),[je,as]=r.useState(!1),Sr=(H==null?void 0:H.includes("mobile-app"))??!1,os=A?{name:A.name,width:A.width,height:A.height}:null;te.current=os;const is=bn(),fe=r.useMemo(()=>{const u=is.pathname.split("/").filter(Boolean),F=u[u.length-1];return F==="build"||F==="history"||F==="settings"?F:F==="structure"?"data":"app"},[is.pathname]),ve=r.useCallback(u=>{re(null),h([]),se(!1);const F=u==="app"?"":`/${u==="data"?"structure":u}`,W=C.get("scenario"),X=W?`?scenario=${W}`:"";T(`/editor${F}${X}`)},[T,C]),Pt=r.useCallback(()=>{ve("build"),Ye(!0)},[ve]),Cr=r.useCallback(()=>{ve("history")},[ve]),Fr=r.useCallback(()=>{ve("build"),Ye(!0),setTimeout(()=>{var u;(u=j.current)==null||u.sendInput("codeyam editor migrate")},300)},[ve]),[Dr,Ye]=r.useState(fe==="build"),qe=!!(D&&z),Qe=z!=null&&z<=1,[Re,lt]=r.useState(Y&&qe&&!Qe?"provider-switch":qe&&!Qe?"pending":qe&&Qe?"fresh":"no-session"),ls=r.useRef(!1);r.useEffect(()=>{(Re==="pending"||Re==="provider-switch")&&!ls.current&&(ls.current=!0,ve("build"),Ye(!0))},[Re,ve]);const cs=r.useRef(!1);r.useEffect(()=>{qe&&Qe&&!cs.current&&(cs.current=!0,fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}))},[qe,Qe]);const Pr=r.useCallback(()=>{lt("continue")},[]),Er=r.useCallback(()=>{fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),lt("fresh")},[]),Tr=r.useCallback(async()=>{await fetch("/api/editor-handoff",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"accept"})}).catch(()=>{}),await fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear-session-id"})}).catch(()=>{}),lt("fresh")},[]),Lr=r.useCallback(async()=>{await fetch("/api/editor-handoff",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"dismiss"})}).catch(()=>{}),await fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),lt("fresh")},[]),[Mr,Et]=r.useState("none"),$r=r.useCallback(()=>{Et("choosing")},[]),Ir=r.useCallback(()=>{var u;fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),Et("none"),(u=j.current)==null||u.sendInput("/clear"),setTimeout(()=>{var F;(F=j.current)==null||F.sendInput("/codeyam-editor")},500)},[]),Ar=r.useCallback(()=>{Et("none")},[]),[Tt,Lt]=r.useState(!1),[mo,Rr]=r.useState(!1),ds=r.useRef(!1),ct=r.useRef(0),Or=r.useRef(!1),_r=r.useCallback(u=>{Lt(u),u||(Or.current=!0),u&&!ds.current&&(Rr(!1),ct.current=Date.now()),u||(ct.current=0),ds.current=u},[]),[ke,Br]=r.useState(!1),Mt=r.useRef(!1),Wr=r.useCallback(u=>{u!==Mt.current&&(console.log("[Editor] claudeBuilding: %s → %s",Mt.current,u),Mt.current=u,Br(u))},[]);ho(Tt);const xs=r.useRef(ke);r.useEffect(()=>{var F;const u=xs.current&&!ke;if(xs.current=ke,!ke)if(u){const W=C.get("scenario")||((F=ut(o))==null?void 0:F.id),X=o.find(ce=>ce.id===W);if(X){console.log("[Editor] Building stopped, loading live preview for: %s",X.name),Ie(null);const ce=et(X.name);R.current=X.id,Ce(!0),Be(!1),ye(!1),fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:ce,scenarioId:X.id,scenarioType:X.type,skipBroadcast:!0})}).then(()=>{_e(ue=>ue+1)}).catch(()=>{Ce(!1),ye(!0)})}else Ie(null)}else Ie(null)},[ke,C,o]);const{editorWidth:ps,isDragging:hs,isEditorCollapsed:Te,isPreviewCollapsed:$t,handleMouseDown:Hr,handleDoubleClick:Ur,collapseEditor:zr,expandEditor:us,expandPreview:Vr}=ro(ee),[It,ms]=r.useState(!1),Gr=r.useCallback(()=>{ms(!0),ve("build"),Ye(!0)},[ve]),gs=r.useCallback(()=>{ms(!1)},[]),Jr=r.useCallback(u=>{Ae(u),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:u,skipBroadcast:!0})})},[]),[fs,bs]=r.useState(wn);r.useEffect(()=>{const u=kn();bs(u),u.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const Kr=r.useCallback(u=>{bs(u),Sn(u)},[]);r.useEffect(()=>{if(fe==="build"){Lt(!1);const u=setTimeout(()=>{var F,W;(F=j.current)==null||F.scrollToBottom(),(W=j.current)==null||W.focus()},50);return()=>clearTimeout(u)}},[fe]),r.useEffect(()=>{function u(){!document.hidden&&fe==="build"&&Lt(!1)}return document.addEventListener("visibilitychange",u),()=>document.removeEventListener("visibilitychange",u)},[fe]);const[Le,Yr]=r.useState(null);r.useEffect(()=>{const u=I.current;if(!u)return;const F=new ResizeObserver(W=>{const X=W[0];X&&Yr({width:X.contentRect.width,height:X.contentRect.height})});return F.observe(u),()=>F.disconnect()},[]);const Xe=Sr&&!je&&(le.height??900)>le.width,Se=r.useMemo(()=>Le?Xe?Rs(Le,{width:le.width+mt.width,height:(le.height??900)+mt.height}):Rs(Le,le):1,[Le,le,Xe]),[Oe,_e]=r.useState(0),[ys,At]=r.useState(null),[dt,Ce]=r.useState(!1),xt=r.useRef(!1),[qr,Be]=r.useState(!1),[Qr,js]=r.useState(!1),Rt=r.useRef(0);r.useEffect(()=>{Oe>0&&(Rt.current=Date.now()+3e3)},[Oe]);const Xr=r.useCallback(()=>{if(Date.now()<Rt.current)return;const u=ct.current;u===0||Date.now()-u<5e3||Be(!0)},[]);r.useEffect(()=>{const u=F=>{var W;if(((W=F.data)==null?void 0:W.type)==="codeyam-localstorage-changed"){if(Date.now()<Rt.current)return;const X=ct.current;if(X===0||Date.now()-X<5e3)return;Be(!0)}};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[]);const vs=r.useCallback(async u=>{js(!0);try{let F;const W=$.current;W!=null&&W.contentWindow&&(F=await new Promise(ue=>{const Fe=setTimeout(()=>ue(void 0),2e3),Ge=$s=>{var Is;((Is=$s.data)==null?void 0:Is.type)==="codeyam-localstorage-state"&&(clearTimeout(Fe),window.removeEventListener("message",Ge),ue($s.data.data))};window.addEventListener("message",Ge),W.contentWindow.postMessage({type:"codeyam-get-localstorage"},"*")}));const ce=await(await fetch("/api/editor-save-seed-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:u,localStorage:F})})).json();ce.success?Be(!1):console.error("[editor] Save seed state failed:",ce.error)}catch(F){console.error("[editor] Save seed state error:",F)}finally{js(!1)}},[]),Zr=r.useCallback((u,F)=>{if(At(u||null),F){const W=new URLSearchParams(C);W.set("scenario",F),R.current=F,g(W);const X=o.find(ce=>ce.id===F);if(X){const ce=zt(X,q.current,te.current);ce&&Ae(ce)}}Ee(null),ye(!1),_e(W=>W+1)},[C,g,o]),{customSizes:Ot,addCustomSize:en,removeCustomSize:tn}=jn(s),Ze=r.useMemo(()=>pr(_,H),[_,H]),pt=r.useMemo(()=>[...Ze,...Ot],[Ze,Ot]);q.current=pt;const We=r.useMemo(()=>{const u=new Map;for(const F of d){u.set(F.name,F.sha);const W=nt(rt(F.filePath));W!==F.name&&u.set(W,F.sha)}return u},[d]),Ns=r.useMemo(()=>{const u=new Map;for(const F of d)u.set(F.sha,F.name);return u},[d]),ws=r.useMemo(()=>{const u=[{name:"App"}];me&&u.push({name:"Roadmap"}),pe&&u.push({name:"Design System"}),ge&&u.push({name:"Tech Stack"});for(const F of Q){const W=We.get(F),X=W?Ns.get(W):void 0;u.push({name:X||F,componentName:F,entitySha:W})}return u},[Q,We,Ns,me,pe,ge]),{pageGroups:ks,componentGroups:_t}=r.useMemo(()=>Zt(o),[o]),He=r.useMemo(()=>mr(ks,_t),[ks,_t]),[sn,Ss]=r.useState("application"),[Ue,ht]=r.useState([]),[Bt,Wt]=r.useState(null),Cs=r.useMemo(()=>Bt?Os(Bt,d):null,[Bt,d,o]),Fs=r.useMemo(()=>{const u=[{name:"App"}];for(const F of Ue)u.push({name:F,componentName:F,entitySha:We.get(F)});return u},[Ue,We]),Ht=r.useCallback((u,F)=>{if(!u){ht([]),Wt(null);return}const W=F||He.get(u);if(!W)return;const X=Ue.indexOf(u);X>=0?ht(Ue.slice(0,X+1)):ht([...Ue,u]),Wt(W)},[Ue,He]),rn=r.useCallback((u,F)=>{if(!u)return;const W=F||We.get(u)||He.get(u);ve("data"),Ss("components"),ht([u]),W&&Wt(W)},[We,He]),Ds=r.useCallback((u,F)=>{if(!u){h([]),re(null);const ue=C.get("scenario"),Fe=ue?`?scenario=${ue}`:"";T(`/editor${Fe}`);return}if(!F){console.error(`[editor] No entity SHA for "${u}" — entity missing from database`);return}const W=Q.indexOf(u);W>=0?h(Q.slice(0,W+1)):h([...Q,u]);const X=o.find(ue=>ue.entitySha===F);re(F);const ce=X?`?scenario=${X.id}`:"";T(`/editor/entity/${F}${ce}`)},[T,o,Q,C]),Ps=r.useCallback(u=>{Ce(!0),xt.current=!0,Be(!1),ye(!1);const F=et(u.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:F,scenarioId:u.id,scenarioType:u.type,skipBroadcast:!0})}).then(()=>{xt.current=!1,_e(W=>W+1)}).catch(()=>{xt.current=!1,Ce(!1),ye(!0)})},[]),ze=r.useCallback((u,F)=>{console.log("[Editor] Scenario selected: %s dimension=%s (claudeBuilding=%s)",u.name,F??"default",ke),Ct(null),ot(null),Ee(null),At(null);let W=null;if(F&&(_!=null&&_[F])){const ce=_[F],ue=pt.find(Fe=>Fe.width===ce.width&&Fe.height===ce.height);W={name:(ue==null?void 0:ue.name)||F,...ce}}W||(W=zt(u,pt,os)),W&&Ae(W),R.current=u.id;const X=new URLSearchParams(C);X.set("scenario",u.id),g(X),ke?Ie({scenarioId:u.id,scenarioName:u.name,updatedAt:u.updatedAt,hasScreenshot:!!u.screenshotPath,screenshotPath:u.screenshotPath}):(Ie(null),Ps(u))},[C,g,pt,_,ke,Ps]),nn=r.useCallback(()=>{const u=N;if(!u)return;const F=o.find(X=>X.id===u);if(!F)return;const W=et(F.name);ye(!1),fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:W,scenarioId:F.id,scenarioType:F.type})}).then(()=>{_e(X=>X+1)})},[N,o]),Es=r.useCallback(u=>{if(!u.commitSha){const F=o.find(W=>W.name===u.scenarioName);if(F){ze(F);return}}Ee(u)},[o,ze]),an=u=>{const F={name:u.name,width:u.width,height:u.height};Ae(F),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:F,skipBroadcast:!0})})},on=(u,F,W)=>{en(u,F,W)},ln=u=>{Ae(u),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:u,skipBroadcast:!0})})};r.useEffect(()=>{const u=F=>{var W;if(((W=F.data)==null?void 0:W.type)==="codeyam-preview-ready"&&!be){if(xt.current)return;ye(!0),Ce(!1)}};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[be]);const Ts=()=>{be||setTimeout(()=>{ye(u=>(u||Ce(!1),!0))},5e3)},Ve=r.useMemo(()=>Cn({activeAnalyzedScenario:!!be,analyzedPreviewUrl:ts,activeScenarioId:N||null,scenarios:o,proxyUrl:oe,devServerUrl:ae,zoomComponent:ne||null}),[oe,ae,ne,N,o,be,ts]),Ut=r.useMemo(()=>{if(pe)return`/api/design-system-showcase?__cb=${xe}`;const u=Fn(Ve,ys);if(!u)return null;const F=u.includes("?")?"&":"?";return`${u}${F}__cb=${Oe}`},[Ve,ys,Oe,pe,xe]),cn=r.useMemo(()=>({projectSlug:s,hasProject:a,scenarioCount:l==null?void 0:l.length,allScenarioCount:o==null?void 0:o.length,analyzedEntityCount:i==null?void 0:i.length,glossaryFunctionCount:x==null?void 0:x.length,entityChangeStatusKeys:y?Object.keys(y):[],featureName:D}),[s,a,l,o,i,x,y,D]);return e.jsxs(e.Fragment,{children:[e.jsx(uo,{loaderSnapshot:cn,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[be&&e.jsx(io,{analysisId:be.analysisId,scenarioId:be.scenarioId,scenarioName:be.scenarioName,entityName:be.entityName,projectSlug:s,onStateChange:kr},be.analysisId),U&&e.jsx(co,{latestVersion:U.latestVersion}),e.jsxs("div",{ref:ee,className:"flex-1 flex min-h-0",children:[Te&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:us,title:"Expand editor",children:e.jsx("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M1 1l4 4-4 4"})})}),e.jsxs("aside",{className:"bg-[#1e1e1e] shrink-0 flex flex-col overflow-hidden",style:{...Te?{display:"none"}:ps!==null?{width:`${ps}px`}:{width:"50%"}},children:[V&&de&&e.jsxs("div",{className:"px-3 py-2 text-xs flex items-center justify-between",style:{background:"#2a1f00",borderBottom:"1px solid #3d2e00",color:"#f0c040"},children:[e.jsxs("span",{children:["Viewing an older version of"," ",e.jsx("strong",{children:de.name}),". A newer version exists."]}),e.jsx("a",{href:`/editor/entity/${V}`,className:"px-2 py-0.5 rounded text-xs",style:{background:"#3d2e00",color:"#f0c040",textDecoration:"none"},children:"View latest"})]}),e.jsx(to,{activeTab:fe,onTabChange:u=>{ve(u),u==="build"&&Ye(!0),fetch("/api/telemetry-page-view",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({route:`/editor/${u}`})}).catch(()=>{})},buildIdle:Tt,claudeBuilding:ke,buildReady:z==null||z>=18,projectTitle:w,breadcrumbItems:fe==="data"?Fs:ws,onBreadcrumbNavigate:fe==="data"?Ht:Ds}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[Dr&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:fe==="build"?"visible":"hidden"},children:[e.jsx(Vn,{projectTitle:w,featureName:D,editorStep:z,editorStepLabel:P,migrationMode:v}),e.jsx("div",{className:"flex-1 min-h-0",style:It?{flex:"1 1 50%"}:void 0,children:Re==="provider-switch"&&Y?e.jsx(An,{from:Y.from,to:Y.to,lastStep:Y.lastStep,lastStepLabel:Y.lastStepLabel,handoffSummary:Y.handoffSummary,featureName:D,onContinue:()=>void Tr(),onStartFresh:()=>void Lr()}):Re==="pending"?e.jsx(Rn,{featureName:D,editorStep:z,editorStepLabel:P,onContinue:Pr,onStartFresh:Er}):e.jsxs("div",{className:"relative h-full",children:[e.jsx(Dn,{ref:j,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:Zr,onShowResults:Gr,onHideResults:gs,onSetViewport:Jr,onDataMutationForwarded:Xr,onFeatureComplete:$r,editorMode:!0,onIdleChange:_r,onBuildingChange:Wr,notificationSettings:fs,buildTabActive:fe==="build",claudeStartMode:Re==="continue"?"resume":"fresh",claudeSessionId:J,editorStepLabel:P,resultsOpen:It}),Mr==="choosing"&&e.jsx(On,{onStartNextFeature:Ir,onContinueInSession:Ar})]})}),It&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(ra,{scenarios:l,allScenarios:o,glossaryFunctions:x,cachedTestResults:O,projectRoot:n,activeScenarioId:N,onScenarioSelect:ze,onClose:gs,entityChangeStatus:y,modifiedFiles:M,featureName:D,userPrompt:p})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:fe==="app"?"visible":"hidden"},children:e.jsx(Za,{hasProject:a,scenarios:o,analyzedEntities:i,allEntities:d,glossaryFunctions:x,cachedTestResults:O,glossaryEntries:b,projectRoot:n,activeScenarioId:N,onScenarioSelect:ze,onAnalyzedScenarioSelect:Dt,onSwitchToBuild:Pt,onSwitchToHistory:Cr,zoomComponent:ne,focusedEntity:de,onZoomChange:Ds,entityImports:f,pageFilePaths:c,projectTitle:w,projectDescription:k,breadcrumbItems:ws,migrationMode:v,migrationState:B,onStartMigration:Fr,onReseedPreview:nn,isAdmin:m,roadmapView:me,onRoadmapViewChange:se,designSystemView:pe,onDesignSystemViewChange:he,onPreviewDesignSystem:()=>{ie(u=>u+1)},techStackView:ge,onTechStackViewChange:L,buildIdle:Tt,onScreenshotClick:Es,onNavigateToComponent:rn})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:fe==="data"?"visible":"hidden"},children:Cs?e.jsx(yr,{focusedEntity:Cs,breadcrumbItems:Fs,onZoomChange:Ht,projectRoot:n,scenarios:o,analyzedEntities:[],activeScenarioId:N,onScenarioSelect:ze,onAnalyzedScenarioSelect:Dt,onSwitchToBuild:Pt,entityImports:f,glossaryFunctions:x,cachedTestResults:O,glossaryEntries:b,entityShaMap:He,componentGroups:_t,visualEntities:[],isEntityComplete:()=>!0}):e.jsx(Gn,{scenarios:o,projectRoot:n,activeScenarioId:N,onScenarioSelect:ze,zoomComponent:void 0,focusedEntity:null,onZoomChange:Ht,analyzedEntities:[],glossaryFunctions:x,cachedTestResults:O,activeAnalyzedScenarioId:be==null?void 0:be.scenarioId,onAnalyzedScenarioSelect:Dt,entityImports:f,pageFilePaths:c,onSwitchToBuild:Pt,entityShaMap:He,structureTab:sn,onStructureTabChange:Ss})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:fe==="history"?"visible":"hidden"},children:e.jsx(va,{isActive:fe==="history",onScreenshotClick:Es,glossaryFunctions:x,cachedTestResults:O})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:fe==="settings"?"visible":"hidden"},children:e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-white mb-4",children:"Settings"}),e.jsx("p",{className:"text-xs text-gray-400",children:"Settings panel coming soon."})]})})]}),e.jsx(Pn,{serverUrl:ae,isStarting:we,projectSlug:s,devServerError:Pe,onStartServer:St?Nr:void 0,notificationSettings:fs,onChangeNotificationSettings:Kr})]}),!Te&&!$t&&e.jsx(so,{onMouseDown:Hr,onDoubleClick:Ur,isDragging:hs}),$t&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:Vr,title:"Expand preview",children:e.jsx("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M5 1l-4 4 4 4"})})}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{...$t?{display:"none"}:void 0,...hs?{pointerEvents:"none"}:void 0},children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center pr-4 relative",children:[e.jsx("div",{className:"flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>{Te?(us(),setTimeout(()=>{var u;return(u=j.current)==null?void 0:u.focus()},50)):zr()},className:`p-1.5 rounded transition-colors cursor-pointer ${Te?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:Te?"Show chat":"Hide chat",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:Te?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"})]})})})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center gap-1 pointer-events-none",children:e.jsxs("div",{className:"flex items-center gap-1 pointer-events-auto",children:[Ze.map(u=>{const F=vt(u),W=F==="desktop"?"Desktop":F==="laptop"?"Laptop":F==="tablet"?"Tablet":"Mobile";return e.jsxs("button",{onClick:()=>{je&&as(!1),an(u)},className:`p-1.5 rounded transition-colors cursor-pointer ${!je&&le.name===u.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${u.name} (${u.width}×${u.height})`,children:[W==="Desktop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}),W==="Laptop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",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"})]}),W==="Tablet"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),W==="Mobile"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})]},u.name)}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>{je||ns(u=>!u)},className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors ${je?"":"cursor-pointer"} ${je||rs||!Ze.some(u=>u.name===le.name)?"text-white bg-[#555]":"text-gray-400 hover:text-gray-200 hover:bg-[#444]"}`,title:"Custom dimensions",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:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})}),e.jsx("span",{className:"text-xs font-mono",children:je&&Le?`${Math.round(Le.width)} × ${Math.round(Le.height)}`:`${le.width} × ${le.height??900}`})]}),rs&&e.jsx(vn,{currentWidth:le.width,currentHeight:le.height??900,devicePresets:Ze,customSizes:Ot,onApply:ln,onSave:on,onRemove:tn,onClose:()=>ns(!1)})]}),e.jsx("button",{onClick:()=>{as(u=>!u)},className:`p-1.5 rounded transition-colors cursor-pointer ${je?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:je?"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:je?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"})]})})}),e.jsx("button",{onClick:()=>{const u=Ut||Ve;u&&window.open(u,"_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"})]})})]})})]}),qr&&e.jsx(lo,{onSaveToCurrent:()=>void vs("overwrite"),onSaveAsNew:()=>void vs("new"),onDismiss:()=>Be(!1),isSaving:Qr,scenarioName:(Ms=o.find(u=>{var F;return u.id===(N||((F=ut(o))==null?void 0:F.id))}))==null?void 0:Ms.name}),e.jsx("div",{ref:I,className:`flex-1 flex overflow-hidden ${je||Ke?"":"items-center justify-center p-8"}`,style:je?{backgroundColor:"#fff"}:Ke?{backgroundImage:`
|
|
151
|
+
Omit empty categories. After posting, briefly summarize what was detected.`,[c]),z=s&&jt.some(({key:P})=>s[P]&&s[P].length>0);return e.jsx("div",{className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-white bg-transparent border-none p-0 cursor-pointer transition-colors",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back to Roadmap"]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Tech Stack"}),e.jsx("div",{className:"flex items-center gap-2",children:a&&!o&&!g&&(z?e.jsx("button",{type:"button",onClick:D,className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Edit"}):e.jsx("button",{type:"button",onClick:()=>b(!0),className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Set up with Claude"}))})]}),g&&e.jsx("div",{className:"border border-[#3d3d3d] rounded-lg overflow-hidden",children:e.jsx($e,{prompt:H,height:400,onClose:()=>{b(!1),y()}})}),o&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("button",{type:"button",onClick:()=>{i(!1),b(!0)},className:"px-3 py-1.5 text-[11px] font-medium text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer",children:"Re-detect with Claude"}),jt.map(({key:P,label:J})=>{const G=d[P]||[];return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wider",children:J}),e.jsx("button",{type:"button",onClick:()=>w(P),className:"text-[11px] text-[#D7FF63] hover:text-[#D7FF63]/70 bg-transparent border-none p-0 cursor-pointer transition-colors",children:"+ Add"})]}),G.map((V,S)=>e.jsxs("div",{className:"bg-[#2a2a2a] border border-[#3d3d3d] rounded-lg p-2.5 mb-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:V.name,onChange:v=>I(P,S,"name",v.target.value),placeholder:"Name *",className:"flex-1 min-w-0 px-2 py-1 text-xs bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors font-medium"}),e.jsx("input",{type:"text",value:V.version||"",onChange:v=>I(P,S,"version",v.target.value),placeholder:"Version",className:"w-20 px-2 py-1 text-xs bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-200 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("button",{type:"button",onClick:()=>k(P,S),className:"text-gray-600 hover:text-red-400 bg-transparent border-none p-0.5 cursor-pointer transition-colors text-xs leading-none",children:"×"})]}),e.jsx("input",{type:"text",value:V.url||"",onChange:v=>I(P,S,"url",v.target.value),placeholder:"URL * (e.g. https://stripe.com)",className:"w-full px-2 py-1 text-[11px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"text",value:V.description||"",onChange:v=>I(P,S,"description",v.target.value),placeholder:"Description * (e.g. Payment processing and billing)",className:"w-full px-2 py-1 text-[11px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors"}),e.jsx("input",{type:"text",value:(V.envKeys||[]).join(", "),onChange:v=>_(P,S,v.target.value),placeholder:"ENV_KEYS (comma-separated, e.g. STRIPE_SECRET_KEY, STRIPE_PUBLISHABLE_KEY)",className:"w-full px-2 py-1 text-[10px] bg-[#1e1e1e] border border-[#3d3d3d] rounded text-gray-400 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors font-mono"})]},S)),G.length===0&&e.jsx("div",{className:"text-[11px] text-gray-600 italic py-1",children:"No items"})]},P)}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:p,className:"px-4 py-1.5 text-[11px] text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer font-medium",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"px-4 py-1.5 text-[11px] text-gray-400 bg-transparent border border-[#3d3d3d] rounded-md hover:text-white hover:border-[#555] transition-colors cursor-pointer",children:"Cancel"})]})]}),!o&&!g&&e.jsx(e.Fragment,{children:z?e.jsx("div",{className:"space-y-4",children:jt.map(({key:P,label:J})=>{const G=s[P];return!G||G.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wider mb-2",children:J}),e.jsx("div",{className:"space-y-2",children:G.map((V,S)=>e.jsxs("div",{className:"bg-[#2a2a2a] rounded-lg px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[V.url?e.jsx("a",{href:V.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-gray-200 hover:text-[#D7FF63] transition-colors",children:V.name}):e.jsx("span",{className:"text-sm font-medium text-gray-200",children:V.name}),V.version&&e.jsxs("span",{className:"text-[11px] text-gray-500",children:["v",V.version]}),V.url&&e.jsx("a",{href:V.url,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-gray-600 hover:text-gray-400 transition-colors truncate",children:V.url.replace(/^https?:\/\//,"")})]}),V.description&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:V.description}),V.envKeys&&V.envKeys.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:V.envKeys.map((v,B)=>e.jsx("span",{className:"text-[10px] text-[#D7FF63]/60 bg-[#D7FF63]/10 px-1.5 py-0.5 rounded font-mono",children:v},B))})]},S))})]},P)})}):e.jsx("div",{className:"text-xs text-gray-500 italic py-4",children:"No tech stack configured yet. Use the buttons above to set up your project's tech stack."})})]})})}function to({hasProject:t,scenarios:s,analyzedEntities:n,allEntities:a=[],glossaryFunctions:l=[],cachedTestResults:o={},glossaryEntries:i=[],projectRoot:d,activeScenarioId:x,onScenarioSelect:g,onAnalyzedScenarioSelect:b,onSwitchToBuild:c,onSwitchToHistory:y,zoomComponent:M,focusedEntity:D,onZoomChange:p,entityImports:w,pageFilePaths:k={},projectTitle:I,projectDescription:_,migrationMode:H="none",migrationState:z,onStartMigration:P,breadcrumbItems:J=[],onReseedPreview:G,isAdmin:V=!1,roadmapView:S=!1,onRoadmapViewChange:v,designSystemView:B=!1,onDesignSystemViewChange:O,onPreviewDesignSystem:Y,techStackView:Z=!1,onTechStackViewChange:E,buildIdle:U=!1,onScreenshotClick:m,onNavigateToComponent:F}){const{pageGroups:f,componentGroups:T}=r.useMemo(()=>ts(s),[s]),j=r.useMemo(()=>br(f,T),[f,T]),$=r.useMemo(()=>new Set(n.map(A=>A.sha)),[n]),R=r.useMemo(()=>ta(w||{}),[w]),ee=r.useCallback(A=>sa(A,$,a,R),[$,a,R]),K=r.useMemo(()=>{const A=new Map;for(const q of a)A.set(q.sha,q.name);return A},[a]),re=r.useMemo(()=>ra(f,T,j,ee),[f,T,j,ee]),me=r.useMemo(()=>n.filter(A=>A.entityType==="visual").sort((A,q)=>A.name.localeCompare(q.name)),[n]),[se,pe]=r.useState(()=>{try{return localStorage.getItem("codeyam-app-banner-dismissed")==="true"}catch{return!1}}),he=r.useCallback(()=>{pe(!0);try{localStorage.setItem("codeyam-app-banner-dismissed","true")}catch{}},[]),[fe,L]=r.useState(""),[xe,ie]=r.useState(()=>new Set),de=r.useRef(null),ne=r.useRef(0),N=r.useCallback(()=>{de.current&&(ne.current=de.current.scrollTop)},[]);r.useEffect(()=>{de.current&&ne.current>0&&(de.current.scrollTop=ne.current)});const Q=(D==null?void 0:D.sha)??"overview";if(!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:c,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})});if(H==="candidate")return e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-5 px-8 text-center max-w-[420px]",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Migrate Your Project"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:"It looks like you have an existing project. Claude can survey your codebase and systematically migrate it — deconstructing pages into clean components, extracting functions with tests, and creating scenarios. One page per session."}),e.jsx("button",{onClick:P,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Get Started"}),e.jsx("button",{onClick:c,className:"text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none p-0 cursor-pointer underline",children:"Skip — build a new feature instead"})]})});if(H==="active"&&z){const A=z.pages||[],q=A.filter(oe=>oe.status==="complete").length,te=A.length,ae=te>0?Math.round(q/te*100):0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-auto p-4 font-['IBM_Plex_Sans']",children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0 mb-3",children:"Project Migration"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsxs("span",{className:"text-xs text-gray-400",children:[q,"/",te," pages (",ae,"%)"]})}),e.jsx("div",{className:"w-full h-1.5 bg-[#2d2d2d] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#005c75] rounded-full transition-all",style:{width:`${ae}%`}})})]}),e.jsx("div",{className:"space-y-1.5",children:A.map((oe,Ne)=>{const Pe=oe.status==="complete"?"✓":oe.status==="in-progress"?"→":"○",Ct=oe.status==="complete"?"text-green-400":oe.status==="in-progress"?"text-cyan-400":"text-gray-600";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs ${Ct} w-3 text-center`,children:Pe}),e.jsx("span",{className:`text-xs ${oe.status==="in-progress"?"text-white font-medium":oe.status==="complete"?"text-gray-400":"text-gray-600"}`,children:oe.name}),e.jsx("span",{className:"text-[10px] text-gray-600",children:oe.route}),oe.status==="complete"&&e.jsxs("span",{className:"text-[10px] text-gray-600",children:[(oe.extractedComponents||[]).length,"c"," ",(oe.extractedFunctions||[]).length,"f"," ",oe.scenarioCount||0,"s"]})]},Ne)})}),(z.sharedComponents||[]).length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-xs font-medium text-gray-400 mb-1.5",children:"Shared Components"}),(z.sharedComponents||[]).map((oe,Ne)=>e.jsxs("div",{className:"text-[10px] text-gray-500 mb-0.5",children:[oe.name," ",e.jsxs("span",{className:"text-gray-600",children:["— used in: ",(oe.usedInPages||[]).join(", ")]})]},Ne))]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:c,className:"px-4 py-2 bg-[#005c75] text-white text-xs font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Continue in Chat"})})]})}return s.length>0||me.length>0?D?e.jsx(Nr,{focusedEntity:D,breadcrumbItems:J,onZoomChange:p,projectRoot:d,scenarios:s,analyzedEntities:n,activeScenarioId:x,onScenarioSelect:g,onAnalyzedScenarioSelect:b,onSwitchToBuild:c,entityImports:w,glossaryFunctions:l,cachedTestResults:o,glossaryEntries:i,entityShaMap:j,componentGroups:T,visualEntities:me,isEntityComplete:ee,onReseedPreview:G}):Z?e.jsx(eo,{onBack:()=>{E==null||E(!1),v==null||v(!0)}}):B?e.jsx(Za,{onBack:()=>{O==null||O(!1),v==null||v(!0)},onPreviewShowcase:()=>Y==null?void 0:Y()}):V&&S?e.jsx(Ga,{onBack:()=>v==null?void 0:v(!1),onSwitchToBuild:c,onSwitchToHistory:y,onNavigateToDesignSystem:()=>{v==null||v(!1),O==null||O(!0)},onNavigateToTechStack:()=>{v==null||v(!1),E==null||E(!0)},expandedTasks:xe,onExpandedTasksChange:ie,buildIdle:U,onScreenshotClick:m,onZoomChange:F}):e.jsxs("div",{ref:de,onScroll:N,className:"flex-1 overflow-auto font-['IBM_Plex_Sans']",children:[V&&e.jsx("div",{className:"px-4 py-4 bg-[#141414] border-b border-[#2D2D2D]",children:e.jsx(ka,{onNavigateToRoadmap:()=>v==null?void 0:v(!0),onSwitchToBuild:c,buildIdle:U})}),e.jsxs("div",{className:"p-4 space-y-4 flex flex-col gap-12",children:[re.length>1&&e.jsx(oa,{brokenEntities:re}),!se&&e.jsxs("div",{className:"relative border border-[#2e7d32]/40 bg-cybg rounded-lg p-4 pr-10",children:[e.jsx("button",{onClick:he,className:"absolute top-3 right-3 text-[#D7FF63] hover:text-white bg-transparent border-none cursor-pointer p-0.5",title:"Dismiss",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("p",{className:"text-sm text-white font-medium m-0 leading-snug",children:"These are all the pages in your project."}),e.jsxs("p",{className:"text-sm text-gray-400 m-0 leading-snug mt-0.5",children:["(1) Select a scenario below and switch to"," ",e.jsx("button",{type:"button",onClick:c,className:"underline text-[#D7FF63] bg-transparent border-none cursor-pointer p-0 text-sm inline hover:text-[#D7FF63]/70 transition-colors",children:"build"})," ","to change or enhance an existing page."]}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-snug mt-0.5",children:"(2) Select a page to see all of its sub-components and edit scenarios."})]}),f.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 font-['IBM_Plex_Mono']",children:[e.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider shrink-0",children:"Pages"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",style:{width:170},children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"text",placeholder:"SEARCH...",value:fe,onChange:A=>L(A.target.value),className:"w-full pl-9 pr-3 py-2 text-xs bg-[#2a2a2a] border border-[#3d3d3d] rounded-md text-gray-300 placeholder-gray-600 outline-none focus:border-[#D7FF63]/50 transition-colors tracking-wider"})]}),e.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-semibold text-[#1e1e1e] bg-[#D7FF63] rounded-md hover:bg-[#D7FF63]/80 transition-colors cursor-pointer shrink-0 uppercase tracking-wider",children:[e.jsx("span",{children:"+"})," New Page"]})]}),e.jsx("div",{className:"border-b border-[#2d2d2d] mt-3"}),[...f.entries()].sort(([A],[q])=>A==="Home"?-1:q==="Home"?1:A.localeCompare(q)).filter(([A])=>{if(!fe.trim())return!0;const q=j.get(A);return((q?K.get(q):void 0)||A).toLowerCase().includes(fe.trim().toLowerCase())}).map(([A,q])=>{const te=q.some(ae=>ae.id===x);return e.jsx("div",{className:"mt-2",children:j.has(A)&&ee(j.get(A))?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-1.5 py-1",children:e.jsxs("button",{onClick:()=>p(A,j.get(A)),className:`flex items-center gap-1.5 text-sm font-normal cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0 ${te?"text-[#D7FF63]":"text-gray-300"}`,children:[(()=>{const ae=j.get(A);return(ae?K.get(ae):void 0)||A})(),e.jsxs("span",{className:`font-normal text-sm ${te?"text-[#D7FF63]/60":"text-gray-500"}`,children:["(",q.length,")"]}),e.jsx("svg",{className:te?"text-[#D7FF63]/60":"text-gray-500",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:De(q).map(({scenario:ae,dimensionLabel:oe,screenshotPath:Ne,key:Pe})=>e.jsx(wt,{scenarioId:ae.id,screenshotPath:Ne,updatedAt:ae.updatedAt,hasScreenshot:!!Ne,name:ae.name,dimensionLabel:oe,isActive:ae.id===x,onSelect:()=>g(ae,oe??void 0)},Pe))})]}):e.jsxs("div",{className:"py-2",children:[e.jsx("span",{className:"text-sm font-normal text-gray-500",children:(()=>{const ae=j.get(A);return ae&&K.get(ae)||A})()}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#E0D400",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("p",{className:"text-xs text-[#E0D400]/80 m-0 leading-relaxed",children:"Data missing for this page."}),e.jsx(vr,{name:A,scenarios:q,reason:j.has(A)?"incomplete":"missing"})]})]})},A)})]})]})]},Q):e.jsx("div",{className:"flex-1 flex items-center justify-center font-['IBM_Plex_Sans']",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[I?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:I}),_&&e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:_})]}):e.jsx("h2",{className:"text-lg font-medium text-white m-0",children:"Your project is ready"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 leading-relaxed",children:"Describe what you want to build in the Chat and your pages and components will appear here."}),e.jsx("button",{onClick:c,className:"px-6 py-3 bg-[#005c75] text-white text-sm font-medium rounded-lg hover:bg-[#004d63] transition-colors cursor-pointer",children:"Start Building"})]})})}const dr=[{key:"app",label:"Home"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"history",label:"History"}],so=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"text-[#8E8E8E] shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function ro({activeTab:t,onTabChange:s,buildIdle:n,claudeBuilding:a=!1,buildReady:l=!1,projectTitle:o,breadcrumbItems:i,onBreadcrumbNavigate:d}){const[x,g]=r.useState(!1),b=r.useRef(null);r.useEffect(()=>{if(!x)return;const y=M=>{b.current&&!b.current.contains(M.target)&&g(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[x]);const c=i&&i.length>0;return e.jsxs("div",{className:"shrink-0 z-20 @container",children:[e.jsxs("div",{className:"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:[e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("img",{src:Ln,alt:"CodeYam",className:"h-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-white whitespace-nowrap hidden @min-[500px]:inline",children:"CodeYam"})]}),e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),e.jsx("div",{className:"hidden @min-[350px]:flex items-center gap-1",children:dr.map(y=>e.jsxs("button",{onClick:()=>s(y.key),className:`px-2.5 py-2.5 text-sm transition-colors cursor-pointer ${t===y.key?"text-[#D7FF63] font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[y.key==="build"&&a&&e.jsx("span",{className:"mr-1 inline-flex items-center",style:{verticalAlign:"middle"},children:e.jsx(kt,{color:"#5ce0d2",dotSize:2})}),y.key==="build"&&n&&!a&&t!=="build"&&e.jsx("span",{className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),y.label,y.key==="build"&&l&&!a&&!n&&e.jsx("span",{className:"ml-1 inline-block w-2 h-2 rounded-full bg-[#D7FF63]"})]},y.key))})]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>s("settings"),className:`hidden @min-[350px]:block p-1.5 rounded-md transition-colors cursor-pointer ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white"}`,title:"Settings",children:e.jsxs("svg",{width:"16",height:"16",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"})]})}),e.jsxs("div",{className:"@min-[350px]:hidden relative",ref:b,children:[e.jsx("button",{onClick:()=>g(!x),className:"p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white",title:"Menu",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),x&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-[#2d2d2d] border border-[#3d3d3d] rounded-lg shadow-lg py-1 min-w-[140px] z-50",children:[dr.map(y=>e.jsxs("button",{onClick:()=>{s(y.key),g(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors cursor-pointer bg-transparent border-none ${t===y.key?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white hover:bg-[#3d3d3d]"}`,children:[y.key==="build"&&a&&e.jsx("span",{className:"mr-1 inline-flex items-center",style:{verticalAlign:"middle"},children:e.jsx(kt,{color:"#5ce0d2",dotSize:2})}),y.key==="build"&&n&&!a&&t!=="build"&&e.jsx("span",{className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),y.label]},y.key)),e.jsx("div",{className:"border-t border-[#3d3d3d] my-1"}),e.jsx("button",{onClick:()=>{s("settings"),g(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors cursor-pointer bg-transparent border-none ${t==="settings"?"text-[#D7FF63]":"text-[#8E8E8E] hover:text-white hover:bg-[#3d3d3d]"}`,children:"Settings"})]})]})]}),e.jsxs("div",{className:`bg-[#161616] flex items-center px-4 border-b border-[#2d2d2d]${t==="build"?" hidden":""}`,style:{height:41},children:[e.jsx("nav",{className:"flex items-center gap-2 text-sm min-w-0 flex-1",children:c?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>d==null?void 0:d(),className:"text-[#8E8E8E] hover:text-white transition-colors bg-transparent border-none p-0 cursor-pointer shrink-0",children:o||"Untitled Project"}),i.slice(1).map((y,M)=>{const D=M===i.length-2;return e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(so,{}),D?e.jsx("span",{className:"text-white truncate",children:y.name}):e.jsx("button",{type:"button",onClick:()=>d==null?void 0:d(y.componentName,y.entitySha),className:"text-[#8E8E8E] hover:text-white transition-colors bg-transparent border-none p-0 cursor-pointer truncate",children:y.name})]},y.componentName||y.name)})]}):e.jsx("span",{className:"text-[#8E8E8E]",children:o||"Untitled Project"})}),n&&t!=="build"&&e.jsxs("button",{type:"button",onClick:()=>s("build"),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg border border-[#FF8B43]/60 bg-[#2a1500] cursor-pointer transition-colors hover:bg-[#3a2000] ml-auto shrink-0",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#FF8B43] shrink-0"}),e.jsxs("span",{className:"text-sm text-[#FF8B43]",children:["Claude is waiting for you."," ",e.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]})]})]})}function no({onMouseDown:t,onDoubleClick:s,isDragging:n}){return e.jsxs("div",{className:"shrink-0 relative cursor-col-resize group",style:{width:2},onMouseDown:t,onDoubleClick:s,children:[e.jsx("div",{className:`absolute inset-0 transition-colors ${n?"bg-[#D7FF63]":"bg-[#646464] group-hover:bg-[#D7FF63]"}`}),e.jsx("div",{className:"absolute inset-y-0 -left-[5px] -right-[5px]"})]})}const xr=300,vt=150;function ao(t){const[s,n]=r.useState(null),[a,l]=r.useState(!1),o=r.useRef(0),i=r.useRef(null);r.useEffect(()=>{t.current&&n(Math.round(t.current.offsetWidth*.5))},[t]);const d=r.useCallback(()=>{var w;return((w=t.current)==null?void 0:w.offsetWidth)??(typeof window<"u"?window.innerWidth:1024)},[t]),x=r.useCallback(w=>{w.preventDefault(),l(!0)},[]),g=r.useCallback(()=>{n(Math.round(d()*.5))},[d]),b=r.useCallback(()=>{n(w=>(w&&w>0&&(i.current=w),0))},[]),c=r.useCallback(()=>{const w=i.current;i.current=null,n(w&&w>=xr?w:Math.round(d()*.5))},[d]),y=r.useCallback(()=>{n(Math.round(d()*.5))},[d]);r.useEffect(()=>{if(!a)return;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const w=I=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{var V;const _=(V=t.current)==null?void 0:V.getBoundingClientRect(),H=(_==null?void 0:_.left)??0,P=((_==null?void 0:_.width)??window.innerWidth)-vt,J=I.clientX-H,G=Math.min(Math.max(J,xr),P);n(G)})},k=I=>{var J;cancelAnimationFrame(o.current),l(!1);const _=(J=t.current)==null?void 0:J.getBoundingClientRect(),H=(_==null?void 0:_.left)??0,z=(_==null?void 0:_.width)??window.innerWidth,P=I.clientX-H;P<vt?n(0):z-P<vt&&n(z)};return document.addEventListener("mousemove",w),document.addEventListener("mouseup",k),()=>{cancelAnimationFrame(o.current),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k),document.body.style.cursor="",document.body.style.userSelect=""}},[a,t]),r.useEffect(()=>{const w=()=>{n(k=>{if(k===null||k===0)return k;const I=d();return k>=I?I:Math.min(k,I-vt)})};if(!(typeof window>"u"))return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[d]);const M=d(),D=s===0,p=s!==null&&s>=M;return{editorWidth:s,isDragging:a,isEditorCollapsed:D,isPreviewCollapsed:p,handleMouseDown:x,handleDoubleClick:g,collapseEditor:b,expandEditor:c,expandPreview:y}}function oo({preview:t,viewportWidth:s,scale:n,onDismiss:a,onLoadCommit:l}){const o=s*n;return e.jsxs("div",{className:"flex flex-col items-center w-full h-full",children:[e.jsxs("div",{className:"w-full bg-[#2a2200] border-b border-amber-600/40 px-4 py-2 flex items-center justify-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-sm text-[#FFBD09]",children:"This is a snapshot from a previous version — not a live preview."}),t.commitSha&&l&&e.jsx(io,{commitSha:t.commitSha,onLoadCommit:l}),e.jsx("button",{type:"button",onClick:a,className:"ml-2 text-gray-500 hover:text-white bg-transparent border-none cursor-pointer p-0.5 transition-colors",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})})]}),e.jsx("div",{className:"flex-1 overflow-auto flex justify-center py-6",children:e.jsx("div",{className:"rounded-lg border border-[#3d3d3d] shadow-md overflow-hidden shrink-0",style:{width:`${o}px`},children:e.jsx("img",{src:t.screenshotUrl,alt:t.scenarioName,className:"block",style:{width:`${o}px`}})})})]})}function io({commitSha:t,onLoadCommit:s}){const[n,a]=r.useState(!1),[l,o]=r.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{a(!0),o(null),s(t).then(i=>{i.success||o(i.error||"Failed")}).catch(i=>{o(i instanceof Error?i.message:"Network error")}).finally(()=>a(!1))},disabled:n,className:"text-sm text-[#D7FF63] hover:text-[#D7FF63]/70 underline bg-transparent border-none p-0 cursor-pointer transition-colors disabled:opacity-50",children:n?"Reverting...":"Revert to this code and load this version."}),l&&e.jsx("span",{className:"text-xs text-red-400 ml-1",children:l})]})}function lo({preview:t,viewportWidth:s,viewportHeight:n,scale:a,onDismiss:l}){const o=s*a,i=n*a;return e.jsxs("div",{className:"flex flex-col items-center gap-4 w-full",style:{maxWidth:`${o}px`},children:[e.jsxs("div",{className:"text-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-200 m-0 font-['IBM_Plex_Sans']",children:t.scenarioName}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("p",{className:"text-sm text-amber-400/90 m-0 font-['IBM_Plex_Sans']",children:"The app is being edited - you can control the live preview when building is paused or complete."})]})]}),t.hasScreenshot?e.jsx("div",{className:"rounded-lg border-2 border-[#4d4d4d] shadow-md overflow-y-auto overflow-x-hidden shrink",style:{width:`${o}px`,maxHeight:`${i}px`},children:e.jsx(Je,{scenarioId:t.scenarioId,screenshotPath:t.screenshotPath,updatedAt:t.updatedAt,alt:t.scenarioName,imgClassName:"block w-full",className:""})}):e.jsx("div",{className:"rounded-lg border-2 border-[#4d4d4d] bg-[#1a1a1a] flex items-center justify-center w-[400px] h-[300px]",children:e.jsx("span",{className:"text-sm text-gray-500",children:"No screenshot available"})}),e.jsx("button",{onClick:l,className:"text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none cursor-pointer transition-colors shrink-0",children:"Dismiss"})]})}function co({analysisId:t,scenarioId:s,scenarioName:n,entityName:a,projectSlug:l,onStateChange:o}){const{interactiveServerUrl:i,isStarting:d,isLoading:x}=Mn({analysisId:t,scenarioId:s,scenarioName:n,entityName:a,projectSlug:l,enabled:!0});return r.useEffect(()=>{o(i,d||x)},[i,d,x,o]),null}function xo({onSaveToCurrent:t,onSaveAsNew:s,onDismiss:n,isSaving:a,scenarioName:l}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-emerald-900/60 border-b border-emerald-700/50 text-emerald-200 text-xs",children:[e.jsx("span",{className:"font-medium",children:l?e.jsxs(e.Fragment,{children:["Data modified in “",l,"”."]}):"Data modified."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:t,disabled:a,className:"px-2.5 py-0.5 bg-emerald-600 hover:bg-emerald-500 disabled:opacity-50 text-white text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:a?"Saving...":"Save to Scenario"}),e.jsx("button",{onClick:s,disabled:a,className:"px-2.5 py-0.5 bg-emerald-800 hover:bg-emerald-700 disabled:opacity-50 text-emerald-200 text-xs font-medium rounded transition-colors cursor-pointer disabled:cursor-not-allowed",children:"Save as New"}),e.jsx("button",{onClick:n,disabled:a,className:"text-emerald-400 hover:text-emerald-200 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",title:"Dismiss",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}function po({latestVersion:t}){const[s,n]=r.useState(!1);if(s)return null;const a=`npm install -g @codeyam/codeyam-cli@${t}`;return e.jsxs("div",{className:"shrink-0 w-full bg-[#D7FF63] px-4 py-1.5 flex items-center text-xs text-black font-['IBM_Plex_Sans']",children:[e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2",children:[e.jsx("span",{children:"An update to the codeyam editor is available."}),e.jsx("code",{className:"bg-[#2d2d2d] text-white font-mono text-xs px-3 py-0.5 rounded-full",children:a}),e.jsx(Re,{content:a,icon:!0,iconSize:12,className:"text-black hover:text-gray-700 transition-colors"})]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"shrink-0 p-0.5 rounded text-black/60 hover:text-black hover:bg-black/10 transition-colors cursor-pointer bg-transparent border-none","aria-label":"Dismiss upgrade banner",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})})]})}function ho(t,s){return s.status==="error"?{url:null,proxyUrl:null,isStarting:!1,error:s.errorMessage||"Dev server crashed",canStartServer:t.canStartServer,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.url?{url:s.url,proxyUrl:s.proxyUrl||null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:t.autoStartAttempted,shouldAutoStart:!1}:s.status==="starting"?{...t,isStarting:!0,error:null,canStartServer:!0,shouldAutoStart:!1}:s.status==="stopped"?t.url?{...t,url:null,isStarting:!1,shouldAutoStart:!1}:t.autoStartAttempted?{...t,isStarting:!1,shouldAutoStart:!1}:{...t,autoStartAttempted:!0,shouldAutoStart:!0}:{...t,shouldAutoStart:!1}}const uo=2,mo=3e4;function fo(t,s,n){return s?{shouldRestart:!1,nextState:t}:n-t.lastAutoRestartAt<mo?{shouldRestart:!1,nextState:t}:t.autoRestartCount>=uo?{shouldRestart:!1,nextState:t}:{shouldRestart:!0,nextState:{lastAutoRestartAt:n,autoRestartCount:t.autoRestartCount+1}}}function go(t){const[s,n]=r.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),a=r.useRef(s);a.current=s;const l=r.useRef({lastAutoRestartAt:0,autoRestartCount:0});r.useEffect(()=>{s.url&&(l.current={...l.current,autoRestartCount:0})},[s.url]),r.useEffect(()=>{let x=!1,g=null;const b=async()=>{try{const c=await fetch("/api/editor-dev-server");if(x)return;const y=await c.json(),M=ho(a.current,y),{shouldAutoStart:D,...p}=M;if(n(p),D&&!(t!=null&&t.skipAutoStart))try{const w=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(x)return;w.ok?n(k=>({...k,isStarting:!0})):n(k=>({...k,canStartServer:!1}))}catch{}}catch{}};return b(),g=setInterval(()=>void b(),2e3),()=>{x=!0,g&&clearInterval(g)}},[s.url]);const o=r.useCallback(()=>{n(x=>({...x,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),i=r.useCallback(()=>{n(x=>({...x,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]),d=r.useCallback(()=>{const{shouldRestart:x,nextState:g}=fo(l.current,a.current.isStarting,Date.now());return x?(l.current=g,o(),!0):!1},[o]);return{devServerUrl:s.url,proxyUrl:s.proxyUrl,isStarting:s.isStarting,error:s.error,canStartServer:s.canStartServer,retryServer:o,startServer:i,handleServerError:d}}function bo(t){const s=r.useRef(null),n=r.useRef(null);r.useEffect(()=>{if(typeof document>"u")return;n.current||(n.current=document.createElement("canvas"),n.current.width=64,n.current.height=64);const a=document.querySelector('link[rel="icon"]');if(!a)return;if(s.current||(s.current=a.href),!t){a.href=s.current;return}const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{const o=n.current,i=o.getContext("2d");i.clearRect(0,0,64,64);const d=56,x=(64-d)/2;i.drawImage(l,x,x,d,d);const g=12,b=64-g-1,c=g+1;i.beginPath(),i.arc(b,c,g,0,2*Math.PI),i.fillStyle="#ef4444",i.fill(),a.href=o.toDataURL("image/png")},l.src=s.current},[t]),r.useEffect(()=>()=>{if(typeof document>"u")return;const a=document.querySelector('link[rel="icon"]');a&&s.current&&(a.href=s.current)},[])}function $o({currentUrl:t,nextUrl:s,formMethod:n,defaultShouldRevalidate:a}){return n||t.pathname===s.pathname?a:t.pathname.startsWith("/editor")&&s.pathname.startsWith("/editor")?!1:a}const Ro=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class yo extends r.Component{constructor(){super(...arguments);_s(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(n){return{error:n,errorInfo:null}}componentDidCatch(n,a){console.error("[EditorErrorBoundary] Error:",n.message),console.error("[EditorErrorBoundary] Component stack:",a.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:a})}render(){var n;return this.state.error?e.jsx("div",{className:"fixed inset-0 bg-[#1e1e1e] flex items-center justify-center p-8",children:e.jsxs("div",{className:"max-w-[600px] w-full space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 font-['IBM_Plex_Sans'] m-0",children:"Something went wrong"}),e.jsx("pre",{className:"text-xs text-gray-300 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[120px]",children:this.state.error.message}),((n=this.state.errorInfo)==null?void 0:n.componentStack)&&e.jsxs("details",{className:"text-xs text-gray-500",children:[e.jsx("summary",{className:"cursor-pointer hover:text-gray-300 transition-colors",children:"Component stack"}),e.jsx("pre",{className:"mt-2 bg-[#2d2d2d] p-3 rounded overflow-auto max-h-[200px] text-yellow-300",children:this.state.errorInfo.componentStack})]}),e.jsx("p",{className:"text-xs text-gray-500 m-0",children:"Full diagnostics are in the browser console."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-[#005c75] text-white text-sm rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Reload"})]})}):this.props.children}}const Io=mn(function(){var Rs,Is;const{projectSlug:s,projectRoot:n,hasProject:a,scenarios:l,allScenarios:o,analyzedEntities:i,allEntities:d,glossaryFunctions:x,glossaryEntries:g,entityImports:b,pageFilePaths:c,entityChangeStatus:y,modifiedFiles:M,featureName:D,userPrompt:p,projectTitle:w,projectDescription:k,defaultScreenSize:I,screenSizes:_,appFormats:H,editorStep:z,editorStepLabel:P,claudeSessionId:J,focusedEntitySha:G,newerEntitySha:V,focusedEntity:S,migrationMode:v,migrationState:B,cachedTestResults:O,providerSwitch:Y,currentProvider:Z}=fn(),E=gn("root"),U=(E==null?void 0:E.npmUpdate)??null,m=(E==null?void 0:E.isAdmin)??!1,[F,f]=bn(),T=yn(),j=r.useRef(null),$=r.useRef(null),R=r.useRef(null),ee=r.useRef(null),[K,re]=r.useState(G),[me,se]=r.useState(!1),[pe,he]=r.useState(!1),[fe,L]=r.useState(!1),[xe,ie]=r.useState(0);r.useEffect(()=>{re(G)},[G]),r.useEffect(()=>{const h=C=>{const W=C.target;(W.tagName==="BUTTON"||W.closest("button"))&&(W.closest("button")??W).blur()};return document.addEventListener("mouseup",h),()=>document.removeEventListener("mouseup",h)},[]);const de=r.useMemo(()=>Ws(K,d),[K,d,o]),ne=(de==null?void 0:de.displayName)??void 0,N=F.get("scenario")||((Rs=mt(o))==null?void 0:Rs.id)||void 0,[Q,u]=r.useState(()=>ne?[ne]:[]),A=r.useRef(null),q=r.useRef([]),te=r.useRef(null);r.useEffect(()=>{var ce;const h=N||((ce=mt(o))==null?void 0:ce.id);if(!kn(h,A.current))return;const C=o.find(ue=>ue.id===h);if(!C)return;A.current=h;const W=Gt(C,q.current,te.current);W&&Ae(W);const X=et(C.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:X,scenarioId:C.id,scenarioName:C.name,scenarioType:C.type})}).catch(()=>{})},[N,o]),r.useEffect(()=>{const h=new BroadcastChannel("codeyam-editor");return h.onmessage=C=>{var W;if(((W=C.data)==null?void 0:W.type)==="switch-scenario"&&C.data.scenarioId){const X=C.data.scenarioId,ce=o.find(Ge=>Ge.id===X);if(!ce)return;A.current=X;const ue=new URLSearchParams(F);ue.set("scenario",X),ue.delete("zoom"),f(ue),Dt(null),ot(null),Ee(null),Ce(!0);const Fe=et(ce.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:Fe,scenarioId:X,scenarioType:ce.type})}).then(()=>{ge(!1),Me(Ge=>Ge+1)}).catch(()=>{Ce(!1)})}},()=>h.close()},[F,f,o]),r.useEffect(()=>{if(F.get("ref")!=="link"||!N)return;const h=new BroadcastChannel("codeyam-editor");h.postMessage({type:"switch-scenario",scenarioId:N}),h.close(),window.close()},[]);const{devServerUrl:ae,proxyUrl:oe,isStarting:Ne,error:Pe,canStartServer:Ct,retryServer:Ft,startServer:kr,handleServerError:rs}=go({skipAutoStart:v==="candidate"||v==="active"}),[at,ge]=r.useState(!1),[ye,Dt]=r.useState(null),[ns,ot]=r.useState(null),[Pt,as]=r.useState(!1),[Ke,Ee]=r.useState(null),[it,Ie]=r.useState(null),Sr=r.useCallback(async h=>{const W=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:h})})).json();return W.success&&(Ee(null),ge(!1)),W},[]),Cr=r.useCallback((h,C)=>{ot(W=>(h&&h!==W&&ge(!1),h)),!C&&h&&ge(!0),as(C)},[]),Et=r.useCallback(h=>{Ee(null),Dt(W=>(W&&W.analysisId===h.analysisId||(ot(null),Me(ce=>ce+1)),h)),as(!0),ge(!1);const C=new URLSearchParams(F);C.delete("scenario"),C.delete("zoom"),f(C)},[F,f]),[le,Ae]=r.useState(I?{name:I.name,width:I.width,height:I.height}:{name:"Desktop",width:1440,height:900}),[os,is]=r.useState(!1),[je,ls]=r.useState(!1),Fr=(H==null?void 0:H.includes("mobile-app"))??!1,cs=I?{name:I.name,width:I.width,height:I.height}:null;te.current=cs;const ds=jn(),be=r.useMemo(()=>{const h=ds.pathname.split("/").filter(Boolean),C=h[h.length-1];return C==="build"||C==="history"||C==="settings"?C:C==="structure"?"data":"app"},[ds.pathname]),ve=r.useCallback(h=>{re(null),u([]),se(!1);const C=h==="app"?"":`/${h==="data"?"structure":h}`,W=F.get("scenario"),X=W?`?scenario=${W}`:"";T(`/editor${C}${X}`)},[T,F]),Tt=r.useCallback(()=>{ve("build"),Ye(!0)},[ve]),Dr=r.useCallback(()=>{ve("history")},[ve]),Pr=r.useCallback(()=>{ve("build"),Ye(!0),setTimeout(()=>{var h;(h=j.current)==null||h.sendInput("codeyam editor migrate")},300)},[ve]),[Er,Ye]=r.useState(be==="build"),qe=!!(D&&z),Qe=z!=null&&z<=1,[Oe,lt]=r.useState(Y&&qe&&!Qe?"provider-switch":qe&&!Qe?"pending":qe&&Qe?"fresh":"no-session"),xs=r.useRef(!1);r.useEffect(()=>{(Oe==="pending"||Oe==="provider-switch")&&!xs.current&&(xs.current=!0,ve("build"),Ye(!0))},[Oe,ve]);const ps=r.useRef(!1);r.useEffect(()=>{qe&&Qe&&!ps.current&&(ps.current=!0,fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}))},[qe,Qe]);const Tr=r.useCallback(()=>{lt("continue")},[]),Lr=r.useCallback(()=>{fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),lt("fresh")},[]),Mr=r.useCallback(async()=>{await fetch("/api/editor-handoff",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"accept"})}).catch(()=>{}),await fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear-session-id"})}).catch(()=>{}),lt("fresh")},[]),$r=r.useCallback(async()=>{await fetch("/api/editor-handoff",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"dismiss"})}).catch(()=>{}),await fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),lt("fresh")},[]),[Rr,Lt]=r.useState("none"),Ir=r.useCallback(()=>{Lt("choosing")},[]),Ar=r.useCallback(()=>{var h;fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),Lt("none"),(h=j.current)==null||h.sendInput("/clear"),setTimeout(()=>{var C;(C=j.current)==null||C.sendInput("/codeyam-editor")},500)},[]),Or=r.useCallback(()=>{Lt("none")},[]),[Mt,$t]=r.useState(!1),[jo,_r]=r.useState(!1),hs=r.useRef(!1),ct=r.useRef(0),Br=r.useRef(!1),Wr=r.useCallback(h=>{$t(h),h||(Br.current=!0),h&&!hs.current&&(_r(!1),ct.current=Date.now()),h||(ct.current=0),hs.current=h},[]),[ke,Hr]=r.useState(!1),Rt=r.useRef(!1),Ur=r.useCallback(h=>{h!==Rt.current&&(console.log("[Editor] claudeBuilding: %s → %s",Rt.current,h),Rt.current=h,Hr(h))},[]);bo(Mt);const us=r.useRef(ke);r.useEffect(()=>{var C;const h=us.current&&!ke;if(us.current=ke,!ke)if(h){const W=F.get("scenario")||((C=mt(o))==null?void 0:C.id),X=o.find(ce=>ce.id===W);if(X){console.log("[Editor] Building stopped, loading live preview for: %s",X.name),Ie(null);const ce=et(X.name);A.current=X.id,Ce(!0),Be(!1),ge(!1),fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:ce,scenarioId:X.id,scenarioType:X.type,skipBroadcast:!0})}).then(()=>{Me(ue=>ue+1)}).catch(()=>{Ce(!1),ge(!0)})}else Ie(null)}else Ie(null)},[ke,F,o]);const{editorWidth:ms,isDragging:fs,isEditorCollapsed:Te,isPreviewCollapsed:It,handleMouseDown:zr,handleDoubleClick:Vr,collapseEditor:Gr,expandEditor:gs,expandPreview:Jr}=ao(ee),[At,bs]=r.useState(!1),Kr=r.useCallback(()=>{bs(!0),ve("build"),Ye(!0)},[ve]),ys=r.useCallback(()=>{bs(!1)},[]),Yr=r.useCallback(h=>{Ae(h),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:h,skipBroadcast:!0})})},[]),[js,vs]=r.useState(Sn);r.useEffect(()=>{const h=Cn();vs(h),h.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const qr=r.useCallback(h=>{vs(h),Fn(h)},[]);r.useEffect(()=>{if(be==="build"){$t(!1);const h=setTimeout(()=>{var C,W;(C=j.current)==null||C.scrollToBottom(),(W=j.current)==null||W.focus()},50);return()=>clearTimeout(h)}},[be]),r.useEffect(()=>{function h(){!document.hidden&&be==="build"&&$t(!1)}return document.addEventListener("visibilitychange",h),()=>document.removeEventListener("visibilitychange",h)},[be]);const[Le,Qr]=r.useState(null);r.useEffect(()=>{const h=R.current;if(!h)return;const C=new ResizeObserver(W=>{const X=W[0];X&&Qr({width:X.contentRect.width,height:X.contentRect.height})});return C.observe(h),()=>C.disconnect()},[]);const Xe=Fr&&!je&&(le.height??900)>le.width,Se=r.useMemo(()=>Le?Xe?Bs(Le,{width:le.width+ft.width,height:(le.height??900)+ft.height}):Bs(Le,le):1,[Le,le,Xe]),[_e,Me]=r.useState(0),[Ns,Ot]=r.useState(null),[dt,Ce]=r.useState(!1),xt=r.useRef(!1),[Xr,Be]=r.useState(!1),[Zr,ws]=r.useState(!1),_t=r.useRef(0);r.useEffect(()=>{_e>0&&(_t.current=Date.now()+3e3)},[_e]);const en=r.useCallback(()=>{if(Date.now()<_t.current)return;const h=ct.current;h===0||Date.now()-h<5e3||Be(!0)},[]);r.useEffect(()=>{const h=C=>{var W;if(((W=C.data)==null?void 0:W.type)==="codeyam-localstorage-changed"){if(Date.now()<_t.current)return;const X=ct.current;if(X===0||Date.now()-X<5e3)return;Be(!0)}};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[]);const ks=r.useCallback(async h=>{ws(!0);try{let C;const W=$.current;W!=null&&W.contentWindow&&(C=await new Promise(ue=>{const Fe=setTimeout(()=>ue(void 0),2e3),Ge=As=>{var Os;((Os=As.data)==null?void 0:Os.type)==="codeyam-localstorage-state"&&(clearTimeout(Fe),window.removeEventListener("message",Ge),ue(As.data.data))};window.addEventListener("message",Ge),W.contentWindow.postMessage({type:"codeyam-get-localstorage"},"*")}));const ce=await(await fetch("/api/editor-save-seed-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:h,localStorage:C})})).json();ce.success?Be(!1):console.error("[editor] Save seed state failed:",ce.error)}catch(C){console.error("[editor] Save seed state error:",C)}finally{ws(!1)}},[]),tn=r.useCallback((h,C)=>{if(Ot(h||null),C){const W=new URLSearchParams(F);W.set("scenario",C),A.current=C,f(W);const X=o.find(ce=>ce.id===C);if(X){const ce=Gt(X,q.current,te.current);ce&&Ae(ce)}}Ee(null),ge(!1),Me(W=>W+1)},[F,f,o]),{customSizes:Bt,addCustomSize:sn,removeCustomSize:rn}=Nn(s),Ze=r.useMemo(()=>mr(_,H),[_,H]),pt=r.useMemo(()=>[...Ze,...Bt],[Ze,Bt]);q.current=pt;const We=r.useMemo(()=>{const h=new Map;for(const C of d){h.set(C.name,C.sha);const W=nt(rt(C.filePath));W!==C.name&&h.set(W,C.sha)}return h},[d]),Ss=r.useMemo(()=>{const h=new Map;for(const C of d)h.set(C.sha,C.name);return h},[d]),Cs=r.useMemo(()=>{const h=[{name:"App"}];me&&h.push({name:"Roadmap"}),pe&&h.push({name:"Design System"}),fe&&h.push({name:"Tech Stack"});for(const C of Q){const W=We.get(C),X=W?Ss.get(W):void 0;h.push({name:X||C,componentName:C,entitySha:W})}return h},[Q,We,Ss,me,pe,fe]),{pageGroups:Fs,componentGroups:Wt}=r.useMemo(()=>ts(o),[o]),He=r.useMemo(()=>br(Fs,Wt),[Fs,Wt]),[nn,Ds]=r.useState("application"),[Ue,ht]=r.useState([]),[Ht,Ut]=r.useState(null),Ps=r.useMemo(()=>Ht?Ws(Ht,d):null,[Ht,d,o]),Es=r.useMemo(()=>{const h=[{name:"App"}];for(const C of Ue)h.push({name:C,componentName:C,entitySha:We.get(C)});return h},[Ue,We]),zt=r.useCallback((h,C)=>{if(!h){ht([]),Ut(null);return}const W=C||He.get(h);if(!W)return;const X=Ue.indexOf(h);X>=0?ht(Ue.slice(0,X+1)):ht([...Ue,h]),Ut(W)},[Ue,He]),an=r.useCallback((h,C)=>{if(!h)return;const W=C||We.get(h)||He.get(h);ve("data"),Ds("components"),ht([h]),W&&Ut(W)},[We,He]),Ts=r.useCallback((h,C)=>{if(!h){u([]),re(null);const ue=F.get("scenario"),Fe=ue?`?scenario=${ue}`:"";T(`/editor${Fe}`);return}if(!C){console.error(`[editor] No entity SHA for "${h}" — entity missing from database`);return}const W=Q.indexOf(h);W>=0?u(Q.slice(0,W+1)):u([...Q,h]);const X=o.find(ue=>ue.entitySha===C);re(C);const ce=X?`?scenario=${X.id}`:"";T(`/editor/entity/${C}${ce}`)},[T,o,Q,F]),Ls=r.useCallback(h=>{Ce(!0),xt.current=!0,Be(!1),ge(!1);const C=et(h.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:C,scenarioId:h.id,scenarioType:h.type,skipBroadcast:!0})}).then(()=>{xt.current=!1,Me(W=>W+1)}).catch(()=>{xt.current=!1,Ce(!1),ge(!0)})},[]),ze=r.useCallback((h,C)=>{console.log("[Editor] Scenario selected: %s dimension=%s (claudeBuilding=%s)",h.name,C??"default",ke),Dt(null),ot(null),Ee(null),Ot(null);let W=null;if(C&&(_!=null&&_[C])){const ce=_[C],ue=pt.find(Fe=>Fe.width===ce.width&&Fe.height===ce.height);W={name:(ue==null?void 0:ue.name)||C,...ce}}W||(W=Gt(h,pt,cs)),W&&Ae(W),A.current=h.id;const X=new URLSearchParams(F);X.set("scenario",h.id),f(X),ke?Ie({scenarioId:h.id,scenarioName:h.name,updatedAt:h.updatedAt,hasScreenshot:!!h.screenshotPath,screenshotPath:h.screenshotPath}):(Ie(null),Ls(h))},[F,f,pt,_,ke,Ls]),on=r.useCallback(()=>{const h=N;if(!h)return;const C=o.find(X=>X.id===h);if(!C)return;const W=et(C.name);ge(!1),fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:W,scenarioId:C.id,scenarioType:C.type})}).then(()=>{Me(X=>X+1)})},[N,o]),Ms=r.useCallback(h=>{if(!h.commitSha){const C=o.find(W=>W.name===h.scenarioName);if(C){ze(C);return}}Ee(h)},[o,ze]),ln=h=>{const C={name:h.name,width:h.width,height:h.height};Ae(C),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:C,skipBroadcast:!0})})},cn=(h,C,W)=>{sn(h,C,W)},dn=h=>{Ae(h),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:h,skipBroadcast:!0})})};r.useEffect(()=>{const h=C=>{var W;if(((W=C.data)==null?void 0:W.type)==="codeyam-preview-ready"&&!ye){if(xt.current)return;ge(!0),Ce(!1)}};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[ye]);const ut=r.useRef(!1);r.useEffect(()=>{const h=C=>{var W,X;((W=C.data)==null?void 0:W.type)==="codeyam-server-error"&&rs()&&(ge(!1),ut.current=!0),((X=C.data)==null?void 0:X.type)==="codeyam-server-error-retry"&&(ge(!1),ut.current=!0,Ft())};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[rs,Ft]),r.useEffect(()=>{ut.current&&!Ne&&ae&&(ut.current=!1,Me(h=>h+1))},[Ne,ae]);const $s=()=>{ye||setTimeout(()=>{ge(h=>(h||Ce(!1),!0))},5e3)},Ve=r.useMemo(()=>Dn({activeAnalyzedScenario:!!ye,analyzedPreviewUrl:ns,activeScenarioId:N||null,scenarios:o,proxyUrl:oe,devServerUrl:ae,zoomComponent:ne||null}),[oe,ae,ne,N,o,ye,ns]),Vt=r.useMemo(()=>{if(pe)return`/api/design-system-showcase?__cb=${xe}`;const h=Pn(Ve,Ns);if(!h)return null;const C=h.includes("?")?"&":"?";return`${h}${C}__cb=${_e}`},[Ve,Ns,_e,pe,xe]),xn=r.useMemo(()=>({projectSlug:s,hasProject:a,scenarioCount:l==null?void 0:l.length,allScenarioCount:o==null?void 0:o.length,analyzedEntityCount:i==null?void 0:i.length,glossaryFunctionCount:x==null?void 0:x.length,entityChangeStatusKeys:y?Object.keys(y):[],featureName:D}),[s,a,l,o,i,x,y,D]);return e.jsxs(e.Fragment,{children:[e.jsx(yo,{loaderSnapshot:xn,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[ye&&e.jsx(co,{analysisId:ye.analysisId,scenarioId:ye.scenarioId,scenarioName:ye.scenarioName,entityName:ye.entityName,projectSlug:s,onStateChange:Cr},ye.analysisId),U&&e.jsx(po,{latestVersion:U.latestVersion}),e.jsxs("div",{ref:ee,className:"flex-1 flex min-h-0",children:[Te&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:gs,title:"Expand editor",children:e.jsx("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M1 1l4 4-4 4"})})}),e.jsxs("aside",{className:"bg-[#1e1e1e] shrink-0 flex flex-col overflow-hidden",style:{...Te?{display:"none"}:ms!==null?{width:`${ms}px`}:{width:"50%"}},children:[V&&de&&e.jsxs("div",{className:"px-3 py-2 text-xs flex items-center justify-between",style:{background:"#2a1f00",borderBottom:"1px solid #3d2e00",color:"#f0c040"},children:[e.jsxs("span",{children:["Viewing an older version of"," ",e.jsx("strong",{children:de.name}),". A newer version exists."]}),e.jsx("a",{href:`/editor/entity/${V}`,className:"px-2 py-0.5 rounded text-xs",style:{background:"#3d2e00",color:"#f0c040",textDecoration:"none"},children:"View latest"})]}),e.jsx(ro,{activeTab:be,onTabChange:h=>{ve(h),h==="build"&&Ye(!0),fetch("/api/telemetry-page-view",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({route:`/editor/${h}`})}).catch(()=>{})},buildIdle:Mt,claudeBuilding:ke,buildReady:z==null||z>=18,projectTitle:w,breadcrumbItems:be==="data"?Es:Cs,onBreadcrumbNavigate:be==="data"?zt:Ts}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[Er&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:be==="build"?"visible":"hidden"},children:[e.jsx(Jn,{projectTitle:w,featureName:D,editorStep:z,editorStepLabel:P,migrationMode:v}),e.jsx("div",{className:"flex-1 min-h-0",style:At?{flex:"1 1 50%"}:void 0,children:Oe==="provider-switch"&&Y?e.jsx(On,{from:Y.from,to:Y.to,lastStep:Y.lastStep,lastStepLabel:Y.lastStepLabel,handoffSummary:Y.handoffSummary,featureName:D,onContinue:()=>void Mr(),onStartFresh:()=>void $r()}):Oe==="pending"?e.jsx(_n,{featureName:D,editorStep:z,editorStepLabel:P,onContinue:Tr,onStartFresh:Lr}):e.jsxs("div",{className:"relative h-full",children:[e.jsx(En,{ref:j,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:tn,onShowResults:Kr,onHideResults:ys,onSetViewport:Yr,onDataMutationForwarded:en,onFeatureComplete:Ir,editorMode:!0,onIdleChange:Wr,onBuildingChange:Ur,notificationSettings:js,buildTabActive:be==="build",claudeStartMode:Oe==="continue"?"resume":"fresh",claudeSessionId:J,editorStepLabel:P,resultsOpen:At}),Rr==="choosing"&&e.jsx(Bn,{onStartNextFeature:Ar,onContinueInSession:Or})]})}),At&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(aa,{scenarios:l,allScenarios:o,glossaryFunctions:x,cachedTestResults:O,projectRoot:n,activeScenarioId:N,onScenarioSelect:ze,onClose:ys,entityChangeStatus:y,modifiedFiles:M,featureName:D,userPrompt:p})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:be==="app"?"visible":"hidden"},children:e.jsx(to,{hasProject:a,scenarios:o,analyzedEntities:i,allEntities:d,glossaryFunctions:x,cachedTestResults:O,glossaryEntries:g,projectRoot:n,activeScenarioId:N,onScenarioSelect:ze,onAnalyzedScenarioSelect:Et,onSwitchToBuild:Tt,onSwitchToHistory:Dr,zoomComponent:ne,focusedEntity:de,onZoomChange:Ts,entityImports:b,pageFilePaths:c,projectTitle:w,projectDescription:k,breadcrumbItems:Cs,migrationMode:v,migrationState:B,onStartMigration:Pr,onReseedPreview:on,isAdmin:m,roadmapView:me,onRoadmapViewChange:se,designSystemView:pe,onDesignSystemViewChange:he,onPreviewDesignSystem:()=>{ie(h=>h+1)},techStackView:fe,onTechStackViewChange:L,buildIdle:Mt,onScreenshotClick:Ms,onNavigateToComponent:an})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:be==="data"?"visible":"hidden"},children:Ps?e.jsx(Nr,{focusedEntity:Ps,breadcrumbItems:Es,onZoomChange:zt,projectRoot:n,scenarios:o,analyzedEntities:[],activeScenarioId:N,onScenarioSelect:ze,onAnalyzedScenarioSelect:Et,onSwitchToBuild:Tt,entityImports:b,glossaryFunctions:x,cachedTestResults:O,glossaryEntries:g,entityShaMap:He,componentGroups:Wt,visualEntities:[],isEntityComplete:()=>!0}):e.jsx(Kn,{scenarios:o,projectRoot:n,activeScenarioId:N,onScenarioSelect:ze,zoomComponent:void 0,focusedEntity:null,onZoomChange:zt,analyzedEntities:[],glossaryFunctions:x,cachedTestResults:O,activeAnalyzedScenarioId:ye==null?void 0:ye.scenarioId,onAnalyzedScenarioSelect:Et,entityImports:b,pageFilePaths:c,onSwitchToBuild:Tt,entityShaMap:He,structureTab:nn,onStructureTabChange:Ds})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:be==="history"?"visible":"hidden"},children:e.jsx(wa,{isActive:be==="history",onScreenshotClick:Ms,glossaryFunctions:x,cachedTestResults:O})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:be==="settings"?"visible":"hidden"},children:e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-white mb-4",children:"Settings"}),e.jsx("p",{className:"text-xs text-gray-400",children:"Settings panel coming soon."})]})})]}),e.jsx(Tn,{serverUrl:ae,isStarting:Ne,projectSlug:s,devServerError:Pe,onStartServer:Ct?kr:void 0,notificationSettings:js,onChangeNotificationSettings:qr})]}),!Te&&!It&&e.jsx(no,{onMouseDown:zr,onDoubleClick:Vr,isDragging:fs}),It&&e.jsx("div",{className:"shrink-0 flex items-center justify-center cursor-pointer hover:bg-[#3d3d3d] transition-colors",style:{width:8,backgroundColor:"#2d2d2d"},onClick:Jr,title:"Expand preview",children:e.jsx("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",stroke:"#888",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M5 1l-4 4 4 4"})})}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{...It?{display:"none"}:void 0,...fs?{pointerEvents:"none"}:void 0},children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center pr-4 relative",children:[e.jsx("div",{className:"flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>{Te?(gs(),setTimeout(()=>{var h;return(h=j.current)==null?void 0:h.focus()},50)):Gr()},className:`p-1.5 rounded transition-colors cursor-pointer ${Te?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:Te?"Show chat":"Hide chat",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:Te?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"})]})})})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center gap-1 pointer-events-none",children:e.jsxs("div",{className:"flex items-center gap-1 pointer-events-auto",children:[Ze.map(h=>{const C=Nt(h),W=C==="desktop"?"Desktop":C==="laptop"?"Laptop":C==="tablet"?"Tablet":"Mobile";return e.jsxs("button",{onClick:()=>{je&&ls(!1),ln(h)},className:`p-1.5 rounded transition-colors cursor-pointer ${!je&&le.name===h.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${h.name} (${h.width}×${h.height})`,children:[W==="Desktop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}),W==="Laptop"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",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"})]}),W==="Tablet"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),W==="Mobile"&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:"2"}),e.jsx("path",{d:"M12 18h.01"})]})]},h.name)}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>{je||is(h=>!h)},className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors ${je?"":"cursor-pointer"} ${je||os||!Ze.some(h=>h.name===le.name)?"text-white bg-[#555]":"text-gray-400 hover:text-gray-200 hover:bg-[#444]"}`,title:"Custom dimensions",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:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})}),e.jsx("span",{className:"text-xs font-mono",children:je&&Le?`${Math.round(Le.width)} × ${Math.round(Le.height)}`:`${le.width} × ${le.height??900}`})]}),os&&e.jsx(wn,{currentWidth:le.width,currentHeight:le.height??900,devicePresets:Ze,customSizes:Bt,onApply:dn,onSave:cn,onRemove:rn,onClose:()=>is(!1)})]}),e.jsx("button",{onClick:()=>{ls(h=>!h)},className:`p-1.5 rounded transition-colors cursor-pointer ${je?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:je?"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:je?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"})]})})}),e.jsx("button",{onClick:()=>{const h=Vt||Ve;h&&window.open(h,"_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"})]})})]})})]}),Xr&&e.jsx(xo,{onSaveToCurrent:()=>void ks("overwrite"),onSaveAsNew:()=>void ks("new"),onDismiss:()=>Be(!1),isSaving:Zr,scenarioName:(Is=o.find(h=>{var C;return h.id===(N||((C=mt(o))==null?void 0:C.id))}))==null?void 0:Is.name}),e.jsx("div",{ref:R,className:`flex-1 flex overflow-hidden ${je||Ke?"":"items-center justify-center p-8"}`,style:je?{backgroundColor:"#fff"}:Ke?{backgroundImage:`
|
|
152
152
|
linear-gradient(45deg, #333 25%, transparent 25%),
|
|
153
153
|
linear-gradient(-45deg, #333 25%, transparent 25%),
|
|
154
154
|
linear-gradient(45deg, transparent 75%, #333 75%),
|
|
@@ -158,4 +158,4 @@ Omit empty categories. After posting, briefly summarize what was detected.`,[c])
|
|
|
158
158
|
linear-gradient(-45deg, #333 25%, transparent 25%),
|
|
159
159
|
linear-gradient(45deg, transparent 75%, #333 75%),
|
|
160
160
|
linear-gradient(-45deg, transparent 75%, #333 75%)
|
|
161
|
-
`,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:Ke?e.jsx(
|
|
161
|
+
`,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:Ke?e.jsx(oo,{preview:Ke,viewportWidth:le.width,viewportHeight:le.height??900,scale:Se,onDismiss:()=>Ee(null),onLoadCommit:Sr}):it?e.jsx(lo,{preview:it,viewportWidth:le.width,viewportHeight:le.height??900,scale:Se,onDismiss:()=>Ie(null)}):Ve?je?e.jsxs("div",{className:"relative w-full h-full bg-white",children:[!at&&!dt&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 bg-[#2a2a2a] rounded-lg p-8 w-[500px] h-[300px]",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Jt,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Loading Preview"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Waiting for the app to render"})]})]})}),dt&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center",style:{backgroundColor:"rgba(0, 0, 0, 0.25)",backdropFilter:"blur(1px)",transition:"opacity 200ms ease-out"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx("svg",{className:"w-6 h-6 text-white/80 animate-spin",viewBox:"0 0 24 24",fill:"none",children:e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"50 100"})}),e.jsx("span",{className:"text-white/70 text-xs font-['IBM_Plex_Sans']",children:"Switching scenario"})]})}),e.jsx("iframe",{ref:$,src:Vt||Ve,className:"w-full h-full border-none",title:"Editor preview",onLoad:$s,style:{opacity:at?1:0}},_e)]}):e.jsx("div",{style:{width:`${(Xe?le.width+ft.width:le.width)*Se}px`,height:`${(Xe?(le.height??900)+ft.height:le.height??900)*Se}px`},children:e.jsx("div",{className:"origin-top-left",style:{transform:Se<1?`scale(${Se})`:void 0},children:e.jsx(An,{width:le.width,height:le.height??900,enabled:Xe,children:e.jsxs("div",{className:"relative bg-white",style:{width:`${le.width}px`,height:`${le.height??900}px`},children:[!at&&!dt&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 bg-[#2a2a2a] rounded-lg p-8 w-[500px] h-[300px]",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Jt,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Loading Preview"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Waiting for the app to render"})]})]})}),dt&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center",style:{backgroundColor:"rgba(0, 0, 0, 0.25)",backdropFilter:"blur(1px)",transition:"opacity 200ms ease-out"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx("svg",{className:"w-6 h-6 text-white/80 animate-spin",viewBox:"0 0 24 24",fill:"none",children:e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"50 100"})}),e.jsx("span",{className:"text-white/70 text-xs font-['IBM_Plex_Sans']",children:"Switching scenario"})]})}),e.jsx("iframe",{ref:$,src:Vt||Ve,className:"w-full h-full border-none",title:"Editor preview",onLoad:$s,style:{opacity:at?1:0}},_e)]})})})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${le.width*Se}px`,height:`${(le.height??900)*Se}px`},children:Pe?e.jsxs("div",{className:"flex flex-col gap-4 text-center px-8 max-w-[600px]",children:[e.jsx("h2",{className:"text-xl font-medium text-red-400 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Dev Server Failed"}),e.jsx("pre",{className:"text-xs text-left bg-[#1e1e1e] text-gray-300 p-4 rounded overflow-auto max-h-[300px] w-full font-mono whitespace-pre-wrap",children:Pe}),e.jsx("button",{onClick:Ft,className:"mx-auto px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded hover:bg-[#004d63] transition-colors cursor-pointer",children:"Retry"})]}):Ne||Pt?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(Jt,{})}),e.jsxs("div",{className:"flex flex-col gap-3 text-center",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:Pt?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:Pt?"Loading component preview...":"Your dev server is starting up..."})]})]}):e.jsxs("div",{className:"flex flex-col gap-3 text-center px-8",children:[e.jsx("h2",{className:"text-xl font-medium text-gray-200 leading-[28px] m-0 font-['IBM_Plex_Sans']",children:"Live Preview"}),e.jsx("p",{className:"text-sm text-gray-500 leading-5 m-0 font-['IBM_Plex_Sans']",children:"Describe what you want to build in the Build tab"})]})})})]})]})]})}),e.jsx(vn,{})]})});export{Io as default,Ro as meta,$o as shouldRevalidate};
|