tycono 0.1.45 → 0.1.46
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
|
@@ -77,7 +77,7 @@ Error generating stack: `+o.message+`
|
|
|
77
77
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:d,tableCell:x,tableRow:m}};function d(v,S,j,E){return f(g(v,j,E),v.align)}function m(v,S,j,E){const C=y(v,j,E),A=f([C]);return A.slice(0,A.indexOf(`
|
|
78
78
|
`))}function x(v,S,j,E){const C=j.enter("tableCell"),A=j.enter("phrasing"),R=j.containerPhrasing(v,{...E,before:u,after:u});return A(),C(),R}function f(v,S){return Q3(v,{align:S,alignDelimiters:i,padding:r,stringLength:c})}function g(v,S,j){const E=v.children;let C=-1;const A=[],R=S.enter("table");for(;++C<E.length;)A[C]=y(E[C],S,j);return R(),A}function y(v,S,j){const E=v.children;let C=-1;const A=[],R=S.enter("tableRow");for(;++C<E.length;)A[C]=x(E[C],v,S,j);return R(),A}function b(v,S,j){let E=Ky.inlineCode(v,S,j);return j.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function B4(){return{exit:{taskListCheckValueChecked:c0,taskListCheckValueUnchecked:c0,paragraph:L4}}}function $4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:H4}}}function c0(t){const l=this.stack[this.stack.length-2];l.type,l.checked=t.type==="taskListCheckValueChecked"}function L4(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=Ky.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[b3(),H3(),q3(),T4(),B4()]}function I4(t){return{extensions:[v3(),U3(t),X3(),O4(t),$4()]}}const Y4={tokenize:W4,partial:!0},Wy={tokenize:Q4,partial:!0},Qy={tokenize:Z4,partial:!0},Zy={tokenize:J4,partial:!0},q4={tokenize:P4,partial:!0},Jy={name:"wwwAutolink",tokenize:G4,previous:eg},Py={name:"protocolAutolink",tokenize:K4,previous:tg},fr={name:"emailAutolink",tokenize:V4,previous:ng},Ll={};function X4(){return{text:Ll}}let Ea=48;for(;Ea<123;)Ll[Ea]=fr,Ea++,Ea===58?Ea=65:Ea===91&&(Ea=97);Ll[43]=fr;Ll[45]=fr;Ll[46]=fr;Ll[95]=fr;Ll[72]=[fr,Py];Ll[104]=[fr,Py];Ll[87]=[fr,Jy];Ll[119]=[fr,Jy];function V4(t,l,r){const i=this;let c,u;return d;function d(y){return!Jf(y)||!ng.call(i,i.previous)||Nh(i.events)?r(y):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),m(y))}function m(y){return Jf(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||Cn(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&&Fn(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||!eg.call(i,i.previous)||Nh(i.events)?r(d):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Y4,t.attempt(Wy,t.attempt(Qy,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)&&tg.call(i,i.previous)&&!Nh(i.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),c+=String.fromCodePoint(y),t.consume(y),m):r(y)}function m(y){if(Fn(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||Fc(y)||Rt(y)||Fa(y)||Yc(y)?r(y):t.attempt(Wy,t.attempt(Qy,g),r)(y)}function g(y){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),l(y)}}function W4(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 Q4(t,l,r){let i,c,u;return d;function d(f){return f===46||f===95?t.check(Zy,x,m)(f):f===null||Rt(f)||Fa(f)||f!==45&&Yc(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(Zy,l,u)(d):d===null||Rt(d)||Fa(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||Rt(m)||Fa(m)?l(m):r(m)}function c(m){return m===null||m===40||m===91||Rt(m)||Fa(m)?l(m):i(m)}function u(m){return Fn(m)?d(m):r(m)}function d(m){return m===59?(t.consume(m),i):Fn(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 Cn(u)?r(u):l(u)}}function eg(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Rt(t)}function tg(t){return!Fn(t)}function ng(t){return!(t===47||Jf(t))}function Jf(t){return t===43||t===45||t===46||t===95||Cn(t)}function Nh(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=Cl(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||Rt(y))return r(y);if(y===93){t.exit("chunkString");const b=t.exit("gfmFootnoteCallString");return c.includes(Cl(i.sliceSerialize(b)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(y),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),l):r(y)}return Rt(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||Rt(S))return r(S);if(S===93){t.exit("chunkString");const j=t.exit("gfmFootnoteDefinitionLabelString");return u=Cl(i.sliceSerialize(j)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(S),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),b}return Rt(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(Qs,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&&nl(b,b.length,0,qc(v,d.slice(f+1,x),m)),nl(b,b.length,0,[["exit",y,m],["enter",d[x][1],m],["exit",d[x][1],m],["exit",g,m]]),nl(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=Ei(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=Ei(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(T){let U=i.events.length-1;for(;U>-1;){const ne=i.events[U][1].type;if(ne==="lineEnding"||ne==="linePrefix")U--;else break}const O=U>-1?i.events[U][1].type:null,Z=O==="tableHead"||O==="tableRow"?_:x;return Z===_&&i.parser.lazy[i.now().line]?r(T):Z(T)}function x(T){return t.enter("tableHead"),t.enter("tableRow"),f(T)}function f(T){return T===124||(d=!0,u+=1),g(T)}function g(T){return T===null?r(T):Ke(T)?u>1?(u=0,i.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),v):r(T):ut(T)?pt(t,g,"whitespace")(T):(u+=1,d&&(d=!1,c+=1),T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),d=!0,g):(t.enter("data"),y(T)))}function y(T){return T===null||T===124||Rt(T)?(t.exit("data"),g(T)):(t.consume(T),T===92?b:y)}function b(T){return T===92||T===124?(t.consume(T),y):y(T)}function v(T){return i.interrupt=!1,i.parser.lazy[i.now().line]?r(T):(t.enter("tableDelimiterRow"),d=!1,ut(T)?pt(t,S,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):S(T))}function S(T){return T===45||T===58?E(T):T===124?(d=!0,t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),j):L(T)}function j(T){return ut(T)?pt(t,E,"whitespace")(T):E(T)}function E(T){return T===58?(u+=1,d=!0,t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),C):T===45?(u+=1,C(T)):T===null||Ke(T)?B(T):L(T)}function C(T){return T===45?(t.enter("tableDelimiterFiller"),A(T)):L(T)}function A(T){return T===45?(t.consume(T),A):T===58?(d=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),R):(t.exit("tableDelimiterFiller"),R(T))}function R(T){return ut(T)?pt(t,B,"whitespace")(T):B(T)}function B(T){return T===124?S(T):T===null||Ke(T)?!d||c!==u?L(T):(t.exit("tableDelimiterRow"),t.exit("tableHead"),l(T)):L(T)}function L(T){return r(T)}function _(T){return t.enter("tableRow"),V(T)}function V(T){return T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),V):T===null||Ke(T)?(t.exit("tableRow"),l(T)):ut(T)?pt(t,V,"whitespace")(T):(t.enter("data"),K(T))}function K(T){return T===null||T===124||Rt(T)?(t.exit("data"),V(T)):(t.consume(T),T===92?Y:K)}function Y(T){return T===92||T===124?(t.consume(T),K):K(T)}}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&&(u0(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=hc(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=hc(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=hc(b,l,u,c,r,y)):d[1]!==0&&(y=hc(b,l,d,c,r,y)),c=0):c&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(d[3]=r)}for(x!==0&&u0(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 hc(t,l,r,i,c,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",m="tableContent";r[0]!==0&&(u.end=Object.assign({},ki(l.events,r[0])),t.add(r[0],0,[["exit",u,l]]));const x=ki(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=ki(l.events,r[2]),g=ki(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({},ki(l.events,c)),t.add(c,0,[["exit",u,l]]),u=void 0),u}function u0(t,l,r,i,c){const u=[],d=ki(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 ki(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 Rt(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 Ke(x)?l(x):ut(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 hy([X4(),tj(),cj(t),hj(),yj()])}const wj={};function Ah(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 Js({content:t,className:l=""}){return s.jsx("div",{className:`office-markdown ${l}`,children:s.jsx(Sh,{remarkPlugins:[Ah],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 d0={$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 lg(t,l){const r=d0[t];if(r&&l)return l[r];const i=Sj.exec(t);if(i){const[,c,u,d]=i,m=d0[u],x=m&&l?l[m]:u,f=parseInt(d,10);return c==="darken"?Cj(x,f):Ej(x,f)}return t}function f0(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:f0(t.left.pixels)}:l==="left"&&t.right?{name:t.right.name,pixels:f0(t.right.pixels)}:t.down}function Aj(t,l){return Pf(t,"hair",l,1)}function Pf(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 Dh=new Map,Th=new Map;function rg(t,l){Dh.set(t,l)}function Kc(t,l){Th.set(t,l)}function eh(t){return Dh.get(t)}function Dj(t){return Th.get(t)}function jN(){return Array.from(Dh.keys())}function SN(){return Array.from(Th.keys())}function Tj(t,l,r,i,c=2){t.clearRect(0,0,l.width*c,l.height*c);for(const u of l.layers)ag(t,u.pixels,c,r,i)}function th(t,l,r,i,c){for(const u of l){const d=lg(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),ag(t,l.pixels,r,0)}function ag(t,l,r,i,c){for(const u of l){const d=lg(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 Bc=new Map;function ra(t,l,r){if("down"in r&&!("pixels"in r)){const c=r;Bc.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;Bc.set(t,{id:t,name:l,layer:{...c,name:"hair"}})}}function Mj(t){return Bc.get(t)}function ig(){return Array.from(Bc.values())}ra("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}]}});ra("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}]}});ra("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}]}});ra("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}]}});ra("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"}]}});ra("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}]}});ra("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}]}});ra("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 $c=new Map;function Hl(t,l,r){if("down"in r&&!("pixels"in r)){const c=r;$c.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;$c.set(t,{id:t,name:l,layer:{...c,name:"torso"}})}}function Fj(t){return $c.get(t)}function sg(){return Array.from($c.values())}Hl("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"}]}});Hl("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"}]}});Hl("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"}]}});Hl("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)"}]}});Hl("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)"}]}});Hl("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"}]}});Hl("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"}]}});Hl("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"}]}});Hl("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"}]}});Hl("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 qs=new Map;function kt(t,l,r){if("down"in r&&!("pixels"in r)){const c=r;qs.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;qs.set(t,{id:t,name:l,layer:{...c,name:"accessory"}})}}function Rj(t){return qs.get(t)}function _j(t,l){const r=qs.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 og(){return Array.from(qs.values())}kt("none","None",{name:"accessory",pixels:[]});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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"}]}});kt("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}]}});kt("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}]}});kt("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"}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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"}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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}]}});kt("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"}]}});kt("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"}]}});kt("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}]}});kt("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}]}});kt("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 cg(t){return Oj[t]??1}function ug(t,l){return l>=cg(t)}kt("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 Ts({r:t,g:l,b:r}){return`#${(t<<16|l<<8|r).toString(16).padStart(6,"0")}`}function Ac(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,Ac(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 $j(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=Ac(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)};Ac(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=Ac(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 Lj(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 h0(t){return .299*t.r+.587*t.g+.114*t.b}function m0(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=Lj(t),i=$j(r,l);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const c=[...i].sort((y,b)=>h0(b)-h0(y)),u=[...i].sort((y,b)=>m0(b)-m0(y)),d=c[0],m=c[c.length-1],x=u[0],f=c[c.length-2],g=c[c.length-1];return{skinColor:Ts(d),hairColor:Ts(m),shirtColor:Ts(x),pantsColor:Ts(f),shoeColor:Ts(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)rg(`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"}],Wj=[{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 Qj(){return{width:12,height:22,layers:[{name:"torso",pixels:Gj},{name:"head",pixels:Kj},{name:"hair",pixels:Wj},{name:"accessory",pixels:[]}]}}rg("mini-seated:default",Qj());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"}]};Kc("meeting",Zj);Kc("bulletin",Jj);Kc("decision",eS);Kc("knowledge",Pj);const wf=16,kf=24,tS=60,nS={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function dg(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=Pf(r,"torso",i.layer,1))}if(l!=null&&l.accessory&&l.accessory!=="none"){const i=Rj(l.accessory);i&&(r=Pf(r,"accessory",i.layer))}return r}function Xs({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=wf*x,g=kf*x,y=k.useMemo(()=>{const b=eh(`mini:${t}`)??eh("mini:default");return dg(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,wf,kf),v.save(),v.translate(2,1),Tj(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:wf,height:kf,className:l,style:{imageRendering:"pixelated",display:"block",width:f,height:g}})}const lS="https://api.tycono.ai",zh=lS;async function mc(t){const l=await fetch(`${zh}${t}`);if(!l.ok)throw new Error(`Cloud API error: ${l.status}`);return l.json()}async function xc(t,l){const r=await fetch(`${zh}${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 Ci={health:()=>mc("/api/health"),getCharacters:()=>mc("/api/store/characters"),getCharacter:t=>mc(`/api/store/characters/${t}`),getCharacterVersion:t=>mc(`/api/store/characters/${t}/version`),syncCheck:t=>xc("/api/sync/check",{roles:t}),syncPull:t=>xc("/api/sync/pull",{sourceId:t}),publishCharacter:t=>xc("/api/store/publish",t),deleteCharacter:t=>fetch(`${zh}/api/store/characters/${t}`,{method:"DELETE"}).then(l=>l.json()),uploadTelemetry:t=>xc("/api/telemetry",t)},rS={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},jf={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,x0=360,p0=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:R,roleLevel:B}){var Fe,Ge;const[L,_]=k.useState(iS),[V,K]=k.useState(!1),Y=k.useRef(0),T=k.useRef(0),[U,O]=k.useState(!1),[Z,ne]=k.useState(!1),[W,I]=k.useState(!1),[P,ae]=k.useState(!1),[je,M]=k.useState("talk"),[z,G]=k.useState(!1),[D,ue]=k.useState(""),[Ee,ge]=k.useState(!1),Ae=k.useRef(null),{events:De,status:Ie}=J0(d??null),[pe,Pe]=k.useState(0);k.useEffect(()=>{if(!x||!f){Pe(0);return}const ye=new Date(f).getTime(),q=()=>Pe(Math.floor((Date.now()-ye)/1e3));q();const Te=setInterval(q,1e3);return()=>clearInterval(Te)},[x,f]);const fe=u>0,he=fe?u:0,be=fe?Math.max(x0,window.innerWidth-u-100):p0,Ce=Math.min(L,be),ze=k.useCallback(ye=>{ye.preventDefault(),Y.current=ye.clientX,T.current=Ce,K(!0);const q=He=>{const Je=Y.current-He.clientX,mt=Math.min(p0,Math.max(x0,T.current+Je));_(mt)},Te=()=>{K(!1),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Te)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",Te)},[Ce]),Oe=k.useRef(null),Me=t?y.find(ye=>ye.roleId===t.id):null,we=ye=>{if(!t)return;const q=x?"talk":je;Me?(S(Me.id,ye,q),j(t.id)):(Oe.current={content:ye,mode:q},v(t.id))};k.useEffect(()=>{if(Me&&Oe.current){const{content:ye,mode:q}=Oe.current;Oe.current=null,S(Me.id,ye,q),t&&j(t.id)}},[Me==null?void 0:Me.id]);const Be=(()=>{if(!De.length)return null;const ye=[];let q=0,Te=0,He=0;for(const Je of De)if(Je.type==="thinking")q++;else if(Je.type==="text")Te++;else if(Je.type==="tool:start"){const mt=String(Je.data.name??"");ye.includes(mt)||ye.push(mt)}else Je.type==="dispatch:start"&&He++;return{tools:ye,thinkCount:q,textCount:Te,dispatchCount:He,total:De.length}})(),tt=m||(()=>{if(!Me)return null;const ye=Me.messages;for(let q=ye.length-1;q>=0;q--)if(ye[q].from==="ceo")return ye[q].content;return null})(),jt=(()=>{if(!Me)return null;const ye=Me.messages;for(let q=ye.length-1;q>=0;q--)if(ye[q].from==="role"&&ye[q].content)return ye[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:Ce,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 Ut=jf[t.id]??"#666",yt=rS[t.id]??"👤",Vt=l.filter(ye=>ye.reportsTo===t.id),ie=Me&&b===Me.id,me=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)] ${V?"resizing":""}`,style:{borderLeftColor:Ut,right:he,width:Ce,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 ${V?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:ze}),s.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Ut}ee, ${Ut}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(Xs,{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:[yt," ",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"})]}),z?s.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async ye=>{ye.preventDefault();const q=D.trim();if(!q||q===me||!C){G(!1);return}ge(!0);try{await C(t.id,{name:q})}catch{}ge(!1),G(!1)},children:[s.jsx("input",{ref:Ae,value:D,onChange:ye=>ue(ye.target.value),onKeyDown:ye=>{ye.key==="Escape"&&G(!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:()=>G(!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&&(ue(me),G(!0))},title:C?"Click to edit name":void 0,children:[me,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.",B??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",pe>0?` · ${sS(pe)}`:""]})]}),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"})]})]}),tt&&s.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:tt})]}),x&&d&&Be&&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:[Be.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 ×",Be.thinkCount]}),Be.tools.map(ye=>s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(59,130,246,0.15)",color:"#60a5fa"},children:ye},ye)),Be.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 ×",Be.dispatchCount]}),Be.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 ×",Be.textCount]}),(Ie==="streaming"||Ie==="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:[Be.total," events"]})]}),x&&jt&&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:[jt.slice(0,200),jt.length>200&&"..."]})]}),x&&s.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:s.jsx(y0,{onSend:we,disabled:!!ie,placeholder:"Ask something...",color:Ut})}),!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:yt,roleId:t.id,roleName:me,color:Ut,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:[jt&&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:[jt.slice(0,150),jt.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:()=>M("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:je==="talk"?"var(--accent)":"transparent",color:je==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),s.jsx("button",{onClick:()=>M("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:je==="do"?"var(--idle-amber)":"transparent",color:je==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),s.jsx(y0,{onSend:we,disabled:!!ie,placeholder:je==="talk"?"Ask something...":"Give a directive...",color:Ut})]})})]})}),s.jsxs("div",{className:"px-4 py-2 space-y-1",children:[s.jsxs(pc,{title:`Profile${t.persona?"":" (empty)"}`,open:U,onToggle:()=>O(ye=>!ye),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(Sf,{label:"Level",value:t.level}),s.jsx(Sf,{label:"Reports to",value:t.reportsTo}),s.jsx(Sf,{label:"Status",value:t.status})]}),Vt.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:Vt.map(ye=>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:jf[ye.id]??"#666"},children:ye.id.slice(0,2).toUpperCase()}),s.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text)"},children:ye.name})]},ye.id))})]})]}),t.authority&&s.jsxs(pc,{title:"Authority",open:Z,onToggle:()=>ne(ye=>!ye),children:[((Fe=t.authority.autonomous)==null?void 0:Fe.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((ye,q)=>s.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",ye]},q))]}),((Ge=t.authority.needsApproval)==null?void 0:Ge.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((ye,q)=>s.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",ye]},q))]})]}),t&&R&&(()=>{const ye=R.filter(q=>q.roleA===t.id||q.roleB===t.id).filter(q=>q.familiarity>0).sort((q,Te)=>Te.familiarity-q.familiarity);return ye.length===0?null:s.jsx(pc,{title:`Relationships (${ye.length})`,open:W,onToggle:()=>I(q=>!q),children:s.jsx("div",{className:"space-y-1.5",children:ye.map((q,Te)=>{const He=q.roleA===t.id?q.roleB:q.roleA,Je=l.find(Yt=>Yt.id===He),mt=q.familiarity>=80?"Best Partner":q.familiarity>=50?"Friend":q.familiarity>=20?"Colleague":"Acquaintance",et=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:jf[He]??"var(--terminal-text-secondary)"},children:(Je==null?void 0:Je.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:et}})}),s.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:mt})]},Te)})})})})(),t.journal&&s.jsx(pc,{title:`Journal (${(t.journal.match(/### /g)??[]).length})`,open:P,onToggle:()=>ae(ye=>!ye),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(Js,{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 Ne.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
|
-
`)[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 Ci.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 Ci.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(Js,{content:c})}):s.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function pc({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 y0({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 Sf({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 fg(this.cover(l,r),l,r,t)}function fg(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)fg(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 Rn(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 Rn(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 Rn(v[3],E,C,x,f),new Rn(v[2],d,C,E,f),new Rn(v[1],E,m,x,C),new Rn(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),R=l-+this._y.call(null,v.data),B=A*A+R*R;if(B<r){var L=Math.sqrt(r=B);c=t-L,u=l-L,g=t+L,y=l+L,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 Rn(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 Rn(c,f,g,m,x)),(c=i[2])&&l.push(new Rn(c,u,g,f,x)),(c=i[1])&&l.push(new Rn(c,f,d,m,g)),(c=i[0])&&l.push(new Rn(c,u,d,f,g))}return this}function jS(t){var l=[],r=[],i;for(this._root&&l.push(new Rn(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 Rn(u,d,m,g,y)),(u=c[1])&&l.push(new Rn(u,g,m,x,y)),(u=c[2])&&l.push(new Rn(u,d,y,g,f)),(u=c[3])&&l.push(new Rn(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 Mh(t,l,r){var i=new Fh(l??SS,r??ES,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function Fh(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 g0(t){for(var l={data:t.data},r=l;t=t.next;)r=r.next={data:t.data};return l}var _n=Mh.prototype=Fh.prototype;_n.copy=function(){var t=new Fh(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=g0(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]=g0(i));return t};_n.add=fS;_n.addAll=hS;_n.cover=mS;_n.data=xS;_n.extent=pS;_n.find=yS;_n.remove=gS;_n.removeAll=bS;_n.root=vS;_n.size=wS;_n.visit=kS;_n.visitAfter=jS;_n.x=CS;_n.y=NS;function Ma(t){return function(){return t}}function ta(t){return(t()-.5)*1e-6}function AS(t){return t.x+t.vx}function DS(t){return t.y+t.vy}function TS(t){var l,r,i,c=1,u=1;typeof t!="function"&&(t=Ma(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=Mh(l,AS,DS).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(R,B,L,_,V){var K=R.data,Y=R.r,T=j+Y;if(K){if(K.index>b.index){var U=v-K.x-K.vx,O=S-K.y-K.vy,Z=U*U+O*O;Z<T*T&&(U===0&&(U=ta(i),Z+=U*U),O===0&&(O=ta(i),Z+=O*O),Z=(T-(Z=Math.sqrt(Z)))/Z*c,b.vx+=(U*=Z)*(T=(Y*=Y)/(E+Y)),b.vy+=(O*=Z)*T,K.vx-=U*(T=1-T),K.vy-=O*T)}return}return B>v+T||_<v-T||L>S+T||V<S-T}}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:Ma(+f),x(),d):t},d}function zS(t){return t.index}function b0(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=Ma(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 R=0,B,L,_,V,K,Y,T;R<A;++R)B=t[R],L=B.source,_=B.target,V=_.x+_.vx-L.x-L.vx||ta(f),K=_.y+_.vy-L.y-L.vy||ta(f),Y=Math.sqrt(V*V+K*K),Y=(Y-u[R])/Y*E*i[R],V*=Y,K*=Y,_.vx-=V*(T=x[R]),_.vy-=K*T,L.vx+=V*(T=1-T),L.vy+=K*T}function v(){if(d){var E,C=d.length,A=t.length,R=new Map(d.map((L,_)=>[l(L,_,d),L])),B;for(E=0,m=new Array(C);E<A;++E)B=t[E],B.index=E,typeof B.source!="object"&&(B.source=b0(R,B.source)),typeof B.target!="object"&&(B.target=b0(R,B.target)),m[B.source.index]=(m[B.source.index]||0)+1,m[B.target.index]=(m[B.target.index]||0)+1;for(E=0,x=new Array(A);E<A;++E)B=t[E],x[E]=m[B.source.index]/(m[B.source.index]+m[B.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:Ma(+E),S(),b):r},b.distance=function(E){return arguments.length?(c=typeof E=="function"?E:Ma(+E),j(),b):c},b}var FS={value:()=>{}};function hg(){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 Dc(r)}function Dc(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}})}Dc.prototype=hg.prototype={constructor:Dc,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]=v0(r[c],t.name,l);else if(l==null)for(c in r)r[c]=v0(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 Dc(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 v0(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 Ni=0,_s=0,zs=0,mg=1e3,Lc,Os,Hc=0,Ra=0,Wc=0,Vs=typeof performance=="object"&&performance.now?performance:Date,xg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function pg(){return Ra||(xg(OS),Ra=Vs.now()+Wc)}function OS(){Ra=0}function nh(){this._call=this._time=this._next=null}nh.prototype=yg.prototype={constructor:nh,restart:function(t,l,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?pg():+r)+(l==null?0:+l),!this._next&&Os!==this&&(Os?Os._next=this:Lc=this,Os=this),this._call=t,this._time=r,lh()},stop:function(){this._call&&(this._call=null,this._time=1/0,lh())}};function yg(t,l,r){var i=new nh;return i.restart(t,l,r),i}function BS(){pg(),++Ni;for(var t=Lc,l;t;)(l=Ra-t._time)>=0&&t._call.call(void 0,l),t=t._next;--Ni}function w0(){Ra=(Hc=Vs.now())+Wc,Ni=_s=0;try{BS()}finally{Ni=0,LS(),Ra=0}}function $S(){var t=Vs.now(),l=t-Hc;l>mg&&(Wc-=l,Hc=t)}function LS(){for(var t,l=Lc,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:Lc=r);Os=t,lh(i)}function lh(t){if(!Ni){_s&&(_s=clearTimeout(_s));var l=t-Ra;l>24?(t<1/0&&(_s=setTimeout(w0,t-Vs.now()-Wc)),zs&&(zs=clearInterval(zs))):(zs||(Hc=Vs.now(),zs=setInterval($S,mg)),Ni=1,xg(w0))}}const HS=1664525,US=1013904223,k0=4294967296;function IS(){let t=1;return()=>(t=(HS*t+US)%k0)/k0}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=yg(y),f=hg("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 R=0;R<j;++R)for(r+=(u-r)*c,m.forEach(function(B){B(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),R=j*VS;C.x=A*Math.cos(R),C.y=A*Math.sin(R)}(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,R=t.length,B,L,_,V,K;for(C==null?C=1/0:C*=C,A=0;A<R;++A)V=t[A],B=j-V.x,L=E-V.y,_=B*B+L*L,_<C&&(K=V,C=_);return K},on:function(j,E){return arguments.length>1?(f.on(j,E),l):f.on(j)}}}function KS(){var t,l,r,i,c=Ma(-30),u,d=1,m=1/0,x=.81;function f(v){var S,j=t.length,E=Mh(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,R,B;if(v.length){for(A=R=B=0;B<4;++B)(j=v[B])&&(E=Math.abs(j.value))&&(S+=j.value,C+=E,A+=E*j.x,R+=E*j.y);v.x=A/C,v.y=R/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,R=E-S,B=C*C+A*A;if(R*R/x<B)return B<m&&(C===0&&(C=ta(r),B+=C*C),A===0&&(A=ta(r),B+=A*A),B<d&&(B=Math.sqrt(d*B)),l.vx+=C*v.value*i/B,l.vy+=A*v.value*i/B),!0;if(v.length||B>=m)return;(v.data!==l||v.next)&&(C===0&&(C=ta(r),B+=C*C),A===0&&(A=ta(r),B+=A*A),B<d&&(B=Math.sqrt(d*B)));do v.data!==l&&(R=u[v.data.index]*i/B,l.vx+=C*R,l.vy+=A*R);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:Ma(+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 Gs={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 WS(t){return Gs[t]??Gs.general}function QS({docs:t,onNodeClick:l,selectedDocId:r}){var U;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}),R=k.useRef(null),B=k.useRef(null);k.useEffect(()=>{const O=i.current;if(!O)return;const Z=new ResizeObserver(ne=>{const{width:W,height:I}=ne[0].contentRect;W>0&&I>0&&(d({width:W,height:I}),E(P=>({...P,w:W,h:I})))});return Z.observe(O),()=>Z.disconnect()},[]),k.useEffect(()=>{if(t.length===0)return;const O=new Set(t.map(ge=>ge.id)),Z=t.map(ge=>({id:ge.id,title:ge.title,category:ge.category,akb_type:ge.akb_type})),ne=(ge,Ae)=>{if(!Ae.startsWith(".")&&!Ae.startsWith("/"))return Ae;const De=ge.split("/");De.pop();const Ie=Ae.split("/");for(const pe of Ie)pe===".."?De.pop():pe!=="."&&pe!==""&&De.push(pe);return De.join("/")},W=[];for(const ge of t)for(const Ae of ge.links){const De=ne(ge.id,Ae.href);O.has(De)&&De!==ge.id&&(W.some(Ie=>Ie.source===ge.id&&Ie.target===De||Ie.source===De&&Ie.target===ge.id)||W.push({source:ge.id,target:De,label:Ae.text}))}const{width:I,height:P}=u,ae=Z.length,je=ae>100?-600:ae>50?-500:-400,M=ae>100?180:ae>50?160:140,z=ae>100?60:50,G=Math.max(I,ae*12),D=Math.max(P,ae*10),ue=GS(Z).force("link",MS(W).id(ge=>ge.id).distance(M)).force("charge",KS().strength(je)).force("center",dS(G/2,D/2)).force("collide",TS(z));B.current=ue,ue.on("tick",()=>{x({nodes:[...Z],links:[...W]})}),ue.alpha(1).restart();const Ee=ae>100?300:150;for(let ge=0;ge<Ee;ge++)ue.tick();if(ue.stop(),x({nodes:[...Z],links:[...W]}),Z.length>0){let ge=1/0,Ae=1/0,De=-1/0,Ie=-1/0;for(const Pe of Z){const fe=Pe.x??0,he=Pe.y??0;fe<ge&&(ge=fe),he<Ae&&(Ae=he),fe>De&&(De=fe),he>Ie&&(Ie=he)}const pe=100;E({x:ge-pe,y:Ae-pe,w:Math.max(I,De-ge+pe*2),h:Math.max(P,Ie-Ae+pe*2)})}return()=>{ue.stop()}},[t,u]);const L=O=>{if(typeof O=="string"){const Z=m.nodes.find(ne=>ne.id===O);return{x:(Z==null?void 0:Z.x)??0,y:(Z==null?void 0:Z.y)??0}}return{x:O.x??0,y:O.y??0}},_=k.useCallback(O=>{O.preventDefault();const Z=O.deltaY>0?1.1:.9;E(ne=>{const W=Math.max(200,Math.min(u.width*3,ne.w*Z)),I=Math.max(150,Math.min(u.height*3,ne.h*Z)),P=(W-ne.w)/2,ae=(I-ne.h)/2;return{x:ne.x-P,y:ne.y-ae,w:W,h:I}})},[u]),V=k.useCallback(O=>{O.button===0&&(C.current=!0,A.current={x:O.clientX,y:O.clientY,vx:j.x,vy:j.y})},[j]),K=k.useCallback(O=>{var Z;if(R.current){const ne=c.current;if(!ne)return;const W=ne.getBoundingClientRect(),I=j.w/W.width,P=j.h/W.height,ae=j.x+(O.clientX-W.left)*I,je=j.y+(O.clientY-W.top)*P;R.current.fx=ae,R.current.fy=je,(Z=B.current)==null||Z.alpha(.3).restart();return}if(C.current){const ne=(O.clientX-A.current.x)*(j.w/u.width),W=(O.clientY-A.current.y)*(j.h/u.height);E(I=>({...I,x:A.current.vx-ne,y:A.current.vy-W}))}},[j,u]),Y=k.useCallback(()=>{C.current=!1,R.current&&(R.current.fx=null,R.current.fy=null,R.current=null)},[]),T=k.useCallback((O,Z)=>{var ne;O.stopPropagation(),R.current=Z,(ne=B.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:_,onMouseDown:V,onMouseMove:K,onMouseUp:Y,onMouseLeave:Y,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((O,Z)=>{const ne=L(O.source),W=L(O.target),I=y===Z,P=(ne.x+W.x)/2,ae=(ne.y+W.y)/2;return s.jsxs("g",{children:[s.jsx("line",{x1:ne.x,y1:ne.y,x2:W.x,y2:W.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>b(Z),onMouseLeave:()=>b(null)}),s.jsx("line",{x1:ne.x,y1:ne.y,x2:W.x,y2:W.y,stroke:I?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.3)",strokeWidth:I?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),I&&O.label&&s.jsx("text",{x:P,y:ae-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:O.label.length>30?O.label.slice(0,28)+"..":O.label})})]},Z)}),m.nodes.map(O=>{const Z=Gs[O.category]??Gs.general,ne=O.akb_type==="hub",W=ne?24:16,I=(f==null?void 0:f.id)===O.id,P=r===O.id,ae=I?1.2:P?1.15:1;return s.jsxs("g",{transform:`translate(${O.x??0}, ${O.y??0}) scale(${ae})`,style:{cursor:"pointer",transition:"transform 0.15s ease"},onClick:je=>{je.stopPropagation();const M=t.find(z=>z.id===O.id);M&&l(M)},onMouseDown:je=>T(je,O),onMouseEnter:je=>{var z;g(O);const M=(z=i.current)==null?void 0:z.getBoundingClientRect();M&&S({x:je.clientX-M.left,y:je.clientY-M.top})},onMouseLeave:()=>g(null),children:[P&&s.jsx("rect",{x:-W/2-4,y:-W/2-4,width:W+8,height:W+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:ne?5:2,opacity:.6}),s.jsx("rect",{x:-W/2,y:-W/2,width:W,height:W,fill:Z.border,rx:ne?4:2,opacity:I?1:.9}),s.jsx("rect",{x:-W/2+3,y:-W/2+3,width:Math.max(0,W-6),height:Math.max(0,W-6),fill:Z.bg,rx:ne?3:1}),s.jsx("text",{y:W/2+14,textAnchor:"middle",fill:P?"#e2e8f0":"#94a3b8",fontSize:11,fontFamily:"monospace",fontWeight:P?"bold":"normal",style:{pointerEvents:"none"},children:O.title.length>24?O.title.slice(0,22)+"..":O.title})]},O.id)})]}),f&&!R.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]}),((U=t.find(O=>O.id===f.id))==null?void 0:U.tldr)&&s.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:t.find(O=>O.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=WS(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(L=>L.id)),C=k.useCallback(L=>{const _=L.split("#")[0];if(!_.match(/\.(md|html)$/))return null;const V=t.includes("/")?t.replace(/\/[^/]+$/,""):"";let K;if(_.startsWith("./"))K=V?`${V}/${_.slice(2)}`:_.slice(2);else if(_.startsWith("../")){const U=V.split("/").filter(Boolean);let O=_;for(;O.startsWith("../");)U.length>0&&U.pop(),O=O.slice(3);K=U.length>0?`${U.join("/")}/${O}`:O}else K=_;if(E.has(K))return K;const Y=K.split("/").pop()??"",T=u.find(U=>U.id===Y||U.id.endsWith("/"+Y));return T?T.id:null},[t,E,u]),A=k.useCallback(L=>{const V=L.target.closest("a");if(!V)return;const K=V.getAttribute("href");if(!K||K.startsWith("http://")||K.startsWith("https://")||!K.match(/\.(md|html)(#.*)?$/))return;L.preventDefault(),L.stopPropagation();const Y=C(K);Y&&c(Y)},[C,c]);k.useEffect(()=>{f(!0),Ne.getKnowledgeDoc(t).then(L=>{m(L),v(L.content)}).catch(console.error).finally(()=>f(!1))},[t]);const R=async()=>{if(d){j(!0);try{await Ne.updateKnowledgeDoc(t,b),m({...d,content:b}),y(!1),r()}catch(L){console.error("Save failed:",L)}finally{j(!1)}}},B=async()=>{if(confirm(`Delete "${d==null?void 0:d.title}"?`))try{await Ne.deleteKnowledgeDoc(t),i(t)}catch(L){console.error("Delete failed:",L)}};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:R,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:B,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:L=>v(L.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:L=>v(L.target.value),spellCheck:!1}):s.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--terminal-text-secondary)"},onClick:A,children:s.jsx(Js,{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 Ne.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,j0=360,S0=700;function Rh(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(j0,window.innerWidth-t-100):S0,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(S0,Math.max(j0,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:R,handleResizeStart:B}=Rh(i),L=["all",...Array.from(new Set(t.map(U=>U.category))).sort()],_=t.filter(U=>{if(m!=="all"&&U.category!==m)return!1;if(y){const O=y.toLowerCase();return U.title.toLowerCase().includes(O)||(U.tldr??"").toLowerCase().includes(O)||U.tags.some(Z=>Z.toLowerCase().includes(O))}return!0}),V=U=>{S(!1),r(),g(U)},K=U=>{g(null),r()},Y=U=>{E(U.id)},T=j?t.find(U=>U.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)] ${R?"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 ${R?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:B}),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(C0,{label:"List",active:u==="list",onClick:()=>{d("list"),E(null)}}),s.jsx(C0,{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:U=>b(U.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:L.map(U=>s.jsx("button",{onClick:()=>x(U),className:"px-3 py-1.5 text-[10px] font-medium cursor-pointer whitespace-nowrap",style:{color:m===U?"#4ade80":"var(--terminal-text-muted)",borderBottom:m===U?"2px solid #4ade80":"2px solid transparent"},children:U==="all"?`All (${t.length})`:`${U} (${t.filter(O=>O.category===U).length})`},U))}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:_.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"}):_.map(U=>s.jsx(ZS,{doc:U,allDocs:t,onOpen:O=>g(O.id),onNavigateDoc:O=>g(O)},U.id))})]}),u==="list"&&f&&!v&&s.jsx(JS,{docId:f,onBack:()=>g(null),onDocUpdated:r,onDelete:K,onNavigateDoc:U=>g(U),allDocs:t}),u==="list"&&v&&s.jsx(PS,{onCreated:V,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(QS,{docs:t,onNodeClick:Y,selectedDocId:j}),T&&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:T.title}),s.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:T.status==="active"?"#16a34a":T.status==="draft"?"#f59e0b":"#94a3b8"}}),T.tldr&&s.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:T.tldr}),T.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"}),T.links.slice(0,5).map((U,O)=>s.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",U.text]},O))]}),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(T.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(Gs).map(([U,O])=>s.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[s.jsx("div",{className:"w-2 h-2",style:{background:O.border}}),s.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:U})]},U))})})]})]})]})}function C0({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}=Rh(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(Cf,{label:`Standups (${t.length})`,active:d==="standups",onClick:()=>m("standups")}),s.jsx(Cf,{label:`Waves (${l.length})`,active:d==="waves",onClick:()=>m("waves")})]}):s.jsx(Cf,{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(Ef,{title:`Standup ${b.date}`,content:b.content},v)),d==="waves"&&l.map((b,v)=>s.jsx(Ef,{title:`Wave ${b.id}`,subtitle:b.timestamp,content:b.content},v)),d==="decisions"&&r.map((b,v)=>s.jsx(Ef,{title:`#${b.id} ${b.title}`,subtitle:b.date,content:b.content},v))]})]})]})}function Cf({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 Ef({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(Js,{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}=Rh(r);if(k.useEffect(()=>{Ne.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(Js,{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 E0={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function gg({event:t,isThinkingCollapsed:l,onToggleThinking:r,onNavigateToJob:i,onOpenKnowledgeDoc:c,compact:u}){var m;const d=E0[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(Sh,{remarkPlugins:[Ah],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=E0[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}=J0(t),[S,j]=k.useState(0),[E,C]=k.useState(new Set),A=k.useRef(null),R=k.useRef(Date.now()),B=k.useRef(!1);k.useEffect(()=>{const U=setInterval(()=>{j(Math.floor((Date.now()-R.current)/1e3))},1e3);return()=>clearInterval(U)},[]),k.useEffect(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[g]),k.useEffect(()=>{(y==="done"||y==="error")&&!B.current&&(B.current=!0,m==null||m())},[y,m]);const L=U=>{C(O=>{const Z=new Set(O);return Z.has(U)?Z.delete(U):Z.add(U),Z})},_={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[y],V={idle:"#888",connecting:"#888",streaming:r,done:"#2E7D32",error:"#C62828"}[y],K=U=>`${Math.floor(U/60)}:${String(U%60).padStart(2,"0")}`,Y=y==="done"||y==="error",T=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:V}}),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:K(S)}),s.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${V}22`,color:V},children:_}),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:"–"}),Y&&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(U=>s.jsx(gg,{event:U,isThinkingCollapsed:E.has(U.seq),onToggleThinking:()=>L(U.seq),onNavigateToJob:x,onOpenKnowledgeDoc:f},U.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`]}),Y&&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:Y?u:void 0}),T]}):T}const Nf={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:Nf[m.id]??"#888",color:Nf[m.id]??"#888",background:`${Nf[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 R=>{if(!R.ok||!R.body){c(V=>{const K=new Map(V),Y=K.get(v);return Y&&K.set(v,{...Y,streamStatus:"error"}),K});return}c(V=>{const K=new Map(V),Y=K.get(v);return Y&&K.set(v,{...Y,streamStatus:"streaming",status:"running"}),K});const B=R.body.getReader(),L=new TextDecoder;let _="";for(;;){const{done:V,value:K}=await B.read();if(V)break;_+=L.decode(K,{stream:!0});const Y=_.split(`
|
|
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 Ci.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 Ci.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(Js,{content:c})}):s.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function pc({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 y0({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 Sf({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 fg(this.cover(l,r),l,r,t)}function fg(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)fg(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 Rn(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 Rn(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 Rn(v[3],E,C,x,f),new Rn(v[2],d,C,E,f),new Rn(v[1],E,m,x,C),new Rn(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),R=l-+this._y.call(null,v.data),B=A*A+R*R;if(B<r){var L=Math.sqrt(r=B);c=t-L,u=l-L,g=t+L,y=l+L,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 Rn(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 Rn(c,f,g,m,x)),(c=i[2])&&l.push(new Rn(c,u,g,f,x)),(c=i[1])&&l.push(new Rn(c,f,d,m,g)),(c=i[0])&&l.push(new Rn(c,u,d,f,g))}return this}function jS(t){var l=[],r=[],i;for(this._root&&l.push(new Rn(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 Rn(u,d,m,g,y)),(u=c[1])&&l.push(new Rn(u,g,m,x,y)),(u=c[2])&&l.push(new Rn(u,d,y,g,f)),(u=c[3])&&l.push(new Rn(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 Mh(t,l,r){var i=new Fh(l??SS,r??ES,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function Fh(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 g0(t){for(var l={data:t.data},r=l;t=t.next;)r=r.next={data:t.data};return l}var _n=Mh.prototype=Fh.prototype;_n.copy=function(){var t=new Fh(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=g0(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]=g0(i));return t};_n.add=fS;_n.addAll=hS;_n.cover=mS;_n.data=xS;_n.extent=pS;_n.find=yS;_n.remove=gS;_n.removeAll=bS;_n.root=vS;_n.size=wS;_n.visit=kS;_n.visitAfter=jS;_n.x=CS;_n.y=NS;function Ma(t){return function(){return t}}function ta(t){return(t()-.5)*1e-6}function AS(t){return t.x+t.vx}function DS(t){return t.y+t.vy}function TS(t){var l,r,i,c=1,u=1;typeof t!="function"&&(t=Ma(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=Mh(l,AS,DS).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(R,B,L,_,V){var K=R.data,Y=R.r,T=j+Y;if(K){if(K.index>b.index){var U=v-K.x-K.vx,O=S-K.y-K.vy,Z=U*U+O*O;Z<T*T&&(U===0&&(U=ta(i),Z+=U*U),O===0&&(O=ta(i),Z+=O*O),Z=(T-(Z=Math.sqrt(Z)))/Z*c,b.vx+=(U*=Z)*(T=(Y*=Y)/(E+Y)),b.vy+=(O*=Z)*T,K.vx-=U*(T=1-T),K.vy-=O*T)}return}return B>v+T||_<v-T||L>S+T||V<S-T}}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:Ma(+f),x(),d):t},d}function zS(t){return t.index}function b0(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=Ma(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 R=0,B,L,_,V,K,Y,T;R<A;++R)B=t[R],L=B.source,_=B.target,V=_.x+_.vx-L.x-L.vx||ta(f),K=_.y+_.vy-L.y-L.vy||ta(f),Y=Math.sqrt(V*V+K*K),Y=(Y-u[R])/Y*E*i[R],V*=Y,K*=Y,_.vx-=V*(T=x[R]),_.vy-=K*T,L.vx+=V*(T=1-T),L.vy+=K*T}function v(){if(d){var E,C=d.length,A=t.length,R=new Map(d.map((L,_)=>[l(L,_,d),L])),B;for(E=0,m=new Array(C);E<A;++E)B=t[E],B.index=E,typeof B.source!="object"&&(B.source=b0(R,B.source)),typeof B.target!="object"&&(B.target=b0(R,B.target)),m[B.source.index]=(m[B.source.index]||0)+1,m[B.target.index]=(m[B.target.index]||0)+1;for(E=0,x=new Array(A);E<A;++E)B=t[E],x[E]=m[B.source.index]/(m[B.source.index]+m[B.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:Ma(+E),S(),b):r},b.distance=function(E){return arguments.length?(c=typeof E=="function"?E:Ma(+E),j(),b):c},b}var FS={value:()=>{}};function hg(){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 Dc(r)}function Dc(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}})}Dc.prototype=hg.prototype={constructor:Dc,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]=v0(r[c],t.name,l);else if(l==null)for(c in r)r[c]=v0(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 Dc(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 v0(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 Ni=0,_s=0,zs=0,mg=1e3,Lc,Os,Hc=0,Ra=0,Wc=0,Vs=typeof performance=="object"&&performance.now?performance:Date,xg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function pg(){return Ra||(xg(OS),Ra=Vs.now()+Wc)}function OS(){Ra=0}function nh(){this._call=this._time=this._next=null}nh.prototype=yg.prototype={constructor:nh,restart:function(t,l,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?pg():+r)+(l==null?0:+l),!this._next&&Os!==this&&(Os?Os._next=this:Lc=this,Os=this),this._call=t,this._time=r,lh()},stop:function(){this._call&&(this._call=null,this._time=1/0,lh())}};function yg(t,l,r){var i=new nh;return i.restart(t,l,r),i}function BS(){pg(),++Ni;for(var t=Lc,l;t;)(l=Ra-t._time)>=0&&t._call.call(void 0,l),t=t._next;--Ni}function w0(){Ra=(Hc=Vs.now())+Wc,Ni=_s=0;try{BS()}finally{Ni=0,LS(),Ra=0}}function $S(){var t=Vs.now(),l=t-Hc;l>mg&&(Wc-=l,Hc=t)}function LS(){for(var t,l=Lc,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:Lc=r);Os=t,lh(i)}function lh(t){if(!Ni){_s&&(_s=clearTimeout(_s));var l=t-Ra;l>24?(t<1/0&&(_s=setTimeout(w0,t-Vs.now()-Wc)),zs&&(zs=clearInterval(zs))):(zs||(Hc=Vs.now(),zs=setInterval($S,mg)),Ni=1,xg(w0))}}const HS=1664525,US=1013904223,k0=4294967296;function IS(){let t=1;return()=>(t=(HS*t+US)%k0)/k0}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=yg(y),f=hg("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 R=0;R<j;++R)for(r+=(u-r)*c,m.forEach(function(B){B(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),R=j*VS;C.x=A*Math.cos(R),C.y=A*Math.sin(R)}(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,R=t.length,B,L,_,V,K;for(C==null?C=1/0:C*=C,A=0;A<R;++A)V=t[A],B=j-V.x,L=E-V.y,_=B*B+L*L,_<C&&(K=V,C=_);return K},on:function(j,E){return arguments.length>1?(f.on(j,E),l):f.on(j)}}}function KS(){var t,l,r,i,c=Ma(-30),u,d=1,m=1/0,x=.81;function f(v){var S,j=t.length,E=Mh(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,R,B;if(v.length){for(A=R=B=0;B<4;++B)(j=v[B])&&(E=Math.abs(j.value))&&(S+=j.value,C+=E,A+=E*j.x,R+=E*j.y);v.x=A/C,v.y=R/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,R=E-S,B=C*C+A*A;if(R*R/x<B)return B<m&&(C===0&&(C=ta(r),B+=C*C),A===0&&(A=ta(r),B+=A*A),B<d&&(B=Math.sqrt(d*B)),l.vx+=C*v.value*i/B,l.vy+=A*v.value*i/B),!0;if(v.length||B>=m)return;(v.data!==l||v.next)&&(C===0&&(C=ta(r),B+=C*C),A===0&&(A=ta(r),B+=A*A),B<d&&(B=Math.sqrt(d*B)));do v.data!==l&&(R=u[v.data.index]*i/B,l.vx+=C*R,l.vy+=A*R);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:Ma(+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 Gs={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 WS(t){return Gs[t]??Gs.general}function QS({docs:t,onNodeClick:l,selectedDocId:r}){var U;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}),R=k.useRef(null),B=k.useRef(null);k.useEffect(()=>{const O=i.current;if(!O)return;const Z=new ResizeObserver(ne=>{const{width:W,height:I}=ne[0].contentRect;W>0&&I>0&&(d({width:W,height:I}),E(P=>({...P,w:W,h:I})))});return Z.observe(O),()=>Z.disconnect()},[]),k.useEffect(()=>{if(t.length===0)return;const O=new Set(t.map(ge=>ge.id)),Z=t.map(ge=>({id:ge.id,title:ge.title,category:ge.category,akb_type:ge.akb_type})),ne=(ge,Ae)=>{if(!Ae.startsWith(".")&&!Ae.startsWith("/"))return Ae;const De=ge.split("/");De.pop();const Ie=Ae.split("/");for(const pe of Ie)pe===".."?De.pop():pe!=="."&&pe!==""&&De.push(pe);return De.join("/")},W=[];for(const ge of t)for(const Ae of ge.links){const De=ne(ge.id,Ae.href);O.has(De)&&De!==ge.id&&(W.some(Ie=>Ie.source===ge.id&&Ie.target===De||Ie.source===De&&Ie.target===ge.id)||W.push({source:ge.id,target:De,label:Ae.text}))}const{width:I,height:P}=u,ae=Z.length,je=ae>100?-600:ae>50?-500:-400,M=ae>100?180:ae>50?160:140,z=ae>100?60:50,G=Math.max(I,ae*12),D=Math.max(P,ae*10),ue=GS(Z).force("link",MS(W).id(ge=>ge.id).distance(M)).force("charge",KS().strength(je)).force("center",dS(G/2,D/2)).force("collide",TS(z));B.current=ue,ue.on("tick",()=>{x({nodes:[...Z],links:[...W]})}),ue.alpha(1).restart();const Ee=ae>100?300:150;for(let ge=0;ge<Ee;ge++)ue.tick();if(ue.stop(),x({nodes:[...Z],links:[...W]}),Z.length>0){let ge=1/0,Ae=1/0,De=-1/0,Ie=-1/0;for(const Pe of Z){const fe=Pe.x??0,he=Pe.y??0;fe<ge&&(ge=fe),he<Ae&&(Ae=he),fe>De&&(De=fe),he>Ie&&(Ie=he)}const pe=100;E({x:ge-pe,y:Ae-pe,w:Math.max(I,De-ge+pe*2),h:Math.max(P,Ie-Ae+pe*2)})}return()=>{ue.stop()}},[t,u]);const L=O=>{if(typeof O=="string"){const Z=m.nodes.find(ne=>ne.id===O);return{x:(Z==null?void 0:Z.x)??0,y:(Z==null?void 0:Z.y)??0}}return{x:O.x??0,y:O.y??0}},_=k.useCallback(O=>{O.preventDefault();const Z=O.deltaY>0?1.1:.9;E(ne=>{const W=Math.max(200,Math.min(u.width*3,ne.w*Z)),I=Math.max(150,Math.min(u.height*3,ne.h*Z)),P=(W-ne.w)/2,ae=(I-ne.h)/2;return{x:ne.x-P,y:ne.y-ae,w:W,h:I}})},[u]),V=k.useCallback(O=>{O.button===0&&(C.current=!0,A.current={x:O.clientX,y:O.clientY,vx:j.x,vy:j.y})},[j]),K=k.useCallback(O=>{var Z;if(R.current){const ne=c.current;if(!ne)return;const W=ne.getBoundingClientRect(),I=j.w/W.width,P=j.h/W.height,ae=j.x+(O.clientX-W.left)*I,je=j.y+(O.clientY-W.top)*P;R.current.fx=ae,R.current.fy=je,(Z=B.current)==null||Z.alpha(.3).restart();return}if(C.current){const ne=(O.clientX-A.current.x)*(j.w/u.width),W=(O.clientY-A.current.y)*(j.h/u.height);E(I=>({...I,x:A.current.vx-ne,y:A.current.vy-W}))}},[j,u]),Y=k.useCallback(()=>{C.current=!1,R.current&&(R.current.fx=null,R.current.fy=null,R.current=null)},[]),T=k.useCallback((O,Z)=>{var ne;O.stopPropagation(),R.current=Z,(ne=B.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:_,onMouseDown:V,onMouseMove:K,onMouseUp:Y,onMouseLeave:Y,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((O,Z)=>{const ne=L(O.source),W=L(O.target),I=y===Z,P=(ne.x+W.x)/2,ae=(ne.y+W.y)/2;return s.jsxs("g",{children:[s.jsx("line",{x1:ne.x,y1:ne.y,x2:W.x,y2:W.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>b(Z),onMouseLeave:()=>b(null)}),s.jsx("line",{x1:ne.x,y1:ne.y,x2:W.x,y2:W.y,stroke:I?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.3)",strokeWidth:I?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),I&&O.label&&s.jsx("text",{x:P,y:ae-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:O.label.length>30?O.label.slice(0,28)+"..":O.label})})]},Z)}),m.nodes.map(O=>{const Z=Gs[O.category]??Gs.general,ne=O.akb_type==="hub",W=ne?24:16,I=(f==null?void 0:f.id)===O.id,P=r===O.id,ae=I?1.2:P?1.15:1;return s.jsxs("g",{transform:`translate(${O.x??0}, ${O.y??0}) scale(${ae})`,style:{cursor:"pointer",transition:"transform 0.15s ease"},onClick:je=>{je.stopPropagation();const M=t.find(z=>z.id===O.id);M&&l(M)},onMouseDown:je=>T(je,O),onMouseEnter:je=>{var z;g(O);const M=(z=i.current)==null?void 0:z.getBoundingClientRect();M&&S({x:je.clientX-M.left,y:je.clientY-M.top})},onMouseLeave:()=>g(null),children:[P&&s.jsx("rect",{x:-W/2-4,y:-W/2-4,width:W+8,height:W+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:ne?5:2,opacity:.6}),s.jsx("rect",{x:-W/2,y:-W/2,width:W,height:W,fill:Z.border,rx:ne?4:2,opacity:I?1:.9}),s.jsx("rect",{x:-W/2+3,y:-W/2+3,width:Math.max(0,W-6),height:Math.max(0,W-6),fill:Z.bg,rx:ne?3:1}),s.jsx("text",{y:W/2+14,textAnchor:"middle",fill:P?"#e2e8f0":"#94a3b8",fontSize:11,fontFamily:"monospace",fontWeight:P?"bold":"normal",style:{pointerEvents:"none"},children:O.title.length>24?O.title.slice(0,22)+"..":O.title})]},O.id)})]}),f&&!R.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]}),((U=t.find(O=>O.id===f.id))==null?void 0:U.tldr)&&s.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:t.find(O=>O.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=WS(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(L=>L.id)),C=k.useCallback(L=>{const _=L.split("#")[0];if(!_.match(/\.(md|html)$/))return null;const V=t.includes("/")?t.replace(/\/[^/]+$/,""):"";let K;if(_.startsWith("./"))K=V?`${V}/${_.slice(2)}`:_.slice(2);else if(_.startsWith("../")){const U=V.split("/").filter(Boolean);let O=_;for(;O.startsWith("../");)U.length>0&&U.pop(),O=O.slice(3);K=U.length>0?`${U.join("/")}/${O}`:O}else K=_;if(E.has(K))return K;const Y=K.split("/").pop()??"",T=u.find(U=>U.id===Y||U.id.endsWith("/"+Y));return T?T.id:null},[t,E,u]),A=k.useCallback(L=>{const V=L.target.closest("a");if(!V)return;const K=V.getAttribute("href");if(!K||K.startsWith("http://")||K.startsWith("https://")||!K.match(/\.(md|html)(#.*)?$/))return;L.preventDefault(),L.stopPropagation();const Y=C(K);Y&&c(Y)},[C,c]);k.useEffect(()=>{f(!0),Ne.getKnowledgeDoc(t).then(L=>{m(L),v(L.content)}).catch(console.error).finally(()=>f(!1))},[t]);const R=async()=>{if(d){j(!0);try{await Ne.updateKnowledgeDoc(t,b),m({...d,content:b}),y(!1),r()}catch(L){console.error("Save failed:",L)}finally{j(!1)}}},B=async()=>{if(confirm(`Delete "${d==null?void 0:d.title}"?`))try{await Ne.deleteKnowledgeDoc(t),i(t)}catch(L){console.error("Delete failed:",L)}};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:R,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:B,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:L=>v(L.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:L=>v(L.target.value),spellCheck:!1}):s.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--terminal-text-secondary)"},onClick:A,children:s.jsx(Js,{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 Ne.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,j0=360,S0=700;function Rh(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(j0,window.innerWidth-t-100):S0,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(S0,Math.max(j0,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:R,handleResizeStart:B}=Rh(i),L=["all",...Array.from(new Set(t.map(U=>U.category))).sort()],_=t.filter(U=>{if(m!=="all"&&U.category!==m)return!1;if(y){const O=y.toLowerCase();return U.title.toLowerCase().includes(O)||(U.tldr??"").toLowerCase().includes(O)||U.tags.some(Z=>Z.toLowerCase().includes(O))}return!0}),V=U=>{S(!1),r(),g(U)},K=U=>{g(null),r()},Y=U=>{E(U.id)},T=j?t.find(U=>U.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)] ${R?"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 ${R?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:B}),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(C0,{label:"List",active:u==="list",onClick:()=>{d("list"),E(null)}}),s.jsx(C0,{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:U=>b(U.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:L.map(U=>s.jsx("button",{onClick:()=>x(U),className:"px-3 py-1.5 text-[10px] font-medium cursor-pointer whitespace-nowrap",style:{color:m===U?"#4ade80":"var(--terminal-text-muted)",borderBottom:m===U?"2px solid #4ade80":"2px solid transparent"},children:U==="all"?`All (${t.length})`:`${U} (${t.filter(O=>O.category===U).length})`},U))}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:_.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"}):_.map(U=>s.jsx(ZS,{doc:U,allDocs:t,onOpen:O=>g(O.id),onNavigateDoc:O=>g(O)},U.id))})]}),u==="list"&&f&&!v&&s.jsx(JS,{docId:f,onBack:()=>g(null),onDocUpdated:r,onDelete:K,onNavigateDoc:U=>g(U),allDocs:t}),u==="list"&&v&&s.jsx(PS,{onCreated:V,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(QS,{docs:t,onNodeClick:Y,selectedDocId:j}),T&&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:T.title}),s.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:T.status==="active"?"#16a34a":T.status==="draft"?"#f59e0b":"#94a3b8"}}),T.tldr&&s.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:T.tldr}),T.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"}),T.links.slice(0,5).map((U,O)=>s.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",U.text]},O))]}),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(T.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(Gs).map(([U,O])=>s.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[s.jsx("div",{className:"w-2 h-2",style:{background:O.border}}),s.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:U})]},U))})})]})]})]})}function C0({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}=Rh(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(Cf,{label:`Standups (${t.length})`,active:d==="standups",onClick:()=>m("standups")}),s.jsx(Cf,{label:`Waves (${l.length})`,active:d==="waves",onClick:()=>m("waves")})]}):s.jsx(Cf,{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(Ef,{title:`Standup ${b.date}`,content:b.content},v)),d==="waves"&&l.map((b,v)=>s.jsx(Ef,{title:`Wave ${b.id}`,subtitle:b.timestamp,content:b.content},v)),d==="decisions"&&r.map((b,v)=>s.jsx(Ef,{title:`#${b.id} ${b.title}`,subtitle:b.date,content:b.content},v))]})]})]})}function Cf({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 Ef({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(Js,{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}=Rh(r);if(k.useEffect(()=>{Ne.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(Js,{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 E0={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function gg({event:t,isThinkingCollapsed:l,onToggleThinking:r,onNavigateToJob:i,onOpenKnowledgeDoc:c,compact:u}){var m;const d=E0[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(Sh,{remarkPlugins:[Ah],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 select-text",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-hidden ${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=E0[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}=J0(t),[S,j]=k.useState(0),[E,C]=k.useState(new Set),A=k.useRef(null),R=k.useRef(Date.now()),B=k.useRef(!1);k.useEffect(()=>{const U=setInterval(()=>{j(Math.floor((Date.now()-R.current)/1e3))},1e3);return()=>clearInterval(U)},[]),k.useEffect(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[g]),k.useEffect(()=>{(y==="done"||y==="error")&&!B.current&&(B.current=!0,m==null||m())},[y,m]);const L=U=>{C(O=>{const Z=new Set(O);return Z.has(U)?Z.delete(U):Z.add(U),Z})},_={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[y],V={idle:"#888",connecting:"#888",streaming:r,done:"#2E7D32",error:"#C62828"}[y],K=U=>`${Math.floor(U/60)}:${String(U%60).padStart(2,"0")}`,Y=y==="done"||y==="error",T=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:V}}),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:K(S)}),s.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${V}22`,color:V},children:_}),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:"–"}),Y&&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(U=>s.jsx(gg,{event:U,isThinkingCollapsed:E.has(U.seq),onToggleThinking:()=>L(U.seq),onNavigateToJob:x,onOpenKnowledgeDoc:f},U.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`]}),Y&&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:Y?u:void 0}),T]}):T}const Nf={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:Nf[m.id]??"#888",color:Nf[m.id]??"#888",background:`${Nf[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 R=>{if(!R.ok||!R.body){c(V=>{const K=new Map(V),Y=K.get(v);return Y&&K.set(v,{...Y,streamStatus:"error"}),K});return}c(V=>{const K=new Map(V),Y=K.get(v);return Y&&K.set(v,{...Y,streamStatus:"streaming",status:"running"}),K});const B=R.body.getReader(),L=new TextDecoder;let _="";for(;;){const{done:V,value:K}=await B.read();if(V)break;_+=L.decode(K,{stream:!0});const Y=_.split(`
|
|
81
81
|
`);_=Y.pop()??"";let T="";for(const U of Y)if(U.startsWith("event: "))T=U.slice(7).trim();else if(U.startsWith("data: ")){try{const O=JSON.parse(U.slice(6));if(T==="activity"){const Z=O;Z.seq>E.lastSeq&&(E.lastSeq=Z.seq),c(ne=>{const W=new Map(ne),I=W.get(v);if(!I||I.events.some(ae=>ae.seq===Z.seq))return ne;const P={...I,events:[...I.events,Z]};if(Z.type==="dispatch:start"&&Z.data.childJobId){const ae=Z.data.childJobId,je=Z.data.targetRoleId??Z.data.roleId;if(je){const M=W.get(je);M&&(W.set(je,{...M,jobId:ae,status:"running",streamStatus:"connecting"}),setTimeout(()=>f(ae,je),0))}}return Z.type==="job:done"?(P.status="done",P.streamStatus="done"):Z.type==="job:error"?(P.status="error",P.streamStatus="error"):Z.type==="job:awaiting_input"?(P.status="awaiting_input",P.streamStatus="done"):Z.type==="job:reply"&&(P.status="running",P.streamStatus="streaming"),W.set(v,P),W})}else if(T==="stream:end"){const Z=O.reason;Z!=="replied"&&c(ne=>{const W=new Map(ne),I=W.get(v);if(!I)return ne;const P=Z==="error"?"error":Z==="awaiting_input"?"awaiting_input":"done";return W.set(v,{...I,status:I.status==="running"?P:I.status,streamStatus:P==="error"?"error":"done"}),W})}}catch{}T=""}}}).catch(R=>{R.name!=="AbortError"&&c(B=>{const L=new Map(B),_=L.get(v);return _&&L.set(v,{..._,streamStatus:"error"}),L})})},[]);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 N0={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},Ta=120,cr=44,A0=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*A0+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))*(Ta+16),x=Math.max(m,280);for(const g of c){const y=g.length*(Ta+16)-16,b=(x-y)/2;g.forEach((v,S)=>{const j=i.find(E=>E.roleId===v);j&&(j.x=b+S*(Ta+16))})}const f=c.length*A0+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+Ta/2,cy:g.y+cr/2}:{cx:0,cy:0}},x=f=>{switch(f.status){case"running":return N0[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:Math.max(u,280),height:d,className:"block",style:{minWidth:u},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=N0[f.roleId]??"#FBBF24",j="6 4",E="wave-edge-flow"),s.jsx("line",{x1:g.cx,y1:g.cy+cr/2-4,x2:y.cx,y2:y.cy-cr/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:Ta,height:cr,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:cr/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:cr/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:cr/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:Ta-18,y:cr/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),g.status==="error"&&s.jsx("text",{x:Ta-18,y:cr/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,onSave:x}){const{nodes:f,selectedRoleId:g,selectNode:y,progress:b,allDone:v,connectStream:S}=dC(l,r,i),[j,E]=k.useState(0),[C,A]=k.useState(new Set),[R,B]=k.useState(""),[L,_]=k.useState(!1),[V,K]=k.useState(!1),Y=k.useRef(null),T=k.useRef(Date.now()),U=k.useRef(!1),O=k.useCallback(async()=>{if(x){K(!0);try{const z=l.map(G=>G.jobId);await x(z)}catch(z){console.error("Save failed:",z)}finally{K(!1),c()}}},[x,l,c]),Z=k.useCallback(async()=>{if(!g||!R.trim())return;const z=f.get(g);if(!(!(z!=null&&z.jobId)||z.status!=="awaiting_input")){_(!0);try{const{jobId:G}=await Ne.replyToJob(z.jobId,R.trim());B(""),S(G,g)}catch(G){console.error("Reply failed:",G)}finally{_(!1)}}},[g,R,f,S]),ne=k.useCallback(async z=>{const G=f.get(z);if(G!=null&&G.jobId)try{await Ne.abortJob(G.jobId)}catch(D){console.error("Abort failed:",D)}},[f]),W=k.useCallback(async()=>{for(const[,z]of f)if((z.status==="running"||z.status==="awaiting_input")&&z.jobId)try{await Ne.abortJob(z.jobId)}catch{}},[f]);k.useEffect(()=>{const z=setInterval(()=>{E(Math.floor((Date.now()-T.current)/1e3))},1e3);return()=>clearInterval(z)},[]);const I=k.useRef(!1);k.useEffect(()=>{const z=Y.current;if(!z)return;const G=()=>{const D=z.scrollHeight-z.scrollTop-z.clientHeight<60;I.current=!D};return z.addEventListener("scroll",G),()=>z.removeEventListener("scroll",G)},[]),k.useEffect(()=>{I.current=!1,Y.current&&(Y.current.scrollTop=Y.current.scrollHeight)},[g]),k.useEffect(()=>{Y.current&&!I.current&&(Y.current.scrollTop=Y.current.scrollHeight)},[f]),k.useEffect(()=>{v&&!U.current&&(U.current=!0,d==null||d())},[v,d]);const P=z=>`${Math.floor(z/60)}:${String(z%60).padStart(2,"0")}`,ae=g?f.get(g):null,je=g?mC[g]??"#888":"#888",M=z=>{A(G=>{const D=new Set(G);return D.has(z)?D.delete(z):D.add(z),D})};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm pointer-events-none"}),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:v?"#2E7D32":"#B71C1C",animation:v?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:v?"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:P(j)}),b.awaitingInput>0&&s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[b.awaitingInput," awaiting reply"]}),s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:v?"#2E7D3222":"#B71C1C22",color:v?"#2E7D32":"#B71C1C"},children:[b.done,"/",b.total," done"]}),!v&&(b.running>0||b.awaitingInput>0)&&s.jsx("button",{onClick:W,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:"–"}),s.jsx("button",{onClick:c,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",title:v?"Dismiss wave":"Close (jobs keep running)",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-col flex-1 min-h-0",children:[s.jsxs("div",{className:"shrink-0 border-b border-[var(--terminal-border)] flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",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 gap-x-3 ml-auto",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(z=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:z.color,animation:z.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),s.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:z.label})]},z.label))})]}),s.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:s.jsx(hC,{nodes:f,rootId:i,selectedRoleId:g,onSelectNode:y})})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[ae&&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:je}}),s.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:ae.roleId.toUpperCase()}),s.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:ae.roleName}),s.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:ae.status==="awaiting_input"?"#F59E0B22":`${je}22`,color:ae.status==="awaiting_input"?"#F59E0B":je},children:ae.status==="running"?"Working":ae.status==="done"?"Complete":ae.status==="error"?"Error":ae.status==="waiting"?"Waiting":ae.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(ae.status==="running"||ae.status==="awaiting_input")&&ae.jobId&&s.jsx("button",{onClick:()=>ne(ae.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:Y,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[ae&&ae.events.length===0&&s.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:ae.status==="waiting"?"Waiting for dispatch...":ae.status==="running"?"Connecting to activity stream...":ae.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),ae==null?void 0:ae.events.map(z=>s.jsx(gg,{event:z,isThinkingCollapsed:C.has(z.seq),onToggleThinking:()=>M(z.seq),onNavigateToJob:G=>{for(const[,D]of f)if(D.jobId===G){y(D.roleId);return}},onOpenKnowledgeDoc:m},z.seq)),(ae==null?void 0:ae.status)==="running"&&s.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(ae==null?void 0:ae.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:[ae.roleName," is waiting for your response"]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:R,onChange:z=>B(z.target.value),onKeyDown:z=>{z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),Z())},placeholder:"Type your response...",disabled:L,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:Z,disabled:L||!R.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:L?"...":"Reply"})]})]}),!ae&&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:ae&&ae.events.length>0&&`${ae.events.length} events`}),v&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:c,className:"px-4 py-1.5 text-xs rounded-lg font-semibold cursor-pointer",style:{background:"rgba(255,255,255,0.08)",color:"var(--terminal-text-muted)"},children:"Dismiss"}),x&&s.jsx("button",{onClick:O,disabled:V,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:V?"Saving...":"Save Wave"})]})]})]})]})]})]})}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 _h(t){return pC[t]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const bg=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],vg=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],wg=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],kg=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],jg=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],na={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 Ms({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 Af({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 Df({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 Zr(t){return t[Math.floor(Math.random()*t.length)]}function ji(t){var c,u,d;const l=ig(),r=sg(),i=og().filter(m=>!t||ug(m.id,t));return{skinColor:Zr(bg),hairColor:Zr(vg),shirtColor:Zr(wg),pantsColor:Zr(kg),shoeColor:Zr(jg),hairStyle:(c=Zr(l))==null?void 0:c.id,outfitStyle:(u=Zr(r))==null?void 0:u.id,accessory:(d=Zr(i))==null?void 0:d.id}}function Sg({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 R;const C=(R=E.target.files)==null?void 0:R[0];if(!C)return;const A=new Image;A.onload=()=>{const B=Hj(A);r({...B,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=ig(),v=sg(),S=og(),j=d!==void 0?S.filter(E=>ug(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(Xs,{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(Df,{label:"LOOK",active:m==="look",onClick:()=>x("look")}),s.jsx(Df,{label:"OUTFIT",active:m==="outfit",onClick:()=>x("outfit")}),s.jsx(Df,{label:"ACCESSORY",active:m==="accessory",onClick:()=>x("accessory")})]}),m==="look"&&s.jsxs(s.Fragment,{children:[s.jsx(Ms,{label:"SKIN",presets:bg,value:l.skinColor,onChange:E=>f("skinColor",E)}),s.jsx(Ms,{label:"HAIR COLOR",presets:vg,value:l.hairColor,onChange:E=>f("hairColor",E)}),s.jsx(Af,{label:"HAIR STYLE",items:b,value:l.hairStyle,onChange:E=>f("hairStyle",E)})]}),m==="outfit"&&s.jsxs(s.Fragment,{children:[s.jsx(Af,{label:"STYLE",items:v,value:l.outfitStyle,onChange:E=>f("outfitStyle",E)}),s.jsx(Ms,{label:"TOP",presets:wg,value:l.shirtColor,onChange:E=>f("shirtColor",E)}),s.jsx(Ms,{label:"PANTS",presets:kg,value:l.pantsColor,onChange:E=>f("pantsColor",E)}),s.jsx(Ms,{label:"SHOES",presets:jg,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(Af,{label:"ACCESSORY",items:S,value:l.accessory,onChange:E=>f("accessory",E),lockInfo:d!==void 0?{roleLevel:d,getLockLevel:cg}: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 rh(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Tf(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 Fs=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=rh(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(""),[R,B]=k.useState("ceo"),[L,_]=k.useState(1),[V,K]=k.useState(""),[Y,T]=k.useState(""),[U,O]=k.useState(!1),[Z,ne]=k.useState("member"),[W,I]=k.useState("ceo"),[P,ae]=k.useState(""),[je,M]=k.useState(ji),[z,G]=k.useState(!1),[D,ue]=k.useState(""),[Ee,ge]=k.useState([]),[Ae,De]=k.useState(new Set),[Ie,pe]=k.useState(""),[Pe,fe]=k.useState("input"),[he,be]=k.useState({done:0,total:0}),Ce=k.useRef(null),ze=k.useRef(null),Oe=k.useRef(null);k.useEffect(()=>{Ne.getSkills().then(q=>ge(q.filter(Te=>Te.installed))).catch(()=>{})},[]),k.useEffect(()=>{var q,Te,He;i==="single"?(L===1&&((q=Ce.current)==null||q.focus()),L===2&&((Te=ze.current)==null||Te.focus())):Pe==="input"&&((He=Oe.current)==null||He.focus())},[L,i,Pe]);const Me=k.useMemo(()=>new Set(t.map(q=>q.id)),[t]),we=k.useMemo(()=>{const q=Ie.split(`
|
|
82
82
|
`),Te=new Set;return q.map(He=>bC(He,Me,Te)).filter(He=>He!==null)},[Ie,Me]),Be=we.length>0&&we.every(q=>!q.error),tt=q=>{K(q),U||T(rh(q))},jt=V.trim().length>0&&Y.trim().length>0&&!t.some(q=>q.id===Y),Ut=P.trim().length>0,yt=async()=>{G(!0),ue("");const q=Tf(Z);try{await r({id:Y,name:V.trim(),level:Z,reportsTo:W,persona:P.trim(),...q,skills:Ae.size>0?[...Ae]:void 0},je),l()}catch(Te){ue(Te instanceof Error?Te.message:"Failed to create role"),G(!1)}},Vt=q=>q===1?jt:q===2?Ut:!0,ie=async()=>{G(!0),ue(""),be({done:0,total:we.length});try{for(let q=0;q<we.length;q++){const Te=we[q],He=Tf(Te.level),Je=ji(),mt=`${Te.name}. A ${Te.level} role reporting to ${Te.reportsTo}.`;await r({id:Te.id,name:Te.name,level:Te.level,reportsTo:Te.reportsTo,persona:mt,...He},Je),be({done:q+1,total:we.length})}l()}catch(q){ue(q instanceof Error?q.message:"Failed to create roles"),G(!1)}},me=async()=>{g(!0),b("");try{const q=u.replace(/^tycono:/,"").trim();if(!q){b("Please enter a character ID"),g(!1);return}const Te=await Ci.getCharacter(q);x(Te),E(Te.name||""),A(rh(Te.name||q)),S("review")}catch{b("Character not found. Check the ID and try again.")}finally{g(!1)}},Fe=async()=>{if(!m)return;G(!0),ue("");const q=m,Te=q.level==="c-level"||q.level==="team-lead"?q.level:"member",He=Tf(Te),Je=q.skills!=null&&typeof q.skills=="object"&&!Array.isArray(q.skills)&&"primary"in q.skills;try{await r({id:C,name:j.trim(),level:Te,reportsTo:R,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:Je?q.skills:void 0},q.appearance?q.appearance:ji()),l()}catch(mt){ue(mt instanceof Error?mt.message:"Failed to hire"),G(!1)}},Ge=q=>{q.key==="Escape"&&l(),q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&(i==="single"?L<Fs&&Vt(L)?_(L+1):L===Fs&&yt():i==="bulk"?Pe==="input"&&Be?fe("review"):Pe==="review"&&ie():i==="store"&&(v==="input"&&u.trim()?me():v==="review"&&Fe()))},ye=t.some(q=>q.id===Y)&&Y.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:Ge,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"),ue("")},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"),ue("")},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"),ue("")},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 ${L} of ${Fs}`:i==="bulk"?Pe==="input"?"Enter roles, one per line":`Review ${we.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:Fs},(q,Te)=>Te+1).map(q=>s.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:q<=L?"#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()&&me()},autoFocus:!0}),s.jsx("button",{onClick:me,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(Xs,{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:R,onChange:q=>B(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 Je,mt;const q=m.skills;if(q&&typeof q=="object"&&!Array.isArray(q)&&"primary"in q){const et=[];return(mt=(Je=q.primary)==null?void 0:Je.frontmatter)!=null&&mt.name&&et.push(q.primary.frontmatter.name),q.shared&&q.shared.forEach(Yt=>{var cn;return et.push(((cn=Yt.frontmatter)==null?void 0:cn.name)||Yt.id)}),et.map(Yt=>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:Yt},Yt))}return(Array.isArray(q)?q:[]).map((et,Yt)=>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 et=="string"?et:et.name},Yt))})()})]})]}),D&&s.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:D})]})]}):i==="single"?s.jsxs(s.Fragment,{children:[L===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:Ce,value:V,onChange:q=>tt(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:Y,onChange:q=>{T(q.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),O(!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 ${ye?"border-red-400":"border-white/10 focus:border-white/25"}`}),ye&&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 ${Z===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:W,onChange:q=>I(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))]})]})]}),L===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:ze,value:P,onChange:q=>ae(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:Ae.has(q.id),onChange:()=>De(Te=>{const He=new Set(Te);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))})]})]}),L===3&&s.jsx("div",{className:"customize-body",style:{padding:0},children:s.jsx(Sg,{roleId:"default",appearance:je,onChange:M,onRandomize:()=>M(ji()),onReset:()=>M(ji()),label:s.jsxs("span",{children:[Y||"new-role"," — ",V||"New Role"]})})}),L===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(Xs,{roleId:"default",appearance:je,scale:4})}),s.jsxs("div",{className:"flex-1 space-y-2.5",children:[s.jsx(Rs,{label:"Name",value:V}),s.jsx(Rs,{label:"ID",value:Y,mono:!0}),s.jsx(Rs,{label:"Level",value:Z}),s.jsx(Rs,{label:"Reports To",value:W}),Ae.size>0&&s.jsx(Rs,{label:"Skills",value:[...Ae].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:P})]})]}),D&&s.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:D})]})]}):s.jsxs(s.Fragment,{children:[Pe==="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:Oe,value:Ie,onChange:q=>pe(q.target.value),placeholder:`Name, Level, ReportsTo
|
|
83
83
|
e.g.
|
|
@@ -98,4 +98,4 @@ ${le}`;wr(se.id,xe,"do")}catch(se){_t(`Failed to delegate: ${se instanceof Error
|
|
|
98
98
|
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
99
99
|
border border-[var(--terminal-border)]
|
|
100
100
|
focus:border-[var(--terminal-border-hover)]
|
|
101
|
-
placeholder:text-[var(--terminal-text-muted)]`,un=ke=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ke?"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:On,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:Te.map((ke,Qt)=>s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Qt<=l?"var(--accent)":"var(--terminal-surface-light)"}}),s.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Qt===l?"var(--terminal-text)":"var(--terminal-text-muted)"},children:xN[ke]})]},ke))})]}),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:un(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:un(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:`${Nn} mt-3`,placeholder:"sk-ant-...",value:m,onChange:ke=>x(ke.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:Y,className:Nn,placeholder:"e.g. Acme Corp",value:y,onChange:ke=>b(ke.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:`${Nn} resize-none`,rows:3,placeholder:"What does your AI company do?",value:v,onChange:ke=>S(ke.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:`${Nn} flex-1`,placeholder:"/path/to/your-company",value:C,onChange:ke=>{A(ke.target.value),_(!0)}}),s.jsx("button",{onClick:()=>K(!V),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."}),V&&s.jsx(Ec,{onSelect:ke=>{A(ke),_(!0),K(!1)},onClose:()=>K(!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:Nn,value:j,onChange:ke=>E(ke.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:un(T==="fresh"),onClick:()=>{U("fresh"),W(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:un(T==="existing"),onClick:()=>U("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."}),T==="existing"&&s.jsxs("div",{className:"mt-3",onClick:ke=>ke.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${Nn} flex-1`,placeholder:"/path/to/your/project",value:O,onChange:ke=>{Z(ke.target.value),W(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>je(!ae),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:Yt,disabled:I||!O.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:I||!O.trim()?.5:1},children:I?"...":"Verify"})]}),ne===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Path verified: ",O]}),ne===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," Invalid path"]}),ae&&s.jsx(Ec,{onSelect:ke=>{Z(ke),W(!0),je(!1)},onClose:()=>je(!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:un(M==="skip"),onClick:()=>z("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:un(M==="import"),onClick:()=>z("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."}),M==="import"&&s.jsxs("div",{className:"mt-3 space-y-2",onClick:ke=>ke.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${Nn} flex-1`,placeholder:"/path/to/docs",value:ue,onChange:ke=>Ee(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&(ke.preventDefault(),Nt())},autoFocus:!0}),s.jsx("button",{onClick:()=>Ae(!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:Nt,disabled:!ue.trim(),className:"px-3 py-2 rounded text-xs font-medium",style:{background:"var(--accent)",color:"#fff",opacity:ue.trim()?1:.5},children:"Add"})]}),ge&&s.jsx(Ec,{onSelect:ke=>{G.includes(ke)||D([...G,ke]),Ae(!1)},onClose:()=>Ae(!1)}),G.length>0&&s.jsx("div",{className:"space-y-1",children:G.map((ke,Qt)=>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:ke}),s.jsx("button",{onClick:()=>D(G.filter((Oa,pl)=>pl!==Qt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Qt))}),G.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:un(M==="existing-akb"),onClick:()=>z("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."}),M==="existing-akb"&&s.jsxs("div",{className:"mt-3",onClick:ke=>ke.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${Nn} flex-1`,placeholder:"/path/to/your/akb",value:De,onChange:ke=>{Ie(ke.target.value),Pe(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>Ce(!be),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:cn,disabled:fe||!De.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:fe||!De.trim()?.5:1},children:fe?"...":"Verify"})]}),pe===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found: ",De]}),pe===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),be&&s.jsx(Ec,{onSelect:ke=>{Ie(ke),Pe(null),Ce(!1)},onClose:()=>Ce(!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."}),ze.map(ke=>s.jsxs("div",{className:un(Me===ke.id),onClick:()=>we(ke.id),children:[s.jsx("div",{className:"font-medium text-sm capitalize",children:ke.id}),s.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ke.roles.map(Qt=>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:Qt.name},Qt.id))})]},ke.id)),s.jsxs("div",{className:un(Me==="custom"),onClick:()=>we("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:jt?M==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!jt&&!Be&&!ye&&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:M==="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:"})," ",De]}),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:"})," ",T==="fresh"?"Start Fresh":`Existing (${O})`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",M==="skip"?"Fresh (empty)":`Import ${G.length} source(s)`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Team:"})," ",Me]}),M==="import"&&G.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."})]})}),yt&&s.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:yt})]}),(Be||ye)&&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:ye?"Connecting to AKB...":"Scaffolding your company..."})]}),jt&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),Fe&&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:"})," ",Fe]}),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:ie.map((ke,Qt)=>s.jsxs("div",{className:"py-0.5",children:[s.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ke]},Qt))}),M==="import"&&G.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&&!jt&&s.jsx("button",{onClick:et,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," / ",Te.length]}),s.jsx("div",{children:jt?s.jsx("button",{onClick:mr,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:mt,disabled:!Je()||Be||ye,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Je()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Je()&&!Be&&!ye?1:.5},children:He==="create"?Be||ye?ye?"Connecting...":"Creating...":M==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function yN(){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 Ne.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 gN=k.lazy(()=>J2(()=>import("./preview-app-F1hM5BWu.js"),[]));function Lg(){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 bN(){var t;try{const l=localStorage.getItem("tycono-theme"),r=l&&l in na?l:"default",i=(t=na[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 vN(){const{initialized:t,loading:l,refetch:r}=yN(),[i,c]=k.useState(null);k.useEffect(()=>{bN()},[]);const u=d=>{d&&c(d),r()};return l?s.jsx(Lg,{}):t?s.jsx(mN,{importJob:i,onImportDone:()=>c(null)}):s.jsx(pN,{onComplete:u})}function wN(){const t=new URLSearchParams(window.location.search).has("sprite-preview");return s.jsx(P2,{children:t?s.jsx(k.Suspense,{fallback:s.jsx(Lg,{}),children:s.jsx(gN,{})}):s.jsx(vN,{})})}W2.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(wN,{})}));export{vg as H,kg as P,jg as S,SN as a,wg as b,bg as c,eh as d,Tj as e,Dj as f,jN as g,zj as h,s as j,k as r};
|
|
101
|
+
placeholder:text-[var(--terminal-text-muted)]`,un=ke=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ke?"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:On,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:Te.map((ke,Qt)=>s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Qt<=l?"var(--accent)":"var(--terminal-surface-light)"}}),s.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Qt===l?"var(--terminal-text)":"var(--terminal-text-muted)"},children:xN[ke]})]},ke))})]}),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:un(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:un(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:`${Nn} mt-3`,placeholder:"sk-ant-...",value:m,onChange:ke=>x(ke.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:Y,className:Nn,placeholder:"e.g. Acme Corp",value:y,onChange:ke=>b(ke.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:`${Nn} resize-none`,rows:3,placeholder:"What does your AI company do?",value:v,onChange:ke=>S(ke.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:`${Nn} flex-1`,placeholder:"/path/to/your-company",value:C,onChange:ke=>{A(ke.target.value),_(!0)}}),s.jsx("button",{onClick:()=>K(!V),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."}),V&&s.jsx(Ec,{onSelect:ke=>{A(ke),_(!0),K(!1)},onClose:()=>K(!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:Nn,value:j,onChange:ke=>E(ke.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:un(T==="fresh"),onClick:()=>{U("fresh"),W(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:un(T==="existing"),onClick:()=>U("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."}),T==="existing"&&s.jsxs("div",{className:"mt-3",onClick:ke=>ke.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${Nn} flex-1`,placeholder:"/path/to/your/project",value:O,onChange:ke=>{Z(ke.target.value),W(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>je(!ae),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:Yt,disabled:I||!O.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:I||!O.trim()?.5:1},children:I?"...":"Verify"})]}),ne===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Path verified: ",O]}),ne===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," Invalid path"]}),ae&&s.jsx(Ec,{onSelect:ke=>{Z(ke),W(!0),je(!1)},onClose:()=>je(!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:un(M==="skip"),onClick:()=>z("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:un(M==="import"),onClick:()=>z("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."}),M==="import"&&s.jsxs("div",{className:"mt-3 space-y-2",onClick:ke=>ke.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${Nn} flex-1`,placeholder:"/path/to/docs",value:ue,onChange:ke=>Ee(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&(ke.preventDefault(),Nt())},autoFocus:!0}),s.jsx("button",{onClick:()=>Ae(!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:Nt,disabled:!ue.trim(),className:"px-3 py-2 rounded text-xs font-medium",style:{background:"var(--accent)",color:"#fff",opacity:ue.trim()?1:.5},children:"Add"})]}),ge&&s.jsx(Ec,{onSelect:ke=>{G.includes(ke)||D([...G,ke]),Ae(!1)},onClose:()=>Ae(!1)}),G.length>0&&s.jsx("div",{className:"space-y-1",children:G.map((ke,Qt)=>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:ke}),s.jsx("button",{onClick:()=>D(G.filter((Oa,pl)=>pl!==Qt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Qt))}),G.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:un(M==="existing-akb"),onClick:()=>z("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."}),M==="existing-akb"&&s.jsxs("div",{className:"mt-3",onClick:ke=>ke.stopPropagation(),children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${Nn} flex-1`,placeholder:"/path/to/your/akb",value:De,onChange:ke=>{Ie(ke.target.value),Pe(null)},autoFocus:!0}),s.jsx("button",{onClick:()=>Ce(!be),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:cn,disabled:fe||!De.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors",style:{background:"var(--accent)",color:"#fff",opacity:fe||!De.trim()?.5:1},children:fe?"...":"Verify"})]}),pe===!0&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found: ",De]}),pe===!1&&s.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),be&&s.jsx(Ec,{onSelect:ke=>{Ie(ke),Pe(null),Ce(!1)},onClose:()=>Ce(!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."}),ze.map(ke=>s.jsxs("div",{className:un(Me===ke.id),onClick:()=>we(ke.id),children:[s.jsx("div",{className:"font-medium text-sm capitalize",children:ke.id}),s.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ke.roles.map(Qt=>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:Qt.name},Qt.id))})]},ke.id)),s.jsxs("div",{className:un(Me==="custom"),onClick:()=>we("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:jt?M==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!jt&&!Be&&!ye&&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:M==="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:"})," ",De]}),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:"})," ",T==="fresh"?"Start Fresh":`Existing (${O})`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",M==="skip"?"Fresh (empty)":`Import ${G.length} source(s)`]}),s.jsxs("div",{children:[s.jsx("span",{className:"opacity-50",children:"Team:"})," ",Me]}),M==="import"&&G.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."})]})}),yt&&s.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:yt})]}),(Be||ye)&&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:ye?"Connecting to AKB...":"Scaffolding your company..."})]}),jt&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),Fe&&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:"})," ",Fe]}),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:ie.map((ke,Qt)=>s.jsxs("div",{className:"py-0.5",children:[s.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ke]},Qt))}),M==="import"&&G.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&&!jt&&s.jsx("button",{onClick:et,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," / ",Te.length]}),s.jsx("div",{children:jt?s.jsx("button",{onClick:mr,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:mt,disabled:!Je()||Be||ye,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Je()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Je()&&!Be&&!ye?1:.5},children:He==="create"?Be||ye?ye?"Connecting...":"Creating...":M==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function yN(){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 Ne.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 gN=k.lazy(()=>J2(()=>import("./preview-app-Dw1HOq70.js"),[]));function Lg(){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 bN(){var t;try{const l=localStorage.getItem("tycono-theme"),r=l&&l in na?l:"default",i=(t=na[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 vN(){const{initialized:t,loading:l,refetch:r}=yN(),[i,c]=k.useState(null);k.useEffect(()=>{bN()},[]);const u=d=>{d&&c(d),r()};return l?s.jsx(Lg,{}):t?s.jsx(mN,{importJob:i,onImportDone:()=>c(null)}):s.jsx(pN,{onComplete:u})}function wN(){const t=new URLSearchParams(window.location.search).has("sprite-preview");return s.jsx(P2,{children:t?s.jsx(k.Suspense,{fallback:s.jsx(Lg,{}),children:s.jsx(gN,{})}):s.jsx(vN,{})})}W2.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(wN,{})}));export{vg as H,kg as P,jg as S,SN as a,wg as b,bg as c,eh as d,Tj as e,Dj as f,jN 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-
|
|
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-C73_NKTf.js";function A({id:i,ap:a,bobY:r,layers:l}){const c=s.useRef(null),o=k(i);return s.useEffect(()=>{if(!o||!c.current)return;const p=c.current.getContext("2d");if(!p)return;const h={...o,layers:o.layers.filter(u=>l.has(u.name))};E(p,h,r,a)},[o,a,r,l]),o?t.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:16,textAlign:"center",minWidth:140},children:[t.jsx("canvas",{ref:c,width:o.width*2,height:o.height*2,style:{imageRendering:"pixelated",display:"block",margin:"0 auto 8px",width:o.width*6,height:o.height*6,border:"1px solid #30363d",background:"#0d1117"}}),t.jsx("div",{style:{fontSize:11,color:"#8b949e",textTransform:"uppercase",letterSpacing:1},children:i})]}):null}function F({id:i}){const a=s.useRef(null),r=w(i);return s.useEffect(()=>{if(!r||!a.current)return;const l=a.current.getContext("2d");l&&B(l,r)},[r]),r?t.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:16,textAlign:"center"},children:[t.jsx("canvas",{ref:a,width:r.canvasWidth,height:r.canvasHeight,style:{imageRendering:"pixelated",display:"block",margin:"0 auto 8px",width:r.canvasWidth*2,height:r.canvasHeight*2,border:"1px solid #30363d",background:"#0d1117"}}),t.jsx("div",{style:{fontSize:11,color:"#8b949e",textTransform:"uppercase",letterSpacing:1},children:i})]}):null}const g=["body","hair","face","accessory","item","legs"];function I(){const[i,a]=s.useState({skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"}),[r,l]=s.useState(new Set(g)),[c,o]=s.useState(0),p=s.useRef(0);s.useEffect(()=>{const e=()=>{p.current++,o(p.current%60<30?1:0),requestAnimationFrame(e)},n=requestAnimationFrame(e);return()=>cancelAnimationFrame(n)},[]);const h=m(),u=S(),x=s.useCallback(e=>{l(n=>{const d=new Set(n);return d.has(e)?d.delete(e):d.add(e),d})},[]),f=s.useCallback(()=>{const e=n=>n[Math.floor(Math.random()*n.length)];a({skinColor:e(R),hairColor:e(v),shirtColor:e(j),pantsColor:e(C),shoeColor:e(y)})},[]);return t.jsxs("div",{style:{fontFamily:"'SF Mono', monospace",background:"#0d1117",color:"#e6edf3",padding:24,minHeight:"100vh"},children:[t.jsx("h1",{style:{fontSize:18,color:"#58a6ff",marginBottom:4},children:"Sprite Blueprint Preview"}),t.jsx("p",{style:{fontSize:12,color:"#484f58",marginBottom:16},children:"All sprites rendered from declarative Blueprint data"}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:12,padding:12,background:"#161b22",border:"1px solid #21262d",borderRadius:8,marginBottom:12,alignItems:"center"},children:[[["Skin","skinColor"],["Hair","hairColor"],["Shirt","shirtColor"],["Pants","pantsColor"],["Shoes","shoeColor"]].map(([e,n])=>t.jsxs("label",{style:{fontSize:11,color:"#8b949e",display:"flex",alignItems:"center",gap:4},children:[e,t.jsx("input",{type:"color",value:i[n],onChange:d=>a(b=>({...b,[n]:d.target.value})),style:{width:28,height:28,border:"1px solid #30363d",borderRadius:4,background:"none",cursor:"pointer"}})]},n)),t.jsx("button",{onClick:f,style:{background:"#21262d",color:"#e6edf3",border:"1px solid #30363d",borderRadius:4,padding:"4px 12px",fontSize:11,cursor:"pointer"},children:"Random"})]}),t.jsx("div",{style:{display:"flex",gap:8,marginBottom:16,flexWrap:"wrap"},children:g.map(e=>t.jsxs("label",{style:{fontSize:11,color:"#8b949e",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:r.has(e),onChange:()=>x(e)}),e]},e))}),t.jsxs("h2",{style:{fontSize:14,color:"#8b949e",margin:"24px 0 12px",borderBottom:"1px solid #21262d",paddingBottom:6},children:["Characters (",h.length,")"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:24},children:h.map(e=>t.jsx(A,{id:e,ap:i,bobY:c,layers:r},e))}),t.jsxs("h2",{style:{fontSize:14,color:"#8b949e",margin:"24px 0 12px",borderBottom:"1px solid #21262d",paddingBottom:6},children:["Facilities (",u.length,")"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:24},children:u.map(e=>t.jsx(F,{id:e},e))})]})}export{I as default};
|
package/src/web/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Tycono</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-C73_NKTf.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-DM-qIa7f.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|