@codeyam/codeyam-cli 0.1.9 → 0.1.11
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 +8 -8
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +45 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +45 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +236 -76
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +1 -0
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +29 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js +18 -8
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +133 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +14 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +205 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +58 -1
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +30 -2
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +155 -1
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +5 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -1
- package/codeyam-cli/src/utils/editorApi.js +11 -5
- package/codeyam-cli/src/utils/editorApi.js.map +1 -1
- package/codeyam-cli/src/utils/editorAudit.js +34 -0
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorPreview.js +9 -4
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
- package/codeyam-cli/src/utils/editorScenarios.js +64 -9
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +34 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
- package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -1
- package/codeyam-cli/src/utils/progress.js +2 -2
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/scenariosManifest.js +82 -0
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +1 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +146 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-Bd-hxofb.js → ScenarioViewer-TSD3C211.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BsDh6TSF.js → dev.empty-Ii3inc0_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-16o0AIFV.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-7Uga8I59.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BsDXNp45.js → entity._sha._-DwCV5__E.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-BgAqUtTZ.js → entity._sha.scenarios._scenarioId.dev-BwKcai0j.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-Bmshgrij.js → entity._sha.scenarios._scenarioId.fullscreen-CHMiAog3.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-CQPR0pFR.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{manifest-65850841.js → manifest-76e7b62c.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{root-BwX8YgFb.js → root-DBjt6o04.js} +4 -4
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C-_hOl_g.js +1 -0
- package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/build/server/assets/{index-DEEQf4pi.js → index-DsZjKspK.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/init-DdqKD2p4.js +10 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CKKeWtVK.js +444 -0
- 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/idleDetector.js +73 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
- package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/server.js +46 -4
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +65 -26
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/codeyam-editor-claude.md +1 -1
- package/codeyam-cli/templates/editor-step-hook.py +3 -2
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +10 -9
- package/package.json +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +45 -0
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-PBc_6L9R.js +0 -10
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-4FzHlcNn.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/globals-B8vTTNy2.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BE43Hjti.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/init-CkWmyFY2.js +0 -10
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BHi-9O8W.js +0 -439
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-yHOVb4rc.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Dt=Object.defineProperty;var _t=(t,s,n)=>s in t?Dt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var et=(t,s,n)=>_t(t,typeof s!="symbol"?s+"":s,n);import{r as a,j as e,w as Ot,u as Ft,b as Ut}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as zt,C as Wt}from"./useCustomSizes-C-_hOl_g.js";import{g as Jt,s as Gt,r as Te,b as he,c as Ht,l as Vt,d as Kt,e as Yt,f as qt,a as Xt,T as Qt,D as Zt}from"./editorPreview-7Uga8I59.js";import{C as Ae}from"./CopyButton-BPXZwM4t.js";import{_ as es}from"./preload-helper-ckwbz45p.js";import{c as ts}from"./cy-logo-cli-DcX-ZS3p.js";import{u as ss,S as tt}from"./Spinner-Bb5uFQ5V.js";import"./copy-n2FB0_Sw.js";import"./createLucideIcon-CC6AbExI.js";import"./useLastLogLine-C14nCb1q.js";const ge=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}];function ns(t){if(!t)return ge;const s=Object.entries(t).map(([l,h])=>({name:l,width:h.width,height:h.height})),n=new Set(s.map(l=>l.name));return[...s,...ge.filter(l=>!n.has(l.name))]}function as({featureName:t,editorStep:s,editorStepLabel:n,onContinue:l,onStartFresh:h,onReview:c}){const[o,p]=a.useState("resume"),[x,k]=a.useState(0),S=a.useCallback(()=>{p("fresh-options"),k(0)},[]),y=a.useCallback(L=>{L.key==="ArrowLeft"||L.key==="ArrowRight"||L.key==="Tab"?(L.preventDefault(),k(I=>I===0?1:0)):L.key==="Enter"&&(L.preventDefault(),o==="resume"?x===0?l():S():x===0?h():c())},[o,x,l,h,c,S]);a.useEffect(()=>(window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)),[y]);const w="flex-1 px-4 py-2 text-sm rounded transition-colors cursor-pointer",M="ring-2 ring-white/50",b="bg-[#005c75] text-white font-medium hover:bg-[#004d63]",B="bg-[#3d3d3d] text-[#d4d4d4] hover:bg-[#4d4d4d]";return e.jsx("div",{className:"flex items-center justify-center h-full bg-[#1e1e1e] text-[#d4d4d4]",children:e.jsx("div",{className:"max-w-md w-full mx-4 p-6 bg-[#252526] border border-[#3d3d3d] rounded-lg",children:o==="resume"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"Resume Previous Session?"}),e.jsx("p",{className:"text-sm text-[#999] mb-4",children:"An editor session is still in progress:"}),e.jsxs("div",{className:"bg-[#1e1e1e] rounded p-3 mb-5 text-sm",children:[t&&e.jsxs("div",{className:"mb-1",children:[e.jsx("span",{className:"text-[#999]",children:"Feature:"})," ",e.jsx("span",{className:"text-white",children:t})]}),s!=null&&n&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[#999]",children:"Step:"})," ",e.jsxs("span",{className:"text-white",children:[s," (",n,")"]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:l,className:`${w} ${b} ${x===0?M:""}`,children:"Continue Session"}),e.jsx("button",{onClick:S,className:`${w} ${B} ${x===1?M:""}`,children:"Start Over"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-white",children:"What would you like to do?"}),e.jsx("p",{className:"text-sm text-[#999] mb-5",children:"The previous session will be cleared."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:h,className:`${w} ${b} ${x===0?M:""}`,children:"Build Next Feature"}),e.jsx("button",{onClick:c,className:`${w} ${B} ${x===1?M:""}`,children:"Review What's Built"})]})]})})})}function Be(t){const[s,n]=a.useState(null),[l,h]=a.useState(!1),c=a.useCallback(()=>{t&&(h(!0),fetch(`/api/editor-test-results?testFile=${encodeURIComponent(t)}`).then(o=>o.json()).then(o=>{n(o),h(!1)}).catch(()=>{n({testFilePath:t,status:"error",testCases:[],errorMessage:"Failed to fetch test results"}),h(!1)}))},[t]);return a.useEffect(()=>{t&&c()},[t,c]),{results:s,isRunning:l,runTests:c}}function te(t){if(!t||t==="/")return"Home";const s=t.split("?")[0].replace(/^\//,"");if(!s)return"Home";const n=s.split("/")[0];return n.charAt(0).toUpperCase()+n.slice(1)}function De(t){return t?t.includes("/isolated-components"):!1}function rs(t,s){return!s||Object.keys(s).length===0?t:t.filter(n=>s[n.name])}function xe({imgSrc:t,name:s,isActive:n,onSelect:l}){return e.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-1 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${n?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,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"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-32 ${n?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function Le({testFile:t,entityName:s}){const{results:n,isRunning:l,runTests:h}=Be(t);if(l&&!n)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(!n)return null;if(n.status==="error")return e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:n.errorMessage})});const c=s?n.testCases.filter(x=>x.fullName.startsWith(s)):n.testCases,o=c.length>0?c:n.testCases;if(o.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"px-2 pt-1 space-y-0.5",children:[o.map(x=>{var S;const k=p&&x.fullName.startsWith(p)?x.fullName.slice(p.length):x.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[x.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):x.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] ${x.status==="passed"?"text-green-400":x.status==="failed"?"text-red-400":"text-gray-500"}`,children:k})]}),x.status==="failed"&&((S=x.failureMessages)==null?void 0:S.map((y,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-300/70 truncate max-w-full",title:y,children:y.split(`
|
|
3
|
+
`)[0]},w)))]},x.fullName)}),e.jsx("button",{onClick:h,disabled:l,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#00c4ee] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":"Re-run"})]})}function Y({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(Ae,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function is({scenarios:t,projectRoot:s,activeScenarioId:n,onScenarioSelect:l,zoomComponent:h,onZoomChange:c,analyzedEntities:o=[],glossaryFunctions:p=[],activeAnalyzedScenarioId:x,onAnalyzedScenarioSelect:k,entityImports:S,pageFilePaths:y={}}){const{pageGroups:w,componentGroups:M}=a.useMemo(()=>{var f;const u=new Map,g=new Map;for(const m of t)if(m.componentName){const i=g.get(m.componentName)||[];i.push(m),g.set(m.componentName,i)}else if(De(m.url)){const i=(f=m.url)==null?void 0:f.match(/[?&]c=([^&]+)/),v=i?decodeURIComponent(i[1]):"Isolated",C=g.get(v)||[];C.push(m),g.set(v,C)}else{const i=te(m.url),v=u.get(i)||[];v.push(m),u.set(i,v)}const d=new Map([...g.entries()].sort(([m],[i])=>m.localeCompare(i)));return{pageGroups:u,componentGroups:d}},[t]),b=a.useMemo(()=>{const u=new Set((o||[]).filter(d=>d.entityType==="visual").map(d=>d.name)),g=new Map;for(const[d,f]of M)u.has(d)||g.set(d,f);return g},[M,o]),{visualEntities:B,libraryEntities:L}=a.useMemo(()=>{const u=o.filter(d=>d.entityType==="visual").sort((d,f)=>d.name.localeCompare(f.name)),g=o.filter(d=>d.entityType==="library"||d.entityType==="functionCall").sort((d,f)=>d.name.localeCompare(f.name));return{visualEntities:u,libraryEntities:g}},[o]),I=a.useMemo(()=>{const u=new Set(L.map(g=>g.name));return p.filter(g=>!u.has(g.name)).sort((g,d)=>g.name.localeCompare(d.name))},[p,L]),U=o.some(u=>u.isAnalyzing),R=a.useRef(null),$=a.useRef(0),D=a.useCallback(()=>{R.current&&($.current=R.current.scrollTop)},[]);if(a.useEffect(()=>{R.current&&$.current>0&&(R.current.scrollTop=$.current)}),t.length===0&&o.length===0&&I.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(h){const u=M.get(h)||[],g=new Set((S==null?void 0:S[h])||[]),d=g.size>0,f=d?B.filter(i=>g.has(i.name)):[],m=d?L.filter(i=>g.has(i.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:()=>c(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:h})}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2",children:u.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No scenarios for this component"}):u.map(i=>e.jsx(xe,{imgSrc:i.screenshotPath?`/api/editor-scenario-image/${i.id}.png${i.updatedAt?`?v=${encodeURIComponent(i.updatedAt)}`:""}`:null,name:i.name,isActive:i.id===n,onSelect:()=>l(i)},i.id))}),f.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"})}),f.map(i=>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:()=>c(i.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:i.name})}),e.jsx(Y,{filePath:i.filePath,projectRoot:s}),(i.scenarios.length>0||i.pendingScenarios.length>0)&&e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:i.scenarios.map(v=>e.jsx(xe,{imgSrc:v.screenshotPath?`/api/screenshot/${v.screenshotPath}`:null,name:v.name,isActive:v.id===x,onSelect:()=>k==null?void 0:k({analysisId:i.analysisId,scenarioId:v.id,scenarioName:v.name,entitySha:i.sha,entityName:i.name})},v.id))})]},i.sha))]}),m.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"})}),m.map(i=>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:i.name})}),e.jsx(Y,{filePath:i.filePath,projectRoot:s}),i.testFile&&e.jsx(Le,{testFile:i.testFile,entityName:i.name})]},i.sha))]})]})})}return e.jsx("div",{ref:R,onScroll:D,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-3",children:[w.size>0&&e.jsxs("div",{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:"Application"})}),[...w.entries()].sort(([u],[g])=>u==="Home"?-1:g==="Home"?1:u.localeCompare(g)).map(([u,g])=>e.jsxs("div",{className:"px-2 pt-1",children:[e.jsx("div",{className:"py-0.5",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-400",children:u})}),y[u]&&e.jsx(Y,{filePath:y[u],projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:g.map(d=>e.jsx(xe,{imgSrc:d.screenshotPath?`/api/editor-scenario-image/${d.id}.png${d.updatedAt?`?v=${encodeURIComponent(d.updatedAt)}`:""}`:null,name:d.name,isActive:d.id===n&&!x,onSelect:()=>l(d)},d.id))})]},u))]}),b.size>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"})}),[...b.entries()].map(([u,g])=>{var d;return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center justify-between px-2 py-1",children:e.jsx("button",{onClick:()=>c(u),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u})}),((d=g[0])==null?void 0:d.componentPath)&&e.jsx(Y,{filePath:g[0].componentPath,projectRoot:s}),e.jsx("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:g.map(f=>e.jsx(xe,{imgSrc:f.screenshotPath?`/api/editor-scenario-image/${f.id}.png${f.updatedAt?`?v=${encodeURIComponent(f.updatedAt)}`:""}`:null,name:f.name,isActive:f.id===n&&!x,onSelect:()=>l(f)},f.id))})]},u)})]}),B.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"}),U&&t.length===0&&o.every(u=>u.scenarioCount===0)&&e.jsx("span",{className:"ml-2 text-[10px] text-gray-500",children:"— Entities are being analyzed..."})]}),B.map(u=>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:()=>c(u.name),className:"text-[11px] font-medium text-gray-400 truncate cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:u.name}),u.isAnalyzing&&u.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(Y,{filePath:u.filePath,projectRoot:s}),(u.scenarios.length>0||u.pendingScenarios.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 px-2 pt-1",children:[u.scenarios.map(g=>e.jsx(xe,{imgSrc:g.screenshotPath?`/api/screenshot/${g.screenshotPath}`:null,name:g.name,isActive:g.id===x,onSelect:()=>k==null?void 0:k({analysisId:u.analysisId,scenarioId:g.id,scenarioName:g.name,entitySha:u.sha,entityName:u.name})},g.id)),u.pendingScenarios.map(g=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:g,children:g},g))]})]},u.sha))]}),(L.length>0||I.length>0)&&e.jsxs("div",{className:`pt-2 mt-1 ${B.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"})}),L.map(u=>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:u.name}),u.isAnalyzing&&u.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(Y,{filePath:u.filePath,projectRoot:s}),u.testFile?e.jsx(Le,{testFile:u.testFile,entityName:u.name}):e.jsx("div",{className:"px-2 pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},u.sha)),I.map(u=>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:u.name})}),e.jsx(Y,{filePath:u.filePath,projectRoot:s}),e.jsx(Le,{testFile:u.testFile,entityName:u.name})]},u.name))]})]})})}function ls(t,s,n=new Date){const l={"1d":1,"3d":3,"7d":7,"30d":30}[s],h=new Date(n);h.setDate(h.getDate()-l);const c=h.toISOString().split("T")[0],o=t.filter(y=>y.date>=c),p=new Set(o.map(y=>y.commitSha).filter(Boolean)),x=new Map;for(const y of o)if(y.scenarioScreenshots)for(const w of y.scenarioScreenshots){x.has(w.name)||x.set(w.name,[]);const M=x.get(w.name);M.some(b=>b.path===w.path)||M.push({path:w.path,time:y.time})}for(const y of x.values())y.sort((w,M)=>w.time.localeCompare(M.time));const k=[],S=new Map;for(const[y,w]of x){const M=y.indexOf(" - ");if(M!==-1){const b=y.slice(0,M);S.has(b)||S.set(b,[]),S.get(b).push({name:y,screenshots:w})}else k.push({name:y,screenshots:w})}return{commitCount:p.size,entryCount:o.length,appScenarios:k,componentGroups:S,totalScenarios:x.size}}function os(t){const s=new Map;for(const n of[...t].reverse()){const l=s.get(n.date)||[];l.push(n),s.set(n.date,l)}return s}function cs(t){const s=new Map;for(const n of t){let l;if("componentName"in n&&n.componentName)l=n.componentName;else if("componentName"in n&&n.componentName===null)l="App";else{const c=n.name.indexOf(" - ");l=c!==-1?n.name.slice(0,c):"App"}const h=s.get(l)||[];h.push(n),s.set(l,h)}return[...s.entries()].sort(([n],[l])=>n==="App"?-1:l==="App"?1:n.localeCompare(l))}const st=120;function pt({text:t,theme:s}){const[n,l]=a.useState(!1),h=t.length>st,c=h&&!n?t.slice(0,st)+"…":t,o=s==="light";return e.jsxs("div",{className:`px-4 py-2 ${o?"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 ${o?"text-gray-600":"text-gray-400"}`,children:[c,h&&e.jsx("button",{onClick:()=>l(!n),className:`ml-1 text-[11px] font-medium bg-transparent border-none p-0 cursor-pointer ${o?"text-blue-500 hover:text-blue-700":"text-[#00a0c4] hover:text-[#00c0e8]"}`,children:n?"Show less":"Read more…"})]})]})}function nt({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 ds({testFile:t,entityName:s}){const{results:n,isRunning:l,runTests:h}=Be(t);if(l&&!n)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(!n)return null;if(n.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-400",children:n.errorMessage})});const c=s?n.testCases.filter(x=>x.fullName.startsWith(s)):n.testCases,o=c.length>0?c:n.testCases;if(o.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(x=>{var S;const k=p&&x.fullName.startsWith(p)?x.fullName.slice(p.length):x.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[x.status==="passed"?e.jsx("span",{className:"text-green-400 text-[10px]",children:"✓"}):x.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] ${x.status==="passed"?"text-green-400":x.status==="failed"?"text-red-400":"text-gray-500"}`,children:k})]}),x.status==="failed"&&((S=x.failureMessages)==null?void 0:S.map((y,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400/70 truncate max-w-full",title:y,children:y.split(`
|
|
4
|
+
`)[0]},w)))]},x.fullName)}),e.jsx("button",{onClick:h,disabled:l,className:"mt-1 text-[10px] text-[#00a0c4] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":"Re-run"})]})}const xs={added:"text-green-400",untracked:"text-green-400",modified:"text-blue-400",renamed:"text-purple-400"};function ms({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 ${xs[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 ps={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 us(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function hs(t){try{return new Date(t+"T00:00:00").toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})}catch{return t}}const fs=[{value:"1d",label:"1 Day"},{value:"3d",label:"3 Days"},{value:"7d",label:"1 Week"},{value:"30d",label:"1 Month"}];function gs({entries:t,onScreenshotClick:s}){const[n,l]=a.useState(!1),[h,c]=a.useState("7d"),o=a.useMemo(()=>ls(t,h),[t,h]);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>l(!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:fs.map(p=>e.jsx("button",{onClick:()=>c(p.value),className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer border ${h===p.value?"bg-[#005c75] text-white border-[#005c75]":"bg-transparent text-gray-400 border-[#4d4d4d] hover:text-white hover:border-[#005c75]"}`,children:p.label},p.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:o.commitCount})," ",o.commitCount===1?"commit":"commits"]}),e.jsx("span",{className:"text-[#3d3d3d]",children:"|"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white font-medium",children:o.totalScenarios})," ",o.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:o.entryCount})," ",o.entryCount===1?"entry":"entries"]})]}),o.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:[o.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"}),o.appScenarios.map(p=>e.jsx(at,{scenario:p,onScreenshotClick:s},p.name))]}),o.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"}),[...o.componentGroups.entries()].sort(([p],[x])=>p.localeCompare(x)).map(([p,x])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400",children:p}),x.map(k=>e.jsx(at,{scenario:k,onScreenshotClick:s},k.name))]},p))]})]})]})]})}function at({scenario:t,onScreenshotClick:s}){const n=t.name.indexOf(" - "),l=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:l}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:t.screenshots.map((h,c)=>e.jsxs("div",{className:"flex items-center shrink-0",children:[c>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(h.time).toLocaleDateString()})`,onClick:()=>s==null?void 0:s({screenshotUrl:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,commitSha:null,commitMessage:null,scenarioName:t.name}),children:e.jsx("img",{src:`/api/editor-journal-image/${h.path.replace("screenshots/","")}`,alt:t.name,className:"max-w-full max-h-full object-contain",loading:"lazy"})})]},h.path))})]})}function js({isActive:t,onScreenshotClick:s,glossaryFunctions:n=[]}){const[l,h]=a.useState([]),[c,o]=a.useState(!0),[p,x]=a.useState(new Set),k=a.useCallback(w=>{x(M=>{const b=new Set(M);return b.has(w)?b.delete(w):b.add(w),b})},[]),S=a.useCallback(async()=>{try{const w=await fetch("/api/editor-journal");if(w.ok){const M=await w.json();h(M.entries||[])}}catch{}finally{o(!1)}},[]);if(a.useEffect(()=>{S()},[S]),a.useEffect(()=>{t&&S()},[t,S]),a.useEffect(()=>{if(!t)return;const w=setInterval(()=>void S(),5e3);return()=>clearInterval(w)},[t,S]),c)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=os(l);return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(gs,{entries:l,onScreenshotClick:s}),[...y.entries()].map(([w,M])=>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:hs(w)})}),e.jsx("div",{className:"space-y-2",children:M.map((b,B)=>{const L=ps[b.type]||{label:b.type,color:"bg-gray-600"},I=`${b.time}-${B}`,U=p.has(I);return e.jsxs("div",{className:"bg-[#2d2d2d] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:`p-3 space-y-2 ${U?"":"max-h-[300px] overflow-y-auto"}`,children:[e.jsx("div",{className:"flex items-start gap-2 cursor-pointer",onClick:()=>k(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:b.title}),e.jsx("span",{className:`${L.color} text-white text-[9px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wider shrink-0`,children:L.label})]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:us(b.time)}),b.featureName&&e.jsx("span",{className:"text-[10px] text-gray-500 italic truncate",title:b.featureName,children:b.featureName})]})}),b.userPrompt&&e.jsx(pt,{text:b.userPrompt,theme:"dark"}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:b.description}),b.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/${b.screenshot.replace("screenshots/","")}`,commitSha:b.commitSha,commitMessage:b.commitMessage,scenarioName:b.title}),children:e.jsx("img",{src:`/api/editor-journal-image/${b.screenshot.replace("screenshots/","")}`,alt:b.title,className:"max-w-full max-h-full object-contain",loading:"lazy"})}),b.scenarioScreenshots&&b.scenarioScreenshots.length>0&&(()=>{const R=cs(b.scenarioScreenshots),$=b.entityChangeStatus,D=R.filter(([m])=>m==="App").flatMap(([,m])=>m),u=R.filter(([m])=>m!=="App"),g=new Map;for(const m of D){const i=te(m.url??null),v=g.get(i)||[];v.push(m),g.set(i,v)}const d=[...g.entries()],f=m=>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/${m.path.replace("screenshots/","")}`,commitSha:b.commitSha,commitMessage:b.commitMessage,scenarioName:m.name}),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);return e.jsxs("div",{className:"space-y-2",children:[d.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"}),d.map(([m,i])=>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:m}),($==null?void 0:$[m])&&e.jsx(nt,{status:$[m]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:i.map(f)})]},m))]}),u.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"}),u.map(([m,i])=>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:m}),($==null?void 0:$[m])&&e.jsx(nt,{status:$[m]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:i.map(f)})]},m))]})]})})(),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(R=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-200",children:R.name}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate block",children:R.filePath}),R.testFile?e.jsx(ds,{testFile:R.testFile,entityName:R.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-500",children:"No test file"})})]},R.name))})]}),b.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:b.commitSha.slice(0,7)}),e.jsx("span",{className:"text-gray-500 truncate",children:b.commitMessage})]}),U&&b.modifiedFiles&&b.modifiedFiles.length>0&&e.jsx(ms,{files:b.modifiedFiles})]}),e.jsxs("button",{onClick:()=>k(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:["——— ",U?"Collapse":"Expand"," ———"]})]},I)})})]},w))]})})}const rt=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-gray-500 shrink-0",children:e.jsx("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});function bs(t,s){if(t.length<=s)return t;const n=s-2;return[t[0],"ellipsis",...t.slice(t.length-n)]}function vs({items:t,onNavigate:s}){if(t.length===0)return null;const n=bs(t,4);return e.jsx("nav",{className:"flex items-center gap-1 text-xs min-w-0",children:n.map((l,h)=>{if(l==="ellipsis")return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rt,{}),e.jsx("span",{className:"text-gray-500",children:"..."})]},"ellipsis");const c=h===n.length-1;return e.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[h>0&&e.jsx(rt,{}),c?e.jsx("span",{className:"text-white font-medium truncate",children:l.name}):e.jsx("button",{onClick:()=>s(l.componentName),className:"text-gray-400 hover:text-white transition-colors cursor-pointer bg-transparent border-none p-0 truncate",children:l.name})]},l.componentName||"app")})})}function me({imgSrc:t,name:s,isActive:n,onSelect:l}){return e.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-1 cursor-pointer group w-full",title:s,children:[e.jsx("div",{className:`w-full aspect-square rounded overflow-hidden border-2 transition-all bg-[#1a1a1a] ${n?"border-[#005c75] ring-1 ring-[#005c75]":"border-transparent hover:border-[#4d4d4d]"}`,children:t?e.jsx("img",{src:t,alt:s,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"})})}),e.jsx("span",{className:`text-[10px] leading-tight text-center truncate w-full ${n?"text-white":"text-gray-500 group-hover:text-gray-300"}`,children:s})]})}function fe({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-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(Ae,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-500 hover:text-gray-300 transition-colors"})]}):null}function Ns({hasProject:t,scenarios:s,analyzedEntities:n,glossaryFunctions:l=[],glossaryEntries:h=[],projectRoot:c,activeScenarioId:o,onScenarioSelect:p,onAnalyzedScenarioSelect:x,onSwitchToBuild:k,zoomComponent:S,onZoomChange:y,entityImports:w,pageFilePaths:M={},projectTitle:b,projectDescription:B,breadcrumbItems:L=[]}){const{pageGroups:I,componentGroups:U}=a.useMemo(()=>{var v;const f=new Map,m=new Map;for(const C of s)if(C.componentName){const P=m.get(C.componentName)||[];P.push(C),m.set(C.componentName,P)}else if(De(C.url)){const P=(v=C.url)==null?void 0:v.match(/[?&]c=([^&]+)/),_=P?decodeURIComponent(P[1]):"Isolated",J=m.get(_)||[];J.push(C),m.set(_,J)}else{const P=te(C.url),_=f.get(P)||[];_.push(C),f.set(P,_)}const i=new Map([...m.entries()].sort(([C],[P])=>C.localeCompare(P)));return{pageGroups:f,componentGroups:i}},[s]),R=a.useMemo(()=>n.filter(f=>f.entityType==="visual").sort((f,m)=>f.name.localeCompare(m.name)),[n]),$=a.useMemo(()=>{const f=new Map;for(const m of l)f.set(m.name,m);return f},[l]),D=a.useRef(null),u=a.useRef(0),g=a.useCallback(()=>{D.current&&(u.current=D.current.scrollTop)},[]);if(a.useEffect(()=>{D.current&&u.current>0&&(D.current.scrollTop=u.current)}),!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Ready to build something?"}),e.jsx("button",{onClick:k,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(!(s.length>0||R.length>0))return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 px-8 text-center",children:[b?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:b}),B&&e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:B})]}):e.jsx("h2",{className:"text-lg font-medium text-white font-['IBM_Plex_Sans'] m-0",children:"Your project is ready"}),e.jsx("p",{className:"text-sm text-gray-400 m-0 font-['IBM_Plex_Sans'] leading-relaxed",children:"Describe what you want to build in the Chat and your pages and components will appear here."}),e.jsx("button",{onClick:k,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(S){const f=I.get(S)||[],m=U.get(S)||[],i=R.find(j=>j.name===S),v=$.get(S),C=[...f,...m],P=new Set((w==null?void 0:w[S])||[]),_=P.size>0,J=_?[...U.entries()].filter(([j])=>P.has(j)):[],q=_?R.filter(j=>P.has(j.name)&&!J.some(([O])=>O===j.name)):[],X=_?h.filter(j=>P.has(j.name)&&j.returnType!=="JSX.Element"&&j.returnType!=="React.ReactNode").map(j=>({name:j.name,filePath:j.filePath,description:j.description||"",testFile:j.testFile,feature:j.feature})):[],se=J.length>0||q.length>0,ne=X.length>0,ae=se||ne;return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(vs,{items:L,onNavigate:y}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-white m-0 font-['IBM_Plex_Sans'] uppercase tracking-wider",children:S}),(()=>{const j=(v==null?void 0:v.filePath)||(i==null?void 0:i.filePath)||M[S];return j?e.jsx(fe,{filePath:j,projectRoot:c}):null})()]}),C.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:C.map(j=>e.jsx(me,{imgSrc:j.screenshotPath?`/api/editor-scenario-image/${j.id}.png${j.updatedAt?`?v=${encodeURIComponent(j.updatedAt)}`:""}`:null,name:j.name,isActive:j.id===o,onSelect:()=>p(j)},j.id))}),i&&(i.scenarios.length>0||i.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[i.scenarios.map(j=>e.jsx(me,{imgSrc:j.screenshotPath?`/api/screenshot/${j.screenshotPath}`:null,name:j.name,isActive:!1,onSelect:()=>x({analysisId:i.analysisId,scenarioId:j.id,scenarioName:j.name,entitySha:i.sha,entityName:i.name})},j.id)),i.pendingScenarios.map(j=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:j,children:j},j))]}),v&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Tests:"}),e.jsx(fe,{filePath:v.testFile,projectRoot:c})]}),C.length===0&&!i&&!v&&e.jsx("div",{className:"text-xs text-gray-500",children:"No scenarios for this entity"}),ae&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-[#3d3d3d] space-y-3",children:[se&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Components"}),J.map(([j,O])=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(j),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:j})}),O.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:O.map(G=>e.jsx(me,{imgSrc:G.screenshotPath?`/api/editor-scenario-image/${G.id}.png${G.updatedAt?`?v=${encodeURIComponent(G.updatedAt)}`:""}`:null,name:G.name,isActive:G.id===o,onSelect:()=>p(G)},G.id))})]},j)),q.map(j=>e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(j.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:j.name})}),(j.scenarios.length>0||j.pendingScenarios.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[j.scenarios.map(O=>e.jsx(me,{imgSrc:O.screenshotPath?`/api/screenshot/${O.screenshotPath}`:null,name:O.name,isActive:!1,onSelect:()=>x({analysisId:j.analysisId,scenarioId:O.id,scenarioName:O.name,entitySha:j.sha,entityName:j.name})},O.id)),j.pendingScenarios.map(O=>e.jsx("div",{className:"px-2.5 py-1 bg-[#2a2a2a] text-gray-400 text-[10px] rounded-full",title:O,children:O},O))]})]},j.sha))]}),ne&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Functions"}),X.map(j=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(j.name),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:j.name})}),e.jsx(fe,{filePath:j.filePath,projectRoot:c}),j.testFile&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("span",{className:"text-[9px] text-gray-600",children:"test:"}),e.jsx("span",{className:"text-[9px] text-gray-500 truncate",children:j.testFile})]})]},j.name))]})]})]})})}return e.jsx("div",{ref:D,onScroll:g,className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[b&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white m-0 font-['IBM_Plex_Sans']",children:b}),B&&e.jsx("p",{className:"text-xs text-gray-400 m-0 mt-1 font-['IBM_Plex_Sans'] leading-relaxed",children:B})]}),I.size>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Application"}),e.jsx("button",{onClick:k,className:"px-2.5 py-1 text-[10px] font-medium text-gray-400 bg-[#2a2a2a] border border-[#4d4d4d] rounded hover:bg-[#333] hover:text-white hover:border-[#005c75] transition-colors cursor-pointer",children:"+ New Page"})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 m-0 mt-1.5 font-['IBM_Plex_Sans'] leading-relaxed",children:["Select a page scenario below and switch to"," ",e.jsx("button",{onClick:k,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"Build"})," ","to change or enhance an existing page or"," ",e.jsx("button",{onClick:k,className:"text-[#00a0c4] hover:text-[#00c4eb] bg-transparent border-none p-0 cursor-pointer underline font-inherit text-inherit",children:"create a new page"})]}),[...I.entries()].sort(([f],[m])=>f==="Home"?-1:m==="Home"?1:f.localeCompare(m)).map(([f,m])=>e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"py-1",children:e.jsx("button",{onClick:()=>y(f),className:"text-[11px] font-medium text-gray-400 cursor-pointer hover:text-white transition-colors bg-transparent border-none p-0",children:f})}),M[f]&&e.jsx(fe,{filePath:M[f],projectRoot:c}),e.jsx("div",{className:"grid grid-cols-3 gap-2 pt-1",children:m.map(i=>e.jsx(me,{imgSrc:i.screenshotPath?`/api/editor-scenario-image/${i.id}.png${i.updatedAt?`?v=${encodeURIComponent(i.updatedAt)}`:""}`:null,name:i.name,isActive:i.id===o,onSelect:()=>p(i)},i.id))})]},f))]})]})})}const it={new:0,edited:1,impacted:2};function lt({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],l=s&&(t.status==="edited"||t.status==="impacted");return e.jsx("button",{onClick:l?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 ${l?"cursor-pointer hover:opacity-80 transition-opacity":"cursor-default"}`,children:n.label})}function ot({filePath:t}){const[s,n]=a.useState(null),[l,h]=a.useState(!0),[c,o]=a.useState(null);return a.useEffect(()=>{es(()=>import("./index-yHOVb4rc.js"),__vite__mapDeps([0,1])).then(p=>{o(()=>p.default)})},[]),a.useEffect(()=>{h(!0),fetch(`/api/editor-file-diff?path=${encodeURIComponent(t)}`).then(p=>p.json()).then(p=>{n({oldContent:p.oldContent,newContent:p.newContent})}).catch(()=>{n(null)}).finally(()=>h(!1))},[t]),l?e.jsx("div",{className:"p-2 text-[10px] text-gray-400",children:"Loading diff..."}):!s||!c?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(c,{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 ct({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 dt({scenarioId:t,name:s,isActive:n,onSelect:l,updatedAt:h}){const[c,o]=a.useState(!1),p=a.useRef(null);a.useEffect(()=>{o(!1)},[t]),a.useEffect(()=>{n&&p.current&&p.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[n]);const x=`/api/editor-scenario-image/${t}.png${h?`?v=${encodeURIComponent(h)}`:""}`;return e.jsxs("button",{ref:p,onClick:l,className:"flex flex-col items-center gap-1.5 cursor-pointer group",title:s,children:[e.jsx("div",{className:`w-32 h-32 rounded-lg overflow-hidden border-2 transition-all ${n?"border-[#0ea5e9] ring-2 ring-[#0ea5e9]/40 shadow-lg shadow-[#0ea5e9]/20":"border-gray-200 hover:border-gray-400 shadow-sm"}`,children:c?e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center",children:e.jsx("span",{className:"text-[9px] text-gray-400",children:"No preview"})}):e.jsx("img",{src:x,alt:s,className:"w-full h-full object-contain bg-white",loading:"lazy",onError:()=>o(!0)})}),e.jsx("span",{className:`text-[11px] leading-tight text-center truncate w-32 font-medium ${n?"text-gray-900":"text-gray-600 group-hover:text-gray-900"}`,children:s})]})}function ys({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(Ae,{content:t,icon:!0,iconSize:10,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors"})]}):null}function ws({testFile:t,entityName:s}){const{results:n,isRunning:l,runTests:h}=Be(t);if(l&&!n)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(!n)return null;if(n.status==="error")return e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-red-500",children:n.errorMessage})});const c=s?n.testCases.filter(x=>x.fullName.startsWith(s)):n.testCases,o=c.length>0?c:n.testCases;if(o.length===0)return null;const p=s?`${s} > `:"";return e.jsxs("div",{className:"pt-1 space-y-0.5",children:[o.map(x=>{var S;const k=p&&x.fullName.startsWith(p)?x.fullName.slice(p.length):x.fullName;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[x.status==="passed"?e.jsx("span",{className:"text-green-600 text-[10px]",children:"✓"}):x.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] ${x.status==="passed"?"text-green-600":x.status==="failed"?"text-red-500":"text-gray-400"}`,children:k})]}),x.status==="failed"&&((S=x.failureMessages)==null?void 0:S.map((y,w)=>e.jsx("div",{className:"pl-4 text-[9px] text-red-400 truncate max-w-full",title:y,children:y.split(`
|
|
5
|
+
`)[0]},w)))]},x.fullName)}),e.jsx("button",{onClick:h,disabled:l,className:"mt-1 text-[10px] text-[#0ea5e9] hover:text-[#38bdf8] transition-colors cursor-pointer disabled:opacity-50 bg-transparent border-none p-0",children:l?"Running...":"Re-run"})]})}function xt(t){const s=t.indexOf(" - ");return s!==-1?t.slice(s+3):t}function mt(t,s){return!s||Object.keys(s).length===0?t:[...t].sort(([n],[l])=>{var p,x;const h=((p=s[n])==null?void 0:p.status)||"impacted",c=((x=s[l])==null?void 0:x.status)||"impacted",o=(it[h]??2)-(it[c]??2);return o!==0?o:n.localeCompare(l)})}function Ss({scenarios:t,allScenarios:s=[],glossaryFunctions:n=[],projectRoot:l,activeScenarioId:h,onScenarioSelect:c,onClose:o,entityChangeStatus:p={},modifiedFiles:x=[],featureName:k,userPrompt:S}){const y=a.useMemo(()=>{if(s.length===0||Object.keys(p).length===0)return t;const d=new Set(t.map(m=>m.id)),f=s.filter(m=>{var v;if(d.has(m.id))return!1;const i=m.componentName||te(m.url);return((v=p[i])==null?void 0:v.status)==="impacted"});return f.length===0?t:[...t,...f]},[t,s,p]),w=a.useMemo(()=>Object.entries(p).filter(([,d])=>d.status==="new"||d.status==="edited").map(([d,f])=>({name:d,status:f.status})),[p]),[M,b]=a.useState(null),B=a.useCallback(d=>{b(f=>f===d?null:d)},[]),{pageGroups:L,componentGroups:I}=a.useMemo(()=>{var m;const d=new Map,f=new Map;for(const i of y)if(i.componentName){const v=f.get(i.componentName)||[];v.push(i),f.set(i.componentName,v)}else if(De(i.url)){const v=(m=i.url)==null?void 0:m.match(/[?&]c=([^&]+)/),C=v?decodeURIComponent(v[1]):"Isolated",P=f.get(C)||[];P.push(i),f.set(C,P)}else{const v=te(i.url),C=d.get(v)||[];C.push(i),d.set(v,C)}return{pageGroups:d,componentGroups:f}},[y]),U=a.useMemo(()=>mt([...L.entries()],p),[L,p]),R=a.useMemo(()=>mt([...I.entries()],p),[I,p]),$=U,D=R,u=a.useMemo(()=>rs(n,p),[n,p]),g=a.useMemo(()=>{const d=[];for(const[,f]of $)d.push(...f);for(const[,f]of D)d.push(...f);return d},[$,D]);return a.useEffect(()=>{if(g.length===0)return;const d=f=>{var P;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(f.key))return;const i=(P=f.target)==null?void 0:P.tagName;if(i==="INPUT"||i==="TEXTAREA"||i==="SELECT")return;f.preventDefault();const v=g.findIndex(_=>_.id===h);let C;f.key==="ArrowLeft"||f.key==="ArrowUp"?C=v<=0?g.length-1:v-1:C=v>=g.length-1?0:v+1,c(g[C])};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[g,h,c]),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:o,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"}),k&&e.jsx("div",{className:"text-[11px] text-gray-400 truncate",title:k,children:k})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-700 text-lg leading-none cursor-pointer bg-transparent border-none shrink-0",title:"Close results",children:"×"})]}),S&&e.jsx(pt,{text:S,theme:"light"}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsxs("div",{className:"space-y-5",children:[$.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:$.map(([d,f])=>{var C;const m=p[d],i=M===d,v=(C=f[0])==null?void 0:C.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:d}),m&&e.jsx(lt,{status:m,onClick:()=>B(d)})]}),i&&(m==null?void 0:m.status)==="edited"&&v&&e.jsx(ot,{filePath:v}),i&&(m==null?void 0:m.status)==="impacted"&&e.jsx(ct,{impactedBy:m.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:f.map(P=>e.jsx(dt,{scenarioId:P.id,name:xt(P.name),isActive:P.id===h,onSelect:()=>c(P),updatedAt:P.updatedAt},P.id))})]},d)})})]}),D.length>0&&e.jsxs("div",{className:$.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:D.map(([d,f])=>{var C;const m=p[d],i=M===d,v=(C=f[0])==null?void 0:C.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:d}),m&&e.jsx(lt,{status:m,onClick:()=>B(d)})]}),i&&(m==null?void 0:m.status)==="edited"&&v&&e.jsx(ot,{filePath:v}),i&&(m==null?void 0:m.status)==="impacted"&&e.jsx(ct,{impactedBy:m.impactedBy,changedEntities:w}),e.jsx("div",{className:"flex flex-wrap gap-3",children:f.map(P=>e.jsx(dt,{scenarioId:P.id,name:xt(P.name),isActive:P.id===h,onSelect:()=>c(P),updatedAt:P.updatedAt},P.id))})]},d)})})]}),u.length>0&&e.jsxs("div",{className:$.length>0||D.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:u.map(d=>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:d.name})}),e.jsx(ys,{filePath:d.filePath,projectRoot:l}),d.testFile?e.jsx(ws,{testFile:d.testFile,entityName:d.name}):e.jsx("div",{className:"pt-1",children:e.jsx("span",{className:"text-[10px] text-gray-400",children:"No test file"})})]},d.name))})]}),x.length>0&&e.jsxs("div",{className:$.length>0||D.length>0||u.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 (",x.length,")"]})}),e.jsx("div",{className:"space-y-0.5 pl-1 max-h-[200px] overflow-auto",children:x.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-bold uppercase w-[14px] text-center ${d.status==="added"||d.status==="untracked"?"text-green-600":d.status==="modified"?"text-blue-600":d.status==="renamed"?"text-purple-600":"text-gray-400"}`,children:d.status==="added"||d.status==="untracked"?"A":d.status==="modified"?"M":d.status==="renamed"?"R":"?"}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate font-mono",children:d.path})]},d.path))})]})]})})]})}const ks=[{key:"app",label:"App"},{key:"build",label:"Build"},{key:"data",label:"Structure"},{key:"journal",label:"Journal"}];function Cs({activeTab:t,onTabChange:s,buildIdle:n,zoomComponent:l,breadcrumbItems:h,onBreadcrumbNavigate:c,panelLayout:o,onToggleExpand:p}){return e.jsxs("div",{className:"bg-[#3d3d3d] h-10 flex items-center px-3 gap-3 shrink-0 z-20 border-b border-[#2d2d2d]",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("img",{src:ts,alt:"CodeYam",className:"h-5 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-xs whitespace-nowrap",children:"Codeyam Editor"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:"flex items-center gap-0.5 bg-[#4a3232] rounded-lg p-0.5",children:ks.map(x=>e.jsxs("button",{onClick:()=>s(x.key),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===x.key?"bg-[#7a4444] text-white":"text-gray-300 hover:text-white"}`,children:[x.label,x.key==="build"&&n&&t!=="build"&&e.jsx("span",{className:"ml-1 inline-block w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"})]},x.key))}),p&&e.jsx("button",{onClick:p,className:"p-1.5 rounded text-gray-400 hover:text-white transition-colors cursor-pointer",title:o==="editor-only"?"Show preview":"Hide 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:o==="editor-only"?e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M16 15l-3-3 3-3"})]}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M14 9l3 3-3 3"})]})})})]})]})}function Ps({preview:t,onDismiss:s,onLoadCommit:n}){return e.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-[700px] w-full",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#333] m-0 font-['IBM_Plex_Sans']",children:"Journal Screenshot"}),e.jsx("p",{className:"text-sm text-[#888] mt-1 m-0 font-['IBM_Plex_Sans']",children:"This is a snapshot from a previous version — not a live preview"})]}),e.jsx("div",{className:"rounded-lg overflow-hidden border-2 border-[#ccc] shadow-md max-w-full w-fit",children:e.jsx("img",{src:t.screenshotUrl,alt:t.scenarioName,className:"max-w-full h-auto block"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#666]",children:[t.commitSha&&e.jsx("span",{className:"font-mono text-xs text-[#00a0c4] bg-[#00a0c4]/15 px-2 py-0.5 rounded",children:t.commitSha.slice(0,7)}),e.jsxs("span",{className:"truncate",children:[t.scenarioName,t.commitMessage&&` — ${t.commitMessage}`]})]}),e.jsx("div",{className:"flex items-center gap-3",children:t.commitSha&&n&&e.jsx(Ms,{commitSha:t.commitSha,onLoadCommit:n})})]})}function Ms({commitSha:t,onLoadCommit:s}){const[n,l]=a.useState(!1),[h,c]=a.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{l(!0),c(null),s(t).then(o=>{o.success||c(o.error||"Failed to load commit")}).catch(o=>{c(o instanceof Error?o.message:"Network error")}).finally(()=>l(!1))},disabled:n,className:"bg-[#005c75] hover:bg-[#004d63] disabled:opacity-50 text-white text-sm font-medium px-4 py-1.5 rounded transition-colors cursor-pointer",children:n?"Reverting...":"Revert to this code and load this version"}),h&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded px-4 py-2 text-sm text-red-600 w-full text-center",children:h})]})}function Es({analysisId:t,scenarioId:s,scenarioName:n,entityName:l,projectSlug:h,onStateChange:c}){const{interactiveServerUrl:o,isStarting:p,isLoading:x}=ss({analysisId:t,scenarioId:s,scenarioName:n,entityName:l,projectSlug:h,enabled:!0});return a.useEffect(()=>{c(o,p||x)},[o,p,x,c]),null}function Is(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 Rs(){const[t,s]=a.useState({url:null,proxyUrl:null,isStarting:!1,error:null,canStartServer:!0,autoStartAttempted:!1}),n=a.useRef(t);n.current=t,a.useEffect(()=>{let c=!1,o=null;const p=async()=>{try{const x=await fetch("/api/editor-dev-server");if(c)return;const k=await x.json(),S=Is(n.current,k),{shouldAutoStart:y,...w}=S;if(s(w),y)try{const M=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})});if(c)return;M.ok?s(b=>({...b,isStarting:!0})):s(b=>({...b,canStartServer:!1}))}catch{}}catch{}};return p(),o=setInterval(()=>void p(),2e3),()=>{c=!0,o&&clearInterval(o)}},[t.url]);const l=a.useCallback(()=>{s(c=>({...c,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})}).catch(()=>{})},[]),h=a.useCallback(()=>{s(c=>({...c,error:null,isStarting:!0})),fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start"})}).catch(()=>{})},[]);return{devServerUrl:t.url,proxyUrl:t.proxyUrl,isStarting:t.isStarting,error:t.error,canStartServer:t.canStartServer,retryServer:l,startServer:h}}function $s(t){const s=a.useRef(null),n=a.useRef(null);a.useEffect(()=>{if(typeof document>"u")return;n.current||(n.current=document.createElement("canvas"),n.current.width=64,n.current.height=64);const l=document.querySelector('link[rel="icon"]');if(!l)return;if(s.current||(s.current=l.href),!t){l.href=s.current;return}const h=new Image;h.crossOrigin="anonymous",h.onload=()=>{const c=n.current,o=c.getContext("2d");o.clearRect(0,0,64,64),o.drawImage(h,0,0,64,64);const p=18,x=64-p,k=p;o.beginPath(),o.arc(x,k,p+3,0,2*Math.PI),o.fillStyle="#ffffff",o.fill(),o.beginPath(),o.arc(x,k,p,0,2*Math.PI),o.fillStyle="#ef4444",o.fill(),l.href=c.toDataURL("image/png")},h.src=s.current},[t]),a.useEffect(()=>()=>{if(typeof document>"u")return;const l=document.querySelector('link[rel="icon"]');l&&s.current&&(l.href=s.current)},[])}const Gs=()=>[{title:"Editor - CodeYam"},{name:"description",content:"CodeYam Code + Data Editor"}];class Ts extends a.Component{constructor(){super(...arguments);et(this,"state",{error:null,errorInfo:null})}static getDerivedStateFromError(n){return{error:n,errorInfo:null}}componentDidCatch(n,l){console.error("[EditorErrorBoundary] Error:",n.message),console.error("[EditorErrorBoundary] Component stack:",l.componentStack),console.error("[EditorErrorBoundary] Loader snapshot:",JSON.stringify(this.props.loaderSnapshot,null,2)),this.setState({errorInfo:l})}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 Hs=Ot(function(){const{projectSlug:s,projectRoot:n,hasProject:l,scenarios:h,allScenarios:c,analyzedEntities:o,glossaryFunctions:p,glossaryEntries:x,entityImports:k,pageFilePaths:S,entityChangeStatus:y,modifiedFiles:w,featureName:M,userPrompt:b,projectTitle:B,projectDescription:L,defaultScreenSize:I,screenSizes:U,editorStep:R,editorStepLabel:$,claudeSessionId:D}=Ft(),[u,g]=Ut(),d=a.useRef(null),f=a.useRef(null),m=a.useRef(null),i=u.get("zoom")||void 0,v=u.get("scenario")||void 0,[C,P]=a.useState(()=>{if(typeof window>"u")return[];const r=new URLSearchParams(window.location.search).get("zoom");return r?[r]:[]}),_=a.useRef(null),J=a.useRef([]),q=a.useRef(null);a.useEffect(()=>{var A;const r=v||((A=Jt(c))==null?void 0:A.id);if(!Gt(r,_.current))return;const N=c.find(K=>K.id===r);if(!N)return;_.current=r;const E=Te(N,J.current,q.current);E&&Q(E);const T=he(N.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:T,scenarioId:N.id,scenarioName:N.name,scenarioType:N.type})}).catch(()=>{})},[v,c]),a.useEffect(()=>{const r=new BroadcastChannel("codeyam-editor");return r.onmessage=N=>{var E;if(((E=N.data)==null?void 0:E.type)==="switch-scenario"&&N.data.scenarioId){const T=N.data.scenarioId,A=c.find($e=>$e.id===T);if(!A)return;_.current=T;const K=new URLSearchParams(u);K.set("scenario",T),K.delete("zoom"),g(K),je(null),pe(null),H(null),V(!0);const Bt=he(A.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:Bt,scenarioId:T,scenarioType:A.type})}).then(()=>{oe($e=>$e+1)}).catch(()=>{V(!1)})}},()=>r.close()},[u,g,c]),a.useEffect(()=>{if(u.get("ref")!=="link"||!v)return;const r=new BroadcastChannel("codeyam-editor");r.postMessage({type:"switch-scenario",scenarioId:v}),r.close(),window.close()},[]);const{devServerUrl:X,proxyUrl:se,isStarting:ne,error:ae,canStartServer:j,retryServer:O,startServer:G}=Rs(),[_e,re]=a.useState(!1),[z,je]=a.useState(null),[Oe,pe]=a.useState(null),[be,Fe]=a.useState(!1),[ve,H]=a.useState(null),ut=a.useCallback(async r=>{const E=await(await fetch("/api/editor-load-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitSha:r})})).json();return E.success&&(H(null),re(!1)),E},[]),ht=a.useCallback((r,N)=>{pe(E=>(r&&r!==E&&re(!1),r)),!N&&r&&re(!0),Fe(N)},[]),Ue=a.useCallback(r=>{H(null),je(E=>(E&&E.analysisId===r.analysisId||(pe(null),oe(A=>A+1)),r)),Fe(!0),re(!1);const N=new URLSearchParams(u);N.delete("scenario"),N.delete("zoom"),g(N)},[u,g]),[F,Q]=a.useState(I?{name:I.name,width:I.width,height:I.height}:{name:"Desktop",width:1440,height:900}),[ze,We]=a.useState(!1),Je=I?{name:I.name,width:I.width,height:I.height}:null;q.current=Je;const[W,Z]=a.useState("app"),ft=a.useCallback(()=>{Z("build"),ie(!0)},[]),[gt,ie]=a.useState(!1),jt=!!(M&&R),[ue,Ne]=a.useState(jt?"pending":"no-session");a.useEffect(()=>{ue==="pending"&&(Z("build"),ie(!0))},[ue]);const bt=a.useCallback(()=>{Ne("continue")},[]),vt=a.useCallback(()=>{fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),Ne("fresh")},[]),Nt=a.useCallback(()=>{fetch("/api/editor-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})}).catch(()=>{}),Ne("fresh"),Z("app")},[]),[ye,we]=a.useState(!1),yt=a.useCallback(r=>{we(r)},[]);$s(ye);const[le,Ge]=a.useState("split"),[Se,He]=a.useState(!1),wt=a.useCallback(()=>{He(!0),Z("build"),ie(!0)},[]),Ve=a.useCallback(()=>{He(!1)},[]),St=a.useCallback(r=>{Q(r),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:r,skipBroadcast:!0})})},[]),[Ke,Ye]=a.useState(Ht);a.useEffect(()=>{const r=Vt();Ye(r),r.systemNotification&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]);const kt=a.useCallback(r=>{Ye(r),Kt(r)},[]);a.useEffect(()=>{if(W==="build"){we(!1);const r=setTimeout(()=>{var N,E;(N=d.current)==null||N.scrollToBottom(),(E=d.current)==null||E.focus()},50);return()=>clearTimeout(r)}},[W]),a.useEffect(()=>{function r(){!document.hidden&&W==="build"&&we(!1)}return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[W]);const[ke,Ct]=a.useState(null);a.useEffect(()=>{const r=m.current;if(!r)return;const N=new ResizeObserver(E=>{const T=E[0];T&&Ct({width:T.contentRect.width,height:T.contentRect.height})});return N.observe(r),()=>N.disconnect()},[]);const ee=a.useMemo(()=>ke?Yt(ke,F):1,[ke,F]),[Ce,oe]=a.useState(0),[qe,Pe]=a.useState(null),[Xe,V]=a.useState(!1),Pt=a.useCallback((r,N)=>{if(Pe(r||null),N){const E=new URLSearchParams(u);E.set("scenario",N),_.current=N,g(E);const T=c.find(A=>A.id===N);if(T){const A=Te(T,J.current,q.current);A&&Q(A)}}H(null),oe(E=>E+1)},[u,g,c]),{customSizes:Me,addCustomSize:Mt,removeCustomSize:Et}=zt(s),Ee=a.useMemo(()=>ns(U),[U]),Ie=a.useMemo(()=>[...Ee,...Me],[Ee,Me]);J.current=Ie;const Qe=a.useMemo(()=>{const r=[{name:"App"}];for(const N of C)r.push({name:N,componentName:N});return r},[C]),Re=a.useCallback(r=>{const N=new URLSearchParams(u);if(r){N.set("zoom",r);const E=C.indexOf(r);E>=0?P(C.slice(0,E+1)):P([...C,r]);const T=c.find(A=>A.componentName===r||A.componentName===null&&te(A.url)===r);if(T){N.set("scenario",T.id),_.current=T.id,V(!0);const A=he(T.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:A,scenarioId:T.id,scenarioType:T.type})}).then(()=>{oe(K=>K+1)}).catch(()=>{V(!1)})}else N.delete("scenario")}else N.delete("zoom"),N.delete("scenario"),P([]);g(N)},[u,g,c,C]),ce=a.useCallback(r=>{je(null),pe(null),H(null),Pe(null);const N=Te(r,Ie,Je);N&&Q(N),_.current=r.id;const E=new URLSearchParams(u);E.set("scenario",r.id),g(E),V(!0);const T=he(r.name);fetch("/api/editor-switch-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSlug:T,scenarioId:r.id,scenarioType:r.type,skipBroadcast:!0})}).then(()=>{oe(A=>A+1)}).catch(()=>{V(!1)})},[u,g,Ie]),It=a.useCallback(r=>{if(!r.commitSha){const N=c.find(E=>E.name===r.scenarioName);if(N){ce(N);return}}H(r)},[c,ce]),Rt=r=>{const N={name:r.name,width:r.width,height:r.height};Q(N),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:N,skipBroadcast:!0})})},$t=(r,N,E)=>{Mt(r,N,E)},Tt=r=>{Q(r),fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultScreenSize:r,skipBroadcast:!0})})},Lt=()=>{z||re(!0),V(!1)},de=a.useMemo(()=>qt({activeAnalyzedScenario:!!z,analyzedPreviewUrl:Oe,activeScenarioId:v||null,scenarios:c,proxyUrl:se,devServerUrl:X,zoomComponent:i||null}),[se,X,i,v,c,z,Oe]),Ze=a.useMemo(()=>{const r=Xt(de,qe);if(!r)return null;const N=r.includes("?")?"&":"?";return`${r}${N}__cb=${Ce}`},[de,qe,Ce]),At=a.useMemo(()=>({projectSlug:s,hasProject:l,scenarioCount:h==null?void 0:h.length,allScenarioCount:c==null?void 0:c.length,analyzedEntityCount:o==null?void 0:o.length,glossaryFunctionCount:p==null?void 0:p.length,entityChangeStatusKeys:y?Object.keys(y):[],featureName:M}),[s,l,h,c,o,p,y,M]);return e.jsx(Ts,{loaderSnapshot:At,children:e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[z&&e.jsx(Es,{analysisId:z.analysisId,scenarioId:z.scenarioId,scenarioName:z.scenarioName,entityName:z.entityName,projectSlug:s,onStateChange:ht},z.analysisId),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:le==="editor-only"?{display:"none"}:void 0,children:[e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 z-10 h-10 flex items-center px-4 relative",children:[e.jsx("div",{className:"flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>Ge(r=>r==="preview-only"?"split":"preview-only"),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:le==="preview-only"?"Show sidebar":"Hide sidebar",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("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})})}),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:[ge.map(r=>e.jsxs("button",{onClick:()=>Rt(r),className:`p-1.5 rounded transition-colors cursor-pointer ${F.name===r.name?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${r.name} (${r.width}×${r.height})`,children:[r.name==="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"})]}),r.name==="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"})]}),r.name==="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"})]}),r.name==="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"})]})]},r.name)),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>We(r=>!r),className:`flex items-center gap-1.5 px-2 py-1 rounded transition-colors cursor-pointer ${ze||!ge.some(r=>r.name===F.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.jsxs("span",{className:"text-xs font-mono",children:[F.width," ×"," ",F.height??900]})]}),ze&&e.jsx(Wt,{currentWidth:F.width,currentHeight:F.height??900,devicePresets:Ee,customSizes:Me,onApply:Tt,onSave:$t,onRemove:Et,onClose:()=>We(!1)})]})]})}),e.jsx("div",{className:"ml-auto flex items-center gap-1 shrink-0 z-10",children:e.jsx("button",{onClick:()=>{const r=Ze||de;r&&window.open(r,"_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"})]})})})]}),e.jsx("div",{ref:m,className:"flex-1 flex items-center justify-center overflow-hidden p-8",style:ve?{backgroundColor:"#f5f0e8",backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, #e8e0d0 19px, #e8e0d0 20px)"}:{backgroundImage:`
|
|
6
|
+
linear-gradient(45deg, #333 25%, transparent 25%),
|
|
7
|
+
linear-gradient(-45deg, #333 25%, transparent 25%),
|
|
8
|
+
linear-gradient(45deg, transparent 75%, #333 75%),
|
|
9
|
+
linear-gradient(-45deg, transparent 75%, #333 75%)
|
|
10
|
+
`,backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px",backgroundColor:"#2d2d2d"},children:ve?e.jsx(Ps,{preview:ve,onDismiss:()=>H(null),onLoadCommit:ut}):de?e.jsx("div",{style:{width:`${F.width*ee}px`,height:`${(F.height??900)*ee}px`},children:e.jsxs("div",{className:"relative bg-white origin-top-left",style:{width:`${F.width}px`,height:`${F.height??900}px`,transform:ee<1?`scale(${ee})`:void 0},children:[!_e&&!Xe&&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(tt,{})}),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"})]})]})}),Xe&&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:f,src:Ze||de,className:"w-full h-full border-none",title:"Editor preview",onLoad:Lt,style:{opacity:_e?1:0}},Ce)]})}):e.jsx("div",{className:"bg-[#2a2a2a] rounded-lg flex flex-col items-center justify-center",style:{width:`${F.width*ee}px`,height:`${(F.height??900)*ee}px`},children:ae?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:ae}),e.jsx("button",{onClick:O,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||be?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(tt,{})}),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:be?"Starting Interactive Mode":"Starting Dev Server"}),e.jsx("p",{className:"text-sm text-gray-400 leading-5 m-0 font-['IBM_Plex_Sans']",children:be?"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.jsxs("aside",{className:`bg-[#1e1e1e] border-r border-[#3d3d3d] shrink-0 flex flex-col overflow-hidden order-first ${le==="editor-only"?"w-full max-w-none min-w-0":"w-[50%] min-w-[400px] max-w-[800px]"}`,style:le==="preview-only"?{display:"none"}:void 0,children:[e.jsx(Cs,{activeTab:W,onTabChange:r=>{Z(r),r==="build"&&ie(!0)},buildIdle:ye,zoomComponent:i,breadcrumbItems:Qe,onBreadcrumbNavigate:Re,panelLayout:le,onToggleExpand:()=>Ge(r=>r==="editor-only"?"split":"editor-only")}),e.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[ye&&W!=="build"&&e.jsxs("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-50 animate-[slideDown_0.3s_ease-out]",children:[e.jsx("style",{children:`
|
|
11
|
+
@keyframes slideDown {
|
|
12
|
+
from { transform: translate(-50%, -100%); opacity: 0; }
|
|
13
|
+
to { transform: translate(-50%, 0); opacity: 1; }
|
|
14
|
+
}
|
|
15
|
+
`}),e.jsxs("button",{onClick:()=>{Z("build"),ie(!0)},className:"flex items-center gap-2 px-4 py-2 bg-amber-50 border-2 border-amber-300 rounded-lg shadow-lg cursor-pointer hover:bg-amber-100 transition-colors",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("span",{className:"text-sm font-medium text-amber-900",children:"Claude is waiting for you"}),e.jsx("span",{className:"text-xs text-amber-600 ml-1",children:"Go to Build"})]})]}),gt&&e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="build"?"visible":"hidden"},children:[e.jsx("div",{className:Se?"flex-1 min-h-0":"flex-1",style:Se?{flex:"1 1 50%"}:void 0,children:ue==="pending"?e.jsx(as,{featureName:M,editorStep:R,editorStepLabel:$,onContinue:bt,onStartFresh:vt,onReview:Nt}):e.jsx(Qt,{ref:d,entityName:"Editor",projectSlug:s,entityFilePath:null,scenarioName:null,onRefreshPreview:Pt,onShowResults:wt,onHideResults:Ve,onSetViewport:St,editorMode:!0,onIdleChange:yt,notificationSettings:Ke,buildTabActive:W==="build",claudeStartMode:ue==="continue"?"resume":"fresh",claudeSessionId:D})}),Se&&e.jsx("div",{style:{flex:"1 1 50%"},className:"min-h-0 border-t-2 border-gray-300",children:e.jsx(Ss,{scenarios:h,allScenarios:c,glossaryFunctions:p,projectRoot:n,activeScenarioId:v,onScenarioSelect:ce,onClose:Ve,entityChangeStatus:y,modifiedFiles:w,featureName:M,userPrompt:b})})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="app"?"visible":"hidden"},children:e.jsx(Ns,{hasProject:l,scenarios:c,analyzedEntities:o,glossaryFunctions:p,glossaryEntries:x,projectRoot:n,activeScenarioId:v,onScenarioSelect:ce,onAnalyzedScenarioSelect:Ue,onSwitchToBuild:ft,zoomComponent:i,onZoomChange:Re,entityImports:k,pageFilePaths:S,projectTitle:B,projectDescription:L,breadcrumbItems:Qe})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="data"?"visible":"hidden"},children:e.jsx(is,{scenarios:c,projectRoot:n,activeScenarioId:v,onScenarioSelect:ce,zoomComponent:i,onZoomChange:Re,analyzedEntities:[],glossaryFunctions:p,activeAnalyzedScenarioId:z==null?void 0:z.scenarioId,onAnalyzedScenarioSelect:Ue,entityImports:k,pageFilePaths:S})}),e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:W==="journal"?"visible":"hidden"},children:e.jsx(js,{isActive:W==="journal",onScreenshotClick:It,glossaryFunctions:p})})]}),e.jsx(Zt,{serverUrl:X,isStarting:ne,projectSlug:s,devServerError:ae,onStartServer:j?G:void 0,notificationSettings:Ke,onChangeNotificationSettings:kt})]})]})]})})});export{Hs as default,Gs as meta};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-Duc5hnl7.js","assets/chunk-JZWAC4HX-C4pqxYJB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as l,j as a}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{_ as V}from"./preload-helper-ckwbz45p.js";const B={sound:"soft-double-tap",systemNotification:!0},de=[{id:"soft-double-tap",label:"Soft double tap"},{id:"gentle-chime",label:"Gentle chime"},{id:"warm-ding",label:"Warm ding"},{id:"mellow-two-tone",label:"Mellow two-tone"},{id:"triangle-bell",label:"Triangle bell"},{id:"off",label:"No sound"}],ne="codeyam-editor-notifications";function ye(){try{const r=localStorage.getItem(ne);if(!r)return B;const n=JSON.parse(r);return typeof n=="string"?n==="true"?B:{...B,sound:"off",systemNotification:!1}:{...B,...n}}catch{return B}}function we(r){localStorage.setItem(ne,JSON.stringify(r))}function oe(r){var n;if(r!=="off")try{const c=new AudioContext,s={"soft-double-tap":e=>{[0,.12].forEach(t=>{const o=e.createOscillator(),y=e.createGain();o.connect(y),y.connect(e.destination),o.type="sine",o.frequency.value=392,y.gain.setValueAtTime(.25,e.currentTime+t),y.gain.exponentialRampToValueAtTime(.01,e.currentTime+t+.1),o.start(e.currentTime+t),o.stop(e.currentTime+t+.1)})},"gentle-chime":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.setValueAtTime(523,e.currentTime),t.frequency.setValueAtTime(659,e.currentTime+.15),o.gain.setValueAtTime(.3,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.4),t.start(),t.stop(e.currentTime+.4)},"warm-ding":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.value=330,o.gain.setValueAtTime(.35,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.6),t.start(),t.stop(e.currentTime+.6)},"mellow-two-tone":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="sine",t.frequency.setValueAtTime(294,e.currentTime),t.frequency.setValueAtTime(440,e.currentTime+.18),o.gain.setValueAtTime(.3,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.5),t.start(),t.stop(e.currentTime+.5)},"triangle-bell":e=>{const t=e.createOscillator(),o=e.createGain();t.connect(o),o.connect(e.destination),t.type="triangle",t.frequency.value=523,o.gain.setValueAtTime(.4,e.currentTime),o.gain.exponentialRampToValueAtTime(.01,e.currentTime+.8),t.start(),t.stop(e.currentTime+.8)}};(n=s[r])==null||n.call(s,c)}catch{}}function ve({serverUrl:r,isStarting:n,projectSlug:c,devServerError:s,onStartServer:e,notificationSettings:t,onChangeNotificationSettings:o}){const[y,S]=l.useState(null),[f,w]=l.useState(!1),A=l.useRef(null),E=l.useRef(null);l.useEffect(()=>{if(!c)return;const p=new EventSource("/api/dev-mode-events");return p.onmessage=_=>{try{const $=JSON.parse(_.data);$.type==="file-synced"&&(S($.fileName),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{S(null)},5e3))}catch{}},()=>{p.close(),E.current&&clearTimeout(E.current)}},[c]),l.useEffect(()=>{if(!f)return;function p(_){A.current&&!A.current.contains(_.target)&&w(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[f]);let T;s?T="error":n?T="starting":r?T="running":T="stopped";const k={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},P={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},W=t&&(t.sound!=="off"||t.systemNotification);return a.jsxs("div",{className:"bg-[#1e1e1e] border-t border-[#3d3d3d] h-7 flex items-center px-4 gap-4 shrink-0 text-xs font-mono",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${k[T]}`}),a.jsxs("span",{className:"text-gray-400",children:["Server:"," ",a.jsx("span",{className:"text-gray-300",children:P[T]})]}),(T==="stopped"||T==="error")&&e&&a.jsx("button",{onClick:e,className:"ml-1 px-2.5 py-0.5 bg-[#005c75] hover:bg-[#007a9a] text-white text-[11px] font-medium rounded transition-colors cursor-pointer border-none leading-tight",children:"Start Server"})]}),a.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),y&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:a.jsx("path",{d:"M20 6L9 17l-5-5"})}),a.jsxs("span",{className:"text-green-400",children:["Synced: ",y]})]}),a.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),a.jsx("div",{className:"flex-1"}),o&&t&&a.jsxs("div",{className:"relative",ref:A,children:[a.jsx("button",{onClick:()=>w(!f),className:`text-[11px] rounded transition-colors cursor-pointer ${W?"text-green-400 hover:text-green-300":"text-gray-500 hover:text-gray-300"}`,children:W?"Notifications On":"Notifications Off"}),f&&a.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 bg-[#2d2d2d] border border-[#4d4d4d] rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:de.map(p=>a.jsx("button",{onClick:()=>{o({...t,sound:p.id}),p.id!=="off"&&oe(p.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${t.sound===p.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:p.label},p.id))})]}),a.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.systemNotification,onChange:p=>{const _=p.target.checked;o({...t,systemNotification:_}),_&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),a.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),a.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function me(r,n){try{const{WebglAddon:s}=await V(async()=>{const{WebglAddon:t}=await import("./addon-webgl-DI8QOUvO.js").then(o=>o.a);return{WebglAddon:t}},[]),e=new s;return e.onContextLoss(()=>{n==null||n("webgl","canvas",new Error("WebGL context lost")),e.dispose(),re(r).then(t=>{t||n==null||n("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),r.loadAddon(e),{type:"webgl",dispose:()=>e.dispose()}}catch(s){n==null||n("webgl","canvas",s)}const c=await re(r);return c||(n==null||n("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function re(r){try{const{CanvasAddon:n}=await V(async()=>{const{CanvasAddon:s}=await import("./addon-canvas-DpzMmAy5.js").then(e=>e.a);return{CanvasAddon:s}},[]),c=new n;return r.loadAddon(c),{type:"canvas",dispose:()=>c.dispose()}}catch{return null}}const fe=`
|
|
3
|
+
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
4
|
+
.xterm.focus, .xterm:focus { outline: none; }
|
|
5
|
+
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
6
|
+
.xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
|
|
7
|
+
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
8
|
+
.xterm .composition-view.active { display: block; }
|
|
9
|
+
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
10
|
+
.xterm .xterm-screen { position: relative; }
|
|
11
|
+
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
12
|
+
.xterm .xterm-scroll-area { visibility: hidden; }
|
|
13
|
+
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
14
|
+
.xterm.enable-mouse-events { cursor: default; }
|
|
15
|
+
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
16
|
+
.xterm.column-select.focus { cursor: crosshair; }
|
|
17
|
+
.xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
|
|
18
|
+
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
19
|
+
.xterm .xterm-accessibility-tree { user-select: text; white-space: pre; }
|
|
20
|
+
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
21
|
+
.xterm-dim { opacity: 1 !important; }
|
|
22
|
+
.xterm-underline-1 { text-decoration: underline; }
|
|
23
|
+
.xterm-underline-2 { text-decoration: double underline; }
|
|
24
|
+
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
25
|
+
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
26
|
+
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
27
|
+
.xterm-overline { text-decoration: overline; }
|
|
28
|
+
.xterm-strikethrough { text-decoration: line-through; }
|
|
29
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
30
|
+
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
31
|
+
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
32
|
+
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
33
|
+
`;function pe(){if(document.getElementById("xterm-css"))return;const r=document.createElement("style");r.id="xterm-css",r.textContent=fe,document.head.appendChild(r)}const be=l.forwardRef(function({entityName:n,entityType:c,entitySha:s,entityFilePath:e,scenarioName:t,scenarioDescription:o,analysisId:y,projectSlug:S,onRefreshPreview:f,onShowResults:w,onHideResults:A,onSetViewport:E,editorMode:T,onIdleChange:k,notificationSettings:P,buildTabActive:W,claudeStartMode:p,claudeSessionId:_},$){const J=l.useRef(null),z=l.useRef(null),M=l.useRef(null),j=l.useRef(null),q=l.useRef(null),H=l.useRef(!1),D=l.useRef(0),U=l.useRef(!1),N=l.useRef(k);N.current=k;const Z=l.useRef(P);Z.current=P;const Q=l.useRef(W);Q.current=W;const O=l.useRef(null);function X(){O.current&&(O.current.close(),O.current=null)}l.useEffect(()=>{function m(){X()}function x(){document.hidden||X()}return window.addEventListener("focus",m),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",m),document.removeEventListener("visibilitychange",x)}},[]);const ie=l.useCallback(()=>{var m;(m=M.current)==null||m.focus()},[]);return l.useImperativeHandle($,()=>({sendInput(m){const x=j.current;x&&x.readyState===WebSocket.OPEN&&(x.send(JSON.stringify({type:"input",data:m})),setTimeout(()=>{x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var m;(m=M.current)==null||m.focus()},scrollToBottom(){var x;const m=(x=J.current)==null?void 0:x.querySelector(".xterm-viewport");m&&(m.scrollTop=m.scrollHeight)}})),l.useEffect(()=>{const m=J.current;if(!m)return;let x=!1;return pe(),Promise.all([V(()=>import("./xterm-BqvuqXEL.js"),[]),V(()=>import("./addon-fit-YJmn1quW.js"),[]),V(()=>import("./addon-web-links-Duc5hnl7.js").then(L=>L.a),__vite__mapDeps([0,1]))]).then(([L,se,ce])=>{if(x)return;const u=new L.Terminal({cursorBlink:!0,scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"},linkHandler:{activate(d,i){try{const h=new URL(i),v=h.searchParams.get("scenario");if(v&&h.pathname==="/editor"){const b=new BroadcastChannel("codeyam-editor");b.postMessage({type:"switch-scenario",scenarioId:v}),b.close();return}}catch{}window.open(i,"_blank")}}}),I=new se.FitAddon;u.loadAddon(I),u.loadAddon(new ce.WebLinksAddon),u.open(m);let G=null;me(u,(d,i,h)=>{console.warn(`[Terminal] Renderer fallback: ${d} → ${i}`,h)}).then(d=>{if(x){d.dispose();return}console.log(`[Terminal] Using ${d.type} renderer`),G=d.dispose}),requestAnimationFrame(()=>{try{I.fit()}catch{}}),M.current=u,u.focus(),setTimeout(()=>u.focus(),100),setTimeout(()=>u.focus(),500);const ae=window.location.protocol==="https:"?"wss:":"ws:",le=window.location.host;function ue(d){const i=new URLSearchParams;return i.set("entityName",n),c&&i.set("entityType",c),s&&i.set("entitySha",s),e&&i.set("entityFilePath",e),t&&i.set("scenarioName",t),o&&i.set("scenarioDescription",o),y&&i.set("analysisId",y),S&&i.set("projectSlug",S),T&&i.set("editorMode","true"),d&&i.set("reconnectId",d),p&&i.set("claudeStartMode",p),_&&i.set("claudeSessionId",_),`${ae}//${le}/ws/terminal?${i.toString()}`}function K(d){const i=ue(d),h=new WebSocket(i);j.current=h,h.onopen=()=>{D.current=0,U.current=!1,h.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))},h.onmessage=v=>{var b,ee,te;try{const g=JSON.parse(v.data);if(g.type==="session-id"){q.current=g.sessionId;return}if(g.type==="refresh-preview"){f==null||f(g.path,g.scenarioId);return}if(g.type==="show-results"){w==null||w();return}if(g.type==="hide-results"){A==null||A();return}if(g.type==="set-viewport"){E==null||E({name:g.name,width:g.width,height:g.height});return}if(g.type==="claude-idle"){(b=N.current)==null||b.call(N,!0);const R=Z.current;if(Q.current)return;if(R!=null&&R.sound&&R.sound!=="off"&&oe(R.sound),!document.hasFocus()&&(R!=null&&R.systemNotification)&&typeof Notification<"u"&&Notification.permission==="granted"){O.current&&O.current.close();const Y=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});Y.onclick=()=>{window.focus(),Y.close()},O.current=Y}return}if(g.type==="claude-active"){(ee=N.current)==null||ee.call(N,!1),O.current&&(O.current.close(),O.current=null);return}g.type==="output"&&(u.write(g.data),(te=N.current)==null||te.call(N,!1))}catch{u.write(v.data)}},h.onclose=()=>{if(H.current){u.write(`\r
|
|
34
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
35
|
+
`);return}const v=D.current;if(v<5&&q.current){const b=1e3*Math.pow(2,Math.min(v,3));D.current=v+1,u.write(`\r
|
|
36
|
+
\x1B[33m[Reconnecting...]\x1B[0m\r
|
|
37
|
+
`),setTimeout(()=>{H.current||K(q.current)},b)}else U.current?u.write(`\r
|
|
38
|
+
\x1B[90m[Terminal session ended]\x1B[0m\r
|
|
39
|
+
`):(U.current=!0,u.write(`\r
|
|
40
|
+
\x1B[33m[Starting new session...]\x1B[0m\r
|
|
41
|
+
`),q.current=null,D.current=0,K())},h.onerror=()=>{}}K(),u.onData(d=>{const i=j.current;i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:"input",data:d})),X()});let C=null;const F=new ResizeObserver(()=>{C&&clearTimeout(C),C=setTimeout(()=>{let d;try{d=I.proposeDimensions()}catch{return}if(!d||d.cols===u.cols&&d.rows===u.rows)return;const i=m.querySelector(".xterm-viewport");let h,v=!0;i&&(h=i.scrollTop,v=i.scrollTop+i.clientHeight>=i.scrollHeight-10),I.fit(),i&&h!==void 0&&(v?i.scrollTop=i.scrollHeight:i.scrollTop=h);const b=j.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))},150)});F.observe(m),z.current=()=>{var d;C&&clearTimeout(C),F.disconnect(),H.current=!0,(d=j.current)==null||d.close(),j.current=null,G==null||G(),u.dispose(),M.current=null}}),()=>{var L;x=!0,(L=z.current)==null||L.call(z),z.current=null}},[]),a.jsx("div",{ref:J,onClick:ie,className:"w-full h-full",style:{padding:"4px 0 0 8px"}})});function xe(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function Te(r){const{activeAnalyzedScenario:n,analyzedPreviewUrl:c,activeScenarioId:s,scenarios:e,proxyUrl:t,devServerUrl:o,zoomComponent:y}=r;if(n&&c)return c;if(n&&!c)return null;if(s){const f=e.find(w=>w.id===s);if(f!=null&&f.url){const w=t||o;return w?f.url.startsWith("/")?`${w}${f.url}`:f.url:null}}const S=t||o;if(!S)return null;if(y&&s){const f=e.find(A=>A.id===s),w=f?xe(f.name):"Default";return`${S}/__codeyam__/${y}/${w}`}return S}function Ne(r,n){if(!r||!n)return r;try{const c=new URL(r),s=n.indexOf("?");return s>=0?(c.pathname=n.slice(0,s),c.search=n.slice(s)):(c.pathname=n,c.search=""),c.href}catch{return r}}function Se(r,n){return r?r!==n:!1}function Ae(r){if(r.length!==0)return r.find(n=>n.type==="application")||r[0]}function Ee(r,n,c){if(!r.viewportWidth||!r.viewportHeight)return c??null;const s=n.find(e=>e.width===r.viewportWidth&&e.height===r.viewportHeight);return{name:(s==null?void 0:s.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function _e(r,n){const c=n.width,s=n.height??900,e=r.width,t=r.height;return c<=e&&s<=t?1:Math.min(e/c,t/s)}export{ve as D,be as T,Ne as a,xe as b,B as c,we as d,_e as e,Te as f,Ae as g,ye as l,Ee as r,Se as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n,L as Y,r as L,f as cm,d as Fe,b as Pm,R as Ne,I as at,g as zm,c as jm,w as qm,u as Hm,k as Gm,a as $m}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as Wm}from"./useLastLogLine-C14nCb1q.js";import{u as Vm}from"./Spinner-Bb5uFQ5V.js";import{W as Ym,I as Km}from"./InteractivePreview-DYFW3lDD.js";import{S as $e}from"./SafeScreenshot-BED4B6sP.js";import{L as Xm}from"./LibraryFunctionPreview-DLeucoVX.js";import{L as Zm}from"./LoadingDots-BU_OAEMP.js";import{g as Qm}from"./scenarioStatus-B_8jpV3e.js";import{E as Jm,S as ef}from"./ScenarioViewer-
|
|
1
|
+
import{j as n,L as Y,r as L,f as cm,d as Fe,b as Pm,R as Ne,I as at,g as zm,c as jm,w as qm,u as Hm,k as Gm,a as $m}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as Wm}from"./useLastLogLine-C14nCb1q.js";import{u as Vm}from"./Spinner-Bb5uFQ5V.js";import{W as Ym,I as Km}from"./InteractivePreview-DYFW3lDD.js";import{S as $e}from"./SafeScreenshot-BED4B6sP.js";import{L as Xm}from"./LibraryFunctionPreview-DLeucoVX.js";import{L as Zm}from"./LoadingDots-BU_OAEMP.js";import{g as Qm}from"./scenarioStatus-B_8jpV3e.js";import{E as Jm,S as ef}from"./ScenarioViewer-TSD3C211.js";import{c as tf}from"./createLucideIcon-CC6AbExI.js";import{c as um,g as rf}from"./executionFlowCoverage-BWhdfn70.js";import{E as El}from"./EntityTypeIcon-CQIG2qda.js";import{C as dm}from"./CopyButton-BPXZwM4t.js";import{L as af}from"./LogViewer-ceAyBX-H.js";import{u as nf}from"./useReportContext-O-jkvSPx.js";import"./preload-helper-ckwbz45p.js";import"./InlineSpinner-Bu6c6aDe.js";import"./ViewportInspectBar-oAf2Kqsf.js";import"./useCustomSizes-C-_hOl_g.js";import"./ReportIssueModal-BzHcG7SE.js";import"./circle-check-BVMi9VA5.js";import"./triangle-alert-BLdiCuG-.js";import"./copy-n2FB0_Sw.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as V,j as e,w as re,u as oe,r as i}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as le,S as W}from"./Spinner-Bb5uFQ5V.js";import{u as ce}from"./useLastLogLine-C14nCb1q.js";import{V as de}from"./ViewportInspectBar-oAf2Kqsf.js";import{u as he,S as xe}from"./useCustomSizes-
|
|
1
|
+
import{a as V,j as e,w as re,u as oe,r as i}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as le,S as W}from"./Spinner-Bb5uFQ5V.js";import{u as ce}from"./useLastLogLine-C14nCb1q.js";import{V as de}from"./ViewportInspectBar-oAf2Kqsf.js";import{u as he,S as xe}from"./useCustomSizes-C-_hOl_g.js";import{c as me}from"./cy-logo-cli-DcX-ZS3p.js";import{I as E}from"./InlineSpinner-Bu6c6aDe.js";import{a as ue,T as pe,D as ge}from"./editorPreview-7Uga8I59.js";import{S as fe}from"./SafeScreenshot-BED4B6sP.js";import"./preload-helper-ckwbz45p.js";function ve({scenarios:w,currentScenarioId:r,entitySha:s,cacheBuster:l}){const c=V();return w.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:e.jsx("p",{className:"text-gray-500 text-sm",children:"No scenarios found"})}):e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:w.map(o=>{var j,u;const g=o.id===r,f=(u=(j=o.metadata)==null?void 0:j.screenshotPaths)==null?void 0:u[0];return e.jsxs("button",{onClick:()=>{c(`/entity/${s}/scenarios/${o.id}/dev`)},className:`w-full text-left rounded-lg overflow-hidden border transition-colors cursor-pointer flex ${g?"border-[#005c75] bg-[#1a3a44]":"border-[#3d3d3d] bg-[#252525] hover:border-[#555]"}`,children:[e.jsx("div",{className:"w-24 h-20 shrink-0 bg-[#1a1a1a]",children:e.jsx(fe,{screenshotPath:f,cacheBuster:l,alt:o.name,className:"w-full h-full object-cover object-top"})}),e.jsxs("div",{className:"p-2.5 min-w-0 flex-1",children:[e.jsxs("div",{className:"text-white text-sm font-medium truncate",children:[g&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-[#005c75] mr-1.5 relative top-[-1px]"}),o.name]}),o.description&&e.jsx("div",{className:"text-gray-400 text-xs mt-1 line-clamp-2",children:o.description})]})]},o.id)})})}const I=[{name:"Mobile",width:375,height:667},{name:"Tablet",width:768,height:1024},{name:"Laptop",width:1024,height:768},{name:"Desktop",width:1440,height:900}],Me=re(function(){const{entity:r,scenario:s,analysis:l,projectSlug:c}=oe(),o=V(),g=i.useRef(null),f=i.useRef(null),[j,u]=i.useState(null),[A,M]=i.useState(1440),[n,N]=i.useState({name:"Desktop",width:1440,height:900}),[H,y]=i.useState(!1),[S,U]=i.useState(null),[d,k]=i.useState("chat"),[F,q]=i.useState(0),[D,$]=i.useState(null),K=i.useCallback(t=>{$(t||null),q(a=>a+1)},[]),{customSizes:_,addCustomSize:Y}=he(c),v=i.useMemo(()=>[...I,..._],[_]),{interactiveServerUrl:h,isStarting:C,isLoading:z,showIframe:B,iframeKey:G,onIframeLoad:J}=le({analysisId:l==null?void 0:l.id,scenarioId:s==null?void 0:s.id,scenarioName:s==null?void 0:s.name,projectSlug:c,enabled:!0,refreshTrigger:F}),O=i.useMemo(()=>ue(h,D),[h,D]),{lastLine:b}=ce(c,C||z),Q=()=>{o(`/entity/${r.sha}`)},X=(t,a)=>{M(t);const m=v.find(T=>T.width===t&&T.height===a);u(m||null),N({name:(m==null?void 0:m.name)||"Custom",width:t,height:a})},R=t=>{u(t),M(t.width),N({name:t.name,width:t.width,height:t.height})},Z=t=>{Y(t,n.width,n.height??900),y(!1),N(a=>({...a,name:t}))},ee=()=>{var a;k("chat"),(a=f.current)==null||a.sendInput("Create a new scenario for this entity based on the work we've just done. Create a name and description that reflects what the live preview is showing. Use the scenario data you've changed to create a new scenario in the database. If the data structure was fixed in any way you need to update that in the database as well and backfill all existing scenarios, then save to the database and capture a screenshot. Remember the database is at `.codeyam/db.sqlite3`, the scenarios table has all scenarios and the analyses table contains the scenariosDataStructure is its metadata.")},x=((l==null?void 0:l.scenarios)||[]).filter(t=>{var a;return!((a=t.metadata)!=null&&a.sameAsDefault)}),p=x.findIndex(t=>t.id===(s==null?void 0:s.id)),te=p+1,se=x.length,L=p>0,P=p<x.length-1,ae=()=>{if(L){const t=x[p-1];o(`/entity/${r.sha}/scenarios/${t.id}/dev`)}},ne=()=>{if(P){const t=x[p+1];o(`/entity/${r.sha}/scenarios/${t.id}/dev`)}},ie=C||z||!B;return e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[e.jsxs("div",{className:"bg-[#3d3d3d] h-12 flex items-center px-4 gap-4 shrink-0 z-20",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("img",{src:me,alt:"CodeYam",className:"h-6 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-sm whitespace-nowrap",children:r.name}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:ae,disabled:!L,className:`${L?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Previous scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 15L7.5 10L12.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("span",{className:"text-gray-400 text-sm",children:[te,"/",se]}),e.jsx("button",{onClick:ne,disabled:!P,className:`${P?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Next scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M7.5 15L12.5 10L7.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 min-w-0",children:[e.jsx("span",{className:"text-white font-semibold text-xs whitespace-nowrap shrink-0",children:s==null?void 0:s.name}),(s==null?void 0:s.description)&&e.jsxs("div",{className:"relative group min-w-0",children:[e.jsx("span",{className:"text-gray-400 text-xs truncate block",children:s.description}),e.jsx("div",{className:"absolute left-0 top-full mt-1 hidden group-hover:block z-50 bg-black text-white text-xs px-3 py-2 rounded shadow-lg max-w-md",children:s.description})]})]}),e.jsx("span",{className:"bg-[#005c75] text-white text-[10px] font-bold px-2 py-0.5 rounded uppercase tracking-wider ml-2",children:"Dev Mode"})]}),e.jsx("button",{onClick:Q,className:"text-white hover:text-gray-300 transition-colors ml-4","aria-label":"Close dev mode",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"bg-[#e5e7eb] border-b border-[rgba(0,0,0,0.1)] shrink-0 z-10 h-6 flex items-center justify-center relative",children:[e.jsx("div",{className:"absolute inset-0 flex justify-center",children:e.jsx("div",{style:{maxWidth:`${I[I.length-1].width}px`,width:"100%"},children:e.jsx(de,{currentViewportWidth:A,currentPresetName:n.name,onDevicePresetClick:R,devicePresets:v,hideLabel:!0,onHoverChange:U,lightMode:!0})})}),e.jsxs("div",{className:"relative z-10 flex items-center gap-2",children:[e.jsxs("div",{className:"relative w-28 h-5",children:[e.jsxs("div",{className:"absolute inset-0 bg-white text-gray-900 text-xs px-2 rounded flex items-center justify-between pointer-events-none border border-gray-300",children:[e.jsx("span",{className:"leading-none",children:(S==null?void 0:S.name)||n.name}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsxs("select",{value:n.name,onChange:t=>{const a=v.find(m=>m.name===t.target.value);a&&R(a)},className:"relative w-full h-full opacity-0 cursor-pointer",children:[v.map(t=>e.jsx("option",{value:t.name,children:t.name},t.name)),n.name==="Custom"&&e.jsx("option",{value:"Custom",children:"Custom"})]})]}),e.jsx("input",{type:"number",value:n.width,onChange:t=>{const a=parseInt(t.target.value,10);!isNaN(a)&&a>0&&X(a,n.height??900)},className:"bg-white text-gray-900 text-xs px-1 rounded border border-gray-300 outline-none w-16 text-center h-5 leading-none",min:"200",max:"3840"}),e.jsx("span",{className:"text-gray-400 text-xs h-5 flex items-center leading-none",children:"x"}),e.jsx("span",{className:"bg-gray-100 text-gray-600 text-xs px-1 rounded w-14 text-center h-5 flex items-center justify-center leading-none",children:n.height??900}),n.name==="Custom"&&e.jsx("button",{onClick:()=>y(!0),className:"bg-white text-gray-900 text-xs px-2 rounded h-5 flex items-center leading-none border border-gray-300 hover:bg-gray-50 transition-colors",children:"Save"})]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center overflow-auto p-8",style:{backgroundImage:`
|
|
2
2
|
linear-gradient(45deg, #ebebeb 25%, transparent 25%),
|
|
3
3
|
linear-gradient(-45deg, #ebebeb 25%, transparent 25%),
|
|
4
4
|
linear-gradient(45deg, transparent 75%, #ebebeb 75%),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as X,u as Z,a as ee,b as te,r as i,j as e}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as se,S as z}from"./Spinner-Bb5uFQ5V.js";import{u as ne}from"./useLastLogLine-C14nCb1q.js";import{V as ae}from"./ViewportInspectBar-oAf2Kqsf.js";import{u as ie,S as re}from"./useCustomSizes-
|
|
1
|
+
import{w as X,u as Z,a as ee,b as te,r as i,j as e}from"./chunk-JZWAC4HX-C4pqxYJB.js";import{u as se,S as z}from"./Spinner-Bb5uFQ5V.js";import{u as ne}from"./useLastLogLine-C14nCb1q.js";import{V as ae}from"./ViewportInspectBar-oAf2Kqsf.js";import{u as ie,S as re}from"./useCustomSizes-C-_hOl_g.js";import{c as oe}from"./cy-logo-cli-DcX-ZS3p.js";import{I as B}from"./InlineSpinner-Bu6c6aDe.js";const N=[{name:"Mobile",width:375,height:667},{name:"Tablet",width:768,height:1024},{name:"Laptop",width:1024,height:768},{name:"Desktop",width:1920,height:1080}],fe=X(function(){const{entity:o,scenario:s,analysis:l,projectSlug:p}=Z(),f=ee();te();const[ce,y]=i.useState(null),[E,k]=i.useState(1920),[a,v]=i.useState({name:"Desktop",width:1920,height:1080}),[W,b]=i.useState(!1),[w,D]=i.useState(null),{customSizes:C,addCustomSize:R}=ie(p),h=i.useMemo(()=>[...N,...C],[C]),x=i.useRef(null),[H,U]=i.useState(1),m=i.useCallback(()=>{if(!x.current)return;const t=32,n=x.current.clientWidth-t,r=x.current.clientHeight-t,_=a.width,g=a.height??900,Q=Math.min(1,n/_,r/g);U(Q)},[a.width,a.height]);i.useEffect(()=>(m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)),[m]);const{interactiveServerUrl:L,isStarting:I,isLoading:M,showIframe:P,iframeKey:V,onIframeLoad:T}=se({analysisId:l==null?void 0:l.id,scenarioId:s==null?void 0:s.id,scenarioName:s==null?void 0:s.name,projectSlug:p,enabled:!0}),{lastLine:u}=ne(p,I||M),A=()=>{f(`/entity/${o.sha}`)},F=(t,n)=>{k(t);const r=h.find(g=>g.width===t&&g.height===n);y(r||null),v({name:(r==null?void 0:r.name)||"Custom",width:t,height:n})},$=t=>{y(t),k(t.width),v({name:t.name,width:t.width,height:t.height})},K=t=>{R(t,a.width,a.height??900),b(!1),v(n=>({...n,name:t}))},c=((l==null?void 0:l.scenarios)||[]).filter(t=>{var n;return!((n=t.metadata)!=null&&n.sameAsDefault)}),d=c.findIndex(t=>t.id===(s==null?void 0:s.id)),O=d+1,Y=c.length,j=d>0,S=d<c.length-1,q=()=>{if(j){const t=c[d-1],n=encodeURIComponent(`/entity/${o.sha}/scenarios/${t.id}/fullscreen`);f(`/entity/${o.sha}/scenarios/${t.id}/fullscreen?from=${n}`)}},G=()=>{if(S){const t=c[d+1],n=encodeURIComponent(`/entity/${o.sha}/scenarios/${t.id}/fullscreen`);f(`/entity/${o.sha}/scenarios/${t.id}/fullscreen?from=${n}`)}},J=I||M||!P;return e.jsxs("div",{className:"fixed inset-0 bg-[#2d2d2d] flex flex-col",children:[e.jsxs("div",{className:"bg-[#3d3d3d] h-12 flex items-center px-4 gap-4 shrink-0 z-20",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("img",{src:oe,alt:"CodeYam",className:"h-6 brightness-0 invert"}),e.jsx("span",{className:"text-white font-medium text-sm whitespace-nowrap",children:o.name}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:q,disabled:!j,className:`${j?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Previous scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 15L7.5 10L12.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("span",{className:"text-gray-400 text-sm",children:[O,"/",Y]}),e.jsx("button",{onClick:G,disabled:!S,className:`${S?"text-white hover:text-gray-300":"text-gray-600 cursor-not-allowed"} transition-colors`,"aria-label":"Next scenario",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M7.5 15L12.5 10L7.5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 min-w-0",children:[e.jsx("span",{className:"text-white font-semibold text-xs whitespace-nowrap shrink-0",children:s==null?void 0:s.name}),(s==null?void 0:s.description)&&e.jsxs("div",{className:"relative group min-w-0",children:[e.jsx("span",{className:"text-gray-400 text-xs truncate block",children:s.description}),e.jsx("div",{className:"absolute left-0 top-full mt-1 hidden group-hover:block z-50 bg-black text-white text-xs px-3 py-2 rounded shadow-lg max-w-md",children:s.description})]})]})]}),e.jsx("button",{onClick:A,className:"text-white hover:text-gray-300 transition-colors ml-4","aria-label":"Close fullscreen",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"bg-[#e5e7eb] border-b border-[rgba(0,0,0,0.1)] shrink-0 z-10 h-6 flex items-center justify-center relative",children:[e.jsx("div",{className:"absolute inset-0 flex justify-center",children:e.jsx("div",{style:{maxWidth:`${N[N.length-1].width}px`,width:"100%"},children:e.jsx(ae,{currentViewportWidth:E,currentPresetName:a.name,onDevicePresetClick:$,devicePresets:h,hideLabel:!0,onHoverChange:D,lightMode:!0})})}),e.jsxs("div",{className:"relative z-10 flex items-center gap-2",children:[e.jsxs("div",{className:"relative w-28 h-5",children:[e.jsxs("div",{className:"absolute inset-0 bg-white text-gray-900 text-xs px-2 rounded flex items-center justify-between pointer-events-none border border-gray-300",children:[e.jsx("span",{className:"leading-none",children:(w==null?void 0:w.name)||a.name}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e.jsxs("select",{value:a.name,onChange:t=>{const n=h.find(r=>r.name===t.target.value);n&&$(n)},className:"relative w-full h-full opacity-0 cursor-pointer",children:[h.map(t=>e.jsx("option",{value:t.name,children:t.name},t.name)),a.name==="Custom"&&e.jsx("option",{value:"Custom",children:"Custom"})]})]}),e.jsx("input",{type:"number",value:a.width,onChange:t=>{const n=parseInt(t.target.value,10);!isNaN(n)&&n>0&&F(n,a.height??900)},className:"bg-white text-gray-900 text-xs px-1 rounded border border-gray-300 outline-none w-16 text-center h-5 leading-none",min:"200",max:"3840"}),e.jsx("span",{className:"text-gray-400 text-xs h-5 flex items-center leading-none",children:"×"}),e.jsx("span",{className:"bg-gray-100 text-gray-600 text-xs px-1 rounded w-14 text-center h-5 flex items-center justify-center leading-none",children:a.height??900}),a.name==="Custom"&&e.jsx("button",{onClick:()=>b(!0),className:"bg-white text-gray-900 text-xs px-2 rounded h-5 flex items-center leading-none border border-gray-300 hover:bg-gray-50 transition-colors",children:"Save"})]})]}),e.jsx("div",{ref:x,className:"flex-1 flex items-center justify-center overflow-hidden p-4",style:{backgroundImage:`
|
|
2
2
|
linear-gradient(45deg, #ebebeb 25%, transparent 25%),
|
|
3
3
|
linear-gradient(-45deg, #ebebeb 25%, transparent 25%),
|
|
4
4
|
linear-gradient(45deg, transparent 75%, #ebebeb 75%),
|