tycono 0.1.32 → 0.1.34

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tycono",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Build an AI company. Watch them work.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -232,11 +232,16 @@ function handleJobStream(jobId: string, fromSeq: number, req: IncomingMessage, r
232
232
  if (event.seq >= fromSeq) {
233
233
  sendSSE(res, 'activity', event);
234
234
  }
235
- // Auto-close SSE when job ends (done or error, NOT awaiting_input)
235
+ // Auto-close SSE when job ends or CEO replies (new stream takes over)
236
236
  if (event.type === 'job:done' || event.type === 'job:error') {
237
237
  sendSSE(res, 'stream:end', { reason: event.type === 'job:done' ? 'done' : 'error' });
238
238
  res.end();
239
239
  job.stream.unsubscribe(subscriber);
240
+ } else if (event.type === 'job:reply') {
241
+ // CEO replied → close this stream; frontend will connect to continuation job
242
+ sendSSE(res, 'stream:end', { reason: 'replied' });
243
+ res.end();
244
+ job.stream.unsubscribe(subscriber);
240
245
  }
241
246
  // awaiting_input keeps SSE open (sends event but doesn't close)
242
247
  };
@@ -331,14 +331,11 @@ class JobManager {
331
331
  const job = this.jobs.get(id);
332
332
  if (!job || job.status !== 'awaiting_input') return null;
333
333
 
334
- // Mark previous job as done
334
+ // Mark previous job as done (don't emit job:done — the stream stays open
335
+ // for the continuation job which will emit its own job:done when finished)
335
336
  job.status = 'done';
336
337
  completeActivity(job.roleId);
337
338
  job.stream.emit('job:reply', job.roleId, { response });
338
- job.stream.emit('job:done', job.roleId, {
339
- output: job.result?.output?.slice(-1000) ?? '',
340
- repliedWith: response,
341
- });
342
339
 
343
340
  // Build continuation prompt with previous context
344
341
  const prevOutput = job.result?.output ?? '';
@@ -78,7 +78,7 @@ Error generating stack: `+o.message+`
78
78
  `))}function x(v,S,j,E){const C=j.enter("tableCell"),A=j.enter("phrasing"),F=j.containerPhrasing(v,{...E,before:u,after:u});return A(),C(),F}function f(v,S){return Wk(v,{align:S,alignDelimiters:i,padding:r,stringLength:c})}function g(v,S,j){const E=v.children;let C=-1;const A=[],F=S.enter("table");for(;++C<E.length;)A[C]=y(E[C],S,j);return F(),A}function y(v,S,j){const E=v.children;let C=-1;const A=[],F=S.enter("tableRow");for(;++C<E.length;)A[C]=x(E[C],v,S,j);return F(),A}function b(v,S,j){let E=qy.inlineCode(v,S,j);return j.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function B4(){return{exit:{taskListCheckValueChecked:a0,taskListCheckValueUnchecked:a0,paragraph:$4}}}function L4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:H4}}}function a0(t){const l=this.stack[this.stack.length-2];l.type,l.checked=t.type==="taskListCheckValueChecked"}function $4(t){const l=this.stack[this.stack.length-2];if(l&&l.type==="listItem"&&typeof l.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const i=r.children[0];if(i&&i.type==="text"){const c=l.children;let u=-1,d;for(;++u<c.length;){const m=c[u];if(m.type==="paragraph"){d=m;break}}d===r&&(i.value=i.value.slice(1),i.value.length===0?r.children.shift():r.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,r.position.start=Object.assign({},i.position.start)))}}this.exit(t)}function H4(t,l,r,i){const c=t.children[0],u=typeof t.checked=="boolean"&&c&&c.type==="paragraph",d="["+(t.checked?"x":" ")+"] ",m=r.createTracker(i);u&&m.move(d);let x=qy.listItem(t,l,r,{...i,...m.current()});return u&&(x=x.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),x;function f(g){return g+d}}function U4(){return[bk(),Hk(),qk(),D4(),B4()]}function I4(t){return{extensions:[vk(),Uk(t),Xk(),O4(t),L4()]}}const Y4={tokenize:Q4,partial:!0},Xy={tokenize:W4,partial:!0},Vy={tokenize:Z4,partial:!0},Gy={tokenize:J4,partial:!0},q4={tokenize:P4,partial:!0},Ky={name:"wwwAutolink",tokenize:G4,previous:Wy},Qy={name:"protocolAutolink",tokenize:K4,previous:Zy},cr={name:"emailAutolink",tokenize:V4,previous:Jy},Bl={};function X4(){return{text:Bl}}let xa=48;for(;xa<123;)Bl[xa]=cr,xa++,xa===58?xa=65:xa===91&&(xa=97);Bl[43]=cr;Bl[45]=cr;Bl[46]=cr;Bl[95]=cr;Bl[72]=[cr,Qy];Bl[104]=[cr,Qy];Bl[87]=[cr,Ky];Bl[119]=[cr,Ky];function V4(t,l,r){const i=this;let c,u;return d;function d(y){return!Vf(y)||!Jy.call(i,i.previous)||wh(i.events)?r(y):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),m(y))}function m(y){return Vf(y)?(t.consume(y),m):y===64?(t.consume(y),x):r(y)}function x(y){return y===46?t.check(q4,g,f)(y):y===45||y===95||kn(y)?(u=!0,t.consume(y),x):g(y)}function f(y){return t.consume(y),c=!0,x}function g(y){return u&&c&&En(i.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),l(y)):r(y)}}function G4(t,l,r){const i=this;return c;function c(d){return d!==87&&d!==119||!Wy.call(i,i.previous)||wh(i.events)?r(d):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Y4,t.attempt(Xy,t.attempt(Vy,u),r),r)(d))}function u(d){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),l(d)}}function K4(t,l,r){const i=this;let c="",u=!1;return d;function d(y){return(y===72||y===104)&&Zy.call(i,i.previous)&&!wh(i.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),c+=String.fromCodePoint(y),t.consume(y),m):r(y)}function m(y){if(En(y)&&c.length<5)return c+=String.fromCodePoint(y),t.consume(y),m;if(y===58){const b=c.toLowerCase();if(b==="http"||b==="https")return t.consume(y),x}return r(y)}function x(y){return y===47?(t.consume(y),u?f:(u=!0,x)):r(y)}function f(y){return y===null||Sc(y)||Ft(y)||ka(y)||Rc(y)?r(y):t.attempt(Xy,t.attempt(Vy,g),r)(y)}function g(y){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),l(y)}}function Q4(t,l,r){let i=0;return c;function c(d){return(d===87||d===119)&&i<3?(i++,t.consume(d),c):d===46&&i===3?(t.consume(d),u):r(d)}function u(d){return d===null?r(d):l(d)}}function W4(t,l,r){let i,c,u;return d;function d(f){return f===46||f===95?t.check(Gy,x,m)(f):f===null||Ft(f)||ka(f)||f!==45&&Rc(f)?x(f):(u=!0,t.consume(f),d)}function m(f){return f===95?i=!0:(c=i,i=void 0),t.consume(f),d}function x(f){return c||i||!u?r(f):l(f)}}function Z4(t,l){let r=0,i=0;return c;function c(d){return d===40?(r++,t.consume(d),c):d===41&&i<r?u(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?t.check(Gy,l,u)(d):d===null||Ft(d)||ka(d)?l(d):(t.consume(d),c)}function u(d){return d===41&&i++,t.consume(d),c}}function J4(t,l,r){return i;function i(m){return m===33||m===34||m===39||m===41||m===42||m===44||m===46||m===58||m===59||m===63||m===95||m===126?(t.consume(m),i):m===38?(t.consume(m),u):m===93?(t.consume(m),c):m===60||m===null||Ft(m)||ka(m)?l(m):r(m)}function c(m){return m===null||m===40||m===91||Ft(m)||ka(m)?l(m):i(m)}function u(m){return En(m)?d(m):r(m)}function d(m){return m===59?(t.consume(m),i):En(m)?(t.consume(m),d):r(m)}}function P4(t,l,r){return i;function i(u){return t.consume(u),c}function c(u){return kn(u)?r(u):l(u)}}function Wy(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Ft(t)}function Zy(t){return!En(t)}function Jy(t){return!(t===47||Vf(t))}function Vf(t){return t===43||t===45||t===46||t===95||kn(t)}function wh(t){let l=t.length,r=!1;for(;l--;){const i=t[l][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){r=!0;break}if(i._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const ej={tokenize:oj,partial:!0};function tj(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:aj,continuation:{tokenize:ij},exit:sj}},text:{91:{name:"gfmFootnoteCall",tokenize:rj},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:nj,resolveTo:lj}}}}function nj(t,l,r){const i=this;let c=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;c--;){const x=i.events[c][1];if(x.type==="labelImage"){d=x;break}if(x.type==="gfmFootnoteCall"||x.type==="labelLink"||x.type==="label"||x.type==="image"||x.type==="link")break}return m;function m(x){if(!d||!d._balanced)return r(x);const f=bl(i.sliceSerialize({start:d.end,end:i.now()}));return f.codePointAt(0)!==94||!u.includes(f.slice(1))?r(x):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(x),t.exit("gfmFootnoteCallLabelMarker"),l(x))}}function lj(t,l){let r=t.length;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},c={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};c.end.column++,c.end.offset++,c.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},c.end),end:Object.assign({},t[t.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},m=[t[r+1],t[r+2],["enter",i,l],t[r+3],t[r+4],["enter",c,l],["exit",c,l],["enter",u,l],["enter",d,l],["exit",d,l],["exit",u,l],t[t.length-2],t[t.length-1],["exit",i,l]];return t.splice(r,t.length-r+1,...m),t}function rj(t,l,r){const i=this,c=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return m;function m(y){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(y),t.exit("gfmFootnoteCallLabelMarker"),x}function x(y){return y!==94?r(y):(t.enter("gfmFootnoteCallMarker"),t.consume(y),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",f)}function f(y){if(u>999||y===93&&!d||y===null||y===91||Ft(y))return r(y);if(y===93){t.exit("chunkString");const b=t.exit("gfmFootnoteCallString");return c.includes(bl(i.sliceSerialize(b)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(y),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),l):r(y)}return Ft(y)||(d=!0),u++,t.consume(y),y===92?g:f}function g(y){return y===91||y===92||y===93?(t.consume(y),u++,f):f(y)}}function aj(t,l,r){const i=this,c=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,m;return x;function x(S){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(S),t.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(S){return S===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(S),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",g):r(S)}function g(S){if(d>999||S===93&&!m||S===null||S===91||Ft(S))return r(S);if(S===93){t.exit("chunkString");const j=t.exit("gfmFootnoteDefinitionLabelString");return u=bl(i.sliceSerialize(j)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(S),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),b}return Ft(S)||(m=!0),d++,t.consume(S),S===92?y:g}function y(S){return S===91||S===92||S===93?(t.consume(S),d++,g):g(S)}function b(S){return S===58?(t.enter("definitionMarker"),t.consume(S),t.exit("definitionMarker"),c.includes(u)||c.push(u),pt(t,v,"gfmFootnoteDefinitionWhitespace")):r(S)}function v(S){return l(S)}}function ij(t,l,r){return t.check(Hs,l,t.attempt(ej,l,r))}function sj(t){t.exit("gfmFootnoteDefinition")}function oj(t,l,r){const i=this;return pt(t,c,"gfmFootnoteDefinitionIndent",5);function c(u){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?l(u):r(u)}}function cj(t){let r=(t||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:c};return r==null&&(r=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function c(d,m){let x=-1;for(;++x<d.length;)if(d[x][0]==="enter"&&d[x][1].type==="strikethroughSequenceTemporary"&&d[x][1]._close){let f=x;for(;f--;)if(d[f][0]==="exit"&&d[f][1].type==="strikethroughSequenceTemporary"&&d[f][1]._open&&d[x][1].end.offset-d[x][1].start.offset===d[f][1].end.offset-d[f][1].start.offset){d[x][1].type="strikethroughSequence",d[f][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},d[f][1].start),end:Object.assign({},d[x][1].end)},y={type:"strikethroughText",start:Object.assign({},d[f][1].end),end:Object.assign({},d[x][1].start)},b=[["enter",g,m],["enter",d[f][1],m],["exit",d[f][1],m],["enter",y,m]],v=m.parser.constructs.insideSpan.null;v&&Qn(b,b.length,0,_c(v,d.slice(f+1,x),m)),Qn(b,b.length,0,[["exit",y,m],["enter",d[x][1],m],["exit",d[x][1],m],["exit",g,m]]),Qn(d,f-1,x-f+3,b),x=f+b.length-2;break}}for(x=-1;++x<d.length;)d[x][1].type==="strikethroughSequenceTemporary"&&(d[x][1].type="data");return d}function u(d,m,x){const f=this.previous,g=this.events;let y=0;return b;function b(S){return f===126&&g[g.length-1][1].type!=="characterEscape"?x(S):(d.enter("strikethroughSequenceTemporary"),v(S))}function v(S){const j=xi(f);if(S===126)return y>1?x(S):(d.consume(S),y++,v);if(y<2&&!r)return x(S);const E=d.exit("strikethroughSequenceTemporary"),C=xi(S);return E._open=!C||C===2&&!!j,E._close=!j||j===2&&!!C,m(S)}}}class uj{constructor(){this.map=[]}add(l,r,i){dj(this,l,r,i)}consume(l){if(this.map.sort(function(u,d){return u[0]-d[0]}),this.map.length===0)return;let r=this.map.length;const i=[];for(;r>0;)r-=1,i.push(l.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),l.length=this.map[r][0];i.push(l.slice()),l.length=0;let c=i.pop();for(;c;){for(const u of c)l.push(u);c=i.pop()}this.map.length=0}}function dj(t,l,r,i){let c=0;if(!(r===0&&i.length===0)){for(;c<t.map.length;){if(t.map[c][0]===l){t.map[c][1]+=r,t.map[c][2].push(...i);return}c+=1}t.map.push([l,r,i])}}function fj(t,l){let r=!1;const i=[];for(;l<t.length;){const c=t[l];if(r){if(c[0]==="enter")c[1].type==="tableContent"&&i.push(t[l+1][1].type==="tableDelimiterMarker"?"left":"none");else if(c[1].type==="tableContent"){if(t[l-1][1].type==="tableDelimiterMarker"){const u=i.length-1;i[u]=i[u]==="left"?"center":"right"}}else if(c[1].type==="tableDelimiterRow")break}else c[0]==="enter"&&c[1].type==="tableDelimiterRow"&&(r=!0);l+=1}return i}function hj(){return{flow:{null:{name:"table",tokenize:mj,resolveAll:xj}}}}function mj(t,l,r){const i=this;let c=0,u=0,d;return m;function m(D){let Y=i.events.length-1;for(;Y>-1;){const ne=i.events[Y][1].type;if(ne==="lineEnding"||ne==="linePrefix")Y--;else break}const B=Y>-1?i.events[Y][1].type:null,V=B==="tableHead"||B==="tableRow"?M:x;return V===M&&i.parser.lazy[i.now().line]?r(D):V(D)}function x(D){return t.enter("tableHead"),t.enter("tableRow"),f(D)}function f(D){return D===124||(d=!0,u+=1),g(D)}function g(D){return D===null?r(D):qe(D)?u>1?(u=0,i.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(D),t.exit("lineEnding"),v):r(D):ct(D)?pt(t,g,"whitespace")(D):(u+=1,d&&(d=!1,c+=1),D===124?(t.enter("tableCellDivider"),t.consume(D),t.exit("tableCellDivider"),d=!0,g):(t.enter("data"),y(D)))}function y(D){return D===null||D===124||Ft(D)?(t.exit("data"),g(D)):(t.consume(D),D===92?b:y)}function b(D){return D===92||D===124?(t.consume(D),y):y(D)}function v(D){return i.interrupt=!1,i.parser.lazy[i.now().line]?r(D):(t.enter("tableDelimiterRow"),d=!1,ct(D)?pt(t,S,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):S(D))}function S(D){return D===45||D===58?E(D):D===124?(d=!0,t.enter("tableCellDivider"),t.consume(D),t.exit("tableCellDivider"),j):H(D)}function j(D){return ct(D)?pt(t,E,"whitespace")(D):E(D)}function E(D){return D===58?(u+=1,d=!0,t.enter("tableDelimiterMarker"),t.consume(D),t.exit("tableDelimiterMarker"),C):D===45?(u+=1,C(D)):D===null||qe(D)?_(D):H(D)}function C(D){return D===45?(t.enter("tableDelimiterFiller"),A(D)):H(D)}function A(D){return D===45?(t.consume(D),A):D===58?(d=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(D),t.exit("tableDelimiterMarker"),F):(t.exit("tableDelimiterFiller"),F(D))}function F(D){return ct(D)?pt(t,_,"whitespace")(D):_(D)}function _(D){return D===124?S(D):D===null||qe(D)?!d||c!==u?H(D):(t.exit("tableDelimiterRow"),t.exit("tableHead"),l(D)):H(D)}function H(D){return r(D)}function M(D){return t.enter("tableRow"),I(D)}function I(D){return D===124?(t.enter("tableCellDivider"),t.consume(D),t.exit("tableCellDivider"),I):D===null||qe(D)?(t.exit("tableRow"),l(D)):ct(D)?pt(t,I,"whitespace")(D):(t.enter("data"),W(D))}function W(D){return D===null||D===124||Ft(D)?(t.exit("data"),I(D)):(t.consume(D),D===92?te:W)}function te(D){return D===92||D===124?(t.consume(D),W):W(D)}}function xj(t,l){let r=-1,i=!0,c=0,u=[0,0,0,0],d=[0,0,0,0],m=!1,x=0,f,g,y;const b=new uj;for(;++r<t.length;){const v=t[r],S=v[1];v[0]==="enter"?S.type==="tableHead"?(m=!1,x!==0&&(i0(b,l,x,f,g),g=void 0,x=0),f={type:"table",start:Object.assign({},S.start),end:Object.assign({},S.end)},b.add(r,0,[["enter",f,l]])):S.type==="tableRow"||S.type==="tableDelimiterRow"?(i=!0,y=void 0,u=[0,0,0,0],d=[0,r+1,0,0],m&&(m=!1,g={type:"tableBody",start:Object.assign({},S.start),end:Object.assign({},S.end)},b.add(r,0,[["enter",g,l]])),c=S.type==="tableDelimiterRow"?2:g?3:1):c&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")?(i=!1,d[2]===0&&(u[1]!==0&&(d[0]=d[1],y=rc(b,l,u,c,void 0,y),u=[0,0,0,0]),d[2]=r)):S.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],y=rc(b,l,u,c,void 0,y)),u=d,d=[u[1],r,0,0])):S.type==="tableHead"?(m=!0,x=r):S.type==="tableRow"||S.type==="tableDelimiterRow"?(x=r,u[1]!==0?(d[0]=d[1],y=rc(b,l,u,c,r,y)):d[1]!==0&&(y=rc(b,l,d,c,r,y)),c=0):c&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(d[3]=r)}for(x!==0&&i0(b,l,x,f,g),b.consume(l.events),r=-1;++r<l.events.length;){const v=l.events[r];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=fj(l.events,r))}return t}function rc(t,l,r,i,c,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",m="tableContent";r[0]!==0&&(u.end=Object.assign({},di(l.events,r[0])),t.add(r[0],0,[["exit",u,l]]));const x=di(l.events,r[1]);if(u={type:d,start:Object.assign({},x),end:Object.assign({},x)},t.add(r[1],0,[["enter",u,l]]),r[2]!==0){const f=di(l.events,r[2]),g=di(l.events,r[3]),y={type:m,start:Object.assign({},f),end:Object.assign({},g)};if(t.add(r[2],0,[["enter",y,l]]),i!==2){const b=l.events[r[2]],v=l.events[r[3]];if(b[1].end=Object.assign({},v[1].end),b[1].type="chunkText",b[1].contentType="text",r[3]>r[2]+1){const S=r[2]+1,j=r[3]-r[2]-1;t.add(S,j,[])}}t.add(r[3]+1,0,[["exit",y,l]])}return c!==void 0&&(u.end=Object.assign({},di(l.events,c)),t.add(c,0,[["exit",u,l]]),u=void 0),u}function i0(t,l,r,i,c){const u=[],d=di(l.events,r);c&&(c.end=Object.assign({},d),u.push(["exit",c,l])),i.end=Object.assign({},d),u.push(["exit",i,l]),t.add(r+1,0,u)}function di(t,l){const r=t[l],i=r[0]==="enter"?"start":"end";return r[1][i]}const pj={name:"tasklistCheck",tokenize:gj};function yj(){return{text:{91:pj}}}function gj(t,l,r){const i=this;return c;function c(x){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?r(x):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(x),t.exit("taskListCheckMarker"),u)}function u(x){return Ft(x)?(t.enter("taskListCheckValueUnchecked"),t.consume(x),t.exit("taskListCheckValueUnchecked"),d):x===88||x===120?(t.enter("taskListCheckValueChecked"),t.consume(x),t.exit("taskListCheckValueChecked"),d):r(x)}function d(x){return x===93?(t.enter("taskListCheckMarker"),t.consume(x),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),m):r(x)}function m(x){return qe(x)?l(x):ct(x)?t.check({tokenize:bj},l,r)(x):r(x)}}function bj(t,l,r){return pt(t,i,"whitespace");function i(c){return c===null?r(c):l(c)}}function vj(t){return cy([X4(),tj(),cj(t),hj(),yj()])}const wj={};function kh(t){const l=this,r=t||wj,i=l.data(),c=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);c.push(vj(r)),u.push(U4()),d.push(I4(r))}function Is({content:t,className:l=""}){return s.jsx("div",{className:`office-markdown ${l}`,children:s.jsx(gh,{remarkPlugins:[kh],components:{code:kj,table:({children:r})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"office-table",children:r})})},children:t})})}function kj({className:t,children:l,...r}){const i=/language-(\w+)/.exec(t??"");return i||typeof l=="string"&&l.includes(`
79
79
  `)?s.jsx(jj,{language:i==null?void 0:i[1],children:l}):s.jsx("code",{className:"bg-gray-100 text-gray-700 px-1 py-0.5 rounded text-[0.9em] font-mono",...r,children:l})}function jj({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 s.jsxs("div",{className:"office-code-block group relative my-2",children:[l&&s.jsx("div",{className:"text-[10px] text-gray-400 px-3 pt-1.5",children:l}),s.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-gray-400 hover:text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:r?"Copied!":"Copy"}),s.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:s.jsx("code",{children:c})})]})}const s0={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},Sj=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function Cj(t,l){const r=parseInt(t.replace("#",""),16),i=Math.max(0,(r>>16&255)-l),c=Math.max(0,(r>>8&255)-l),u=Math.max(0,(r&255)-l);return`#${(i<<16|c<<8|u).toString(16).padStart(6,"0")}`}function Ej(t,l){const r=parseInt(t.replace("#",""),16),i=Math.min(255,(r>>16&255)+l),c=Math.min(255,(r>>8&255)+l),u=Math.min(255,(r&255)+l);return`#${(i<<16|c<<8|u).toString(16).padStart(6,"0")}`}function Py(t,l){const r=s0[t];if(r&&l)return l[r];const i=Sj.exec(t);if(i){const[,c,u,d]=i,m=s0[u],x=m&&l?l[m]:u,f=parseInt(d,10);return c==="darken"?Cj(x,f):Ej(x,f)}return t}function o0(t,l=12){return t.map(r=>({...r,x:l-r.x-r.w}))}function Nj(t,l){return l==="down"?t.down:l==="up"&&t.up?t.up:l==="left"&&t.left?t.left:l==="right"&&t.right?t.right:l==="right"&&t.left?{name:t.left.name,pixels:o0(t.left.pixels)}:l==="left"&&t.right?{name:t.right.name,pixels:o0(t.right.pixels)}:t.down}function Aj(t,l){return Gf(t,"hair",l,1)}function Gf(t,l,r,i){const c=t.layers.findIndex(d=>d.name===l),u=[...t.layers];if(c>=0)u[c]={...r,name:l};else{const d=i??u.length;u.splice(d,0,{...r,name:l})}return{...t,layers:u}}const jh=new Map,Sh=new Map;function eg(t,l){jh.set(t,l)}function $c(t,l){Sh.set(t,l)}function Kf(t){return jh.get(t)}function Tj(t){return Sh.get(t)}function vN(){return Array.from(jh.keys())}function wN(){return Array.from(Sh.keys())}function Dj(t,l,r,i,c=2){t.clearRect(0,0,l.width*c,l.height*c);for(const u of l.layers)tg(t,u.pixels,c,r,i)}function Qf(t,l,r,i,c){for(const u of l){const d=Py(u.c,c);u.a!==void 0&&u.a!==1&&(t.globalAlpha=u.a),t.fillStyle=d,t.fillRect(r+u.x,i+u.y,u.w,u.h),u.a!==void 0&&u.a!==1&&(t.globalAlpha=1)}}function zj(t,l){const r=l.scale;t.clearRect(0,0,l.canvasWidth,l.canvasHeight),tg(t,l.pixels,r,0)}function tg(t,l,r,i,c){for(const u of l){const d=Py(u.c,c);u.a!==void 0&&u.a!==1&&(t.globalAlpha=u.a),t.fillStyle=d,t.fillRect(u.x*r,(u.y+i)*r,u.w*r,u.h*r),u.a!==void 0&&u.a!==1&&(t.globalAlpha=1)}}const Ac=new Map;function Qr(t,l,r){if("down"in r&&!("pixels"in r)){const c=r;Ac.set(t,{id:t,name:l,layer:{...c.down,name:"hair"},directions:{down:{...c.down,name:"hair"},up:c.up?{...c.up,name:"hair"}:void 0,left:c.left?{...c.left,name:"hair"}:void 0,right:c.right?{...c.right,name:"hair"}:void 0}})}else{const c=r;Ac.set(t,{id:t,name:l,layer:{...c,name:"hair"}})}}function Mj(t){return Ac.get(t)}function ng(){return Array.from(Ac.values())}Qr("short","Short",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Qr("messy","Messy",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:0,w:2,h:4,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:7,y:-1,w:2,h:2,c:"lighten($hair, 20)"},{x:2,y:0,w:4,h:1,c:"lighten($hair, 30)",a:.3}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:4,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:0,w:2,h:4,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:7,y:-1,w:2,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:2,y:0,w:4,h:1,c:"lighten($hair, 30)",a:.3}]}});Qr("bun","Bun",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]}});Qr("long","Long",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:11,y:1,w:2,h:7,c:"$hair"},{x:-1,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:11,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:11,y:1,w:2,h:7,c:"$hair"},{x:1,y:2,w:10,h:6,c:"$hair"},{x:2,y:6,w:8,h:2,c:"darken($hair, 10)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:-1,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Qr("mohawk","Mohawk",{down:{name:"hair",pixels:[{x:4,y:-2,w:4,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"},{x:8,y:1,w:3,h:2,c:"$hair"}]},up:{name:"hair",pixels:[{x:4,y:-2,w:4,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"},{x:8,y:1,w:3,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:4,y:-2,w:3,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"}]}});Qr("slicked","Slicked Back",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 15)",a:.4},{x:3,y:1,w:6,h:1,c:"lighten($hair, 10)",a:.2}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 15)",a:.4}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:6,h:1,c:"lighten($hair, 15)",a:.4}]}});Qr("bob","Bob Cut",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:-1,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:11,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:1,y:2,w:10,h:4,c:"$hair"},{x:2,y:5,w:8,h:1,c:"darken($hair, 10)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:-1,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Qr("curly","Curly",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:2,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:6,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:4,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3},{x:8,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:1,y:2,w:10,h:4,c:"$hair"},{x:3,y:1,w:2,h:1,c:"lighten($hair, 15)",a:.3},{x:7,y:1,w:2,h:1,c:"lighten($hair, 15)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:2,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:5,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:3,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3}]}});const Tc=new Map;function Ll(t,l,r){if("down"in r&&!("pixels"in r)){const c=r;Tc.set(t,{id:t,name:l,layer:{...c.down,name:"torso"},directions:{down:{...c.down,name:"torso"},up:c.up?{...c.up,name:"torso"}:void 0,left:c.left?{...c.left,name:"torso"}:void 0,right:c.right?{...c.right,name:"torso"}:void 0}})}else{const c=r;Tc.set(t,{id:t,name:l,layer:{...c,name:"torso"}})}}function Fj(t){return Tc.get(t)}function lg(){return Array.from(Tc.values())}Ll("tshirt","T-Shirt",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:5,y:10,w:2,h:3,c:"darken($shirt, 10)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:2,y:10,w:7,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ll("suit","Suit",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 12)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:10,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:2,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:7,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:5,y:10,w:2,h:5,c:"#E8E8E8",a:.5},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:11,w:2,h:1,c:"darken($shirt, 20)",a:.2},{x:11,y:11,w:2,h:1,c:"darken($shirt, 20)",a:.2},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:10,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:5,y:12,w:2,h:4,c:"darken($shirt, 10)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:2,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:11,w:3,h:1,c:"darken($shirt, 20)",a:.2},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ll("hoodie","Hoodie",{down:{name:"torso",pixels:[{x:0,y:10,w:12,h:6,c:"$shirt"},{x:1,y:10,w:10,h:1,c:"lighten($shirt, 15)",a:.25},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:8,w:8,h:2,c:"$shirt",a:.4},{x:3,y:13,w:6,h:2,c:"darken($shirt, 15)",a:.2},{x:5,y:10,w:1,h:2,c:"#DDD",a:.3},{x:6,y:10,w:1,h:2,c:"#DDD",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:6,c:"$shirt"},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:7,w:8,h:3,c:"$shirt",a:.5},{x:3,y:7,w:6,h:1,c:"darken($shirt, 10)",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:0,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:8,h:1,c:"lighten($shirt, 15)",a:.25},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:8,w:6,h:2,c:"$shirt",a:.4},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ll("vest","Vest",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:5,y:10,w:2,h:2,c:"$skin",a:.6},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:3,h:5,c:"$skin"},{x:-1,y:15,w:3,h:1,c:"darken($skin, 10)"}]}});Ll("tank","Tank Top",{down:{name:"torso",pixels:[{x:2,y:10,w:8,h:6,c:"$shirt"},{x:3,y:10,w:6,h:1,c:"lighten($shirt, 18)",a:.3},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:9,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:10,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},up:{name:"torso",pixels:[{x:2,y:10,w:8,h:6,c:"$shirt"},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:9,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:10,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},left:{name:"torso",pixels:[{x:2,y:10,w:7,h:6,c:"$shirt"},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:3,h:5,c:"$skin"},{x:-1,y:15,w:3,h:1,c:"darken($skin, 10)"}]}});Ll("polo","Polo",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:6,h:2,c:"lighten($shirt, 25)",a:.5},{x:5,y:9,w:2,h:1,c:"$skin",a:.4},{x:5,y:10,w:2,h:3,c:"darken($shirt, 15)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:6,h:1,c:"lighten($shirt, 25)",a:.5},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:4,h:2,c:"lighten($shirt, 25)",a:.5},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ll("labcoat","Lab Coat",{down:{name:"torso",pixels:[{x:4,y:10,w:4,h:5,c:"$shirt"},{x:0,y:10,w:4,h:7,c:"#F0F0F0"},{x:8,y:10,w:4,h:7,c:"#F0F0F0"},{x:1,y:10,w:10,h:1,c:"#FAFAFA"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:11,y:10,w:1,h:7,c:"#DDD",a:.5},{x:1,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:9,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:-1,y:11,w:2,h:5,c:"#F0F0F0"},{x:11,y:11,w:2,h:5,c:"#F0F0F0"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"#F0F0F0"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:11,y:10,w:1,h:7,c:"#DDD",a:.5},{x:5,y:11,w:2,h:5,c:"#E8E8E8",a:.3},{x:-1,y:11,w:2,h:5,c:"#F0F0F0"},{x:11,y:11,w:2,h:5,c:"#F0F0F0"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:3,y:10,w:3,h:5,c:"$shirt"},{x:0,y:10,w:3,h:7,c:"#F0F0F0"},{x:6,y:10,w:4,h:7,c:"#F0F0F0"},{x:1,y:10,w:8,h:1,c:"#FAFAFA"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:1,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:-1,y:11,w:3,h:5,c:"#F0F0F0"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ll("overalls","Overalls",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:3,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:3,y:11,w:6,h:5,c:"#3D6B99"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:7,y:10,w:2,h:1,c:"#3D6B99"},{x:3,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:8,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:1,y:13,w:2,h:3,c:"#3D6B99"},{x:9,y:13,w:2,h:3,c:"#3D6B99"},{x:5,y:13,w:2,h:2,c:"#345E87",a:.4},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:3,c:"$shirt"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:7,y:10,w:2,h:1,c:"#3D6B99"},{x:1,y:13,w:10,h:3,c:"#3D6B99"},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:3,c:"$shirt"},{x:3,y:11,w:5,h:5,c:"#3D6B99"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:3,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:1,y:13,w:2,h:3,c:"#3D6B99"},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ll("turtleneck","Turtleneck",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:6,h:2,c:"$shirt"},{x:4,y:8,w:4,h:1,c:"lighten($shirt, 12)",a:.3},{x:3,y:9,w:1,h:1,c:"darken($shirt, 15)",a:.2},{x:8,y:9,w:1,h:1,c:"darken($shirt, 15)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:6,h:2,c:"$shirt"},{x:4,y:8,w:4,h:1,c:"lighten($shirt, 12)",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:4,h:2,c:"$shirt"},{x:3,y:8,w:3,h:1,c:"lighten($shirt, 12)",a:.3},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ll("robe","Robe",{down:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:3,y:10,w:3,h:4,c:"lighten($shirt, 15)",a:.25},{x:6,y:10,w:3,h:4,c:"darken($shirt, 10)",a:.2},{x:1,y:14,w:10,h:1,c:"darken($shirt, 35)"},{x:2,y:14,w:8,h:1,c:"darken($shirt, 25)",a:.4},{x:-2,y:11,w:3,h:5,c:"$shirt"},{x:11,y:11,w:3,h:5,c:"$shirt"},{x:-2,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:11,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:1,y:14,w:10,h:1,c:"darken($shirt, 35)"},{x:-2,y:11,w:3,h:5,c:"$shirt"},{x:11,y:11,w:3,h:5,c:"$shirt"},{x:-2,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:11,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:0,y:10,w:10,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:1,y:14,w:8,h:1,c:"darken($shirt, 35)"},{x:-2,y:11,w:4,h:5,c:"$shirt"},{x:-2,y:15,w:4,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"}]}});const Rs=new Map;function jt(t,l,r){if("down"in r&&!("pixels"in r)){const c=r;Rs.set(t,{id:t,name:l,layer:{...c.down,name:"accessory"},directions:{down:{...c.down,name:"accessory"},up:c.up?{...c.up,name:"accessory"}:void 0,left:c.left?{...c.left,name:"accessory"}:void 0,right:c.right?{...c.right,name:"accessory"}:void 0}})}else{const c=r;Rs.set(t,{id:t,name:l,layer:{...c,name:"accessory"}})}}function Rj(t){return Rs.get(t)}function _j(t,l){const r=Rs.get(t);if(!r)return;if(r.directions)return Nj(r.directions,l);if(l==="down")return r.layer;const i=r.layer.pixels.filter(u=>u.y<2);if(i.length===0)return;const c=l==="right"?1:l==="left"?-1:0;return{name:r.layer.name,pixels:c?i.map(u=>({...u,x:u.x+c})):i}}function rg(){return Array.from(Rs.values())}jt("none","None",{name:"accessory",pixels:[]});jt("glasses","Glasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:7,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:2,h:1,c:"#2A3A50",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#2A3A50",a:.4},{x:10,y:3,w:2,h:1,c:"#2A3A50",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:6,h:1,c:"#2A3A50",a:.3}]}});jt("round-glasses","Round Glasses",{down:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:7,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:8,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:2,h:1,c:"#8B7355",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#8B7355",a:.3},{x:10,y:3,w:2,h:1,c:"#8B7355",a:.3}]},left:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:6,h:1,c:"#8B7355",a:.25}]}});jt("sunglasses","Sunglasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:7,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:5,y:4,w:2,h:1,c:"#1A1A2E",a:.4},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:8,y:4,w:1,h:1,c:"#334",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#1A1A2E",a:.4},{x:10,y:3,w:2,h:1,c:"#1A1A2E",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:5,y:4,w:6,h:1,c:"#1A1A2E",a:.35}]}});jt("headphones","Headphones",{down:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:10,h:1,c:"#333",a:.7},{x:-1,y:1,w:3,h:5,c:"#444"},{x:-1,y:2,w:3,h:3,c:"#555",a:.3}]}});jt("beret","Beret",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:1,y:0,w:2,h:1,c:"#E91E63",a:.6},{x:4,y:-1,w:4,h:1,c:"#F06292",a:.3}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:9,y:0,w:2,h:1,c:"#E91E63",a:.6}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:8,h:2,c:"#E91E63"},{x:2,y:-1,w:4,h:1,c:"#F06292",a:.3}]}});jt("cap","Cap",{down:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:0,y:1,w:12,h:1,c:"#0D47A1"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3},{x:5,y:1,w:2,h:1,c:"#0D47A1",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:9,h:2,c:"#1565C0"},{x:-2,y:1,w:6,h:1,c:"#0D47A1"},{x:2,y:-1,w:5,h:1,c:"#1E88E5",a:.3}]}});jt("badge","Badge",{down:{name:"accessory",pixels:[{x:5,y:8,w:2,h:3,c:"#2196F3",a:.4},{x:4,y:11,w:4,h:3,c:"#FFF",a:.5},{x:5,y:12,w:2,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:8,w:1,h:3,c:"#2196F3",a:.4},{x:2,y:11,w:3,h:3,c:"#FFF",a:.5}]}});jt("lapels","Lapels",{down:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4},{x:8,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]}});jt("blush","Blush",{down:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3},{x:9,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]}});jt("scarf","Scarf",{down:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3},{x:3,y:11,w:2,h:3,c:"#E53935",a:.5}]},up:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:9,w:8,h:2,c:"#E53935",a:.6},{x:2,y:9,w:5,h:1,c:"#EF5350",a:.3},{x:1,y:11,w:2,h:3,c:"#E53935",a:.5}]}});jt("tie","Tie",{down:{name:"accessory",pixels:[{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:5,y:10,w:2,h:4,c:"#D32F2F"},{x:5,y:10,w:1,h:4,c:"#E53935",a:.3},{x:5,y:14,w:2,h:1,c:"#B71C1C",a:.8}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:4,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:10,w:2,h:4,c:"#D32F2F"},{x:4,y:14,w:2,h:1,c:"#B71C1C",a:.8}]}});jt("bowtie","Bowtie",{down:{name:"accessory",pixels:[{x:3,y:9,w:2,h:1,c:"#D32F2F"},{x:7,y:9,w:2,h:1,c:"#D32F2F"},{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:9,w:1,h:1,c:"#E53935",a:.3},{x:7,y:9,w:1,h:1,c:"#E53935",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:9,w:3,h:1,c:"#D32F2F"},{x:4,y:9,w:1,h:1,c:"#B71C1C"}]}});jt("cat-ears","Cat Ears",{down:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:1,y:-2,w:1,h:1,c:"#FFB0C0",a:.6},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"},{x:10,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:2,y:-3,w:2,h:1,c:"#555"},{x:1,y:-2,w:3,h:1,c:"#555"},{x:1,y:-1,w:3,h:1,c:"#555"},{x:2,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]}});jt("bear-ears","Bear Ears",{down:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:1,y:-1,w:1,h:1,c:"#C4A24A",a:.5},{x:9,y:-2,w:3,h:2,c:"#8B6914"},{x:10,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]},up:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:9,y:-2,w:3,h:2,c:"#8B6914"}]},left:{name:"accessory",pixels:[{x:1,y:-2,w:3,h:2,c:"#8B6914"},{x:2,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]}});jt("bunny-ears","Bunny Ears",{down:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:2,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},up:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},left:{name:"accessory",pixels:[{x:3,y:-5,w:2,h:4,c:"#F5F5F5"},{x:3,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:4,y:-6,w:2,h:1,c:"#F5F5F5"}]}});jt("dog-nose","Dog Nose",{down:{name:"accessory",pixels:[{x:4,y:5,w:4,h:3,c:"#D2B48C",a:.5},{x:5,y:5,w:2,h:1,c:"#222"},{x:6,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:0,y:5,w:4,h:2,c:"#D2B48C",a:.5},{x:0,y:5,w:2,h:1,c:"#222"},{x:1,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]}});jt("fox-mask","Fox Mask",{down:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"},{x:0,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:11,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:9,y:5,w:2,h:2,c:"#FFF",a:.25},{x:5,y:6,w:2,h:1,c:"#222",a:.6}]},up:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#E65100"},{x:0,y:-2,w:3,h:1,c:"#E65100"},{x:1,y:-1,w:3,h:1,c:"#E65100"},{x:1,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:1,y:6,w:2,h:1,c:"#222",a:.6}]}});jt("crown","Crown",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:4,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:6,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:8,y:-2,w:1,h:1,c:"#66BB6A",a:.8},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-1,w:7,h:2,c:"#FFD700"},{x:2,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:3,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:5,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:2,y:-1,w:5,h:1,c:"#FFF",a:.15}]}});jt("halo","Halo",{down:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:7,h:1,c:"#FFE082",a:.7},{x:0,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:8,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:2,y:-4,w:5,h:1,c:"#FFF9C4",a:.4},{x:2,y:-3,w:5,h:1,c:"#FFF",a:.15}]}});jt("horns","Horns",{down:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},left:{name:"accessory",pixels:[{x:2,y:-1,w:2,h:2,c:"#8B0000"},{x:1,y:-3,w:2,h:2,c:"#A00"},{x:1,y:-4,w:1,h:1,c:"#C62828"}]}});jt("mask","Mask",{down:{name:"accessory",pixels:[{x:1,y:3,w:10,h:3,c:"#1A1A2E",a:.75},{x:3,y:4,w:2,h:1,c:"#000",a:0},{x:7,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:10,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:10,h:1,c:"#FFD700",a:.2}]},up:{name:"accessory",pixels:[{x:0,y:4,w:12,h:1,c:"#1A1A2E",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:6,h:3,c:"#1A1A2E",a:.75},{x:2,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:6,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:6,h:1,c:"#FFD700",a:.2}]}});jt("bandana","Bandana",{down:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3},{x:11,y:2,w:2,h:2,c:"#E53935",a:.7},{x:12,y:3,w:1,h:1,c:"#C62828",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:1,w:10,h:2,c:"#E53935"},{x:1,y:1,w:8,h:1,c:"#EF5350",a:.3}]}});jt("eyepatch","Eye Patch",{down:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5},{x:2,y:3,w:3,h:3,c:"#1A1A1A"},{x:3,y:4,w:1,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:3,w:10,h:1,c:"#222",a:.5},{x:1,y:3,w:3,h:3,c:"#1A1A1A"},{x:2,y:4,w:1,h:1,c:"#333",a:.3}]}});jt("cat-face","Cat Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:1,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:10,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:7,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:8,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:4,y:6,w:1,h:1,c:"#444",a:.6},{x:7,y:6,w:1,h:1,c:"#444",a:.6},{x:0,y:5,w:2,h:1,c:"#888",a:.4},{x:10,y:5,w:2,h:1,c:"#888",a:.4},{x:0,y:6,w:2,h:1,c:"#888",a:.3},{x:10,y:6,w:2,h:1,c:"#888",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:5,y:1,w:2,h:5,c:"#4A4A4A",a:.3},{x:9,y:8,w:2,h:2,c:"#555"},{x:10,y:7,w:1,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#555"},{x:2,y:0,w:7,h:1,c:"#555"},{x:2,y:-2,w:3,h:2,c:"#555"},{x:3,y:-3,w:2,h:1,c:"#555"},{x:3,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#555"},{x:0,y:5,w:2,h:1,c:"#FFB0C0"},{x:-1,y:5,w:2,h:1,c:"#888",a:.4},{x:-1,y:6,w:2,h:1,c:"#888",a:.3}]}});jt("bear-face","Bear Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:3,y:5,w:6,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:7,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:7,y:3,w:1,h:1,c:"#FFF",a:.3},{x:5,y:5,w:2,h:1,c:"#222"},{x:5,y:7,w:2,h:1,c:"#6B4F10",a:.5}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:5,y:1,w:2,h:5,c:"#7A5B10",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#8B6914"},{x:2,y:-1,w:7,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:0,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:0,y:4,w:3,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:5,w:2,h:1,c:"#222"}]}});jt("panda-face","Panda Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:7,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:8,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:6,w:2,h:1,c:"#222"},{x:5,y:7,w:1,h:1,c:"#CCC",a:.4},{x:6,y:7,w:1,h:1,c:"#CCC",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:5,y:1,w:2,h:5,c:"#EEE",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#F5F5F5"},{x:2,y:-1,w:7,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#F5F5F5"},{x:1,y:6,w:1,h:1,c:"#222"}]}});jt("frog-face","Frog Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:3,c:"#4CAF50"},{x:7,y:-2,w:4,h:3,c:"#4CAF50"},{x:2,y:-1,w:2,h:2,c:"#FFF"},{x:8,y:-1,w:2,h:2,c:"#FFF"},{x:3,y:0,w:1,h:1,c:"#111"},{x:9,y:0,w:1,h:1,c:"#111"},{x:3,y:5,w:6,h:3,c:"#81C784",a:.5},{x:2,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:4,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:7,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:1,y:5,w:2,h:1,c:"#FF8A80",a:.25},{x:9,y:5,w:2,h:1,c:"#FF8A80",a:.25}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:2,c:"#4CAF50"},{x:7,y:-2,w:4,h:2,c:"#4CAF50"},{x:5,y:2,w:2,h:4,c:"#388E3C",a:.2}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#4CAF50"},{x:2,y:0,w:7,h:1,c:"#4CAF50"},{x:0,y:-2,w:4,h:3,c:"#4CAF50"},{x:1,y:-1,w:2,h:2,c:"#FFF"},{x:2,y:0,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:3,c:"#81C784",a:.5},{x:0,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:1,y:5,w:1,h:1,c:"#FF8A80",a:.25}]}});jt("rabbit-face","Rabbit Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:7,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:8,y:3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:5,y:6,w:1,h:1,c:"#DDD",a:.4},{x:6,y:6,w:1,h:1,c:"#DDD",a:.4},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6},{x:10,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:5,y:8,w:3,h:2,c:"#FFF"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#F5F5F5"},{x:2,y:0,w:7,h:1,c:"#F5F5F5"},{x:3,y:-6,w:3,h:6,c:"#F5F5F5"},{x:4,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:0,y:4,w:3,h:3,c:"#F5F5F5"},{x:1,y:5,w:1,h:1,c:"#FFB0C0"},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]}});jt("dog-face","Dog Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:3,y:5,w:6,h:4,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:7,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:7,y:2,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:2,c:"#222"},{x:5,y:7,w:2,h:2,c:"#FF6B8A",a:.8},{x:5,y:7,w:1,h:1,c:"#FF8A9E",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:5,y:0,w:2,h:6,c:"#B8883C",a:.3},{x:2,y:8,w:8,h:1,c:"#A67B3D",a:.5}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#D2A25C"},{x:2,y:-1,w:7,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:-1,y:4,w:3,h:4,c:"#D2A25C"},{x:-1,y:5,w:2,h:3,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:0,y:5,w:2,h:1,c:"#222"},{x:0,y:7,w:2,h:1,c:"#FF6B8A",a:.7}]}});const Oj={none:1,glasses:1,beret:1,cap:1,badge:1,blush:1,lapels:1,"round-glasses":2,headphones:2,scarf:3,tie:3,bowtie:3,sunglasses:4,bandana:4,eyepatch:4,crown:5,halo:5,horns:5,mask:5,"cat-ears":6,"bear-ears":6,"bunny-ears":6,"dog-nose":6,"fox-mask":6,"cat-face":7,"bear-face":7,"panda-face":7,"frog-face":8,"rabbit-face":8,"dog-face":8,"star-glasses":9};function ag(t){return Oj[t]??1}function ig(t,l){return l>=ag(t)}jt("star-glasses","Star Glasses",{down:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:7,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:8,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:8,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:2,h:1,c:"#FF4081",a:.4}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#FF4081",a:.3},{x:10,y:3,w:2,h:1,c:"#FF4081",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:6,h:1,c:"#FF4081",a:.3}]}});function vs({r:t,g:l,b:r}){return`#${(t<<16|l<<8|r).toString(16).padStart(6,"0")}`}function bc(t,l){const r=t.r-l.r,i=t.g-l.g,c=t.b-l.b;return r*r+i*i+c*c}function Bj(t,l){const r=[];r.push(t[Math.floor(Math.random()*t.length)]);for(let i=1;i<l;i++){const c=t.map(m=>{let x=1/0;for(const f of r)x=Math.min(x,bc(m,f));return x}),u=c.reduce((m,x)=>m+x,0);let d=Math.random()*u;for(let m=0;m<t.length;m++)if(d-=c[m],d<=0){r.push(t[m]);break}r.length<=i&&r.push(t[Math.floor(Math.random()*t.length)])}return r}function Lj(t,l,r=20){if(t.length===0)return[];const i=Bj(t,l);for(let u=0;u<r;u++){const d=Array.from({length:l},()=>[]);for(const x of t){let f=1/0,g=0;for(let y=0;y<l;y++){const b=bc(x,i[y]);b<f&&(f=b,g=y)}d[g].push(x)}let m=!0;for(let x=0;x<l;x++){if(d[x].length===0)continue;const f={r:0,g:0,b:0};for(const b of d[x])f.r+=b.r,f.g+=b.g,f.b+=b.b;const g=d[x].length,y={r:Math.round(f.r/g),g:Math.round(f.g/g),b:Math.round(f.b/g)};bc(y,i[x])>1&&(m=!1),i[x]=y}if(m)break}const c=new Array(l).fill(0);for(const u of t){let d=1/0,m=0;for(let x=0;x<l;x++){const f=bc(u,i[x]);f<d&&(d=f,m=x)}c[m]++}return i.map((u,d)=>({c:u,count:c[d]})).sort((u,d)=>d.count-u.count).map(u=>u.c)}function $j(t,l=1e4){const r=document.createElement("canvas"),i=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;r.width=i,r.height=c;const u=r.getContext("2d");u.drawImage(t,0,0);const d=u.getImageData(0,0,i,c).data,m=i*c,x=Math.max(1,Math.floor(m/l)),f=[];for(let g=0;g<m;g+=x){const y=g*4;d[y+3]<128||f.push({r:d[y],g:d[y+1],b:d[y+2]})}return f}function c0(t){return .299*t.r+.587*t.g+.114*t.b}function u0(t){const l=Math.max(t.r,t.g,t.b),r=Math.min(t.r,t.g,t.b);return l===0?0:(l-r)/l*255}function Hj(t,l=8){const r=$j(t),i=Lj(r,l);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const c=[...i].sort((y,b)=>c0(b)-c0(y)),u=[...i].sort((y,b)=>u0(b)-u0(y)),d=c[0],m=c[c.length-1],x=u[0],f=c[c.length-2],g=c[c.length-1];return{skinColor:vs(d),hairColor:vs(m),shirtColor:vs(x),pantsColor:vs(f),shoeColor:vs(g)}}const Uj=[{x:1,y:19,w:10,h:2,c:"#100A06",a:.15},{x:2,y:15,w:3,h:4,c:"$pants"},{x:7,y:15,w:3,h:4,c:"$pants"},{x:2,y:19,w:3,h:2,c:"$shoes"},{x:7,y:19,w:3,h:2,c:"$shoes"},{x:2,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4},{x:7,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4}],Ij=[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}],Yj=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}],qj=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function Xj(){return{width:12,height:22,layers:[{name:"lower",pixels:Uj},{name:"torso",pixels:Ij},{name:"head",pixels:Yj},{name:"hair",pixels:qj},{name:"accessory",pixels:[]}]}}const Vj=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const t of Vj)eg(`mini:${t}`,Xj());const Gj=[{x:1,y:10,w:10,h:8,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"}],Kj=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}],Qj=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function Wj(){return{width:12,height:22,layers:[{name:"torso",pixels:Gj},{name:"head",pixels:Kj},{name:"hair",pixels:Qj},{name:"accessory",pixels:[]}]}}eg("mini-seated:default",Wj());const Zj={canvasWidth:160,canvasHeight:80,scale:2,pixels:[{x:0,y:0,w:80,h:40,c:"#1e2030"},{x:10,y:2,w:10,h:6,c:"#78889c"},{x:10,y:2,w:10,h:1,c:"#8899ad"},{x:24,y:0,w:10,h:6,c:"#78889c"},{x:24,y:0,w:10,h:1,c:"#8899ad"},{x:38,y:2,w:10,h:6,c:"#78889c"},{x:38,y:2,w:10,h:1,c:"#8899ad"},{x:54,y:2,w:10,h:6,c:"#78889c"},{x:54,y:2,w:10,h:1,c:"#8899ad"},{x:11,y:7,w:2,h:2,c:"#2a2a2a"},{x:17,y:7,w:2,h:2,c:"#2a2a2a"},{x:25,y:5,w:2,h:2,c:"#2a2a2a"},{x:31,y:5,w:2,h:2,c:"#2a2a2a"},{x:39,y:7,w:2,h:2,c:"#2a2a2a"},{x:45,y:7,w:2,h:2,c:"#2a2a2a"},{x:55,y:7,w:2,h:2,c:"#2a2a2a"},{x:61,y:7,w:2,h:2,c:"#2a2a2a"},{x:8,y:8,w:64,h:24,c:"#6b5b4b"},{x:4,y:10,w:72,h:20,c:"#7d6d5d"},{x:2,y:12,w:76,h:16,c:"#7d6d5d"},{x:2,y:12,w:76,h:2,c:"#8b7b6b"},{x:2,y:26,w:76,h:2,c:"#4b3b2b"},{x:2,y:28,w:76,h:3,c:"#4b3b2b"},{x:4,y:28,w:72,h:1,c:"#5b4b3b"},{x:6,y:30,w:3,h:2,c:"#3a2a1a"},{x:71,y:30,w:3,h:2,c:"#3a2a1a"},{x:18,y:14,w:44,h:12,c:"#6b5b4b",a:.5},{x:28,y:14,w:14,h:8,c:"#1a1a2e"},{x:29,y:15,w:12,h:6,c:"#1565C0",a:.5},{x:30,y:16,w:8,h:1,c:"#60A5FA",a:.45},{x:30,y:18,w:5,h:1,c:"#60A5FA",a:.3},{x:58,y:16,w:5,h:5,c:"#795548"},{x:59,y:17,w:3,h:3,c:"#A67C52"},{x:63,y:18,w:2,h:2,c:"#795548"},{x:10,y:16,w:10,h:8,c:"#FFEE58",a:.7},{x:11,y:17,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:19,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:21,w:6,h:1,c:"#9E9E9E",a:.5},{x:10,y:32,w:10,h:6,c:"#78889c"},{x:10,y:32,w:10,h:1,c:"#8899ad"},{x:24,y:34,w:10,h:6,c:"#78889c"},{x:24,y:34,w:10,h:1,c:"#8899ad"},{x:38,y:32,w:10,h:6,c:"#78889c"},{x:38,y:32,w:10,h:1,c:"#8899ad"},{x:54,y:32,w:10,h:6,c:"#78889c"},{x:54,y:32,w:10,h:1,c:"#8899ad"},{x:11,y:37,w:2,h:2,c:"#2a2a2a"},{x:17,y:37,w:2,h:2,c:"#2a2a2a"},{x:25,y:39,w:2,h:2,c:"#2a2a2a"},{x:31,y:39,w:2,h:2,c:"#2a2a2a"},{x:39,y:37,w:2,h:2,c:"#2a2a2a"},{x:45,y:37,w:2,h:2,c:"#2a2a2a"},{x:55,y:37,w:2,h:2,c:"#2a2a2a"},{x:61,y:37,w:2,h:2,c:"#2a2a2a"}]},Jj={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:0,y:0,w:64,h:48,c:"#4b3b2b"},{x:3,y:3,w:58,h:42,c:"#8B7355"},{x:4,y:4,w:10,h:10,c:"#A0845C",a:.5},{x:20,y:8,w:8,h:8,c:"#A0845C",a:.4},{x:40,y:6,w:12,h:6,c:"#A0845C",a:.3},{x:8,y:30,w:14,h:10,c:"#A0845C",a:.25},{x:44,y:32,w:10,h:8,c:"#A0845C",a:.3},{x:6,y:8,w:18,h:12,c:"#FFEE58"},{x:5,y:7,w:3,h:3,c:"#EF5350"},{x:6,y:7,w:2,h:2,c:"#C62828"},{x:8,y:10,w:14,h:1,c:"#9E9E9E"},{x:8,y:12,w:12,h:1,c:"#9E9E9E"},{x:8,y:14,w:10,h:1,c:"#9E9E9E"},{x:28,y:6,w:16,h:14,c:"#B3E5FC"},{x:35,y:5,w:3,h:3,c:"#42A5F5"},{x:36,y:5,w:2,h:2,c:"#1565C0"},{x:30,y:9,w:12,h:1,c:"#9E9E9E"},{x:30,y:11,w:10,h:1,c:"#9E9E9E"},{x:30,y:13,w:11,h:1,c:"#9E9E9E"},{x:8,y:24,w:16,h:14,c:"#C8E6C9"},{x:15,y:23,w:3,h:3,c:"#66BB6A"},{x:16,y:23,w:2,h:2,c:"#388E3C"},{x:10,y:27,w:12,h:1,c:"#9E9E9E"},{x:10,y:29,w:8,h:1,c:"#9E9E9E"},{x:10,y:31,w:10,h:1,c:"#9E9E9E"},{x:28,y:24,w:28,h:16,c:"#FFCDD2"},{x:43,y:23,w:3,h:3,c:"#EF5350"},{x:44,y:23,w:2,h:2,c:"#B71C1C"},{x:32,y:27,w:24,h:1,c:"#9E9E9E"},{x:32,y:29,w:20,h:1,c:"#9E9E9E"},{x:32,y:31,w:22,h:1,c:"#9E9E9E"},{x:32,y:33,w:15,h:1,c:"#9E9E9E"},{x:0,y:0,w:64,h:3,c:"#5a4a3a"},{x:0,y:45,w:64,h:3,c:"#3a2a1a"}]},Pj={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:2,y:0,w:60,h:48,c:"#3b1f0a"},{x:4,y:2,w:56,h:44,c:"#5a3310"},{x:4,y:13,w:56,h:2,c:"#2d1508"},{x:4,y:27,w:56,h:2,c:"#2d1508"},{x:4,y:41,w:56,h:2,c:"#2d1508"},{x:5,y:3,w:4,h:10,c:"#2563EB"},{x:5,y:3,w:4,h:2,c:"#1D4ED8"},{x:10,y:4,w:3,h:9,c:"#DC2626"},{x:10,y:4,w:3,h:2,c:"#B91C1C"},{x:14,y:3,w:5,h:10,c:"#16A34A"},{x:14,y:3,w:5,h:2,c:"#15803D"},{x:20,y:4,w:3,h:9,c:"#9333EA"},{x:20,y:4,w:3,h:2,c:"#7E22CE"},{x:24,y:3,w:4,h:10,c:"#D97706"},{x:24,y:3,w:4,h:2,c:"#B45309"},{x:29,y:4,w:3,h:9,c:"#0891B2"},{x:29,y:4,w:3,h:2,c:"#0E7490"},{x:33,y:3,w:5,h:10,c:"#BE123C"},{x:33,y:3,w:5,h:2,c:"#9F1239"},{x:39,y:4,w:4,h:9,c:"#4F46E5"},{x:39,y:4,w:4,h:2,c:"#3730A3"},{x:44,y:3,w:3,h:10,c:"#065F46"},{x:44,y:3,w:3,h:2,c:"#064E3B"},{x:48,y:4,w:4,h:9,c:"#92400E"},{x:48,y:4,w:4,h:2,c:"#78350F"},{x:53,y:3,w:5,h:10,c:"#1E3A5F"},{x:53,y:3,w:5,h:2,c:"#1e3060"},{x:6,y:6,w:2,h:1,c:"#BFDBFE",a:.7},{x:11,y:7,w:1,h:1,c:"#FCA5A5",a:.7},{x:16,y:6,w:3,h:1,c:"#BBF7D0",a:.7},{x:21,y:7,w:1,h:1,c:"#D8B4FE",a:.7},{x:25,y:6,w:2,h:1,c:"#FDE68A",a:.7},{x:5,y:16,w:5,h:11,c:"#0F766E"},{x:5,y:16,w:5,h:2,c:"#0D6056"},{x:11,y:17,w:3,h:10,c:"#C2410C"},{x:11,y:17,w:3,h:2,c:"#9A3412"},{x:15,y:16,w:4,h:11,c:"#7C3AED"},{x:15,y:16,w:4,h:2,c:"#6D28D9"},{x:20,y:17,w:3,h:10,c:"#1D4ED8"},{x:20,y:17,w:3,h:2,c:"#1E40AF"},{x:24,y:16,w:5,h:11,c:"#166534"},{x:24,y:16,w:5,h:2,c:"#14532D"},{x:30,y:17,w:4,h:10,c:"#991B1B"},{x:30,y:17,w:4,h:2,c:"#7F1D1D"},{x:35,y:16,w:3,h:11,c:"#854D0E"},{x:35,y:16,w:3,h:2,c:"#713F12"},{x:39,y:17,w:4,h:10,c:"#1E40AF"},{x:39,y:17,w:4,h:2,c:"#1E3A8A"},{x:44,y:16,w:5,h:11,c:"#065F46"},{x:44,y:16,w:5,h:2,c:"#064E3B"},{x:50,y:17,w:3,h:10,c:"#831843"},{x:50,y:17,w:3,h:2,c:"#6B21A8"},{x:54,y:16,w:5,h:11,c:"#374151"},{x:54,y:16,w:5,h:2,c:"#1F2937"},{x:5,y:30,w:4,h:11,c:"#0E7490"},{x:5,y:30,w:4,h:2,c:"#0C6B7E"},{x:10,y:31,w:3,h:10,c:"#B45309"},{x:10,y:31,w:3,h:2,c:"#92400E"},{x:14,y:30,w:5,h:11,c:"#6D28D9"},{x:14,y:30,w:5,h:2,c:"#5B21B6"},{x:20,y:30,w:7,h:8,c:"#1e293b"},{x:22,y:32,w:3,h:3,c:"#3b82f6",a:.9},{x:22,y:32,w:1,h:3,c:"#60a5fa",a:.6},{x:28,y:31,w:4,h:10,c:"#DC2626"},{x:28,y:31,w:4,h:2,c:"#B91C1C"},{x:33,y:30,w:3,h:11,c:"#065F46"},{x:33,y:30,w:3,h:2,c:"#064E3B"},{x:37,y:31,w:4,h:10,c:"#1D4ED8"},{x:37,y:31,w:4,h:2,c:"#1E40AF"},{x:42,y:35,w:6,h:6,c:"#92400E"},{x:43,y:30,w:4,h:6,c:"#16a34a",a:.8},{x:43,y:29,w:2,h:3,c:"#15803d",a:.7},{x:45,y:28,w:2,h:4,c:"#16a34a",a:.6},{x:49,y:30,w:3,h:11,c:"#7C3AED"},{x:49,y:30,w:3,h:2,c:"#6D28D9"},{x:53,y:31,w:5,h:10,c:"#B45309"},{x:53,y:31,w:5,h:2,c:"#92400E"},{x:2,y:46,w:60,h:2,c:"#1a0a03"},{x:2,y:0,w:60,h:2,c:"#4a2510"},{x:2,y:0,w:2,h:48,c:"#2d1508"},{x:60,y:0,w:2,h:48,c:"#2d1508"}]},eS={canvasWidth:96,canvasHeight:120,scale:2,pixels:[{x:2,y:0,w:44,h:60,c:"#546E7A"},{x:2,y:0,w:44,h:3,c:"#78909C"},{x:2,y:57,w:44,h:3,c:"#37474F"},{x:2,y:0,w:2,h:60,c:"#455A64"},{x:44,y:0,w:2,h:60,c:"#37474F"},{x:5,y:4,w:38,h:3,c:"#FFD54F",a:.5},{x:6,y:1,w:2,h:4,c:"#FFFDE7"},{x:10,y:0,w:2,h:5,c:"#FFF9C4"},{x:14,y:1,w:2,h:3,c:"#FFFDE7"},{x:18,y:0,w:2,h:4,c:"#FFF8E1"},{x:5,y:5,w:38,h:16,c:"#607D8B"},{x:5,y:5,w:38,h:2,c:"#78909C"},{x:15,y:12,w:18,h:4,c:"#37474F"},{x:22,y:11,w:4,h:6,c:"#455A64"},{x:23,y:13,w:2,h:2,c:"#B0BEC5"},{x:7,y:14,w:8,h:5,c:"#B0BEC5"},{x:8,y:15,w:6,h:1,c:"#607D8B"},{x:8,y:17,w:5,h:1,c:"#607D8B"},{x:5,y:23,w:38,h:16,c:"#607D8B"},{x:5,y:23,w:38,h:2,c:"#78909C"},{x:15,y:30,w:18,h:4,c:"#37474F"},{x:22,y:29,w:4,h:6,c:"#455A64"},{x:23,y:31,w:2,h:2,c:"#B0BEC5"},{x:7,y:32,w:8,h:5,c:"#B0BEC5"},{x:8,y:33,w:6,h:1,c:"#607D8B"},{x:8,y:35,w:4,h:1,c:"#607D8B"},{x:5,y:41,w:38,h:16,c:"#607D8B"},{x:5,y:41,w:38,h:2,c:"#78909C"},{x:15,y:48,w:18,h:4,c:"#37474F"},{x:22,y:47,w:4,h:6,c:"#455A64"},{x:23,y:49,w:2,h:2,c:"#B0BEC5"},{x:7,y:50,w:8,h:5,c:"#B0BEC5"},{x:8,y:51,w:6,h:1,c:"#607D8B"},{x:8,y:53,w:3,h:1,c:"#607D8B"}]};$c("meeting",Zj);$c("bulletin",Jj);$c("decision",eS);$c("knowledge",Pj);const xf=16,pf=24,tS=60,nS={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function sg(t,l){if(!t)return t;let r=t;if(l!=null&&l.hairStyle){const i=Mj(l.hairStyle);i&&(r=Aj(r,i.layer))}if(l!=null&&l.outfitStyle){const i=Fj(l.outfitStyle);i&&(r=Gf(r,"torso",i.layer,1))}if(l!=null&&l.accessory&&l.accessory!=="none"){const i=Rj(l.accessory);i&&(r=Gf(r,"accessory",i.layer))}return r}function _s({roleId:t,className:l,appearance:r,scale:i}){const c=k.useRef(null),u=k.useRef(0),d=k.useRef(0),m=k.useRef(r);m.current=r;const x=i??4,f=xf*x,g=pf*x,y=k.useMemo(()=>{const b=Kf(`mini:${t}`)??Kf("mini:default");return sg(b,r)},[t,r==null?void 0:r.hairStyle,r==null?void 0:r.outfitStyle,r==null?void 0:r.accessory]);return k.useEffect(()=>{const b=c.current;if(!b)return;const v=b.getContext("2d");if(!v)return;const S=nS[t]??0,j=()=>{d.current++;const E=m.current;if(!E||!y){u.current=requestAnimationFrame(j);return}const A=(d.current+S)%tS<30?1:0;v.clearRect(0,0,xf,pf),v.save(),v.translate(2,1),Dj(v,y,A,E,1),v.restore(),u.current=requestAnimationFrame(j)};return u.current=requestAnimationFrame(j),()=>cancelAnimationFrame(u.current)},[t,y]),s.jsx("canvas",{ref:c,width:xf,height:pf,className:l,style:{imageRendering:"pixelated",display:"block",width:f,height:g}})}const lS="https://api.tycono.ai",Ch=lS;async function ac(t){const l=await fetch(`${Ch}${t}`);if(!l.ok)throw new Error(`Cloud API error: ${l.status}`);return l.json()}async function ic(t,l){const r=await fetch(`${Ch}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!r.ok)throw new Error(`Cloud API error: ${r.status}`);return r.json()}const mi={health:()=>ac("/api/health"),getCharacters:()=>ac("/api/store/characters"),getCharacter:t=>ac(`/api/store/characters/${t}`),getCharacterVersion:t=>ac(`/api/store/characters/${t}/version`),syncCheck:t=>ic("/api/sync/check",{roles:t}),syncPull:t=>ic("/api/sync/pull",{sourceId:t}),publishCharacter:t=>ic("/api/store/publish",t),deleteCharacter:t=>fetch(`${Ch}/api/store/characters/${t}`,{method:"DELETE"}).then(l=>l.json()),uploadTelemetry:t=>ic("/api/telemetry",t)},rS={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},yf={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},aS={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},iS=500,d0=360,f0=700,sS=t=>`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`;function oS({role:t,allRoles:l,recentActivity:r,onClose:i,onFireRole:c,terminalWidth:u=0,activeJobId:d,activeTask:m,isWorking:x,jobStartedAt:f,onStopJob:g,sessions:y,streamingSessionId:b,onCreateSessionSilent:v,onSendMessage:S,onFocusTerminal:j,onCustomize:E,onUpdateRole:C,appearance:A,relationships:F,roleLevel:_}){var Te,Ye;const[H,M]=k.useState(iS),[I,W]=k.useState(!1),te=k.useRef(0),D=k.useRef(0),[Y,B]=k.useState(!1),[V,ne]=k.useState(!1),[G,L]=k.useState(!1),[Z,de]=k.useState(!1),[ue,z]=k.useState("talk"),[R,K]=k.useState(!1),[T,fe]=k.useState(""),[Ee,Ne]=k.useState(!1),Le=k.useRef(null),{events:Be,status:Qe}=K0(d??null),[Se,tt]=k.useState(0);k.useEffect(()=>{if(!x||!f){tt(0);return}const xe=new Date(f).getTime(),q=()=>tt(Math.floor((Date.now()-xe)/1e3));q();const ze=setInterval(q,1e3);return()=>clearInterval(ze)},[x,f]);const me=u>0,he=me?u:0,ge=me?Math.max(d0,window.innerWidth-u-100):f0,ke=Math.min(H,ge),Fe=k.useCallback(xe=>{xe.preventDefault(),te.current=xe.clientX,D.current=ke,W(!0);const q=He=>{const Xe=te.current-He.clientX,ht=Math.min(f0,Math.max(d0,D.current+Xe));M(ht)},ze=()=>{W(!1),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ze)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",ze)},[ke]),Ae=k.useRef(null),De=t?y.find(xe=>xe.roleId===t.id):null,je=xe=>{if(!t)return;const q=x?"talk":ue;De?(S(De.id,xe,q),j(t.id)):(Ae.current={content:xe,mode:q},v(t.id))};k.useEffect(()=>{if(De&&Ae.current){const{content:xe,mode:q}=Ae.current;Ae.current=null,S(De.id,xe,q),t&&j(t.id)}},[De==null?void 0:De.id]);const _e=(()=>{if(!Be.length)return null;const xe=[];let q=0,ze=0,He=0;for(const Xe of Be)if(Xe.type==="thinking")q++;else if(Xe.type==="text")ze++;else if(Xe.type==="tool:start"){const ht=String(Xe.data.name??"");xe.includes(ht)||xe.push(ht)}else Xe.type==="dispatch:start"&&He++;return{tools:xe,thinkCount:q,textCount:ze,dispatchCount:He,total:Be.length}})(),Ke=m||(()=>{if(!De)return null;const xe=De.messages;for(let q=xe.length-1;q>=0;q--)if(xe[q].from==="ceo")return xe[q].content;return null})(),Et=(()=>{if(!De)return null;const xe=De.messages;for(let q=xe.length-1;q>=0;q--)if(xe[q].from==="role"&&xe[q].content)return xe[q].content;return null})();if(!t)return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:he},onClick:i}),s.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px]",style:{right:he,width:ke,background:"var(--terminal-bg)",borderLeftColor:"var(--pixel-border)"},children:s.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading role..."})})]});const Ht=yf[t.id]??"#666",gt=rS[t.id]??"👤",Rt=l.filter(xe=>xe.reportsTo===t.id),re=De&&b===De.id,pe=t.name||aS[t.id]||t.id;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:he},onClick:i}),s.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${I?"resizing":""}`,style:{borderLeftColor:Ht,right:he,width:ke,background:"var(--terminal-bg)"},children:[s.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${I?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:Fe}),s.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Ht}ee, ${Ht}99)`},children:[s.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 8px, white 8px, white 9px)"}}),s.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1.5 z-10",children:[E&&s.jsx("button",{onClick:()=>E(t.id),className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-sm hover:bg-black/30 cursor-pointer backdrop-blur-sm",title:"Customize",children:"🎨"}),s.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-lg hover:bg-black/30 cursor-pointer backdrop-blur-sm",children:"×"})]}),s.jsxs("div",{className:"relative flex items-end gap-4 px-4 pt-4 pb-3",children:[s.jsx("div",{className:"shrink-0 relative",style:{marginBottom:-2},children:s.jsx("div",{className:"rounded-lg p-1",style:{background:"rgba(0,0,0,0.2)"},children:s.jsx(_s,{roleId:t.id,appearance:A,scale:8})})}),s.jsxs("div",{className:"flex-1 min-w-0 text-white pb-1",children:[s.jsxs("div",{className:"text-lg font-bold flex items-center gap-2",style:{fontFamily:"var(--pixel-font)"},children:[gt," ",t.id.toUpperCase(),x&&s.jsx("span",{className:"text-[9px] font-semibold px-2 py-0.5 rounded-full animate-pulse",style:{background:"rgba(251,191,36,0.25)",color:"#fde68a"},children:"WORKING"})]}),R?s.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async xe=>{xe.preventDefault();const q=T.trim();if(!q||q===pe||!C){K(!1);return}Ne(!0);try{await C(t.id,{name:q})}catch{}Ne(!1),K(!1)},children:[s.jsx("input",{ref:Le,value:T,onChange:xe=>fe(xe.target.value),onKeyDown:xe=>{xe.key==="Escape"&&K(!1)},disabled:Ee,autoFocus:!0,className:"bg-white/20 text-white text-xs rounded px-1.5 py-0.5 outline-none focus:bg-white/30 w-full",style:{fontFamily:"inherit"}}),s.jsx("button",{type:"submit",disabled:Ee,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✓"}),s.jsx("button",{type:"button",onClick:()=>K(!1),className:"text-white/60 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✕"})]}):s.jsxs("div",{className:"text-xs opacity-75 mt-0.5 group/name flex items-center gap-1 cursor-pointer hover:opacity-100 transition-opacity",onClick:()=>{C&&(fe(pe),K(!0))},title:C?"Click to edit name":void 0,children:[pe,C&&s.jsx("span",{className:"opacity-0 group-hover/name:opacity-60 text-[10px]",children:"✎"})]})]})]}),s.jsxs("div",{className:"relative flex items-center gap-3 px-4 py-2 text-[10px] font-bold text-white/80",style:{background:"rgba(0,0,0,0.2)",fontFamily:"var(--pixel-font)"},children:[s.jsxs("span",{children:["Lv.",_??1]}),s.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x?"var(--idle-amber)":"var(--active-green)"}}),x?"Working":"Idle"]}),s.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),s.jsx("span",{children:t.level}),t.reportsTo&&s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),s.jsxs("span",{className:"opacity-60",children:["→"," ",t.reportsTo]})]})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[x&&s.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--idle-amber)"}}),s.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--idle-amber)"},children:["Working",Se>0?` · ${sS(Se)}`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>j(t.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"}),d&&g&&s.jsx("button",{onClick:()=>g(d),className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold transition-colors",style:{background:"rgba(239,68,68,0.15)",color:"#ef4444"},children:"Stop"})]})]}),Ke&&s.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:Ke})]}),x&&d&&_e&&s.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[s.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Activity"}),s.jsx("button",{onClick:()=>j(t.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"View details ↗"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[_e.thinkCount>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(168,85,247,0.15)",color:"#c084fc"},children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:"#a855f7"}}),"thinking ×",_e.thinkCount]}),_e.tools.map(xe=>s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(59,130,246,0.15)",color:"#60a5fa"},children:xe},xe)),_e.dispatchCount>0&&s.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(249,115,22,0.15)",color:"#fb923c"},children:["dispatch ×",_e.dispatchCount]}),_e.textCount>0&&s.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(34,197,94,0.15)",color:"#4ade80"},children:["output ×",_e.textCount]}),(Qe==="streaming"||Qe==="connecting")&&s.jsx("span",{className:"inline-block w-1.5 h-3 animate-pulse rounded-sm",style:{background:"var(--active-green)"}})]}),s.jsxs("div",{className:"text-[10px] mt-1",style:{color:"var(--terminal-text-muted)"},children:[_e.total," events"]})]}),x&&Et&&s.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[s.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Last Message"}),s.jsx("button",{onClick:()=>j(t.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"})]}),s.jsxs("div",{className:"rounded-lg p-2.5 text-xs leading-relaxed line-clamp-3 overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[Et.slice(0,200),Et.length>200&&"..."]})]}),x&&s.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:s.jsx(h0,{onSend:je,disabled:!!re,placeholder:"Ask something...",color:Ht})}),!x&&s.jsxs("div",{className:"px-4 pt-4 pb-2",children:[s.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-secondary)"},children:"Latest"}),s.jsx(uS,{icon:gt,roleId:t.id,roleName:pe,color:Ht,text:r})]}),!x&&s.jsx("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--terminal-border)"},children:s.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[Et&&s.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>j(t.id),children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"Last response"}),s.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:"View ↗"})]}),s.jsxs("div",{className:"text-xs leading-relaxed line-clamp-2 overflow-hidden",style:{color:"var(--terminal-text-secondary)"},children:[Et.slice(0,150),Et.length>150&&"..."]})]}),s.jsx("div",{className:"p-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex rounded-lg overflow-hidden shrink-0",style:{border:"1px solid var(--pixel-border)"},children:[s.jsx("button",{onClick:()=>z("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:ue==="talk"?"var(--accent)":"transparent",color:ue==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),s.jsx("button",{onClick:()=>z("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:ue==="do"?"var(--idle-amber)":"transparent",color:ue==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),s.jsx(h0,{onSend:je,disabled:!!re,placeholder:ue==="talk"?"Ask something...":"Give a directive...",color:Ht})]})})]})}),s.jsxs("div",{className:"px-4 py-2 space-y-1",children:[s.jsxs(sc,{title:`Profile${t.persona?"":" (empty)"}`,open:Y,onToggle:()=>B(xe=>!xe),children:[t.persona&&s.jsx("div",{className:"text-xs leading-relaxed rounded-lg p-3",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:t.persona}),s.jsxs("div",{className:"space-y-0 mt-2",children:[s.jsx(gf,{label:"Level",value:t.level}),s.jsx(gf,{label:"Reports to",value:t.reportsTo}),s.jsx(gf,{label:"Status",value:t.status})]}),Rt.length>0&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"text-[11px] font-semibold mb-1",style:{color:"var(--terminal-text-muted)"},children:"Direct Reports"}),s.jsx("div",{className:"space-y-1",children:Rt.map(xe=>s.jsxs("div",{className:"flex items-center gap-2 p-1.5 rounded-lg",style:{background:"var(--hud-bg-alt)"},children:[s.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center text-white text-[10px] font-bold",style:{background:yf[xe.id]??"#666"},children:xe.id.slice(0,2).toUpperCase()}),s.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text)"},children:xe.name})]},xe.id))})]})]}),t.authority&&s.jsxs(sc,{title:"Authority",open:V,onToggle:()=>ne(xe=>!xe),children:[((Te=t.authority.autonomous)==null?void 0:Te.length)>0&&s.jsxs("div",{className:"mb-2",children:[s.jsx("div",{className:"text-xs font-semibold mb-1",style:{color:"var(--active-green)"},children:"Autonomous"}),t.authority.autonomous.map((xe,q)=>s.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",xe]},q))]}),((Ye=t.authority.needsApproval)==null?void 0:Ye.length)>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-semibold mb-1",style:{color:"var(--idle-amber)"},children:"Needs Approval"}),t.authority.needsApproval.map((xe,q)=>s.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",xe]},q))]})]}),t&&F&&(()=>{const xe=F.filter(q=>q.roleA===t.id||q.roleB===t.id).filter(q=>q.familiarity>0).sort((q,ze)=>ze.familiarity-q.familiarity);return xe.length===0?null:s.jsx(sc,{title:`Relationships (${xe.length})`,open:G,onToggle:()=>L(q=>!q),children:s.jsx("div",{className:"space-y-1.5",children:xe.map((q,ze)=>{const He=q.roleA===t.id?q.roleB:q.roleA,Xe=l.find(We=>We.id===He),ht=q.familiarity>=80?"Best Partner":q.familiarity>=50?"Friend":q.familiarity>=20?"Colleague":"Acquaintance",Pe=q.familiarity>=80?"#4CAF50":q.familiarity>=50?"#2196F3":q.familiarity>=20?"#FF9800":"#9E9E9E";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs w-20 truncate",style:{color:yf[He]??"var(--terminal-text-secondary)"},children:(Xe==null?void 0:Xe.name)??He}),s.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-white/10",children:s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${q.familiarity}%`,background:Pe}})}),s.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:ht})]},ze)})})})})(),t.journal&&s.jsx(sc,{title:`Journal (${(t.journal.match(/### /g)??[]).length})`,open:Z,onToggle:()=>de(xe=>!xe),children:s.jsxs("div",{className:"text-xs leading-relaxed rounded-lg p-3 max-h-[300px] overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[s.jsx(Is,{content:t.journal.slice(0,3e3)}),t.journal.length>3e3&&s.jsx("div",{className:"italic mt-2",style:{color:"var(--terminal-text-muted)"},children:"... (truncated)"})]})})]}),s.jsx(cS,{role:t,appearance:A}),c&&s.jsx("div",{className:"px-4 pb-4 mt-auto shrink-0",children:s.jsx("button",{onClick:()=>{c(t.id,t.name),i()},className:"w-full p-2 text-center text-xs font-medium border-2 border-dashed rounded-lg cursor-pointer transition-colors",style:{borderColor:"rgba(239,68,68,0.3)",color:"rgba(239,68,68,0.5)"},children:"Fire Role"})})]})]})]})}function cS({role:t,appearance:l}){const[r,i]=k.useState("idle"),[c,u]=k.useState(""),[d,m]=k.useState(!1),x=async()=>{var f,g;if(!d){m(!0);return}i("publishing");try{let y=null;try{y=await Ce.exportSkills(t.id)}catch{}const b={roleId:t.id,persona:t.persona??"",authority:t.authority??{autonomous:[],needsApproval:[]},level:t.level,tagline:((f=(t.persona??"").split(/[.\n]/)[0])==null?void 0:f.trim().slice(0,80))||t.name,chatStyle:"Professional and focused",skills:y??[],resume:{summary:((g=t.persona)==null?void 0:g.split(`
80
80
  `)[0])??"",strengths:[],specialties:[],experience:""},author:{id:"tycono",name:"Tycono"},tags:[t.level,t.id],price:"free",installs:0,rating:0,featured:!1,randomActive:!0,randomPersonality:""};l&&(b.appearance=l);let v="1.0.0";try{const S=await mi.getCharacterVersion(t.id);if(S!=null&&S.version){const j=S.version.split(".").map(Number);j[2]=(j[2]??0)+1,v=j.join(".")}}catch{}await mi.publishCharacter({id:t.id,name:t.name||t.id,version:v,data:b}),i("done"),u(`Published v${v}`),m(!1)}catch(y){i("error"),u(y instanceof Error?y.message:"Failed"),m(!1)}};return s.jsx("div",{className:"px-4 pb-2 shrink-0",children:s.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:s.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between",style:{background:"var(--hud-bg-alt)"},children:[s.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Cloud Store"}),r==="done"?s.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--active-green)"},children:c}):r==="error"?s.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#ef4444"},children:c}):s.jsx("button",{onClick:x,disabled:r==="publishing",className:"text-[10px] px-2.5 py-1 rounded font-semibold cursor-pointer transition-colors disabled:opacity-50",style:{background:d?"rgba(59,130,246,0.3)":"rgba(59,130,246,0.15)",color:"#60a5fa",border:d?"1px solid rgba(59,130,246,0.5)":"1px solid transparent"},children:r==="publishing"?"Publishing...":d?"Confirm Publish?":"Publish to Store"})]})})})}function uS({icon:t,roleId:l,roleName:r,color:i,text:c}){const u=!!c;return s.jsx("div",{className:"relative",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"shrink-0",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center text-xl shadow-sm",style:{background:`${i}18`,border:`2px solid ${i}44`},children:t}),s.jsx("div",{className:"text-[9px] font-bold text-center mt-0.5 uppercase tracking-wide",style:{color:i},children:l})]}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"absolute top-3 -left-2 w-0 h-0",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:`8px solid ${i}12`}}),s.jsxs("div",{className:"rounded-xl rounded-tl-sm p-4 border",style:{background:`${i}08`,borderColor:`${i}22`},children:[s.jsx("div",{className:"text-[10px] font-semibold mb-1.5 uppercase tracking-wider",style:{color:i},children:r}),u?s.jsx("div",{className:"text-sm leading-relaxed",style:{color:"var(--terminal-text)"},children:s.jsx(Is,{content:c})}):s.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function sc({title:t,open:l,onToggle:r,children:i}){return s.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[s.jsxs("button",{onClick:r,className:"w-full px-3 py-2.5 flex items-center justify-between cursor-pointer transition-colors group",style:{background:"var(--hud-bg-alt)"},children:[s.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:t}),s.jsx("span",{className:"text-[10px] transition-transform",style:{color:"var(--terminal-text-muted)",transform:l?"rotate(0deg)":"rotate(-90deg)"},children:"▼"})]}),l&&s.jsx("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:i})]})}function h0({onSend:t,disabled:l,placeholder:r,color:i}){const[c,u]=k.useState(""),d=()=>{const m=c.trim();!m||l||(t(m),u(""))};return s.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[s.jsx("input",{type:"text",value:c,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),d())},placeholder:l?"Waiting...":r,disabled:l,className:"flex-1 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none disabled:opacity-40",style:{background:"var(--hud-bg)",border:"1px solid var(--pixel-border)",color:"var(--terminal-text)"}}),s.jsx("button",{onClick:d,disabled:l||!c.trim(),className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 cursor-pointer text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:l||!c.trim()?"#666":i},children:s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M22 2L11 13"}),s.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})}function gf({label:t,value:l}){return s.jsxs("div",{className:"flex justify-between py-1.5 text-xs",style:{borderBottom:"1px solid var(--terminal-border)"},children:[s.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:t}),s.jsx("span",{className:"font-semibold",style:{color:"var(--terminal-text)"},children:l})]})}function dS(t,l){var r,i=1;t==null&&(t=0),l==null&&(l=0);function c(){var u,d=r.length,m,x=0,f=0;for(u=0;u<d;++u)m=r[u],x+=m.x,f+=m.y;for(x=(x/d-t)*i,f=(f/d-l)*i,u=0;u<d;++u)m=r[u],m.x-=x,m.y-=f}return c.initialize=function(u){r=u},c.x=function(u){return arguments.length?(t=+u,c):t},c.y=function(u){return arguments.length?(l=+u,c):l},c.strength=function(u){return arguments.length?(i=+u,c):i},c}function fS(t){const l=+this._x.call(null,t),r=+this._y.call(null,t);return og(this.cover(l,r),l,r,t)}function og(t,l,r,i){if(isNaN(l)||isNaN(r))return t;var c,u=t._root,d={data:i},m=t._x0,x=t._y0,f=t._x1,g=t._y1,y,b,v,S,j,E,C,A;if(!u)return t._root=d,t;for(;u.length;)if((j=l>=(y=(m+f)/2))?m=y:f=y,(E=r>=(b=(x+g)/2))?x=b:g=b,c=u,!(u=u[C=E<<1|j]))return c[C]=d,t;if(v=+t._x.call(null,u.data),S=+t._y.call(null,u.data),l===v&&r===S)return d.next=u,c?c[C]=d:t._root=d,t;do c=c?c[C]=new Array(4):t._root=new Array(4),(j=l>=(y=(m+f)/2))?m=y:f=y,(E=r>=(b=(x+g)/2))?x=b:g=b;while((C=E<<1|j)===(A=(S>=b)<<1|v>=y));return c[A]=u,c[C]=d,t}function hS(t){var l,r,i=t.length,c,u,d=new Array(i),m=new Array(i),x=1/0,f=1/0,g=-1/0,y=-1/0;for(r=0;r<i;++r)isNaN(c=+this._x.call(null,l=t[r]))||isNaN(u=+this._y.call(null,l))||(d[r]=c,m[r]=u,c<x&&(x=c),c>g&&(g=c),u<f&&(f=u),u>y&&(y=u));if(x>g||f>y)return this;for(this.cover(x,f).cover(g,y),r=0;r<i;++r)og(this,d[r],m[r],t[r]);return this}function mS(t,l){if(isNaN(t=+t)||isNaN(l=+l))return this;var r=this._x0,i=this._y0,c=this._x1,u=this._y1;if(isNaN(r))c=(r=Math.floor(t))+1,u=(i=Math.floor(l))+1;else{for(var d=c-r||1,m=this._root,x,f;r>t||t>=c||i>l||l>=u;)switch(f=(l<i)<<1|t<r,x=new Array(4),x[f]=m,m=x,d*=2,f){case 0:c=r+d,u=i+d;break;case 1:r=c-d,u=i+d;break;case 2:c=r+d,i=u-d;break;case 3:r=c-d,i=u-d;break}this._root&&this._root.length&&(this._root=m)}return this._x0=r,this._y0=i,this._x1=c,this._y1=u,this}function xS(){var t=[];return this.visit(function(l){if(!l.length)do t.push(l.data);while(l=l.next)}),t}function pS(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Nn(t,l,r,i,c){this.node=t,this.x0=l,this.y0=r,this.x1=i,this.y1=c}function yS(t,l,r){var i,c=this._x0,u=this._y0,d,m,x,f,g=this._x1,y=this._y1,b=[],v=this._root,S,j;for(v&&b.push(new Nn(v,c,u,g,y)),r==null?r=1/0:(c=t-r,u=l-r,g=t+r,y=l+r,r*=r);S=b.pop();)if(!(!(v=S.node)||(d=S.x0)>g||(m=S.y0)>y||(x=S.x1)<c||(f=S.y1)<u))if(v.length){var E=(d+x)/2,C=(m+f)/2;b.push(new Nn(v[3],E,C,x,f),new Nn(v[2],d,C,E,f),new Nn(v[1],E,m,x,C),new Nn(v[0],d,m,E,C)),(j=(l>=C)<<1|t>=E)&&(S=b[b.length-1],b[b.length-1]=b[b.length-1-j],b[b.length-1-j]=S)}else{var A=t-+this._x.call(null,v.data),F=l-+this._y.call(null,v.data),_=A*A+F*F;if(_<r){var H=Math.sqrt(r=_);c=t-H,u=l-H,g=t+H,y=l+H,i=v.data}}return i}function gS(t){if(isNaN(g=+this._x.call(null,t))||isNaN(y=+this._y.call(null,t)))return this;var l,r=this._root,i,c,u,d=this._x0,m=this._y0,x=this._x1,f=this._y1,g,y,b,v,S,j,E,C;if(!r)return this;if(r.length)for(;;){if((S=g>=(b=(d+x)/2))?d=b:x=b,(j=y>=(v=(m+f)/2))?m=v:f=v,l=r,!(r=r[E=j<<1|S]))return this;if(!r.length)break;(l[E+1&3]||l[E+2&3]||l[E+3&3])&&(i=l,C=E)}for(;r.data!==t;)if(c=r,!(r=r.next))return this;return(u=r.next)&&delete r.next,c?(u?c.next=u:delete c.next,this):l?(u?l[E]=u:delete l[E],(r=l[0]||l[1]||l[2]||l[3])&&r===(l[3]||l[2]||l[1]||l[0])&&!r.length&&(i?i[C]=r:this._root=r),this):(this._root=u,this)}function bS(t){for(var l=0,r=t.length;l<r;++l)this.remove(t[l]);return this}function vS(){return this._root}function wS(){var t=0;return this.visit(function(l){if(!l.length)do++t;while(l=l.next)}),t}function kS(t){var l=[],r,i=this._root,c,u,d,m,x;for(i&&l.push(new Nn(i,this._x0,this._y0,this._x1,this._y1));r=l.pop();)if(!t(i=r.node,u=r.x0,d=r.y0,m=r.x1,x=r.y1)&&i.length){var f=(u+m)/2,g=(d+x)/2;(c=i[3])&&l.push(new Nn(c,f,g,m,x)),(c=i[2])&&l.push(new Nn(c,u,g,f,x)),(c=i[1])&&l.push(new Nn(c,f,d,m,g)),(c=i[0])&&l.push(new Nn(c,u,d,f,g))}return this}function jS(t){var l=[],r=[],i;for(this._root&&l.push(new Nn(this._root,this._x0,this._y0,this._x1,this._y1));i=l.pop();){var c=i.node;if(c.length){var u,d=i.x0,m=i.y0,x=i.x1,f=i.y1,g=(d+x)/2,y=(m+f)/2;(u=c[0])&&l.push(new Nn(u,d,m,g,y)),(u=c[1])&&l.push(new Nn(u,g,m,x,y)),(u=c[2])&&l.push(new Nn(u,d,y,g,f)),(u=c[3])&&l.push(new Nn(u,g,y,x,f))}r.push(i)}for(;i=r.pop();)t(i.node,i.x0,i.y0,i.x1,i.y1);return this}function SS(t){return t[0]}function CS(t){return arguments.length?(this._x=t,this):this._x}function ES(t){return t[1]}function NS(t){return arguments.length?(this._y=t,this):this._y}function Eh(t,l,r){var i=new Nh(l??SS,r??ES,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function Nh(t,l,r,i,c,u){this._x=t,this._y=l,this._x0=r,this._y0=i,this._x1=c,this._y1=u,this._root=void 0}function m0(t){for(var l={data:t.data},r=l;t=t.next;)r=r.next={data:t.data};return l}var An=Eh.prototype=Nh.prototype;An.copy=function(){var t=new Nh(this._x,this._y,this._x0,this._y0,this._x1,this._y1),l=this._root,r,i;if(!l)return t;if(!l.length)return t._root=m0(l),t;for(r=[{source:l,target:t._root=new Array(4)}];l=r.pop();)for(var c=0;c<4;++c)(i=l.source[c])&&(i.length?r.push({source:i,target:l.target[c]=new Array(4)}):l.target[c]=m0(i));return t};An.add=fS;An.addAll=hS;An.cover=mS;An.data=xS;An.extent=pS;An.find=yS;An.remove=gS;An.removeAll=bS;An.root=vS;An.size=wS;An.visit=kS;An.visitAfter=jS;An.x=CS;An.y=NS;function wa(t){return function(){return t}}function Vr(t){return(t()-.5)*1e-6}function AS(t){return t.x+t.vx}function TS(t){return t.y+t.vy}function DS(t){var l,r,i,c=1,u=1;typeof t!="function"&&(t=wa(t==null?1:+t));function d(){for(var f,g=l.length,y,b,v,S,j,E,C=0;C<u;++C)for(y=Eh(l,AS,TS).visitAfter(m),f=0;f<g;++f)b=l[f],j=r[b.index],E=j*j,v=b.x+b.vx,S=b.y+b.vy,y.visit(A);function A(F,_,H,M,I){var W=F.data,te=F.r,D=j+te;if(W){if(W.index>b.index){var Y=v-W.x-W.vx,B=S-W.y-W.vy,V=Y*Y+B*B;V<D*D&&(Y===0&&(Y=Vr(i),V+=Y*Y),B===0&&(B=Vr(i),V+=B*B),V=(D-(V=Math.sqrt(V)))/V*c,b.vx+=(Y*=V)*(D=(te*=te)/(E+te)),b.vy+=(B*=V)*D,W.vx-=Y*(D=1-D),W.vy-=B*D)}return}return _>v+D||M<v-D||H>S+D||I<S-D}}function m(f){if(f.data)return f.r=r[f.data.index];for(var g=f.r=0;g<4;++g)f[g]&&f[g].r>f.r&&(f.r=f[g].r)}function x(){if(l){var f,g=l.length,y;for(r=new Array(g),f=0;f<g;++f)y=l[f],r[y.index]=+t(y,f,l)}}return d.initialize=function(f,g){l=f,i=g,x()},d.iterations=function(f){return arguments.length?(u=+f,d):u},d.strength=function(f){return arguments.length?(c=+f,d):c},d.radius=function(f){return arguments.length?(t=typeof f=="function"?f:wa(+f),x(),d):t},d}function zS(t){return t.index}function x0(t,l){var r=t.get(l);if(!r)throw new Error("node not found: "+l);return r}function MS(t){var l=zS,r=y,i,c=wa(30),u,d,m,x,f,g=1;t==null&&(t=[]);function y(E){return 1/Math.min(m[E.source.index],m[E.target.index])}function b(E){for(var C=0,A=t.length;C<g;++C)for(var F=0,_,H,M,I,W,te,D;F<A;++F)_=t[F],H=_.source,M=_.target,I=M.x+M.vx-H.x-H.vx||Vr(f),W=M.y+M.vy-H.y-H.vy||Vr(f),te=Math.sqrt(I*I+W*W),te=(te-u[F])/te*E*i[F],I*=te,W*=te,M.vx-=I*(D=x[F]),M.vy-=W*D,H.vx+=I*(D=1-D),H.vy+=W*D}function v(){if(d){var E,C=d.length,A=t.length,F=new Map(d.map((H,M)=>[l(H,M,d),H])),_;for(E=0,m=new Array(C);E<A;++E)_=t[E],_.index=E,typeof _.source!="object"&&(_.source=x0(F,_.source)),typeof _.target!="object"&&(_.target=x0(F,_.target)),m[_.source.index]=(m[_.source.index]||0)+1,m[_.target.index]=(m[_.target.index]||0)+1;for(E=0,x=new Array(A);E<A;++E)_=t[E],x[E]=m[_.source.index]/(m[_.source.index]+m[_.target.index]);i=new Array(A),S(),u=new Array(A),j()}}function S(){if(d)for(var E=0,C=t.length;E<C;++E)i[E]=+r(t[E],E,t)}function j(){if(d)for(var E=0,C=t.length;E<C;++E)u[E]=+c(t[E],E,t)}return b.initialize=function(E,C){d=E,f=C,v()},b.links=function(E){return arguments.length?(t=E,v(),b):t},b.id=function(E){return arguments.length?(l=E,b):l},b.iterations=function(E){return arguments.length?(g=+E,b):g},b.strength=function(E){return arguments.length?(r=typeof E=="function"?E:wa(+E),S(),b):r},b.distance=function(E){return arguments.length?(c=typeof E=="function"?E:wa(+E),j(),b):c},b}var FS={value:()=>{}};function cg(){for(var t=0,l=arguments.length,r={},i;t<l;++t){if(!(i=arguments[t]+"")||i in r||/[\s.]/.test(i))throw new Error("illegal type: "+i);r[i]=[]}return new vc(r)}function vc(t){this._=t}function RS(t,l){return t.trim().split(/^|\s+/).map(function(r){var i="",c=r.indexOf(".");if(c>=0&&(i=r.slice(c+1),r=r.slice(0,c)),r&&!l.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:i}})}vc.prototype=cg.prototype={constructor:vc,on:function(t,l){var r=this._,i=RS(t+"",r),c,u=-1,d=i.length;if(arguments.length<2){for(;++u<d;)if((c=(t=i[u]).type)&&(c=_S(r[c],t.name)))return c;return}if(l!=null&&typeof l!="function")throw new Error("invalid callback: "+l);for(;++u<d;)if(c=(t=i[u]).type)r[c]=p0(r[c],t.name,l);else if(l==null)for(c in r)r[c]=p0(r[c],t.name,null);return this},copy:function(){var t={},l=this._;for(var r in l)t[r]=l[r].slice();return new vc(t)},call:function(t,l){if((c=arguments.length-2)>0)for(var r=new Array(c),i=0,c,u;i<c;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(u=this._[t],i=0,c=u.length;i<c;++i)u[i].value.apply(l,r)},apply:function(t,l,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],c=0,u=i.length;c<u;++c)i[c].value.apply(l,r)}};function _S(t,l){for(var r=0,i=t.length,c;r<i;++r)if((c=t[r]).name===l)return c.value}function p0(t,l,r){for(var i=0,c=t.length;i<c;++i)if(t[i].name===l){t[i]=FS,t=t.slice(0,i).concat(t.slice(i+1));break}return r!=null&&t.push({name:l,value:r}),t}var pi=0,Cs=0,ws=0,ug=1e3,Dc,Es,zc=0,ja=0,Hc=0,Os=typeof performance=="object"&&performance.now?performance:Date,dg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function fg(){return ja||(dg(OS),ja=Os.now()+Hc)}function OS(){ja=0}function Wf(){this._call=this._time=this._next=null}Wf.prototype=hg.prototype={constructor:Wf,restart:function(t,l,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?fg():+r)+(l==null?0:+l),!this._next&&Es!==this&&(Es?Es._next=this:Dc=this,Es=this),this._call=t,this._time=r,Zf()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zf())}};function hg(t,l,r){var i=new Wf;return i.restart(t,l,r),i}function BS(){fg(),++pi;for(var t=Dc,l;t;)(l=ja-t._time)>=0&&t._call.call(void 0,l),t=t._next;--pi}function y0(){ja=(zc=Os.now())+Hc,pi=Cs=0;try{BS()}finally{pi=0,$S(),ja=0}}function LS(){var t=Os.now(),l=t-zc;l>ug&&(Hc-=l,zc=t)}function $S(){for(var t,l=Dc,r,i=1/0;l;)l._call?(i>l._time&&(i=l._time),t=l,l=l._next):(r=l._next,l._next=null,l=t?t._next=r:Dc=r);Es=t,Zf(i)}function Zf(t){if(!pi){Cs&&(Cs=clearTimeout(Cs));var l=t-ja;l>24?(t<1/0&&(Cs=setTimeout(y0,t-Os.now()-Hc)),ws&&(ws=clearInterval(ws))):(ws||(zc=Os.now(),ws=setInterval(LS,ug)),pi=1,dg(y0))}}const HS=1664525,US=1013904223,g0=4294967296;function IS(){let t=1;return()=>(t=(HS*t+US)%g0)/g0}function YS(t){return t.x}function qS(t){return t.y}var XS=10,VS=Math.PI*(3-Math.sqrt(5));function GS(t){var l,r=1,i=.001,c=1-Math.pow(i,1/300),u=0,d=.6,m=new Map,x=hg(y),f=cg("tick","end"),g=IS();t==null&&(t=[]);function y(){b(),f.call("tick",l),r<i&&(x.stop(),f.call("end",l))}function b(j){var E,C=t.length,A;j===void 0&&(j=1);for(var F=0;F<j;++F)for(r+=(u-r)*c,m.forEach(function(_){_(r)}),E=0;E<C;++E)A=t[E],A.fx==null?A.x+=A.vx*=d:(A.x=A.fx,A.vx=0),A.fy==null?A.y+=A.vy*=d:(A.y=A.fy,A.vy=0);return l}function v(){for(var j=0,E=t.length,C;j<E;++j){if(C=t[j],C.index=j,C.fx!=null&&(C.x=C.fx),C.fy!=null&&(C.y=C.fy),isNaN(C.x)||isNaN(C.y)){var A=XS*Math.sqrt(.5+j),F=j*VS;C.x=A*Math.cos(F),C.y=A*Math.sin(F)}(isNaN(C.vx)||isNaN(C.vy))&&(C.vx=C.vy=0)}}function S(j){return j.initialize&&j.initialize(t,g),j}return v(),l={tick:b,restart:function(){return x.restart(y),l},stop:function(){return x.stop(),l},nodes:function(j){return arguments.length?(t=j,v(),m.forEach(S),l):t},alpha:function(j){return arguments.length?(r=+j,l):r},alphaMin:function(j){return arguments.length?(i=+j,l):i},alphaDecay:function(j){return arguments.length?(c=+j,l):+c},alphaTarget:function(j){return arguments.length?(u=+j,l):u},velocityDecay:function(j){return arguments.length?(d=1-j,l):1-d},randomSource:function(j){return arguments.length?(g=j,m.forEach(S),l):g},force:function(j,E){return arguments.length>1?(E==null?m.delete(j):m.set(j,S(E)),l):m.get(j)},find:function(j,E,C){var A=0,F=t.length,_,H,M,I,W;for(C==null?C=1/0:C*=C,A=0;A<F;++A)I=t[A],_=j-I.x,H=E-I.y,M=_*_+H*H,M<C&&(W=I,C=M);return W},on:function(j,E){return arguments.length>1?(f.on(j,E),l):f.on(j)}}}function KS(){var t,l,r,i,c=wa(-30),u,d=1,m=1/0,x=.81;function f(v){var S,j=t.length,E=Eh(t,YS,qS).visitAfter(y);for(i=v,S=0;S<j;++S)l=t[S],E.visit(b)}function g(){if(t){var v,S=t.length,j;for(u=new Array(S),v=0;v<S;++v)j=t[v],u[j.index]=+c(j,v,t)}}function y(v){var S=0,j,E,C=0,A,F,_;if(v.length){for(A=F=_=0;_<4;++_)(j=v[_])&&(E=Math.abs(j.value))&&(S+=j.value,C+=E,A+=E*j.x,F+=E*j.y);v.x=A/C,v.y=F/C}else{j=v,j.x=j.data.x,j.y=j.data.y;do S+=u[j.data.index];while(j=j.next)}v.value=S}function b(v,S,j,E){if(!v.value)return!0;var C=v.x-l.x,A=v.y-l.y,F=E-S,_=C*C+A*A;if(F*F/x<_)return _<m&&(C===0&&(C=Vr(r),_+=C*C),A===0&&(A=Vr(r),_+=A*A),_<d&&(_=Math.sqrt(d*_)),l.vx+=C*v.value*i/_,l.vy+=A*v.value*i/_),!0;if(v.length||_>=m)return;(v.data!==l||v.next)&&(C===0&&(C=Vr(r),_+=C*C),A===0&&(A=Vr(r),_+=A*A),_<d&&(_=Math.sqrt(d*_)));do v.data!==l&&(F=u[v.data.index]*i/_,l.vx+=C*F,l.vy+=A*F);while(v=v.next)}return f.initialize=function(v,S){t=v,r=S,g()},f.strength=function(v){return arguments.length?(c=typeof v=="function"?v:wa(+v),g(),f):c},f.distanceMin=function(v){return arguments.length?(d=v*v,f):Math.sqrt(d)},f.distanceMax=function(v){return arguments.length?(m=v*v,f):Math.sqrt(m)},f.theta=function(v){return arguments.length?(x=v*v,f):Math.sqrt(x)},f}const Bs={tech:{bg:"rgba(59,130,246,0.15)",border:"#3b82f6",text:"#60a5fa"},market:{bg:"rgba(245,158,11,0.15)",border:"#f59e0b",text:"#fbbf24"},strategy:{bg:"rgba(139,92,246,0.15)",border:"#8b5cf6",text:"#a78bfa"},financial:{bg:"rgba(34,197,94,0.15)",border:"#22c55e",text:"#4ade80"},process:{bg:"rgba(236,72,153,0.15)",border:"#ec4899",text:"#f472b6"},competitor:{bg:"rgba(239,68,68,0.15)",border:"#ef4444",text:"#f87171"},domain:{bg:"rgba(14,165,233,0.15)",border:"#0ea5e9",text:"#38bdf8"},general:{bg:"rgba(148,163,184,0.12)",border:"#64748b",text:"#94a3b8"}};function QS(t){return Bs[t]??Bs.general}function WS({docs:t,onNodeClick:l,selectedDocId:r}){var Y;const i=k.useRef(null),c=k.useRef(null),[u,d]=k.useState({width:600,height:400}),[m,x]=k.useState({nodes:[],links:[]}),[f,g]=k.useState(null),[y,b]=k.useState(null),[v,S]=k.useState({x:0,y:0}),[j,E]=k.useState({x:0,y:0,w:600,h:400}),C=k.useRef(!1),A=k.useRef({x:0,y:0,vx:0,vy:0}),F=k.useRef(null),_=k.useRef(null);k.useEffect(()=>{const B=i.current;if(!B)return;const V=new ResizeObserver(ne=>{const{width:G,height:L}=ne[0].contentRect;G>0&&L>0&&(d({width:G,height:L}),E(Z=>({...Z,w:G,h:L})))});return V.observe(B),()=>V.disconnect()},[]),k.useEffect(()=>{if(t.length===0)return;const B=new Set(t.map(ue=>ue.id)),V=t.map(ue=>({id:ue.id,title:ue.title,category:ue.category,akb_type:ue.akb_type})),ne=(ue,z)=>{if(!z.startsWith(".")&&!z.startsWith("/"))return z;const R=ue.split("/");R.pop();const K=z.split("/");for(const T of K)T===".."?R.pop():T!=="."&&T!==""&&R.push(T);return R.join("/")},G=[];for(const ue of t)for(const z of ue.links){const R=ne(ue.id,z.href);B.has(R)&&R!==ue.id&&(G.some(K=>K.source===ue.id&&K.target===R||K.source===R&&K.target===ue.id)||G.push({source:ue.id,target:R,label:z.text}))}const{width:L,height:Z}=u,de=GS(V).force("link",MS(G).id(ue=>ue.id).distance(140)).force("charge",KS().strength(-400)).force("center",dS(L/2,Z/2)).force("collide",DS(50));_.current=de,de.on("tick",()=>{for(const ue of V)ue.x=Math.max(60,Math.min(L-60,ue.x??L/2)),ue.y=Math.max(60,Math.min(Z-60,ue.y??Z/2));x({nodes:[...V],links:[...G]})}),de.alpha(1).restart();for(let ue=0;ue<150;ue++)de.tick();return de.stop(),x({nodes:[...V],links:[...G]}),()=>{de.stop()}},[t,u]);const H=B=>{if(typeof B=="string"){const V=m.nodes.find(ne=>ne.id===B);return{x:(V==null?void 0:V.x)??0,y:(V==null?void 0:V.y)??0}}return{x:B.x??0,y:B.y??0}},M=k.useCallback(B=>{B.preventDefault();const V=B.deltaY>0?1.1:.9;E(ne=>{const G=Math.max(200,Math.min(u.width*3,ne.w*V)),L=Math.max(150,Math.min(u.height*3,ne.h*V)),Z=(G-ne.w)/2,de=(L-ne.h)/2;return{x:ne.x-Z,y:ne.y-de,w:G,h:L}})},[u]),I=k.useCallback(B=>{B.button===0&&(C.current=!0,A.current={x:B.clientX,y:B.clientY,vx:j.x,vy:j.y})},[j]),W=k.useCallback(B=>{var V;if(F.current){const ne=c.current;if(!ne)return;const G=ne.getBoundingClientRect(),L=j.w/G.width,Z=j.h/G.height,de=j.x+(B.clientX-G.left)*L,ue=j.y+(B.clientY-G.top)*Z;F.current.fx=de,F.current.fy=ue,(V=_.current)==null||V.alpha(.3).restart();return}if(C.current){const ne=(B.clientX-A.current.x)*(j.w/u.width),G=(B.clientY-A.current.y)*(j.h/u.height);E(L=>({...L,x:A.current.vx-ne,y:A.current.vy-G}))}},[j,u]),te=k.useCallback(()=>{C.current=!1,F.current&&(F.current.fx=null,F.current.fy=null,F.current=null)},[]),D=k.useCallback((B,V)=>{var ne;B.stopPropagation(),F.current=V,(ne=_.current)==null||ne.alpha(.3).restart()},[]);return s.jsxs("div",{ref:i,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[s.jsxs("svg",{ref:c,width:u.width,height:u.height,viewBox:`${j.x} ${j.y} ${j.w} ${j.h}`,style:{display:"block",cursor:C.current?"grabbing":"grab"},onWheel:M,onMouseDown:I,onMouseMove:W,onMouseUp:te,onMouseLeave:te,children:[s.jsx("defs",{children:s.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:s.jsx("circle",{cx:"0",cy:"0",r:"0.5",fill:"rgba(255,255,255,0.06)"})})}),s.jsx("rect",{x:j.x-100,y:j.y-100,width:j.w+200,height:j.h+200,fill:"url(#grid)",pointerEvents:"none"}),m.links.map((B,V)=>{const ne=H(B.source),G=H(B.target),L=y===V,Z=(ne.x+G.x)/2,de=(ne.y+G.y)/2;return s.jsxs("g",{children:[s.jsx("line",{x1:ne.x,y1:ne.y,x2:G.x,y2:G.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>b(V),onMouseLeave:()=>b(null)}),s.jsx("line",{x1:ne.x,y1:ne.y,x2:G.x,y2:G.y,stroke:L?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.3)",strokeWidth:L?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),L&&B.label&&s.jsx("text",{x:Z,y:de-6,textAnchor:"middle",fill:"#e2e8f0",fontSize:9,fontFamily:"monospace",style:{pointerEvents:"none"},children:s.jsx("tspan",{style:{filter:"drop-shadow(0 0 2px rgba(0,0,0,0.8))"},children:B.label.length>30?B.label.slice(0,28)+"..":B.label})})]},V)}),m.nodes.map(B=>{const V=Bs[B.category]??Bs.general,ne=B.akb_type==="hub",G=ne?24:16,L=(f==null?void 0:f.id)===B.id,Z=r===B.id,de=L?1.2:Z?1.15:1;return s.jsxs("g",{transform:`translate(${B.x??0}, ${B.y??0}) scale(${de})`,style:{cursor:"pointer",transition:"transform 0.15s ease"},onClick:ue=>{ue.stopPropagation();const z=t.find(R=>R.id===B.id);z&&l(z)},onMouseDown:ue=>D(ue,B),onMouseEnter:ue=>{var R;g(B);const z=(R=i.current)==null?void 0:R.getBoundingClientRect();z&&S({x:ue.clientX-z.left,y:ue.clientY-z.top})},onMouseLeave:()=>g(null),children:[Z&&s.jsx("rect",{x:-G/2-4,y:-G/2-4,width:G+8,height:G+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:ne?5:2,opacity:.6}),s.jsx("rect",{x:-G/2,y:-G/2,width:G,height:G,fill:V.border,rx:ne?4:2,opacity:L?1:.9}),s.jsx("rect",{x:-G/2+3,y:-G/2+3,width:Math.max(0,G-6),height:Math.max(0,G-6),fill:V.bg,rx:ne?3:1}),s.jsx("text",{y:G/2+14,textAnchor:"middle",fill:Z?"#e2e8f0":"#94a3b8",fontSize:11,fontFamily:"monospace",fontWeight:Z?"bold":"normal",style:{pointerEvents:"none"},children:B.title.length>24?B.title.slice(0,22)+"..":B.title})]},B.id)})]}),f&&!F.current&&s.jsxs("div",{className:"absolute z-10 pointer-events-none p-2.5 rounded text-xs max-w-[240px]",style:{left:Math.min(v.x+16,u.width-250),top:Math.max(v.y-30,8),background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[s.jsx("div",{className:"font-bold mb-1",children:f.title}),s.jsxs("div",{className:"text-[10px] opacity-60 mb-1",children:[f.akb_type.toUpperCase()," / ",f.category]}),((Y=t.find(B=>B.id===f.id))==null?void 0:Y.tldr)&&s.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:t.find(B=>B.id===f.id).tldr}),s.jsx("div",{className:"text-[10px] text-green-400",children:"Click to open | Drag to move"})]}),t.length===0&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{color:"var(--terminal-text-muted)"},children:"No knowledge documents found"})]})}function ZS({doc:t,allDocs:l,onOpen:r,onNavigateDoc:i}){const[c,u]=k.useState(!1),d=QS(t.category),m=t.akb_type==="hub",x=new Set(l.map(f=>f.id));return s.jsxs("div",{className:"mb-2 rounded-lg overflow-hidden",style:{background:m?"rgba(22,163,106,0.08)":"var(--hud-bg-alt)",border:`2px solid ${m?"rgba(22,163,106,0.4)":"var(--terminal-border)"}`},children:[s.jsxs("div",{className:"p-3 cursor-pointer hover:bg-white/5",onClick:()=>u(!c),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"shrink-0 text-sm",children:m?"🗂":t.format==="html"?"🌐":"📄"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[s.jsx("span",{className:"font-semibold text-xs truncate",style:{color:"var(--terminal-text)"},children:t.title}),s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:t.status==="active"?"#16a34a":t.status==="draft"?"#f59e0b":"#94a3b8"},title:t.status})]}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:t.tags.slice(0,4).map(f=>s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:d.bg,color:d.text,border:`1px solid ${d.border}`},children:f},f))})]}),s.jsx("span",{className:"text-xs shrink-0",style:{color:"var(--terminal-text-muted)"},children:c?"▲":"▼"})]}),!c&&t.tldr&&s.jsx("div",{className:"mt-1.5 text-[10px] line-clamp-2 ml-6",style:{color:"var(--terminal-text-secondary)"},children:t.tldr})]}),c&&s.jsxs("div",{className:"px-3 pb-3",style:{borderTop:"1px solid var(--terminal-border)"},children:[t.tldr&&s.jsx("div",{className:"mt-2 text-[11px] leading-relaxed italic",style:{color:"var(--terminal-text-secondary)"},children:t.tldr}),t.links.length>0&&s.jsxs("div",{className:"mt-2",children:[s.jsx("div",{className:"text-[9px] font-bold uppercase mb-1",style:{color:"var(--terminal-text-muted)"},children:"Cross-links"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:t.links.slice(0,5).map((f,g)=>{const y=f.href.replace(/^.*knowledge\//,"").replace(/^\.\.\/.*$/,"").replace(/^\.\//,""),b=x.has(y);return s.jsxs("span",{className:`px-1.5 py-0.5 text-[9px] rounded ${b?"cursor-pointer hover:opacity-70":""}`,style:{background:b?"rgba(22,163,106,0.15)":"rgba(148,163,184,0.1)",color:b?"#4ade80":"var(--terminal-text-muted)",border:`1px solid ${b?"rgba(22,163,106,0.3)":"var(--terminal-border)"}`},onClick:v=>{b&&(v.stopPropagation(),i(y))},children:["🔗"," ",f.text]},g)})})]}),s.jsxs("button",{className:"mt-2 text-[10px] font-semibold cursor-pointer hover:opacity-70",style:{color:"var(--active-green)"},onClick:f=>{f.stopPropagation(),r(t)},children:["Open full ","→"]})]})]})}function JS({docId:t,onBack:l,onDocUpdated:r,onDelete:i,onNavigateDoc:c,allDocs:u}){const[d,m]=k.useState(null),[x,f]=k.useState(!0),[g,y]=k.useState(!1),[b,v]=k.useState(""),[S,j]=k.useState(!1),E=new Set(u.map(H=>H.id)),C=k.useCallback(H=>{const M=H.split("#")[0];if(!M.match(/\.(md|html)$/))return null;const I=t.includes("/")?t.replace(/\/[^/]+$/,""):"";let W;if(M.startsWith("./"))W=I?`${I}/${M.slice(2)}`:M.slice(2);else if(M.startsWith("../")){const Y=I.split("/").filter(Boolean);let B=M;for(;B.startsWith("../");)Y.length>0&&Y.pop(),B=B.slice(3);W=Y.length>0?`${Y.join("/")}/${B}`:B}else W=M;if(E.has(W))return W;const te=W.split("/").pop()??"",D=u.find(Y=>Y.id===te||Y.id.endsWith("/"+te));return D?D.id:null},[t,E,u]),A=k.useCallback(H=>{const I=H.target.closest("a");if(!I)return;const W=I.getAttribute("href");if(!W||W.startsWith("http://")||W.startsWith("https://")||!W.match(/\.(md|html)(#.*)?$/))return;H.preventDefault(),H.stopPropagation();const te=C(W);te&&c(te)},[C,c]);k.useEffect(()=>{f(!0),Ce.getKnowledgeDoc(t).then(H=>{m(H),v(H.content)}).catch(console.error).finally(()=>f(!1))},[t]);const F=async()=>{if(d){j(!0);try{await Ce.updateKnowledgeDoc(t,b),m({...d,content:b}),y(!1),r()}catch(H){console.error("Save failed:",H)}finally{j(!1)}}},_=async()=>{if(confirm(`Delete "${d==null?void 0:d.title}"?`))try{await Ce.deleteKnowledgeDoc(t),i(t)}catch(H){console.error("Delete failed:",H)}};return x?s.jsx("div",{className:"flex-1 flex items-center justify-center text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}):d?s.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[s.jsxs("button",{onClick:l,className:"text-xs font-semibold cursor-pointer hover:opacity-70",style:{color:"var(--active-green)"},children:["←"," Back"]}),s.jsx("div",{className:"flex-1"}),g?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{y(!1),v(d.content)},className:"px-2.5 py-1 text-[10px] rounded cursor-pointer",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Cancel"}),s.jsx("button",{onClick:F,disabled:S,className:"px-2.5 py-1 text-[10px] rounded cursor-pointer font-semibold text-white",style:{background:S?"#86efac":"#16a34a"},children:S?"Saving...":"Save"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>y(!0),className:"px-2.5 py-1 text-[10px] rounded cursor-pointer font-semibold",style:{background:"rgba(59,130,246,0.15)",color:"#60a5fa",border:"1px solid rgba(59,130,246,0.3)"},children:"Edit"}),s.jsx("button",{onClick:_,className:"px-2.5 py-1 text-[10px] rounded cursor-pointer font-semibold",style:{background:"rgba(239,68,68,0.15)",color:"#f87171",border:"1px solid rgba(239,68,68,0.3)"},children:"Delete"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[s.jsx("h2",{className:"text-sm font-bold mb-1",style:{color:"var(--terminal-text)"},children:d.title}),d.tldr&&!g&&s.jsx("div",{className:"mb-3 text-xs italic",style:{color:"var(--terminal-text-secondary)"},children:d.tldr}),d.format==="html"?g?s.jsx("textarea",{className:"w-full h-full min-h-[400px] p-3 text-xs leading-relaxed rounded border resize-y",style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',background:"var(--hud-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},value:b,onChange:H=>v(H.target.value),spellCheck:!1}):s.jsx("iframe",{srcDoc:d.content,sandbox:"allow-same-origin",className:"w-full flex-1 min-h-[400px] rounded",style:{border:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},title:d.title}):g?s.jsx("textarea",{className:"w-full h-full min-h-[400px] p-3 text-xs leading-relaxed rounded border resize-y",style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',background:"#1e1e2e",color:"#e2e8f0",border:"1px solid #334155"},value:b,onChange:H=>v(H.target.value),spellCheck:!1}):s.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--terminal-text-secondary)"},onClick:A,children:s.jsx(Is,{content:d.content})})]})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-xs",style:{color:"var(--terminal-text-muted)"},children:"Failed to load document"})}function PS({onCreated:t,onCancel:l}){const[r,i]=k.useState(""),[c,u]=k.useState(""),[d,m]=k.useState(""),[x,f]=k.useState(!1),[g,y]=k.useState("");k.useEffect(()=>{if(!r){u("");return}const v=r.toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,60);u(v)},[r]);const b=async()=>{if(!r.trim()||!c.trim()){y("Title and filename are required");return}f(!0),y("");try{const v=await Ce.createKnowledgeDoc({filename:c,title:r,category:d||void 0});t(v.id)}catch(v){y(v instanceof Error?v.message:"Failed to create")}finally{f(!1)}};return s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsxs("button",{onClick:l,className:"text-xs font-semibold cursor-pointer hover:opacity-70",style:{color:"var(--active-green)"},children:["←"," Cancel"]}),s.jsx("h2",{className:"text-sm font-bold",style:{color:"var(--terminal-text)"},children:"New Document"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-semibold mb-1",style:{color:"var(--terminal-text-muted)"},children:"TITLE"}),s.jsx("input",{type:"text",value:r,onChange:v=>i(v.target.value),placeholder:"Document title...",className:"w-full px-3 py-2 text-xs rounded focus:outline-none",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-semibold mb-1",style:{color:"var(--terminal-text-muted)"},children:"FILENAME"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"text",value:c,onChange:v=>u(v.target.value),className:"flex-1 px-3 py-2 text-xs rounded focus:outline-none font-mono",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),s.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:".md"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-semibold mb-1",style:{color:"var(--terminal-text-muted)"},children:"CATEGORY (optional)"}),s.jsx("input",{type:"text",value:d,onChange:v=>m(v.target.value),placeholder:"e.g., tech, market, strategy",className:"w-full px-3 py-2 text-xs rounded focus:outline-none",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}})]}),g&&s.jsx("div",{className:"text-[10px] px-3 py-1.5 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:g}),s.jsx("button",{onClick:b,disabled:x||!r.trim(),className:"w-full py-2 text-xs font-semibold rounded cursor-pointer text-white",style:{background:x?"#86efac":"#16a34a"},children:x?"Creating...":"Create Document"})]})]})}const eC=500,b0=360,v0=700;function Ah(t){const[l,r]=k.useState(eC),[i,c]=k.useState(!1),u=k.useRef(0),d=k.useRef(0),m=t>0,x=m?t:0,f=m?Math.max(b0,window.innerWidth-t-100):v0,g=Math.min(l,f),y=k.useCallback(b=>{b.preventDefault(),u.current=b.clientX,d.current=g,c(!0);const v=j=>{const E=u.current-j.clientX,C=Math.min(v0,Math.max(b0,d.current+E));r(C)},S=()=>{c(!1),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",S)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",S)},[g]);return{panelRight:x,panelWidth:g,isResizing:i,handleResizeStart:y}}function tC({docs:t,onClose:l,onRefresh:r,terminalWidth:i=0,initialDocId:c}){const[u,d]=k.useState("list"),[m,x]=k.useState("all"),[f,g]=k.useState(c??null),[y,b]=k.useState(""),[v,S]=k.useState(!1),[j,E]=k.useState(null),{panelRight:C,panelWidth:A,isResizing:F,handleResizeStart:_}=Ah(i),H=["all",...Array.from(new Set(t.map(Y=>Y.category))).sort()],M=t.filter(Y=>{if(m!=="all"&&Y.category!==m)return!1;if(y){const B=y.toLowerCase();return Y.title.toLowerCase().includes(B)||(Y.tldr??"").toLowerCase().includes(B)||Y.tags.some(V=>V.toLowerCase().includes(B))}return!0}),I=Y=>{S(!1),r(),g(Y)},W=Y=>{g(null),r()},te=Y=>{E(Y.id)},D=j?t.find(Y=>Y.id===j):null;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:C},onClick:l}),s.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${F?"resizing":""}`,style:{right:C,width:A,background:"var(--terminal-bg)",borderLeftColor:"#16a34a"},children:[s.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${F?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:_}),s.jsxs("div",{className:"p-5 text-white relative",style:{background:"#16a34a"},children:[s.jsx("button",{onClick:l,className:"absolute top-3 right-3 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),s.jsxs("div",{className:"text-lg font-bold",children:["📚"," Knowledge Base"]}),s.jsxs("div",{className:"text-xs opacity-80 mt-0.5",children:[t.length," documents"]})]}),s.jsxs("div",{className:"flex",style:{borderBottom:"1px solid var(--terminal-border)"},children:[s.jsx(w0,{label:"List",active:u==="list",onClick:()=>{d("list"),E(null)}}),s.jsx(w0,{label:"Graph",active:u==="graph",onClick:()=>d("graph")})]}),u==="list"&&!f&&!v&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[s.jsx("input",{type:"text",value:y,onChange:Y=>b(Y.target.value),placeholder:"Search docs...",className:"flex-1 px-2.5 py-1.5 text-[11px] rounded focus:outline-none",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),s.jsx("button",{onClick:()=>S(!0),className:"px-2.5 py-1.5 text-[10px] font-semibold rounded cursor-pointer text-white shrink-0",style:{background:"#16a34a"},children:"+ New"})]}),s.jsx("div",{className:"flex overflow-x-auto shrink-0",style:{borderBottom:"1px solid var(--terminal-border)",scrollbarWidth:"none"},children:H.map(Y=>s.jsx("button",{onClick:()=>x(Y),className:"px-3 py-1.5 text-[10px] font-medium cursor-pointer whitespace-nowrap",style:{color:m===Y?"#4ade80":"var(--terminal-text-muted)",borderBottom:m===Y?"2px solid #4ade80":"2px solid transparent"},children:Y==="all"?`All (${t.length})`:`${Y} (${t.filter(B=>B.category===Y).length})`},Y))}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:M.length===0?s.jsx("div",{className:"text-center text-xs py-8",style:{color:"var(--terminal-text-muted)"},children:y?"No matching documents":"No documents in this category"}):M.map(Y=>s.jsx(ZS,{doc:Y,allDocs:t,onOpen:B=>g(B.id),onNavigateDoc:B=>g(B)},Y.id))})]}),u==="list"&&f&&!v&&s.jsx(JS,{docId:f,onBack:()=>g(null),onDocUpdated:r,onDelete:W,onNavigateDoc:Y=>g(Y),allDocs:t}),u==="list"&&v&&s.jsx(PS,{onCreated:I,onCancel:()=>S(!1)}),u==="graph"&&s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[s.jsx(WS,{docs:t,onNodeClick:te,selectedDocId:j}),D&&s.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:200,background:"var(--hud-bg-alt)",borderLeft:"1px solid var(--terminal-border)"},children:[s.jsx("div",{className:"text-[10px] font-bold uppercase mb-1",style:{color:"var(--terminal-text-muted)"},children:"Selected"}),s.jsx("div",{className:"text-xs font-bold mb-1",style:{color:"var(--terminal-text)"},children:D.title}),s.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:D.status==="active"?"#16a34a":D.status==="draft"?"#f59e0b":"#94a3b8"}}),D.tldr&&s.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:D.tldr}),D.links.length>0&&s.jsxs("div",{className:"mb-2",children:[s.jsx("div",{className:"text-[9px] font-bold mb-1",style:{color:"var(--terminal-text-muted)"},children:"Links"}),D.links.slice(0,5).map((Y,B)=>s.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",Y.text]},B))]}),s.jsx("button",{className:"w-full py-1.5 text-[10px] font-semibold rounded cursor-pointer text-white",style:{background:"#16a34a"},onClick:()=>{d("list"),g(D.id),E(null)},children:"Open Document"})]})]}),s.jsx("div",{className:"shrink-0 p-2",style:{borderTop:"1px solid var(--terminal-border)"},children:s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(Bs).map(([Y,B])=>s.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[s.jsx("div",{className:"w-2 h-2",style:{background:B.border}}),s.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:Y})]},Y))})})]})]})]})}function w0({label:t,active:l,onClick:r}){return s.jsx("button",{onClick:r,className:"px-4 py-2.5 text-sm font-medium cursor-pointer",style:{color:l?"#4ade80":"var(--terminal-text-muted)",borderBottom:l?"2px solid #4ade80":"2px solid transparent"},children:t})}function nC({standups:t,waves:l,decisions:r,mode:i,onClose:c,terminalWidth:u=0}){const[d,m]=k.useState(i==="decisions"?"decisions":"standups"),{panelRight:x,panelWidth:f,isResizing:g,handleResizeStart:y}=Ah(u);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:x},onClick:c}),s.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${g?"resizing":""}`,style:{right:x,width:f,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[s.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${g?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:y}),s.jsxs("div",{className:"p-5 bg-[var(--desk-wood)] text-white relative",children:[s.jsx("button",{onClick:c,className:"absolute top-3 right-3 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),s.jsx("div",{className:"text-lg font-bold",children:i==="bulletin"?"📌 Bulletin Board":"📜 Decision Log"})]}),s.jsx("div",{className:"flex",style:{borderBottom:"1px solid var(--terminal-border)"},children:i==="bulletin"?s.jsxs(s.Fragment,{children:[s.jsx(bf,{label:`Standups (${t.length})`,active:d==="standups",onClick:()=>m("standups")}),s.jsx(bf,{label:`Waves (${l.length})`,active:d==="waves",onClick:()=>m("waves")})]}):s.jsx(bf,{label:`Decisions (${r.length})`,active:d==="decisions",onClick:()=>m("decisions")})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[d==="standups"&&t.map((b,v)=>s.jsx(vf,{title:`Standup ${b.date}`,content:b.content},v)),d==="waves"&&l.map((b,v)=>s.jsx(vf,{title:`Wave ${b.id}`,subtitle:b.timestamp,content:b.content},v)),d==="decisions"&&r.map((b,v)=>s.jsx(vf,{title:`#${b.id} ${b.title}`,subtitle:b.date,content:b.content},v))]})]})]})}function bf({label:t,active:l,onClick:r}){return s.jsx("button",{onClick:r,className:"px-4 py-2.5 text-sm font-medium cursor-pointer",style:{color:l?"var(--accent)":"var(--terminal-text-muted)",borderBottom:l?"2px solid var(--accent)":"2px solid transparent"},children:t})}function lC(t){return t.replace(/^#{1,6}\s+/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/```[\s\S]*?```/g,"").replace(/^\s*[-*+]\s+/gm,"• ").replace(/^\s*\d+\.\s+/gm,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^>\s+/gm,"").replace(/^---+$/gm,"").replace(/\|[^|]*\|/g,"").replace(/\n{2,}/g," · ").replace(/\n/g," ").trim()}function vf({title:t,subtitle:l,content:r}){const[i,c]=k.useState(!1),u=r.length>100,d=lC(r).slice(0,160);return s.jsxs("div",{className:"mb-3 rounded-lg overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[s.jsxs("div",{className:"p-3 cursor-pointer hover:bg-white/5",onClick:()=>c(!i),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"font-medium text-sm",style:{color:"var(--terminal-text)"},children:t}),s.jsx("span",{className:"text-xs shrink-0 ml-2",style:{color:"var(--terminal-text-muted)"},children:i?"▲":"▼"})]}),l&&s.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:l})]}),i&&s.jsx("div",{className:"px-3 pb-3 text-xs leading-relaxed pt-2",style:{borderTop:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:s.jsx(Is,{content:r})}),!i&&u&&s.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:d})]})}function rC({projectId:t,onClose:l,terminalWidth:r=0}){const[i,c]=k.useState(null),{panelRight:u,panelWidth:d,isResizing:m,handleResizeStart:x}=Ah(r);if(k.useEffect(()=>{Ce.getProject(t).then(c).catch(console.error)},[t]),!i)return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:u},onClick:l}),s.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px] border-[var(--meeting-blue)]",style:{right:u,width:d,background:"var(--terminal-bg)"},children:s.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading project..."})})]});const f=i.tasks.filter(b=>b.status==="done").length,g=i.tasks.length,y=g>0?Math.round(f/g*100):0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:u},onClick:l}),s.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] border-[var(--meeting-blue)] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${m?"resizing":""}`,style:{right:u,width:d,background:"var(--terminal-bg)"},children:[s.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${m?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:x}),s.jsxs("div",{className:"p-5 bg-[var(--meeting-blue)] text-white relative",children:[s.jsx("div",{className:"text-sm opacity-70",children:"Meeting Room"}),s.jsx("button",{onClick:l,className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),s.jsx("div",{className:"text-xl font-bold mt-1",children:i.name}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-sm",children:[s.jsxs("span",{children:["Tasks: ",g]}),s.jsxs("span",{children:["Done: ",f]}),s.jsxs("span",{children:["Progress: ",y,"%"]})]}),s.jsx("div",{className:"mt-2 h-1.5 bg-white/20 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-white rounded-full transition-all",style:{width:`${y}%`}})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[i.prd&&s.jsxs("div",{className:"mb-5",children:[s.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"PRD"}),s.jsx("div",{className:"rounded-lg p-4 text-xs leading-relaxed max-h-60 overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:s.jsx(Is,{content:i.prd})})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:["Tasks (",g,")"]}),s.jsx("div",{className:"space-y-2",children:i.tasks.map(b=>s.jsxs("div",{className:"rounded-lg p-3",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium",style:{color:"var(--terminal-text)"},children:b.title}),s.jsx(aC,{status:b.status})]}),s.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-muted)"},children:b.role}),b.description&&s.jsx("div",{className:"text-xs mt-1.5 line-clamp-2",style:{color:"var(--terminal-text-secondary)"},children:b.description})]},b.id))})]})]})]})]})}function aC({status:t}){const l={done:{bg:"rgba(34,197,94,0.15)",color:"#4ade80"},"in-progress":{bg:"rgba(59,130,246,0.15)",color:"#60a5fa"},todo:{bg:"rgba(148,163,184,0.15)",color:"var(--terminal-text-muted)"}},r=l[t]??l.todo;return s.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:r.bg,color:r.color},children:t})}const iC={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function sC({roleId:t,roleName:l,mode:r="assign",onClose:i,onExecutionStart:c}){const[u,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{var y;(y=m.current)==null||y.focus()},[]);const x=()=>{u.trim()&&(c(t,u.trim()),i())},f=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&x(),y.key==="Escape"&&i()},g=iC[t]??"#666";return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),s.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"p-5 text-white",style:{background:`linear-gradient(135deg, ${g}, ${g}cc)`},children:[s.jsx("div",{className:"text-lg font-bold",children:r==="ask"?"Ask":"Assign Task"}),s.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:r==="ask"?`to ${l}`:`to ${l} (${t})`})]}),s.jsxs("div",{className:"p-5",children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Task Description"}),s.jsx("textarea",{ref:m,value:u,onChange:y=>d(y.target.value),onKeyDown:f,placeholder:r==="ask"?"What would you like to ask?":"Describe the task...",className:"w-full h-32 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"}),s.jsx("div",{className:"text-[10px] text-white/30 mt-1",children:"Cmd+Enter to submit"})]}),s.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[s.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),s.jsx("button",{onClick:x,disabled:!u.trim(),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:g},children:r==="ask"?"Ask":"Assign"})]})]})]})}const k0={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function mg({event:t,isThinkingCollapsed:l,onToggleThinking:r,onNavigateToJob:i,onOpenKnowledgeDoc:c,compact:u}){var m;const d=k0[t.roleId]??"#888";switch(t.type){case"text":{const x=t.data.text??"",f=u?x.slice(0,300):x;return/[#*|`\[\]_~>-]/.test(f)?s.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:s.jsx(gh,{remarkPlugins:[kh],children:f})}):s.jsx("div",{className:"text-green-300/90 whitespace-pre-wrap leading-relaxed",children:f})}case"thinking":{const x=t.data.text??"";return s.jsxs("div",{className:"group",children:[s.jsxs("button",{onClick:r,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-[10px] cursor-pointer flex items-center gap-1",children:[s.jsx("span",{children:l?"▶":"▼"}),s.jsx("span",{className:"italic",children:"thinking..."})]}),!l&&s.jsxs("div",{className:`ml-3 text-[var(--terminal-text-muted)] italic whitespace-pre-wrap opacity-60 text-[11px] overflow-y-auto ${u?"max-h-[60px]":"max-h-[120px]"}`,children:[x.slice(0,u?200:500),x.length>(u?200:500)?"...":""]})]})}case"tool:start":{const x=String(t.data.name??""),f=t.data.input,g=typeof(f==null?void 0:f.command)=="string"?f.command.slice(0,80):"",y=typeof(f==null?void 0:f.file_path)=="string"?String(f.file_path):typeof(f==null?void 0:f.path)=="string"?String(f.path):"",b=y?y.split("/").pop()??"":"",v=/^(write_file|Write|edit_file|Edit)$/i.test(x),S=(m=y.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:m[1],j=v&&S&&c;return s.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${j?"text-green-400/80 bg-green-400/10":"text-blue-400/80 bg-blue-400/10"}`,children:j?v&&x.toLowerCase().includes("edit")?"Edit":"Write":x}),j?s.jsx("button",{onClick:()=>c(S),className:"text-[10px] text-green-400 hover:text-green-300 underline underline-offset-2 cursor-pointer truncate",style:{maxWidth:u?200:400},children:b}):s.jsxs(s.Fragment,{children:[g&&s.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:g}),b&&s.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:b})]})]})}case"dispatch:start":{const x=t.data.targetRoleId??t.data.roleId??"",f=t.data.task??"",g=t.data.childJobId,y=k0[x]??"#888";return s.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${y}44`,background:`${y}11`},onClick:()=>g&&(i==null?void 0:i(g)),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{style:{color:y},className:"font-bold text-[11px]",children:["→"," ",x.toUpperCase()]}),s.jsx("span",{className:"text-[var(--terminal-text-secondary)] text-[10px] truncate flex-1",children:f.slice(0,u?60:100)}),g&&i&&s.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-[var(--terminal-text-muted)]",children:["View ","→"]})]})})}case"dispatch:done":return s.jsx("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pl-3 border-l-2 border-[var(--terminal-border)] my-0.5",children:"Dispatch completed"});case"turn:complete":return s.jsx("div",{className:"border-t border-[var(--terminal-border)] my-2 relative",children:s.jsxs("span",{className:"absolute -top-2 left-2 bg-[var(--terminal-bg)] px-2 text-[9px] text-[var(--terminal-text-muted)]",children:["Turn ",t.data.turn]})});case"stderr":return s.jsxs("div",{className:"text-red-400/80 text-[11px]",children:["⚠"," ",t.data.message]});case"job:start":return s.jsxs("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pb-1",children:[s.jsx("span",{style:{color:d},className:"font-bold",children:t.roleId.toUpperCase()})," ","started: ",(t.data.task??"").slice(0,u?50:80)]});case"job:done":{const x=t.data.turns??0,f=t.data.toolCalls??0;return s.jsx("div",{className:"mt-2 p-2 rounded-lg bg-green-900/20 border border-green-800/30",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),s.jsx("span",{className:"text-green-300 font-bold text-[11px]",children:"Complete"}),s.jsxs("span",{className:"text-[var(--terminal-text-muted)] text-[10px]",children:[x," turns · ",f," tools"]})]})})}case"job:error":return s.jsx("div",{className:"mt-2 p-2 rounded-lg bg-red-900/20 border border-red-800/30",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400"}),s.jsx("span",{className:"text-red-300 font-bold text-[11px]",children:"Error"}),s.jsx("span",{className:"text-red-200/70 text-[10px]",children:t.data.message})]})});case"job:awaiting_input":{const x=t.data.question??"";return s.jsxs("div",{className:"mt-2 p-2 rounded-lg border",style:{background:"#F59E0B11",borderColor:"#F59E0B33"},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),s.jsx("span",{className:"font-bold text-[11px]",style:{color:"#F59E0B"},children:"Awaiting Reply"})]}),x&&s.jsx("div",{className:"mt-1 text-[11px] text-[var(--terminal-text)] whitespace-pre-wrap",children:x})]})}case"job:reply":return s.jsx("div",{className:"mt-1 p-2 rounded-lg bg-blue-900/20 border border-blue-800/30",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-blue-300 font-bold text-[11px]",children:"CEO replied:"}),s.jsx("span",{className:"text-blue-200/80 text-[11px]",children:t.data.response??""})]})});case"import:scan":case"import:process":case"import:created":return s.jsxs("div",{className:"text-cyan-300/70 text-[11px]",children:["[",t.type,"] ",JSON.stringify(t.data)]});default:return null}}function oC({jobId:t,title:l,color:r,variant:i,style:c,onClose:u,onMinimize:d,onDone:m,onNavigateToJob:x,onOpenKnowledgeDoc:f}){const{events:g,status:y,textOutput:b,childJobIds:v}=K0(t),[S,j]=k.useState(0),[E,C]=k.useState(new Set),A=k.useRef(null),F=k.useRef(Date.now()),_=k.useRef(!1);k.useEffect(()=>{const Y=setInterval(()=>{j(Math.floor((Date.now()-F.current)/1e3))},1e3);return()=>clearInterval(Y)},[]),k.useEffect(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[g]),k.useEffect(()=>{(y==="done"||y==="error")&&!_.current&&(_.current=!0,m==null||m())},[y,m]);const H=Y=>{C(B=>{const V=new Set(B);return V.has(Y)?V.delete(Y):V.add(Y),V})},M={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[y],I={idle:"#888",connecting:"#888",streaming:r,done:"#2E7D32",error:"#C62828"}[y],W=Y=>`${Math.floor(Y/60)}:${String(Y%60).padStart(2,"0")}`,te=y==="done"||y==="error",D=s.jsxs("div",{className:i==="modal"?"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col":"bg-[var(--terminal-bg)] rounded-xl border border-[var(--terminal-border)] overflow-hidden flex flex-col max-h-[400px]",style:c,children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full animate-pulse",style:{background:I}}),s.jsx("div",{children:s.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:l})})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:W(S)}),s.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${I}22`,color:I},children:M}),d&&i==="modal"&&s.jsx("button",{onClick:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),te&&s.jsx("button",{onClick:u,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",children:"×"})]})]}),s.jsxs("div",{ref:A,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[g.length===0&&y==="connecting"&&s.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:"Connecting to activity stream..."}),g.map(Y=>s.jsx(mg,{event:Y,isThinkingCollapsed:E.has(Y.seq),onToggleThinking:()=>H(Y.seq),onNavigateToJob:x,onOpenKnowledgeDoc:f},Y.seq)),y==="streaming"&&s.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),s.jsxs("div",{className:"px-5 py-3 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[s.jsxs("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[g.length>0&&`${g.length} events`,b.length>0&&` · ${b.length} chars`,v.length>0&&` · ${v.length} dispatches`]}),te&&s.jsx("button",{onClick:u,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer",style:{background:r},children:"Close"})]})]});return i==="modal"?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:te?u:void 0}),D]}):D}const wf={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function cC({orgNodes:t,rootId:l}){const r=t[l];if(!r)return null;const c=r.children.map(m=>t[m]).filter(Boolean),u=[];for(const m of c)for(const x of m.children){const f=t[x];f&&u.push({node:f,parentId:m.id})}const d=c.length+u.length;return s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Propagation Preview"}),s.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[s.jsx("div",{className:"flex justify-center mb-2",children:s.jsx("span",{className:"px-3 py-1 text-[10px] font-bold rounded border-2 border-white/20 bg-white/5 text-white/30 uppercase",children:"CEO"})}),c.length>0&&s.jsx("div",{className:"flex justify-center mb-1",children:s.jsx("div",{className:"w-px h-3 bg-white/15"})}),c.length>1&&s.jsx("div",{className:"flex justify-center mb-1",children:s.jsx("div",{className:"h-px bg-white/15",style:{width:`${Math.min(c.length*80,320)}px`}})}),s.jsx("div",{className:"flex justify-center gap-3 mb-2 flex-wrap",children:c.map(m=>s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("span",{className:"px-2.5 py-1 text-[10px] font-bold rounded border-2 uppercase",style:{borderColor:wf[m.id]??"#888",color:wf[m.id]??"#888",background:`${wf[m.id]??"#888"}22`},children:m.id}),s.jsx("span",{className:"text-[8px] text-white/30 mt-0.5",children:"direct"})]},m.id))}),u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex justify-center mb-1",children:s.jsx("div",{className:"w-px h-2 bg-white/10"})}),s.jsx("div",{className:"flex justify-center gap-2 flex-wrap",children:u.map(({node:m})=>s.jsx("span",{className:"px-2 py-0.5 text-[9px] font-semibold rounded border border-white/15 text-white/40 uppercase",children:m.id},m.id))}),s.jsx("div",{className:"text-center text-[8px] text-white/30 mt-1",children:"via re-dispatch"})]})]}),s.jsxs("div",{className:"text-[10px] text-gray-400 mt-1.5",children:[d," role",d!==1?"s":""," will receive this wave"]})]})}function uC({cLevelRoles:t,orgNodes:l,rootId:r,onClose:i,onDispatch:c}){const[u,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{var y;(y=m.current)==null||y.focus()},[]);const x=()=>{!u.trim()||t.length===0||(c(u.trim()),i())},f=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&x(),y.key==="Escape"&&i()},g=r&&Object.keys(l).length>0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),s.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[s.jsx("div",{className:"text-lg font-bold",children:"CEO Wave"}),s.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:"Broadcast a directive to all C-Level reports"})]}),s.jsxs("div",{className:"p-5 space-y-4",children:[g&&s.jsx(cC,{orgNodes:l,rootId:r}),!g&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Dispatching to"}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:t.length>0?t.map(y=>s.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg border-2 border-red-200 bg-red-50 text-red-800",children:[y.id.toUpperCase()," · ",y.name]},y.id)):s.jsx("span",{className:"text-xs text-gray-400 italic",children:"No C-Level roles found"})}),s.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Each C-Level receives the directive and delegates to their reports"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Directive"}),s.jsx("textarea",{ref:m,value:u,onChange:y=>d(y.target.value),onKeyDown:f,placeholder:"e.g. Report current status across all departments",className:"w-full h-28 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"}),s.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Cmd+Enter to dispatch"})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[s.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),s.jsxs("button",{onClick:x,disabled:!u.trim()||t.length===0,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:["Dispatch to ",t.length," Role",t.length!==1?"s":""]})]})]})]})}function dC(t,l,r){const[i,c]=k.useState(new Map),[u,d]=k.useState(null),m=k.useRef(new Map),x=k.useRef(i);x.current=i,k.useEffect(()=>{if(!r||Object.keys(l).length===0)return;const b=new Map,v=j=>{const E=l[j];E&&(b.set(j,{jobId:null,roleId:j,roleName:E.name,children:E.children,status:"waiting",events:[],streamStatus:"idle"}),E.children.forEach(v))},S=l[r];S&&(b.set(r,{jobId:null,roleId:r,roleName:"CEO",children:S.children,status:"not-dispatched",events:[],streamStatus:"idle"}),S.children.forEach(v));for(const j of t){const E=b.get(j.roleId);E&&(E.jobId=j.jobId,E.status="running",E.streamStatus="connecting")}c(b),t.length>0&&d(t[0].roleId)},[t,l,r]);const f=k.useCallback((b,v)=>{const S=m.current.get(b);S&&S.controller.abort();const j=new AbortController,E={controller:j,lastSeq:-1};m.current.set(b,E);const A=`/api/jobs/${b}/stream?from=0`;fetch(A,{signal:j.signal}).then(async F=>{if(!F.ok||!F.body){c(I=>{const W=new Map(I),te=W.get(v);return te&&W.set(v,{...te,streamStatus:"error"}),W});return}c(I=>{const W=new Map(I),te=W.get(v);return te&&W.set(v,{...te,streamStatus:"streaming",status:"running"}),W});const _=F.body.getReader(),H=new TextDecoder;let M="";for(;;){const{done:I,value:W}=await _.read();if(I)break;M+=H.decode(W,{stream:!0});const te=M.split(`
81
- `);M=te.pop()??"";let D="";for(const Y of te)if(Y.startsWith("event: "))D=Y.slice(7).trim();else if(Y.startsWith("data: ")){try{const B=JSON.parse(Y.slice(6));if(D==="activity"){const V=B;V.seq>E.lastSeq&&(E.lastSeq=V.seq),c(ne=>{const G=new Map(ne),L=G.get(v);if(!L||L.events.some(de=>de.seq===V.seq))return ne;const Z={...L,events:[...L.events,V]};if(V.type==="dispatch:start"&&V.data.childJobId){const de=V.data.childJobId,ue=V.data.targetRoleId??V.data.roleId;if(ue){const z=G.get(ue);z&&(G.set(ue,{...z,jobId:de,status:"running",streamStatus:"connecting"}),setTimeout(()=>f(de,ue),0))}}return V.type==="job:done"?(Z.status="done",Z.streamStatus="done"):V.type==="job:error"?(Z.status="error",Z.streamStatus="error"):V.type==="job:awaiting_input"?(Z.status="awaiting_input",Z.streamStatus="done"):V.type==="job:reply"&&(Z.status="running",Z.streamStatus="streaming"),G.set(v,Z),G})}else if(D==="stream:end"){const V=B.reason;c(ne=>{const G=new Map(ne),L=G.get(v);if(!L)return ne;const Z=V==="error"?"error":V==="awaiting_input"?"awaiting_input":"done";return G.set(v,{...L,status:L.status==="running"?Z:L.status,streamStatus:Z==="error"?"error":"done"}),G})}}catch{}D=""}}}).catch(F=>{F.name!=="AbortError"&&c(_=>{const H=new Map(_),M=H.get(v);return M&&H.set(v,{...M,streamStatus:"error"}),H})})},[]);k.useEffect(()=>{if(t.length!==0){for(const b of t)f(b.jobId,b.roleId);return()=>{for(const[,b]of m.current)b.controller.abort();m.current.clear()}}},[t,f]);const g=(()=>{let b=0,v=0,S=0,j=0;for(const[E,C]of i)E!==r&&(j++,C.status==="done"?b++:C.status==="running"?v++:C.status==="awaiting_input"&&S++);return{done:b,total:j,running:v,awaitingInput:S}})(),y=g.total>0&&g.running===0&&g.awaitingInput===0&&Array.from(i.values()).every(b=>b.status!=="running"&&b.status!=="awaiting_input"&&b.streamStatus!=="streaming"&&b.streamStatus!=="connecting");return k.useEffect(()=>{y&&c(b=>{const v=new Map(b);let S=!1;for(const[j,E]of v)E.status==="waiting"&&(v.set(j,{...E,status:"not-dispatched"}),S=!0);return S?v:b})},[y]),{nodes:i,selectedRoleId:u,selectNode:d,progress:g,allDone:y,connectStream:f}}const j0={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},ba=120,ir=44,S0=80;function fC(t,l){if(!t.get(l))return{layout:[],width:300,height:200};const i=[],c=[],u=[{id:l,depth:0,parentId:null}],d=new Set;for(;u.length>0;){const{id:g,depth:y,parentId:b}=u.shift();if(d.has(g))continue;for(d.add(g);c.length<=y;)c.push([]);c[y].push(g),i.push({roleId:g,x:0,y:y*S0+20,parentId:b});const v=t.get(g);if(v)for(const S of v.children)t.has(S)&&!d.has(S)&&u.push({id:S,depth:y+1,parentId:g})}const m=Math.max(...c.map(g=>g.length))*(ba+16),x=Math.max(m,280);for(const g of c){const y=g.length*(ba+16)-16,b=(x-y)/2;g.forEach((v,S)=>{const j=i.find(E=>E.roleId===v);j&&(j.x=b+S*(ba+16))})}const f=c.length*S0+40;return{layout:i,width:x,height:f}}function hC({nodes:t,rootId:l,selectedRoleId:r,onSelectNode:i}){const{layout:c,width:u,height:d}=fC(t,l),m=f=>{const g=c.find(y=>y.roleId===f);return g?{cx:g.x+ba/2,cy:g.y+ir/2}:{cx:0,cy:0}},x=f=>{switch(f.status){case"running":return j0[f.roleId]??"#FBBF24";case"awaiting_input":return"#F59E0B";case"done":return"#2E7D32";case"error":return"#C62828";case"not-dispatched":return"#666";default:return"#888"}};return s.jsxs("svg",{viewBox:`0 0 ${u} ${d}`,width:"100%",height:"100%",className:"block",children:[s.jsx("defs",{children:s.jsxs("filter",{id:"glow",children:[s.jsx("feGaussianBlur",{stdDeviation:"2",result:"blur"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"blur"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),c.filter(f=>f.parentId).map(f=>{const g=m(f.parentId),y=m(f.roleId),b=t.get(f.roleId),v=t.get(f.parentId);let S="rgba(180,200,240,0.15)",j="4 4",E="";return(b==null?void 0:b.status)==="done"||(v==null?void 0:v.status)==="done"?(S="#2E7D3266",j=""):(b==null?void 0:b.status)==="awaiting_input"?(S="#F59E0B",j="6 4",E="wave-edge-flow"):(b==null?void 0:b.status)==="running"&&(S=j0[f.roleId]??"#FBBF24",j="6 4",E="wave-edge-flow"),s.jsx("line",{x1:g.cx,y1:g.cy+ir/2-4,x2:y.cx,y2:y.cy-ir/2+4,stroke:S,strokeWidth:1.5,strokeDasharray:j,className:E},`${f.parentId}-${f.roleId}`)}),c.map(f=>{const g=t.get(f.roleId);if(!g)return null;const y=x(g),b=r===f.roleId,v=f.roleId===l,S=v?.4:g.status==="not-dispatched"?.35:1;return s.jsxs("g",{transform:`translate(${f.x}, ${f.y})`,style:{cursor:v?"default":"pointer",opacity:S},onClick:()=>!v&&i(f.roleId),children:[s.jsx("rect",{x:0,y:0,width:ba,height:ir,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:b?"#fff":y,strokeWidth:b?2:1.5,strokeDasharray:g.status==="not-dispatched"?"4 3":""}),s.jsx("circle",{cx:14,cy:ir/2,r:4,fill:y,filter:g.status==="running"||g.status==="awaiting_input"?"url(#glow)":void 0,children:(g.status==="running"||g.status==="awaiting_input")&&s.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),s.jsx("text",{x:26,y:ir/2-4,fill:"var(--terminal-text, #fff)",fontSize:10,fontWeight:700,fontFamily:"var(--pixel-font)",children:g.roleId.toUpperCase()}),s.jsx("text",{x:26,y:ir/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:g.status==="running"?"Working...":g.status==="awaiting_input"?"Awaiting Reply":g.status==="done"?"Complete":g.status==="error"?"Error":g.status==="waiting"?"Waiting":""}),g.status==="done"&&s.jsx("text",{x:ba-18,y:ir/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),g.status==="error"&&s.jsx("text",{x:ba-18,y:ir/2+4,fontSize:14,fill:"#C62828",children:"✗"})]},f.roleId)})]})}const mC={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function xC({directive:t,rootJobs:l,orgNodes:r,rootRoleId:i,onClose:c,onMinimize:u,onDone:d,onOpenKnowledgeDoc:m}){const{nodes:x,selectedRoleId:f,selectNode:g,progress:y,allDone:b,connectStream:v}=dC(l,r,i),[S,j]=k.useState(0),[E,C]=k.useState(new Set),[A,F]=k.useState(""),[_,H]=k.useState(!1),M=k.useRef(null),I=k.useRef(Date.now()),W=k.useRef(!1),te=k.useCallback(async()=>{if(!f||!A.trim())return;const L=x.get(f);if(!(!(L!=null&&L.jobId)||L.status!=="awaiting_input")){H(!0);try{const{jobId:Z}=await Ce.replyToJob(L.jobId,A.trim());F(""),v(Z,f)}catch(Z){console.error("Reply failed:",Z)}finally{H(!1)}}},[f,A,x,v]),D=k.useCallback(async L=>{const Z=x.get(L);if(Z!=null&&Z.jobId)try{await Ce.abortJob(Z.jobId)}catch(de){console.error("Abort failed:",de)}},[x]),Y=k.useCallback(async()=>{for(const[,L]of x)if((L.status==="running"||L.status==="awaiting_input")&&L.jobId)try{await Ce.abortJob(L.jobId)}catch{}},[x]);k.useEffect(()=>{const L=setInterval(()=>{j(Math.floor((Date.now()-I.current)/1e3))},1e3);return()=>clearInterval(L)},[]),k.useEffect(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[f,x]),k.useEffect(()=>{b&&!W.current&&(W.current=!0,d==null||d())},[b,d]);const B=L=>`${Math.floor(L/60)}:${String(L%60).padStart(2,"0")}`,V=f?x.get(f):null,ne=f?mC[f]??"#888":"#888",G=L=>{C(Z=>{const de=new Set(Z);return de.has(L)?de.delete(L):de.add(L),de})};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:b?c:void 0}),s.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[960px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:b?"#2E7D32":"#B71C1C",animation:b?void 0:"wave-pulse 2s ease-in-out infinite"}}),s.jsx("div",{children:s.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:b?"WAVE COMPLETE":"WAVE COMMAND CENTER"})})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:B(S)}),y.awaitingInput>0&&s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[y.awaitingInput," awaiting reply"]}),s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:b?"#2E7D3222":"#B71C1C22",color:b?"#2E7D32":"#B71C1C"},children:[y.done,"/",y.total," done"]}),!b&&(y.running>0||y.awaitingInput>0)&&s.jsx("button",{onClick:Y,className:"text-xs px-2 py-0.5 rounded font-semibold cursor-pointer",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Stop all running jobs",children:"Stop All"}),s.jsx("button",{onClick:u,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),b&&s.jsx("button",{onClick:c,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",children:"×"})]})]}),s.jsx("div",{className:"px-5 py-2 border-b border-[var(--terminal-border)] shrink-0",children:s.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic",children:["“",t,"”"]})}),s.jsxs("div",{className:"flex flex-1 min-h-0",children:[s.jsxs("div",{className:"w-[280px] shrink-0 border-r border-[var(--terminal-border)] flex flex-col",children:[s.jsx("div",{className:"px-3 py-2 border-b border-[var(--terminal-border)]",children:s.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:"Org Propagation"})}),s.jsx("div",{className:"flex-1 overflow-auto p-3",children:s.jsx(hC,{nodes:x,rootId:i,selectedRoleId:f,onSelectNode:g})}),s.jsx("div",{className:"px-3 py-2 border-t border-[var(--terminal-border)] flex flex-wrap gap-x-3 gap-y-1",children:[{label:"running",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(L=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L.color,animation:L.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),s.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:L.label})]},L.label))})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[V&&s.jsxs("div",{className:"px-4 py-2 border-b border-[var(--terminal-border)] shrink-0 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:ne}}),s.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:V.roleId.toUpperCase()}),s.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:V.roleName}),s.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:V.status==="awaiting_input"?"#F59E0B22":`${ne}22`,color:V.status==="awaiting_input"?"#F59E0B":ne},children:V.status==="running"?"Working":V.status==="done"?"Complete":V.status==="error"?"Error":V.status==="waiting"?"Waiting":V.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(V.status==="running"||V.status==="awaiting_input")&&V.jobId&&s.jsx("button",{onClick:()=>D(V.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Force stop this job",children:"Stop"})]}),s.jsxs("div",{ref:M,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[V&&V.events.length===0&&s.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:V.status==="waiting"?"Waiting for dispatch...":V.status==="running"?"Connecting to activity stream...":V.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),V==null?void 0:V.events.map(L=>s.jsx(mg,{event:L,isThinkingCollapsed:E.has(L.seq),onToggleThinking:()=>G(L.seq),onNavigateToJob:Z=>{for(const[,de]of x)if(de.jobId===Z){g(de.roleId);return}},onOpenKnowledgeDoc:m},L.seq)),(V==null?void 0:V.status)==="running"&&s.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(V==null?void 0:V.status)==="awaiting_input"&&s.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#F59E0B0A"},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),s.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#F59E0B"},children:[V.roleName," is waiting for your response"]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:A,onChange:L=>F(L.target.value),onKeyDown:L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),te())},placeholder:"Type your response...",disabled:_,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#F59E0B]",autoFocus:!0}),s.jsx("button",{onClick:te,disabled:_||!A.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#F59E0B",color:"#000"},children:_?"...":"Reply"})]})]}),!V&&s.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-xs",children:"Click a node in the org tree to view activity"}),s.jsxs("div",{className:"px-4 py-2 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[s.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:V&&V.events.length>0&&`${V.events.length} events`}),b&&s.jsx("button",{onClick:c,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer",style:{background:"#2E7D32"},children:"Close"})]})]})]})]})]})}const pC={cto:{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"glasses"},cbo:{skinColor:"#FDEBD0",hairColor:"#1A0A00",shirtColor:"#E65100",pantsColor:"#37474F",shoeColor:"#1A1A1A",hairStyle:"slicked",outfitStyle:"suit",accessory:"lapels"},pm:{skinColor:"#FDEBD0",hairColor:"#6D4C41",shirtColor:"#2E7D32",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bun",outfitStyle:"tshirt",accessory:"blush"},engineer:{skinColor:"#F5CBA7",hairColor:"#1A1A1A",shirtColor:"#4A148C",pantsColor:"#37474F",shoeColor:"#7B1FA2",hairStyle:"messy",outfitStyle:"hoodie",accessory:"headphones"},designer:{skinColor:"#FDEBD0",hairColor:"#AD1457",shirtColor:"#AD1457",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bob",outfitStyle:"tshirt",accessory:"beret"},qa:{skinColor:"#F5CBA7",hairColor:"#4E342E",shirtColor:"#00695C",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"badge"},"data-analyst":{skinColor:"#F5CBA7",hairColor:"#3E2723",shirtColor:"#0277BD",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"curly",outfitStyle:"vest",accessory:"none"}};function Th(t){return pC[t]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const xg=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],pg=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],yg=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],gg=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],bg=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],Gr={default:{name:"MIDNIGHT",icon:"🌃",vars:{"--floor-light":"#0d1117","--floor-dark":"#0a0e14","--hud-bg":"#0d1117","--hud-bg-alt":"#161b22","--pixel-border":"#30363d","--terminal-bg":"#0d1117","--terminal-border":"#21262d","--terminal-border-hover":"#388bfd","--terminal-text":"#e6edf3","--terminal-text-secondary":"#8b949e","--terminal-text-muted":"#484f58","--accent":"#388bfd","--active-green":"#3fb950","--idle-amber":"#d29922"}},light:{name:"DAYLIGHT",icon:"☀️",vars:{"--floor-light":"#f6f8fa","--floor-dark":"#eaeef2","--hud-bg":"#24292f","--hud-bg-alt":"#32383f","--pixel-border":"#d0d7de","--terminal-bg":"#ffffff","--terminal-border":"#d0d7de","--terminal-border-hover":"#0969da","--terminal-text":"#1f2328","--terminal-text-secondary":"#656d76","--terminal-text-muted":"#8c959f","--accent":"#0969da","--active-green":"#1a7f37","--idle-amber":"#9a6700"}},retro:{name:"RETRO",icon:"🎮",vars:{"--floor-light":"#1a1410","--floor-dark":"#140f0a","--hud-bg":"#1a1410","--hud-bg-alt":"#2a2018","--pixel-border":"#5c4a32","--terminal-bg":"#1a1410","--terminal-border":"#3a2e20","--terminal-border-hover":"#d4a44e","--terminal-text":"#e8d5b0","--terminal-text-secondary":"#a08860","--terminal-text-muted":"#6b5840","--accent":"#d4a44e","--active-green":"#8bba4a","--idle-amber":"#e8a030"}},cyberpunk:{name:"NEON",icon:"🌌",vars:{"--floor-light":"#0a0014","--floor-dark":"#06000e","--hud-bg":"#0a0014","--hud-bg-alt":"#14002a","--pixel-border":"#4a1a80","--terminal-bg":"#0a0014","--terminal-border":"#2a0a50","--terminal-border-hover":"#e040fb","--terminal-text":"#e0d0ff","--terminal-text-secondary":"#9070c0","--terminal-text-muted":"#5a3a80","--accent":"#e040fb","--active-green":"#00ff88","--idle-amber":"#ffab00"}},forest:{name:"FOREST",icon:"🌲",vars:{"--floor-light":"#0a1410","--floor-dark":"#060e0a","--hud-bg":"#0a1410","--hud-bg-alt":"#142a1e","--pixel-border":"#2a5a3a","--terminal-bg":"#0a1410","--terminal-border":"#1a3a26","--terminal-border-hover":"#4ade80","--terminal-text":"#d0f0d8","--terminal-text-secondary":"#70a880","--terminal-text-muted":"#3a6848","--accent":"#4ade80","--active-green":"#86efac","--idle-amber":"#fcd34d"}},ocean:{name:"OCEAN",icon:"🌊",vars:{"--floor-light":"#0a1420","--floor-dark":"#060e18","--hud-bg":"#0a1420","--hud-bg-alt":"#142a40","--pixel-border":"#1e4a6a","--terminal-bg":"#0a1420","--terminal-border":"#163050","--terminal-border-hover":"#38bdf8","--terminal-text":"#d0e8f8","--terminal-text-secondary":"#6090b0","--terminal-text-muted":"#305070","--accent":"#38bdf8","--active-green":"#34d399","--idle-amber":"#fbbf24"}}};function yC({color:t,selected:l,onClick:r}){return s.jsx("button",{onClick:r,className:"customize-swatch",style:{background:t,outline:l?"2px solid #fff":"2px solid transparent",boxShadow:l?`0 0 0 1px ${t}, 0 0 6px ${t}88`:"none"}})}function ks({label:t,presets:l,value:r,onChange:i}){return s.jsxs("div",{className:"customize-row",children:[s.jsxs("div",{className:"customize-row-header",children:[s.jsx("span",{className:"customize-row-label",children:t}),s.jsx("div",{className:"customize-row-current",style:{background:r}})]}),s.jsx("div",{className:"customize-swatches",children:l.map(c=>s.jsx(yC,{color:c,selected:c===r,onClick:()=>i(c)},c))})]})}function kf({label:t,items:l,value:r,onChange:i,lockInfo:c}){return s.jsxs("div",{className:"customize-row",children:[s.jsx("div",{className:"customize-row-header",children:s.jsx("span",{className:"customize-row-label",children:t})}),s.jsx("div",{className:"customize-swatches",style:{gap:4},children:l.map(u=>{const d=c?c.getLockLevel(u.id):1,m=u.id===r,x=c?d>c.roleLevel&&!m:!1,f=c?m&&d>c.roleLevel:!1;return s.jsxs("button",{onClick:()=>{x||i(u.id===r?void 0:u.id)},className:"customize-swatch",style:{width:"auto",height:"auto",padding:x?"2px 6px 10px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:m?"rgba(255,255,255,0.15)":x?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",outline:m?f?"2px solid #F59E0B":"2px solid #fff":"2px solid transparent",color:x?"rgba(255,255,255,0.25)":m?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:x?"not-allowed":"pointer",opacity:x?.35:1,position:"relative"},children:[u.name,x&&s.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:"rgba(255,255,255,0.5)",whiteSpace:"nowrap"},children:["🔒"," Lv.",d]}),f&&s.jsxs("span",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",fontSize:7,color:"#F59E0B",whiteSpace:"nowrap"},children:["⚠"," Lv.",d]})]},u.id)})})]})}function jf({label:t,active:l,onClick:r}){return s.jsx("button",{onClick:r,style:{flex:1,padding:"6px 0",fontSize:10,fontFamily:"var(--font-pixel, monospace)",fontWeight:"bold",letterSpacing:1,background:l?"rgba(255,255,255,0.08)":"transparent",color:l?"#fff":"rgba(255,255,255,0.35)",border:"none",borderBottom:l?"2px solid #3B82F6":"2px solid transparent",cursor:"pointer",transition:"all 0.15s"},children:t})}function Ir(t){return t[Math.floor(Math.random()*t.length)]}function fi(t){var c,u,d;const l=ng(),r=lg(),i=rg().filter(m=>!t||ig(m.id,t));return{skinColor:Ir(xg),hairColor:Ir(pg),shirtColor:Ir(yg),pantsColor:Ir(gg),shoeColor:Ir(bg),hairStyle:(c=Ir(l))==null?void 0:c.id,outfitStyle:(u=Ir(r))==null?void 0:u.id,accessory:(d=Ir(i))==null?void 0:d.id}}function vg({roleId:t,appearance:l,onChange:r,onRandomize:i,onReset:c,label:u,roleLevel:d}){const[m,x]=k.useState("look"),f=k.useCallback((E,C)=>{r({...l,[E]:C})},[l,r]),g=k.useRef(null),y=k.useCallback(E=>{var F;const C=(F=E.target.files)==null?void 0:F[0];if(!C)return;const A=new Image;A.onload=()=>{const _=Hj(A);r({..._,hairStyle:l.hairStyle,outfitStyle:l.outfitStyle,accessory:l.accessory}),URL.revokeObjectURL(A.src)},A.src=URL.createObjectURL(C),E.target.value=""},[l.hairStyle,l.outfitStyle,l.accessory,r]),b=ng(),v=lg(),S=rg(),j=d!==void 0?S.filter(E=>ig(E.id,d)).length:S.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"customize-preview",children:[s.jsx("div",{className:"customize-preview-bg",children:s.jsx(_s,{roleId:t,appearance:l,scale:12})}),u&&s.jsx("div",{className:"customize-preview-name",children:u}),s.jsxs("div",{className:"customize-preview-actions",children:[s.jsx("button",{className:"customize-btn customize-btn--random",onClick:i,children:"RANDOM"}),s.jsx("button",{className:"customize-btn customize-btn--reset",onClick:c,children:"RESET"}),s.jsx("button",{className:"customize-btn",onClick:()=>{var E;return(E=g.current)==null?void 0:E.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),s.jsx("input",{ref:g,type:"file",accept:"image/*",onChange:y,style:{display:"none"}})]})]}),s.jsxs("div",{className:"customize-colors",children:[s.jsxs("div",{style:{display:"flex",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:[s.jsx(jf,{label:"LOOK",active:m==="look",onClick:()=>x("look")}),s.jsx(jf,{label:"OUTFIT",active:m==="outfit",onClick:()=>x("outfit")}),s.jsx(jf,{label:"ACCESSORY",active:m==="accessory",onClick:()=>x("accessory")})]}),m==="look"&&s.jsxs(s.Fragment,{children:[s.jsx(ks,{label:"SKIN",presets:xg,value:l.skinColor,onChange:E=>f("skinColor",E)}),s.jsx(ks,{label:"HAIR COLOR",presets:pg,value:l.hairColor,onChange:E=>f("hairColor",E)}),s.jsx(kf,{label:"HAIR STYLE",items:b,value:l.hairStyle,onChange:E=>f("hairStyle",E)})]}),m==="outfit"&&s.jsxs(s.Fragment,{children:[s.jsx(kf,{label:"STYLE",items:v,value:l.outfitStyle,onChange:E=>f("outfitStyle",E)}),s.jsx(ks,{label:"TOP",presets:yg,value:l.shirtColor,onChange:E=>f("shirtColor",E)}),s.jsx(ks,{label:"PANTS",presets:gg,value:l.pantsColor,onChange:E=>f("pantsColor",E)}),s.jsx(ks,{label:"SHOES",presets:bg,value:l.shoeColor,onChange:E=>f("shoeColor",E)})]}),m==="accessory"&&s.jsxs(s.Fragment,{children:[d!==void 0&&s.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s.jsxs("span",{children:["Lv.",d]}),s.jsxs("span",{children:[j,"/",S.length," unlocked"]})]}),s.jsx(kf,{label:"ACCESSORY",items:S,value:l.accessory,onChange:E=>f("accessory",E),lockInfo:d!==void 0?{roleLevel:d,getLockLevel:ag}:void 0}),s.jsx("div",{style:{marginTop:12,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,border:"1px dashed rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.25)",fontSize:9,fontFamily:"var(--font-pixel, monospace)",textAlign:"center"},children:d!==void 0&&d<10?"Level up to unlock more accessories":"More accessories coming soon"})]})]})]})}const gC=[{value:"c-level",label:"C-Level"},{value:"team-lead",label:"Team Lead"},{value:"member",label:"Member"}];function Jf(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Sf(t){switch(t){case"c-level":return{authority:{autonomous:["Strategic decisions within domain","Task delegation to reports"],needsApproval:["Budget over $5K","External commitments"]},knowledge:{reads:["company/","operations/","projects/"],writes:["operations/","knowledge/"]},reports:{daily:"standup",weekly:"summary"}};case"team-lead":return{authority:{autonomous:["Task planning","Sprint management"],needsApproval:["Architecture changes","New tool adoption"]},knowledge:{reads:["projects/","architecture/"],writes:["projects/"]},reports:{daily:"standup",weekly:"summary"}};default:return{authority:{autonomous:["Implementation within assigned tasks"],needsApproval:["Design changes","New dependencies"]},knowledge:{reads:["projects/"],writes:[]},reports:{daily:"standup",weekly:""}}}}const js=4;function bC(t,l,r){const i=t.trim();if(!i||i.startsWith("#"))return null;const c=i.split(",").map(y=>y.trim()),u=c[0];if(!u)return null;const d=Jf(u),m=(c[1]||"member").toLowerCase(),x=m==="c-level"?"c-level":m==="team-lead"?"team-lead":"member",f=c[2]||"ceo";let g;return l.has(d)?g="ID already exists":r.has(d)&&(g="Duplicate ID in batch"),r.add(d),{name:u,id:d,level:x,reportsTo:f,error:g}}function vC({existingRoles:t,onClose:l,onHire:r}){const[i,c]=k.useState("single"),[u,d]=k.useState(""),[m,x]=k.useState(null),[f,g]=k.useState(!1),[y,b]=k.useState(""),[v,S]=k.useState("input"),[j,E]=k.useState(""),[C,A]=k.useState(""),[F,_]=k.useState("ceo"),[H,M]=k.useState(1),[I,W]=k.useState(""),[te,D]=k.useState(""),[Y,B]=k.useState(!1),[V,ne]=k.useState("member"),[G,L]=k.useState("ceo"),[Z,de]=k.useState(""),[ue,z]=k.useState(fi),[R,K]=k.useState(!1),[T,fe]=k.useState(""),[Ee,Ne]=k.useState([]),[Le,Be]=k.useState(new Set),[Qe,Se]=k.useState(""),[tt,me]=k.useState("input"),[he,ge]=k.useState({done:0,total:0}),ke=k.useRef(null),Fe=k.useRef(null),Ae=k.useRef(null);k.useEffect(()=>{Ce.getSkills().then(q=>Ne(q.filter(ze=>ze.installed))).catch(()=>{})},[]),k.useEffect(()=>{var q,ze,He;i==="single"?(H===1&&((q=ke.current)==null||q.focus()),H===2&&((ze=Fe.current)==null||ze.focus())):tt==="input"&&((He=Ae.current)==null||He.focus())},[H,i,tt]);const De=k.useMemo(()=>new Set(t.map(q=>q.id)),[t]),je=k.useMemo(()=>{const q=Qe.split(`
81
+ `);M=te.pop()??"";let D="";for(const Y of te)if(Y.startsWith("event: "))D=Y.slice(7).trim();else if(Y.startsWith("data: ")){try{const B=JSON.parse(Y.slice(6));if(D==="activity"){const V=B;V.seq>E.lastSeq&&(E.lastSeq=V.seq),c(ne=>{const G=new Map(ne),L=G.get(v);if(!L||L.events.some(de=>de.seq===V.seq))return ne;const Z={...L,events:[...L.events,V]};if(V.type==="dispatch:start"&&V.data.childJobId){const de=V.data.childJobId,ue=V.data.targetRoleId??V.data.roleId;if(ue){const z=G.get(ue);z&&(G.set(ue,{...z,jobId:de,status:"running",streamStatus:"connecting"}),setTimeout(()=>f(de,ue),0))}}return V.type==="job:done"?(Z.status="done",Z.streamStatus="done"):V.type==="job:error"?(Z.status="error",Z.streamStatus="error"):V.type==="job:awaiting_input"?(Z.status="awaiting_input",Z.streamStatus="done"):V.type==="job:reply"&&(Z.status="running",Z.streamStatus="streaming"),G.set(v,Z),G})}else if(D==="stream:end"){const V=B.reason;V!=="replied"&&c(ne=>{const G=new Map(ne),L=G.get(v);if(!L)return ne;const Z=V==="error"?"error":V==="awaiting_input"?"awaiting_input":"done";return G.set(v,{...L,status:L.status==="running"?Z:L.status,streamStatus:Z==="error"?"error":"done"}),G})}}catch{}D=""}}}).catch(F=>{F.name!=="AbortError"&&c(_=>{const H=new Map(_),M=H.get(v);return M&&H.set(v,{...M,streamStatus:"error"}),H})})},[]);k.useEffect(()=>{if(t.length!==0){for(const b of t)f(b.jobId,b.roleId);return()=>{for(const[,b]of m.current)b.controller.abort();m.current.clear()}}},[t,f]);const g=(()=>{let b=0,v=0,S=0,j=0;for(const[E,C]of i)E!==r&&(j++,C.status==="done"?b++:C.status==="running"?v++:C.status==="awaiting_input"&&S++);return{done:b,total:j,running:v,awaitingInput:S}})(),y=g.total>0&&g.running===0&&g.awaitingInput===0&&Array.from(i.values()).every(b=>b.status!=="running"&&b.status!=="awaiting_input"&&b.streamStatus!=="streaming"&&b.streamStatus!=="connecting");return k.useEffect(()=>{y&&c(b=>{const v=new Map(b);let S=!1;for(const[j,E]of v)E.status==="waiting"&&(v.set(j,{...E,status:"not-dispatched"}),S=!0);return S?v:b})},[y]),{nodes:i,selectedRoleId:u,selectNode:d,progress:g,allDone:y,connectStream:f}}const j0={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},ba=120,ir=44,S0=80;function fC(t,l){if(!t.get(l))return{layout:[],width:300,height:200};const i=[],c=[],u=[{id:l,depth:0,parentId:null}],d=new Set;for(;u.length>0;){const{id:g,depth:y,parentId:b}=u.shift();if(d.has(g))continue;for(d.add(g);c.length<=y;)c.push([]);c[y].push(g),i.push({roleId:g,x:0,y:y*S0+20,parentId:b});const v=t.get(g);if(v)for(const S of v.children)t.has(S)&&!d.has(S)&&u.push({id:S,depth:y+1,parentId:g})}const m=Math.max(...c.map(g=>g.length))*(ba+16),x=Math.max(m,280);for(const g of c){const y=g.length*(ba+16)-16,b=(x-y)/2;g.forEach((v,S)=>{const j=i.find(E=>E.roleId===v);j&&(j.x=b+S*(ba+16))})}const f=c.length*S0+40;return{layout:i,width:x,height:f}}function hC({nodes:t,rootId:l,selectedRoleId:r,onSelectNode:i}){const{layout:c,width:u,height:d}=fC(t,l),m=f=>{const g=c.find(y=>y.roleId===f);return g?{cx:g.x+ba/2,cy:g.y+ir/2}:{cx:0,cy:0}},x=f=>{switch(f.status){case"running":return j0[f.roleId]??"#FBBF24";case"awaiting_input":return"#F59E0B";case"done":return"#2E7D32";case"error":return"#C62828";case"not-dispatched":return"#666";default:return"#888"}};return s.jsxs("svg",{viewBox:`0 0 ${u} ${d}`,width:"100%",height:"100%",className:"block",children:[s.jsx("defs",{children:s.jsxs("filter",{id:"glow",children:[s.jsx("feGaussianBlur",{stdDeviation:"2",result:"blur"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"blur"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),c.filter(f=>f.parentId).map(f=>{const g=m(f.parentId),y=m(f.roleId),b=t.get(f.roleId),v=t.get(f.parentId);let S="rgba(180,200,240,0.15)",j="4 4",E="";return(b==null?void 0:b.status)==="done"||(v==null?void 0:v.status)==="done"?(S="#2E7D3266",j=""):(b==null?void 0:b.status)==="awaiting_input"?(S="#F59E0B",j="6 4",E="wave-edge-flow"):(b==null?void 0:b.status)==="running"&&(S=j0[f.roleId]??"#FBBF24",j="6 4",E="wave-edge-flow"),s.jsx("line",{x1:g.cx,y1:g.cy+ir/2-4,x2:y.cx,y2:y.cy-ir/2+4,stroke:S,strokeWidth:1.5,strokeDasharray:j,className:E},`${f.parentId}-${f.roleId}`)}),c.map(f=>{const g=t.get(f.roleId);if(!g)return null;const y=x(g),b=r===f.roleId,v=f.roleId===l,S=v?.4:g.status==="not-dispatched"?.35:1;return s.jsxs("g",{transform:`translate(${f.x}, ${f.y})`,style:{cursor:v?"default":"pointer",opacity:S},onClick:()=>!v&&i(f.roleId),children:[s.jsx("rect",{x:0,y:0,width:ba,height:ir,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:b?"#fff":y,strokeWidth:b?2:1.5,strokeDasharray:g.status==="not-dispatched"?"4 3":""}),s.jsx("circle",{cx:14,cy:ir/2,r:4,fill:y,filter:g.status==="running"||g.status==="awaiting_input"?"url(#glow)":void 0,children:(g.status==="running"||g.status==="awaiting_input")&&s.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),s.jsx("text",{x:26,y:ir/2-4,fill:"var(--terminal-text, #fff)",fontSize:10,fontWeight:700,fontFamily:"var(--pixel-font)",children:g.roleId.toUpperCase()}),s.jsx("text",{x:26,y:ir/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:g.status==="running"?"Working...":g.status==="awaiting_input"?"Awaiting Reply":g.status==="done"?"Complete":g.status==="error"?"Error":g.status==="waiting"?"Waiting":""}),g.status==="done"&&s.jsx("text",{x:ba-18,y:ir/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),g.status==="error"&&s.jsx("text",{x:ba-18,y:ir/2+4,fontSize:14,fill:"#C62828",children:"✗"})]},f.roleId)})]})}const mC={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function xC({directive:t,rootJobs:l,orgNodes:r,rootRoleId:i,onClose:c,onMinimize:u,onDone:d,onOpenKnowledgeDoc:m}){const{nodes:x,selectedRoleId:f,selectNode:g,progress:y,allDone:b,connectStream:v}=dC(l,r,i),[S,j]=k.useState(0),[E,C]=k.useState(new Set),[A,F]=k.useState(""),[_,H]=k.useState(!1),M=k.useRef(null),I=k.useRef(Date.now()),W=k.useRef(!1),te=k.useCallback(async()=>{if(!f||!A.trim())return;const L=x.get(f);if(!(!(L!=null&&L.jobId)||L.status!=="awaiting_input")){H(!0);try{const{jobId:Z}=await Ce.replyToJob(L.jobId,A.trim());F(""),v(Z,f)}catch(Z){console.error("Reply failed:",Z)}finally{H(!1)}}},[f,A,x,v]),D=k.useCallback(async L=>{const Z=x.get(L);if(Z!=null&&Z.jobId)try{await Ce.abortJob(Z.jobId)}catch(de){console.error("Abort failed:",de)}},[x]),Y=k.useCallback(async()=>{for(const[,L]of x)if((L.status==="running"||L.status==="awaiting_input")&&L.jobId)try{await Ce.abortJob(L.jobId)}catch{}},[x]);k.useEffect(()=>{const L=setInterval(()=>{j(Math.floor((Date.now()-I.current)/1e3))},1e3);return()=>clearInterval(L)},[]),k.useEffect(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[f,x]),k.useEffect(()=>{b&&!W.current&&(W.current=!0,d==null||d())},[b,d]);const B=L=>`${Math.floor(L/60)}:${String(L%60).padStart(2,"0")}`,V=f?x.get(f):null,ne=f?mC[f]??"#888":"#888",G=L=>{C(Z=>{const de=new Set(Z);return de.has(L)?de.delete(L):de.add(L),de})};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:b?c:void 0}),s.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[960px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:b?"#2E7D32":"#B71C1C",animation:b?void 0:"wave-pulse 2s ease-in-out infinite"}}),s.jsx("div",{children:s.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:b?"WAVE COMPLETE":"WAVE COMMAND CENTER"})})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:B(S)}),y.awaitingInput>0&&s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[y.awaitingInput," awaiting reply"]}),s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:b?"#2E7D3222":"#B71C1C22",color:b?"#2E7D32":"#B71C1C"},children:[y.done,"/",y.total," done"]}),!b&&(y.running>0||y.awaitingInput>0)&&s.jsx("button",{onClick:Y,className:"text-xs px-2 py-0.5 rounded font-semibold cursor-pointer",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Stop all running jobs",children:"Stop All"}),s.jsx("button",{onClick:u,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),b&&s.jsx("button",{onClick:c,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",children:"×"})]})]}),s.jsx("div",{className:"px-5 py-2 border-b border-[var(--terminal-border)] shrink-0",children:s.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic",children:["“",t,"”"]})}),s.jsxs("div",{className:"flex flex-1 min-h-0",children:[s.jsxs("div",{className:"w-[280px] shrink-0 border-r border-[var(--terminal-border)] flex flex-col",children:[s.jsx("div",{className:"px-3 py-2 border-b border-[var(--terminal-border)]",children:s.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:"Org Propagation"})}),s.jsx("div",{className:"flex-1 overflow-auto p-3",children:s.jsx(hC,{nodes:x,rootId:i,selectedRoleId:f,onSelectNode:g})}),s.jsx("div",{className:"px-3 py-2 border-t border-[var(--terminal-border)] flex flex-wrap gap-x-3 gap-y-1",children:[{label:"running",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(L=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L.color,animation:L.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),s.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:L.label})]},L.label))})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[V&&s.jsxs("div",{className:"px-4 py-2 border-b border-[var(--terminal-border)] shrink-0 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:ne}}),s.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:V.roleId.toUpperCase()}),s.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:V.roleName}),s.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:V.status==="awaiting_input"?"#F59E0B22":`${ne}22`,color:V.status==="awaiting_input"?"#F59E0B":ne},children:V.status==="running"?"Working":V.status==="done"?"Complete":V.status==="error"?"Error":V.status==="waiting"?"Waiting":V.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(V.status==="running"||V.status==="awaiting_input")&&V.jobId&&s.jsx("button",{onClick:()=>D(V.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Force stop this job",children:"Stop"})]}),s.jsxs("div",{ref:M,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[V&&V.events.length===0&&s.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:V.status==="waiting"?"Waiting for dispatch...":V.status==="running"?"Connecting to activity stream...":V.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),V==null?void 0:V.events.map(L=>s.jsx(mg,{event:L,isThinkingCollapsed:E.has(L.seq),onToggleThinking:()=>G(L.seq),onNavigateToJob:Z=>{for(const[,de]of x)if(de.jobId===Z){g(de.roleId);return}},onOpenKnowledgeDoc:m},L.seq)),(V==null?void 0:V.status)==="running"&&s.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(V==null?void 0:V.status)==="awaiting_input"&&s.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#F59E0B0A"},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),s.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#F59E0B"},children:[V.roleName," is waiting for your response"]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:A,onChange:L=>F(L.target.value),onKeyDown:L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),te())},placeholder:"Type your response...",disabled:_,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#F59E0B]",autoFocus:!0}),s.jsx("button",{onClick:te,disabled:_||!A.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#F59E0B",color:"#000"},children:_?"...":"Reply"})]})]}),!V&&s.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-xs",children:"Click a node in the org tree to view activity"}),s.jsxs("div",{className:"px-4 py-2 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[s.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:V&&V.events.length>0&&`${V.events.length} events`}),b&&s.jsx("button",{onClick:c,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer",style:{background:"#2E7D32"},children:"Close"})]})]})]})]})]})}const pC={cto:{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"glasses"},cbo:{skinColor:"#FDEBD0",hairColor:"#1A0A00",shirtColor:"#E65100",pantsColor:"#37474F",shoeColor:"#1A1A1A",hairStyle:"slicked",outfitStyle:"suit",accessory:"lapels"},pm:{skinColor:"#FDEBD0",hairColor:"#6D4C41",shirtColor:"#2E7D32",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bun",outfitStyle:"tshirt",accessory:"blush"},engineer:{skinColor:"#F5CBA7",hairColor:"#1A1A1A",shirtColor:"#4A148C",pantsColor:"#37474F",shoeColor:"#7B1FA2",hairStyle:"messy",outfitStyle:"hoodie",accessory:"headphones"},designer:{skinColor:"#FDEBD0",hairColor:"#AD1457",shirtColor:"#AD1457",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bob",outfitStyle:"tshirt",accessory:"beret"},qa:{skinColor:"#F5CBA7",hairColor:"#4E342E",shirtColor:"#00695C",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"badge"},"data-analyst":{skinColor:"#F5CBA7",hairColor:"#3E2723",shirtColor:"#0277BD",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"curly",outfitStyle:"vest",accessory:"none"}};function Th(t){return pC[t]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const xg=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],pg=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],yg=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],gg=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],bg=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],Gr={default:{name:"MIDNIGHT",icon:"🌃",vars:{"--floor-light":"#0d1117","--floor-dark":"#0a0e14","--hud-bg":"#0d1117","--hud-bg-alt":"#161b22","--pixel-border":"#30363d","--terminal-bg":"#0d1117","--terminal-border":"#21262d","--terminal-border-hover":"#388bfd","--terminal-text":"#e6edf3","--terminal-text-secondary":"#8b949e","--terminal-text-muted":"#484f58","--accent":"#388bfd","--active-green":"#3fb950","--idle-amber":"#d29922"}},light:{name:"DAYLIGHT",icon:"☀️",vars:{"--floor-light":"#f6f8fa","--floor-dark":"#eaeef2","--hud-bg":"#24292f","--hud-bg-alt":"#32383f","--pixel-border":"#d0d7de","--terminal-bg":"#ffffff","--terminal-border":"#d0d7de","--terminal-border-hover":"#0969da","--terminal-text":"#1f2328","--terminal-text-secondary":"#656d76","--terminal-text-muted":"#8c959f","--accent":"#0969da","--active-green":"#1a7f37","--idle-amber":"#9a6700"}},retro:{name:"RETRO",icon:"🎮",vars:{"--floor-light":"#1a1410","--floor-dark":"#140f0a","--hud-bg":"#1a1410","--hud-bg-alt":"#2a2018","--pixel-border":"#5c4a32","--terminal-bg":"#1a1410","--terminal-border":"#3a2e20","--terminal-border-hover":"#d4a44e","--terminal-text":"#e8d5b0","--terminal-text-secondary":"#a08860","--terminal-text-muted":"#6b5840","--accent":"#d4a44e","--active-green":"#8bba4a","--idle-amber":"#e8a030"}},cyberpunk:{name:"NEON",icon:"🌌",vars:{"--floor-light":"#0a0014","--floor-dark":"#06000e","--hud-bg":"#0a0014","--hud-bg-alt":"#14002a","--pixel-border":"#4a1a80","--terminal-bg":"#0a0014","--terminal-border":"#2a0a50","--terminal-border-hover":"#e040fb","--terminal-text":"#e0d0ff","--terminal-text-secondary":"#9070c0","--terminal-text-muted":"#5a3a80","--accent":"#e040fb","--active-green":"#00ff88","--idle-amber":"#ffab00"}},forest:{name:"FOREST",icon:"🌲",vars:{"--floor-light":"#0a1410","--floor-dark":"#060e0a","--hud-bg":"#0a1410","--hud-bg-alt":"#142a1e","--pixel-border":"#2a5a3a","--terminal-bg":"#0a1410","--terminal-border":"#1a3a26","--terminal-border-hover":"#4ade80","--terminal-text":"#d0f0d8","--terminal-text-secondary":"#70a880","--terminal-text-muted":"#3a6848","--accent":"#4ade80","--active-green":"#86efac","--idle-amber":"#fcd34d"}},ocean:{name:"OCEAN",icon:"🌊",vars:{"--floor-light":"#0a1420","--floor-dark":"#060e18","--hud-bg":"#0a1420","--hud-bg-alt":"#142a40","--pixel-border":"#1e4a6a","--terminal-bg":"#0a1420","--terminal-border":"#163050","--terminal-border-hover":"#38bdf8","--terminal-text":"#d0e8f8","--terminal-text-secondary":"#6090b0","--terminal-text-muted":"#305070","--accent":"#38bdf8","--active-green":"#34d399","--idle-amber":"#fbbf24"}}};function yC({color:t,selected:l,onClick:r}){return s.jsx("button",{onClick:r,className:"customize-swatch",style:{background:t,outline:l?"2px solid #fff":"2px solid transparent",boxShadow:l?`0 0 0 1px ${t}, 0 0 6px ${t}88`:"none"}})}function ks({label:t,presets:l,value:r,onChange:i}){return s.jsxs("div",{className:"customize-row",children:[s.jsxs("div",{className:"customize-row-header",children:[s.jsx("span",{className:"customize-row-label",children:t}),s.jsx("div",{className:"customize-row-current",style:{background:r}})]}),s.jsx("div",{className:"customize-swatches",children:l.map(c=>s.jsx(yC,{color:c,selected:c===r,onClick:()=>i(c)},c))})]})}function kf({label:t,items:l,value:r,onChange:i,lockInfo:c}){return s.jsxs("div",{className:"customize-row",children:[s.jsx("div",{className:"customize-row-header",children:s.jsx("span",{className:"customize-row-label",children:t})}),s.jsx("div",{className:"customize-swatches",style:{gap:4},children:l.map(u=>{const d=c?c.getLockLevel(u.id):1,m=u.id===r,x=c?d>c.roleLevel&&!m:!1,f=c?m&&d>c.roleLevel:!1;return s.jsxs("button",{onClick:()=>{x||i(u.id===r?void 0:u.id)},className:"customize-swatch",style:{width:"auto",height:"auto",padding:x?"2px 6px 10px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:m?"rgba(255,255,255,0.15)":x?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",outline:m?f?"2px solid #F59E0B":"2px solid #fff":"2px solid transparent",color:x?"rgba(255,255,255,0.25)":m?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:x?"not-allowed":"pointer",opacity:x?.35:1,position:"relative"},children:[u.name,x&&s.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:"rgba(255,255,255,0.5)",whiteSpace:"nowrap"},children:["🔒"," Lv.",d]}),f&&s.jsxs("span",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",fontSize:7,color:"#F59E0B",whiteSpace:"nowrap"},children:["⚠"," Lv.",d]})]},u.id)})})]})}function jf({label:t,active:l,onClick:r}){return s.jsx("button",{onClick:r,style:{flex:1,padding:"6px 0",fontSize:10,fontFamily:"var(--font-pixel, monospace)",fontWeight:"bold",letterSpacing:1,background:l?"rgba(255,255,255,0.08)":"transparent",color:l?"#fff":"rgba(255,255,255,0.35)",border:"none",borderBottom:l?"2px solid #3B82F6":"2px solid transparent",cursor:"pointer",transition:"all 0.15s"},children:t})}function Ir(t){return t[Math.floor(Math.random()*t.length)]}function fi(t){var c,u,d;const l=ng(),r=lg(),i=rg().filter(m=>!t||ig(m.id,t));return{skinColor:Ir(xg),hairColor:Ir(pg),shirtColor:Ir(yg),pantsColor:Ir(gg),shoeColor:Ir(bg),hairStyle:(c=Ir(l))==null?void 0:c.id,outfitStyle:(u=Ir(r))==null?void 0:u.id,accessory:(d=Ir(i))==null?void 0:d.id}}function vg({roleId:t,appearance:l,onChange:r,onRandomize:i,onReset:c,label:u,roleLevel:d}){const[m,x]=k.useState("look"),f=k.useCallback((E,C)=>{r({...l,[E]:C})},[l,r]),g=k.useRef(null),y=k.useCallback(E=>{var F;const C=(F=E.target.files)==null?void 0:F[0];if(!C)return;const A=new Image;A.onload=()=>{const _=Hj(A);r({..._,hairStyle:l.hairStyle,outfitStyle:l.outfitStyle,accessory:l.accessory}),URL.revokeObjectURL(A.src)},A.src=URL.createObjectURL(C),E.target.value=""},[l.hairStyle,l.outfitStyle,l.accessory,r]),b=ng(),v=lg(),S=rg(),j=d!==void 0?S.filter(E=>ig(E.id,d)).length:S.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"customize-preview",children:[s.jsx("div",{className:"customize-preview-bg",children:s.jsx(_s,{roleId:t,appearance:l,scale:12})}),u&&s.jsx("div",{className:"customize-preview-name",children:u}),s.jsxs("div",{className:"customize-preview-actions",children:[s.jsx("button",{className:"customize-btn customize-btn--random",onClick:i,children:"RANDOM"}),s.jsx("button",{className:"customize-btn customize-btn--reset",onClick:c,children:"RESET"}),s.jsx("button",{className:"customize-btn",onClick:()=>{var E;return(E=g.current)==null?void 0:E.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),s.jsx("input",{ref:g,type:"file",accept:"image/*",onChange:y,style:{display:"none"}})]})]}),s.jsxs("div",{className:"customize-colors",children:[s.jsxs("div",{style:{display:"flex",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:[s.jsx(jf,{label:"LOOK",active:m==="look",onClick:()=>x("look")}),s.jsx(jf,{label:"OUTFIT",active:m==="outfit",onClick:()=>x("outfit")}),s.jsx(jf,{label:"ACCESSORY",active:m==="accessory",onClick:()=>x("accessory")})]}),m==="look"&&s.jsxs(s.Fragment,{children:[s.jsx(ks,{label:"SKIN",presets:xg,value:l.skinColor,onChange:E=>f("skinColor",E)}),s.jsx(ks,{label:"HAIR COLOR",presets:pg,value:l.hairColor,onChange:E=>f("hairColor",E)}),s.jsx(kf,{label:"HAIR STYLE",items:b,value:l.hairStyle,onChange:E=>f("hairStyle",E)})]}),m==="outfit"&&s.jsxs(s.Fragment,{children:[s.jsx(kf,{label:"STYLE",items:v,value:l.outfitStyle,onChange:E=>f("outfitStyle",E)}),s.jsx(ks,{label:"TOP",presets:yg,value:l.shirtColor,onChange:E=>f("shirtColor",E)}),s.jsx(ks,{label:"PANTS",presets:gg,value:l.pantsColor,onChange:E=>f("pantsColor",E)}),s.jsx(ks,{label:"SHOES",presets:bg,value:l.shoeColor,onChange:E=>f("shoeColor",E)})]}),m==="accessory"&&s.jsxs(s.Fragment,{children:[d!==void 0&&s.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s.jsxs("span",{children:["Lv.",d]}),s.jsxs("span",{children:[j,"/",S.length," unlocked"]})]}),s.jsx(kf,{label:"ACCESSORY",items:S,value:l.accessory,onChange:E=>f("accessory",E),lockInfo:d!==void 0?{roleLevel:d,getLockLevel:ag}:void 0}),s.jsx("div",{style:{marginTop:12,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,border:"1px dashed rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.25)",fontSize:9,fontFamily:"var(--font-pixel, monospace)",textAlign:"center"},children:d!==void 0&&d<10?"Level up to unlock more accessories":"More accessories coming soon"})]})]})]})}const gC=[{value:"c-level",label:"C-Level"},{value:"team-lead",label:"Team Lead"},{value:"member",label:"Member"}];function Jf(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Sf(t){switch(t){case"c-level":return{authority:{autonomous:["Strategic decisions within domain","Task delegation to reports"],needsApproval:["Budget over $5K","External commitments"]},knowledge:{reads:["company/","operations/","projects/"],writes:["operations/","knowledge/"]},reports:{daily:"standup",weekly:"summary"}};case"team-lead":return{authority:{autonomous:["Task planning","Sprint management"],needsApproval:["Architecture changes","New tool adoption"]},knowledge:{reads:["projects/","architecture/"],writes:["projects/"]},reports:{daily:"standup",weekly:"summary"}};default:return{authority:{autonomous:["Implementation within assigned tasks"],needsApproval:["Design changes","New dependencies"]},knowledge:{reads:["projects/"],writes:[]},reports:{daily:"standup",weekly:""}}}}const js=4;function bC(t,l,r){const i=t.trim();if(!i||i.startsWith("#"))return null;const c=i.split(",").map(y=>y.trim()),u=c[0];if(!u)return null;const d=Jf(u),m=(c[1]||"member").toLowerCase(),x=m==="c-level"?"c-level":m==="team-lead"?"team-lead":"member",f=c[2]||"ceo";let g;return l.has(d)?g="ID already exists":r.has(d)&&(g="Duplicate ID in batch"),r.add(d),{name:u,id:d,level:x,reportsTo:f,error:g}}function vC({existingRoles:t,onClose:l,onHire:r}){const[i,c]=k.useState("single"),[u,d]=k.useState(""),[m,x]=k.useState(null),[f,g]=k.useState(!1),[y,b]=k.useState(""),[v,S]=k.useState("input"),[j,E]=k.useState(""),[C,A]=k.useState(""),[F,_]=k.useState("ceo"),[H,M]=k.useState(1),[I,W]=k.useState(""),[te,D]=k.useState(""),[Y,B]=k.useState(!1),[V,ne]=k.useState("member"),[G,L]=k.useState("ceo"),[Z,de]=k.useState(""),[ue,z]=k.useState(fi),[R,K]=k.useState(!1),[T,fe]=k.useState(""),[Ee,Ne]=k.useState([]),[Le,Be]=k.useState(new Set),[Qe,Se]=k.useState(""),[tt,me]=k.useState("input"),[he,ge]=k.useState({done:0,total:0}),ke=k.useRef(null),Fe=k.useRef(null),Ae=k.useRef(null);k.useEffect(()=>{Ce.getSkills().then(q=>Ne(q.filter(ze=>ze.installed))).catch(()=>{})},[]),k.useEffect(()=>{var q,ze,He;i==="single"?(H===1&&((q=ke.current)==null||q.focus()),H===2&&((ze=Fe.current)==null||ze.focus())):tt==="input"&&((He=Ae.current)==null||He.focus())},[H,i,tt]);const De=k.useMemo(()=>new Set(t.map(q=>q.id)),[t]),je=k.useMemo(()=>{const q=Qe.split(`
82
82
  `),ze=new Set;return q.map(He=>bC(He,De,ze)).filter(He=>He!==null)},[Qe,De]),_e=je.length>0&&je.every(q=>!q.error),Ke=q=>{W(q),Y||D(Jf(q))},Et=I.trim().length>0&&te.trim().length>0&&!t.some(q=>q.id===te),Ht=Z.trim().length>0,gt=async()=>{K(!0),fe("");const q=Sf(V);try{await r({id:te,name:I.trim(),level:V,reportsTo:G,persona:Z.trim(),...q,skills:Le.size>0?[...Le]:void 0},ue),l()}catch(ze){fe(ze instanceof Error?ze.message:"Failed to create role"),K(!1)}},Rt=q=>q===1?Et:q===2?Ht:!0,re=async()=>{K(!0),fe(""),ge({done:0,total:je.length});try{for(let q=0;q<je.length;q++){const ze=je[q],He=Sf(ze.level),Xe=fi(),ht=`${ze.name}. A ${ze.level} role reporting to ${ze.reportsTo}.`;await r({id:ze.id,name:ze.name,level:ze.level,reportsTo:ze.reportsTo,persona:ht,...He},Xe),ge({done:q+1,total:je.length})}l()}catch(q){fe(q instanceof Error?q.message:"Failed to create roles"),K(!1)}},pe=async()=>{g(!0),b("");try{const q=u.replace(/^tycono:/,"").trim();if(!q){b("Please enter a character ID"),g(!1);return}const ze=await mi.getCharacter(q);x(ze),E(ze.name||""),A(Jf(ze.name||q)),S("review")}catch{b("Character not found. Check the ID and try again.")}finally{g(!1)}},Te=async()=>{if(!m)return;K(!0),fe("");const q=m,ze=q.level==="c-level"||q.level==="team-lead"?q.level:"member",He=Sf(ze),Xe=q.skills!=null&&typeof q.skills=="object"&&!Array.isArray(q.skills)&&"primary"in q.skills;try{await r({id:C,name:j.trim(),level:ze,reportsTo:F,persona:q.persona||`${j}. Imported from Tycono Store.`,authority:q.authority||He.authority,knowledge:He.knowledge,reports:He.reports,source:{id:`tycono/${q.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:Xe?q.skills:void 0},q.appearance?q.appearance:fi()),l()}catch(ht){fe(ht instanceof Error?ht.message:"Failed to hire"),K(!1)}},Ye=q=>{q.key==="Escape"&&l(),q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&(i==="single"?H<js&&Rt(H)?M(H+1):H===js&&gt():i==="bulk"?tt==="input"&&_e?me("review"):tt==="review"&&re():i==="store"&&(v==="input"&&u.trim()?pe():v==="review"&&Te()))},xe=t.some(q=>q.id===te)&&te.length>0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:l}),s.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] max-h-[90vh] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",onKeyDown:Ye,children:[s.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #2E7D32, #43A047)"},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-lg font-bold",children:"Hire New Role"}),s.jsxs("div",{className:"flex bg-black/20 rounded-lg p-0.5",children:[s.jsx("button",{onClick:()=>{c("single"),fe("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${i==="single"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Single"}),s.jsx("button",{onClick:()=>{c("bulk"),fe("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${i==="bulk"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Bulk"}),s.jsx("button",{onClick:()=>{c("store"),fe("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${i==="store"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Import"})]})]}),s.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:i==="single"?`Step ${H} of ${js}`:i==="bulk"?tt==="input"?"Enter roles, one per line":`Review ${je.length} roles`:v==="input"?"Import from Tycono Store":"Review & customize"})]}),i==="single"&&s.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:js},(q,ze)=>ze+1).map(q=>s.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:q<=H?"#2E7D32":"rgba(255,255,255,0.1)"}},q))}),s.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:i==="store"?s.jsxs(s.Fragment,{children:[v==="input"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Character ID"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:u,onChange:q=>d(q.target.value),placeholder:"tycono:engineer",className:"flex-1 p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 font-mono focus:outline-none focus:border-white/25 transition-colors",onKeyDown:q=>{q.key==="Enter"&&u.trim()&&pe()},autoFocus:!0}),s.jsx("button",{onClick:pe,disabled:!u.trim()||f,className:"px-4 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:f?"Fetching...":"Fetch"})]}),s.jsxs("div",{className:"text-[10px] text-gray-400 mt-1",children:["Copy a character ID from ",s.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",className:"text-green-400 hover:underline",children:"tycono.ai/store"})," and paste it here"]})]}),y&&s.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:y})]}),v==="review"&&m&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"bg-white/5 rounded-xl p-4 border border-white/10",children:[s.jsxs("div",{className:"flex gap-4",children:[m.appearance&&s.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:s.jsx(_s,{roleId:"store-preview",appearance:m.appearance,scale:4})}),s.jsxs("div",{className:"flex-1 space-y-2.5",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Name"}),s.jsx("input",{value:j,onChange:q=>E(q.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Role ID"}),s.jsx("input",{value:C,onChange:q=>A(q.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 font-mono focus:outline-none focus:border-white/25 transition-colors"}),t.some(q=>q.id===C)&&C.length>0&&s.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Level"}),s.jsx("div",{className:"text-sm text-white/70 p-2 rounded-lg bg-white/5 border border-white/10",children:m.level==="c-level"?"C-Level":m.level==="team-lead"?"Lead":"Member"})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Reports To"}),s.jsxs("select",{value:F,onChange:q=>_(q.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:[s.jsx("option",{value:"ceo",className:"bg-[var(--wall)] text-white",children:"CEO"}),t.map(q=>s.jsxs("option",{value:q.id,className:"bg-[var(--wall)] text-white",children:[q.name," (",q.id,")"]},q.id))]})]})]})]})]}),m.persona&&s.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[s.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),s.jsx("div",{className:"text-xs text-white/60 leading-relaxed line-clamp-3",children:m.persona})]}),m.skills&&s.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[s.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Skills"}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{var Xe,ht;const q=m.skills;if(q&&typeof q=="object"&&!Array.isArray(q)&&"primary"in q){const Pe=[];return(ht=(Xe=q.primary)==null?void 0:Xe.frontmatter)!=null&&ht.name&&Pe.push(q.primary.frontmatter.name),q.shared&&q.shared.forEach(We=>{var un;return Pe.push(((un=We.frontmatter)==null?void 0:un.name)||We.id)}),Pe.map(We=>s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:We},We))}return(Array.isArray(q)?q:[]).map((Pe,We)=>s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:typeof Pe=="string"?Pe:Pe.name},We))})()})]})]}),T&&s.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:T})]})]}):i==="single"?s.jsxs(s.Fragment,{children:[H===1&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role Name"}),s.jsx("input",{ref:ke,value:I,onChange:q=>Ke(q.target.value),placeholder:"e.g. Data Analyst",className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role ID (slug)"}),s.jsx("input",{value:te,onChange:q=>{D(q.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),B(!0)},className:`w-full p-2.5 rounded-lg border bg-white/5 text-sm text-white/90 font-mono focus:outline-none transition-colors ${xe?"border-red-400":"border-white/10 focus:border-white/25"}`}),xe&&s.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Level"}),s.jsx("div",{className:"flex gap-2",children:gC.map(q=>s.jsx("button",{onClick:()=>ne(q.value),className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${V===q.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:q.label},q.value))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Reports To"}),s.jsxs("select",{value:G,onChange:q=>L(q.target.value),className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:[s.jsx("option",{value:"ceo",className:"bg-[var(--wall)] text-white",children:"CEO"}),t.map(q=>s.jsxs("option",{value:q.id,className:"bg-[var(--wall)] text-white",children:[q.name," (",q.id,")"]},q.id))]})]})]}),H===2&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Persona"}),s.jsx("textarea",{ref:Fe,value:Z,onChange:q=>de(q.target.value),placeholder:"Describe this role's personality, expertise, and working style...",className:"w-full h-32 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"}),s.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"This defines how the AI agent will behave in this role"})]}),Ee.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Skills"}),s.jsx("div",{className:"space-y-1.5 max-h-[120px] overflow-y-auto",children:Ee.map(q=>s.jsxs("label",{className:"flex items-center gap-2 p-2 rounded-lg border border-white/10 bg-white/5 cursor-pointer hover:border-white/20 transition-colors",children:[s.jsx("input",{type:"checkbox",checked:Le.has(q.id),onChange:()=>Be(ze=>{const He=new Set(ze);return He.has(q.id)?He.delete(q.id):He.add(q.id),He}),className:"accent-green-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-white/80",children:q.name}),s.jsx("div",{className:"text-[10px] text-white/40 truncate",children:q.description})]})]},q.id))})]})]}),H===3&&s.jsx("div",{className:"customize-body",style:{padding:0},children:s.jsx(vg,{roleId:"default",appearance:ue,onChange:z,onRandomize:()=>z(fi()),onReset:()=>z(fi()),label:s.jsxs("span",{children:[te||"new-role"," — ",I||"New Role"]})})}),H===4&&s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Review"}),s.jsxs("div",{className:"bg-white/5 rounded-xl p-4 border border-white/10",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:s.jsx(_s,{roleId:"default",appearance:ue,scale:4})}),s.jsxs("div",{className:"flex-1 space-y-2.5",children:[s.jsx(Ss,{label:"Name",value:I}),s.jsx(Ss,{label:"ID",value:te,mono:!0}),s.jsx(Ss,{label:"Level",value:V}),s.jsx(Ss,{label:"Reports To",value:G}),Le.size>0&&s.jsx(Ss,{label:"Skills",value:[...Le].join(", ")})]})]}),s.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[s.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),s.jsx("div",{className:"text-xs text-white/60 leading-relaxed",children:Z})]})]}),T&&s.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:T})]})]}):s.jsxs(s.Fragment,{children:[tt==="input"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Roles (one per line)"}),s.jsx("textarea",{ref:Ae,value:Qe,onChange:q=>Se(q.target.value),placeholder:`Name, Level, ReportsTo
83
83
  e.g.
84
84
  Data Analyst
@@ -97,4 +97,4 @@ ${ae}`;za(se.id,ye,"do")}catch(se){yt(`Failed to delegate: ${se instanceof Error
97
97
  bg-[var(--terminal-bg)] text-[var(--terminal-text)]
98
98
  border border-[var(--terminal-border)]
99
99
  focus:border-[var(--terminal-border-hover)]
100
- placeholder:text-[var(--terminal-text-muted)]`,Wt=ve=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ve?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return s.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:$n,children:s.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:[s.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[s.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),s.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),s.jsx("div",{className:"flex gap-1.5 mt-4",children:ze.map((ve,Zt)=>s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Zt<=l?"var(--accent)":"var(--terminal-surface-light)"}}),s.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Zt===l?"var(--terminal-text)":"var(--terminal-text-muted)"},children:fN[ve]})]},ve))})]}),s.jsxs("div",{className:"px-6 py-5 min-h-[280px]",children:[He==="engine"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"AI Engine Setup"}),f?s.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:"Detecting AI engine..."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:Wt(u==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&d("claude-cli"),style:{opacity:i!=null&&i.claudeCli?1:.4},children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-lg",children:i!=null&&i.claudeCli?"✅":"❌"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-sm",children:"Claude Code CLI"}),s.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"})]})]})}),s.jsxs("div",{className:Wt(u==="direct-api"),onClick:()=>d("direct-api"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-lg",children:i!=null&&i.apiKey?"✅":"🔑"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"font-medium text-sm",children:"Anthropic API Key (BYOK)"}),s.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)&&s.jsx("input",{type:"password",className:`${fn} mt-3`,placeholder:"sk-ant-...",value:m,onChange:ve=>x(ve.target.value),autoFocus:!0})]})]})]}),He==="company"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company Info"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),s.jsx("input",{ref:te,className:fn,placeholder:"e.g. Acme Corp",value:y,onChange:ve=>b(ve.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),s.jsx("textarea",{className:`${fn} resize-none`,rows:3,placeholder:"What does your AI company do?",value:v,onChange:ve=>S(ve.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Location"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/your-company",value:C,onChange:ve=>{A(ve.target.value),M(!0)}}),s.jsx("button",{onClick:()=>W(!I),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),s.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--terminal-text-muted)"},children:"Where your AI company files will be created."}),I&&s.jsx(yc,{onSelect:ve=>{A(ve),M(!0),W(!1)},onClose:()=>W(!1)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"AI Response Language"}),s.jsxs("select",{className:fn,value:j,onChange:ve=>E(ve.target.value),children:[s.jsx("option",{value:"auto",children:"Auto"}),s.jsx("option",{value:"en",children:"English"}),s.jsx("option",{value:"ko",children:"한국어"}),s.jsx("option",{value:"ja",children:"日本語"})]})]})]}),He==="project"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Project Setup"}),s.jsxs("div",{className:Wt(D==="fresh"),onClick:()=>{Y("fresh"),G(null)},children:[s.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Create a new AI company from scratch with clean directory structure."})]}),s.jsxs("div",{className:Wt(D==="existing"),onClick:()=>Y("existing"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["📂"," Connect Existing Project"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Add AI company structure to an existing codebase or knowledge base."}),D==="existing"&&s.jsxs("div",{className:"mt-3",onClick:ve=>ve.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/your/project",value:B,onChange:ve=>{V(ve.target.value),G(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>ue(!de),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:"📁"}),s.jsx("button",{onClick:We,disabled:L||!B.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:L||!B.trim()?.5:1},children:L?"...":"Verify"})]}),ne===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Path verified: ",B]}),ne===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," Invalid path"]}),de&&s.jsx(yc,{onSelect:ve=>{V(ve),G(!0),ue(!1)},onClose:()=>ue(!1)})]})]})]}),He==="knowledge"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Knowledge Strategy"}),s.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"How should AI handle your knowledge base?"}),s.jsxs("div",{className:Wt(z==="skip"),onClick:()=>R("skip"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Empty knowledge base. Add documents later from the office."})]}),s.jsxs("div",{className:Wt(z==="import"),onClick:()=>R("import"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["📚"," Import & Build"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Select folders with documents — AI reads, summarizes, and organizes them."}),z==="import"&&s.jsxs("div",{className:"mt-3 space-y-2",onClick:ve=>ve.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/docs",value:fe,onChange:ve=>Ee(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&(ve.preventDefault(),$l())},autoFocus:!0}),s.jsx("button",{onClick:()=>Le(!Ne),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:"📁"}),s.jsx("button",{onClick:$l,disabled:!fe.trim(),className:"px-3 py-2 rounded text-xs font-medium",style:{background:"var(--accent)",color:"#fff",opacity:fe.trim()?1:.5},children:"Add"})]}),Ne&&s.jsx(yc,{onSelect:ve=>{K.includes(ve)||T([...K,ve]),Le(!1)},onClose:()=>Le(!1)}),K.length>0&&s.jsx("div",{className:"space-y-1",children:K.map((ve,Zt)=>s.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:[s.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:ve}),s.jsx("button",{onClick:()=>T(K.filter((Zr,cl)=>cl!==Zt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Zt))}),K.length===0&&s.jsx("div",{className:"text-[10px] text-center py-2",style:{color:"var(--terminal-text-muted)"},children:"Add at least one folder to import."})]})]}),s.jsxs("div",{className:Wt(z==="existing-akb"),onClick:()=>R("existing-akb"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["🔗"," Connect Existing AKB"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Connect a directory that already has CLAUDE.md and AKB structure."}),z==="existing-akb"&&s.jsxs("div",{className:"mt-3",onClick:ve=>ve.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/your/akb",value:Be,onChange:ve=>{Qe(ve.target.value),tt(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>ke(!ge),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:"📁"}),s.jsx("button",{onClick:un,disabled:me||!Be.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:me||!Be.trim()?.5:1},children:me?"...":"Verify"})]}),Se===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found: ",Be]}),Se===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),ge&&s.jsx(yc,{onSelect:ve=>{Qe(ve),tt(null),ke(!1)},onClose:()=>ke(!1)})]})]})]}),He==="team"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Team Template"}),s.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"Choose a starting team. You can add or remove roles later."}),Fe.map(ve=>s.jsxs("div",{className:Wt(De===ve.id),onClick:()=>je(ve.id),children:[s.jsx("div",{className:"font-medium text-sm capitalize",children:ve.id}),s.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ve.roles.map(Zt=>s.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:Zt.name},Zt.id))})]},ve.id)),s.jsxs("div",{className:Wt(De==="custom"),onClick:()=>je("custom"),children:[s.jsx("div",{className:"font-medium text-sm",children:"Custom"}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Start with no pre-built roles. Hire them from the office."})]})]}),He==="create"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:Et?z==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!Et&&!_e&&!xe&&s.jsxs(s.Fragment,{children:[s.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"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Path:"})," ",Be]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Company:"})," ",y]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Location:"})," ",C||"(default)"]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Project:"})," ",D==="fresh"?"Start Fresh":`Existing (${B})`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",z==="skip"?"Fresh (empty)":`Import ${K.length} source(s)`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Team:"})," ",De]}),z==="import"&&K.length>0&&s.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),gt&&s.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:gt})]}),(_e||xe)&&s.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[s.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),s.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:xe?"Connecting to AKB...":"Scaffolding your company..."})]}),Et&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),Te&&s.jsxs("div",{className:"rounded-lg p-3 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[s.jsx("span",{className:"opacity-50",children:"Location:"})," ",Te]}),s.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:re.map((ve,Zt)=>s.jsxs("div",{className:"py-0.5",children:[s.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ve]},Zt))}),z==="import"&&K.length>0&&s.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."})]})]})]}),s.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[s.jsx("div",{children:l>0&&!Et&&s.jsx("button",{onClick:Pe,className:"px-4 py-2 rounded text-sm transition-colors",style:{color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Back"})}),s.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[l+1," / ",ze.length]}),s.jsx("div",{children:Et?s.jsx("button",{onClick:dr,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff"},children:"Enter Office"}):s.jsx("button",{onClick:ht,disabled:!Xe()||_e||xe,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Xe()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Xe()&&!_e&&!xe?1:.5},children:He==="create"?_e||xe?xe?"Connecting...":"Creating...":z==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function mN(){const[t,l]=k.useState(null),[r,i]=k.useState(!0),[c,u]=k.useState(null),d=k.useCallback(async()=>{i(!0),u(null);try{const m=await Ce.getStatus();l(m)}catch(m){u(m instanceof Error?m.message:"Failed to fetch status")}finally{i(!1)}},[]);return k.useEffect(()=>{d()},[d]),{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:d}}const xN=k.lazy(()=>J2(()=>import("./preview-app-mMmnwqgt.js"),[]));function _g(){return s.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"w-10 h-10 mx-auto border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),s.jsx("div",{className:"mt-4 text-sm",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Loading..."})]})})}function pN(){var t;try{const l=localStorage.getItem("tycono-theme"),r=l&&l in Gr?l:"default",i=(t=Gr[r])==null?void 0:t.vars;if(!i)return;const c=document.documentElement;for(const[u,d]of Object.entries(i))c.style.setProperty(u,d)}catch{}}function yN(){const{initialized:t,loading:l,refetch:r}=mN(),[i,c]=k.useState(null);k.useEffect(()=>{pN()},[]);const u=d=>{d&&c(d),r()};return l?s.jsx(_g,{}):t?s.jsx(dN,{importJob:i,onImportDone:()=>c(null)}):s.jsx(hN,{onComplete:u})}function gN(){const t=new URLSearchParams(window.location.search).has("sprite-preview");return s.jsx(P2,{children:t?s.jsx(k.Suspense,{fallback:s.jsx(_g,{}),children:s.jsx(xN,{})}):s.jsx(yN,{})})}Q2.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(gN,{})}));export{pg as H,gg as P,bg as S,wN as a,yg as b,xg as c,Kf as d,Dj as e,Tj as f,vN as g,zj as h,s as j,k as r};
100
+ placeholder:text-[var(--terminal-text-muted)]`,Wt=ve=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ve?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return s.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:$n,children:s.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:[s.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[s.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),s.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),s.jsx("div",{className:"flex gap-1.5 mt-4",children:ze.map((ve,Zt)=>s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Zt<=l?"var(--accent)":"var(--terminal-surface-light)"}}),s.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Zt===l?"var(--terminal-text)":"var(--terminal-text-muted)"},children:fN[ve]})]},ve))})]}),s.jsxs("div",{className:"px-6 py-5 min-h-[280px]",children:[He==="engine"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"AI Engine Setup"}),f?s.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:"Detecting AI engine..."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:Wt(u==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&d("claude-cli"),style:{opacity:i!=null&&i.claudeCli?1:.4},children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-lg",children:i!=null&&i.claudeCli?"✅":"❌"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-sm",children:"Claude Code CLI"}),s.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"})]})]})}),s.jsxs("div",{className:Wt(u==="direct-api"),onClick:()=>d("direct-api"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-lg",children:i!=null&&i.apiKey?"✅":"🔑"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"font-medium text-sm",children:"Anthropic API Key (BYOK)"}),s.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)&&s.jsx("input",{type:"password",className:`${fn} mt-3`,placeholder:"sk-ant-...",value:m,onChange:ve=>x(ve.target.value),autoFocus:!0})]})]})]}),He==="company"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company Info"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),s.jsx("input",{ref:te,className:fn,placeholder:"e.g. Acme Corp",value:y,onChange:ve=>b(ve.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),s.jsx("textarea",{className:`${fn} resize-none`,rows:3,placeholder:"What does your AI company do?",value:v,onChange:ve=>S(ve.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Location"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/your-company",value:C,onChange:ve=>{A(ve.target.value),M(!0)}}),s.jsx("button",{onClick:()=>W(!I),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),s.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--terminal-text-muted)"},children:"Where your AI company files will be created."}),I&&s.jsx(yc,{onSelect:ve=>{A(ve),M(!0),W(!1)},onClose:()=>W(!1)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"AI Response Language"}),s.jsxs("select",{className:fn,value:j,onChange:ve=>E(ve.target.value),children:[s.jsx("option",{value:"auto",children:"Auto"}),s.jsx("option",{value:"en",children:"English"}),s.jsx("option",{value:"ko",children:"한국어"}),s.jsx("option",{value:"ja",children:"日本語"})]})]})]}),He==="project"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Project Setup"}),s.jsxs("div",{className:Wt(D==="fresh"),onClick:()=>{Y("fresh"),G(null)},children:[s.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Create a new AI company from scratch with clean directory structure."})]}),s.jsxs("div",{className:Wt(D==="existing"),onClick:()=>Y("existing"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["📂"," Connect Existing Project"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Add AI company structure to an existing codebase or knowledge base."}),D==="existing"&&s.jsxs("div",{className:"mt-3",onClick:ve=>ve.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/your/project",value:B,onChange:ve=>{V(ve.target.value),G(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>ue(!de),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:"📁"}),s.jsx("button",{onClick:We,disabled:L||!B.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:L||!B.trim()?.5:1},children:L?"...":"Verify"})]}),ne===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Path verified: ",B]}),ne===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," Invalid path"]}),de&&s.jsx(yc,{onSelect:ve=>{V(ve),G(!0),ue(!1)},onClose:()=>ue(!1)})]})]})]}),He==="knowledge"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Knowledge Strategy"}),s.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"How should AI handle your knowledge base?"}),s.jsxs("div",{className:Wt(z==="skip"),onClick:()=>R("skip"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["🌱"," Start Fresh"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Empty knowledge base. Add documents later from the office."})]}),s.jsxs("div",{className:Wt(z==="import"),onClick:()=>R("import"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["📚"," Import & Build"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Select folders with documents — AI reads, summarizes, and organizes them."}),z==="import"&&s.jsxs("div",{className:"mt-3 space-y-2",onClick:ve=>ve.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/docs",value:fe,onChange:ve=>Ee(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&(ve.preventDefault(),$l())},autoFocus:!0}),s.jsx("button",{onClick:()=>Le(!Ne),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:"📁"}),s.jsx("button",{onClick:$l,disabled:!fe.trim(),className:"px-3 py-2 rounded text-xs font-medium",style:{background:"var(--accent)",color:"#fff",opacity:fe.trim()?1:.5},children:"Add"})]}),Ne&&s.jsx(yc,{onSelect:ve=>{K.includes(ve)||T([...K,ve]),Le(!1)},onClose:()=>Le(!1)}),K.length>0&&s.jsx("div",{className:"space-y-1",children:K.map((ve,Zt)=>s.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:[s.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:ve}),s.jsx("button",{onClick:()=>T(K.filter((Zr,cl)=>cl!==Zt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Zt))}),K.length===0&&s.jsx("div",{className:"text-[10px] text-center py-2",style:{color:"var(--terminal-text-muted)"},children:"Add at least one folder to import."})]})]}),s.jsxs("div",{className:Wt(z==="existing-akb"),onClick:()=>R("existing-akb"),children:[s.jsxs("div",{className:"font-medium text-sm",children:["🔗"," Connect Existing AKB"]}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Connect a directory that already has CLAUDE.md and AKB structure."}),z==="existing-akb"&&s.jsxs("div",{className:"mt-3",onClick:ve=>ve.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${fn} flex-1`,placeholder:"/path/to/your/akb",value:Be,onChange:ve=>{Qe(ve.target.value),tt(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>ke(!ge),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:"📁"}),s.jsx("button",{onClick:un,disabled:me||!Be.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:me||!Be.trim()?.5:1},children:me?"...":"Verify"})]}),Se===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found: ",Be]}),Se===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),ge&&s.jsx(yc,{onSelect:ve=>{Qe(ve),tt(null),ke(!1)},onClose:()=>ke(!1)})]})]})]}),He==="team"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Team Template"}),s.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"Choose a starting team. You can add or remove roles later."}),Fe.map(ve=>s.jsxs("div",{className:Wt(De===ve.id),onClick:()=>je(ve.id),children:[s.jsx("div",{className:"font-medium text-sm capitalize",children:ve.id}),s.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ve.roles.map(Zt=>s.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:Zt.name},Zt.id))})]},ve.id)),s.jsxs("div",{className:Wt(De==="custom"),onClick:()=>je("custom"),children:[s.jsx("div",{className:"font-medium text-sm",children:"Custom"}),s.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Start with no pre-built roles. Hire them from the office."})]})]}),He==="create"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:Et?z==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!Et&&!_e&&!xe&&s.jsxs(s.Fragment,{children:[s.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"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Path:"})," ",Be]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Company:"})," ",y]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Location:"})," ",C||"(default)"]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Project:"})," ",D==="fresh"?"Start Fresh":`Existing (${B})`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",z==="skip"?"Fresh (empty)":`Import ${K.length} source(s)`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Team:"})," ",De]}),z==="import"&&K.length>0&&s.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),gt&&s.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:gt})]}),(_e||xe)&&s.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[s.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),s.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:xe?"Connecting to AKB...":"Scaffolding your company..."})]}),Et&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),Te&&s.jsxs("div",{className:"rounded-lg p-3 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[s.jsx("span",{className:"opacity-50",children:"Location:"})," ",Te]}),s.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:re.map((ve,Zt)=>s.jsxs("div",{className:"py-0.5",children:[s.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ve]},Zt))}),z==="import"&&K.length>0&&s.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."})]})]})]}),s.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[s.jsx("div",{children:l>0&&!Et&&s.jsx("button",{onClick:Pe,className:"px-4 py-2 rounded text-sm transition-colors",style:{color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Back"})}),s.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[l+1," / ",ze.length]}),s.jsx("div",{children:Et?s.jsx("button",{onClick:dr,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff"},children:"Enter Office"}):s.jsx("button",{onClick:ht,disabled:!Xe()||_e||xe,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Xe()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Xe()&&!_e&&!xe?1:.5},children:He==="create"?_e||xe?xe?"Connecting...":"Creating...":z==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function mN(){const[t,l]=k.useState(null),[r,i]=k.useState(!0),[c,u]=k.useState(null),d=k.useCallback(async()=>{i(!0),u(null);try{const m=await Ce.getStatus();l(m)}catch(m){u(m instanceof Error?m.message:"Failed to fetch status")}finally{i(!1)}},[]);return k.useEffect(()=>{d()},[d]),{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:d}}const xN=k.lazy(()=>J2(()=>import("./preview-app-DruzggY0.js"),[]));function _g(){return s.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"w-10 h-10 mx-auto border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),s.jsx("div",{className:"mt-4 text-sm",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Loading..."})]})})}function pN(){var t;try{const l=localStorage.getItem("tycono-theme"),r=l&&l in Gr?l:"default",i=(t=Gr[r])==null?void 0:t.vars;if(!i)return;const c=document.documentElement;for(const[u,d]of Object.entries(i))c.style.setProperty(u,d)}catch{}}function yN(){const{initialized:t,loading:l,refetch:r}=mN(),[i,c]=k.useState(null);k.useEffect(()=>{pN()},[]);const u=d=>{d&&c(d),r()};return l?s.jsx(_g,{}):t?s.jsx(dN,{importJob:i,onImportDone:()=>c(null)}):s.jsx(hN,{onComplete:u})}function gN(){const t=new URLSearchParams(window.location.search).has("sprite-preview");return s.jsx(P2,{children:t?s.jsx(k.Suspense,{fallback:s.jsx(_g,{}),children:s.jsx(xN,{})}):s.jsx(yN,{})})}Q2.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(gN,{})}));export{pg as H,gg as P,bg as S,wN as a,yg as b,xg as c,Kf as d,Dj as e,Tj as f,vN as g,zj as h,s 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-CYBgtkj3.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};
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-CSglCQXL.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};
@@ -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-CYBgtkj3.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-CSglCQXL.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-BUOfLjiN.css">
9
9
  </head>
10
10
  <body>