tycono 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -86,11 +86,11 @@ DevOps Engineer, member, cto
|
|
|
86
86
|
VP Marketing, c-level, ceo`,className:"w-full h-40 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors font-mono"}),o.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Format: Name, Level (member/team-lead/c-level), ReportsTo. Level and ReportsTo are optional."})]}),D.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:["Preview (",D.length," role",D.length!==1?"s":"",")"]}),o.jsx("div",{className:"bg-white/5 rounded-lg border border-white/10 overflow-hidden",children:o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-white/10",children:[o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Name"}),o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"ID"}),o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Level"}),o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Reports To"})]})}),o.jsx("tbody",{children:D.map((te,ke)=>o.jsxs("tr",{className:`border-b border-white/5 ${te.error?"bg-red-900/10":""}`,children:[o.jsx("td",{className:"p-2 text-white/80",children:te.name}),o.jsx("td",{className:"p-2 text-white/60 font-mono",children:te.id}),o.jsx("td",{className:"p-2 text-white/60",children:te.level}),o.jsx("td",{className:"p-2 text-white/60",children:te.reportsTo}),te.error&&o.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:te.error})]},ke))})]})})]})]}),V==="review"&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:["Confirm Bulk Hire — ",D.length," roles"]}),o.jsx("div",{className:"bg-white/5 rounded-lg border border-white/10 overflow-hidden max-h-[300px] overflow-y-auto",children:o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{className:"sticky top-0 bg-[var(--wall)]",children:o.jsxs("tr",{className:"border-b border-white/10",children:[o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"#"}),o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Name"}),o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"ID"}),o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Level"}),o.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Reports To"})]})}),o.jsx("tbody",{children:D.map((te,ke)=>o.jsxs("tr",{className:"border-b border-white/5",children:[o.jsx("td",{className:"p-2 text-white/30",children:ke+1}),o.jsx("td",{className:"p-2 text-white/80",children:te.name}),o.jsx("td",{className:"p-2 text-white/60 font-mono",children:te.id}),o.jsx("td",{className:"p-2 text-white/60",children:te.level}),o.jsx("td",{className:"p-2 text-white/60",children:te.reportsTo})]},ke))})]})}),B&&Q.total>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between text-[10px] text-white/40 mb-1",children:[o.jsx("span",{children:"Hiring..."}),o.jsxs("span",{children:[Q.done,"/",Q.total]})]}),o.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Q.done/Q.total*100}%`,background:"#2E7D32"}})})]}),o.jsx("div",{className:"text-[10px] text-white/30",children:"Each role will get a random appearance and auto-generated persona. You can customize them later."}),I&&o.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:I})]})]})}),o.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[o.jsxs("div",{children:[i==="single"&&u>1&&o.jsx("button",{onClick:()=>f(u-1),className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Back"}),i==="bulk"&&V==="review"&&o.jsx("button",{onClick:()=>Y("input"),disabled:B,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer disabled:opacity-40",children:"Back"})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:l,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),i==="single"?u<ps?o.jsx("button",{onClick:()=>f(u+1),disabled:!oe(u),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:"Next"}):o.jsx("button",{onClick:_e,disabled:B,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:B?"Hiring...":"HIRE"}):V==="input"?o.jsxs("button",{onClick:()=>Y("review"),disabled:!pe,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:["Review (",D.length,")"]}):o.jsx("button",{onClick:K,disabled:B,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:B?`Hiring ${Q.done}/${Q.total}...`:`HIRE ALL (${D.length})`})]})]})]})]})}function ys({label:t,value:l,mono:r}){return o.jsxs("div",{className:"flex justify-between text-sm",children:[o.jsx("span",{className:"text-white/40",children:t}),o.jsx("span",{className:`font-semibold text-white/80 ${r?"font-mono":""}`,children:l})]})}function vC({roleId:t,roleName:l,onClose:r,onConfirm:i}){const[c,u]=k.useState(!1),f=async()=>{u(!0);try{await i(t)}finally{u(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:r}),o.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[o.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[o.jsx("div",{className:"text-lg font-bold",children:"Fire Role"}),o.jsxs("div",{className:"text-sm opacity-80 mt-0.5",children:["Remove ",l," (",t,")"]})]}),o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"p-4 rounded-lg border-2 border-red-300 bg-red-50 mb-4",children:[o.jsx("div",{className:"text-sm font-bold text-red-800 mb-1",children:"Warning"}),o.jsxs("div",{className:"text-xs text-red-700 leading-relaxed",children:["This will permanently delete the role directory including",o.jsx("strong",{children:" role.yaml"}),", ",o.jsx("strong",{children:"profile.md"}),", ",o.jsx("strong",{children:"SKILL.md"}),", and all journal entries. This action cannot be undone."]})]}),o.jsxs("div",{className:"text-sm text-gray-600",children:["Are you sure you want to fire ",o.jsx("strong",{children:l}),"?"]})]}),o.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[o.jsx("button",{onClick:r,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 cursor-pointer",children:"Cancel"}),o.jsx("button",{onClick:f,disabled:c,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:c?"Removing...":"Confirm Fire"})]})]})]})}const wC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function kC({roleId:t,title:l,roleColor:r,active:i,onClick:c,onClose:u,"data-session-id":f}){return o.jsxs("button",{onClick:c,"data-session-id":f,className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors max-w-[180px] group ${i?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] hover:bg-[var(--terminal-surface)]"}`,style:i?{borderTop:`2px solid ${r}`}:void 0,children:[o.jsx("span",{className:"text-xs",children:wC[t]??"👤"}),o.jsx("span",{className:"truncate",children:l}),o.jsx("span",{onClick:u,className:"ml-auto text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none",children:"×"})]})}function SC({content:t,streaming:l}){let r=t;return l&&(t.match(/```/g)??[]).length%2!==0&&(r+="\n```"),o.jsx("div",{className:"terminal-markdown",children:o.jsx(Ny,{remarkPlugins:[Zy],components:{code:jC,table:({children:i})=>o.jsx("div",{className:"overflow-x-auto my-2",children:o.jsx("table",{className:"terminal-table",children:i})})},children:r})})}function jC({className:t,children:l,...r}){const i=/language-(\w+)/.exec(t??"");return i||typeof l=="string"&&l.includes(`
|
|
87
87
|
`)?o.jsx(CC,{language:i==null?void 0:i[1],children:l}):o.jsx("code",{className:"terminal-inline-code",...r,children:l})}function CC({children:t,language:l}){const[r,i]=k.useState(!1),c=String(t).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(c),i(!0),setTimeout(()=>i(!1),1500)};return o.jsxs("div",{className:"terminal-code-block group relative my-2",children:[l&&o.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] px-3 pt-1.5",children:l}),o.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:r?"Copied!":"Copy"}),o.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:o.jsx("code",{children:c})})]})}const EC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function jd(t,l){return l?l.file_path?String(l.file_path).replace(/^.*\/(?=[^/]+\/)/,""):l.path?String(l.path).replace(/^.*\/(?=[^/]+\/)/,""):l.pattern?String(l.pattern):l.command?String(l.command).slice(0,60):l.query?String(l.query).slice(0,60):l.url?String(l.url).slice(0,60):"":""}function NC(t){const l=[];let r="";for(const i of t)if(i.type==="thinking")i.text&&(r=i.text),l.length===0||l[l.length-1].type!=="thinking"?l.push({type:"thinking",text:i.text}):l[l.length-1].text=i.text;else if(i.type==="tool")l.push({type:"tool",toolName:i.toolName,toolSummary:jd(i.toolName??"",i.toolInput),toolInput:i.toolInput});else if(i.type==="dispatch")l.push({type:"dispatch",roleId:i.roleId,task:i.task});else if(i.type==="dispatch:progress"){const c=l.length>0?l[l.length-1]:null;(c==null?void 0:c.type)==="dispatch:progress"&&c.roleId===i.roleId?i.progressType==="tool"?(c.toolName=i.toolName,c.toolSummary=jd(i.toolName??"",i.toolInput),c.progressType="tool"):i.progressType==="thinking"?(c.text=i.text,c.progressType="thinking"):i.progressType==="text"?(c.text=i.text,c.progressType="text"):(i.progressType==="done"||i.progressType==="error")&&(c.progressType=i.progressType):l.push({type:"dispatch:progress",roleId:i.roleId,progressType:i.progressType,text:i.text,toolName:i.toolName,toolSummary:i.toolName?jd(i.toolName,i.toolInput):void 0})}if(r){const i=l.filter(c=>c.type==="thinking");i.length>0&&(i[i.length-1].text=r)}return l}function AC({event:t,isStreaming:l}){var c,u,f;const[r,i]=k.useState(!1);switch(t.type){case"thinking":return o.jsxs("div",{className:"stream-event-thinking",children:[o.jsxs("div",{className:"stream-event-thinking-header",onClick:()=>i(!r),children:[o.jsx("span",{className:"stream-event-thinking-icon"}),o.jsxs("span",{className:"stream-event-thinking-label",children:["thinking",l?"...":""]}),t.text&&!l&&o.jsx("span",{className:"stream-event-thinking-toggle",children:r?"▾":"▸"})]}),(l||r)&&t.text&&o.jsx("div",{className:"stream-event-thinking-content",children:t.text.slice(-500)})]});case"tool":return o.jsxs("div",{className:"stream-event-tool",children:[o.jsx("span",{className:"stream-event-tool-badge",children:t.toolName}),t.toolSummary&&o.jsx("span",{className:"stream-event-tool-path",children:t.toolSummary}),t.toolInput&&o.jsx("span",{className:"stream-event-tool-toggle",onClick:()=>i(!r),children:r?"▾":"▸"}),r&&t.toolInput&&o.jsx("div",{className:"stream-event-tool-detail",children:JSON.stringify(t.toolInput,null,1).slice(0,300)})]});case"dispatch":return o.jsxs("div",{className:"stream-event-dispatch",children:[o.jsxs("span",{className:"stream-event-dispatch-badge",children:["→"," ",(c=t.roleId)==null?void 0:c.toUpperCase()]}),o.jsx("span",{className:"stream-event-dispatch-task",children:(u=t.task)==null?void 0:u.slice(0,80)})]});case"dispatch:progress":return o.jsxs("div",{className:"stream-event-dispatch-progress",children:[o.jsx("span",{className:"stream-event-dispatch-progress-role",children:(f=t.roleId)==null?void 0:f.toUpperCase()}),t.progressType==="thinking"&&o.jsxs("span",{className:"stream-event-dispatch-progress-status",children:["thinking",l?"...":""]}),t.progressType==="tool"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-event-tool-badge",children:t.toolName}),t.toolSummary&&o.jsx("span",{className:"stream-event-tool-path",children:t.toolSummary})]}),t.progressType==="text"&&t.text&&o.jsx("span",{className:"stream-event-dispatch-progress-status",children:"responding..."}),t.progressType==="done"&&o.jsx("span",{className:"stream-event-dispatch-progress-done",children:"done"}),t.progressType==="error"&&o.jsx("span",{className:"stream-event-dispatch-progress-error",children:"error"})]});default:return null}}function DC({events:t,isStreaming:l}){const[r,i]=k.useState(!1);if(t.length===0)return null;const c=NC(t);if(c.length===0)return null;const u=t.filter(b=>b.type==="thinking").length,f=t.filter(b=>b.type==="tool"),m=t.filter(b=>b.type==="dispatch"||b.type==="dispatch:progress"),p=t.filter(b=>b.type==="turn").reduce((b,v)=>Math.max(b,v.turn??0),0),d=[];if(u>0&&d.push("thinking"),f.length>0){const b=[...new Set(f.map(v=>v.toolName))];b.length<=3?d.push(b.join(", ")):d.push(`${f.length} tool calls`)}m.length>0&&d.push(`${m.length} dispatch`),p>1&&d.push(`${p} turns`);const g=d.join(" · "),y=!r;return o.jsxs("div",{className:"stream-activity-log",children:[o.jsxs("div",{className:"stream-activity-header",onClick:()=>i(!r),children:[l&&o.jsx("span",{className:"stream-activity-pulse"}),o.jsxs("span",{className:"stream-activity-summary",children:[r?"▸":"▾"," ",g,l?"...":""]})]}),y&&o.jsx("div",{className:"stream-activity-events",children:c.map((b,v)=>o.jsx(AC,{event:b,isStreaming:l&&v===c.length-1},v))})]})}function TC({message:t,roleId:l,roleColor:r}){var d;const i=t.from==="ceo",c=t.type==="system",u=t.status==="streaming";if(c)return o.jsx("div",{className:"flex justify-center my-2",children:o.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] bg-[var(--terminal-inline-bg)] px-3 py-1 rounded-full",children:t.content})});if(i)return o.jsx("div",{className:"flex justify-end mb-3",children:o.jsxs("div",{className:"max-w-[85%]",children:[o.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] text-right mb-1",children:"CEO"}),o.jsxs("div",{className:"bg-[var(--terminal-surface-light)] rounded-xl rounded-tr-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",children:[t.type==="directive"&&o.jsx("span",{className:"text-amber-400 text-[10px] font-bold mr-1.5",children:"DO"}),t.content]})]})});const f=(((d=t.streamEvents)==null?void 0:d.length)??0)>0,m=!!t.thinking,p=m&&!t.content&&u&&!f;return o.jsxs("div",{className:"flex gap-2.5 mb-3",children:[o.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-sm shrink-0 mt-5",style:{background:`${r}33`},children:EC[l]??"👤"}),o.jsxs("div",{className:"max-w-[85%] min-w-0",children:[o.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] mb-1",children:l.toUpperCase()}),f&&o.jsx(DC,{events:t.streamEvents,isStreaming:u}),m&&!f&&o.jsxs("details",{open:p,className:"mb-1",children:[o.jsxs("summary",{className:"text-[10px] text-purple-400/70 cursor-pointer select-none flex items-center gap-1",children:[p&&o.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"}),"thinking",p?"...":` (${t.thinking.length} chars)`]}),o.jsx("div",{className:"text-[11px] text-[var(--terminal-text-muted)] leading-relaxed mt-1 pl-2 border-l border-purple-400/20 max-h-32 overflow-y-auto",children:t.thinking.slice(-500)})]}),o.jsxs("div",{className:"rounded-xl rounded-tl-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",style:{borderLeft:`3px solid ${r}`,background:"var(--terminal-surface)"},children:[t.content?o.jsx(SC,{content:t.content,streaming:u}):u&&!m?o.jsx("span",{className:"inline-block w-2 h-4 bg-[var(--terminal-text-secondary)] animate-pulse"}):u&&m?o.jsx("span",{className:"text-[11px] text-purple-400/50 italic",children:"analyzing..."}):null,u&&t.content&&o.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--terminal-text-secondary)] animate-pulse ml-0.5 align-middle"})]}),t.status==="error"&&o.jsx("div",{className:"text-[10px] text-red-400 mt-1",children:"Error occurred"})]})]})}function zC({messages:t,roleId:l,roleColor:r}){var c;const i=k.useRef(null);return k.useEffect(()=>{var u;(u=i.current)==null||u.scrollIntoView({behavior:"smooth"})},[t,(c=t[t.length-1])==null?void 0:c.content]),t.length===0?o.jsxs("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:["Start a conversation with ",l.toUpperCase()]}):o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 terminal-scrollbar",children:[t.map(u=>o.jsx(TC,{message:u,roleId:l,roleColor:r},u.id)),o.jsx("div",{ref:i})]})}function MC({mode:t,onModeChange:l,onSend:r,disabled:i,disabledReason:c}){const[u,f]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{const g=m.current;g&&(g.style.height="0",g.style.height=Math.min(g.scrollHeight,120)+"px")},[u]);const p=()=>{const g=u.trim();!g||i||(r(g),f(""))},d=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),p())};return o.jsxs("div",{className:"border-t border-[var(--terminal-border)] p-3 shrink-0",children:[c&&o.jsx("div",{className:"text-[10px] text-amber-400/70 mb-2 text-center",children:c}),o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsxs("div",{className:"flex rounded-lg overflow-hidden border border-[var(--terminal-border)] shrink-0",children:[o.jsx("button",{onClick:()=>l("talk"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${t==="talk"?"bg-[var(--desk-wood)] text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Talk"}),o.jsx("button",{onClick:()=>l("do"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${t==="do"?"bg-amber-700 text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Do"})]}),o.jsx("textarea",{ref:m,value:u,onChange:g=>f(g.target.value),onKeyDown:d,placeholder:i?"Waiting...":t==="talk"?"Ask something...":"Give a directive...",disabled:i,rows:1,className:"flex-1 bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] rounded-lg px-3 py-2 text-sm text-[var(--terminal-text)] placeholder:text-[var(--terminal-text-muted)] resize-none focus:outline-none focus:border-[var(--terminal-border-hover)] disabled:opacity-40 terminal-scrollbar"}),o.jsx("button",{onClick:p,disabled:i||!u.trim(),className:"w-8 h-8 rounded-lg bg-[var(--terminal-surface-light)] text-[var(--terminal-text-secondary)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--desk-wood)] hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M22 2L11 13"}),o.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})]})}const RC={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},wg={cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function S0(t){return new Date(t).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function FC({msg:t}){const l=RC[t.roleId]??"#888",r=wg[t.roleId]??t.roleId;if(t.type==="dispatch"){const i=t.text.includes("WAVE"),c=t.text.includes("completed")||t.text.includes("완료"),u=i?"📡":c?"✓":"→",f=c?"text-green-400/70":"text-[var(--terminal-text-muted)]";return o.jsxs("div",{className:"flex items-start gap-2 px-3 py-1 hover:bg-white/[0.02]",children:[o.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:S0(t.ts)}),o.jsx("span",{className:"text-[10px] shrink-0 mt-0.5",children:u}),o.jsx("span",{className:`text-[11px] ${f}`,children:t.text})]})}return o.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-white/[0.02]",children:[o.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:S0(t.ts)}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-[11px] font-semibold mr-1.5",style:{color:l},children:r}),o.jsx("span",{className:"text-xs text-[var(--terminal-text-secondary)]",children:t.text})]})]})}function _C({channel:t,allRoles:l,onUpdateMembers:r,onUpdateTopic:i}){const c=k.useRef(null),u=k.useRef(null);k.useEffect(()=>{var j;const b=u.current;if(!b)return;b.scrollHeight-b.scrollTop-b.clientHeight<80&&((j=c.current)==null||j.scrollIntoView({behavior:"smooth"}))},[t.messages.length]);const[f,m]=k.useState(!1),[p,d]=k.useState(!1),[g,y]=k.useState("");return o.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto terminal-scrollbar py-2",children:[o.jsxs("div",{className:"px-3 py-2 mb-2 border-b border-[var(--terminal-border)] flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--terminal-text)]",children:t.name}),t.members.length>0&&o.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:t.members.map(b=>wg[b]??b).join(", ")}),t.members.length===0&&o.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:t.isDefault?"system logs":"no members"}),!t.isDefault&&l&&r&&o.jsx("button",{className:"ml-auto text-[10px] px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 text-[var(--terminal-text-muted)]",onClick:()=>m(!f),children:f?"Done":"Invite"})]}),!t.isDefault&&i&&o.jsx("div",{className:"px-3 pb-2 mb-1",children:p?o.jsx("input",{autoFocus:!0,value:g,onChange:b=>y(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(i(t.id,g.trim()),d(!1)),b.key==="Escape"&&d(!1)},onBlur:()=>{i(t.id,g.trim()),d(!1)},placeholder:"Set a topic for this channel...",className:"w-full bg-transparent text-[10px] text-[var(--terminal-text-muted)] outline-none border-b border-[var(--terminal-border)] pb-0.5"}):o.jsx("button",{onClick:()=>{y(t.topic??""),d(!0)},className:"text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] cursor-pointer italic",children:t.topic||"Click to set channel topic..."})}),f&&!t.isDefault&&l&&r&&o.jsx("div",{className:"px-3 pb-2 mb-2 border-b border-[var(--terminal-border)]",children:o.jsx("div",{className:"flex flex-wrap gap-1",children:l.map(b=>{const v=t.members.includes(b.id);return o.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${v?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const j=v?t.members.filter(S=>S!==b.id):[...t.members,b.id];r(t.id,j)},children:[v?"✓ ":"",b.name]},b.id)})})}),t.messages.length===0&&o.jsx("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] text-xs gap-1 py-8",children:o.jsx("span",{children:t.isDefault?"No dispatch events yet":"No messages yet — invite roles to start chatting"})}),t.messages.map(b=>o.jsx(FC,{msg:b},b.id)),o.jsx("div",{ref:c})]})}const Cd={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},OC=400,BC=800;function LC({sessions:t,activeSessionId:l,roles:r,streamingSessionId:i,width:c,onWidthChange:u,onSwitchSession:f,onCloseSession:m,onCreateSession:p,onClearEmpty:d,onCloseAll:g,onSendMessage:y,onModeChange:b,onCloseTerminal:v,chatChannels:j,activeChatChannelId:S,onSwitchChatChannel:C,onCreateChatChannel:E,onDeleteChatChannel:A,onUpdateChatMembers:R,onUpdateChatTopic:O,unreadChannels:B}){const[T,I]=k.useState(!1),[X,ee]=k.useState(!1),[z,$]=k.useState(!1),[U,ne]=k.useState(""),re=S!=null,V=j==null?void 0:j.find(K=>K.id===S),[Y,Q]=k.useState(!1),[se,ve]=k.useState(!1),[M,_]=k.useState(!1),J=k.useRef(0),D=k.useRef(0),pe=k.useRef(null),Ce=t.find(K=>K.id===l),Ne=i===l,He=t.filter(K=>K.messages.length===0).length,_e=k.useCallback(()=>{const K=pe.current;K&&(ve(K.scrollLeft>0),_(K.scrollLeft+K.clientWidth<K.scrollWidth-1))},[]);k.useEffect(()=>{if(!l||!pe.current)return;const K=pe.current.querySelector(`[data-session-id="${l}"]`);K&&K.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),_e()},[l,t.length,_e]),k.useEffect(()=>{const K=pe.current;if(!K)return;_e(),K.addEventListener("scroll",_e);const fe=new ResizeObserver(_e);return fe.observe(K),()=>{K.removeEventListener("scroll",_e),fe.disconnect()}},[_e]);const oe=k.useCallback(K=>{K.preventDefault(),J.current=K.clientX,D.current=c,Q(!0);const fe=te=>{const ke=J.current-te.clientX,je=Math.min(BC,Math.max(OC,D.current+ke));u==null||u(je)},Se=()=>{Q(!1),document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",Se)};document.addEventListener("mousemove",fe),document.addEventListener("mouseup",Se)},[c,u]);return o.jsxs("div",{className:"shrink-0 bg-[var(--terminal-bg)] border-l border-[var(--terminal-border)] flex flex-col h-full relative",style:{width:c},children:[u&&o.jsx("div",{className:`terminal-resize-handle absolute top-0 left-0 w-1 h-full cursor-col-resize z-10 transition-colors ${Y?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:oe}),o.jsxs("div",{className:"flex items-center bg-[var(--terminal-bg-deeper)] border-b border-[var(--terminal-border)] shrink-0",children:[o.jsxs("div",{className:"relative flex-1 min-w-0",children:[se&&o.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 bg-gradient-to-r from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"}),o.jsxs("div",{ref:pe,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[j==null?void 0:j.map(K=>o.jsxs("button",{onClick:()=>{C==null||C(K.id)},className:`flex items-center gap-1 px-2.5 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors group ${S===K.id?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface)]"}`,style:S===K.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[o.jsx("span",{className:"text-[10px]",children:"💬"}),o.jsx("span",{className:"truncate",children:K.name}),(B==null?void 0:B.has(K.id))&&S!==K.id&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!K.isDefault&&o.jsx("span",{onClick:fe=>{fe.stopPropagation(),A==null||A(K.id)},className:"ml-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none opacity-0 group-hover:opacity-100",children:"×"})]},K.id)),j&&j.length>0&&t.length>0&&o.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),t.map(K=>o.jsx(kC,{roleId:K.roleId,title:K.title,roleColor:Cd[K.roleId]??"#666",active:!re&&K.id===l,onClick:()=>{C==null||C(null),f(K.id)},onClose:fe=>{fe.stopPropagation(),m(K.id)},"data-session-id":K.id},K.id))]}),M&&o.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-6 bg-gradient-to-l from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"})]}),o.jsxs("div",{className:"relative shrink-0",children:[o.jsx("button",{onClick:()=>{I(!T),ee(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-lg cursor-pointer",children:"+"}),T&&o.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[E&&o.jsxs(o.Fragment,{children:[z?o.jsxs("div",{className:"px-3 py-2 flex items-center gap-1",children:[o.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"#"}),o.jsx("input",{autoFocus:!0,value:U,onChange:K=>ne(K.target.value),onKeyDown:K=>{K.key==="Enter"&&U.trim()&&(E(U.trim(),[]),ne(""),$(!1),I(!1)),K.key==="Escape"&&($(!1),ne(""))},placeholder:"channel name",className:"flex-1 bg-transparent text-xs text-[var(--terminal-text)] outline-none border-b border-[var(--terminal-border)]"})]}):o.jsxs("button",{onClick:()=>$(!0),className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer flex items-center gap-2",children:[o.jsx("span",{className:"text-[10px]",children:"💬"}),"New Channel"]}),o.jsx("div",{className:"border-b border-[var(--terminal-border)] my-1"})]}),r.map(K=>o.jsxs("button",{onClick:()=>{p(K.id),C==null||C(null),I(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:Cd[K.id]??"#666"}}),K.id.toUpperCase()," — ",K.name]},K.id))]})]}),o.jsxs("div",{className:"relative shrink-0",children:[o.jsx("button",{onClick:()=>{ee(!X),I(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-xs cursor-pointer tracking-tight",title:"Manage sessions",children:"···"}),X&&o.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[o.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-[var(--terminal-text-muted)] border-b border-[var(--terminal-border)]",children:[t.length," session",t.length!==1?"s":""]}),He>0&&d&&o.jsxs("button",{onClick:()=>{d(),ee(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:["Clear empty sessions (",He,")"]}),t.length>0&&g&&o.jsx("button",{onClick:()=>{g(),ee(!1)},className:"w-full text-left px-3 py-2 text-xs text-[#E57373] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:"Close all sessions"}),t.length===0&&o.jsx("div",{className:"px-3 py-2 text-xs text-[var(--terminal-text-muted)]",children:"No sessions"})]})]}),o.jsx("button",{onClick:v,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"×"})]}),re&&V?o.jsx(_C,{channel:V,allRoles:r,onUpdateMembers:R,onUpdateTopic:O}):Ce?o.jsxs(o.Fragment,{children:[o.jsx(zC,{messages:Ce.messages,roleId:Ce.roleId,roleColor:Cd[Ce.roleId]??"#666"}),o.jsx(MC,{mode:Ce.mode,onModeChange:K=>b(Ce.id,K),onSend:K=>y(Ce.id,K,Ce.mode),disabled:Ne,disabledReason:Ne?`${Ce.roleId.toUpperCase()} is responding...`:void 0})]}):o.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"No active session. Click [+] to start."})]})}function $C(){const t=k.useRef(null),l=k.useCallback(()=>{var i;(i=t.current)==null||i.abort(),t.current=null},[]);return{sendMessage:k.useCallback((i,c,u,f)=>{l();const m=new AbortController;return t.current=m,fetch(`/api/exec/session/${i}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:c,mode:u}),signal:m.signal}).then(async p=>{var b,v,j,S,C;if(!p.ok||!p.body){f.onError("Failed to connect");return}const d=p.body.getReader(),g=new TextDecoder;let y="";for(;;){const{done:E,value:A}=await d.read();if(E)break;y+=g.decode(A,{stream:!0});const R=y.split(`
|
|
88
88
|
`);y=R.pop()??"";let O="";for(let B=0;B<R.length;B++){const T=R[B];if(T.startsWith("event: ")){O=T.slice(7).trim();continue}if(T.startsWith("data: ")){let I;try{I=JSON.parse(T.slice(6))}catch{O="";continue}switch(O){case"thinking":I.text&&((b=f.onThinking)==null||b.call(f,I.text));break;case"output":I.text&&f.onText(I.text);break;case"tool":(v=f.onToolUse)==null||v.call(f,I.name,I.input);break;case"dispatch":(j=f.onDispatch)==null||j.call(f,I.roleId,I.task);break;case"dispatch:progress":(S=f.onDispatchProgress)==null||S.call(f,I.roleId,I.type,I);break;case"turn":(C=f.onTurn)==null||C.call(f,I.turn);break;case"done":f.onDone(I);break;case"error":f.onError(I.message??"Unknown error");break;default:I.text&&f.onText(I.text);break}O=""}}}}).catch(p=>{p.name!=="AbortError"&&f.onError(p.message)}),{abort:l}},[l]),abort:l}}const Eh="tycono-appearances",Ac="tycono-theme";(()=>{try{for(const[t,l]of[["the-company-appearances",Eh],["the-company-theme",Ac]]){const r=localStorage.getItem(t);r&&!localStorage.getItem(l)&&(localStorage.setItem(l,r),localStorage.removeItem(t))}}catch{}})();function j0(){try{const t=localStorage.getItem(Eh);return t?JSON.parse(t):{}}catch{return{}}}function Ed(t){localStorage.setItem(Eh,JSON.stringify(t))}function C0(){try{const t=localStorage.getItem(Ac);if(t&&t in $r)return t}catch{}return"default"}function HC(t){var i;const l=(i=$r[t])==null?void 0:i.vars;if(!l)return;const r=document.documentElement;for(const[c,u]of Object.entries(l))r.style.setProperty(c,u)}const Nd={mode:"auto",intervalSec:18,dailyBudgetUsd:1},Jd="tycono-speech-settings",Ad="tycono-language";function UC(){try{const t=localStorage.getItem(Jd);return t?{...Nd,...JSON.parse(t)}:Nd}catch{return Nd}}function IC(){const[t,l]=k.useState(j0),[r,i]=k.useState(C0),[c,u]=k.useState(UC),[f,m]=k.useState(()=>{try{return localStorage.getItem(Ad)??"auto"}catch{return"auto"}}),p=k.useRef(!1);k.useEffect(()=>{p.current||(p.current=!0,Ee.getPreferences().then(S=>{const C=Object.keys(S.appearances??{}).length>0||S.theme!=="default";if(S.speech&&(u(E=>({...E,...S.speech})),localStorage.setItem(Jd,JSON.stringify(S.speech))),S.language&&(m(S.language),localStorage.setItem(Ad,S.language)),C){const E=S.appearances;l(E),Ed(E),S.theme&&S.theme in $r&&(i(S.theme),localStorage.setItem(Ac,S.theme))}else{const E=j0(),A=C0();(Object.keys(E).length>0||A!=="default")&&Ee.updatePreferences({appearances:E,theme:A}).catch(()=>{})}}).catch(()=>{}))},[]),k.useEffect(()=>{HC(r)},[r]);const d=k.useCallback(S=>t[S]??Ch(S),[t]),g=k.useCallback((S,C)=>{l(E=>{const A={...E,[S]:C};return Ed(A),Ee.updatePreferences({appearances:A}).catch(()=>{}),A})},[]),y=k.useCallback(S=>{l(C=>{const E={...C};return delete E[S],Ed(E),Ee.updatePreferences({appearances:E}).catch(()=>{}),E})},[]),b=k.useCallback(S=>{i(S),localStorage.setItem(Ac,S),Ee.updatePreferences({theme:S}).catch(()=>{})},[]),v=k.useCallback(S=>{u(C=>{const E={...C,...S};return localStorage.setItem(Jd,JSON.stringify(E)),Ee.updatePreferences({speech:E}).catch(()=>{}),E})},[]),j=k.useCallback(S=>{m(S),localStorage.setItem(Ad,S),Ee.updatePreferences({language:S}).catch(()=>{})},[]);return{appearances:t,getAppearance:d,setAppearance:g,resetAppearance:y,theme:r,setTheme:b,speechSettings:c,setSpeechSettings:v,language:f,setLanguage:j}}const YC=3e4;function qC(){var j;const[t,l]=k.useState(null),[r,i]=k.useState("synced"),[c,u]=k.useState([]),f=k.useRef(null),m=k.useCallback(async()=>{try{const S=await Ee.getSaveStatus();l(S),S.noGit?i("no-git"):i(C=>C==="saving"?C:S.dirty?"dirty":"synced")}catch{i("error")}},[]);k.useEffect(()=>(m(),f.current=setInterval(m,YC),()=>{f.current&&clearInterval(f.current)}),[m]);const p=k.useCallback(async S=>{i("saving");try{const C=await Ee.save(S);return await m(),C}catch(C){throw i("error"),C}},[m]),d=k.useCallback(async()=>{try{const S=await Ee.getSaveHistory(20);u(S)}catch{}},[]),g=k.useCallback(async S=>{i("saving");try{await Ee.restoreSave(S),await m()}catch(C){throw i("error"),C}},[m]),y=k.useCallback(async()=>{try{await Ee.initGit(),await m()}catch{i("error")}},[m]),b=t?t.modified.length+t.untracked.length:0,v=((j=t==null?void 0:t.lastCommit)==null?void 0:j.date)??null;return{state:r,dirtyCount:b,lastSaved:v,status:t,save:p,history:c,loadHistory:d,restore:g,refresh:m,initGit:y}}const E0={cto:["Need to reduce this architecture tech debt...","Don't over-engineer. Keep it minimal.","Performance profiling results are a bit concerning.","Should do a system design review.","If I just strip one abstraction layer, it should work.","Let me check the monitoring dashboard.","Need to go through the code review queue.","It's about time to clean up these module dependencies."],cbo:["Heard the competitor launched a new feature... need to analyze.","Should compile this month's revenue metrics.","It's time to update the market trend report.","Maybe I should benchmark the pricing strategy.","Need to recalculate the ROI.","Let me check the competitor's GitHub star trends.","Thinking about launch timing...","Should re-examine the positioning strategy."],pm:["Is this feature really what users want?","Need to clean up the backlog...","MVP scope keeps expanding.","Analyzing user feedback...","Might need to re-prioritize.","Watch out for scope creep.","Will the roadmap timeline hold...","Should double-check the task dependencies."],engineer:["I want to refactor this code...","Test coverage seems a bit low.","Working code first, perfect code later.","Waiting for PR review...","What could be causing this bug...","Is the build broken?","Need to fix that one type error.","Maybe I should run npm audit."],designer:["This UI flow feels a bit awkward...","Usability first, pretty later.","Need to organize the design system components.","Let me make two quick options and compare.","Should run through the accessibility checklist.","Maybe I should prototype this interaction.","Let me revisit the color palette...","The spacing feels a bit cramped."],qa:['"Works" and "correct" are two different things.',"Organizing edge case scenarios...","Should run the regression test suite.","This part could be converted to automated tests.","Need to go through the pre-release checklist.","Reproducible bug reports are key.","Should run cross-browser tests.","Need to check for performance regressions."],"data-analyst":["Checking the data pipeline status...","Interesting outlier detection pattern.","Need to update the dashboard metrics.","Correlation isn't causation though...","Seems like there is room for SQL query optimization.","It's time for a data quality check."]},N0={cto:["Should I assign more work to the team...","It's time to clean up the architecture debt.","Need to re-examine the tech roadmap.","It's quiet... am I missing something?"],cbo:["It's time to update the market analysis...","Should be preparing the revenue report, but no directives.","Let me check on competitor movements.","It's quiet on the business side..."],pm:["Backlog is pretty quiet... nothing to plan?","It's been a while since we scheduled a sprint.","User feedback must be piling up...","No PRD to write... that's unusual."],engineer:["Nothing to do today... maybe some code reviews.","Task queue is empty. Guess I'll refactor.","Am I missing something?","Should clean up the commit log."],designer:["No design requests coming in. Should I improve something on my own?","Maybe run a UI audit...","Should organize my portfolio.","Let me tidy up the component library."],qa:["No builds to test. Let me improve the automation scripts.","It's quiet... no bugs, or just haven't found them?","Let me review the existing test scenarios.","Should update the test coverage report."],"data-analyst":["No analysis requests coming in...","Maybe I should clean up the data warehouse.","Should verify the past reports."]},XC=[{id:"sup-check-1",relation:"superior-subordinate",minFamiliarity:0,topic:"progress",turns:[{speaker:"A",text:"How's the progress?"},{speaker:"B",text:"Going well. Should be done soon."},{speaker:"A",text:"Good, let me know when it's done."}]},{id:"sup-check-2",relation:"superior-subordinate",minFamiliarity:20,topic:"progress",turns:[{speaker:"A",text:"What are you working on today?"},{speaker:"B",text:"Finishing up what I was doing yesterday."}]},{id:"sub-report-1",relation:"superior-subordinate",minFamiliarity:10,topic:"report",turns:[{speaker:"B",text:"Done with that task from earlier."},{speaker:"A",text:"Nice work. Can you share the results?"},{speaker:"B",text:"Sure, I've updated the docs."}]},{id:"peer-tech-1",relation:"peer",minFamiliarity:20,topic:"tech",turns:[{speaker:"A",text:"What do you think about this design?"},{speaker:"B",text:"I think we could go simpler."},{speaker:"A",text:"Really? Want to look at it together?"}]},{id:"peer-tech-2",relation:"peer",minFamiliarity:30,topic:"tech",turns:[{speaker:"A",text:"Have you used this library before?"},{speaker:"B",text:"Yeah, used it in the last project. It was decent."}]},{id:"close-feedback-1",relation:"peer",minFamiliarity:60,topic:"feedback",turns:[{speaker:"A",text:"Can I be honest with you?"},{speaker:"B",text:"Of course, go ahead."},{speaker:"A",text:"This one feels a bit off. Let's revisit."},{speaker:"B",text:"...Alright. Thanks for the feedback."}]},{id:"clevel-sync-1",relation:"c-level",minFamiliarity:10,topic:"strategy",turns:[{speaker:"A",text:"We need to sync the roadmap with the business timeline."},{speaker:"B",text:"Agreed. I'll have it organized and shared by tomorrow."}]},{id:"clevel-sync-2",relation:"c-level",minFamiliarity:30,topic:"strategy",turns:[{speaker:"A",text:"I have some competitor intel to share."},{speaker:"B",text:"Great, I have a tech update too."},{speaker:"A",text:"Let's sync up when you're free."}]},{id:"casual-coffee",relation:"any",minFamiliarity:30,topic:"casual",turns:[{speaker:"A",text:"Want to grab a coffee?"},{speaker:"B",text:"Sure. Feels like it's going to be a long day."}]},{id:"casual-overtime",relation:"any",minFamiliarity:25,topic:"casual",turns:[{speaker:"A",text:"Working late again..."},{speaker:"B",text:"We're in this together. Hang in there."}]},{id:"casual-lunch",relation:"any",minFamiliarity:35,topic:"casual",turns:[{speaker:"A",text:"What should we get for lunch?"},{speaker:"B",text:"Anything. Feel like we eat the same thing every day."}]},{id:"casual-weekend",relation:"any",minFamiliarity:40,topic:"casual",turns:[{speaker:"A",text:"What did you do this weekend?"},{speaker:"B",text:"Just rested. Was too tired."}]},{id:"bestie-1",relation:"any",minFamiliarity:80,topic:"trust",turns:[{speaker:"A",text:"I'm a bit unsure about this direction..."},{speaker:"B",text:"What's bothering you? Be honest."},{speaker:"A",text:"Thanks. It's nice having someone I can talk to."}]}],VC=18e3,A0=6e3,GC=2500,KC=30*6e4,kg="tycono:relationships";function QC(){try{const t=localStorage.getItem(kg);return t?JSON.parse(t):[]}catch{return[]}}function WC(t){localStorage.setItem(kg,JSON.stringify(t))}function ac(t,l,r){const[i,c]=l<r?[l,r]:[r,l];let u=t.find(f=>f.roleA===i&&f.roleB===c);return u||(u={roleA:i,roleB:c,dispatches:0,wavesTogether:0,conversations:0,familiarity:0,lastInteraction:new Date().toISOString()},t.push(u)),u}function ic(t){return Math.min(100,t.dispatches*5+t.wavesTogether*10+t.conversations*2)}function sc(t){return t[Math.floor(Math.random()*t.length)]}function ZC(t,l,r){const i=r.find(m=>m.id===t),c=r.find(m=>m.id===l);if(!i||!c)return null;const u=i.level==="c-level",f=c.level==="c-level";return u&&f?"c-level":i.reportsTo===l||c.reportsTo===t?"superior-subordinate":(i.reportsTo===c.reportsTo,"peer")}function JC(t,l){return t.relation==="any"?!0:t.relation===l}function PC({roles:t,roleStatuses:l,activeExecs:r,getStandupSpeech:i}){const[c,u]=k.useState(new Map),[f,m]=k.useState(QC),p=k.useRef({}),d=k.useRef(null),g=k.useRef(t),y=k.useRef(l),b=k.useRef(r),v=k.useRef(i),j=k.useRef(f);g.current=t,y.current=l,b.current=r,v.current=i,j.current=f,k.useEffect(()=>{const O=Date.now();for(const[B,T]of Object.entries(l))T==="working"&&(p.current[B]=O)},[l]),k.useEffect(()=>{WC(f)},[f]);const S=k.useCallback(O=>{const B=y.current[O],T=b.current.find($=>$.roleId===O);if(B==="working"&&(T!=null&&T.task))return null;const I=v.current(O);if(I&&Math.random()<.3)return{text:I,type:"work",ts:Date.now()};const X=Date.now(),ee=p.current[O]??0;if(X-ee>KC&&Math.random()<.5){const $=N0[O]??N0.engineer;return{text:sc($),type:"guilt",ts:X}}const z=E0[O]??E0.engineer;return{text:sc(z),type:"personality",ts:X}},[]),C=k.useCallback(O=>{if(d.current)return!1;const B=O.filter(Q=>y.current[Q.id]!=="working");if(B.length<2)return!1;const T=[...B].sort(()=>Math.random()-.5),I=T[0],X=T[1],ee=ZC(I.id,X.id,O);if(!ee)return!1;const z=ac(j.current,I.id,X.id),$=ic(z),U=XC.filter(Q=>JC(Q,ee)&&$>=Q.minFamiliarity);if(U.length===0)return!1;const ne=sc(U);let re=I.id,V=X.id;ne.relation==="superior-subordinate"&&(X.reportsTo===I.id||I.level==="c-level"?(re=I.id,V=X.id):(re=X.id,V=I.id)),d.current={templateId:ne.id,roleA:re,roleB:V,turnIdx:0,timer:null};const Y=Q=>{if(!d.current||Q>=ne.turns.length){d.current=null,m(_=>{const J=[..._],D=ac(J,re,V);return D.conversations++,D.familiarity=ic(D),D.lastInteraction=new Date().toISOString(),J}),setTimeout(()=>{u(_=>{const J=new Map(_);return J.delete(re),J.delete(V),J})},A0);return}const se=ne.turns[Q],ve=se.speaker==="A"?re:V,M=se.speaker==="A"?V:re;u(_=>{const J=new Map(_);if(J.set(ve,{text:se.text,type:"social",partnerId:M,ts:Date.now()}),Q>0){const D=ne.turns[Q-1].speaker==="A"?re:V;D!==ve&&J.delete(D)}return J}),d.current.turnIdx=Q,d.current.timer=setTimeout(()=>Y(Q+1),GC)};return Y(0),!0},[]);k.useEffect(()=>{const O=setInterval(()=>{const B=g.current;if(B.length===0||d.current||Math.random()<.35&&C(B))return;const T=B.filter(ee=>y.current[ee.id]!=="working");if(T.length===0)return;const I=sc(T),X=S(I.id);X&&(u(ee=>{const z=new Map(ee);return z.set(I.id,X),z}),setTimeout(()=>{u(ee=>{const z=new Map(ee),$=z.get(I.id);return $&&$.ts===X.ts&&z.delete(I.id),z})},A0))},VC);return()=>{var B;clearInterval(O),(B=d.current)!=null&&B.timer&&clearTimeout(d.current.timer)}},[S,C]);const E=k.useCallback(O=>{const B=c.get(O);return(B==null?void 0:B.text)??""},[c]),A=k.useCallback((O,B)=>{m(T=>{const I=[...T],X=ac(I,O,B);return X.dispatches++,X.familiarity=ic(X),X.lastInteraction=new Date().toISOString(),I})},[]),R=k.useCallback(O=>{O.length<2||m(B=>{const T=[...B];for(let I=0;I<O.length;I++)for(let X=I+1;X<O.length;X++){const ee=ac(T,O[I],O[X]);ee.wavesTogether++,ee.familiarity=ic(ee),ee.lastInteraction=new Date().toISOString()}return T})},[]);return{speeches:c,getSpeech:E,relationships:f,notifyDispatch:A,notifyWave:R}}const Sg="tycono:office-chat";let eE=0;function tE(){return`chat-${Date.now()}-${++eE}`}function Dd(){return[{id:"general",name:"#general",members:[],isDefault:!0,messages:[],topic:"Company-wide announcements and general discussion"},{id:"watercooler",name:"#watercooler",members:[],isDefault:!0,messages:[],topic:"No managers allowed. Vent, gossip, joke around. Talk freely about work frustrations, complain about directives you disagree with, share hot takes."}]}function nE(){try{const t=localStorage.getItem(Sg);if(t){const l=JSON.parse(t);if(l.find(i=>i.id==="office")&&!l.find(i=>i.id==="general")){const i=l.filter(c=>c.id!=="office");return[...Dd(),...i]}const r=Dd();for(const i of r)l.find(c=>c.id===i.id)||l.unshift(i);return l}}catch{}return Dd()}function lE(t){const l=t.map(r=>({...r,messages:r.messages.slice(-200)}));localStorage.setItem(Sg,JSON.stringify(l))}function rE(){const[t,l]=k.useState(nE),[r,i]=k.useState(null),[c,u]=k.useState(new Set);k.useEffect(()=>{lE(t)},[t]);const f=k.useCallback(v=>{i(v),v&&u(j=>{const S=new Set(j);return S.delete(v),S})},[]),m=k.useCallback(v=>{const j={...v,id:tE()};l(S=>{const C=S.map(E=>E.id==="general"?v.type==="dispatch"?{...E,messages:[...E.messages,j].slice(-200)}:E:v.channelId?E.id===v.channelId?{...E,messages:[...E.messages,j].slice(-200)}:E:E.members.length>0&&E.members.includes(v.roleId)?{...E,messages:[...E.messages,j].slice(-200)}:E);return u(E=>{const A=new Set(E);for(const R of C){const O=S.find(B=>B.id===R.id);O&&R.messages.length>O.messages.length&&A.add(R.id)}return A}),C})},[]),p=k.useCallback((v,j,S)=>{const C=`ch-${Date.now()}`,E={id:C,name:v.startsWith("#")?v:`#${v}`,members:j,isDefault:!1,messages:[],topic:S};l(A=>[...A,E]),i(C)},[]),d=k.useCallback(v=>{l(j=>j.filter(S=>S.id!==v||S.isDefault)),i(j=>j===v?"general":j)},[]),g=k.useCallback((v,j)=>{l(S=>S.map(C=>C.id===v&&!C.isDefault?{...C,members:j}:C))},[]),y=k.useCallback((v,j)=>{l(S=>S.map(C=>C.id===v&&!C.isDefault?{...C,topic:j||void 0}:C))},[]),b=k.useCallback(v=>{l(j=>j.map(S=>{if(S.id==="watercooler"){const C=v.filter(E=>E.level!=="c-level").map(E=>E.id);if(S.members.length!==C.length||!C.every(E=>S.members.includes(E)))return{...S,members:C}}return S}))},[]);return{channels:t,activeChannelId:r,setActiveChannelId:f,pushMessage:m,createChannel:p,deleteChannel:d,updateMembers:g,updateTopic:y,unreadChannels:c,syncDefaultMembers:b}}const aE=45e3,iE=3e3,sE=3,oE=20;function cE({roles:t,roleStatuses:l,activeExecs:r,channels:i,relationships:c,pushMessage:u,speechSettings:f,engineType:m,hasApiKey:p}){const g=((f==null?void 0:f.mode)==="auto"?m==="claude-cli"||m==="local"?"llm":"template":(f==null?void 0:f.mode)??"template")==="llm"&&(p!==!1||m==="claude-cli"),y=((f==null?void 0:f.intervalSec)??aE/1e3)*1e3,b=k.useRef(t),v=k.useRef(l),j=k.useRef(r),S=k.useRef(i),C=k.useRef(c),E=k.useRef(u),A=k.useRef(0),R=k.useRef(!1);b.current=t,v.current=l,j.current=r,S.current=i,C.current=c,E.current=u;const O=k.useCallback(async(T,I)=>{if(R.current)return!1;R.current=!0;try{if(!b.current.find(V=>V.id===T))return!1;const ee=I.messages.slice(-oE).map(V=>({roleId:V.roleId,text:V.text,ts:V.ts})),z=b.current.filter(V=>I.members.includes(V.id)),$=C.current.filter(V=>V.roleA===T||V.roleB===T).map(V=>({partnerId:V.roleA===T?V.roleB:V.roleA,familiarity:V.familiarity})),U=j.current.find(V=>V.roleId===T),ne=U?{currentTask:U.task,taskProgress:null}:{currentTask:null,taskProgress:null},re=await Ee.chatInChannel({channelId:I.name.replace("#",""),channelTopic:I.topic,roleId:T,history:ee,members:z.map(V=>({id:V.id,name:V.name,level:V.level})),relationships:$,workContext:ne});return re.message?(E.current({ts:Date.now(),roleId:T,text:re.message,type:"chat",channelId:I.id}),!0):!1}catch{return!1}finally{R.current=!1}},[]),B=k.useCallback(async(T,I)=>{if(A.current>=sE){A.current=0;return}const X=T.members.filter(z=>z!==I&&v.current[z]!=="working");if(X.length===0){A.current=0;return}const ee=X[Math.floor(Math.random()*X.length)];if(Math.random()>.6){A.current=0;return}setTimeout(async()=>{A.current++;const z=S.current.find(U=>U.id===T.id);if(!z)return;await O(ee,z)?B(z,ee):A.current=0},iE+Math.random()*2e3)},[O]);k.useEffect(()=>{if(!g)return;const T=setInterval(async()=>{const I=b.current;if(I.length===0||R.current)return;const X=I.filter(ne=>v.current[ne.id]!=="working");if(X.length===0)return;const ee=X[Math.floor(Math.random()*X.length)],z=S.current.filter(ne=>ne.members.length===0?!0:ne.members.includes(ee.id));if(z.length===0)return;const $=z[Math.floor(Math.random()*z.length)];A.current=0,await O(ee.id,$)&&B($,ee.id)},y);return()=>clearInterval(T)},[g,y,O,B])}function oc({type:t,className:l}){const r=k.useRef(null),i=AS(t);return k.useEffect(()=>{const c=r.current;if(!c||!i)return;const u=c.getContext("2d");u&&TS(u,i)},[t,i]),i?o.jsx("canvas",{ref:r,width:i.canvasWidth,height:i.canvasHeight,className:l,style:{imageRendering:"pixelated",display:"block"}}):null}const jg=[[1,8],[3,5],[8,1],[5,3]],uE=[[1,4],[2,3],[4,1],[3,2]];function cc(t){const l=t===1||t===3?-1:0,r=jg[t],i=t<2?[0,1]:[1,0],c=l;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:r[0],y:13,w:3,h:4,c:"$pants"},{x:r[1],y:13,w:3,h:4,c:"$pants"},{x:r[0]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:r[1]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:r[0],y:16,w:3,h:2,c:"$shoes"},{x:r[1],y:16,w:3,h:2,c:"$shoes"},{x:r[0],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:r[1],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:1,y:c+8,w:10,h:6,c:"$shirt"},{x:2,y:c+8,w:8,h:1,c:"lighten($shirt, 20)",a:.35},{x:1,y:c+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:10,y:c+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:-1,y:c+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:c+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:-1,y:c+12,w:2,h:1,c:"$skin"},{x:11,y:c+12,w:2,h:1,c:"$skin"},{x:4,y:c+6,w:4,h:3,c:"$skin"},{x:1,y:c+0,w:10,h:7,c:"$skin"},{x:3,y:c+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:c+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:c+3,w:1,h:1,c:"#FFF",a:.4},{x:7,y:c+3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:c+6,w:2,h:1,c:"darken($skin, 25)",a:.35},{x:0,y:c+3,w:1,h:1,c:"$skin"},{x:11,y:c+3,w:1,h:1,c:"$skin"},{x:1,y:c+0,w:10,h:3,c:"$hair"},{x:0,y:c+1,w:2,h:3,c:"$hair"},{x:10,y:c+1,w:2,h:3,c:"$hair"},{x:2,y:c+0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]}function uc(t){const l=t===1||t===3?-1:0,r=jg[t],i=t<2?[0,1]:[1,0],c=l;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:r[0],y:13,w:3,h:4,c:"$pants"},{x:r[1],y:13,w:3,h:4,c:"$pants"},{x:r[0],y:16,w:3,h:2,c:"$shoes"},{x:r[1],y:16,w:3,h:2,c:"$shoes"},{x:1,y:c+8,w:10,h:6,c:"$shirt"},{x:2,y:c+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:5,y:c+10,w:2,h:3,c:"darken($shirt, 30)",a:.12},{x:-1,y:c+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:c+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:4,y:c+6,w:4,h:3,c:"$skin"},{x:1,y:c+0,w:10,h:7,c:"$skin"},{x:1,y:c+0,w:10,h:6,c:"$hair"},{x:0,y:c+1,w:2,h:5,c:"$hair"},{x:10,y:c+1,w:2,h:5,c:"$hair"},{x:2,y:c+0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:0,y:c+4,w:1,h:1,c:"$skin",a:.6},{x:11,y:c+4,w:1,h:1,c:"$skin",a:.6}]}function _r(t,l){const r=t===1||t===3?-1:0,i=uE[t],c=r,u=t%2===0?1:0;return l?[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:c+8,w:8,h:6,c:"$shirt"},{x:2,y:c+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:8,y:c+9+u,w:3,h:4-u,c:"$shirt"},{x:9,y:c+12,w:2,h:1,c:"$skin"},{x:4,y:c+6,w:4,h:3,c:"$skin"},{x:2,y:c+0,w:8,h:7,c:"$skin"},{x:7,y:c+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:c+3,w:1,h:1,c:"#FFF",a:.3},{x:9,y:c+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:c+0,w:8,h:3,c:"$hair"},{x:1,y:c+1,w:2,h:4,c:"$hair"},{x:9,y:c+1,w:2,h:3,c:"$hair"},{x:3,y:c+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]:[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:c+8,w:8,h:6,c:"$shirt"},{x:2,y:c+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:0,y:c+9+u,w:3,h:4-u,c:"$shirt"},{x:-1,y:c+12,w:2,h:1,c:"$skin"},{x:4,y:c+6,w:4,h:3,c:"$skin"},{x:2,y:c+0,w:8,h:7,c:"$skin"},{x:3,y:c+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:c+3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:c+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:c+0,w:8,h:3,c:"$hair"},{x:1,y:c+1,w:2,h:3,c:"$hair"},{x:9,y:c+1,w:2,h:4,c:"$hair"},{x:3,y:c+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]}const D0={down:[cc(0),cc(1),cc(2),cc(3)],up:[uc(0),uc(1),uc(2),uc(3)],right:[_r(0,!0),_r(1,!0),_r(2,!0),_r(3,!0)],left:[_r(0,!1),_r(1,!1),_r(2,!1),_r(3,!1)]},Ye=4,Nt=28,rn=2,ot=4,Ze=4,nr=[{wallColor:"#C8B898",baseboardColor:"#6A5840",floorType:"wood"},{wallColor:"#A8B8C8",baseboardColor:"#586878",floorType:"dark"},{wallColor:"#A8C8B0",baseboardColor:"#4A6A50",floorType:"carpet"},{wallColor:"#C8C0A8",baseboardColor:"#7A6A50",floorType:"tile"}];function Nh(t,l,r){const u=t.fy+Math.max(10,Math.floor(t.fh*.18)),f=Math.min(l,r),m=Math.ceil(l/f),p=[],d=f*28,g=t.fx+Math.max(8,Math.floor((t.fw-d)/2));for(let y=0;y<m&&p.length<l;y++){const b=Math.min(f,l-y*f);for(let v=0;v<b;v++)p.push({dx:g+v*28,dy:u+y*28,room:t.id})}return p}function fE(t){const i=nr[0],c={id:"main",wx:Ye+Ze,wy:Ye,ww:160-2*(Ye+Ze),wh:Nt,fx:Ye+Ze,fy:Ye+Nt+rn,fw:160-2*(Ye+Ze),fh:120-Ye-Nt-rn-Ye,...i},u=Nh(c,Math.min(t,6),3),f=[{id:"s-window-l",type:"window",room:"main",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"s-window-r",type:"window",room:"main",zone:"wall",anchorX:"right",offsetX:-26,offsetY:6,windowW:16,windowH:14},{id:"s-clock",type:"clock",room:"main",zone:"wall",offsetX:Math.floor((160-2*(Ye+Ze))/2),offsetY:10}],m=[{id:"s-plant-l",type:"plant",room:"main",zone:"floor",offsetX:4,offsetY:4},{id:"s-plant-r",type:"plant",room:"main",zone:"floor",anchorX:"right",offsetX:-8,offsetY:4}];return{preset:"S",canvasW:160,canvasH:120,rooms:{main:c},desks:u,doors:{},adjacency:{main:[]},corridorY:{main:c.fy+c.fh-12},waypoints:{main:[{x:c.fx+10,y:c.fy+c.fh-14},{x:c.fx+c.fw/2,y:c.fy+c.fh-14},{x:c.fx+c.fw-10,y:c.fy+c.fh-14}]},wallDecorations:f,furniture:m}}function dE(t){const c={id:"exec",wx:Ye+Ze,wy:Ye,ww:144-Ye-Ze-ot/2,wh:Nt,fx:Ye+Ze,fy:Ye+Nt+rn,fw:144-Ye-Ze-ot/2,fh:66,...nr[0]},u={id:"work",wx:144+ot/2+Ze,wy:Ye,ww:144-ot/2-Ze-Ye,wh:Nt,fx:144+ot/2+Ze,fy:Ye+Nt+rn,fw:144-ot/2-Ze-Ye,fh:66,...nr[1]},f={id:"meet",wx:Ye+Ze,wy:Ye+Nt+rn+66+ot,ww:144-Ye-Ze-ot/2,wh:Nt,fx:Ye+Ze,fy:Ye+Nt+rn+66+ot+Nt+rn,fw:144-Ye-Ze-ot/2,fh:70,...nr[2]},m={id:"comm",wx:144+ot/2+Ze,wy:Ye+Nt+rn+66+ot,ww:144-ot/2-Ze-Ye,wh:Nt,fx:144+ot/2+Ze,fy:Ye+Nt+rn+66+ot+Nt+rn,fw:144-ot/2-Ze-Ye,fh:70,...nr[3]},p={exec:c,work:u,meet:f,comm:m},d=[];let g=t;const y=[[c,Math.min(3,g)],[u,0]];y[1][1]=Math.min(3,g-y[0][1]);const b=[[f,0],[m,0]];let v=g-y[0][1]-y[1][1];v>0&&(b[0][1]=Math.min(2,v),v-=b[0][1]),v>0&&(b[1][1]=Math.min(2,v));for(const[T,I]of[...y,...b])I>0&&d.push(...Nh(T,I,3));const j=Ye+Nt+rn+66,S=144-ot/2,C={exec_work:{id:"exec_work",type:"v",doorY:Ye+Nt+rn+20+12,xA:S-2,xB:u.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:Ye+Nt+rn+66+ot+Nt+rn+20+12,xA:S-2,xB:m.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:Ye+Ze+40+14,yA:j-2,yB:f.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+ot/2+Ze+40+14,yA:j-2,yB:m.fy+2}},E={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},A={exec:c.fy+52,work:u.fy+48,meet:f.fy+56,comm:m.fy+42},R={exec:[{x:c.fx+6,y:c.fy+52},{x:c.fx+60,y:c.fy+54},{x:c.fx+112,y:c.fy+50},{x:c.fx+50,y:c.fy+52}],work:[{x:u.fx+14,y:u.fy+48},{x:u.fx+44,y:u.fy+48},{x:u.fx+70,y:u.fy+48},{x:u.fx+100,y:u.fy+48}],meet:[{x:f.fx+60,y:f.fy+56},{x:f.fx+30,y:f.fy+54},{x:f.fx+110,y:f.fy+50},{x:f.fx+80,y:f.fy+56}],comm:[{x:m.fx+96,y:m.fy+8},{x:m.fx+60,y:m.fy+42},{x:m.fx+40,y:m.fy+42},{x:m.fx+20,y:m.fy+42}]},O=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0"},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:18},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],B=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(c.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:14,condition:"no-desks",facility:{id:"meeting",label:"MEETING",icon:"🏢",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"📚",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"M",canvasW:288,canvasH:208,rooms:p,desks:d,doors:C,adjacency:E,corridorY:A,waypoints:R,wallDecorations:O,furniture:B}}function hE(t){const f={id:"exec",wx:Ye+Ze,wy:Ye,ww:180-Ye-Ze-ot/2,wh:Nt,fx:Ye+Ze,fy:Ye+Nt+rn,fw:180-Ye-Ze-ot/2,fh:82,...nr[0]},m={id:"work",wx:180+ot/2+Ze,wy:Ye,ww:180-ot/2-Ze-Ye,wh:Nt,fx:180+ot/2+Ze,fy:Ye+Nt+rn,fw:180-ot/2-Ze-Ye,fh:82,...nr[1]},p=Ye+Nt+rn+82,d={id:"meet",wx:Ye+Ze,wy:p+ot,ww:180-Ye-Ze-ot/2,wh:Nt,fx:Ye+Ze,fy:p+ot+Nt+rn,fw:180-Ye-Ze-ot/2,fh:86,...nr[2]},g={id:"comm",wx:180+ot/2+Ze,wy:p+ot,ww:180-ot/2-Ze-Ye,wh:Nt,fx:180+ot/2+Ze,fy:p+ot+Nt+rn,fw:180-ot/2-Ze-Ye,fh:86,...nr[3]},y={exec:f,work:m,meet:d,comm:g},b=[];let v=t;const j=[[f,Math.min(5,v)],[m,0]];j[1][1]=Math.min(5,v-j[0][1]);const S=[[d,0],[g,0]];let C=v-j[0][1]-j[1][1];C>0&&(S[0][1]=Math.min(3,C),C-=S[0][1]),C>0&&(S[1][1]=Math.min(3,C));for(const[X,ee]of[...j,...S])ee>0&&b.push(...Nh(X,ee,4));const E=180-ot/2,A={exec_work:{id:"exec_work",type:"v",doorY:f.fy+82/2,xA:E-2,xB:m.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:d.fy+86/2,xA:E-2,xB:g.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:f.fx+54,yA:p-2,yB:d.fy+2},work_comm:{id:"work_comm",type:"h",doorX:m.fx+54,yA:p-2,yB:g.fy+2}},R={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},O={exec:f.fy+82-12,work:m.fy+82-12,meet:d.fy+86-12,comm:g.fy+86-12},B={exec:[{x:f.fx+10,y:O.exec},{x:f.fx+f.fw/2,y:O.exec},{x:f.fx+f.fw-10,y:O.exec}],work:[{x:m.fx+10,y:O.work},{x:m.fx+m.fw/2,y:O.work},{x:m.fx+m.fw-10,y:O.work}],meet:[{x:d.fx+10,y:O.meet},{x:d.fx+d.fw/2,y:O.meet},{x:d.fx+d.fw-10,y:O.meet}],comm:[{x:g.fx+10,y:O.comm},{x:g.fx+g.fw/2,y:O.comm},{x:g.fx+g.fw-10,y:O.comm}]},T=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0"},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:18},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],I=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(f.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:14,condition:"no-desks",facility:{id:"meeting",label:"MEETING",icon:"🏢",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"📚",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"L",canvasW:360,canvasH:260,rooms:y,desks:b,doors:A,adjacency:R,corridorY:O,waypoints:B,wallDecorations:T,furniture:I}}const mE=2;function Cg(t,l){return l?l==="L"&&t<=12-mE?"M":l==="M"&&t>12?"L":l:t<=12?"M":"L"}function Eg(t,l){switch(l??Cg(t)){case"S":return fE(t);case"M":return dE(t);case"L":return hE(t)}}function T0(t,l){if(!l||Object.keys(l).length===0)return t;const r=i=>i.map(c=>{const u=l[c.id];return u?{...c,offsetX:u.offsetX,offsetY:u.offsetY}:c});return{...t,wallDecorations:r(t.wallDecorations),furniture:r(t.furniture)}}function z0(t,l){if(l)for(const[r,i]of Object.entries(l))t[r]&&(t[r]={...t[r],dx:i.dx,dy:i.dy})}function Td(t,l){if(!l||l.length===0)return t;const r=new Set(l);return{...t,wallDecorations:t.wallDecorations.filter(i=>!r.has(i.id)),furniture:t.furniture.filter(i=>!r.has(i.id))}}function M0(t,l){if(!l||l.length===0)return t;const r=[],i=[];for(const c of l)c.zone==="wall"?r.push(c):i.push(c);return{...t,wallDecorations:[...t.wallDecorations,...r],furniture:[...t.furniture,...i]}}let ws;function xE(t){ws=t}function L(t,l,r,i,c,u){t=Math.round(t),l=Math.round(l),!(u!==void 0&&u<.01)&&(u!==void 0&&u!==1&&(ws.globalAlpha=u),ws.fillStyle=c,ws.fillRect(t,l,r,i),u!==void 0&&u!==1&&(ws.globalAlpha=1))}function Je(t,l,r,i){L(t,l,1,1,r,i)}let yc=1;function fi(t){yc=t}function Nl(){return yc=yc*16807%2147483647,(yc&65535)/65535}function Ng(t){const l=parseInt(t.slice(1,3),16)/255,r=parseInt(t.slice(3,5),16)/255,i=parseInt(t.slice(5,7),16)/255,c=Math.max(l,r,i),u=Math.min(l,r,i);let f=0,m=0;const p=(c+u)/2;if(c!==u){const d=c-u;m=p>.5?d/(2-c-u):d/(c+u),c===l?f=((r-i)/d+(r<i?6:0))/6:c===r?f=((i-l)/d+2)/6:f=((l-r)/d+4)/6}return[f*360,m*100,p*100]}function Ag(t,l,r){t=(t%360+360)%360,l=Math.max(0,Math.min(100,l))/100,r=Math.max(0,Math.min(100,r))/100;const i=l*Math.min(r,1-r),c=f=>{const m=(f+t/30)%12;return r-i*Math.max(-1,Math.min(m-3,9-m,1))},u=f=>Math.round(f*255).toString(16).padStart(2,"0");return"#"+u(c(0))+u(c(8))+u(c(4))}function Al(t,l=1){const[r,i,c]=Ng(t);return Ag(r+15*l,Math.min(100,i+8),c-12*l)}function $t(t,l=1){const[r,i,c]=Ng(t);return Ag(r-10*l,i-3,c+10*l)}const ln={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},El={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},Sl={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},Ir="#100A06";function pE(t,l,r=14,i=12){L(t,l,r,i,"#4A3828"),L(t+1,l+1,r-2,i-2,"#5A4838"),L(t+2,l+2,r-4,i-4,"#4A7098"),L(t+2,l+2,r-4,Math.floor((i-4)/2),"#6A90B8",.35);const c=Math.floor(r/2);L(t+c,l+1,1,i-2,"#4A3828"),L(t+1,l+Math.floor(i/2),r-2,1,"#4A3828",.5),Je(t+3,l+3,"#8AB8E8",.35),Je(t+c+2,l+3,"#8AB8E8",.25),L(t-1,l+i,r+2,2,"#5A4838"),L(t-1,l+i,r+2,1,$t("#5A4838",.5),.35)}function yE(t,l,r){L(t,l,10,8,"#3A2818"),L(t+1,l+1,8,6,r),L(t+2,l+2,4,3,$t(r,1.2),.3),Je(t+3,l+2,$t(r,2),.25)}function gE(t,l){L(t,l,7,7,"#3A2818"),L(t+1,l+1,5,5,"#F0EDE5"),Je(t+3,l+1,"#AAA"),Je(t+3,l+5,"#AAA"),Je(t+1,l+3,"#AAA"),Je(t+5,l+3,"#AAA"),Je(t+3,l+3,"#222"),L(t+3,l+1,1,2,"#333"),Je(t+4,l+3,"#D32F2F")}function bE(t,l){L(t,l,26,16,"#586878"),L(t+1,l+1,24,13,"#ECEFF1"),L(t+1,l+1,24,1,"#F5F5F5",.4),L(t+3,l+3,14,1,"#1565C0",.6),L(t+3,l+5,18,1,"#333",.2),L(t+3,l+7,12,1,"#D32F2F",.35),L(t+3,l+9,16,1,"#333",.15),L(t+1,l+14,24,2,"#708898"),L(t+3,l+14,3,1,"#D32F2F"),L(t+7,l+14,3,1,"#1565C0"),L(t+11,l+14,3,1,"#2E7D32")}function vE(t,l){L(t,l,22,16,"#6A5030"),L(t+1,l+1,20,14,"#C4A66A"),fi(88);for(let r=0;r<14;r++)for(let i=0;i<20;i++)Nl()>.5&&Je(t+1+i,l+1+r,Nl()>.5?"#B89858":"#D4B87A",.18);L(t+2,l+2,5,4,"#FFF176"),L(t+8,l+2,5,4,"#90CAF9"),L(t+14,l+3,5,4,"#CE93D8"),L(t+3,l+8,7,4,"#C8E6C9"),L(t+11,l+8,8,4,"#F8BBD0"),Je(t+4,l+2,"#E53935"),Je(t+10,l+2,"#1E88E5"),Je(t+16,l+3,"#FF9800")}function wE(t,l){L(t,l,20,3,"#5A4030"),L(t,l,20,1,$t("#5A4030",.5),.35),L(t,l+2,20,1,Al("#5A4030",.5),.3),L(t+2,l-4,3,4,"#E53935"),L(t+2,l-4,3,1,$t("#E53935",1),.3),L(t+6,l-3,2,3,"#1E88E5"),L(t+9,l-5,4,5,"#43A047"),L(t+14,l-3,3,3,"#FFD54F"),Je(t+15,l-3,"#FFF176",.4)}function kE(t,l){L(t,l,16,12,"#1E1E28"),L(t+1,l+1,14,9,"#0C1420"),L(t+2,l+2,12,1,"#EF4444",.6),Je(t+2,l+4,"#4CAF50"),L(t+4,l+4,7,1,"#8b949e",.4),Je(t+2,l+6,"#FF9800"),L(t+4,l+6,5,1,"#8b949e",.3),Je(t+2,l+8,"#42A5F5"),L(t+4,l+8,8,1,"#8b949e",.25),L(t+7,l+10,2,2,"#1E1E28"),L(t+5,l+11,6,1,"#586878")}function SE(t,l,r){L(t+2,l+20,22,2,Ir,.15),L(t,l,22,20,El.deep),L(t+1,l+1,20,18,El.base),L(t,l,22,1,El.hi,.35),L(t,l,1,20,El.hi,.2);for(const u of[6,12])L(t+1,l+u,20,2,El.sh),L(t+1,l+u,20,1,El.hi,.2);const i=["#E53935","#1E88E5","#43A047","#8E24AA","#FB8C00","#00897B","#5C6BC0"];let c=t+2;for(let u=0;u<5;u++){const f=2+u%2;L(c,l+1,f,5,i[u]),L(c,l+1,f,1,$t(i[u],1),.35),c+=f+1}c=t+2;for(let u=0;u<4;u++)L(c,l+7,4,5,i[u+3]),L(c,l+7,4,1,$t(i[u+3],1),.25),c+=5;L(t+2,l+14,4,4,"#FFD54F"),L(t+8,l+14,7,4,"#90CAF9"),r&&L(t,l-1,22,1,r,.7)}function jE(t,l){L(t+2,l+11,6,2,Ir,.1),L(t+2,l+8,6,4,"#8B5E3C"),L(t+1,l+7,8,2,Al("#A06E48",.3)),L(t+2,l+7,6,1,$t("#A06E48",.5),.4),L(t+1,l+3,3,4,"#2E7D32"),L(t+5,l+2,3,4,"#2E7D32"),L(t+2,l+1,4,4,"#43A047"),L(t+3,l+0,3,3,"#66BB6A"),Je(t+4,l,"#81C784"),Je(t+3,l+1,"#A5D6A7",.4)}function CE(t,l){ha(t+4,l-4,"down"),ha(t+16,l-4,"down"),ha(t+28,l-4,"down"),L(t+3,l+24,34,3,Ir,.15),L(t,l+2,36,18,ln.deep),L(t+1,l+3,34,16,ln.base),L(t+1,l+3,34,1,ln.hi,.35);for(let r=0;r<14;r+=3)L(t+1,l+4+r,34,1,Al(ln.base,.2),.08);L(t,l+20,36,4,ln.deep),L(t+1,l+21,34,2,ln.sh),L(t+6,l+7,10,6,"#1A1A24"),L(t+7,l+8,8,4,"#0C1420"),L(t+8,l+9,4,1,"#2A6898",.4),L(t+20,l+8,6,4,"#F0F0F0"),L(t+15,l+7,3,3,"#ECEFF1"),Je(t+16,l+8,"#795548"),ha(t+4,l+24,"up"),ha(t+16,l+24,"up"),ha(t+28,l+24,"up")}function EE(t,l){L(t+2,l+16,36,3,Ir,.15),L(t,l,36,5,"#5D4037"),L(t+1,l+1,34,3,"#6D4C41"),L(t+1,l+1,34,1,$t("#6D4C41",.5),.3),L(t,l+5,36,8,"#5D4037"),L(t+2,l+6,15,6,"#6D4C41"),L(t+3,l+6,13,1,$t("#6D4C41",.5),.35),L(t+19,l+6,15,6,"#6D4C41"),L(t+20,l+6,13,1,$t("#6D4C41",.5),.35),L(t+17,l+6,2,6,"#5D4037"),L(t,l+13,36,3,Al("#5D4037",1)),L(t-2,l+2,3,12,"#5D4037"),L(t+35,l+2,3,12,"#5D4037"),L(t+4,l+7,6,4,"#FF8A65"),L(t+5,l+7,4,1,$t("#FF8A65",1),.35)}function NE(t,l){L(t+2,l+10,22,2,Ir,.12),L(t,l,22,8,El.deep),L(t+1,l+1,20,6,El.base),L(t+1,l+1,20,1,El.hi,.3),L(t,l+8,22,2,El.sh),L(t+3,l+2,6,4,"#F0F0F0"),L(t+13,l+3,3,3,"#ECEFF1"),Je(t+14,l+4,"#795548")}function AE(t,l){L(t+1,l+14,10,2,Ir,.12),L(t,l,10,14,"#546E7A"),L(t,l,10,1,$t("#546E7A",1),.35),L(t+1,l+1,8,3,"#78909C"),L(t+1,l+5,8,4,"#37474F"),Je(t+2,l+6,"#EF5350"),Je(t+4,l+6,"#66BB6A"),L(t+2,l+11,4,2,"#ECEFF1")}function DE(t,l){L(t+2,l+16,26,3,Ir,.18),L(t,l,26,10,ln.deep),L(t+1,l+1,24,8,ln.base),L(t+1,l+2,24,1,ln.hi,.2),L(t+1,l+4,24,1,Al(ln.base,.2),.1),L(t+1,l+6,24,1,ln.hi,.15),L(t+1,l+1,24,1,ln.hi,.4),L(t+1,l+1,1,8,ln.hi,.2),L(t,l+10,26,5,ln.deep),L(t+1,l+11,24,3,ln.sh),L(t+1,l+10,24,1,Al(ln.base,1.5),.4),L(t+1,l+14,24,1,ln.base,.15),L(t+2,l+12,10,1,ln.deep,.4),L(t+14,l+12,10,1,ln.deep,.4),Je(t+7,l+11,"#C8D0D8",.6),Je(t+19,l+11,"#C8D0D8",.6),L(t+6,l-5,14,7,"#1E1E28"),L(t+7,l-4,12,5,"#0C1420"),L(t+8,l-3,5,1,"#2A6898",.6),L(t+8,l-2,8,1,"#1A3858",.4),L(t+8,l-1,3,1,"#2A6898",.35),Je(t+7,l-4,"#4A98D8",.25),Je(t+12,l+1,"#4CAF50",.4),L(t+12,l+2,2,3,"#586878"),L(t+10,l+4,6,1,"#8898A8"),L(t+6,l+4,12,4,"#222228"),L(t+6,l+4,12,1,"#333338",.4);for(let r=0;r<5;r++)Je(t+7+r*2,l+5,"#444",.6),Je(t+7+r*2,l+6,"#3A3A3E",.4);L(t+20,l+5,3,4,"#333338"),L(t+20,l+5,3,1,"#444448"),L(t+1,l+3,4,4,"#F0EDE8"),L(t+1,l+3,4,1,"#F8F6F2"),Je(t+2,l+5,"#6D4C41")}function ha(t,l,r){L(t+1,l+9,10,2,Ir,.1),Je(t+5,l+9,"#1E1E22"),Je(t+1,l+10,"#1A1A1E"),Je(t+9,l+10,"#1A1A1E"),Je(t+3,l+11,"#1A1A1E"),Je(t+7,l+11,"#1A1A1E"),L(t+1,l+2,8,6,Sl.base),L(t+2,l+3,6,4,Sl.hi,.35),L(t+2,l+3,6,1,$t(Sl.hi,.5),.25),L(t+1,l+7,8,1,Sl.deep),r==="up"?(L(t,l+7,10,3,Sl.deep),L(t+1,l+8,8,1,Sl.sh)):(L(t,l-1,10,3,Sl.deep),L(t+1,l,8,1,Sl.sh)),L(t,l+3,1,4,Sl.sh),L(t+9,l+3,1,4,Sl.sh)}const Dg={bookshelf:(t,l,r)=>SE(t,l,r.accent),plant:(t,l)=>jE(t,l),"meeting-table":(t,l)=>CE(t,l),sofa:(t,l)=>EE(t,l),"coffee-table":(t,l)=>NE(t,l),"coffee-machine":(t,l)=>AE(t,l),window:(t,l,r)=>pE(t,l,r.windowW??16,r.windowH??14),picture:(t,l,r)=>yE(t,l,r.pictureColor??"#1565C0"),clock:(t,l)=>gE(t,l),whiteboard:(t,l)=>bE(t,l),"bulletin-board":(t,l)=>vE(t,l),shelf:(t,l)=>wE(t,l),screen:(t,l)=>kE(t,l)};function oi(t,l){const r=t.zone==="wall"?l.wx:l.fx,i=t.zone==="wall"?l.wy:l.fy;return{x:t.anchorX==="right"?(t.zone==="wall"?l.wx+l.ww:l.fx+l.fw)+t.offsetX:r+t.offsetX,y:i+t.offsetY}}function TE(t){for(const l of t.wallDecorations){const r=t.rooms[l.room];if(!r)continue;const{x:i,y:c}=oi(l,r),u=Dg[l.type];u&&u(i,c,l)}}function zE(t,l,r){for(const i of t.furniture){const c=t.rooms[i.room];if(!c||i.condition==="no-desks"&&r.has(i.room))continue;const{x:u,y:f}=oi(i,c),m=Dg[i.type];m&&l.push({y:f,draw:()=>m(u,f,i)})}}function Or(t){const l=[],r=[...t.wallDecorations,...t.furniture];for(const i of r){if(!i.facility)continue;const c=t.rooms[i.room];if(!c)continue;const{x:u,y:f}=oi(i,c);l.push({id:i.facility.id,label:i.facility.label,icon:i.facility.icon,color:i.facility.color,dx:u,dy:f,pw:i.facility.hitW,ph:i.facility.hitH})}return l}const ME={bookshelf:{w:22,h:20},plant:{w:10,h:12},"meeting-table":{w:36,h:28},sofa:{w:38,h:16},"coffee-table":{w:22,h:10},"coffee-machine":{w:10,h:14},window:{w:16,h:14},picture:{w:10,h:8},clock:{w:7,h:7},whiteboard:{w:26,h:16},"bulletin-board":{w:22,h:16},shelf:{w:20,h:8},screen:{w:16,h:12}};function Pd(t){return ME[t]??{w:16,h:16}}function zd(t,l,r,i){for(let c=t.furniture.length-1;c>=0;c--){const u=t.furniture[c],f=t.rooms[u.room];if(!f||u.condition==="no-desks"&&i.has(u.room))continue;const{x:m,y:p}=oi(u,f),d=Pd(u.type);if(l>=m&&l<=m+d.w&&r>=p&&r<=p+d.h)return u.id}for(let c=t.wallDecorations.length-1;c>=0;c--){const u=t.wallDecorations[c],f=t.rooms[u.room];if(!f)continue;const{x:m,y:p}=oi(u,f),d=Pd(u.type);if(l>=m&&l<=m+d.w&&r>=p&&r<=p+d.h)return u.id}return null}function R0(t,l,r,i,c){const f=[...l.wallDecorations,...l.furniture].find(y=>y.id===r);if(!f||f.condition==="no-desks"&&c.has(f.room))return;const m=l.rooms[f.room];if(!m)return;const{x:p,y:d}=oi(f,m),g=Pd(f.type);t.save(),t.fillStyle=i,t.globalAlpha=.2,t.fillRect(p-1,d-1,g.w+2,g.h+2),t.globalAlpha=.9,t.strokeStyle=i,t.lineWidth=1,t.strokeRect(p-.5,d-.5,g.w+1,g.h+1),t.restore()}function F0(t,l,r,i){t.save(),t.fillStyle=i,t.globalAlpha=.2,t.fillRect(l-1,r-1,28,42),t.globalAlpha=.9,t.strokeStyle=i,t.lineWidth=1,t.strokeRect(l-.5,r-.5,27,41),t.restore()}function _0(t,l,r){for(const[i,c]of Object.entries(t))if(l>=c.dx&&l<=c.dx+26&&r>=c.dy&&r<=c.dy+40)return i;return null}const RE=[{type:"plant",zone:"floor",label:"Plant",icon:"🪴"},{type:"bookshelf",zone:"floor",label:"Bookshelf",icon:"📚"},{type:"sofa",zone:"floor",label:"Sofa",icon:"🛋️"},{type:"coffee-table",zone:"floor",label:"Coffee Table",icon:"☕"},{type:"coffee-machine",zone:"floor",label:"Coffee Machine",icon:"☕"},{type:"meeting-table",zone:"floor",label:"Meeting Table",icon:"🪑"},{type:"window",zone:"wall",label:"Window",icon:"🪟"},{type:"picture",zone:"wall",label:"Picture",icon:"🖼️"},{type:"clock",zone:"wall",label:"Clock",icon:"🕐"},{type:"whiteboard",zone:"wall",label:"Whiteboard",icon:"📋"},{type:"shelf",zone:"wall",label:"Shelf",icon:"📦"},{type:"screen",zone:"wall",label:"Screen",icon:"🖥️"}],fc=16,FE=4,da=4,gc=2,xt=4,Br=4;let Fe=Eg(7);const Dc={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};let ml=Or(Fe);function Tg(t){return{x:t.dx,y:t.dy,w:t.pw,h:t.ph}}function zg(t){return{cx:t.dx+t.pw/2,botY:t.dy+t.ph}}let It={};function _E(t){const l={};for(let r=0;r<t.length&&r<Fe.desks.length;r++)l[t[r]]=Fe.desks[r];return l}let Ft,pa=null,ma=null,tr=!1,xl=null,Gn=null,mn=null,nn=null,li=null,jl=null;function OE(t,l){const{wx:r,wy:i,ww:c,wh:u,wallColor:f,baseboardColor:m}=t,p=Al(f,.5),d=$t(f,.5),g=[];if(l){const y=l.x-r,b=l.w;y>0&&g.push({sx:r,sw:y}),y+b<c&&g.push({sx:l.x+b,sw:c-y-b})}else g.push({sx:r,sw:c});for(const y of g){L(y.sx,i,y.sw,u,f);for(let b=0;b<u;b+=4)L(y.sx,i+b,y.sw,1,d,.08),L(y.sx,i+b+2,y.sw,1,p,.05);fi(Math.round(y.sx*7+i*13));for(let b=0;b<y.sw;b+=3)Nl()>.4&&L(y.sx+b,i,1,u,d,.04);L(y.sx,i,y.sw,2,d,.3),L(y.sx,i,y.sw,1,$t(f,1),.2),L(y.sx,i+u-2,y.sw,2,p,.3),L(y.sx,i+u,y.sw,gc,m),L(y.sx,i+u,y.sw,1,$t(m,.5),.4)}l&&(L(l.x-1,i,1,u+gc,"#4A3828"),L(l.x+l.w,i,1,u+gc,"#4A3828"),L(l.x,i,l.w,1,"#0A0808",.12)),L(t.fx,t.fy,t.fw,3,"#0A0808",.12),L(t.fx,t.fy+3,t.fw,2,"#0A0808",.06)}function BE(t){const l="#504038",r=Al(l,.5),i=$t(l,.5),c=t.wx-Br,u=t.wy,f=t.wh+gc+t.fh;L(c,u,Br,f,l),L(c,u,1,f,i,.3),L(c+Br-1,u,1,f,r,.4);for(let p=0;p<f;p+=6)L(c+1,u+p,Br-2,1,i,.06);const m=t.wx+t.ww;L(m,u,Br,f,l),L(m,u,1,f,i,.2),L(m+Br-1,u,1,f,r,.3)}function Md(t){const{fx:l,fy:r,fw:i,fh:c}=t,u="#B08040",f="#C89848",m="#8A6030",p="#6A4820";L(l,r,i,c,u),fi(42);for(let d=0;d<c;d+=5){const g=Math.floor(d/5)%2*10;for(let y=-10;y<i+10;y+=20){const b=l+y+g,v=Math.max(l,b),j=Math.min(b+19,l+i)-v;if(j<=0)continue;const S=Nl()>.5?f:u;L(v,r+d,j,4,S,.25),L(v,r+d,j,1,f,.3),L(v,r+d+4,j,1,p,.35),b>=l&&b<l+i&&L(b,r+d,1,4,p,.2),L(v,r+d+2,j,1,m,.1)}}L(l,r,i,2,"#0A0808",.08),L(l,r,2,c,"#0A0808",.06)}function O0(t){const{fx:l,fy:r,fw:i,fh:c}=t,u="#1C2A38",f="#101820";fi(99),L(l,r,i,c,u);for(let m=0;m<c;m+=fc)for(let p=0;p<i;p+=fc){const d=Math.min(fc,i-p),g=Math.min(fc,c-m);Nl()>.5&&L(l+p,r+m,d,g,$t(u,.2),.15),L(l+p+2,r+m+2,d-4,g-4,$t(u,.3),.08),L(l+p,r+m,d,1,f,.5),L(l+p,r+m,1,g,f,.5),L(l+p+1,r+m+1,1,g-1,$t(u,.4),.1),Nl()>.85&&Je(l+p+4+Math.floor(Nl()*8),r+m+4+Math.floor(Nl()*8),"#3A6A9A",.08)}}function LE(t){const{fx:l,fy:r,fw:i,fh:c}=t,u="#387848",f="#4A9058",m="#285E38";L(l,r,i,c,u),fi(77);for(let d=0;d<c;d+=2)for(let g=0;g<i;g+=2)Nl()>.5&&Je(l+g,r+d,f,.1),Nl()>.8&&Je(l+g+1,r+d+1,m,.12);const p=5;L(l+p,r+p,i-p*2,1,f,.45),L(l+p,r+c-p-1,i-p*2,1,m,.45),L(l+p,r+p,1,c-p*2,f,.35),L(l+i-p-1,r+p,1,c-p*2,m,.35)}function $E(t){const{fx:l,fy:r,fw:i,fh:c}=t,u="#D8C490",f="#B09060",m="#907848";fi(55);for(let p=0;p<c;p+=8)for(let d=0;d<i;d+=8){const g=Math.min(8,i-d),y=Math.min(8,c-p),b=(d/8+p/8)%2===0?f:u;L(l+d,r+p,g,y,b),L(l+d+1,r+p+1,g-2,1,$t(b,.4),.2),L(l+d+1,r+p+1,1,y-2,$t(b,.4),.15),L(l+d+g-2,r+p+2,1,y-3,Al(b,.4),.15),L(l+d+2,r+p+y-2,g-3,1,Al(b,.4),.15),L(l+d,r+p,g,1,m,.3),L(l+d,r+p,1,y,m,.3)}}function HE(){const{canvasW:t,canvasH:l,rooms:r,doors:i}=Fe,c="#2A1E14",u="#3A2E24";if(L(0,0,t,da,c),L(0,l-da,t,da,c),L(0,0,da,l,c),L(t-da,0,da,l,c),L(0,0,t,1,u,.3),L(0,0,1,l,u,.2),!r.exec||!r.work||!r.meet||!r.comm)return;const f=r.exec,m=r.meet,p=t/2,d=p-xt/2,g=f.fy+f.fh,y=i.exec_work,b=i.meet_comm,v=i.exec_meet,j=i.work_comm,S=24,C=28,E=((y==null?void 0:y.doorY)??f.fy+20)-S/2,A=((v==null?void 0:v.doorX)??da+Br+54)-C/2,R=((j==null?void 0:j.doorX)??p+xt/2+Br+54)-C/2,O=((b==null?void 0:b.doorY)??m.fy+20)-S/2;L(0,g,A,xt,c),L(A+C,g,d-A-C,xt,c),L(d+xt,g,R-d-xt,xt,c),L(R+C,g,t-R-C,xt,c),L(0,g,A,1,u,.3),L(A+C,g,d-A-C,1,u,.3),L(d+xt,g,R-d-xt,1,u,.3),L(R+C,g,t-R-C,1,u,.3),L(d,0,xt,E,c),L(d,E+S,xt,g-E-S,c),L(d,g+xt,xt,O-g-xt,c),L(d,O+S,xt,l-O-S,c),L(d,0,1,E,u,.2),L(d,E+S,1,g-E-S,u,.2),L(d,g+xt,1,O-g-xt,u,.2),L(d,O+S,1,l-O-S,u,.2),L(d,E,xt,S,"#C4A070"),L(d+xt/2,E,xt/2,S,"#3A4858"),L(d,O,xt,S,"#7AA880"),L(d+xt/2,O,xt/2,S,"#C8B890");const B="#4A3828";L(d,E-1,xt,1,B),L(d,E+S,xt,1,B),L(A-1,g,1,xt,B),L(A+C,g,1,xt,B),L(R-1,g,1,xt,B),L(R+C,g,1,xt,B),L(d,O-1,xt,1,B),L(d,O+S,xt,1,B)}const B0=new Map;function UE(t){const l=`${t.hairStyle??""}|${t.outfitStyle??""}|${t.accessory??""}`;let r=B0.get(l);if(!r){const i=Kd("mini-seated:default"),c=ig(i,t);r=c?c.layers.flatMap(u=>u.pixels):[],B0.set(l,r)}return r}function IE(t,l,r){Qd(Ft,UE(r),t,l,r)}function YE(t,l,r,i,c){ha(t+8,l+20,"up"),c||IE(t+8,l+0+i,r),DE(t,l+14)}function qE(t,l,r,i,c){const u=i in D0?i:"down",f=c%4,m=D0[u][f];Qd(Ft,m,t,l,r);const p=f===1||f===3?-1:0;if(r.accessory&&r.accessory!=="none"){const d=FS(r.accessory,u);d&&d.pixels.length>0&&Qd(Ft,d.pixels,t,l+p,r)}Ft.globalAlpha=1}function XE(t){const l={};let r=0;for(const i of t){const c=It[i];c&&(l[i]={state:"sitting",homeX:c.dx+8,homeY:c.dy+34,homeRoom:c.room,x:c.dx+8,y:c.dy+34,path:[],room:c.room,dir:"down",walkFrame:0,walkTimer:0,bobY:0,bobOff:r*17,stateTimer:600+Math.floor(Math.random()*900)},r++)}return l}function Es(t,l,r,i,c){const u=Fe.corridorY[c]??l,f=[];return l<u-4&&f.push({x:t,y:u}),Math.abs(t-r)>4&&f.push({x:r,y:u}),f.push({x:r,y:i}),f}function Rd(t,l,r,i){const c=Fe.adjacency[r];if(!c)return[];const u=c.find(g=>g.room===i);if(!u)return[];const f=Fe.doors[u.door];if(!f)return[];const m=[],p=Fe.corridorY[r]??l,d=Fe.corridorY[i]??l;if(Math.abs(l-p)>4&&m.push({x:t,y:p}),f.type==="v"){const g=u.side==="A"?f.xA:f.xB,y=u.side==="A"?f.xB:f.xA;m.push({x:g,y:p}),m.push({x:g,y:f.doorY}),m.push({x:y,y:f.doorY}),m.push({x:y,y:d})}else{const g=u.side==="A"?f.yA:f.yB,y=u.side==="A"?f.yB:f.yA;m.push({x:f.doorX,y:p}),m.push({x:f.doorX,y:g}),m.push({x:f.doorX,y}),m.push({x:f.doorX,y:d})}return m}function Mg(t,l){const r=Fe.adjacency[t.room];if(!r)return[];if(!r.find(c=>c.room===l)){for(const c of r){const u=Fe.adjacency[c.room];if(u!=null&&u.find(f=>f.room===l)){const f=Rd(t.x,t.y,t.room,c.room),m=f[f.length-1],p=Rd((m==null?void 0:m.x)??t.x,(m==null?void 0:m.y)??t.y,c.room,l);return[...f,...p]}}return[]}return Rd(t.x,t.y,t.room,l)}function VE(t){if(t.room!==t.homeRoom){const l=Mg({...t},t.homeRoom),r=l[l.length-1],i=Es((r==null?void 0:r.x)??t.x,(r==null?void 0:r.y)??t.y,t.homeX,t.homeY,t.homeRoom);return[...l,...i]}return Es(t.x,t.y,t.homeX,t.homeY,t.room)}function GE(t,l){for(const[,r]of Object.entries(t))if(r.stateTimer--,r.state==="sitting"){if(r.bobY=(l+r.bobOff)%60<30?1:0,r.stateTimer<=0){r.state="walking",r.x=r.homeX,r.y=r.homeY,r.room=r.homeRoom;const i=Object.keys(Fe.rooms);if(Math.random()<.25&&i.length>1){const c=i.filter(p=>p!==r.room),u=c[Math.floor(Math.random()*c.length)],f=Mg(r,u),m=Fe.waypoints[u];if(m&&m.length>0){const p=m[Math.floor(Math.random()*m.length)],d=f[f.length-1]??{x:r.x,y:r.y},g=Es(d.x,d.y,p.x,p.y,u);r.path=[...f,...g]}else r.path=f;r.walkTimer=0}else{const c=Fe.waypoints[r.room];if(c&&c.length>0){const u=c[Math.floor(Math.random()*c.length)];r.path=Es(r.x,r.y,u.x,u.y,r.room)}r.walkTimer=0}}}else if(r.state==="walking"||r.state==="returning"){if(r.path.length===0){r.state==="returning"?(r.state="sitting",r.room=r.homeRoom,r.stateTimer=800+Math.floor(Math.random()*1200)):(r.state="idle",r.dir="down",r.stateTimer=180+Math.floor(Math.random()*360));continue}const i=r.path[0],c=i.x-r.x,u=i.y-r.y,f=Math.sqrt(c*c+u*u);if(f<1.5){r.x=i.x,r.y=i.y,r.path.shift();for(const[m,p]of Object.entries(Fe.rooms))if(r.x>=p.fx&&r.x<=p.fx+p.fw&&r.y>=p.fy&&r.y<=p.fy+p.fh){r.room=m;break}}else r.x+=c/f*.2,r.y+=u/f*.2,Math.abs(c)>Math.abs(u)?r.dir=c>0?"right":"left":r.dir=u>0?"down":"up",r.walkTimer++,r.walkFrame=Math.floor(r.walkTimer/12)%4}else if(r.state==="idle"&&r.stateTimer<=0)if(Math.random()<.3){r.state="walking";const i=Fe.waypoints[r.room];if(i&&i.length>0){const c=i[Math.floor(Math.random()*i.length)];r.path=Es(r.x,r.y,c.x,c.y,r.room)}r.walkTimer=0}else r.state="returning",r.path=VE(r),r.walkTimer=0}function KE(t,l,r){const{canvasW:i,canvasH:c,rooms:u}=Fe;Ft.clearRect(0,0,i,c),L(0,0,i,c,"#2A1E14");const f={wood:Md,dark:O0,carpet:LE,tile:$E};for(const y of Object.values(u))(f[y.floorType]??Md)(y);const m=Object.keys(u);if(m.length>=4){const y=u.exec,b=u.meet,{doors:v}=Fe;if(y&&b&&v.exec_meet&&v.work_comm){const S=(v.exec_meet.doorX??0)-14,C=(v.work_comm.doorX??0)-28/2,E=y.fy+y.fh,A=b.fy;Md({fx:S,fy:E,fw:28,fh:A-E}),O0({fx:C,fy:E,fw:28,fh:A-E})}}const p={};if(m.length>=4){const{doors:y}=Fe,b=28,v=y.exec_meet,j=y.work_comm;v!=null&&v.doorX&&(p.meet={x:v.doorX-b/2,w:b}),j!=null&&j.doorX&&(p.comm={x:j.doorX-b/2,w:b})}for(const y of Object.values(u))OE(y,p[y.id]),BE(y);HE(),TE(Fe);const d=[],g=new Set(Object.values(It).map(y=>y.room));zE(Fe,d,g);for(const[y,b]of Object.entries(It)){const v=t[y];if(!v)continue;const j=v.state==="sitting",S=l(y),C=r[y]==="working";d.push({y:b.dy+14,draw:()=>{if(YE(b.dx,b.dy,S,j?v.bobY:0,!j),j&&C){const E=Dc[y]??"#388bfd";L(b.dx+7,b.dy+14-4,12,5,E,.15),Je(b.dx+12,b.dy+14+1,"#4CAF50",.8)}}})}for(const[y,b]of Object.entries(t))if(b.state!=="sitting"){const v=l(y);d.push({y:b.y+14,draw:()=>qE(Math.round(b.x),Math.round(b.y),v,b.dir,b.walkFrame)})}d.sort((y,b)=>y.y-b.y);for(const y of d)y.draw();for(const y of ml){const b=ma===y.id,v=zg(y);if(Ft.save(),Ft.globalAlpha=b?.9:.5,Ft.fillStyle=y.color,Ft.fillRect(v.cx-1,v.botY-2,3,3),b){const j=Tg(y);Ft.globalAlpha=.3,Ft.strokeStyle=y.color,Ft.lineWidth=1,Ft.strokeRect(j.x-1,j.y-1,j.w+2,j.h+2)}Ft.restore()}if(tr){const y=new Set(Object.values(It).map(b=>b.room));if(xl&&xl!==Gn)if(xl.startsWith("desk:")){const b=xl.slice(5),v=It[b];v&&F0(Ft,v.dx,v.dy,"#FBBF24")}else R0(Ft,Fe,xl,"#FBBF24",y);if(Gn)if(Gn.startsWith("desk:")){const b=Gn.slice(5),v=It[b];v&&F0(Ft,v.dx,v.dy,"#3B82F6")}else R0(Ft,Fe,Gn,"#3B82F6",y)}if(pa){const y=It[pa],b=t[pa];y&&b&&(Ft.save(),Ft.globalAlpha=.25,Ft.fillStyle=Dc[pa]??"#fff",b.state==="sitting"?Ft.fillRect(y.dx-1,y.dy+6,28,30):Ft.fillRect(Math.round(b.x)-1,Math.round(b.y)-1,14,24),Ft.restore())}}function QE({roles:t,projects:l,roleStatuses:r,activeExecs:i,onRoleClick:c,onProjectClick:u,onBulletinClick:f,onDecisionsClick:m,onKnowledgeClick:p,getRoleSpeech:d,getAppearance:g,onHireClick:y}){const b=k.useRef(null),v=k.useRef(null),j=k.useRef(null),S=k.useRef({}),C=k.useRef(0),E=k.useRef(FE),[A,R]=k.useState(!1),[O,B]=k.useState(null),[T,I]=k.useState(null),X=k.useRef({}),ee=k.useRef({}),z=k.useRef([]),$=k.useRef([]);k.useEffect(()=>{tr=A},[A]),k.useEffect(()=>{li=O,jl=T},[O,T]),k.useEffect(()=>{Ee.getPreferences().then(oe=>{const K=oe.furnitureOverrides;K&&Object.keys(K).length>0&&(X.current=K,Fe=T0(Fe,K));const fe=oe.deskOverrides;if(fe&&Object.keys(fe).length>0){ee.current=fe,z0(It,fe);for(const[ke,je]of Object.entries(It)){const Te=S.current[ke];Te&&(Te.homeX=je.dx+8,Te.homeY=je.dy+34)}}const Se=oe.removedFurniture;Se&&Se.length>0&&(z.current=Se,Fe=Td(Fe,Se));const te=oe.addedFurniture;te&&te.length>0&&($.current=te,Fe=M0(Fe,te)),ml=Or(Fe)}).catch(()=>{})},[]);const U=k.useRef({roleStatuses:r,activeExecs:i,getRoleSpeech:d,getAppearance:g});U.current={roleStatuses:r,activeExecs:i,getRoleSpeech:d,getAppearance:g};const ne=k.useMemo(()=>t.map(oe=>oe.id),[t]),re=k.useRef(Fe);k.useEffect(()=>{const oe=ne.length,K=Cg(oe,re.current.preset);let fe=Eg(oe,K);z.current.length>0&&(fe=Td(fe,z.current)),$.current.length>0&&(fe=M0(fe,$.current)),Object.keys(X.current).length>0&&(fe=T0(fe,X.current)),Fe=fe,re.current=fe,It=_E(ne),Object.keys(ee.current).length>0&&z0(It,ee.current),ml=Or(fe),S.current=XE(ne);const Se=b.current;Se&&(Se.width=fe.canvasW,Se.height=fe.canvasH),Y()},[ne]);const V=k.useCallback(oe=>{var K,fe;return((fe=(K=U.current).getAppearance)==null?void 0:fe.call(K,oe))??Ch(oe)},[]),Y=k.useCallback(()=>{const oe=v.current,K=b.current;if(!oe||!K)return;const fe=oe.parentElement;if(!fe)return;const Se=fe.clientWidth,te=fe.clientHeight;if(Se===0||te===0)return;const{canvasW:ke,canvasH:je}=Fe;let Te=Math.floor(Math.min(Se/ke,te/je));Te=Math.max(2,Math.min(Te,5)),E.current=Te,K.style.width=ke*Te+"px",K.style.height=je*Te+"px",oe.style.width=ke*Te+"px",oe.style.height=je*Te+"px"},[]);k.useEffect(()=>{var je;const oe=b.current;if(!oe)return;const K=oe.getContext("2d");if(!K)return;Ft=K,xE(K),Y();const fe=new ResizeObserver(()=>Y()),Se=(je=v.current)==null?void 0:je.parentElement;Se&&fe.observe(Se);let te;const ke=()=>{C.current++,GE(S.current,C.current),KE(S.current,V,U.current.roleStatuses),Q(),te=requestAnimationFrame(ke)};return te=requestAnimationFrame(ke),()=>{cancelAnimationFrame(te),fe.disconnect()}},[V,Y]),k.useEffect(()=>{const oe=j.current;if(!oe)return;oe.innerHTML="";for(const fe of ne){const Se=Dc[fe]??"#8b949e",te=document.createElement("div");te.className="td-nametag",te.dataset.role=fe;const ke=document.createElement("span");ke.className="td-dot",ke.style.background=Se,te.appendChild(ke),te.appendChild(document.createTextNode(fe.toUpperCase())),oe.appendChild(te);const je=document.createElement("div");je.className="td-bubble",je.dataset.role=fe,je.dataset.type="bubble",oe.appendChild(je)}const K={meeting:()=>{const fe=l[0];fe?u(fe.id):f()},bulletin:f,decisions:m,knowledge:p};for(const fe of ml){const Se=document.createElement("div");Se.className="td-facility-label",Se.dataset.facility=fe.id,Se.textContent=`${fe.icon} ${fe.label}`,Se.style.borderColor=`${fe.color}44`;const te=K[fe.id];te&&Se.addEventListener("click",te),Se.addEventListener("mouseenter",()=>{ma=fe.id}),Se.addEventListener("mouseleave",()=>{ma=null}),oe.appendChild(Se)}},[ne,l,u,f,m,p]);const Q=k.useCallback(()=>{var je;const oe=j.current;if(!oe)return;const K=E.current,fe=S.current,{getRoleSpeech:Se,roleStatuses:te,activeExecs:ke}=U.current;for(const Te of Object.keys(fe)){const Le=fe[Te],$e=It[Te];if(!$e)continue;let Yt,pt,St;Le.state==="sitting"?(Yt=$e.dx+13,St=$e.dy+2,pt=$e.dy+37):(Yt=Math.round(Le.x)+6,St=Math.round(Le.y)-2,pt=Math.round(Le.y)+18);const Bt=Yt/Fe.canvasW*100,Kt=oe.querySelector(`.td-nametag[data-role="${Te}"]`);if(Kt){Kt.style.left=Bt+"%",Kt.style.top=pt*K+2+"px";const qt=Kt.querySelector(".td-dot");if(qt){const ae=te[Te]==="working";qt.style.background=ae?"#FBBF24":Dc[Te]??"#8b949e",ae?qt.style.animation="td-pulse 1s ease-in-out infinite":qt.style.animation=""}}const vt=oe.querySelector(`.td-bubble[data-role="${Te}"]`);if(vt){const qt=te[Te]==="working",ae=(je=ke.find(qe=>qe.roleId===Te))==null?void 0:je.task,ye=Se(Te),Re=qt&&ae?ae.slice(0,30):ye?ye.slice(0,30):"";Re&&Le.state==="sitting"?(vt.style.display="",vt.style.left=Bt+"%",vt.style.top=(St-5)*K+"px",vt.textContent=Re):vt.style.display="none"}}for(const Te of ml){const Le=oe.querySelector(`.td-facility-label[data-facility="${Te.id}"]`);if(Le){const $e=zg(Te);Le.style.left=$e.cx/Fe.canvasW*100+"%",Le.style.top=$e.botY*K+2+"px",Le.classList.toggle("td-facility-label--hover",ma===Te.id)}}},[]),se=k.useCallback(oe=>{const K=b.current;if(!K)return null;const fe=K.getBoundingClientRect(),Se=E.current,te=(oe.clientX-fe.left)/Se,ke=(oe.clientY-fe.top)/Se,je=S.current;for(const[Te,Le]of Object.entries(It)){if(!je[Te])continue;const $e=je[Te];if($e.state==="sitting"){if(te>=Le.dx&&te<=Le.dx+26&&ke>=Le.dy&&ke<=Le.dy+40)return{type:"role",id:Te}}else if(te>=$e.x-2&&te<=$e.x+14&&ke>=$e.y-2&&ke<=$e.y+20)return{type:"role",id:Te}}for(const Te of ml){const Le=Tg(Te);if(te>=Le.x&&te<=Le.x+Le.w&&ke>=Le.y&&ke<=Le.y+Le.h)return{type:"facility",id:Te.id}}return null},[]),ve=k.useCallback(oe=>{const K=b.current;if(!K)return{mx:0,my:0};const fe=K.getBoundingClientRect(),Se=E.current;return{mx:(oe.clientX-fe.left)/Se,my:(oe.clientY-fe.top)/Se}},[]),M=k.useCallback(oe=>{Ee.updatePreferences(oe).catch(()=>{})},[]),_=k.useCallback(oe=>{const K=[...z.current,oe];z.current=K,Fe=Td(Fe,[oe]),ml=Or(Fe),Gn=null,xl=null,M({removedFurniture:K})},[M]),J=k.useCallback((oe,K)=>{if(!li||!jl)return;let fe=null;for(const[Le,$e]of Object.entries(Fe.rooms)){const Yt=jl==="wall"?$e.wx:$e.fx,pt=jl==="wall"?$e.wy:$e.fy,St=jl==="wall"?$e.ww:$e.fw,Bt=jl==="wall"?$e.wh:$e.fh;if(oe>=Yt&&oe<=Yt+St&&K>=pt&&K<=pt+Bt){fe=Le;break}}if(!fe)return;const Se=Fe.rooms[fe],te=jl==="wall"?Se.wx:Se.fx,ke=jl==="wall"?Se.wy:Se.fy,je={id:`user-${li}-${Date.now()}`,type:li,room:fe,zone:jl,offsetX:Math.round(oe-te),offsetY:Math.round(K-ke)},Te=[...$.current,je];$.current=Te,jl==="wall"?Fe.wallDecorations.push(je):Fe.furniture.push(je),ml=Or(Fe),M({addedFurniture:Te}),B(null),I(null)},[M]),D=k.useCallback(oe=>{const K=b.current;if(tr&&mn){const{mx:Se,my:te}=ve(oe),je=[...Fe.furniture,...Fe.wallDecorations].find($e=>$e.id===mn.defId);if(!je)return;const Te=Se-mn.startMx,Le=te-mn.startMy;je.offsetX=Math.round(mn.origOffX+Te),je.offsetY=Math.round(mn.origOffY+Le),ml=Or(Fe),K&&(K.style.cursor="grabbing");return}if(tr&&nn){const{mx:Se,my:te}=ve(oe),ke=It[nn.roleId];if(!ke)return;ke.dx=Math.round(nn.origDx+(Se-nn.startMx)),ke.dy=Math.round(nn.origDy+(te-nn.startMy));const je=S.current[nn.roleId];je&&(je.homeX=ke.dx+8,je.homeY=ke.dy+34),K&&(K.style.cursor="grabbing");return}if(tr){const{mx:Se,my:te}=ve(oe);if(li){K&&(K.style.cursor="crosshair");return}const ke=new Set(Object.values(It).map(Te=>Te.room)),je=zd(Fe,Se,te,ke);if(je)xl=je;else{const Te=_0(It,Se,te);xl=Te?`desk:${Te}`:null}pa=null,ma=null,K&&(K.style.cursor=xl?"grab":"default");return}const fe=se(oe);pa=(fe==null?void 0:fe.type)==="role"?fe.id:null,ma=(fe==null?void 0:fe.type)==="facility"?fe.id:null,xl=null,K&&(K.style.cursor=fe?"pointer":"default")},[se,ve]),pe=k.useCallback(oe=>{if(!tr)return;const{mx:K,my:fe}=ve(oe);if(li){J(K,fe),oe.preventDefault();return}const Se=new Set(Object.values(It).map(je=>je.room)),te=zd(Fe,K,fe,Se);if(te){const Te=[...Fe.furniture,...Fe.wallDecorations].find(Le=>Le.id===te);Te&&(Gn=te,mn={defId:te,startMx:K,startMy:fe,origOffX:Te.offsetX,origOffY:Te.offsetY},oe.preventDefault());return}const ke=_0(It,K,fe);if(ke){const je=It[ke];Gn=`desk:${ke}`,nn={roleId:ke,startMx:K,startMy:fe,origDx:je.dx,origDy:je.dy},oe.preventDefault();return}Gn=null},[ve,J]),Ce=k.useCallback(oe=>{if(mn){const fe=[...Fe.furniture,...Fe.wallDecorations].find(Se=>Se.id===mn.defId);if(fe){const Se={...X.current,[fe.id]:{offsetX:fe.offsetX,offsetY:fe.offsetY}};X.current=Se,M({furnitureOverrides:Se}),ml=Or(Fe)}mn=null,b.current&&(b.current.style.cursor="grab");return}if(nn){const K=It[nn.roleId];if(K){const fe={...ee.current,[nn.roleId]:{dx:K.dx,dy:K.dy}};ee.current=fe,M({deskOverrides:fe})}nn=null,b.current&&(b.current.style.cursor="grab")}},[M]),Ne=k.useCallback(oe=>{if(!tr)return;oe.preventDefault();const{mx:K,my:fe}=ve(oe),Se=new Set(Object.values(It).map(ke=>ke.room)),te=zd(Fe,K,fe,Se);te&&_(te)},[ve,_]);k.useEffect(()=>{const oe=K=>{!tr||!Gn||(K.key==="Delete"||K.key==="Backspace")&&(Gn.startsWith("desk:")||_(Gn))};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[_]);const He=k.useCallback(()=>{if(mn){const K=[...Fe.furniture,...Fe.wallDecorations].find(fe=>fe.id===mn.defId);K&&(K.offsetX=mn.origOffX,K.offsetY=mn.origOffY,ml=Or(Fe)),mn=null}if(nn){const oe=It[nn.roleId];oe&&(oe.dx=nn.origDx,oe.dy=nn.origDy);const K=S.current[nn.roleId];K&&(K.homeX=oe.dx+8,K.homeY=oe.dy+34),nn=null}pa=null,ma=null,xl=null,b.current&&(b.current.style.cursor="default")},[]),_e=k.useCallback(oe=>{if(tr)return;const K=se(oe);if(K){if(K.type==="role"){c(K.id);return}switch(K.id){case"meeting":{const fe=l[0];fe?u(fe.id):f();break}case"bulletin":f();break;case"decisions":m();break;case"knowledge":p();break}}},[se,c,u,f,m,p]);return o.jsxs("div",{className:`td-scene${A?" td-scene--editing":""}`,children:[o.jsxs("div",{ref:v,className:"td-wrap",children:[o.jsx("canvas",{ref:b,width:Fe.canvasW,height:Fe.canvasH,className:"td-canvas",onClick:_e,onMouseDown:pe,onMouseUp:Ce,onMouseMove:D,onMouseLeave:He,onContextMenu:Ne}),o.jsx("div",{ref:j,className:"td-overlay"})]}),A&&o.jsxs("div",{className:"td-edit-banner",children:[o.jsx("span",{className:"td-edit-banner__icon",children:"✎"})," EDIT MODE — Click DONE when finished"]}),o.jsxs("button",{className:`td-edit-btn${A?" td-edit-btn--active":""}`,onClick:()=>{R(oe=>{const K=!oe;return K||(B(null),I(null)),K}),Gn=null,mn=null,nn=null},title:A?"Exit Edit Mode":"Edit Furniture Layout",children:[o.jsx("span",{className:"td-edit-btn__icon",children:A?"✓":"✎"}),o.jsx("span",{className:"td-edit-btn__label",children:A?"DONE":"EDIT"})]}),A&&o.jsx("div",{className:"td-palette",children:RE.map(oe=>o.jsx("button",{className:`td-palette__item${O===oe.type?" td-palette__item--active":""}`,onClick:()=>{O===oe.type?(B(null),I(null)):(B(oe.type),I(oe.zone))},title:oe.label,children:o.jsx("span",{children:oe.icon})},oe.type))}),y&&o.jsxs("button",{className:"td-hire-btn",onClick:y,title:"Hire New Role",children:[o.jsx("span",{className:"td-hire-btn__icon",children:"+"}),o.jsx("span",{className:"td-hire-btn__label",children:"HIRE"})]})]})}function WE({role:t,appearance:l,onSave:r,onReset:i,onClose:c,theme:u,onThemeChange:f,onUpdateName:m,initialTab:p,speechSettings:d,onSpeechSettingsChange:g,language:y,onLanguageChange:b,roleLevel:v}){var z;const[j,S]=k.useState(p??"character"),[C,E]=k.useState({...l}),[A,R]=k.useState(t.name),[O,B]=k.useState(!1),T=k.useCallback(()=>E(vs(v)),[v]),I=k.useCallback(()=>{const $=Ch(t.id);E({...$}),i()},[t.id,i]),X=k.useCallback(async()=>{r(C);const $=A.trim();if(m&&$&&$!==t.name){B(!0);try{await m(t.id,$)}catch{}B(!1)}c()},[C,r,c,A,t.name,t.id,m]),ee=o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsxs("span",{children:[t.id.toUpperCase()," –"]}),m?o.jsx("input",{value:A,onChange:$=>R($.target.value),disabled:O,className:"customize-name-input",style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:4,color:"inherit",font:"inherit",padding:"2px 6px",flex:1,minWidth:0}}):o.jsx("span",{children:t.name})]});return o.jsx("div",{className:"customize-overlay",onClick:c,children:o.jsxs("div",{className:"customize-modal",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"customize-header",children:[o.jsxs("div",{className:"customize-tabs",children:[o.jsx("button",{className:`customize-tab ${j==="character"?"active":""}`,onClick:()=>S("character"),children:"CHARACTER"}),o.jsx("button",{className:`customize-tab ${j==="office"?"active":""}`,onClick:()=>S("office"),children:"OFFICE THEME"}),o.jsx("button",{className:`customize-tab ${j==="settings"?"active":""}`,onClick:()=>S("settings"),children:"SETTINGS"})]}),o.jsx("button",{className:"customize-close",onClick:c,children:"X"})]}),j==="character"?o.jsx("div",{className:"customize-body",children:o.jsx(bg,{roleId:t.id,appearance:C,onChange:E,onRandomize:T,onReset:I,label:ee,roleLevel:v})}):j==="office"?o.jsx("div",{className:"customize-body",children:o.jsx("div",{className:"customize-themes",children:Object.entries($r).map(([$,U])=>o.jsxs("button",{className:`customize-theme-card ${u===$?"active":""}`,onClick:()=>f($),children:[o.jsxs("div",{className:"customize-theme-preview",style:{background:U.vars["--floor-light"],borderColor:U.vars["--pixel-border"]},children:[o.jsx("div",{style:{background:U.vars["--hud-bg"],height:8,borderBottom:`2px solid ${U.vars["--pixel-border"]}`}}),o.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 p-1",children:[o.jsx("div",{style:{width:10,height:14,background:U.vars["--accent"],borderRadius:1}}),o.jsx("div",{style:{width:10,height:14,background:U.vars["--active-green"],borderRadius:1}}),o.jsx("div",{style:{width:10,height:14,background:U.vars["--idle-amber"],borderRadius:1}})]}),o.jsx("div",{style:{background:U.vars["--hud-bg"],height:6,borderTop:`2px solid ${U.vars["--pixel-border"]}`}})]}),o.jsxs("div",{className:"customize-theme-name",children:[U.icon," ",U.name]})]},$))})}):o.jsx("div",{className:"customize-body",children:o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,padding:"8px 0"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"AMBIENT SPEECH MODE"}),o.jsx("div",{style:{display:"flex",gap:6},children:["template","llm","auto"].map($=>o.jsxs("button",{onClick:()=>g==null?void 0:g({mode:$}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(d==null?void 0:d.mode)===$?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(d==null?void 0:d.mode)===$?"rgba(255,255,255,0.08)":"transparent",color:(d==null?void 0:d.mode)===$?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[o.jsx("div",{style:{fontWeight:600,marginBottom:2},children:$==="template"?"TEMPLATE":$==="llm"?"AI":"AUTO"}),o.jsx("div",{style:{fontSize:9,opacity:.7},children:$==="template"?"Static pool ($0)":$==="llm"?"LLM generated":"Detect engine"})]},$))}),o.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Auto: CLI Max = AI, BYOK = Template"})]}),o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["SPEECH INTERVAL: ",(d==null?void 0:d.intervalSec)??18,"s"]}),o.jsx("input",{type:"range",min:5,max:120,step:5,value:(d==null?void 0:d.intervalSec)??18,onChange:$=>g==null?void 0:g({intervalSec:Number($.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[o.jsx("span",{children:"5s (frequent)"}),o.jsx("span",{children:"120s (rare)"})]})]}),(d==null?void 0:d.mode)!=="template"&&o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",((z=d==null?void 0:d.dailyBudgetUsd)==null?void 0:z.toFixed(2))??"1.00"]}),o.jsx("input",{type:"range",min:0,max:5,step:.25,value:(d==null?void 0:d.dailyBudgetUsd)??1,onChange:$=>g==null?void 0:g({dailyBudgetUsd:Number($.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[o.jsx("span",{children:"$0 (unlimited)"}),o.jsx("span",{children:"$5.00/day"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"LANGUAGE"}),o.jsx("div",{style:{display:"flex",gap:6},children:[{key:"auto",label:"Auto"},{key:"en",label:"English"},{key:"ko",label:"한국어"},{key:"ja",label:"日本語"}].map(({key:$,label:U})=>o.jsx("button",{onClick:()=>b==null?void 0:b($),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(y??"auto")===$?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(y??"auto")===$?"rgba(255,255,255,0.08)":"transparent",color:(y??"auto")===$?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:U},$))}),o.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),j==="character"&&o.jsxs("div",{className:"customize-footer",children:[o.jsx("button",{className:"customize-btn customize-btn--cancel",onClick:c,children:"CANCEL"}),o.jsx("button",{className:"customize-btn customize-btn--save",onClick:X,children:"SAVE"})]})]})})}function L0(t){const l=Date.now()-new Date(t).getTime(),r=Math.floor(l/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function ZE({status:t,history:l,onClose:r,onSave:i,onLoadHistory:c,onRestore:u,saving:f}){const[m,p]=k.useState("save"),[d,g]=k.useState(""),[y,b]=k.useState(null),[v,j]=k.useState(!1),[S,C]=k.useState(null),E=k.useRef(null);k.useEffect(()=>{m==="history"&&c()},[m,c]),k.useEffect(()=>{var T;(T=E.current)==null||T.focus()},[]);const A=[...((t==null?void 0:t.modified)??[]).map(T=>({status:"M",file:T})),...((t==null?void 0:t.untracked)??[]).map(T=>({status:"A",file:T}))],R=async()=>{b(null),C(null);try{const T=await i(d||void 0);C(T),g("")}catch(T){b(T instanceof Error?T.message:"Save failed")}},O=async T=>{if(confirm(`Restore from commit ${T.slice(0,7)}? This creates a new commit with those files.`)){j(!0);try{await u(T),j(!1)}catch(I){b(I instanceof Error?I.message:"Restore failed"),j(!1)}}};k.useEffect(()=>{const T=I=>{I.key==="Escape"&&r()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[r]);const B=T=>{T.key==="Enter"&&(T.metaKey||T.ctrlKey)&&R()};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:r}),o.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] max-h-[80vh] z-[61] overflow-hidden flex flex-col",style:{background:"var(--hud-bg)",border:"3px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",color:"var(--terminal-text)"},onKeyDown:B,children:[o.jsxs("div",{className:"px-5 py-3 flex items-center justify-between shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-lg font-black tracking-tight",children:"SAVE GAME"}),o.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:(t==null?void 0:t.branch)??""})]}),o.jsx("button",{onClick:r,className:"text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] cursor-pointer text-lg",children:"×"})]}),o.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["save","history"].map(T=>o.jsx("button",{onClick:()=>p(T),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:m===T?"var(--hud-bg-alt)":"transparent",color:m===T?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:m===T?"2px solid var(--accent)":"2px solid transparent"},children:T==="save"?"SAVE":"HISTORY"},T))}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[m==="save"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:A.length>0?o.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",A.length," unsaved change",A.length>1?"s":""]}):o.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),A.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"Changed Files"}),o.jsx("div",{className:"text-[11px] max-h-[160px] overflow-y-auto p-2 space-y-0.5",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)"},children:A.map(({status:T,file:I})=>o.jsxs("div",{className:"flex gap-2",children:[o.jsx("span",{style:{color:T==="A"?"var(--active-green)":"var(--idle-amber)",width:"14px"},children:T}),o.jsx("span",{style:{color:"var(--terminal-text-secondary)"},children:I})]},I))})]}),A.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"Save Message"}),o.jsx("input",{ref:E,type:"text",value:d,onChange:T=>g(T.target.value),placeholder:"Optional: describe your progress...",className:"w-full px-3 py-2 text-[12px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}})]}),A.length>0&&o.jsx("div",{className:"flex gap-3",children:o.jsx("button",{onClick:R,disabled:f,className:"flex-1 py-2.5 text-[12px] font-black uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"2px solid var(--accent)"},children:f?"SAVING...":t!=null&&t.hasRemote?"SAVE & PUSH":"SAVE"})}),A.length>0&&t&&!t.hasRemote&&o.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:"Local save only — add a git remote to enable push"}),S&&o.jsxs("div",{className:"text-[11px] p-2",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:["Saved! ",S.filesChanged," file",S.filesChanged>1?"s":""," committed",S.pushed?" & pushed":"",S.pushError?` (push error: ${S.pushError})`:""]}),y&&o.jsx("div",{className:"text-[11px] p-2",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:y}),(t==null?void 0:t.lastCommit)&&o.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:["Last save: ",t.lastCommit.message," (",L0(t.lastCommit.date),")"]})]}),m==="history"&&o.jsxs(o.Fragment,{children:[l.length===0&&o.jsx("div",{className:"text-[11px] text-center py-8",style:{color:"var(--terminal-text-muted)"},children:"No save history"}),o.jsx("div",{className:"space-y-1",children:l.map(T=>o.jsxs("div",{className:"flex items-center justify-between py-2 px-3 group",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--accent)"},children:T.shortSha}),o.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:T.message})]}),o.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:L0(T.date)})]}),o.jsx("button",{onClick:()=>O(T.sha),disabled:v,className:"text-[10px] font-bold px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--idle-amber)"},children:"LOAD"})]},T.sha))})]})]})]})]})}function JE({onClose:t}){const[l,r]=k.useState(null),[i,c]=k.useState(!0),[u,f]=k.useState(null);return k.useEffect(()=>{Ee.getCompanyStats().then(r).catch(m=>f(m.message)).finally(()=>c(!1))},[]),i?o.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading stats..."}):u||!l?o.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u||"Failed to load stats",o.jsx("button",{onClick:t,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]}):o.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[o.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Company Stats"}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:20},children:[o.jsx(dc,{label:"Roles",value:String(l.company.roleCount)}),o.jsx(dc,{label:"Avg Level",value:`Lv.${l.company.avgLevel}`}),o.jsx(dc,{label:"Total Tokens",value:l.company.formattedTokens}),o.jsx(dc,{label:"Total Cost",value:`$${l.company.totalCostUsd.toFixed(2)}`})]}),o.jsx("h4",{style:{margin:"0 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Role Leaderboard"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[l.roles.map((m,p)=>o.jsx(PE,{role:m,rank:p+1},m.roleId)),l.roles.length===0&&o.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"8px 0"},children:"No role activity yet. Assign tasks to start leveling up!"})]}),Object.keys(l.byModel).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h4",{style:{margin:"20px 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Model Usage"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:Object.entries(l.byModel).map(([m,p])=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,fontSize:12},children:[o.jsx("span",{style:{color:"rgba(255,255,255,0.7)"},children:eN(m)}),o.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",p.costUsd.toFixed(2)]})]},m))})]})]})}function dc({label:t,value:l}){return o.jsxs("div",{style:{padding:"12px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[o.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.45)",marginBottom:4},children:t}),o.jsx("div",{style:{fontSize:18,fontWeight:600},children:l})]})}function PE({role:t,rank:l}){const r=["🥇","🥈","🥉"],i=l<=3?r[l-1]:`#${l}`;return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:8},children:[o.jsx("span",{style:{fontSize:14,width:28,textAlign:"center",flexShrink:0},children:i}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:4},children:[o.jsx("span",{style:{fontSize:13,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),o.jsxs("span",{style:{fontSize:12,color:$0(t.level),fontWeight:600,flexShrink:0,marginLeft:8},children:["Lv.",t.level]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("div",{style:{flex:1,height:4,background:"rgba(255,255,255,0.08)",borderRadius:2,overflow:"hidden"},children:o.jsx("div",{style:{width:`${t.progress*100}%`,height:"100%",background:$0(t.level),borderRadius:2,transition:"width 0.3s ease"}})}),o.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",flexShrink:0},children:t.formattedTokens})]})]})]})}function $0(t){return t>=9?"#FFD700":t>=7?"#C0A0FF":t>=5?"#4FC3F7":t>=3?"#81C784":"rgba(255,255,255,0.4)"}function eN(t){return t.includes("opus")?"Opus":t.includes("sonnet")?"Sonnet":t.includes("haiku")?"Haiku":t.split("-").slice(0,2).join(" ")}function tN({onClose:t,onSyncComplete:l}){const[r,i]=k.useState([]),[c,u]=k.useState([]),[f,m]=k.useState(!0),[p,d]=k.useState(null),[g,y]=k.useState(new Set),[b,v]=k.useState(null),[j,S]=k.useState(null),C=k.useCallback(async()=>{m(!0),v(null);try{const{roles:A}=await Ee.getSyncRoles();i(A);const R=A.filter(B=>B.source.sync!=="off");if(R.length===0){u([]),S(null);return}let O=!1;try{const B=await Cs.syncCheck(R.map(I=>({roleId:I.roleId,sourceId:I.source.id,currentVersion:I.source.upstream_version??I.source.forked_at??"0.0.0"})));O=!0,S(!0);const T=[];for(const I of B.updates){if(!I.hasUpdate)continue;const X=R.find(ne=>ne.roleId===I.roleId);if(!X)continue;const{character:ee}=await Cs.syncPull(I.sourceId),z=[];X.persona.trim()!==ee.persona.trim()&&z.push({field:"persona",local:X.persona.slice(0,120)+(X.persona.length>120?"...":""),upstream:ee.persona.slice(0,120)+(ee.persona.length>120?"...":"")});const $=JSON.stringify(X.authority),U=JSON.stringify(ee.authority);$!==U&&z.push({field:"authority",local:`${X.authority.autonomous.length} autonomous, ${X.authority.needsApproval.length} approval`,upstream:`${ee.authority.autonomous.length} autonomous, ${ee.authority.needsApproval.length} approval`}),z.length>0&&T.push({roleId:I.roleId,roleName:X.name,sourceId:I.sourceId,currentVersion:I.currentVersion,latestVersion:I.latestVersion,fields:z})}u(T)}catch{S(!1),u([])}}catch(A){v(A instanceof Error?A.message:"Failed to check for updates")}finally{m(!1)}},[]);k.useEffect(()=>{C()},[C]);const E=async A=>{d(A.roleId);try{const{character:R,version:O}=await Cs.syncPull(A.sourceId);await Ee.applySyncUpdate({roleId:A.roleId,changes:{persona:R.persona,authority:R.authority},upstreamVersion:O}),y(B=>new Set(B).add(A.roleId)),l==null||l()}catch(R){v(R instanceof Error?R.message:"Failed to apply update")}finally{d(null)}};return o.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[o.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Role Sync"}),o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("button",{onClick:C,disabled:f,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:f?"wait":"pointer"},children:f?"Checking...":"Refresh"}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),j===!1&&o.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,180,0,0.1)",borderRadius:6,color:"#FFB74D",fontSize:12,marginBottom:12},children:"Cloud API unreachable. Sync requires connection to api.tycono.ai."}),b&&o.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:b}),o.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[o.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Tracked roles: "}),o.jsx("span",{style:{fontWeight:500},children:r.length}),o.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"·"}),o.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Updates available: "}),o.jsx("span",{style:{fontWeight:500,color:c.length>0?"#4FC3F7":"rgba(255,255,255,0.7)"},children:c.filter(A=>!g.has(A.roleId)).length}),j===!0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"·"}),o.jsx("span",{style:{fontSize:11,color:"#81C784"},children:"Cloud connected"})]})]}),c.length===0&&!f&&o.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:r.length===0?"No roles with source tracking. Hire from the Store to enable sync.":"All roles are up to date!"}),c.map(A=>o.jsxs("div",{style:{marginBottom:12,padding:14,background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:14,fontWeight:500},children:A.roleName}),o.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[A.sourceId," · v",A.currentVersion," → v",A.latestVersion]})]}),g.has(A.roleId)?o.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied ✓"}):o.jsx("button",{onClick:()=>E(A),disabled:p===A.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:p===A.roleId?"wait":"pointer",opacity:p===A.roleId?.6:1},children:p===A.roleId?"Applying...":"Apply Update"})]}),A.fields.map(R=>o.jsxs("div",{style:{marginBottom:6,fontSize:12},children:[o.jsx("div",{style:{color:"rgba(255,255,255,0.5)",marginBottom:2,textTransform:"uppercase",fontSize:10,letterSpacing:.5},children:R.field}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[o.jsxs("div",{style:{padding:"4px 8px",background:"rgba(255,100,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[o.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"LOCAL"}),o.jsx("br",{}),R.local]}),o.jsxs("div",{style:{padding:"4px 8px",background:"rgba(100,255,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[o.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"UPSTREAM"}),o.jsx("br",{}),R.upstream]})]})]},R.field))]},A.roleId)),r.length>0&&o.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Roles hired from the Store are tracked automatically. Set ",o.jsx("code",{style:{background:"rgba(255,255,255,0.06)",padding:"1px 4px",borderRadius:3},children:"sync: off"})," in role.yaml to stop tracking."]})]})}function nN({onClose:t}){const[l,r]=k.useState(null),[i,c]=k.useState(!0),[u,f]=k.useState(null),[m,p]=k.useState(null),d=k.useCallback(async()=>{c(!0),f(null);try{const A=await Ee.getGitStatus();r(A)}catch(A){f(A instanceof Error?A.message:"Failed to load git status")}finally{c(!1)}},[]);k.useEffect(()=>{d()},[d]);const g=async A=>{p(A.path);try{await Ee.deleteWorktree(A.path),await d()}catch(R){f(R instanceof Error?R.message:"Failed to remove worktree")}finally{p(null)}},y=async A=>{p(A);try{await Ee.deleteBranch(A),await d()}catch(R){f(R instanceof Error?R.message:"Failed to delete branch")}finally{p(null)}};if(i&&!l)return o.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading git status..."});if(u&&!l)return o.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,o.jsx("button",{onClick:t,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!l)return null;const b=l.worktrees.filter(A=>A.status==="active"),v=l.worktrees.filter(A=>A.status==="pending-merge"),j=l.worktrees.filter(A=>A.status==="stale");function S(A){const R=A.split("/");if(R.length>1){const O=R[R.length-1],B=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const T of B)if(O.toLowerCase().includes(T))return T}return null}function C(A,R=40){return A.length<=R?A:"..."+A.slice(A.length-R+3)}function E(A){const R=Date.now()-new Date(A).getTime(),O=Math.floor(R/6e4);if(O<1)return"just now";if(O<60)return`${O}m ago`;const B=Math.floor(O/60);return B<24?`${B}h ago`:`${Math.floor(B/24)}d ago`}return o.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[o.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"GIT STATUS"}),o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("button",{onClick:d,disabled:i,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:i?"wait":"pointer"},children:i?"Checking...":"Refresh"}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),u&&o.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),o.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o.jsxs("div",{children:[o.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Branch: "}),o.jsx("span",{style:{fontWeight:500},children:l.currentBranch})]}),o.jsx("div",{children:l.unsavedCount>0&&o.jsxs("span",{style:{color:"#FFB74D",fontSize:12},children:[l.unsavedCount," unsaved"]})})]}),l.lastCommit&&o.jsxs("div",{style:{marginTop:6,fontSize:11,color:"rgba(255,255,255,0.4)"},children:["Last commit: ",l.lastCommit.message.slice(0,60),l.lastCommit.message.length>60?"...":""," · ",E(l.lastCommit.date)]})]}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{label:"Active Worktrees",count:b.length}),b.map(A=>o.jsx(Fd,{wt:A,roleFromBranch:A.roleId||S(A.branch),truncatePath:C,timeAgo:E,removing:m===A.path,onRemove:()=>g(A),statusColor:"#4FC3F7",statusIcon:"📂"},A.path))]}),v.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{label:"Pending Merge",count:v.length}),v.map(A=>o.jsx(Fd,{wt:A,roleFromBranch:A.roleId||S(A.branch),truncatePath:C,timeAgo:E,removing:m===A.path,onRemove:()=>g(A),statusColor:"#FFB74D",statusIcon:"⚠️"},A.path))]}),j.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{label:"Stale",count:j.length}),j.map(A=>o.jsx(Fd,{wt:A,roleFromBranch:A.roleId||S(A.branch),truncatePath:C,timeAgo:E,removing:m===A.path,onRemove:()=>g(A),statusColor:"#ff6b6b",statusIcon:"🔴"},A.path))]}),l.staleBranches.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{label:"Unmerged Branches",count:l.staleBranches.length}),l.staleBranches.map(A=>o.jsxs("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o.jsxs("div",{style:{fontSize:13},children:[o.jsx("span",{style:{color:"rgba(255,255,255,0.5)",marginRight:6},children:"⚠️"}),o.jsx("span",{style:{fontWeight:500},children:A})]}),o.jsx("button",{onClick:()=>y(A),disabled:m===A,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:m===A?"wait":"pointer",opacity:m===A?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:m===A?"...":"DELETE"})]},A))]}),b.length===0&&v.length===0&&j.length===0&&l.staleBranches.length===0&&o.jsxs("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:["✓"," All clean. No active worktrees or stale branches."]}),l.lastMerge&&o.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Last merge: ",o.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:l.lastMerge.branch})," · ",l.lastMerge.roleId," · ",E(l.lastMerge.mergedAt)]})]})}function hc({label:t,count:l}){return o.jsxs("h4",{style:{margin:"16px 0 8px",fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:1},children:[t," (",l,")"]})}function Fd({wt:t,roleFromBranch:l,truncatePath:r,timeAgo:i,removing:c,onRemove:u,statusColor:f,statusIcon:m}){return o.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[o.jsx("span",{style:{marginRight:6},children:m}),t.branch,l&&o.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)",textTransform:"uppercase"},children:l})]}),t.task&&o.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:2},children:['"',t.task.slice(0,50),t.task.length>50?"...":"",'"']}),o.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[r(t.path)," · ",t.filesChanged," file",t.filesChanged!==1?"s":""," changed"," · ",i(t.createdAt)]}),t.conflictFiles&&t.conflictFiles.length>0&&o.jsxs("div",{style:{fontSize:10,color:"#ff6b6b",marginTop:4},children:["⛔"," CONFLICT: ",t.conflictFiles.join(", ")]})]}),o.jsx("button",{onClick:u,disabled:c,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:f,borderRadius:4,padding:"3px 8px",fontSize:10,cursor:c?"wait":"pointer",opacity:c?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:c?"...":"REMOVE"})]})})}const Tc=[0,1e4,5e4,15e4,4e5,1e6,25e5,5e6,1e7,25e6];function Rg(t){let l=1;for(let r=Tc.length-1;r>=0;r--)if(t>=Tc[r]){l=r+1;break}return Math.min(l,10)}function lN(t){const l=Rg(t);if(l>=10)return 1;const r=Tc[l-1],i=Tc[l];return Math.min(1,(t-r)/(i-r))}function H0(t){const l={};for(const[r,i]of Object.entries(t)){const c=i.inputTokens+i.outputTokens;l[r]={level:Rg(c),totalTokens:c,progress:lN(c)}}return l}const rN=[{id:"first-employee",name:"First Employee",icon:"🏆",description:"Hired your first role",check:t=>t.roleCount>=1},{id:"full-team",name:"Full Team",icon:"👥",description:"Hired 5+ roles",check:t=>t.roleCount>=5},{id:"token-10k",name:"Getting Started",icon:"📊",description:"Used 10K tokens total",check:t=>t.totalTokens>=1e4},{id:"token-100k",name:"Power User",icon:"💪",description:"Used 100K tokens total",check:t=>t.totalTokens>=1e5},{id:"token-millionaire",name:"Token Millionaire",icon:"🎖",description:"Used 1M tokens total",check:t=>t.totalTokens>=1e6},{id:"token-mogul",name:"Token Mogul",icon:"💎",description:"Used 10M tokens total",check:t=>t.totalTokens>=1e7},{id:"first-promotion",name:"First Promotion",icon:"⭐",description:"Any role reached Lv.3",check:t=>t.roles.some(l=>l.level>=3)},{id:"senior-staff",name:"Senior Staff",icon:"🌟",description:"Any role reached Lv.5",check:t=>t.roles.some(l=>l.level>=5)},{id:"master-class",name:"Master Class",icon:"👑",description:"Any role reached Lv.10",check:t=>t.roles.some(l=>l.level>=10)},{id:"full-house",name:"Full House",icon:"🏠",description:"All roles Lv.5+",check:t=>t.roleCount>=3&&t.roles.every(l=>l.level>=5)}];function U0(t){return rN.filter(l=>l.check(t))}const aN={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍","data-analyst":"📊"},bc={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},iN={cto:"아키텍처",cbo:"시장 분석",pm:"PRD 작성",engineer:"코딩",designer:"시안 제작",qa:"품질 검증"};function sN(t){let l=0;for(let i=0;i<t.length;i++)l=t.charCodeAt(i)+((l<<5)-l);return`hsl(${(l%360+360)%360}, 50%, 40%)`}function oN({importJob:t,onImportDone:l}){var ja,Ca,Bl,Ll;const[r,i]=k.useState([]),[c,u]=k.useState([]),[f,m]=k.useState([]),[p,d]=k.useState([]),[g,y]=k.useState([]),[b,v]=k.useState([]),[j,S]=k.useState("TYCONO"),[C,E]=k.useState(!0),[A,R]=k.useState(null),[O,B]=k.useState({type:"none"}),[T,I]=k.useState(null),[X,ee]=k.useState(null),[z,$]=k.useState([]),[U,ne]=k.useState(!1),[re,V]=k.useState([]),[Y,Q]=k.useState(0),[se,ve]=k.useState(!1),[M,_]=k.useState({}),[J,D]=k.useState("ceo"),[pe,Ce]=k.useState(null),[Ne,He]=k.useState(!1),[_e,oe]=k.useState({}),K=k.useRef({}),[fe,Se]=k.useState(!1),[te,ke]=k.useState(null),[je,Te]=k.useState({}),[Le,$e]=k.useState([]),[Yt,pt]=k.useState([]),[St,Bt]=k.useState(void 0),[Kt,vt]=k.useState(!1);k.useEffect(()=>{Ee.getStatus().then(F=>{Bt(F.engine),vt(!!F.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:qt,setAppearance:ae,resetAppearance:ye,theme:Re,setTheme:qe,speechSettings:we,setSpeechSettings:Ae,language:bt,setLanguage:rt}=IC(),[de,Pe]=k.useState(null),[dt,dn]=k.useState("character"),et=qC(),[$c,rr]=k.useState(!1),[wa,ar]=k.useState(!1),[zl,ir]=k.useState(!1),[Yr,di]=k.useState(!1),[yn,hi]=k.useState(null);k.useEffect(()=>{const F=ue=>{(ue.metaKey||ue.ctrlKey)&&ue.key==="s"&&(ue.preventDefault(),et.dirtyCount>0&&rr(!0))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[et.dirtyCount]),k.useEffect(()=>{let F=!1;const ue=async()=>{try{const xe=await Ee.getGitStatus();F||hi(xe)}catch{}};ue();const me=setInterval(ue,1e4);return()=>{F=!0,clearInterval(me)}},[]);const[Qn,mi]=k.useState(null),[Ml,Rl]=k.useState(null),[Fl,ka]=k.useState([]),[yl,xi]=k.useState(!1),pi=k.useRef(!1),Wn=k.useRef(null);let Qt=k.useRef(0);const sn=k.useRef(new Set),Sn=(F,ue,me)=>{const xe={id:Qt.current++,type:F,text:ue,detail:me};ka(ge=>[...ge,xe])};k.useEffect(()=>{var F;yl&&((F=Wn.current)==null||F.scrollIntoView({behavior:"smooth"}))},[Fl,yl]),k.useEffect(()=>{t&&(pi.current||(pi.current=!0,Rl("Scanning knowledge sources..."),ka([{id:0,type:"scan",text:"Starting knowledge import..."}]),Qt.current=1,fetch("/api/setup/import-knowledge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:t.paths,companyRoot:t.companyRoot})}).then(async F=>{var ge;const ue=(ge=F.body)==null?void 0:ge.getReader();if(!ue)return;const me=new TextDecoder;let xe="";for(;;){const{done:ze,value:Oe}=await ue.read();if(ze)break;xe+=me.decode(Oe,{stream:!0});const Xe=xe.split(`
|
|
89
|
-
`);xe=Xe.pop()||"";let at="";for(const Ve of Xe)if(Ve.startsWith("event: "))at=Ve.slice(7).trim();else if(Ve.startsWith("data: ")&&at){try{const Lt=JSON.parse(Ve.slice(6));switch(at){case"scanning":Rl(`Scanning: ${Lt.path} (${Lt.fileCount} files)`),Sn("scan",`Found ${Lt.fileCount} files`,Lt.path);break;case"processing":mi({index:Lt.index,total:Lt.total}),Rl(`Importing knowledge... (${Lt.index}/${Lt.total})`),Sn("process",`Processing: ${Lt.file}`,`${Lt.index} / ${Lt.total}`);break;case"created":Sn("created",Lt.title,Lt.summary);break;case"skipped":Sn("process",`Skipped: ${Lt.file}`,Lt.reason);break;case"done":Rl(null),mi(null),Sn("done",`Import complete! ${Lt.created} created, ${Lt.skipped} skipped.`),_t(`Knowledge import complete! ${Lt.created} documents imported.`,"#2E7D32"),l==null||l();break;case"error":Rl(null),mi(null),Sn("error",Lt.message),_t(`Import failed: ${Lt.message}`,"#B71C1C"),l==null||l();break}}catch{}at=""}}}).catch(F=>{Rl(null),Sn("error",F.message),_t(`Import error: ${F.message}`,"#B71C1C"),l==null||l()})))},[t]);const[qr,Bs]=k.useState("card"),[Ls,$s]=k.useState(typeof window<"u"?window.innerWidth:1200);k.useEffect(()=>{const F=()=>$s(window.innerWidth);return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]);const _l=Ls<1024,[jn,On]=k.useState(!1),[Zn,Xr]=k.useState(560),[Bn,ft]=k.useState([]),[Vr,Jn]=k.useState(null),[Ln,gl]=k.useState(null),{sendMessage:Hc}=$C();k.useEffect(()=>{Promise.all([Ee.getCompany().then(F=>{S(F.name),i(F.roles)}),Ee.getProjects().then(u),Ee.getStandups().then(m),Ee.getWaves().then(d),Ee.getDecisions().then(y),Ee.getKnowledge().then(v).catch(()=>{}),Ee.getOrgTree().then(F=>{_(F.nodes),D(F.root)}).catch(()=>{}),Ee.getCostSummary().then(F=>Gr(H0(F.byRole))).catch(()=>{})]).catch(F=>R(`Failed to load: ${F.message}`)).finally(()=>E(!1))},[]),k.useEffect(()=>{Ee.deleteEmptySessions().catch(()=>{}),Ee.getSessions().then(F=>{if(F.length>0){const ue=F.map(xe=>({...xe,messages:[]}));ft(ue);const me=ue.find(xe=>xe.status==="active")??ue[0];Jn(me.id),On(!0)}}).catch(F=>{console.error("Failed to load sessions",F)})},[]),k.useEffect(()=>{const F=()=>{fetch("/api/exec/status").then(me=>me.json()).then(me=>{Te(me.statuses??{}),$e(me.activeExecutions??[])}).catch(()=>{})};F();const ue=setInterval(F,3e3);return()=>clearInterval(ue)},[]);const sr=k.useMemo(()=>{const F={...je};if(Ln){const ue=Bn.find(me=>me.id===Ln);ue&&(F[ue.roleId]="working")}return F},[je,Ln,Bn]);k.useEffect(()=>{O.type==="role"?Ee.getRole(O.roleId).then(I).catch(console.error):I(null)},[O]);const or=()=>B({type:"none"}),Uc=async(F,ue)=>{const me=r.find(ge=>ge.id===F),xe=(X==null?void 0:X.mode)==="ask";ee(null);try{const{jobId:ge}=await Ee.startJob({type:"assign",roleId:F,task:ue,readOnly:xe}),ze=bc[F]??"#666",Oe=`${F.toUpperCase()} · ${(me==null?void 0:me.name)??F}`;ve(!1),$([{jobId:ge,title:Oe,color:ze}]),Xt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(me==null?void 0:me.name)??F}] ${xe?"Ask":"Assign"}: ${ue}`,type:"dispatch",targetRoleId:F})}catch(ge){_t(`Failed to start job: ${ge instanceof Error?ge.message:"unknown"}`,"#C62828")}},_t=(F,ue)=>{const me=Date.now();pt(xe=>[...xe,{id:me,message:F,color:ue}]),setTimeout(()=>pt(xe=>xe.filter(ge=>ge.id!==me)),4e3)},Gr=F=>{var me,xe;const ue=K.current;for(const[ge,ze]of Object.entries(F)){const Oe=((me=ue[ge])==null?void 0:me.level)??0;if(Oe>0&&ze.level>Oe){const Xe=((xe=r.find(at=>at.id===ge))==null?void 0:xe.name)??ge.toUpperCase();_t(`${Xe} leveled up to Lv.${ze.level}!`,"#7C3AED")}}K.current=F,oe(F)};k.useEffect(()=>{const F={roles:Object.entries(_e).map(([xe,ge])=>({id:xe,level:ge.level,totalTokens:ge.totalTokens})),totalTokens:Object.values(_e).reduce((xe,ge)=>xe+ge.totalTokens,0),roleCount:r.length},ue=U0(F),me=sn.current;for(const xe of ue)me.has(xe.id)||me.size>0&&_t(`${xe.icon} Badge earned: ${xe.name}!`,"#D4A017");sn.current=new Set(ue.map(xe=>xe.id))},[_e,r.length]);const ol=()=>{var ue;const F=z[z.length-1];F&&(_t(`${F.title} completed`,F.color),Xt.pushMessage({ts:Date.now(),roleId:((ue=F.title.split(" · ")[0])==null?void 0:ue.toLowerCase())??"unknown",text:`[${F.title}] Job completed`,type:"dispatch"})),Ee.getStandups().then(m).catch(console.error),Ee.getCompany().then(me=>i(me.roles)).catch(console.error),Ee.getCostSummary().then(me=>Gr(H0(me.byRole))).catch(()=>{})},Cn=async F=>{ne(!1);try{const ue=await Ee.startJob({type:"wave",directive:F}),me=ue.jobIds??(ue.jobId?[ue.jobId]:[]),xe=r.filter(ze=>ze.level==="c-level"),ge=me.map((ze,Oe)=>{var Xe,at;return{jobId:ze,roleId:((Xe=xe[Oe])==null?void 0:Xe.id)??`role-${Oe}`,roleName:((at=xe[Oe])==null?void 0:at.name)??`C-Level ${Oe+1}`}});Xt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${F}" → ${ge.map(ze=>ze.roleName).join(", ")}`,type:"dispatch"}),Object.keys(M).length>0?(Ce({directive:F,rootJobs:ge}),He(!1)):(V(ge),Q(0),ve(!1),ge.length>0&&$([{jobId:ge[0].jobId,title:`CEO WAVE · ${ge[0].roleId.toUpperCase()}`,color:"#B71C1C"}]))}catch(ue){_t(`Failed to start wave: ${ue instanceof Error?ue.message:"unknown"}`,"#C62828")}},yi=()=>{Ee.getWaves().then(d).catch(console.error),Ee.getStandups().then(m).catch(console.error)},gi=()=>{Ee.getCompany().then(F=>i(F.roles)).catch(console.error)},bi=async(F,ue)=>{await Ee.createRole(F),ae(F.id,ue),gi(),_t(`${F.name} hired!`,"#2E7D32")},Hs=async F=>{await Ee.deleteRole(F),gi(),ke(null),_t(`${F.toUpperCase()} removed`,"#B71C1C")},Kr=async(F,ue)=>{await Ee.updateRole(F,ue),gi(),ue.name&&_t(`${F.toUpperCase()} renamed to "${ue.name}"`,"#1565C0")},Ic=F=>{On(!0)},En=async F=>{try{const ue=await Ee.createSession(F,"talk");ft(me=>[ue,...me]),Jn(ue.id),On(!0)}catch(ue){console.error("Failed to create session",ue),_t(`Failed to create session: ${ue instanceof Error?ue.message:"API unreachable"}`,"#B71C1C")}},vi=async F=>{try{const ue=await Ee.createSession(F,"talk");ft(me=>[ue,...me]),Jn(ue.id)}catch(ue){console.error("Failed to create session",ue),_t(`Failed to create session: ${ue instanceof Error?ue.message:"API unreachable"}`,"#B71C1C")}},Us=async F=>{const ue=Le.find(ge=>ge.roleId===F),me=(ue==null?void 0:ue.jobId)??(ue==null?void 0:ue.id);if(me&&sr[F]==="working"){const ge=r.find(Xe=>Xe.id===F),ze=bc[F]??"#666",Oe=`${F.toUpperCase()} · ${(ge==null?void 0:ge.name)??F}`;$([{jobId:me,title:Oe,color:ze}]),ve(!1);return}const xe=Bn.find(ge=>ge.roleId===F);if(xe)Jn(xe.id),Xt.setActiveChannelId(null);else try{const ge=await Ee.createSession(F,"talk");ft(ze=>[ge,...ze]),Jn(ge.id),Xt.setActiveChannelId(null)}catch(ge){console.error("Failed to create session",ge)}On(!0)},wi=async F=>{try{await Ee.deleteSession(F),ft(ue=>{var xe;const me=ue.filter(ge=>ge.id!==F);return Vr===F&&Jn(((xe=me[0])==null?void 0:xe.id)??null),me})}catch(ue){console.error("Failed to delete session",ue),_t(`Failed to close session: ${ue instanceof Error?ue.message:"API error"}`,"#B71C1C")}},cr=async()=>{try{const{ids:F}=await Ee.deleteEmptySessions();if(F.length===0)return;ft(ue=>{var xe;const me=ue.filter(ge=>!F.includes(ge.id));return Vr&&F.includes(Vr)&&Jn(((xe=me[0])==null?void 0:xe.id)??null),me}),_t(`Cleared ${F.length} empty session${F.length!==1?"s":""}`,"#2E7D32")}catch(F){_t(`Failed to clear empty sessions: ${F instanceof Error?F.message:"API error"}`,"#B71C1C")}},Is=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const F=Bn.map(ue=>ue.id);try{await Ee.deleteSessions(F),ft([]),Jn(null),_t("All sessions closed","#2E7D32")}catch(ue){_t(`Failed to close sessions: ${ue instanceof Error?ue.message:"API error"}`,"#B71C1C")}},cl=(F,ue)=>{ft(me=>me.map(xe=>{if(xe.id!==F)return xe;const ge=[...xe.messages],ze=ge[ge.length-1];if(ze&&ze.from==="role"&&ze.status==="streaming"){const Oe=[...ze.streamEvents??[],ue];ge[ge.length-1]={...ze,streamEvents:Oe}}return{...xe,messages:ge}}))},Ol=(F,ue,me)=>{const xe={id:`msg-${Date.now()}-ceo`,from:"ceo",content:ue,type:me==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString()},ge={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};ft(ze=>ze.map(Oe=>Oe.id===F?{...Oe,messages:[...Oe.messages,xe,ge],updatedAt:new Date().toISOString()}:Oe)),gl(F),Hc(F,ue,me,{onThinking:ze=>{ft(Oe=>Oe.map(Xe=>{if(Xe.id!==F)return Xe;const at=[...Xe.messages],Ve=at[at.length-1];return Ve&&Ve.from==="role"&&Ve.status==="streaming"&&(at[at.length-1]={...Ve,thinking:(Ve.thinking??"")+ze}),{...Xe,messages:at}})),cl(F,{type:"thinking",timestamp:Date.now(),text:ze})},onText:ze=>{ft(Oe=>Oe.map(Xe=>{if(Xe.id!==F)return Xe;const at=[...Xe.messages],Ve=at[at.length-1];return Ve&&Ve.from==="role"&&Ve.status==="streaming"&&(at[at.length-1]={...Ve,content:Ve.content+ze}),{...Xe,messages:at}}))},onToolUse:(ze,Oe)=>{cl(F,{type:"tool",timestamp:Date.now(),toolName:ze,toolInput:Oe})},onDispatch:(ze,Oe)=>{cl(F,{type:"dispatch",timestamp:Date.now(),roleId:ze,task:Oe})},onDispatchProgress:(ze,Oe,Xe)=>{var at;Oe==="tool"?cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:"tool",toolName:Xe.name,toolInput:Xe.input}):Oe==="thinking"?cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:"thinking",text:Xe.text}):Oe==="text"?cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:"text",text:(at=Xe.text)==null?void 0:at.slice(-200)}):(Oe==="done"||Oe==="error")&&cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:Oe})},onTurn:ze=>{cl(F,{type:"turn",timestamp:Date.now(),turn:ze})},onDone:()=>{ft(ze=>ze.map(Oe=>{if(Oe.id!==F)return Oe;const Xe=Oe.messages.map(Ve=>Ve.status==="streaming"?{...Ve,status:"done"}:Ve),at=Oe.messages.length<=2?ue.slice(0,40).replace(/\n/g," "):Oe.title;return{...Oe,messages:Xe,title:at}})),gl(null)},onError:ze=>{ft(Oe=>Oe.map(Xe=>{if(Xe.id!==F)return Xe;const at=Xe.messages.map(Ve=>Ve.status==="streaming"?{...Ve,status:"error",content:Ve.content||ze}:Ve);return{...Xe,messages:at}})),gl(null)}})},Yc=(F,ue)=>{ft(me=>me.map(xe=>xe.id===F?{...xe,mode:ue}:xe)),Ee.updateSession(F,{mode:ue}).catch(console.error)},Ys=new Date().toISOString().slice(0,10),ul=c[0],Sa={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},qc=F=>{const ue=Sa[F];if(!ue)return"";for(const me of f){const xe=me.content,ge=xe.indexOf(`## ${ue}`);if(ge===-1)continue;const ze=xe.indexOf(`
|
|
89
|
+
`);xe=Xe.pop()||"";let at="";for(const Ve of Xe)if(Ve.startsWith("event: "))at=Ve.slice(7).trim();else if(Ve.startsWith("data: ")&&at){try{const Lt=JSON.parse(Ve.slice(6));switch(at){case"scanning":Rl(`Scanning: ${Lt.path} (${Lt.fileCount} files)`),Sn("scan",`Found ${Lt.fileCount} files`,Lt.path);break;case"processing":mi({index:Lt.index,total:Lt.total}),Rl(`Importing knowledge... (${Lt.index}/${Lt.total})`),Sn("process",`Processing: ${Lt.file}`,`${Lt.index} / ${Lt.total}`);break;case"created":Sn("created",Lt.title,Lt.summary);break;case"skipped":Sn("process",`Skipped: ${Lt.file}`,Lt.reason);break;case"done":Rl(null),mi(null),Sn("done",`Import complete! ${Lt.created} created, ${Lt.skipped} skipped.`),_t(`Knowledge import complete! ${Lt.created} documents imported.`,"#2E7D32"),l==null||l();break;case"error":Rl(null),mi(null),Sn("error",Lt.message),_t(`Import failed: ${Lt.message}`,"#B71C1C"),l==null||l();break}}catch{}at=""}}}).catch(F=>{Rl(null),Sn("error",F.message),_t(`Import error: ${F.message}`,"#B71C1C"),l==null||l()})))},[t]);const[qr,Bs]=k.useState("card"),[Ls,$s]=k.useState(typeof window<"u"?window.innerWidth:1200);k.useEffect(()=>{const F=()=>$s(window.innerWidth);return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]);const _l=Ls<1024,[jn,On]=k.useState(!1),[Zn,Xr]=k.useState(560),[Bn,ft]=k.useState([]),[Vr,Jn]=k.useState(null),[Ln,gl]=k.useState(null),{sendMessage:Hc}=$C();k.useEffect(()=>{Promise.all([Ee.getCompany().then(F=>{S(F.name),i(F.roles)}),Ee.getProjects().then(u),Ee.getStandups().then(m),Ee.getWaves().then(d),Ee.getDecisions().then(y),Ee.getKnowledge().then(v).catch(()=>{}),Ee.getOrgTree().then(F=>{_(F.nodes),D(F.root)}).catch(()=>{}),Ee.getCostSummary().then(F=>Gr(H0(F.byRole))).catch(()=>{})]).catch(F=>R(`Failed to load: ${F.message}`)).finally(()=>E(!1))},[]),k.useEffect(()=>{Ee.deleteEmptySessions().catch(()=>{}),Ee.getSessions().then(F=>{if(F.length>0){const ue=F.map(xe=>({...xe,messages:[]}));ft(ue);const me=ue.find(xe=>xe.status==="active")??ue[0];Jn(me.id),On(!0)}}).catch(F=>{console.error("Failed to load sessions",F)})},[]),k.useEffect(()=>{const F=()=>{fetch("/api/exec/status").then(me=>me.json()).then(me=>{Te(me.statuses??{}),$e(me.activeExecutions??[])}).catch(()=>{})};F();const ue=setInterval(F,3e3);return()=>clearInterval(ue)},[]);const sr=k.useMemo(()=>{const F={...je};if(Ln){const ue=Bn.find(me=>me.id===Ln);ue&&(F[ue.roleId]="working")}return F},[je,Ln,Bn]);k.useEffect(()=>{O.type==="role"?Ee.getRole(O.roleId).then(I).catch(console.error):I(null)},[O]);const or=()=>B({type:"none"}),Uc=async(F,ue)=>{const me=r.find(ge=>ge.id===F),xe=(X==null?void 0:X.mode)==="ask";ee(null);try{const{jobId:ge}=await Ee.startJob({type:"assign",roleId:F,task:ue,readOnly:xe}),ze=bc[F]??"#666",Oe=`${F.toUpperCase()} · ${(me==null?void 0:me.name)??F}`;ve(!1),$([{jobId:ge,title:Oe,color:ze}]),Xt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(me==null?void 0:me.name)??F}] ${xe?"Ask":"Assign"}: ${ue}`,type:"dispatch",targetRoleId:F})}catch(ge){_t(`Failed to start job: ${ge instanceof Error?ge.message:"unknown"}`,"#C62828")}},_t=(F,ue)=>{const me=Date.now();pt(xe=>[...xe,{id:me,message:F,color:ue}]),setTimeout(()=>pt(xe=>xe.filter(ge=>ge.id!==me)),4e3)},Gr=F=>{var me,xe;const ue=K.current;for(const[ge,ze]of Object.entries(F)){const Oe=((me=ue[ge])==null?void 0:me.level)??0;if(Oe>0&&ze.level>Oe){const Xe=((xe=r.find(at=>at.id===ge))==null?void 0:xe.name)??ge.toUpperCase();_t(`${Xe} leveled up to Lv.${ze.level}!`,"#7C3AED")}}K.current=F,oe(F)};k.useEffect(()=>{const F={roles:Object.entries(_e).map(([xe,ge])=>({id:xe,level:ge.level,totalTokens:ge.totalTokens})),totalTokens:Object.values(_e).reduce((xe,ge)=>xe+ge.totalTokens,0),roleCount:r.length},ue=U0(F),me=sn.current;for(const xe of ue)me.has(xe.id)||me.size>0&&_t(`${xe.icon} Badge earned: ${xe.name}!`,"#D4A017");sn.current=new Set(ue.map(xe=>xe.id))},[_e,r.length]);const ol=()=>{var ue;const F=z[z.length-1];F&&(_t(`${F.title} completed`,F.color),Xt.pushMessage({ts:Date.now(),roleId:((ue=F.title.split(" · ")[0])==null?void 0:ue.toLowerCase())??"unknown",text:`[${F.title}] Job completed`,type:"dispatch"})),Ee.getStandups().then(m).catch(console.error),Ee.getCompany().then(me=>i(me.roles)).catch(console.error),Ee.getCostSummary().then(me=>Gr(H0(me.byRole))).catch(()=>{})},Cn=async F=>{ne(!1);try{const ue=await Ee.startJob({type:"wave",directive:F}),me=ue.jobIds??(ue.jobId?[ue.jobId]:[]),xe=r.filter(ze=>ze.level==="c-level"),ge=me.map((ze,Oe)=>{var Xe,at;return{jobId:ze,roleId:((Xe=xe[Oe])==null?void 0:Xe.id)??`role-${Oe}`,roleName:((at=xe[Oe])==null?void 0:at.name)??`C-Level ${Oe+1}`}});Xt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${F}" → ${ge.map(ze=>ze.roleName).join(", ")}`,type:"dispatch"}),Object.keys(M).length>0?(Ce({directive:F,rootJobs:ge}),He(!1)):(V(ge),Q(0),ve(!1),ge.length>0&&$([{jobId:ge[0].jobId,title:`CEO WAVE · ${ge[0].roleId.toUpperCase()}`,color:"#B71C1C"}]))}catch(ue){_t(`Failed to start wave: ${ue instanceof Error?ue.message:"unknown"}`,"#C62828")}},yi=()=>{Ee.getWaves().then(d).catch(console.error),Ee.getStandups().then(m).catch(console.error)},gi=()=>{Ee.getCompany().then(F=>i(F.roles)).catch(console.error)},bi=async(F,ue)=>{await Ee.createRole(F),ae(F.id,ue),gi(),_t(`${F.name} hired!`,"#2E7D32")},Hs=async F=>{await Ee.deleteRole(F),gi(),ke(null),_t(`${F.toUpperCase()} removed`,"#B71C1C")},Kr=async(F,ue)=>{await Ee.updateRole(F,ue),gi(),O.type==="role"&&O.roleId===F&&Ee.getRole(F).then(I).catch(console.error),ue.name&&_t(`${F.toUpperCase()} renamed to "${ue.name}"`,"#1565C0")},Ic=F=>{On(!0)},En=async F=>{try{const ue=await Ee.createSession(F,"talk");ft(me=>[ue,...me]),Jn(ue.id),On(!0)}catch(ue){console.error("Failed to create session",ue),_t(`Failed to create session: ${ue instanceof Error?ue.message:"API unreachable"}`,"#B71C1C")}},vi=async F=>{try{const ue=await Ee.createSession(F,"talk");ft(me=>[ue,...me]),Jn(ue.id)}catch(ue){console.error("Failed to create session",ue),_t(`Failed to create session: ${ue instanceof Error?ue.message:"API unreachable"}`,"#B71C1C")}},Us=async F=>{const ue=Le.find(ge=>ge.roleId===F),me=(ue==null?void 0:ue.jobId)??(ue==null?void 0:ue.id);if(me&&sr[F]==="working"){const ge=r.find(Xe=>Xe.id===F),ze=bc[F]??"#666",Oe=`${F.toUpperCase()} · ${(ge==null?void 0:ge.name)??F}`;$([{jobId:me,title:Oe,color:ze}]),ve(!1);return}const xe=Bn.find(ge=>ge.roleId===F);if(xe)Jn(xe.id),Xt.setActiveChannelId(null);else try{const ge=await Ee.createSession(F,"talk");ft(ze=>[ge,...ze]),Jn(ge.id),Xt.setActiveChannelId(null)}catch(ge){console.error("Failed to create session",ge)}On(!0)},wi=async F=>{try{await Ee.deleteSession(F),ft(ue=>{var xe;const me=ue.filter(ge=>ge.id!==F);return Vr===F&&Jn(((xe=me[0])==null?void 0:xe.id)??null),me})}catch(ue){console.error("Failed to delete session",ue),_t(`Failed to close session: ${ue instanceof Error?ue.message:"API error"}`,"#B71C1C")}},cr=async()=>{try{const{ids:F}=await Ee.deleteEmptySessions();if(F.length===0)return;ft(ue=>{var xe;const me=ue.filter(ge=>!F.includes(ge.id));return Vr&&F.includes(Vr)&&Jn(((xe=me[0])==null?void 0:xe.id)??null),me}),_t(`Cleared ${F.length} empty session${F.length!==1?"s":""}`,"#2E7D32")}catch(F){_t(`Failed to clear empty sessions: ${F instanceof Error?F.message:"API error"}`,"#B71C1C")}},Is=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const F=Bn.map(ue=>ue.id);try{await Ee.deleteSessions(F),ft([]),Jn(null),_t("All sessions closed","#2E7D32")}catch(ue){_t(`Failed to close sessions: ${ue instanceof Error?ue.message:"API error"}`,"#B71C1C")}},cl=(F,ue)=>{ft(me=>me.map(xe=>{if(xe.id!==F)return xe;const ge=[...xe.messages],ze=ge[ge.length-1];if(ze&&ze.from==="role"&&ze.status==="streaming"){const Oe=[...ze.streamEvents??[],ue];ge[ge.length-1]={...ze,streamEvents:Oe}}return{...xe,messages:ge}}))},Ol=(F,ue,me)=>{const xe={id:`msg-${Date.now()}-ceo`,from:"ceo",content:ue,type:me==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString()},ge={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};ft(ze=>ze.map(Oe=>Oe.id===F?{...Oe,messages:[...Oe.messages,xe,ge],updatedAt:new Date().toISOString()}:Oe)),gl(F),Hc(F,ue,me,{onThinking:ze=>{ft(Oe=>Oe.map(Xe=>{if(Xe.id!==F)return Xe;const at=[...Xe.messages],Ve=at[at.length-1];return Ve&&Ve.from==="role"&&Ve.status==="streaming"&&(at[at.length-1]={...Ve,thinking:(Ve.thinking??"")+ze}),{...Xe,messages:at}})),cl(F,{type:"thinking",timestamp:Date.now(),text:ze})},onText:ze=>{ft(Oe=>Oe.map(Xe=>{if(Xe.id!==F)return Xe;const at=[...Xe.messages],Ve=at[at.length-1];return Ve&&Ve.from==="role"&&Ve.status==="streaming"&&(at[at.length-1]={...Ve,content:Ve.content+ze}),{...Xe,messages:at}}))},onToolUse:(ze,Oe)=>{cl(F,{type:"tool",timestamp:Date.now(),toolName:ze,toolInput:Oe})},onDispatch:(ze,Oe)=>{cl(F,{type:"dispatch",timestamp:Date.now(),roleId:ze,task:Oe})},onDispatchProgress:(ze,Oe,Xe)=>{var at;Oe==="tool"?cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:"tool",toolName:Xe.name,toolInput:Xe.input}):Oe==="thinking"?cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:"thinking",text:Xe.text}):Oe==="text"?cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:"text",text:(at=Xe.text)==null?void 0:at.slice(-200)}):(Oe==="done"||Oe==="error")&&cl(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ze,progressType:Oe})},onTurn:ze=>{cl(F,{type:"turn",timestamp:Date.now(),turn:ze})},onDone:()=>{ft(ze=>ze.map(Oe=>{if(Oe.id!==F)return Oe;const Xe=Oe.messages.map(Ve=>Ve.status==="streaming"?{...Ve,status:"done"}:Ve),at=Oe.messages.length<=2?ue.slice(0,40).replace(/\n/g," "):Oe.title;return{...Oe,messages:Xe,title:at}})),gl(null)},onError:ze=>{ft(Oe=>Oe.map(Xe=>{if(Xe.id!==F)return Xe;const at=Xe.messages.map(Ve=>Ve.status==="streaming"?{...Ve,status:"error",content:Ve.content||ze}:Ve);return{...Xe,messages:at}})),gl(null)}})},Yc=(F,ue)=>{ft(me=>me.map(xe=>xe.id===F?{...xe,mode:ue}:xe)),Ee.updateSession(F,{mode:ue}).catch(console.error)},Ys=new Date().toISOString().slice(0,10),ul=c[0],Sa={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},qc=F=>{const ue=Sa[F];if(!ue)return"";for(const me of f){const xe=me.content,ge=xe.indexOf(`## ${ue}`);if(ge===-1)continue;const ze=xe.indexOf(`
|
|
90
90
|
## `,ge+10),Xe=(ze===-1?xe.slice(ge):xe.slice(ge,ze)).split(`
|
|
91
91
|
`).filter(at=>at.trim().length>0);for(const at of Xe){const Ve=at.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(Ve.startsWith("|")||Ve.startsWith("{")||Ve.startsWith("[")||Ve.startsWith("```")||Ve.startsWith("---")||Ve.includes("Journal")||Ve.includes("(c-level)")||Ve.includes("(team-lead)")||Ve.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(Ve))&&Ve.length>15&&Ve.length<120)return Ve}}return""},Xc=F=>{const ue=Sa[F];if(!ue)return"";for(const me of f){const xe=me.content,ge=xe.indexOf(`## ${ue}`);if(ge===-1)continue;const ze=xe.indexOf(`
|
|
92
92
|
## `,ge+10),Xe=(ze===-1?xe.slice(ge):xe.slice(ge,ze)).replace(/^## .+\n/,"").trim();if(Xe)return Xe.slice(0,1500)}return""},Xt=rE();k.useEffect(()=>{r.length>0&&Xt.syncDefaultMembers(r)},[r]);const gn=PC({roles:r,roleStatuses:je,activeExecs:Le,getStandupSpeech:qc});return cE({roles:r,roleStatuses:je,activeExecs:Le,channels:Xt.channels,relationships:gn.relationships,pushMessage:Xt.pushMessage,speechSettings:we,engineType:St,hasApiKey:Kt}),C?o.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(Ml||Fl.length>0)&&o.jsxs("div",{className:"shrink-0 z-[44]",children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>xi(F=>!F),children:[Ml?o.jsx("div",{className:"w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin shrink-0"}):o.jsx("span",{className:"shrink-0",children:"✅"}),o.jsx("span",{className:"flex-1",children:Ml||"Knowledge import finished"}),Qn&&o.jsx("div",{className:"w-24 h-1.5 rounded-full overflow-hidden shrink-0",style:{background:"rgba(255,255,255,0.3)"},children:o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Qn.index/Qn.total*100}%`,background:"#fff"}})}),o.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:yl?"▲":"▼"})]}),yl&&o.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[Fl.map(F=>o.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[o.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[F.type==="scan"&&"🔍",F.type==="process"&&"⚙️",F.type==="created"&&"✅",F.type==="done"&&"🎉",F.type==="error"&&"❌"]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{style:{color:F.type==="error"?"#EF4444":F.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:F.text}),F.detail&&o.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:F.detail})]})]},F.id)),o.jsx("div",{ref:Wn})]})]}),o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-4xl mb-3",children:"🏢"}),o.jsx("div",{className:"text-gray-600 font-semibold text-xs",children:"LOADING OFFICE..."})]})})]}):A?o.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:o.jsxs("div",{className:"text-center max-w-md",style:{fontFamily:"var(--pixel-font)"},children:[o.jsx("div",{className:"text-4xl mb-3",children:"⚠️"}),o.jsx("div",{className:"text-gray-800 font-semibold mb-2 text-xs",children:"CONNECTION ERROR"}),o.jsx("div",{className:"text-gray-500 text-xs mb-4",children:A}),o.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white text-xs font-bold cursor-pointer border-2 border-gray-600",style:{fontFamily:"var(--pixel-font)"},children:"RETRY"})]})}):o.jsxs("div",{className:"flex flex-col",style:{height:"100dvh",fontFamily:"var(--pixel-font)"},children:[o.jsxs("div",{className:"flex items-center justify-between px-5 py-2 bg-[var(--hud-bg)] text-white text-sm shrink-0 z-[45]",style:{borderBottom:"3px solid var(--pixel-border)"},children:[o.jsxs("div",{className:"font-black text-[13px] tracking-tight",style:{color:"var(--idle-amber)",textShadow:"2px 2px 0 rgba(0,0,0,0.5)"},children:["🏢"," ",o.jsx("span",{style:{color:"var(--terminal-text)"},children:j})]}),o.jsxs("div",{className:"flex gap-4 text-[var(--terminal-text-secondary)] text-[11px] items-center",children:[(()=>{const F=Object.values(_e).reduce((ze,Oe)=>ze+Oe.totalTokens,0),ue=F>=1e6?`${(F/1e6).toFixed(1)}M`:F>=1e3?`${Math.round(F/1e3)}K`:String(F),me=Math.min(100,Math.round(F/25e4*100)),xe=Le.length,ge=r.length>0?Math.round(xe/r.length*100):0;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["💰",o.jsx("div",{className:"w-[50px] h-2 bg-[#111] overflow-hidden",style:{border:"2px solid var(--pixel-border)"},children:o.jsx("div",{className:"h-full",style:{width:`${me}%`,background:"linear-gradient(90deg,#22c55e,#34D399)"}})}),o.jsx("strong",{className:"text-[var(--active-green)]",children:ue})]}),o.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["⚡",o.jsx("div",{className:"w-[50px] h-2 bg-[#111] overflow-hidden",style:{border:"2px solid var(--pixel-border)"},children:o.jsx("div",{className:"h-full",style:{width:`${ge}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),o.jsx("strong",{className:"text-[var(--terminal-text)]",children:ge})]})]})})(),o.jsxs("span",{className:"hidden sm:inline",children:["Roles: ",o.jsx("strong",{className:"text-[var(--terminal-text)]",children:r.length})]}),o.jsxs("span",{className:"hidden sm:inline",children:["Projects: ",o.jsx("strong",{className:"text-[var(--terminal-text)]",children:c.length})]}),Le.length>0&&o.jsxs("span",{className:"text-amber-400",children:["Working: ",o.jsx("strong",{children:Le.length})]}),(()=>{const F={roles:Object.entries(_e).map(([me,xe])=>({id:me,level:xe.level,totalTokens:xe.totalTokens})),totalTokens:Object.values(_e).reduce((me,xe)=>me+xe.totalTokens,0),roleCount:r.length},ue=U0(F);return ue.length>0?o.jsx("div",{className:"hidden sm:flex",style:{gap:2,alignItems:"center",marginLeft:8,paddingLeft:8,borderLeft:"1px solid rgba(255,255,255,0.1)"},children:ue.map(me=>o.jsx("span",{title:`${me.name}: ${me.description}`,style:{fontSize:12,cursor:"default"},children:me.icon},me.id))}):null})(),o.jsxs("button",{onClick:()=>{et.state==="no-git"?et.initGit():rr(!0)},className:"flex items-center gap-1 cursor-pointer px-1.5 py-0.5",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--pixel-border)"},title:et.state==="no-git"?"Click to initialize git repository":et.state==="dirty"?`${et.dirtyCount} unsaved changes`:"All saved",children:[o.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:et.state==="no-git"?"var(--terminal-text-muted)":et.state==="saving"||et.state==="dirty"?"var(--idle-amber)":et.state==="error"?"#EF5350":"var(--active-green)",animation:et.state==="saving"?"pulse 1s infinite":void 0}}),o.jsx("span",{children:Ys})]})]})]}),(Ml||Fl.length>0)&&o.jsxs("div",{className:"shrink-0 z-[44]",children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>xi(F=>!F),children:[Ml?o.jsx("div",{className:"w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin shrink-0"}):o.jsx("span",{className:"shrink-0",children:"✅"}),o.jsx("span",{className:"flex-1",children:Ml||"Knowledge import finished"}),Qn&&o.jsx("div",{className:"w-24 h-1.5 rounded-full overflow-hidden shrink-0",style:{background:"rgba(255,255,255,0.3)"},children:o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Qn.index/Qn.total*100}%`,background:"#fff"}})}),o.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:yl?"▲":"▼"})]}),yl&&o.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[Fl.map(F=>o.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[o.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[F.type==="scan"&&"🔍",F.type==="process"&&"⚙️",F.type==="created"&&"✅",F.type==="done"&&"🎉",F.type==="error"&&"❌"]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{style:{color:F.type==="error"?"#EF4444":F.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:F.text}),F.detail&&o.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:F.detail})]})]},F.id)),o.jsx("div",{ref:Wn}),Fl.length===0&&o.jsx("div",{className:"px-5 py-4 text-center",style:{color:"var(--terminal-text-muted)"},children:"Waiting for events..."})]})]}),o.jsxs("div",{className:"flex-1 overflow-hidden flex relative",children:[o.jsx("div",{className:"flex-1 overflow-y-auto relative floor-grid",style:{background:"var(--floor-light)"},children:qr==="iso"?o.jsx(QE,{roles:r,projects:c,waves:p,standups:f,decisions:g,roleStatuses:sr,activeExecs:Le,onRoleClick:F=>B({type:"role",roleId:F}),onProjectClick:F=>B({type:"project",projectId:F}),onBulletinClick:()=>B({type:"bulletin"}),onDecisionsClick:()=>B({type:"decisions"}),onKnowledgeClick:()=>B({type:"knowledge"}),knowledgeDocsCount:b.length,getRoleSpeech:gn.getSpeech,getAppearance:qt,onHireClick:()=>Se(!0)}):o.jsxs("div",{className:`${jn?"max-w-full":"max-w-[1100px]"} mx-auto h-full p-4 flex flex-col gap-3 relative z-[1]`,children:[(()=>{const F=r.filter(me=>me.level==="c-level"),ue=r.filter(me=>me.level!=="c-level");return o.jsxs(o.Fragment,{children:[F.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"pixel-section-label",children:"LEADERSHIP"}),o.jsx("div",{className:`grid gap-2 ${F.length===1?"grid-cols-1":"grid-cols-2"}`,children:F.map(me=>{var xe,ge;return o.jsx(I0,{role:me,speech:gn.getSpeech(me.id),onClick:()=>B({type:"role",roleId:me.id}),liveStatus:sr[me.id],activeTask:(xe=Le.find(ze=>ze.roleId===me.id))==null?void 0:xe.task,featured:!0,appearance:qt(me.id),xpLevel:(ge=_e[me.id])==null?void 0:ge.level},me.id)})})]}),o.jsx("div",{className:"pixel-section-label",children:"TEAM"}),o.jsxs("div",{className:`grid gap-2 ${jn?"grid-cols-3":"grid-cols-4"}`,children:[ue.map(me=>{var xe,ge;return o.jsx(I0,{role:me,speech:gn.getSpeech(me.id),onClick:()=>B({type:"role",roleId:me.id}),liveStatus:sr[me.id],activeTask:(xe=Le.find(ze=>ze.roleId===me.id))==null?void 0:xe.task,appearance:qt(me.id),xpLevel:(ge=_e[me.id])==null?void 0:ge.level},me.id)}),o.jsx("div",{className:"pixel-card pixel-card--hire",onClick:()=>Se(!0),children:o.jsxs("div",{className:"pixel-card--hire-inner",children:[o.jsx("span",{className:"pixel-card--hire-icon",children:"+"}),o.jsx("span",{className:"pixel-card--hire-label",children:"HIRE NEW ROLE"})]})})]})]})})(),o.jsx("div",{className:"pixel-section-label mt-1",children:"OFFICE"}),o.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[o.jsxs("div",{className:"facility-card-compact",onClick:ul?()=>B({type:"project",projectId:ul.id}):void 0,style:ul?void 0:{borderStyle:"dashed",opacity:.5},children:[o.jsxs("div",{className:"fcc-hdr",style:{background:"#3B82F6"},children:["🏢"," MEETING ROOM"]}),o.jsx("div",{className:"fcc-canvas",children:o.jsx(oc,{type:"meeting"})}),o.jsxs("div",{className:"fcc-body",children:[o.jsx("div",{className:"fcc-desc",children:"Projects, PRDs, and task boards"}),ul?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"fcc-title",children:['"',ul.name,'"']}),o.jsxs("div",{className:"fcc-meta",children:["Status: ",o.jsx("strong",{style:{color:"var(--active-green)"},children:ul.status})]})]}):o.jsx("div",{className:"fcc-meta",style:{fontStyle:"italic"},children:"No active projects"})]})]}),o.jsxs("div",{className:"facility-card-compact",onClick:()=>B({type:"bulletin"}),children:[o.jsxs("div",{className:"fcc-hdr",style:{background:"#64748b"},children:["📋"," BULLETIN"]}),o.jsx("div",{className:"fcc-canvas",children:o.jsx(oc,{type:"bulletin"})}),o.jsxs("div",{className:"fcc-body",children:[o.jsx("div",{className:"fcc-desc",children:"Waves and daily standups"}),p.slice(0,1).map(F=>o.jsxs("div",{className:"fcc-item",children:["Wave ",F.id]},F.id)),f.slice(0,1).map(F=>o.jsxs("div",{className:"fcc-item",children:["Standup ",F.date]},F.date)),p.length===0&&f.length===0&&o.jsx("div",{className:"fcc-meta",style:{fontStyle:"italic"},children:"No entries yet"})]})]}),o.jsxs("div",{className:"facility-card-compact",onClick:()=>B({type:"decisions"}),children:[o.jsxs("div",{className:"fcc-hdr",style:{background:"#EF4444"},children:["📜"," DECISIONS"]}),o.jsx("div",{className:"fcc-canvas",children:o.jsx(oc,{type:"decision"})}),o.jsxs("div",{className:"fcc-body",children:[o.jsx("div",{className:"fcc-desc",children:"CEO strategic decision log"}),o.jsxs("div",{className:"fcc-title",children:[g.length," decisions"]}),g.slice(0,2).map(F=>o.jsxs("div",{className:"fcc-item",children:["#",F.id," ",F.title]},F.id))]})]}),o.jsxs("div",{className:"facility-card-compact",onClick:()=>B({type:"knowledge"}),children:[o.jsxs("div",{className:"fcc-hdr",style:{background:"#0D9488"},children:["📚"," KNOWLEDGE"]}),o.jsx("div",{className:"fcc-canvas",children:o.jsx(oc,{type:"knowledge"})}),o.jsxs("div",{className:"fcc-body",children:[o.jsx("div",{className:"fcc-desc",children:"Research, analysis, and references"}),o.jsxs("div",{className:"fcc-title",children:[b.length," docs"]}),b.slice(0,2).map(F=>o.jsx("div",{className:"fcc-item",children:F.title},F.id))]})]})]})]})}),jn&&o.jsx("div",{className:_l?"absolute inset-0 z-50":"contents",children:o.jsx(LC,{sessions:Bn,activeSessionId:Vr,roles:r,streamingSessionId:Ln,width:_l?Ls:Zn,onWidthChange:_l?void 0:Xr,onSwitchSession:Jn,onCloseSession:wi,onCreateSession:En,onClearEmpty:cr,onCloseAll:Is,onSendMessage:Ol,onModeChange:Yc,onCloseTerminal:()=>On(!1),chatChannels:Xt.channels,activeChatChannelId:Xt.activeChannelId,onSwitchChatChannel:Xt.setActiveChannelId,onCreateChatChannel:Xt.createChannel,onDeleteChatChannel:Xt.deleteChannel,onUpdateChatMembers:Xt.updateMembers,onUpdateChatTopic:Xt.updateTopic,unreadChannels:Xt.unreadChannels})})]}),o.jsxs("div",{className:"flex items-center justify-between px-5 py-2 bg-[var(--hud-bg)] text-[var(--terminal-text-secondary)] text-[10px] shrink-0 z-[45]",style:{borderTop:"3px solid var(--pixel-border)"},children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>Bs("card"),className:`view-toggle-btn ${qr==="card"?"active":""}`,children:"CARD"}),o.jsx("button",{onClick:()=>Bs("iso"),className:`view-toggle-btn ${qr==="iso"?"active":""}`,children:"ISO"}),o.jsx("span",{className:"mx-1",children:"|"}),o.jsxs("button",{className:"theme-btn",onClick:()=>{dn("office"),Pe(r[0]??null)},title:"Customize",children:[((ja=$r[Re])==null?void 0:ja.icon)??""," ",((Ca=$r[Re])==null?void 0:Ca.name)??"THEME"]}),o.jsx("span",{className:"mx-1",children:"|"}),o.jsx("button",{className:"theme-btn",onClick:()=>ar(!0),title:"Company Stats",children:"STATS"}),o.jsx("button",{className:"theme-btn",onClick:()=>ir(!0),title:"Role Sync",children:"SYNC"}),o.jsx("span",{className:"mx-1",children:"|"}),o.jsx("button",{onClick:()=>di(!0),title:"Git Status",style:{background:"none",border:"none",cursor:"pointer",fontSize:10,fontFamily:"var(--pixel-font)",color:yn?yn.worktrees.some(F=>F.status==="stale")?"#ff6b6b":yn.worktrees.some(F=>F.status==="pending-merge")?"#FFB74D":yn.worktrees.length>0?"#4FC3F7":"#81C784":"var(--terminal-text-muted)"},children:yn?yn.worktrees.length===0&&yn.staleBranches.length===0?"✓ clean":`📂 ${yn.worktrees.length} worktree${yn.worktrees.length!==1?"s":""}${yn.staleBranches.length>0?` · ⚠ ${yn.staleBranches.length} branch${yn.staleBranches.length!==1?"es":""}`:""}`:"GIT"}),o.jsx("span",{className:"mx-1",children:"|"}),o.jsx("span",{style:{color:et.state==="dirty"?"var(--idle-amber)":"var(--terminal-text-muted)"},children:et.state==="no-git"?"No git":et.state==="saving"?"Saving...":et.state==="dirty"?`${et.dirtyCount} unsaved`:et.lastSaved?`Saved ${(()=>{const F=Math.floor((Date.now()-new Date(et.lastSaved).getTime())/6e4);return F<1?"just now":F<60?`${F}m ago`:`${Math.floor(F/60)}h ago`})()}`:"Saved"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[pe&&Ne&&o.jsx("button",{onClick:()=>He(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:"#B71C1C",border:"2px solid #7f121288",fontFamily:"var(--pixel-font)",borderRadius:4},children:"WAVE"}),z.length>0&&se&&o.jsxs("button",{onClick:()=>ve(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:z[z.length-1].color,border:`2px solid ${z[z.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[z[z.length-1].title.slice(0,20),z[z.length-1].title.length>20?"..":""]}),o.jsxs("button",{onClick:()=>ne(!0),className:"wave-btn px-3 py-1 font-black text-white cursor-pointer",style:{background:"#B71C1C",border:"2px solid #7f1212",fontFamily:"var(--pixel-font)"},children:["🔴"," CEO WAVE"]}),o.jsx("button",{onClick:()=>jn?On(!1):Ic(),className:"px-3 py-1 font-black cursor-pointer",style:{background:jn?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${jn?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]}),o.jsxs("span",{children:["Expand: +",Math.max(0,10-r.length)," desks available"]})]}),O.type==="role"&&T&&(()=>{var ue;const F=Le.find(me=>me.roleId===T.id);return o.jsx(sj,{role:T,allRoles:r,recentActivity:Xc(T.id),onClose:or,onFireRole:(me,xe)=>{ke({roleId:me,roleName:xe}),or()},terminalWidth:jn?Zn:0,activeJobId:F==null?void 0:F.id,activeTask:F==null?void 0:F.task,isWorking:sr[T.id]==="working",jobStartedAt:F==null?void 0:F.startedAt,onStopJob:me=>Ee.abortJob(me),sessions:Bn,streamingSessionId:Ln,onCreateSessionSilent:vi,onSendMessage:Ol,onFocusTerminal:Us,onCustomize:me=>{const xe=r.find(ge=>ge.id===me);xe&&(dn("character"),Pe(xe))},onUpdateRole:Kr,appearance:qt(T.id),relationships:gn.relationships,roleLevel:(ue=_e[T.id])==null?void 0:ue.level})})(),O.type==="project"&&ul&&o.jsx(lC,{projectId:ul.id,onClose:or,terminalWidth:jn?Zn:0}),(O.type==="bulletin"||O.type==="decisions")&&o.jsx(tC,{standups:f,waves:p,decisions:g,mode:O.type==="bulletin"?"bulletin":"decisions",onClose:or,terminalWidth:jn?Zn:0}),O.type==="knowledge"&&o.jsx(eC,{docs:b,onClose:or,onRefresh:()=>Ee.getKnowledge().then(v).catch(()=>{}),terminalWidth:jn?Zn:0,initialDocId:O.docId}),X&&o.jsx(iC,{roleId:X.roleId,roleName:X.roleName,mode:X.mode,onClose:()=>ee(null),onExecutionStart:Uc}),pe&&!Ne&&o.jsx(mC,{directive:pe.directive,rootJobs:pe.rootJobs,orgNodes:M,rootRoleId:J,onClose:()=>{Ce(null),He(!1)},onMinimize:()=>He(!0),onDone:()=>{yi(),_t("Wave complete","#2E7D32")},onOpenKnowledgeDoc:F=>{Ce(null),He(!1),B({type:"knowledge",docId:F}),Ee.getKnowledge().then(v).catch(()=>{})}}),z.length>0&&!se&&(()=>{var me;const F=z[z.length-1],ue=re.length>1;return o.jsxs(o.Fragment,{children:[ue&&z.length===1&&o.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[63] flex gap-1 px-2 pt-2",children:re.map((xe,ge)=>o.jsx("button",{onClick:()=>{Q(ge),$([{jobId:xe.jobId,title:`CEO WAVE · ${xe.roleId.toUpperCase()}`,color:"#B71C1C"}])},className:"px-3 py-1.5 text-xs font-bold rounded-t-lg cursor-pointer transition-colors",style:{background:Y===ge?"#B71C1C":"var(--terminal-bg)",color:Y===ge?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${Y===ge?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:xe.roleId.toUpperCase()},xe.jobId))}),o.jsx(sC,{jobId:F.jobId,title:z.length>1?F.title:ue?`CEO WAVE · ${((me=re[Y])==null?void 0:me.roleName)??""}`:F.title,color:F.color,variant:"modal",style:ue&&z.length===1?{marginTop:28}:void 0,onClose:()=>{$([]),V([]),Q(0),ve(!1)},onMinimize:()=>ve(!0),onDone:()=>{ol(),yi()},onNavigateToJob:xe=>{Ee.getJob(xe).then(ge=>{const ze=bc[ge.roleId]??"#888";$(Oe=>[...Oe,{jobId:xe,title:`${ge.roleId.toUpperCase()} · ${ge.task.slice(0,40)}`,color:ze}])}).catch(console.error)},onOpenKnowledgeDoc:xe=>{$([]),V([]),Q(0),ve(!1),B({type:"knowledge",docId:xe}),Ee.getKnowledge().then(v).catch(()=>{})}},F.jobId)]})})(),z.length>1&&o.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[62] pointer-events-none",children:o.jsx("div",{className:"pointer-events-auto",children:o.jsxs("button",{onClick:()=>$(F=>F.slice(0,-1)),className:"mt-2 ml-2 px-3 py-1 text-xs font-bold text-[var(--terminal-text)] bg-[var(--terminal-bg)] border border-[var(--terminal-border)] rounded-lg cursor-pointer hover:bg-[var(--terminal-inline-bg)]",children:["←"," Back to ",(Bl=z[z.length-2])==null?void 0:Bl.title]})})}),U&&o.jsx(cC,{cLevelRoles:r.filter(F=>F.level==="c-level"),orgNodes:M,rootId:J,onClose:()=>ne(!1),onDispatch:Cn}),fe&&o.jsx(bC,{existingRoles:r,onClose:()=>Se(!1),onHire:bi}),te&&o.jsx(vC,{roleId:te.roleId,roleName:te.roleName,onClose:()=>ke(null),onConfirm:Hs}),de&&o.jsx(WE,{role:de,appearance:qt(de.id),onSave:F=>ae(de.id,F),onReset:()=>ye(de.id),onClose:()=>{Pe(null),dn("character")},theme:Re,onThemeChange:qe,onUpdateName:async(F,ue)=>{await Kr(F,{name:ue})},initialTab:dt,speechSettings:we,onSpeechSettingsChange:Ae,language:bt,onLanguageChange:rt,roleLevel:(Ll=_e[de.id])==null?void 0:Ll.level}),$c&&o.jsx(ZE,{status:et.status,history:et.history,onClose:()=>rr(!1),onSave:async F=>await et.save(F),onLoadHistory:et.loadHistory,onRestore:et.restore,saving:et.state==="saving"}),wa&&o.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>ar(!1),children:o.jsx("div",{style:{width:420,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8},onClick:F=>F.stopPropagation(),children:o.jsx(JE,{onClose:()=>ar(!1)})})}),zl&&o.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>ir(!1),children:o.jsx("div",{style:{width:480,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:F=>F.stopPropagation(),children:o.jsx(tN,{onClose:()=>ir(!1),onSyncComplete:()=>{}})})}),Yr&&o.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>di(!1),children:o.jsx("div",{style:{width:520,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:F=>F.stopPropagation(),children:o.jsx(nN,{onClose:()=>di(!1)})})}),o.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:Yt.map(F=>o.jsxs("div",{className:"toast-enter flex items-center gap-2 px-4 py-2.5 shadow-lg text-white text-xs font-black",style:{background:F.color,border:"2px solid rgba(0,0,0,0.3)",fontFamily:"var(--pixel-font)"},children:[o.jsx("div",{className:"w-2 h-2 bg-white/60"}),F.message]},F.id))})]})}function I0({role:t,speech:l,onClick:r,liveStatus:i,activeTask:c,featured:u,appearance:f,xpLevel:m}){const p=bc[t.id]??sN(t.id),d=m??1,g=iN[t.id]??t.name,y=i==="working",b=y&&c?c:l||g;return o.jsxs("div",{className:`pixel-card ${y?"working":""} ${u?"pixel-card--featured":""}`,onClick:r,children:[o.jsxs("div",{className:"pixel-card-hdr",style:{background:p},children:[o.jsxs("span",{children:[t.id.toUpperCase()," ","·"," ",t.name.toUpperCase()]}),o.jsxs("span",{className:"lvl",children:["Lv.",d]})]}),o.jsxs("div",{className:"pixel-card-body",children:[o.jsx("div",{className:"pixel-desk"}),o.jsx(Bc,{roleId:t.id,appearance:f}),o.jsx("div",{className:"pixel-status-dot",style:{background:y?"var(--idle-amber)":"var(--active-green)"}})]}),o.jsxs("div",{className:"pixel-card-task",children:[o.jsx("span",{className:"pixel-card-task-icon",children:y?"🛠️":aN[t.id]??"👤"}),o.jsx("span",{className:"pixel-card-task-text",children:b||g})]})]})}function _d({onSelect:t,onClose:l}){const[r,i]=k.useState(null),[c,u]=k.useState(!0),f=k.useCallback(async m=>{u(!0);try{const p=await Ee.browse(m);i(p)}catch{}finally{u(!1)}},[]);return k.useEffect(()=>{f()},[f]),c&&!r?o.jsx("div",{className:"mt-3 rounded-lg p-4 text-xs text-center",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-muted)"},children:"Loading..."}):r?o.jsxs("div",{className:"mt-3 rounded-lg overflow-hidden text-xs",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",maxHeight:220,overflowY:"auto"},children:[o.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 sticky top-0",style:{background:"var(--terminal-surface)",borderBottom:"1px solid var(--terminal-border)"},children:[o.jsx("span",{style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},className:"truncate flex-1",children:r.current}),o.jsx("button",{onClick:()=>t(r.current),className:"px-2 py-1 rounded text-[10px] font-medium shrink-0",style:{background:"var(--active-green)",color:"#fff"},children:"Select"}),o.jsx("button",{onClick:l,className:"opacity-50 hover:opacity-100 shrink-0",style:{color:"var(--terminal-text)"},children:"✕"})]}),r.parent&&o.jsxs("div",{className:"px-3 py-1.5 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)]",style:{color:"var(--terminal-text-secondary)"},onClick:()=>f(r.parent),children:[o.jsx("span",{children:"⬆️"}),o.jsx("span",{children:".."})]}),r.dirs.map(m=>o.jsxs("div",{className:"px-3 py-1.5 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)]",style:{color:"var(--terminal-text)"},onClick:()=>f(m.path),children:[o.jsx("span",{children:"📁"}),o.jsx("span",{children:m.name})]},m.path)),r.dirs.length===0&&o.jsx("div",{className:"px-3 py-3 text-center",style:{color:"var(--terminal-text-muted)"},children:"No subdirectories"})]}):null}const cN={engine:"AI Engine",company:"Company Info",project:"Project",knowledge:"Knowledge",team:"Team Template",create:"Create"};function Y0(t){switch(t){case"skip":return["engine","company","project","knowledge","team","create"];case"import":return["engine","company","project","knowledge","team","create"];case"existing-akb":return["engine","knowledge","create"]}}function uN({onComplete:t}){const[l,r]=k.useState(0),[i,c]=k.useState(null),[u,f]=k.useState("none"),[m,p]=k.useState(""),[d,g]=k.useState(!0),[y,b]=k.useState(""),[v,j]=k.useState(""),S=k.useRef(null),[C,E]=k.useState("fresh"),[A,R]=k.useState(""),[O,B]=k.useState(null),[T,I]=k.useState(!1),[X,ee]=k.useState(!1),[z,$]=k.useState("skip"),[U,ne]=k.useState([]),[re,V]=k.useState(""),[Y,Q]=k.useState(!1),[se,ve]=k.useState(""),[M,_]=k.useState(null),[J,D]=k.useState(!1),[pe,Ce]=k.useState(!1),[Ne,He]=k.useState([]),[_e,oe]=k.useState("startup"),[K,fe]=k.useState(!1),[Se,te]=k.useState(!1),[ke,je]=k.useState(null),[Te,Le]=k.useState([]),[$e,Yt]=k.useState(!1),pt=k.useMemo(()=>Y0(z),[z]),St=pt[l]??"engine";k.useEffect(()=>{Ee.detectEngine().then(de=>{c(de),f(de.recommended),g(!1)}).catch(()=>g(!1)),Ee.getTeams().then(He).catch(()=>{})},[]),k.useEffect(()=>{var de;St==="company"&&((de=S.current)==null||de.focus())},[St]);const Bt=()=>{switch(St){case"engine":return u!=="none"||m.length>10;case"company":return y.trim().length>0;case"project":return C==="fresh"||C==="existing"&&O===!0;case"knowledge":return z==="existing-akb"?M===!0:z==="import"?U.length>0:!0;case"team":return!0;case"create":return!Se;default:return!1}},Kt=()=>{l<pt.length-1&&Bt()&&r(l+1),St==="create"&&!K&&!$e&&(z==="existing-akb"?qe():Re())},vt=()=>{l>0&&r(l-1)};k.useEffect(()=>{const de=Y0(z);l>=de.length&&r(de.length-1)},[z,l]);const qt=async()=>{if(A.trim()){I(!0);try{const de=await Ee.validatePath(A.trim());B(de.valid)}catch{B(!1)}finally{I(!1)}}},ae=async()=>{if(se.trim()){D(!0);try{const de=await Ee.validatePath(se.trim());_(de.valid&&de.hasClaudeMd===!0)}catch{_(!1)}finally{D(!1)}}},ye=()=>{const de=re.trim();de&&!U.includes(de)&&(ne([...U,de]),V(""))},Re=async()=>{fe(!0),je(null);try{const de={companyName:y.trim(),description:v.trim()||"An AI-powered organization",team:_e,existingProjectPath:C==="existing"?A.trim():void 0,knowledgePaths:z==="import"&&U.length>0?U:void 0};(u==="direct-api"||m)&&(de.apiKey=m||void 0);const Pe=await Ee.scaffold(de);Le(Pe.created),te(!0)}catch(de){je(de instanceof Error?de.message:"Scaffold failed")}finally{fe(!1)}},qe=async()=>{Yt(!0),je(null);try{const de=await Ee.connectAkb(se.trim());de.ok?(te(!0),Le([`Connected to: ${de.companyRoot}`])):je(de.error||"Failed to connect")}catch(de){je(de instanceof Error?de.message:"Connect failed")}finally{Yt(!1)}},we=()=>{z==="import"&&U.length>0?t({paths:U,companyRoot:""}):t()},Ae=de=>{de.key==="Enter"&&Bt()&&(de.preventDefault(),Kt())},bt=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
|
|
93
93
|
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
94
94
|
border border-[var(--terminal-border)]
|
|
95
95
|
focus:border-[var(--terminal-border-hover)]
|
|
96
|
-
placeholder:text-[var(--terminal-text-muted)]`,rt=de=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${de?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return o.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:Ae,children:o.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:[o.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[o.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),o.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),o.jsx("div",{className:"flex gap-1.5 mt-4",children:pt.map((de,Pe)=>o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Pe<=l?"var(--accent)":"var(--terminal-surface-light)"}}),o.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Pe===l?"var(--terminal-text)":"var(--terminal-text-muted)"},children:cN[de]})]},de))})]}),o.jsxs("div",{className:"px-6 py-5 min-h-[280px]",children:[St==="engine"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"AI Engine Setup"}),d?o.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:"Detecting AI engine..."}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:rt(u==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&f("claude-cli"),style:{opacity:i!=null&&i.claudeCli?1:.4},children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-lg",children:i!=null&&i.claudeCli?"✅":"❌"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-sm",children:"Claude Code CLI"}),o.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.claudeCli?"Detected! Recommended — zero config needed.":"Not installed. Get it at claude.ai/download"})]})]})}),o.jsxs("div",{className:rt(u==="direct-api"),onClick:()=>f("direct-api"),children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-lg",children:i!=null&&i.apiKey?"✅":"🔑"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"font-medium text-sm",children:"Anthropic API Key (BYOK)"}),o.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.apiKey?"API key found in environment.":"Enter your ANTHROPIC_API_KEY"})]})]}),u==="direct-api"&&!(i!=null&&i.apiKey)&&o.jsx("input",{type:"password",className:`${bt} mt-3`,placeholder:"sk-ant-...",value:m,onChange:de=>p(de.target.value),autoFocus:!0})]})]})]}),St==="company"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company Info"}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),o.jsx("input",{ref:S,className:bt,placeholder:"e.g. Acme Corp",value:y,onChange:de=>b(de.target.value)})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),o.jsx("textarea",{className:`${bt} resize-none`,rows:3,placeholder:"What does your AI company do?",value:v,onChange:de=>j(de.target.value)})]})]}),St==="project"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Project Setup"}),o.jsxs("div",{className:rt(C==="fresh"),onClick:()=>{E("fresh"),B(null)},children:[o.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Create a new AI company from scratch with clean directory structure."})]}),o.jsxs("div",{className:rt(C==="existing"),onClick:()=>E("existing"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["📂"," Connect Existing Project"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Add AI company structure to an existing codebase or knowledge base."}),C==="existing"&&o.jsxs("div",{className:"mt-3",onClick:de=>de.stopPropagation(),children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:`${bt} flex-1`,placeholder:"/path/to/your/project",value:A,onChange:de=>{R(de.target.value),B(null)},autoFocus:!0}),o.jsx("button",{onClick:()=>ee(!X),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)"},title:"Browse folders",children:"📁"}),o.jsx("button",{onClick:qt,disabled:T||!A.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:T||!A.trim()?.5:1},children:T?"...":"Verify"})]}),O===!0&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Path verified: ",A]}),O===!1&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," Invalid path"]}),X&&o.jsx(_d,{onSelect:de=>{R(de),B(!0),ee(!1)},onClose:()=>ee(!1)})]})]})]}),St==="knowledge"&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Knowledge Strategy"}),o.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"How should AI handle your knowledge base?"}),o.jsxs("div",{className:rt(z==="skip"),onClick:()=>$("skip"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Empty knowledge base. Add documents later from the office."})]}),o.jsxs("div",{className:rt(z==="import"),onClick:()=>$("import"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["📚"," Import & Build"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Select folders with documents — AI reads, summarizes, and organizes them."}),z==="import"&&o.jsxs("div",{className:"mt-3 space-y-2",onClick:de=>de.stopPropagation(),children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:`${bt} flex-1`,placeholder:"/path/to/docs",value:re,onChange:de=>V(de.target.value),onKeyDown:de=>{de.key==="Enter"&&(de.preventDefault(),ye())},autoFocus:!0}),o.jsx("button",{onClick:()=>Q(!Y),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)"},title:"Browse folders",children:"📁"}),o.jsx("button",{onClick:ye,disabled:!re.trim(),className:"px-3 py-2 rounded text-xs font-medium",style:{background:"var(--accent)",color:"#fff",opacity:re.trim()?1:.5},children:"Add"})]}),Y&&o.jsx(_d,{onSelect:de=>{U.includes(de)||ne([...U,de]),Q(!1)},onClose:()=>Q(!1)}),U.length>0&&o.jsx("div",{className:"space-y-1",children:U.map((de,Pe)=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:[o.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:de}),o.jsx("button",{onClick:()=>ne(U.filter((dt,dn)=>dn!==Pe)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Pe))}),U.length===0&&o.jsx("div",{className:"text-[10px] text-center py-2",style:{color:"var(--terminal-text-muted)"},children:"Add at least one folder to import."})]})]}),o.jsxs("div",{className:rt(z==="existing-akb"),onClick:()=>$("existing-akb"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["🔗"," Connect Existing AKB"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Connect a directory that already has CLAUDE.md and AKB structure."}),z==="existing-akb"&&o.jsxs("div",{className:"mt-3",onClick:de=>de.stopPropagation(),children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:`${bt} flex-1`,placeholder:"/path/to/your/akb",value:se,onChange:de=>{ve(de.target.value),_(null)},autoFocus:!0}),o.jsx("button",{onClick:()=>Ce(!pe),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)"},title:"Browse folders",children:"📁"}),o.jsx("button",{onClick:ae,disabled:J||!se.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:J||!se.trim()?.5:1},children:J?"...":"Verify"})]}),M===!0&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found: ",se]}),M===!1&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),pe&&o.jsx(_d,{onSelect:de=>{ve(de),_(null),Ce(!1)},onClose:()=>Ce(!1)})]})]})]}),St==="team"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Team Template"}),o.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"Choose a starting team. You can add or remove roles later."}),Ne.map(de=>o.jsxs("div",{className:rt(_e===de.id),onClick:()=>oe(de.id),children:[o.jsx("div",{className:"font-medium text-sm capitalize",children:de.id}),o.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:de.roles.map(Pe=>o.jsx("span",{className:"px-2 py-0.5 rounded text-[10px]",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:Pe.name},Pe.id))})]},de.id)),o.jsxs("div",{className:rt(_e==="custom"),onClick:()=>oe("custom"),children:[o.jsx("div",{className:"font-medium text-sm",children:"Custom"}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Start with no pre-built roles. Hire them from the office."})]})]}),St==="create"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:Se?z==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!Se&&!K&&!$e&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"rounded-lg p-4 space-y-2 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:z==="existing-akb"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Path:"})," ",se]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Company:"})," ",y]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Project:"})," ",C==="fresh"?"Start Fresh":`Existing (${A})`]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",z==="skip"?"Fresh (empty)":`Import ${U.length} source(s)`]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Team:"})," ",_e]}),z==="import"&&U.length>0&&o.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),ke&&o.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:ke})]}),(K||$e)&&o.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[o.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),o.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:$e?"Connecting to AKB...":"Scaffolding your company..."})]}),Se&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),o.jsx("div",{className:"rounded-lg p-4 text-xs max-h-40 overflow-y-auto",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:Te.map((de,Pe)=>o.jsxs("div",{className:"py-0.5",children:[o.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",de]},Pe))}),z==="import"&&U.length>0&&o.jsx("div",{className:"text-xs p-3 rounded",style:{background:"var(--accent)",color:"#fff",opacity:.9},children:"Knowledge import will start in the background after entering the office."})]})]})]}),o.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[o.jsx("div",{children:l>0&&!Se&&o.jsx("button",{onClick:vt,className:"px-4 py-2 rounded text-sm transition-colors",style:{color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Back"})}),o.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[l+1," / ",pt.length]}),o.jsx("div",{children:Se?o.jsx("button",{onClick:we,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff"},children:"Enter Office"}):o.jsx("button",{onClick:Kt,disabled:!Bt()||K||$e,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Bt()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Bt()&&!K&&!$e?1:.5},children:St==="create"?K||$e?$e?"Connecting...":"Creating...":z==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function fN(){const[t,l]=k.useState(null),[r,i]=k.useState(!0),[c,u]=k.useState(null),f=k.useCallback(async()=>{i(!0),u(null);try{const m=await Ee.getStatus();l(m)}catch(m){u(m instanceof Error?m.message:"Failed to fetch status")}finally{i(!1)}},[]);return k.useEffect(()=>{f()},[f]),{initialized:(t==null?void 0:t.initialized)??!1,companyName:(t==null?void 0:t.companyName)??null,engine:(t==null?void 0:t.engine)??"none",companyRoot:(t==null?void 0:t.companyRoot)??"",loading:r,error:c,refetch:f}}const dN=k.lazy(()=>Zb(()=>import("./preview-app-CGBZJEYG.js"),[]));function Fg(){return o.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"w-10 h-10 mx-auto border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),o.jsx("div",{className:"mt-4 text-sm",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Loading..."})]})})}function hN(){var t;try{const l=localStorage.getItem("tycono-theme")||localStorage.getItem("the-company-theme"),r=l&&l in $r?l:"default",i=(t=$r[r])==null?void 0:t.vars;if(!i)return;const c=document.documentElement;for(const[u,f]of Object.entries(i))c.style.setProperty(u,f)}catch{}}function mN(){const{initialized:t,loading:l,refetch:r}=fN(),[i,c]=k.useState(null);k.useEffect(()=>{hN()},[]);const u=f=>{f&&c(f),r()};return l?o.jsx(Fg,{}):t?o.jsx(oN,{importJob:i,onImportDone:()=>c(null)}):o.jsx(uN,{onComplete:u})}function xN(){const t=new URLSearchParams(window.location.search).has("sprite-preview");return o.jsx(Jb,{children:t?o.jsx(k.Suspense,{fallback:o.jsx(Fg,{}),children:o.jsx(dN,{})}):o.jsx(mN,{})})}Kb.createRoot(document.getElementById("root")).render(o.jsx(k.StrictMode,{children:o.jsx(xN,{})}));export{xg as H,yg as P,gg as S,gN as a,pg as b,mg as c,Kd as d,DS as e,AS as f,yN as g,TS as h,o as j,k as r};
|
|
96
|
+
placeholder:text-[var(--terminal-text-muted)]`,rt=de=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${de?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return o.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:Ae,children:o.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:[o.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[o.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),o.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),o.jsx("div",{className:"flex gap-1.5 mt-4",children:pt.map((de,Pe)=>o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Pe<=l?"var(--accent)":"var(--terminal-surface-light)"}}),o.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Pe===l?"var(--terminal-text)":"var(--terminal-text-muted)"},children:cN[de]})]},de))})]}),o.jsxs("div",{className:"px-6 py-5 min-h-[280px]",children:[St==="engine"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"AI Engine Setup"}),d?o.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:"Detecting AI engine..."}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:rt(u==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&f("claude-cli"),style:{opacity:i!=null&&i.claudeCli?1:.4},children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-lg",children:i!=null&&i.claudeCli?"✅":"❌"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-sm",children:"Claude Code CLI"}),o.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.claudeCli?"Detected! Recommended — zero config needed.":"Not installed. Get it at claude.ai/download"})]})]})}),o.jsxs("div",{className:rt(u==="direct-api"),onClick:()=>f("direct-api"),children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-lg",children:i!=null&&i.apiKey?"✅":"🔑"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"font-medium text-sm",children:"Anthropic API Key (BYOK)"}),o.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.apiKey?"API key found in environment.":"Enter your ANTHROPIC_API_KEY"})]})]}),u==="direct-api"&&!(i!=null&&i.apiKey)&&o.jsx("input",{type:"password",className:`${bt} mt-3`,placeholder:"sk-ant-...",value:m,onChange:de=>p(de.target.value),autoFocus:!0})]})]})]}),St==="company"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company Info"}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),o.jsx("input",{ref:S,className:bt,placeholder:"e.g. Acme Corp",value:y,onChange:de=>b(de.target.value)})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),o.jsx("textarea",{className:`${bt} resize-none`,rows:3,placeholder:"What does your AI company do?",value:v,onChange:de=>j(de.target.value)})]})]}),St==="project"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Project Setup"}),o.jsxs("div",{className:rt(C==="fresh"),onClick:()=>{E("fresh"),B(null)},children:[o.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Create a new AI company from scratch with clean directory structure."})]}),o.jsxs("div",{className:rt(C==="existing"),onClick:()=>E("existing"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["📂"," Connect Existing Project"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Add AI company structure to an existing codebase or knowledge base."}),C==="existing"&&o.jsxs("div",{className:"mt-3",onClick:de=>de.stopPropagation(),children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:`${bt} flex-1`,placeholder:"/path/to/your/project",value:A,onChange:de=>{R(de.target.value),B(null)},autoFocus:!0}),o.jsx("button",{onClick:()=>ee(!X),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)"},title:"Browse folders",children:"📁"}),o.jsx("button",{onClick:qt,disabled:T||!A.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:T||!A.trim()?.5:1},children:T?"...":"Verify"})]}),O===!0&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Path verified: ",A]}),O===!1&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," Invalid path"]}),X&&o.jsx(_d,{onSelect:de=>{R(de),B(!0),ee(!1)},onClose:()=>ee(!1)})]})]})]}),St==="knowledge"&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Knowledge Strategy"}),o.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"How should AI handle your knowledge base?"}),o.jsxs("div",{className:rt(z==="skip"),onClick:()=>$("skip"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Empty knowledge base. Add documents later from the office."})]}),o.jsxs("div",{className:rt(z==="import"),onClick:()=>$("import"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["📚"," Import & Build"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Select folders with documents — AI reads, summarizes, and organizes them."}),z==="import"&&o.jsxs("div",{className:"mt-3 space-y-2",onClick:de=>de.stopPropagation(),children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:`${bt} flex-1`,placeholder:"/path/to/docs",value:re,onChange:de=>V(de.target.value),onKeyDown:de=>{de.key==="Enter"&&(de.preventDefault(),ye())},autoFocus:!0}),o.jsx("button",{onClick:()=>Q(!Y),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)"},title:"Browse folders",children:"📁"}),o.jsx("button",{onClick:ye,disabled:!re.trim(),className:"px-3 py-2 rounded text-xs font-medium",style:{background:"var(--accent)",color:"#fff",opacity:re.trim()?1:.5},children:"Add"})]}),Y&&o.jsx(_d,{onSelect:de=>{U.includes(de)||ne([...U,de]),Q(!1)},onClose:()=>Q(!1)}),U.length>0&&o.jsx("div",{className:"space-y-1",children:U.map((de,Pe)=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:[o.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:de}),o.jsx("button",{onClick:()=>ne(U.filter((dt,dn)=>dn!==Pe)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Pe))}),U.length===0&&o.jsx("div",{className:"text-[10px] text-center py-2",style:{color:"var(--terminal-text-muted)"},children:"Add at least one folder to import."})]})]}),o.jsxs("div",{className:rt(z==="existing-akb"),onClick:()=>$("existing-akb"),children:[o.jsxs("div",{className:"font-medium text-sm",children:["🔗"," Connect Existing AKB"]}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Connect a directory that already has CLAUDE.md and AKB structure."}),z==="existing-akb"&&o.jsxs("div",{className:"mt-3",onClick:de=>de.stopPropagation(),children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:`${bt} flex-1`,placeholder:"/path/to/your/akb",value:se,onChange:de=>{ve(de.target.value),_(null)},autoFocus:!0}),o.jsx("button",{onClick:()=>Ce(!pe),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)"},title:"Browse folders",children:"📁"}),o.jsx("button",{onClick:ae,disabled:J||!se.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:J||!se.trim()?.5:1},children:J?"...":"Verify"})]}),M===!0&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found: ",se]}),M===!1&&o.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),pe&&o.jsx(_d,{onSelect:de=>{ve(de),_(null),Ce(!1)},onClose:()=>Ce(!1)})]})]})]}),St==="team"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Team Template"}),o.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"Choose a starting team. You can add or remove roles later."}),Ne.map(de=>o.jsxs("div",{className:rt(_e===de.id),onClick:()=>oe(de.id),children:[o.jsx("div",{className:"font-medium text-sm capitalize",children:de.id}),o.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:de.roles.map(Pe=>o.jsx("span",{className:"px-2 py-0.5 rounded text-[10px]",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:Pe.name},Pe.id))})]},de.id)),o.jsxs("div",{className:rt(_e==="custom"),onClick:()=>oe("custom"),children:[o.jsx("div",{className:"font-medium text-sm",children:"Custom"}),o.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Start with no pre-built roles. Hire them from the office."})]})]}),St==="create"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:Se?z==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!Se&&!K&&!$e&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"rounded-lg p-4 space-y-2 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:z==="existing-akb"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Path:"})," ",se]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Company:"})," ",y]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Project:"})," ",C==="fresh"?"Start Fresh":`Existing (${A})`]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",z==="skip"?"Fresh (empty)":`Import ${U.length} source(s)`]}),o.jsxs("div",{children:[o.jsx("span",{className:"opacity-50",children:"Team:"})," ",_e]}),z==="import"&&U.length>0&&o.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),ke&&o.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:ke})]}),(K||$e)&&o.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[o.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),o.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:$e?"Connecting to AKB...":"Scaffolding your company..."})]}),Se&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),o.jsx("div",{className:"rounded-lg p-4 text-xs max-h-40 overflow-y-auto",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:Te.map((de,Pe)=>o.jsxs("div",{className:"py-0.5",children:[o.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",de]},Pe))}),z==="import"&&U.length>0&&o.jsx("div",{className:"text-xs p-3 rounded",style:{background:"var(--accent)",color:"#fff",opacity:.9},children:"Knowledge import will start in the background after entering the office."})]})]})]}),o.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[o.jsx("div",{children:l>0&&!Se&&o.jsx("button",{onClick:vt,className:"px-4 py-2 rounded text-sm transition-colors",style:{color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Back"})}),o.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[l+1," / ",pt.length]}),o.jsx("div",{children:Se?o.jsx("button",{onClick:we,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff"},children:"Enter Office"}):o.jsx("button",{onClick:Kt,disabled:!Bt()||K||$e,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Bt()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Bt()&&!K&&!$e?1:.5},children:St==="create"?K||$e?$e?"Connecting...":"Creating...":z==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function fN(){const[t,l]=k.useState(null),[r,i]=k.useState(!0),[c,u]=k.useState(null),f=k.useCallback(async()=>{i(!0),u(null);try{const m=await Ee.getStatus();l(m)}catch(m){u(m instanceof Error?m.message:"Failed to fetch status")}finally{i(!1)}},[]);return k.useEffect(()=>{f()},[f]),{initialized:(t==null?void 0:t.initialized)??!1,companyName:(t==null?void 0:t.companyName)??null,engine:(t==null?void 0:t.engine)??"none",companyRoot:(t==null?void 0:t.companyRoot)??"",loading:r,error:c,refetch:f}}const dN=k.lazy(()=>Zb(()=>import("./preview-app-BR4p4AQ9.js"),[]));function Fg(){return o.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"w-10 h-10 mx-auto border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),o.jsx("div",{className:"mt-4 text-sm",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Loading..."})]})})}function hN(){var t;try{const l=localStorage.getItem("tycono-theme")||localStorage.getItem("the-company-theme"),r=l&&l in $r?l:"default",i=(t=$r[r])==null?void 0:t.vars;if(!i)return;const c=document.documentElement;for(const[u,f]of Object.entries(i))c.style.setProperty(u,f)}catch{}}function mN(){const{initialized:t,loading:l,refetch:r}=fN(),[i,c]=k.useState(null);k.useEffect(()=>{hN()},[]);const u=f=>{f&&c(f),r()};return l?o.jsx(Fg,{}):t?o.jsx(oN,{importJob:i,onImportDone:()=>c(null)}):o.jsx(uN,{onComplete:u})}function xN(){const t=new URLSearchParams(window.location.search).has("sprite-preview");return o.jsx(Jb,{children:t?o.jsx(k.Suspense,{fallback:o.jsx(Fg,{}),children:o.jsx(dN,{})}):o.jsx(mN,{})})}Kb.createRoot(document.getElementById("root")).render(o.jsx(k.StrictMode,{children:o.jsx(xN,{})}));export{xg as H,yg as P,gg as S,gN as a,pg as b,mg as c,Kd as d,DS as e,AS as f,yN as g,TS as h,o as j,k as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,g as m,a as S,j as t,S as y,P as C,b as j,H as v,c as R,d as k,e as E,f as w,h as B}from"./index-
|
|
1
|
+
import{r as s,g as m,a as S,j as t,S as y,P as C,b as j,H as v,c as R,d as k,e as E,f as w,h as B}from"./index-B0GiFOxN.js";function A({id:i,ap:a,bobY:r,layers:l}){const c=s.useRef(null),o=k(i);return s.useEffect(()=>{if(!o||!c.current)return;const p=c.current.getContext("2d");if(!p)return;const h={...o,layers:o.layers.filter(u=>l.has(u.name))};E(p,h,r,a)},[o,a,r,l]),o?t.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:16,textAlign:"center",minWidth:140},children:[t.jsx("canvas",{ref:c,width:o.width*2,height:o.height*2,style:{imageRendering:"pixelated",display:"block",margin:"0 auto 8px",width:o.width*6,height:o.height*6,border:"1px solid #30363d",background:"#0d1117"}}),t.jsx("div",{style:{fontSize:11,color:"#8b949e",textTransform:"uppercase",letterSpacing:1},children:i})]}):null}function F({id:i}){const a=s.useRef(null),r=w(i);return s.useEffect(()=>{if(!r||!a.current)return;const l=a.current.getContext("2d");l&&B(l,r)},[r]),r?t.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:16,textAlign:"center"},children:[t.jsx("canvas",{ref:a,width:r.canvasWidth,height:r.canvasHeight,style:{imageRendering:"pixelated",display:"block",margin:"0 auto 8px",width:r.canvasWidth*2,height:r.canvasHeight*2,border:"1px solid #30363d",background:"#0d1117"}}),t.jsx("div",{style:{fontSize:11,color:"#8b949e",textTransform:"uppercase",letterSpacing:1},children:i})]}):null}const g=["body","hair","face","accessory","item","legs"];function I(){const[i,a]=s.useState({skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"}),[r,l]=s.useState(new Set(g)),[c,o]=s.useState(0),p=s.useRef(0);s.useEffect(()=>{const e=()=>{p.current++,o(p.current%60<30?1:0),requestAnimationFrame(e)},n=requestAnimationFrame(e);return()=>cancelAnimationFrame(n)},[]);const h=m(),u=S(),x=s.useCallback(e=>{l(n=>{const d=new Set(n);return d.has(e)?d.delete(e):d.add(e),d})},[]),f=s.useCallback(()=>{const e=n=>n[Math.floor(Math.random()*n.length)];a({skinColor:e(R),hairColor:e(v),shirtColor:e(j),pantsColor:e(C),shoeColor:e(y)})},[]);return t.jsxs("div",{style:{fontFamily:"'SF Mono', monospace",background:"#0d1117",color:"#e6edf3",padding:24,minHeight:"100vh"},children:[t.jsx("h1",{style:{fontSize:18,color:"#58a6ff",marginBottom:4},children:"Sprite Blueprint Preview"}),t.jsx("p",{style:{fontSize:12,color:"#484f58",marginBottom:16},children:"All sprites rendered from declarative Blueprint data"}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:12,padding:12,background:"#161b22",border:"1px solid #21262d",borderRadius:8,marginBottom:12,alignItems:"center"},children:[[["Skin","skinColor"],["Hair","hairColor"],["Shirt","shirtColor"],["Pants","pantsColor"],["Shoes","shoeColor"]].map(([e,n])=>t.jsxs("label",{style:{fontSize:11,color:"#8b949e",display:"flex",alignItems:"center",gap:4},children:[e,t.jsx("input",{type:"color",value:i[n],onChange:d=>a(b=>({...b,[n]:d.target.value})),style:{width:28,height:28,border:"1px solid #30363d",borderRadius:4,background:"none",cursor:"pointer"}})]},n)),t.jsx("button",{onClick:f,style:{background:"#21262d",color:"#e6edf3",border:"1px solid #30363d",borderRadius:4,padding:"4px 12px",fontSize:11,cursor:"pointer"},children:"Random"})]}),t.jsx("div",{style:{display:"flex",gap:8,marginBottom:16,flexWrap:"wrap"},children:g.map(e=>t.jsxs("label",{style:{fontSize:11,color:"#8b949e",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:r.has(e),onChange:()=>x(e)}),e]},e))}),t.jsxs("h2",{style:{fontSize:14,color:"#8b949e",margin:"24px 0 12px",borderBottom:"1px solid #21262d",paddingBottom:6},children:["Characters (",h.length,")"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:24},children:h.map(e=>t.jsx(A,{id:e,ap:i,bobY:c,layers:r},e))}),t.jsxs("h2",{style:{fontSize:14,color:"#8b949e",margin:"24px 0 12px",borderBottom:"1px solid #21262d",paddingBottom:6},children:["Facilities (",u.length,")"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:24},children:u.map(e=>t.jsx(F,{id:e},e))})]})}export{I as default};
|
package/src/web/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Tycono</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-B0GiFOxN.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-BaLxr7Du.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|