@codeyam/codeyam-cli 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/analyzer-template/.build-info.json +6 -6
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +1 -1
  4. package/analyzer-template/packages/aws/package.json +5 -5
  5. package/codeyam-cli/src/commands/editor.js +232 -5
  6. package/codeyam-cli/src/commands/editor.js.map +1 -1
  7. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +136 -0
  8. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  9. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js +398 -0
  10. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js.map +1 -0
  11. package/codeyam-cli/src/utils/designSystemShowcase.js +810 -0
  12. package/codeyam-cli/src/utils/designSystemShowcase.js.map +1 -0
  13. package/codeyam-cli/src/utils/editorAudit.js +6 -1
  14. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  15. package/codeyam-cli/src/utils/editorRoadmap.js +301 -0
  16. package/codeyam-cli/src/utils/editorRoadmap.js.map +1 -0
  17. package/codeyam-cli/src/utils/editorScenarios.js +10 -0
  18. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  19. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js +1 -0
  20. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js.map +1 -1
  21. package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-CLe80MMu.js → CopyButton-DTBZZfSk.js} +1 -1
  22. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-Crt_KN_U.js → EntityItem-BxclONWq.js} +1 -1
  23. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CD7lGABo.js → EntityTypeIcon-BsnEOJZ_.js} +1 -1
  24. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-CgTNOhnu.js → InlineSpinner-ByaELMbv.js} +1 -1
  25. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-DtYTSPL2.js → InteractivePreview-6WjVfhxX.js} +2 -2
  26. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-D3s1MFkb.js → LibraryFunctionPreview-ChX-Hp7W.js} +1 -1
  27. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CM5zg40N.js → LogViewer-C-9zQdXg.js} +1 -1
  28. package/codeyam-cli/src/webserver/build/client/assets/{MiniClaudeChat-CQENLSrF.js → MiniClaudeChat-BusrvT2F.js} +1 -1
  29. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-C2PLkej3.js → ReportIssueModal-DQsceHVv.js} +1 -1
  30. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DanvyBPb.js → SafeScreenshot-DThcm_9M.js} +1 -1
  31. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-CefgqbCr.js → ScenarioViewer-Cl4oOA3A.js} +1 -1
  32. package/codeyam-cli/src/webserver/build/client/assets/{Spinner-Bc8BG-Lw.js → Spinner-CIil5-gb.js} +1 -1
  33. package/codeyam-cli/src/webserver/build/client/assets/{ViewportInspectBar-BA_Ry-rs.js → ViewportInspectBar-BqkA9zyZ.js} +1 -1
  34. package/codeyam-cli/src/webserver/build/client/assets/{_index-C1YkzTAV.js → _index-DnOgyseQ.js} +1 -1
  35. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-yH46LLUz.js → activity.(_tab)-DqM9hbNE.js} +1 -1
  36. package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-CHx25PAe.js → addon-web-links-C58dYPwR.js} +1 -1
  37. package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-Bg3e7q4S.js → agent-transcripts-B8NCeOrm.js} +1 -1
  38. package/codeyam-cli/src/webserver/build/client/assets/api.editor-roadmap-l0sNRNKZ.js +1 -0
  39. package/codeyam-cli/src/webserver/build/client/assets/{book-open-CL-lMgHh.js → book-open-BFSIqZgO.js} +1 -1
  40. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-GmAjGS9-.js → chevron-down-B9fDzFVh.js} +1 -1
  41. package/codeyam-cli/src/webserver/build/client/assets/chunk-UVKPFVEO-Bmq2apuh.js +43 -0
  42. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-DFcQkN5j.js → circle-check-DLPObLUx.js} +1 -1
  43. package/codeyam-cli/src/webserver/build/client/assets/{copy-C6iF61Xs.js → copy-DXEmO0TD.js} +1 -1
  44. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-4ImjHTVC.js → createLucideIcon-BwyFiRot.js} +1 -1
  45. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-CRepiabR.js → dev.empty-iRhRIFlp.js} +1 -1
  46. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-BZPBzV73.js +1 -0
  47. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-785deXbZ.js +147 -0
  48. package/codeyam-cli/src/webserver/build/client/assets/{editorPreview-CluPkvXJ.js → editorPreview-C6fEYHrh.js} +6 -6
  49. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-DYJRGiDI.js → entity._sha._-Ce1s4OQ1.js} +1 -1
  50. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-wdiwx5-Z.js → entity._sha.scenarios._scenarioId.dev-C8AyYgYT.js} +1 -1
  51. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-BrkN-40Y.js → entity._sha.scenarios._scenarioId.fullscreen-DziaVQX1.js} +1 -1
  52. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-DxfhekTZ.js → entity._sha_.create-scenario-BTcpgIpC.js} +1 -1
  53. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CRXJWmpB.js → entity._sha_.edit._scenarioId-D_O_ajfZ.js} +1 -1
  54. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-SuW9syRS.js → entry.client-j1Vi0bco.js} +6 -6
  55. package/codeyam-cli/src/webserver/build/client/assets/{files-D-xGrg29.js → files-kuny2Q_s.js} +1 -1
  56. package/codeyam-cli/src/webserver/build/client/assets/{git-Bq_fbXP5.js → git-DgCZPMie.js} +1 -1
  57. package/codeyam-cli/src/webserver/build/client/assets/globals-Bt7TsgQz.css +1 -0
  58. package/codeyam-cli/src/webserver/build/client/assets/{index-Bp1l4hSv.js → index-BliGSSpl.js} +1 -1
  59. package/codeyam-cli/src/webserver/build/client/assets/{index-DE3jI_dv.js → index-SqjQKTdH.js} +1 -1
  60. package/codeyam-cli/src/webserver/build/client/assets/{index-CWV9XZiG.js → index-vyrZD2g4.js} +1 -1
  61. package/codeyam-cli/src/webserver/build/client/assets/{labs-B_IX45ih.js → labs-c3yLxSEp.js} +1 -1
  62. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-De-7qQ2u.js → loader-circle-D-q28GLF.js} +1 -1
  63. package/codeyam-cli/src/webserver/build/client/assets/manifest-3d8cde80.js +1 -0
  64. package/codeyam-cli/src/webserver/build/client/assets/{memory-Cx2xEx7s.js → memory-CEWIUC4t.js} +1 -1
  65. package/codeyam-cli/src/webserver/build/client/assets/{pause-CFxEKL1u.js → pause-BP6fitdh.js} +1 -1
  66. package/codeyam-cli/src/webserver/build/client/assets/{root-dKFRTYcy.js → root-CVjDQwjJ.js} +6 -6
  67. package/codeyam-cli/src/webserver/build/client/assets/{search-BdBb5aqc.js → search-BooqacKS.js} +1 -1
  68. package/codeyam-cli/src/webserver/build/client/assets/{settings-DdE-Untf.js → settings-BM0nbryO.js} +1 -1
  69. package/codeyam-cli/src/webserver/build/client/assets/{simulations-DSCdE99u.js → simulations-ovy6FjRY.js} +1 -1
  70. package/codeyam-cli/src/webserver/build/client/assets/{terminal-CrplD4b1.js → terminal-DHemCJIs.js} +1 -1
  71. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-DqJ0j69l.js → triangle-alert-D87ekDl8.js} +1 -1
  72. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-DhXHbEjP.js → useCustomSizes-Dk0Tciqg.js} +1 -1
  73. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-D9QZKaLJ.js → useLastLogLine-C8QvIe05.js} +1 -1
  74. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-Cy5Qg_UR.js → useReportContext-jkCytuYz.js} +1 -1
  75. package/codeyam-cli/src/webserver/build/client/assets/{useToast-5HR2j9ZE.js → useToast-BgqkixU9.js} +1 -1
  76. package/codeyam-cli/src/webserver/build/server/assets/{analysisRunner-OLsM110H.js → analysisRunner-CTJYMVFP.js} +1 -1
  77. package/codeyam-cli/src/webserver/build/server/assets/{index-WHdB6WTN.js → index-CCth4Hgw.js} +1 -1
  78. package/codeyam-cli/src/webserver/build/server/assets/{init-DbSiZoE6.js → init-UXl-3vVp.js} +1 -1
  79. package/codeyam-cli/src/webserver/build/server/assets/{server-build-DZbLY6O_.js → server-build-DSW2mE30.js} +198 -147
  80. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  81. package/codeyam-cli/src/webserver/build-info.json +5 -5
  82. package/codeyam-cli/src/webserver/server.js +67 -0
  83. package/codeyam-cli/src/webserver/server.js.map +1 -1
  84. package/codeyam-cli/src/webserver/terminalServer.js +21 -0
  85. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  86. package/codeyam-cli/templates/editor-step-hook.py +4 -4
  87. package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +36 -1
  88. package/codeyam-cli/templates/expo-react-native/app.json +11 -0
  89. package/codeyam-cli/templates/expo-react-native/package.json +1 -0
  90. package/package.json +1 -1
  91. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-BAdwhyCx.js +0 -43
  92. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-Gbk_i5Js.js +0 -1
  93. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-CRxPi2BB.js +0 -96
  94. package/codeyam-cli/src/webserver/build/client/assets/globals-BsGHu8WX.css +0 -1
  95. package/codeyam-cli/src/webserver/build/client/assets/manifest-9032538f.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-CHx25PAe.js","assets/chunk-JZWAC4HX-BAdwhyCx.js"])))=>i.map(i=>d[i]);
2
- var we=Object.defineProperty;var be=(r,e,s)=>e in r?we(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s;var I=(r,e,s)=>be(r,typeof e!="symbol"?e+"":e,s);import{j as d}from"./jsx-runtime-D_zvdyIk.js";import{r as u}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{_ as q}from"./preload-helper-ckwbz45p.js";const $={sound:"soft-double-tap",systemNotification:!0},Te=[{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"}],fe="codeyam-editor-notifications";function Le(){try{const r=localStorage.getItem(fe);if(!r)return $;const e=JSON.parse(r);return typeof e=="string"?e==="true"?$:{...$,sound:"off",systemNotification:!1}:{...$,...e}}catch{return $}}function ke(r){localStorage.setItem(fe,JSON.stringify(r))}function me(r){var e;if(r!=="off")try{const s=new AudioContext,l={"soft-double-tap":t=>{[0,.12].forEach(n=>{const o=t.createOscillator(),v=t.createGain();o.connect(v),v.connect(t.destination),o.type="sine",o.frequency.value=392,v.gain.setValueAtTime(.25,t.currentTime+n),v.gain.exponentialRampToValueAtTime(.01,t.currentTime+n+.1),o.start(t.currentTime+n),o.stop(t.currentTime+n+.1)})},"gentle-chime":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(523,t.currentTime),n.frequency.setValueAtTime(659,t.currentTime+.15),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),n.start(),n.stop(t.currentTime+.4)},"warm-ding":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.value=330,o.gain.setValueAtTime(.35,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),n.start(),n.stop(t.currentTime+.6)},"mellow-two-tone":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(294,t.currentTime),n.frequency.setValueAtTime(440,t.currentTime+.18),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),n.start(),n.stop(t.currentTime+.5)},"triangle-bell":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="triangle",n.frequency.value=523,o.gain.setValueAtTime(.4,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),n.start(),n.stop(t.currentTime+.8)}};(e=l[r])==null||e.call(l,s)}catch{}}function je({serverUrl:r,isStarting:e,projectSlug:s,devServerError:l,onStartServer:t,notificationSettings:n,onChangeNotificationSettings:o}){const[v,A]=u.useState(null),[x,g]=u.useState(!1),_=u.useRef(null),E=u.useRef(null);u.useEffect(()=>{if(!s)return;const p=new EventSource("/api/dev-mode-events");return p.onmessage=O=>{try{const P=JSON.parse(O.data);P.type==="file-synced"&&(A(P.fileName),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{A(null)},5e3))}catch{}},()=>{p.close(),E.current&&clearTimeout(E.current)}},[s]),u.useEffect(()=>{if(!x)return;function p(O){_.current&&!_.current.contains(O.target)&&g(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[x]);let T;l?T="error":e?T="starting":r?T="running":T="stopped";const D={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},J={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},z=n&&(n.sound!=="off"||n.systemNotification);return d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:`w-2 h-2 rounded-full ${D[T]}`}),d.jsxs("span",{className:"text-gray-400",children:["Server:"," ",d.jsx("span",{className:"text-gray-300",children:J[T]})]}),(T==="stopped"||T==="error")&&t&&d.jsx("button",{onClick:t,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"})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),v&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:d.jsx("path",{d:"M20 6L9 17l-5-5"})}),d.jsxs("span",{className:"text-green-400",children:["Synced: ",v]})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),d.jsx("div",{className:"flex-1"}),o&&n&&d.jsxs("div",{className:"relative",ref:_,children:[d.jsx("button",{onClick:()=>g(!x),className:`text-[11px] rounded transition-colors cursor-pointer ${z?"text-cygreen hover:text-cygreen/80":"text-gray-500 hover:text-gray-300"}`,children:z?"Notifications On":"Notifications Off"}),x&&d.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:[d.jsxs("div",{children:[d.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:Te.map(p=>d.jsx("button",{onClick:()=>{o({...n,sound:p.id}),p.id!=="off"&&me(p.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${n.sound===p.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:p.label},p.id))})]}),d.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:n.systemNotification,onChange:p=>{const O=p.target.checked;o({...n,systemNotification:O}),O&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),d.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),d.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function Ne(r,e){try{const{WebglAddon:l}=await q(async()=>{const{WebglAddon:n}=await import("./addon-webgl-DI8QOUvO.js").then(o=>o.a);return{WebglAddon:n}},[]),t=new l;return t.onContextLoss(()=>{e==null||e("webgl","canvas",new Error("WebGL context lost")),t.dispose(),de(r).then(n=>{n||e==null||e("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),r.loadAddon(t),{type:"webgl",dispose:()=>t.dispose()}}catch(l){e==null||e("webgl","canvas",l)}const s=await de(r);return s||(e==null||e("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function de(r){try{const{CanvasAddon:e}=await q(async()=>{const{CanvasAddon:l}=await import("./addon-canvas-DpzMmAy5.js").then(t=>t.a);return{CanvasAddon:l}},[]),s=new e;return r.loadAddon(s),{type:"canvas",dispose:()=>s.dispose()}}catch{return null}}class Se{constructor(e,s){I(this,"deferred",!1);I(this,"userActiveSinceLastOutput",!1);I(this,"actions");I(this,"env");this.actions=e,this.env=s}reportUserActivity(){this.userActiveSinceLastOutput=!0}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(e,s){return this.deferred=!1,s&&this.env.hasBrowserFocus()&&this.userActiveSinceLastOutput?(this.userActiveSinceLastOutput=!1,"suppressed"):this.notify(e)}onBuildTabChange(e,s){return!e&&this.deferred?(this.deferred=!1,this.notify(s),!0):!1}onActive(){this.deferred=!1}onUserEngagement(){const e=this.deferred;return this.deferred=!1,e}get isDeferred(){return this.deferred}notify(e){const s=!!(e!=null&&e.sound)&&e.sound!=="off";return s&&this.actions.playSound(e.sound),!this.env.hasBrowserFocus()&&(e!=null&&e.systemNotification)&&this.env.hasNotificationPermission()&&this.actions.showSystemNotification(),s?"played":"played-no-sound"}}class Ae{constructor(e){I(this,"_isIdle",!1);I(this,"_isBuilding",!1);I(this,"callbacks");this.callbacks=e}get isIdle(){return this._isIdle}get isBuilding(){return this._isBuilding}handleClaudeIdle(e,s,l){console.log("[TerminalIdleHandler] claude-idle, building: %s → false",this._isBuilding),e==null||e.onIdle(s,l),this._isIdle=!0,this._isBuilding=!1,this.callbacks.onIdleChange(!0),this.callbacks.onBuildingChange(!1)}handleClaudeActive(e){console.log("[TerminalIdleHandler] claude-active, building: %s → true",this._isBuilding),this._isIdle=!1,this._isBuilding=!0,this.callbacks.onIdleChange(!1),this.callbacks.onBuildingChange(!0),e==null||e.onActive(),e==null||e.resetActivityFlag(),this.callbacks.onCloseNotification()}handleOutput(e){this.callbacks.onIdleChange(!1),e==null||e.resetActivityFlag()}reset(){this._isBuilding&&(console.log("[TerminalIdleHandler] reset, was building: true"),this._isBuilding=!1,this.callbacks.onBuildingChange(!1))}}const _e=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/addon-web-links-C58dYPwR.js","assets/chunk-UVKPFVEO-Bmq2apuh.js"])))=>i.map(i=>d[i]);
2
+ var be=Object.defineProperty;var Te=(r,e,s)=>e in r?be(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s;var L=(r,e,s)=>Te(r,typeof e!="symbol"?e+"":e,s);import{j as d}from"./jsx-runtime-D_zvdyIk.js";import{r as u}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{_ as q}from"./preload-helper-ckwbz45p.js";const $={sound:"soft-double-tap",systemNotification:!0},Ne=[{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"}],me="codeyam-editor-notifications";function ke(){try{const r=localStorage.getItem(me);if(!r)return $;const e=JSON.parse(r);return typeof e=="string"?e==="true"?$:{...$,sound:"off",systemNotification:!1}:{...$,...e}}catch{return $}}function je(r){localStorage.setItem(me,JSON.stringify(r))}function pe(r){var e;if(r!=="off")try{const s=new AudioContext,l={"soft-double-tap":t=>{[0,.12].forEach(n=>{const o=t.createOscillator(),v=t.createGain();o.connect(v),v.connect(t.destination),o.type="sine",o.frequency.value=392,v.gain.setValueAtTime(.25,t.currentTime+n),v.gain.exponentialRampToValueAtTime(.01,t.currentTime+n+.1),o.start(t.currentTime+n),o.stop(t.currentTime+n+.1)})},"gentle-chime":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(523,t.currentTime),n.frequency.setValueAtTime(659,t.currentTime+.15),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),n.start(),n.stop(t.currentTime+.4)},"warm-ding":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.value=330,o.gain.setValueAtTime(.35,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),n.start(),n.stop(t.currentTime+.6)},"mellow-two-tone":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="sine",n.frequency.setValueAtTime(294,t.currentTime),n.frequency.setValueAtTime(440,t.currentTime+.18),o.gain.setValueAtTime(.3,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),n.start(),n.stop(t.currentTime+.5)},"triangle-bell":t=>{const n=t.createOscillator(),o=t.createGain();n.connect(o),o.connect(t.destination),n.type="triangle",n.frequency.value=523,o.gain.setValueAtTime(.4,t.currentTime),o.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),n.start(),n.stop(t.currentTime+.8)}};(e=l[r])==null||e.call(l,s)}catch{}}function We({serverUrl:r,isStarting:e,projectSlug:s,devServerError:l,onStartServer:t,notificationSettings:n,onChangeNotificationSettings:o}){const[v,A]=u.useState(null),[x,g]=u.useState(!1),_=u.useRef(null),E=u.useRef(null);u.useEffect(()=>{if(!s)return;const p=new EventSource("/api/dev-mode-events");return p.onmessage=O=>{try{const P=JSON.parse(O.data);P.type==="file-synced"&&(A(P.fileName),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{A(null)},5e3))}catch{}},()=>{p.close(),E.current&&clearTimeout(E.current)}},[s]),u.useEffect(()=>{if(!x)return;function p(O){_.current&&!_.current.contains(O.target)&&g(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[x]);let T;l?T="error":e?T="starting":r?T="running":T="stopped";const D={starting:"bg-yellow-400",running:"bg-green-400",stopped:"bg-gray-400",error:"bg-red-400"},J={starting:"Starting...",running:r||"Running",stopped:"Stopped",error:"Error"},z=n&&(n.sound!=="off"||n.systemNotification);return d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:`w-2 h-2 rounded-full ${D[T]}`}),d.jsxs("span",{className:"text-gray-400",children:["Server:"," ",d.jsx("span",{className:"text-gray-300",children:J[T]})]}),(T==="stopped"||T==="error")&&t&&d.jsx("button",{onClick:t,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"})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"}),v&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",children:d.jsx("path",{d:"M20 6L9 17l-5-5"})}),d.jsxs("span",{className:"text-green-400",children:["Synced: ",v]})]}),d.jsx("div",{className:"w-px h-3 bg-[#3d3d3d]"})]}),d.jsx("div",{className:"flex-1"}),o&&n&&d.jsxs("div",{className:"relative",ref:_,children:[d.jsx("button",{onClick:()=>g(!x),className:`text-[11px] rounded transition-colors cursor-pointer ${z?"text-cygreen hover:text-cygreen/80":"text-gray-500 hover:text-gray-300"}`,children:z?"Notifications On":"Notifications Off"}),x&&d.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:[d.jsxs("div",{children:[d.jsx("div",{className:"text-[11px] text-gray-400 mb-1.5",children:"Notification sound"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:Ne.map(p=>d.jsx("button",{onClick:()=>{o({...n,sound:p.id}),p.id!=="off"&&pe(p.id)},className:`text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors ${n.sound===p.id?"bg-[#444] text-white":"text-gray-300 hover:bg-[#3a3a3a]"}`,children:p.label},p.id))})]}),d.jsxs("div",{className:"border-t border-[#4d4d4d] pt-2",children:[d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:n.systemNotification,onChange:p=>{const O=p.target.checked;o({...n,systemNotification:O}),O&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),d.jsx("span",{className:"text-[11px] text-gray-300",children:"System notification"})]}),d.jsx("div",{className:"text-[10px] text-gray-500 mt-1 ml-5",children:"Shows when tab is not visible"})]})]})]})]})}async function Se(r,e){try{const{WebglAddon:l}=await q(async()=>{const{WebglAddon:n}=await import("./addon-webgl-DI8QOUvO.js").then(o=>o.a);return{WebglAddon:n}},[]),t=new l;return t.onContextLoss(()=>{e==null||e("webgl","canvas",new Error("WebGL context lost")),t.dispose(),fe(r).then(n=>{n||e==null||e("canvas","dom",new Error("Canvas fallback failed after context loss"))})}),r.loadAddon(t),{type:"webgl",dispose:()=>t.dispose()}}catch(l){e==null||e("webgl","canvas",l)}const s=await fe(r);return s||(e==null||e("canvas","dom",new Error("Canvas addon failed")),{type:"dom",dispose:()=>{}})}async function fe(r){try{const{CanvasAddon:e}=await q(async()=>{const{CanvasAddon:l}=await import("./addon-canvas-DpzMmAy5.js").then(t=>t.a);return{CanvasAddon:l}},[]),s=new e;return r.loadAddon(s),{type:"canvas",dispose:()=>s.dispose()}}catch{return null}}class Ae{constructor(e,s){L(this,"deferred",!1);L(this,"userActiveSinceLastOutput",!1);L(this,"actions");L(this,"env");this.actions=e,this.env=s}reportUserActivity(){this.userActiveSinceLastOutput=!0}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(e,s){return this.deferred=!1,s&&this.env.hasBrowserFocus()&&this.userActiveSinceLastOutput?(this.userActiveSinceLastOutput=!1,"suppressed"):this.notify(e)}onBuildTabChange(e,s){return!e&&this.deferred?(this.deferred=!1,this.notify(s),!0):!1}onActive(){this.deferred=!1}onUserEngagement(){const e=this.deferred;return this.deferred=!1,e}get isDeferred(){return this.deferred}notify(e){const s=!!(e!=null&&e.sound)&&e.sound!=="off";return s&&this.actions.playSound(e.sound),!this.env.hasBrowserFocus()&&(e!=null&&e.systemNotification)&&this.env.hasNotificationPermission()&&this.actions.showSystemNotification(),s?"played":"played-no-sound"}}class _e{constructor(e){L(this,"_isIdle",!1);L(this,"_isBuilding",!1);L(this,"callbacks");this.callbacks=e}get isIdle(){return this._isIdle}get isBuilding(){return this._isBuilding}handleClaudeIdle(e,s,l){console.log("[TerminalIdleHandler] claude-idle, building: %s → false",this._isBuilding),e==null||e.onIdle(s,l),this._isIdle=!0,this._isBuilding=!1,this.callbacks.onIdleChange(!0),this.callbacks.onBuildingChange(!1)}handleClaudeActive(e){console.log("[TerminalIdleHandler] claude-active, building: %s → true",this._isBuilding),this._isIdle=!1,this._isBuilding=!0,this.callbacks.onIdleChange(!1),this.callbacks.onBuildingChange(!0),e==null||e.onActive(),e==null||e.resetActivityFlag(),this.callbacks.onCloseNotification()}handleOutput(e){this.callbacks.onIdleChange(!1),e==null||e.resetActivityFlag()}reset(){this._isBuilding&&(console.log("[TerminalIdleHandler] reset, was building: true"),this._isBuilding=!1,this.callbacks.onBuildingChange(!1))}}const Ee=`
3
3
  .xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
4
4
  .xterm.focus, .xterm:focus { outline: none; }
5
5
  .xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
@@ -30,12 +30,12 @@ var we=Object.defineProperty;var be=(r,e,s)=>e in r?we(r,e,{enumerable:!0,config
30
30
  .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
31
31
  .xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
32
32
  .xterm-decoration-top { z-index: 2; position: relative; }
33
- `;function Ee(){let r=document.getElementById("xterm-css");r||(r=document.createElement("style"),r.id="xterm-css",document.head.appendChild(r)),r.textContent=_e}const We=u.forwardRef(function({entityName:e,entityType:s,entitySha:l,entityFilePath:t,scenarioName:n,scenarioDescription:o,analysisId:v,projectSlug:A,onRefreshPreview:x,onShowResults:g,onHideResults:_,onSetViewport:E,editorMode:T,onIdleChange:D,onBuildingChange:J,notificationSettings:z,buildTabActive:p,claudeStartMode:O,claudeSessionId:P,onDataMutationForwarded:re,resultsOpen:ce,editorStepLabel:le},pe){const ne=u.useRef(null),V=u.useRef(null),G=u.useRef(null),L=u.useRef(null),K=u.useRef(null),X=u.useRef(!1),Y=u.useRef(0),se=u.useRef(!1),k=u.useRef(D);k.current=D;const Z=u.useRef(J);Z.current=J;const ie=u.useRef(z);ie.current=z;const R=u.useRef(p);R.current=p;const ae=u.useRef(ce);ae.current=ce;const B=u.useRef(null),F=u.useRef(!1),N=u.useRef(null);N.current||(N.current=new Se({playSound:i=>me(i),showSystemNotification:()=>{B.current&&B.current.close();const i=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});i.onclick=()=>{window.focus(),i.close()},B.current=i}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"}));const j=u.useRef(null);j.current||(j.current=new Ae({onIdleChange:i=>{var f;F.current=i,(f=k.current)==null||f.call(k,i)},onCloseNotification:()=>{B.current&&(B.current.close(),B.current=null)},onBuildingChange:i=>{var f;(f=Z.current)==null||f.call(Z,i)}}));function he(){B.current&&(B.current.close(),B.current=null)}function W(){var i,f;F.current&&(F.current=!1,he(),(i=k.current)==null||i.call(k,!1),(f=N.current)==null||f.onUserEngagement())}u.useEffect(()=>{function i(){var S;document.hasFocus()&&R.current&&W(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function f(){!document.hidden&&R.current&&W()}function C(){var S;document.hasFocus()&&R.current&&W(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function Q(){var S;R.current&&W(),R.current&&((S=N.current)==null||S.reportUserActivity())}return window.addEventListener("focus",Q),document.addEventListener("visibilitychange",f),document.addEventListener("mousemove",i),document.addEventListener("mousedown",C),document.addEventListener("keydown",i),()=>{window.removeEventListener("focus",Q),document.removeEventListener("visibilitychange",f),document.removeEventListener("mousemove",i),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",i)}},[]),u.useEffect(()=>{var i;p&&F.current&&document.hasFocus()&&W(),(i=N.current)==null||i.onBuildTabChange(!!p,ie.current)},[p]);const xe=u.useCallback(()=>{var i;(i=G.current)==null||i.focus()},[]);return u.useImperativeHandle(pe,()=>({sendInput(i){const f=L.current;f&&f.readyState===WebSocket.OPEN&&(f.send(JSON.stringify({type:"input",data:i})),setTimeout(()=>{f.readyState===WebSocket.OPEN&&f.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var i;(i=G.current)==null||i.focus()},scrollToBottom(){var f;const i=(f=ne.current)==null?void 0:f.querySelector(".xterm-viewport");i&&(i.scrollTop=i.scrollHeight)}})),u.useEffect(()=>{const i=ne.current;if(!i)return;let f=!1;return Ee(),Promise.all([q(()=>import("./xterm-BqvuqXEL.js"),[]),q(()=>import("./addon-fit-YJmn1quW.js"),[]),q(()=>import("./addon-web-links-CHx25PAe.js").then(C=>C.a),__vite__mapDeps([0,1]))]).then(([C,Q,S])=>{if(f)return;const m=new C.Terminal({cursorBlink:!1,cursorInactiveStyle:"none",scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#1e1e1e",selectionBackground:"#264f78"},linkHandler:{activate(a,c){try{const h=new URL(c),w=h.searchParams.get("scenario");if(w&&h.pathname.startsWith("/editor")){const b=new BroadcastChannel("codeyam-editor");b.postMessage({type:"switch-scenario",scenarioId:w}),b.close();return}}catch{}window.open(c,"_blank")}}}),M=new Q.FitAddon;m.loadAddon(M),m.loadAddon(new S.WebLinksAddon),m.open(i),m.attachCustomKeyEventHandler(a=>{if(ae.current&&(a.key==="ArrowLeft"||a.key==="ArrowRight")&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&a.type==="keydown"){const c=a.key==="ArrowLeft"?"\x1B[D":"\x1B[C",h=L.current;return h&&h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({type:"input",data:c})),!1}return!0}),m.write("\x1B[?25l");let ee=null;Ne(m,(a,c,h)=>{console.warn(`[Terminal] Renderer fallback: ${a} → ${c}`,h)}).then(a=>{if(f){a.dispose();return}console.log(`[Terminal] Using ${a.type} renderer`),ee=a.dispose}),requestAnimationFrame(()=>{try{M.fit()}catch{}}),G.current=m,m.focus(),setTimeout(()=>m.focus(),100),setTimeout(()=>m.focus(),500);const ye=window.location.protocol==="https:"?"wss:":"ws:",ve=window.location.host;function ge(a){const c=new URLSearchParams;return c.set("entityName",e),s&&c.set("entityType",s),l&&c.set("entitySha",l),t&&c.set("entityFilePath",t),n&&c.set("scenarioName",n),o&&c.set("scenarioDescription",o),v&&c.set("analysisId",v),A&&c.set("projectSlug",A),T&&c.set("editorMode","true"),a&&c.set("reconnectId",a),O&&c.set("claudeStartMode",O),P&&c.set("claudeSessionId",P),le&&c.set("editorStepLabel",le),`${ye}//${ve}/ws/terminal?${c.toString()}`}function oe(a){const c=ge(a),h=new WebSocket(c);L.current=h,h.onopen=()=>{Y.current=0,se.current=!1,h.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},h.onmessage=w=>{var b,U,te;try{const y=JSON.parse(w.data);if(y.type==="session-id"){K.current=y.sessionId;return}if(y.type==="refresh-preview"){x==null||x(y.path,y.scenarioId);return}if(y.type==="show-results"){g==null||g();return}if(y.type==="hide-results"){_==null||_();return}if(y.type==="data-mutation-forwarded"){re==null||re();return}if(y.type==="set-viewport"){E==null||E({name:y.name,width:y.width,height:y.height});return}if(y.type==="claude-idle"){(b=j.current)==null||b.handleClaudeIdle(N.current,ie.current,R.current??!1);return}if(y.type==="claude-active"){(U=j.current)==null||U.handleClaudeActive(N.current);return}y.type==="output"&&(m.write(y.data),(te=j.current)==null||te.handleOutput(N.current))}catch{m.write(w.data)}},h.onclose=()=>{var b,U;if(console.log("[Terminal] WS closed, intentional=%s",X.current),X.current){m.write(`\r
33
+ `;function Oe(){let r=document.getElementById("xterm-css");r||(r=document.createElement("style"),r.id="xterm-css",document.head.appendChild(r)),r.textContent=Ee}const ze=u.forwardRef(function({entityName:e,entityType:s,entitySha:l,entityFilePath:t,scenarioName:n,scenarioDescription:o,analysisId:v,projectSlug:A,onRefreshPreview:x,onShowResults:g,onHideResults:_,onSetViewport:E,editorMode:T,onIdleChange:D,onBuildingChange:J,notificationSettings:z,buildTabActive:p,claudeStartMode:O,claudeSessionId:P,onFeatureComplete:re,onDataMutationForwarded:ne,resultsOpen:le,editorStepLabel:ae},he){const se=u.useRef(null),V=u.useRef(null),G=u.useRef(null),C=u.useRef(null),K=u.useRef(null),X=u.useRef(!1),Y=u.useRef(0),ie=u.useRef(!1),k=u.useRef(D);k.current=D;const Z=u.useRef(J);Z.current=J;const oe=u.useRef(z);oe.current=z;const R=u.useRef(p);R.current=p;const ue=u.useRef(le);ue.current=le;const B=u.useRef(null),Q=u.useRef(!1),N=u.useRef(null);N.current||(N.current=new Ae({playSound:i=>pe(i),showSystemNotification:()=>{B.current&&B.current.close();const i=new Notification("Claude is ready for you",{body:"Claude has finished and is waiting for your input.",tag:"claude-idle"});i.onclick=()=>{window.focus(),i.close()},B.current=i}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"}));const j=u.useRef(null);j.current||(j.current=new _e({onIdleChange:i=>{var f;Q.current=i,(f=k.current)==null||f.call(k,i)},onCloseNotification:()=>{B.current&&(B.current.close(),B.current=null)},onBuildingChange:i=>{var f;(f=Z.current)==null||f.call(Z,i)}}));function xe(){B.current&&(B.current.close(),B.current=null)}function W(){var i,f;Q.current&&(Q.current=!1,xe(),(i=k.current)==null||i.call(k,!1),(f=N.current)==null||f.onUserEngagement())}u.useEffect(()=>{function i(){var S;document.hasFocus()&&R.current&&W(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function f(){!document.hidden&&R.current&&W()}function I(){var S;document.hasFocus()&&R.current&&W(),R.current&&document.hasFocus()&&((S=N.current)==null||S.reportUserActivity())}function F(){var S;R.current&&W(),R.current&&((S=N.current)==null||S.reportUserActivity())}return window.addEventListener("focus",F),document.addEventListener("visibilitychange",f),document.addEventListener("mousemove",i),document.addEventListener("mousedown",I),document.addEventListener("keydown",i),()=>{window.removeEventListener("focus",F),document.removeEventListener("visibilitychange",f),document.removeEventListener("mousemove",i),document.removeEventListener("mousedown",I),document.removeEventListener("keydown",i)}},[]),u.useEffect(()=>{var i;p&&Q.current&&document.hasFocus()&&W(),(i=N.current)==null||i.onBuildTabChange(!!p,oe.current)},[p]);const ye=u.useCallback(()=>{var i;(i=G.current)==null||i.focus()},[]);return u.useImperativeHandle(he,()=>({sendInput(i){const f=C.current;f&&f.readyState===WebSocket.OPEN&&(f.send(JSON.stringify({type:"input",data:i})),setTimeout(()=>{f.readyState===WebSocket.OPEN&&f.send(JSON.stringify({type:"input",data:"\r"}))},100))},focus(){var i;(i=G.current)==null||i.focus()},scrollToBottom(){var f;const i=(f=se.current)==null?void 0:f.querySelector(".xterm-viewport");i&&(i.scrollTop=i.scrollHeight)}})),u.useEffect(()=>{const i=se.current;if(!i)return;let f=!1;return Oe(),Promise.all([q(()=>import("./xterm-BqvuqXEL.js"),[]),q(()=>import("./addon-fit-YJmn1quW.js"),[]),q(()=>import("./addon-web-links-C58dYPwR.js").then(I=>I.a),__vite__mapDeps([0,1]))]).then(([I,F,S])=>{if(f)return;const m=new I.Terminal({cursorBlink:!1,cursorInactiveStyle:"none",scrollback:5e3,fontSize:13,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#1e1e1e",selectionBackground:"#264f78"},linkHandler:{activate(a,c){try{const h=new URL(c),w=h.searchParams.get("scenario");if(w&&h.pathname.startsWith("/editor")){const b=new BroadcastChannel("codeyam-editor");b.postMessage({type:"switch-scenario",scenarioId:w}),b.close();return}}catch{}window.open(c,"_blank")}}}),M=new F.FitAddon;m.loadAddon(M),m.loadAddon(new S.WebLinksAddon),m.open(i),m.attachCustomKeyEventHandler(a=>{if(ue.current&&(a.key==="ArrowLeft"||a.key==="ArrowRight")&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&a.type==="keydown"){const c=a.key==="ArrowLeft"?"\x1B[D":"\x1B[C",h=C.current;return h&&h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({type:"input",data:c})),!1}return!0}),m.write("\x1B[?25l");let ee=null;Se(m,(a,c,h)=>{console.warn(`[Terminal] Renderer fallback: ${a} → ${c}`,h)}).then(a=>{if(f){a.dispose();return}console.log(`[Terminal] Using ${a.type} renderer`),ee=a.dispose}),requestAnimationFrame(()=>{try{M.fit()}catch{}}),G.current=m,m.focus(),setTimeout(()=>m.focus(),100),setTimeout(()=>m.focus(),500);const ve=window.location.protocol==="https:"?"wss:":"ws:",ge=window.location.host;function we(a){const c=new URLSearchParams;return c.set("entityName",e),s&&c.set("entityType",s),l&&c.set("entitySha",l),t&&c.set("entityFilePath",t),n&&c.set("scenarioName",n),o&&c.set("scenarioDescription",o),v&&c.set("analysisId",v),A&&c.set("projectSlug",A),T&&c.set("editorMode","true"),a&&c.set("reconnectId",a),O&&c.set("claudeStartMode",O),P&&c.set("claudeSessionId",P),ae&&c.set("editorStepLabel",ae),`${ve}//${ge}/ws/terminal?${c.toString()}`}function ce(a){const c=we(a),h=new WebSocket(c);C.current=h,h.onopen=()=>{Y.current=0,ie.current=!1,h.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},h.onmessage=w=>{var b,U,te;try{const y=JSON.parse(w.data);if(y.type==="session-id"){K.current=y.sessionId;return}if(y.type==="refresh-preview"){x==null||x(y.path,y.scenarioId);return}if(y.type==="show-results"){g==null||g();return}if(y.type==="hide-results"){_==null||_();return}if(y.type==="feature-complete"){re==null||re();return}if(y.type==="data-mutation-forwarded"){ne==null||ne();return}if(y.type==="set-viewport"){E==null||E({name:y.name,width:y.width,height:y.height});return}if(y.type==="claude-idle"){(b=j.current)==null||b.handleClaudeIdle(N.current,oe.current,R.current??!1);return}if(y.type==="claude-active"){(U=j.current)==null||U.handleClaudeActive(N.current);return}y.type==="output"&&(m.write(y.data),(te=j.current)==null||te.handleOutput(N.current))}catch{m.write(w.data)}},h.onclose=()=>{var b,U;if(console.log("[Terminal] WS closed, intentional=%s",X.current),X.current){m.write(`\r
34
34
  \x1B[90m[Terminal session ended]\x1B[0m\r
35
35
  `),(b=j.current)==null||b.reset();return}const w=Y.current;if(w<5&&K.current){const te=1e3*Math.pow(2,Math.min(w,3));Y.current=w+1,m.write(`\r
36
36
  \x1B[33m[Reconnecting...]\x1B[0m\r
37
- `),setTimeout(()=>{X.current||oe(K.current)},te)}else se.current?(m.write(`\r
37
+ `),setTimeout(()=>{X.current||ce(K.current)},te)}else ie.current?(m.write(`\r
38
38
  \x1B[90m[Terminal session ended]\x1B[0m\r
39
- `),(U=j.current)==null||U.reset()):(se.current=!0,m.write(`\r
39
+ `),(U=j.current)==null||U.reset()):(ie.current=!0,m.write(`\r
40
40
  \x1B[33m[Starting new session...]\x1B[0m\r
41
- `),K.current=null,Y.current=0,oe())},h.onerror=()=>{}}oe(),m.onData(a=>{const c=L.current;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({type:"input",data:a})),W()});let H=null;const ue=new ResizeObserver(()=>{H&&clearTimeout(H),H=setTimeout(()=>{let a;try{a=M.proposeDimensions()}catch{return}if(!a||a.cols===m.cols&&a.rows===m.rows)return;const c=i.querySelector(".xterm-viewport");let h,w=!0;c&&(h=c.scrollTop,w=c.scrollTop+c.clientHeight>=c.scrollHeight-10),M.fit(),c&&h!==void 0&&(w?c.scrollTop=c.scrollHeight:c.scrollTop=h);const b=L.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},150)});ue.observe(i),V.current=()=>{var a;H&&clearTimeout(H),ue.disconnect(),X.current=!0,(a=L.current)==null||a.close(),L.current=null,ee==null||ee(),m.dispose(),G.current=null}}),()=>{var C;f=!0,(C=V.current)==null||C.call(V),V.current=null}},[]),d.jsx("div",{ref:ne,onClick:xe,className:"w-full h-full relative overflow-hidden",style:{padding:"4px 0 0 8px"}})});function Oe(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function ze(r){const{activeAnalyzedScenario:e,analyzedPreviewUrl:s,activeScenarioId:l,scenarios:t,proxyUrl:n,devServerUrl:o,zoomComponent:v}=r;if(e&&s)return s;if(e&&!s)return null;if(l){const x=t.find(g=>g.id===l);if(x!=null&&x.url){const g=n||o;return g?x.url.startsWith("/")?`${g}${x.url}`:x.url:null}}const A=n||o;if(!A)return null;if(v&&l){const x=t.find(_=>_.id===l),g=x?Oe(x.name):"Default";return`${A}/__codeyam__/${v}/${g}`}return A}function Pe(r,e){if(!r||!e)return r;try{const s=new URL(r),l=e.indexOf("?");return l>=0?(s.pathname=e.slice(0,l),s.search=e.slice(l)):(s.pathname=e,s.search=""),s.href}catch{return r}}function Ve(r,e){return r?r!==e:!1}function He(r){if(r.length!==0)return r.find(e=>e.url==="/")||r.find(e=>e.type==="application")||r[0]}function Ue(r,e,s){if(!r.viewportWidth||!r.viewportHeight)return s??null;const l=e.find(t=>t.width===r.viewportWidth&&t.height===r.viewportHeight);return{name:(l==null?void 0:l.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function $e(r,e){const s=e.width,l=e.height??900,t=r.width,n=r.height;return s<=t&&l<=n?1:Math.min(t/s,n/l)}export{je as D,We as T,Pe as a,Oe as b,$ as c,ke as d,$e as e,ze as f,He as g,Le as l,Ue as r,Ve as s};
41
+ `),K.current=null,Y.current=0,ce())},h.onerror=()=>{}}ce(),m.onData(a=>{const c=C.current;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({type:"input",data:a})),W()});let H=null;const de=new ResizeObserver(()=>{H&&clearTimeout(H),H=setTimeout(()=>{let a;try{a=M.proposeDimensions()}catch{return}if(!a||a.cols===m.cols&&a.rows===m.rows)return;const c=i.querySelector(".xterm-viewport");let h,w=!0;c&&(h=c.scrollTop,w=c.scrollTop+c.clientHeight>=c.scrollHeight-10),M.fit(),c&&h!==void 0&&(w?c.scrollTop=c.scrollHeight:c.scrollTop=h);const b=C.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},150)});de.observe(i),V.current=()=>{var a;H&&clearTimeout(H),de.disconnect(),X.current=!0,(a=C.current)==null||a.close(),C.current=null,ee==null||ee(),m.dispose(),G.current=null}}),()=>{var I;f=!0,(I=V.current)==null||I.call(V),V.current=null}},[]),d.jsx("div",{ref:se,onClick:ye,className:"w-full h-full relative overflow-hidden",style:{padding:"4px 0 0 8px"}})});function Re(r){return r.replace(/[^a-zA-Z0-9_]+/g,"_")}function Pe(r){const{activeAnalyzedScenario:e,analyzedPreviewUrl:s,activeScenarioId:l,scenarios:t,proxyUrl:n,devServerUrl:o,zoomComponent:v}=r;if(e&&s)return s;if(e&&!s)return null;if(l){const x=t.find(g=>g.id===l);if(x!=null&&x.url){const g=n||o;return g?x.url.startsWith("/")?`${g}${x.url}`:x.url:null}}const A=n||o;if(!A)return null;if(v&&l){const x=t.find(_=>_.id===l),g=x?Re(x.name):"Default";return`${A}/__codeyam__/${v}/${g}`}return A}function Ve(r,e){if(!r||!e)return r;try{const s=new URL(r),l=e.indexOf("?");return l>=0?(s.pathname=e.slice(0,l),s.search=e.slice(l)):(s.pathname=e,s.search=""),s.href}catch{return r}}function He(r,e){return r?r!==e:!1}function Ue(r){if(r.length!==0)return r.find(e=>e.url==="/")||r.find(e=>e.type==="application")||r[0]}function $e(r,e,s){if(!r.viewportWidth||!r.viewportHeight)return s??null;const l=e.find(t=>t.width===r.viewportWidth&&t.height===r.viewportHeight);return{name:(l==null?void 0:l.name)||"Custom",width:r.viewportWidth,height:r.viewportHeight}}function qe(r,e){const s=e.width,l=e.height??900,t=r.width,n=r.height;return s<=t&&l<=n?1:Math.min(t/s,n/l)}export{We as D,ze as T,Ve as a,Re as b,$ as c,je as d,qe as e,Pe as f,Ue as g,ke as l,$e as r,He as s};
@@ -1,4 +1,4 @@
1
- import{L as J,r as L,f as dm,d as ze,b as Hm,R as Oe,J as at,g as Gm,c as $m,w as Wm,u as Vm,j as Ym,a as Km}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{j as n}from"./jsx-runtime-D_zvdyIk.js";import{u as Xm}from"./useLastLogLine-D9QZKaLJ.js";import{u as Zm}from"./Spinner-Bc8BG-Lw.js";import{W as Qm,I as Jm}from"./InteractivePreview-DtYTSPL2.js";import{S as We}from"./SafeScreenshot-DanvyBPb.js";import{L as ef}from"./LibraryFunctionPreview-D3s1MFkb.js";import{L as tf}from"./LoadingDots-By5zI316.js";import{g as rf}from"./scenarioStatus-B_8jpV3e.js";import{E as af,S as nf}from"./ScenarioViewer-CefgqbCr.js";import{c as of}from"./createLucideIcon-4ImjHTVC.js";import{c as pm,g as sf}from"./executionFlowCoverage-BWhdfn70.js";import{E as kl}from"./EntityTypeIcon-CD7lGABo.js";import{C as gm}from"./CopyButton-CLe80MMu.js";import{L as lf}from"./LogViewer-CM5zg40N.js";import{M as cf}from"./MiniClaudeChat-CQENLSrF.js";import{u as uf}from"./useReportContext-Cy5Qg_UR.js";import"./preload-helper-ckwbz45p.js";import"./InlineSpinner-CgTNOhnu.js";import"./ViewportInspectBar-BA_Ry-rs.js";import"./useCustomSizes-DhXHbEjP.js";import"./ReportIssueModal-C2PLkej3.js";import"./circle-check-DFcQkN5j.js";import"./triangle-alert-DqJ0j69l.js";import"./copy-C6iF61Xs.js";/**
1
+ import{L as J,r as L,f as dm,d as ze,b as Hm,R as Oe,J as at,g as Gm,c as $m,w as Wm,u as Vm,j as Ym,a as Km}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as n}from"./jsx-runtime-D_zvdyIk.js";import{u as Xm}from"./useLastLogLine-C8QvIe05.js";import{u as Zm}from"./Spinner-CIil5-gb.js";import{W as Qm,I as Jm}from"./InteractivePreview-6WjVfhxX.js";import{S as We}from"./SafeScreenshot-DThcm_9M.js";import{L as ef}from"./LibraryFunctionPreview-ChX-Hp7W.js";import{L as tf}from"./LoadingDots-By5zI316.js";import{g as rf}from"./scenarioStatus-B_8jpV3e.js";import{E as af,S as nf}from"./ScenarioViewer-Cl4oOA3A.js";import{c as of}from"./createLucideIcon-BwyFiRot.js";import{c as pm,g as sf}from"./executionFlowCoverage-BWhdfn70.js";import{E as kl}from"./EntityTypeIcon-BsnEOJZ_.js";import{C as gm}from"./CopyButton-DTBZZfSk.js";import{L as lf}from"./LogViewer-C-9zQdXg.js";import{M as cf}from"./MiniClaudeChat-BusrvT2F.js";import{u as uf}from"./useReportContext-jkCytuYz.js";import"./preload-helper-ckwbz45p.js";import"./InlineSpinner-ByaELMbv.js";import"./ViewportInspectBar-BqkA9zyZ.js";import"./useCustomSizes-Dk0Tciqg.js";import"./ReportIssueModal-DQsceHVv.js";import"./circle-check-DLPObLUx.js";import"./triangle-alert-D87ekDl8.js";import"./copy-DXEmO0TD.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,w as re,u as oe,r as i}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as le,S as W}from"./Spinner-Bc8BG-Lw.js";import{u as ce}from"./useLastLogLine-D9QZKaLJ.js";import{V as de}from"./ViewportInspectBar-BA_Ry-rs.js";import{u as he,S as xe}from"./useCustomSizes-DhXHbEjP.js";import{c as me}from"./cy-logo-cli-Coe5NhbS.js";import{I as E}from"./InlineSpinner-CgTNOhnu.js";import{a as ue,T as pe,D as ge}from"./editorPreview-CluPkvXJ.js";import{S as fe}from"./SafeScreenshot-DanvyBPb.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}],De=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:`
1
+ import{a as V,w as re,u as oe,r as i}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as le,S as W}from"./Spinner-CIil5-gb.js";import{u as ce}from"./useLastLogLine-C8QvIe05.js";import{V as de}from"./ViewportInspectBar-BqkA9zyZ.js";import{u as he,S as xe}from"./useCustomSizes-Dk0Tciqg.js";import{c as me}from"./cy-logo-cli-Coe5NhbS.js";import{I as E}from"./InlineSpinner-ByaELMbv.js";import{a as ue,T as pe,D as ge}from"./editorPreview-C6fEYHrh.js";import{S as fe}from"./SafeScreenshot-DThcm_9M.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}],De=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}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as se,S as z}from"./Spinner-Bc8BG-Lw.js";import{u as ne}from"./useLastLogLine-D9QZKaLJ.js";import{V as ae}from"./ViewportInspectBar-BA_Ry-rs.js";import{u as ie,S as re}from"./useCustomSizes-DhXHbEjP.js";import{c as oe}from"./cy-logo-cli-Coe5NhbS.js";import{I as B}from"./InlineSpinner-CgTNOhnu.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}],ve=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:`
1
+ import{w as X,u as Z,a as ee,b as te,r as i}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as se,S as z}from"./Spinner-CIil5-gb.js";import{u as ne}from"./useLastLogLine-C8QvIe05.js";import{V as ae}from"./ViewportInspectBar-BqkA9zyZ.js";import{u as ie,S as re}from"./useCustomSizes-Dk0Tciqg.js";import{c as oe}from"./cy-logo-cli-Coe5NhbS.js";import{I as B}from"./InlineSpinner-ByaELMbv.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}],ve=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%),
@@ -1,4 +1,4 @@
1
- import{r as a,w as Z,u as ee,a as te,L as v}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{W as se,u as re,I as ae}from"./InteractivePreview-DtYTSPL2.js";import{u as ne}from"./Spinner-Bc8BG-Lw.js";import{c as oe}from"./executionFlowCoverage-BWhdfn70.js";import"./preload-helper-ckwbz45p.js";import"./useLastLogLine-D9QZKaLJ.js";import"./InlineSpinner-CgTNOhnu.js";function ie({executionFlows:t,selections:r,onChange:n,disabled:i=!1}){const x=a.useCallback(s=>r.some(o=>o.flowId===s),[r]),p=a.useCallback(s=>{x(s.id)?n(r.filter(o=>o.flowId!==s.id)):n([...r,{flowId:s.id,flowName:s.name}])},[r,n,x]);return t.length===0?e.jsx("div",{className:"text-sm text-gray-500 py-2",children:"No execution flows found."}):e.jsx("div",{className:"space-y-3",children:t.map(s=>{const o=x(s.id),I=s.usedInScenarios.length>0;return e.jsxs("div",{className:"border-b border-gray-100 pb-3 last:border-0 last:pb-0",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:()=>p(s),disabled:i,className:"mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-mono text-sm font-medium text-gray-900",children:s.name}),!I&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-amber-100 text-amber-700 rounded",children:"uncovered"}),s.blocksOtherFlows&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:"blocking"}),s.impact==="high"&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"high impact"})]}),s.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5 m-0",children:s.description})]})]}),o&&s.requiredValues.length>0&&e.jsxs("div",{className:"ml-6 mt-2 p-2 bg-gray-50 rounded text-xs",children:[e.jsx("span",{className:"text-gray-700 font-medium",children:"Required values:"}),e.jsx("ul",{className:"m-0 mt-1 pl-4 space-y-0.5",children:s.requiredValues.map((h,E)=>e.jsxs("li",{className:"text-gray-600",children:[e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:h.attributePath})," ",e.jsx("span",{className:"text-gray-400",children:h.comparison})," ",e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:h.value})]},E))})]})]},s.id)})})}const be=({data:t})=>[{title:t!=null&&t.entity?`Create Scenario - ${t.entity.name} - CodeYam`:"Create Scenario - CodeYam"},{name:"description",content:"Create a new scenario"}];function ce(){var W;const{analysis:t,defaultScenario:r,entity:n,entitySha:i,projectSlug:x}=ee(),p=te(),{iframeRef:s}=re(),[o,I]=a.useState(""),[h,E]=a.useState(400),[b,P]=a.useState(!1),[U,R]=a.useState(!1),[G,$]=a.useState(!1),[M,L]=a.useState(null),[F,l]=a.useState(null),[d,H]=a.useState([]),D=a.useMemo(()=>{var c;return!((c=t==null?void 0:t.metadata)!=null&&c.executionFlows)||!(t!=null&&t.scenarios)?[]:oe(t.metadata.executionFlows,t.scenarios).executionFlows},[t]),{interactiveServerUrl:y,isStarting:J,isLoading:_,showIframe:q,iframeKey:B,onIframeLoad:V}=ne({analysisId:t==null?void 0:t.id,scenarioId:r==null?void 0:r.id,scenarioName:r==null?void 0:r.name,projectSlug:x,enabled:!0}),Y=a.useCallback(async()=>{var m,c,T,z;if(!o.trim()&&d.length===0){L("Please describe how you want to change the scenario or select execution flows");return}R(!0),L(null),l("Generating scenario with AI...");try{const u=await fetch("/api/generate-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:o,existingScenarios:t.scenarios,scenariosDataStructure:(m=t.metadata)==null?void 0:m.scenariosDataStructure,flowSelections:d.length>0?d:void 0})}),N=await u.json();if(!u.ok||!N.success)throw new Error(N.error||"Failed to generate scenario data");console.log("[CreateScenario] AI generated scenario:",N.data);const g=N.data;if(!g.name||!g.data)throw new Error("AI response missing required fields (name or data)");l("Saving new scenario..."),$(!0);const X={name:g.name,description:g.description||o,metadata:{data:g.data,interactiveExamplePath:(c=r.metadata)==null?void 0:c.interactiveExamplePath}},Q=[...t.scenarios||[],X],O=await fetch("/api/save-scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({analysis:t,scenarios:Q})}),C=await O.json();if(!O.ok||!C.success)throw new Error(C.error||"Failed to save scenario");console.log("[CreateScenario] Scenario saved:",C);const f=(z=(T=C.analysis)==null?void 0:T.scenarios)==null?void 0:z.find(k=>k.name===g.name);if(!(f!=null&&f.id)){console.warn("[CreateScenario] Could not find saved scenario ID, navigating to entity page"),l("Scenario created! Redirecting..."),setTimeout(()=>void p(`/entity/${i}`),1e3);return}if(y){l("Capturing screenshot...");const k=await fetch("/api/capture-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverUrl:y,scenarioId:f.id,projectId:t.projectId,viewportWidth:1440})}),A=await k.json();!k.ok||!A.success?(console.error("[CreateScenario] Capture failed:",A),l("Scenario created! (Screenshot capture failed)")):l("Scenario created and captured!")}else l("Scenario created!");setTimeout(()=>{p(`/entity/${i}/scenarios/${f.id}`)},1e3)}catch(u){console.error("[CreateScenario] Error:",u),L(u instanceof Error?u.message:String(u)),l(null)}finally{R(!1),$(!1)}},[o,d,t,r,i,y,p]),j=U||G,K=a.useCallback(()=>{P(!0)},[]),w=a.useCallback(m=>{if(!b)return;const c=m.clientX;c>=250&&c<=600&&E(c)},[b]),S=a.useCallback(()=>{P(!1)},[]);return a.useEffect(()=>(b?(document.addEventListener("mousemove",w),document.addEventListener("mouseup",S)):(document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)}),[b,w,S]),e.jsxs("div",{className:"h-screen bg-white flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 shrink-0 relative h-[54px]",children:e.jsxs("div",{className:"flex items-end h-full px-6 gap-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1 pb-[14px]",children:[e.jsx("button",{onClick:()=>void p(`/entity/${i}`),className:"no-underline shrink-0 bg-transparent border-none cursor-pointer p-0 flex items-center",title:"Back",children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",children:e.jsx("path",{d:"M13 8.5H4M4 8.5L8.5 4M4 8.5L8.5 13",stroke:"#005c75",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("h1",{className:"text-base font-semibold text-black m-0 leading-[20px] shrink-0",children:n==null?void 0:n.name}),e.jsx("span",{className:"text-xs text-[#9e9e9e] font-mono font-normal whitespace-nowrap overflow-hidden text-ellipsis min-w-0",title:n==null?void 0:n.filePath,children:n==null?void 0:n.filePath})]}),e.jsxs("div",{className:"flex items-end gap-8 shrink-0",children:[e.jsx(v,{to:`/entity/${i}/scenarios`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-medium border-b-2",style:{color:"#005C75",borderColor:"#005C75"},children:e.jsxs("span",{className:"flex items-center gap-2",children:["Scenarios",e.jsx("span",{className:"inline-flex items-center justify-center px-2 py-0.5 text-xs font-semibold rounded-full bg-[#cbf3fa] text-[#005c75]",children:((W=t==null?void 0:t.scenarios)==null?void 0:W.length)||0})]})}),e.jsx(v,{to:`/entity/${i}/related`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Related Entities"}),e.jsx(v,{to:`/entity/${i}/code`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Code"}),e.jsx(v,{to:`/entity/${i}/data`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Data Structure"}),e.jsx(v,{to:`/entity/${i}/history`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"History"})]})]})}),e.jsxs("div",{className:"flex flex-1 gap-0 min-h-0 relative",children:[e.jsxs("aside",{className:"bg-white border-r border-gray-200 overflow-y-auto shrink-0 p-6 flex flex-col",style:{width:`${h}px`},children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Default Scenario Preview"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:"The preview on the right shows the Default Scenario. Select execution flows and/or describe how you'd like to change it."})]}),D.length>0&&e.jsxs("details",{className:"mb-4 border border-gray-200 rounded-lg",children:[e.jsxs("summary",{className:"px-3 py-2 text-sm font-medium text-gray-700 cursor-pointer hover:bg-gray-50 rounded-lg",children:["Select Execution Flows"," ",d.length>0&&e.jsxs("span",{className:"text-blue-600",children:["(",d.length," selected)"]})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-gray-100",children:e.jsx(ie,{executionFlows:D,selections:d,onChange:H,disabled:j})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-700 mb-2",children:"Describe your scenario"}),e.jsx("textarea",{id:"prompt",value:o,onChange:m=>I(m.target.value),placeholder:"e.g., Show an empty state with no items...",className:"w-full h-32 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 text-sm resize-none",disabled:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>void Y(),disabled:j||!o.trim()&&d.length===0,className:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg text-sm font-medium cursor-pointer transition-colors hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed",children:j?"Creating...":"Create Scenario"}),F&&e.jsx("div",{className:"text-xs text-blue-600 bg-blue-50 px-2 py-1.5 rounded",children:F}),M&&e.jsx("div",{className:"text-xs text-red-600 bg-red-50 px-2 py-1.5 rounded",children:M})]})]}),e.jsxs("div",{onMouseDown:K,style:{width:"20px",position:"absolute",top:0,left:`${h-10}px`,bottom:0,cursor:"col-resize",touchAction:"none",userSelect:"none",zIndex:100,pointerEvents:"auto"},children:[e.jsx("div",{style:{position:"absolute",left:"10px",top:0,bottom:0,width:"1px",background:b?"#005c75":"rgba(0,0,0,0.1)",transition:"background 0.15s ease"}}),e.jsx("div",{style:{position:"absolute",top:"50%",left:"10px",transform:"translate(-50%, -50%)",width:"8px",height:"40px",background:"#fff",border:"1px solid rgba(0,0,0,0.15)",borderRadius:"4px",cursor:"col-resize"}})]}),e.jsx("main",{className:"flex-1 overflow-auto flex items-center justify-center min-w-0",style:{backgroundImage:`
1
+ import{r as a,w as Z,u as ee,a as te,L as v}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{W as se,u as re,I as ae}from"./InteractivePreview-6WjVfhxX.js";import{u as ne}from"./Spinner-CIil5-gb.js";import{c as oe}from"./executionFlowCoverage-BWhdfn70.js";import"./preload-helper-ckwbz45p.js";import"./useLastLogLine-C8QvIe05.js";import"./InlineSpinner-ByaELMbv.js";function ie({executionFlows:t,selections:r,onChange:n,disabled:i=!1}){const x=a.useCallback(s=>r.some(o=>o.flowId===s),[r]),p=a.useCallback(s=>{x(s.id)?n(r.filter(o=>o.flowId!==s.id)):n([...r,{flowId:s.id,flowName:s.name}])},[r,n,x]);return t.length===0?e.jsx("div",{className:"text-sm text-gray-500 py-2",children:"No execution flows found."}):e.jsx("div",{className:"space-y-3",children:t.map(s=>{const o=x(s.id),I=s.usedInScenarios.length>0;return e.jsxs("div",{className:"border-b border-gray-100 pb-3 last:border-0 last:pb-0",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:()=>p(s),disabled:i,className:"mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-mono text-sm font-medium text-gray-900",children:s.name}),!I&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-amber-100 text-amber-700 rounded",children:"uncovered"}),s.blocksOtherFlows&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:"blocking"}),s.impact==="high"&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"high impact"})]}),s.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5 m-0",children:s.description})]})]}),o&&s.requiredValues.length>0&&e.jsxs("div",{className:"ml-6 mt-2 p-2 bg-gray-50 rounded text-xs",children:[e.jsx("span",{className:"text-gray-700 font-medium",children:"Required values:"}),e.jsx("ul",{className:"m-0 mt-1 pl-4 space-y-0.5",children:s.requiredValues.map((h,E)=>e.jsxs("li",{className:"text-gray-600",children:[e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:h.attributePath})," ",e.jsx("span",{className:"text-gray-400",children:h.comparison})," ",e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:h.value})]},E))})]})]},s.id)})})}const be=({data:t})=>[{title:t!=null&&t.entity?`Create Scenario - ${t.entity.name} - CodeYam`:"Create Scenario - CodeYam"},{name:"description",content:"Create a new scenario"}];function ce(){var W;const{analysis:t,defaultScenario:r,entity:n,entitySha:i,projectSlug:x}=ee(),p=te(),{iframeRef:s}=re(),[o,I]=a.useState(""),[h,E]=a.useState(400),[b,P]=a.useState(!1),[U,R]=a.useState(!1),[G,$]=a.useState(!1),[M,L]=a.useState(null),[F,l]=a.useState(null),[d,H]=a.useState([]),D=a.useMemo(()=>{var c;return!((c=t==null?void 0:t.metadata)!=null&&c.executionFlows)||!(t!=null&&t.scenarios)?[]:oe(t.metadata.executionFlows,t.scenarios).executionFlows},[t]),{interactiveServerUrl:y,isStarting:J,isLoading:_,showIframe:q,iframeKey:B,onIframeLoad:V}=ne({analysisId:t==null?void 0:t.id,scenarioId:r==null?void 0:r.id,scenarioName:r==null?void 0:r.name,projectSlug:x,enabled:!0}),Y=a.useCallback(async()=>{var m,c,T,z;if(!o.trim()&&d.length===0){L("Please describe how you want to change the scenario or select execution flows");return}R(!0),L(null),l("Generating scenario with AI...");try{const u=await fetch("/api/generate-scenario-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:o,existingScenarios:t.scenarios,scenariosDataStructure:(m=t.metadata)==null?void 0:m.scenariosDataStructure,flowSelections:d.length>0?d:void 0})}),N=await u.json();if(!u.ok||!N.success)throw new Error(N.error||"Failed to generate scenario data");console.log("[CreateScenario] AI generated scenario:",N.data);const g=N.data;if(!g.name||!g.data)throw new Error("AI response missing required fields (name or data)");l("Saving new scenario..."),$(!0);const X={name:g.name,description:g.description||o,metadata:{data:g.data,interactiveExamplePath:(c=r.metadata)==null?void 0:c.interactiveExamplePath}},Q=[...t.scenarios||[],X],O=await fetch("/api/save-scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({analysis:t,scenarios:Q})}),C=await O.json();if(!O.ok||!C.success)throw new Error(C.error||"Failed to save scenario");console.log("[CreateScenario] Scenario saved:",C);const f=(z=(T=C.analysis)==null?void 0:T.scenarios)==null?void 0:z.find(k=>k.name===g.name);if(!(f!=null&&f.id)){console.warn("[CreateScenario] Could not find saved scenario ID, navigating to entity page"),l("Scenario created! Redirecting..."),setTimeout(()=>void p(`/entity/${i}`),1e3);return}if(y){l("Capturing screenshot...");const k=await fetch("/api/capture-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverUrl:y,scenarioId:f.id,projectId:t.projectId,viewportWidth:1440})}),A=await k.json();!k.ok||!A.success?(console.error("[CreateScenario] Capture failed:",A),l("Scenario created! (Screenshot capture failed)")):l("Scenario created and captured!")}else l("Scenario created!");setTimeout(()=>{p(`/entity/${i}/scenarios/${f.id}`)},1e3)}catch(u){console.error("[CreateScenario] Error:",u),L(u instanceof Error?u.message:String(u)),l(null)}finally{R(!1),$(!1)}},[o,d,t,r,i,y,p]),j=U||G,K=a.useCallback(()=>{P(!0)},[]),w=a.useCallback(m=>{if(!b)return;const c=m.clientX;c>=250&&c<=600&&E(c)},[b]),S=a.useCallback(()=>{P(!1)},[]);return a.useEffect(()=>(b?(document.addEventListener("mousemove",w),document.addEventListener("mouseup",S)):(document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)}),[b,w,S]),e.jsxs("div",{className:"h-screen bg-white flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 shrink-0 relative h-[54px]",children:e.jsxs("div",{className:"flex items-end h-full px-6 gap-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1 pb-[14px]",children:[e.jsx("button",{onClick:()=>void p(`/entity/${i}`),className:"no-underline shrink-0 bg-transparent border-none cursor-pointer p-0 flex items-center",title:"Back",children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",children:e.jsx("path",{d:"M13 8.5H4M4 8.5L8.5 4M4 8.5L8.5 13",stroke:"#005c75",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("h1",{className:"text-base font-semibold text-black m-0 leading-[20px] shrink-0",children:n==null?void 0:n.name}),e.jsx("span",{className:"text-xs text-[#9e9e9e] font-mono font-normal whitespace-nowrap overflow-hidden text-ellipsis min-w-0",title:n==null?void 0:n.filePath,children:n==null?void 0:n.filePath})]}),e.jsxs("div",{className:"flex items-end gap-8 shrink-0",children:[e.jsx(v,{to:`/entity/${i}/scenarios`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-medium border-b-2",style:{color:"#005C75",borderColor:"#005C75"},children:e.jsxs("span",{className:"flex items-center gap-2",children:["Scenarios",e.jsx("span",{className:"inline-flex items-center justify-center px-2 py-0.5 text-xs font-semibold rounded-full bg-[#cbf3fa] text-[#005c75]",children:((W=t==null?void 0:t.scenarios)==null?void 0:W.length)||0})]})}),e.jsx(v,{to:`/entity/${i}/related`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Related Entities"}),e.jsx(v,{to:`/entity/${i}/code`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Code"}),e.jsx(v,{to:`/entity/${i}/data`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"Data Structure"}),e.jsx(v,{to:`/entity/${i}/history`,className:"relative pb-[17px] px-2 text-sm transition-colors cursor-pointer no-underline font-normal hover:text-gray-700",style:{color:"#9ca3af"},children:"History"})]})]})}),e.jsxs("div",{className:"flex flex-1 gap-0 min-h-0 relative",children:[e.jsxs("aside",{className:"bg-white border-r border-gray-200 overflow-y-auto shrink-0 p-6 flex flex-col",style:{width:`${h}px`},children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Default Scenario Preview"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:"The preview on the right shows the Default Scenario. Select execution flows and/or describe how you'd like to change it."})]}),D.length>0&&e.jsxs("details",{className:"mb-4 border border-gray-200 rounded-lg",children:[e.jsxs("summary",{className:"px-3 py-2 text-sm font-medium text-gray-700 cursor-pointer hover:bg-gray-50 rounded-lg",children:["Select Execution Flows"," ",d.length>0&&e.jsxs("span",{className:"text-blue-600",children:["(",d.length," selected)"]})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-gray-100",children:e.jsx(ie,{executionFlows:D,selections:d,onChange:H,disabled:j})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-700 mb-2",children:"Describe your scenario"}),e.jsx("textarea",{id:"prompt",value:o,onChange:m=>I(m.target.value),placeholder:"e.g., Show an empty state with no items...",className:"w-full h-32 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 text-sm resize-none",disabled:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>void Y(),disabled:j||!o.trim()&&d.length===0,className:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg text-sm font-medium cursor-pointer transition-colors hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed",children:j?"Creating...":"Create Scenario"}),F&&e.jsx("div",{className:"text-xs text-blue-600 bg-blue-50 px-2 py-1.5 rounded",children:F}),M&&e.jsx("div",{className:"text-xs text-red-600 bg-red-50 px-2 py-1.5 rounded",children:M})]})]}),e.jsxs("div",{onMouseDown:K,style:{width:"20px",position:"absolute",top:0,left:`${h-10}px`,bottom:0,cursor:"col-resize",touchAction:"none",userSelect:"none",zIndex:100,pointerEvents:"auto"},children:[e.jsx("div",{style:{position:"absolute",left:"10px",top:0,bottom:0,width:"1px",background:b?"#005c75":"rgba(0,0,0,0.1)",transition:"background 0.15s ease"}}),e.jsx("div",{style:{position:"absolute",top:"50%",left:"10px",transform:"translate(-50%, -50%)",width:"8px",height:"40px",background:"#fff",border:"1px solid rgba(0,0,0,0.15)",borderRadius:"4px",cursor:"col-resize"}})]}),e.jsx("main",{className:"flex-1 overflow-auto flex items-center justify-center min-w-0",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{r as l,w as Y,u as K,a as Q,L as z}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{W as X,u as Z,I as ee}from"./InteractivePreview-DtYTSPL2.js";import{u as te}from"./Spinner-Bc8BG-Lw.js";import"./preload-helper-ckwbz45p.js";import"./useLastLogLine-D9QZKaLJ.js";import"./InlineSpinner-CgTNOhnu.js";function U(t,n,r){if(Array.isArray(t)){if(!isNaN(parseInt(n)))return t[parseInt(n)];for(const s of t)if(s.name===n||s.title===n||s.id===n)return s}return t[n]}function q(t){return t&&(typeof t=="object"||Array.isArray(t))}function re(t){return Array.isArray(t)?t.length:void 0}function ne(t){const{data:n,structure:r}=t;if(!(!n&&!r)){if(Array.isArray(r))return Array.isArray(n)?n.map((s,d)=>d.toString()):[];if(typeof r=="object")return[...new Set([...Object.keys(n),...Object.keys(r)])].sort((d,o)=>{const p=q(n[d]),c=q(n[o]);return p&&!c?1:!p&&c?-1:d.localeCompare(o)});if(typeof n=="object")return Object.keys(n).sort((d,o)=>d.localeCompare(o))}}function se({scenarioFormData:t,handleInputChange:n}){return e.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid w-full max-w-sm items-center gap-1.5",children:[e.jsx("label",{htmlFor:"name",className:"text-sm font-medium text-gray-700",children:"Name"}),e.jsx("input",{type:"text",id:"name",placeholder:"Name",name:"name",value:t.name,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{className:"grid w-full gap-1.5 pt-2",children:[e.jsx("label",{htmlFor:"description",className:"text-sm font-medium text-gray-700",children:"Description"}),e.jsx("textarea",{placeholder:"Type your message here.",id:"description",name:"description",value:t.description,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 min-h-[100px]"})]}),e.jsx("button",{type:"submit",className:"mt-3 w-full px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium",children:"Save Name & Description"})]})}function ae({path:t,namedPath:n,isArray:r,count:s,onClick:d}){const o=l.useCallback(()=>{d&&d(t)},[d,t]);return e.jsxs("div",{className:"bg-blue-50 p-3 rounded-lg flex items-center justify-between cursor-pointer group hover:bg-blue-100 transition-colors border border-blue-200",onClick:o,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})}),e.jsxs("div",{className:"capitalize font-medium text-gray-900",children:[n[n.length-1],s!==void 0&&` (${s})`]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-5 h-5 text-red-500 opacity-0 group-hover:opacity-100 transition-opacity",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})}var V=(t=>(t.STRING="string",t.NUMBER="number",t.BOOLEAN="boolean",t.UNION="union",t.OBJECT="object",t.ARRAY="array",t))(V||{});const oe=({name:t,value:n,options:r,onChange:s})=>{const d=l.useCallback(o=>{s({target:{name:t,value:o.target.value}})},[t,s]);return e.jsx("select",{name:t,value:n,onChange:d,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:r.map((o,p)=>e.jsx("option",{value:o.trim(),children:o.trim()},p))})},ie=({name:t,value:n,onChange:r})=>{const s=l.useCallback(d=>{const o=d.target.checked;r({target:{name:t,value:o}})},[t,r]);return e.jsx("label",{className:"flex items-center gap-2 cursor-pointer",children:e.jsx("input",{type:"checkbox",name:t,checked:n,onChange:s,className:`w-10 h-6 rounded-full appearance-none cursor-pointer transition-colors relative
1
+ import{r as l,w as Y,u as K,a as Q,L as z}from"./chunk-UVKPFVEO-Bmq2apuh.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{W as X,u as Z,I as ee}from"./InteractivePreview-6WjVfhxX.js";import{u as te}from"./Spinner-CIil5-gb.js";import"./preload-helper-ckwbz45p.js";import"./useLastLogLine-C8QvIe05.js";import"./InlineSpinner-ByaELMbv.js";function U(t,n,r){if(Array.isArray(t)){if(!isNaN(parseInt(n)))return t[parseInt(n)];for(const s of t)if(s.name===n||s.title===n||s.id===n)return s}return t[n]}function q(t){return t&&(typeof t=="object"||Array.isArray(t))}function re(t){return Array.isArray(t)?t.length:void 0}function ne(t){const{data:n,structure:r}=t;if(!(!n&&!r)){if(Array.isArray(r))return Array.isArray(n)?n.map((s,d)=>d.toString()):[];if(typeof r=="object")return[...new Set([...Object.keys(n),...Object.keys(r)])].sort((d,o)=>{const p=q(n[d]),c=q(n[o]);return p&&!c?1:!p&&c?-1:d.localeCompare(o)});if(typeof n=="object")return Object.keys(n).sort((d,o)=>d.localeCompare(o))}}function se({scenarioFormData:t,handleInputChange:n}){return e.jsxs("div",{className:"p-3 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid w-full max-w-sm items-center gap-1.5",children:[e.jsx("label",{htmlFor:"name",className:"text-sm font-medium text-gray-700",children:"Name"}),e.jsx("input",{type:"text",id:"name",placeholder:"Name",name:"name",value:t.name,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{className:"grid w-full gap-1.5 pt-2",children:[e.jsx("label",{htmlFor:"description",className:"text-sm font-medium text-gray-700",children:"Description"}),e.jsx("textarea",{placeholder:"Type your message here.",id:"description",name:"description",value:t.description,onChange:n,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 min-h-[100px]"})]}),e.jsx("button",{type:"submit",className:"mt-3 w-full px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 font-medium",children:"Save Name & Description"})]})}function ae({path:t,namedPath:n,isArray:r,count:s,onClick:d}){const o=l.useCallback(()=>{d&&d(t)},[d,t]);return e.jsxs("div",{className:"bg-blue-50 p-3 rounded-lg flex items-center justify-between cursor-pointer group hover:bg-blue-100 transition-colors border border-blue-200",onClick:o,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})}),e.jsxs("div",{className:"capitalize font-medium text-gray-900",children:[n[n.length-1],s!==void 0&&` (${s})`]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("svg",{className:"w-5 h-5 text-red-500 opacity-0 group-hover:opacity-100 transition-opacity",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})}var V=(t=>(t.STRING="string",t.NUMBER="number",t.BOOLEAN="boolean",t.UNION="union",t.OBJECT="object",t.ARRAY="array",t))(V||{});const oe=({name:t,value:n,options:r,onChange:s})=>{const d=l.useCallback(o=>{s({target:{name:t,value:o.target.value}})},[t,s]);return e.jsx("select",{name:t,value:n,onChange:d,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:r.map((o,p)=>e.jsx("option",{value:o.trim(),children:o.trim()},p))})},ie=({name:t,value:n,onChange:r})=>{const s=l.useCallback(d=>{const o=d.target.checked;r({target:{name:t,value:o}})},[t,r]);return e.jsx("label",{className:"flex items-center gap-2 cursor-pointer",children:e.jsx("input",{type:"checkbox",name:t,checked:n,onChange:s,className:`w-10 h-6 rounded-full appearance-none cursor-pointer transition-colors relative
2
2
  bg-gray-300 checked:bg-blue-600
3
3
  after:content-[''] after:absolute after:top-1 after:left-1 after:w-4 after:h-4
4
4
  after:bg-white after:rounded-full after:transition-transform