nothumanallowed 16.0.52 → 16.0.53

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.
@@ -748,7 +748,7 @@ Be concise. Highlight what each agent contributed uniquely. Give your own synthe
748
748
  `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``}(n||(t.C0=n={})),function(e){e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`}(r||(t.C1=r={})),function(e){e.ST=`${n.ESC}\\`}(i||(t.C1_ESCAPED=i={}))},7399:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.evaluateKeyboardEvent=void 0;let r=n(2584),i={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};t.evaluateKeyboardEvent=function(e,t,n,a){let o={type:0,cancel:!1,key:void 0},s=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`:e.key===`UIKeyInputRightArrow`?o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`);break;case 8:if(e.altKey){o.key=r.C0.ESC+r.C0.DEL;break}o.key=r.C0.DEL;break;case 9:if(e.shiftKey){o.key=r.C0.ESC+`[Z`;break}o.key=r.C0.HT,o.cancel=!0;break;case 13:o.key=e.altKey?r.C0.ESC+r.C0.CR:r.C0.CR,o.cancel=!0;break;case 27:o.key=r.C0.ESC,e.altKey&&(o.key=r.C0.ESC+r.C0.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`D`,o.key===r.C0.ESC+`[1;3D`&&(o.key=r.C0.ESC+(n?`b`:`[1;5D`))):o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`;break;case 39:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`C`,o.key===r.C0.ESC+`[1;3C`&&(o.key=r.C0.ESC+(n?`f`:`[1;5C`))):o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`;break;case 38:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`A`,n||o.key!==r.C0.ESC+`[1;3A`||(o.key=r.C0.ESC+`[1;5A`)):o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`;break;case 40:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`B`,n||o.key!==r.C0.ESC+`[1;3B`||(o.key=r.C0.ESC+`[1;5B`)):o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`;break;case 45:e.shiftKey||e.ctrlKey||(o.key=r.C0.ESC+`[2~`);break;case 46:o.key=s?r.C0.ESC+`[3;`+(s+1)+`~`:r.C0.ESC+`[3~`;break;case 36:o.key=s?r.C0.ESC+`[1;`+(s+1)+`H`:t?r.C0.ESC+`OH`:r.C0.ESC+`[H`;break;case 35:o.key=s?r.C0.ESC+`[1;`+(s+1)+`F`:t?r.C0.ESC+`OF`:r.C0.ESC+`[F`;break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=r.C0.ESC+`[5;`+(s+1)+`~`:o.key=r.C0.ESC+`[5~`;break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=r.C0.ESC+`[6;`+(s+1)+`~`:o.key=r.C0.ESC+`[6~`;break;case 112:o.key=s?r.C0.ESC+`[1;`+(s+1)+`P`:r.C0.ESC+`OP`;break;case 113:o.key=s?r.C0.ESC+`[1;`+(s+1)+`Q`:r.C0.ESC+`OQ`;break;case 114:o.key=s?r.C0.ESC+`[1;`+(s+1)+`R`:r.C0.ESC+`OR`;break;case 115:o.key=s?r.C0.ESC+`[1;`+(s+1)+`S`:r.C0.ESC+`OS`;break;case 116:o.key=s?r.C0.ESC+`[15;`+(s+1)+`~`:r.C0.ESC+`[15~`;break;case 117:o.key=s?r.C0.ESC+`[17;`+(s+1)+`~`:r.C0.ESC+`[17~`;break;case 118:o.key=s?r.C0.ESC+`[18;`+(s+1)+`~`:r.C0.ESC+`[18~`;break;case 119:o.key=s?r.C0.ESC+`[19;`+(s+1)+`~`:r.C0.ESC+`[19~`;break;case 120:o.key=s?r.C0.ESC+`[20;`+(s+1)+`~`:r.C0.ESC+`[20~`;break;case 121:o.key=s?r.C0.ESC+`[21;`+(s+1)+`~`:r.C0.ESC+`[21~`;break;case 122:o.key=s?r.C0.ESC+`[23;`+(s+1)+`~`:r.C0.ESC+`[23~`;break;case 123:o.key=s?r.C0.ESC+`[24;`+(s+1)+`~`:r.C0.ESC+`[24~`;break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(n&&!a||!e.altKey||e.metaKey)!n||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(o.key=r.C0.US),e.key===`@`&&(o.key=r.C0.NUL)):e.keyCode===65&&(o.type=1);else{let t=i[e.keyCode]?.[+!!e.shiftKey];if(t)o.key=r.C0.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),o.key=r.C0.ESC+n}else if(e.keyCode===32)o.key=r.C0.ESC+(e.ctrlKey?r.C0.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),o.key=r.C0.ESC+t,o.cancel=!0}}else e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=r.C0.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=r.C0.DEL:e.keyCode===219?o.key=r.C0.ESC:e.keyCode===220?o.key=r.C0.FS:e.keyCode===221&&(o.key=r.C0.GS)}return o}},482:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r},t.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=1024*(this._interim-55296)+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=1024*(i-55296)+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},t.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r,i,a,o,s=0,c=0,l=0;if(this.interim[0]){let r=!1,i=this.interim[0];i&=(224&i)==192?31:(240&i)==224?15:7;let a,o=0;for(;(a=63&this.interim[++o])&&o<4;)i<<=6,i|=a;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(a=e[l++],(192&a)!=128){l--,r=!0;break}this.interim[o++]=a,i<<=6,i|=63&a}r||(c===2?i<128?l--:t[s++]=i:c===3?i<2048||i>=55296&&i<=57343||i===65279||(t[s++]=i):i<65536||i>1114111||(t[s++]=i)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;!(!(d<u)||128&(r=e[d])||128&(i=e[d+1])||128&(a=e[d+2])||128&(o=e[d+3]));)t[s++]=r,t[s++]=i,t[s++]=a,t[s++]=o,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((224&r)==192){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(c=(31&r)<<6|63&i,c<128){d--;continue}t[s++]=c}else if((240&r)==224){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(c=(15&r)<<12|(63&i)<<6|63&a,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((248&r)==240){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,this.interim[2]=a,s;if(o=e[d++],(192&o)!=128){d--;continue}if(c=(7&r)<<18|(63&i)<<12|(63&a)<<6|63&o,c<65536||c>1114111)continue;t[s++]=c}}return s}}},225:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeV6=void 0;let n=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],r=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],i;t.UnicodeV6=class{constructor(){if(this.version=`6`,!i){i=new Uint8Array(65536),i.fill(1),i[0]=0,i.fill(0,1,32),i.fill(0,127,160),i.fill(2,4352,4448),i[9001]=2,i[9002]=2,i.fill(2,11904,42192),i[12351]=1,i.fill(2,44032,55204),i.fill(2,63744,64256),i.fill(2,65040,65050),i.fill(2,65072,65136),i.fill(2,65280,65377),i.fill(2,65504,65511);for(let e=0;e<n.length;++e)i.fill(0,n[e][0],n[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?i[e]:function(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}(e,r)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}}},5981:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.WriteBuffer=void 0;let r=n(8460),i=n(844);class a extends i.Disposable{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new r.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t)return void(this._syncCalls=0);if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let n;for(this._isSyncWriting=!0;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>5e7)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch((e=>(queueMicrotask((()=>{throw e})),Promise.resolve(!1)))).then(e=>Date.now()-n>=12?setTimeout((()=>this._innerWrite(0,e))):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,Date.now()-n>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}t.WriteBuffer=a},5941:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.toRgbString=t.parseColor=void 0;let n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,r=/^[\da-f]+$/;function i(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}t.parseColor=function(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=n.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),r.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}},t.toRgbString=function(e,t=16){let[n,r,a]=e;return`rgb:${i(n,t)}/${i(r,t)}/${i(a,t)}`}},5770:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},6351:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.DcsHandler=t.DcsParser=void 0;let r=n(482),i=n(8742),a=n(5770),o=[];t.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=o,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=o,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||o,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t);else this._handlerFb(this._ident,`HOOK`,t)}put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._ident,`PUT`,(0,r.utf32ToString)(e,t,n))}unhook(e,t=!0){if(this._active.length){let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===n){for(;r>=0&&(n=this._active[r].unhook(e),!0!==n);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,`UNHOOK`,e);this._active=o,this._ident=0}};let s=new i.Params;s.addParam(0),t.DcsHandler=class{constructor(e){this._handler=e,this._data=``,this._params=s,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():s,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=(0,r.utf32ToString)(e,t,n),this._data.length>a.PAYLOAD_LIMIT&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then((e=>(this._params=s,this._data=``,this._hitLimit=!1,e)));return this._params=s,this._data=``,this._hitLimit=!1,t}}},2015:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;let r=n(844),i=n(8742),a=n(6242),o=n(6351);class s{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}}t.TransitionTable=s,t.VT500_TRANSITION_TABLE=function(){let e=new s(4095),t=Array.apply(null,Array(256)).map(((e,t)=>t)),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}();class c extends r.Disposable{constructor(e=t.VT500_TRANSITION_TABLE){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new i.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,r.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new a.OscParser),this._dcsParser=this.register(new o.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},(()=>!0))}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r,i=0,a=0,o=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,a=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](this._params),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 4:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],r=this._dcsParser.unhook(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],r=this._oscParser.end(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let n=o;n<t;++n){switch(i=e[n],a=this._transitions.table[this.currentState<<8|(i<160?i:160)],a>>4){case 2:for(let r=n+1;;++r){if(r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|i],s=o?o.length-1:-1;for(;s>=0&&(r=o[s](this._params),!0!==r);s--)if(r instanceof Promise)return this._preserveStack(3,o,s,a,n),r;s<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingCodepoint=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++n<t&&(i=e[n])>47&&i<60);n--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(r=c[l](),!0!==r);l--)if(r instanceof Promise)return this._preserveStack(4,c,l,a,n),r;l<0&&this._escHandlerFb(this._collect<<8|i),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let r=n+1;;++r)if(r>=t||(i=e[r])===24||i===26||i===27||i>127&&i<160){this._dcsParser.put(e,n,r),n=r-1;break}break;case 14:if(r=this._dcsParser.unhook(i!==24&&i!==26),r)return this._preserveStack(6,[],0,a,n),r;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let r=n+1;;r++)if(r>=t||(i=e[r])<32||i>127&&i<160){this._oscParser.put(e,n,r),n=r-1;break}break;case 6:if(r=this._oscParser.end(i!==24&&i!==26),r)return this._preserveStack(5,[],0,a,n),r;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&a}}}t.EscapeSequenceParser=c},6242:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.OscHandler=t.OscParser=void 0;let r=n(5770),i=n(482),a=[];t.OscParser=class{constructor(){this._state=0,this._active=a,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=a,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,`START`)}_put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._id,`PUT`,(0,i.utf32ToString)(e,t,n))}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===n){for(;r>=0&&(n=this._active[r].end(e),!0!==n);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._id,`END`,e);this._active=a,this._id=-1,this._state=0}}},t.OscHandler=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=(0,i.utf32ToString)(e,t,n),this._data.length>r.PAYLOAD_LIMIT&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then((e=>(this._data=``,this._hitLimit=!1,e)));return this._data=``,this._hitLimit=!1,t}}},8742:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Params=void 0;let n=2147483647;class r{static fromArray(e){let t=new r;if(!e.length)return t;for(let n=+!!Array.isArray(e[0]);n<e.length;++n){let r=e[n];if(Array.isArray(r))for(let e=0;e<r.length;++e)t.addSubParam(r[e]);else t.addParam(r)}return t}constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>256)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let e=new r(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=255&this._subParamsIdx[t];r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>n?n:e}}addSubParam(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>n?n:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=255&this._subParamsIdx[e];return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=255&this._subParamsIdx[t];r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[t-1];r[t-1]=~i?Math.min(10*i+e,n):e}}t.Params=r},5741:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.AddonManager=void 0,t.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}}},8771:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferApiView=void 0;let r=n(3785),i=n(511);t.BufferApiView=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new r.BufferLineApiView(t)}getNullCell(){return new i.CellData}}},3785:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferLineApiView=void 0;let r=n(511);t.BufferLineApiView=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new r.CellData)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}}},8285:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferNamespaceApi=void 0;let r=n(8771),i=n(8460),a=n(844);class o extends a.Disposable{constructor(e){super(),this._core=e,this._onBufferChange=this.register(new i.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new r.BufferApiView(this._core.buffers.normal,`normal`),this._alternate=new r.BufferApiView(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}t.BufferNamespaceApi=o},7975:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ParserApi=void 0,t.ParserApi=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,(e=>t(e.toArray())))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,((e,n)=>t(e,n.toArray())))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}}},7090:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeApi=void 0,t.UnicodeApi=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}}},744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;let a=n(8460),o=n(844),s=n(5295),c=n(2585);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;let l=t.BufferService=class extends o.Disposable{get buffer(){return this.buffers.active}constructor(e){super(),this.isUserScrolling=!1,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,t.MINIMUM_COLS),this.rows=Math.max(e.rawOptions.rows||0,t.MINIMUM_ROWS),this.buffers=this.register(new s.BufferSet(e,this))}resize(e,t){this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t,n){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let i=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),i!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};t.BufferService=l=r([i(0,c.IOptionsService)],l)},7994:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CharsetService=void 0,t.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}}},1753:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CoreMouseService=void 0;let a=n(2585),o=n(8460),s=n(844),c={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button!==4&&e.action===1&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function l(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=3&e.button,4&e.button&&(n|=64),8&e.button&&(n|=128),e.action===32?n|=32:e.action!==0||t||(n|=3)),n}let u=String.fromCharCode,d={DEFAULT:e=>{let t=[l(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`${u(t[0])}${u(t[1])}${u(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.x};${e.y}${t}`}},f=t.CoreMouseService=class extends s.Disposable{constructor(e,t){super(),this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._onProtocolChange=this.register(new o.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(c))this.addProtocol(e,c[e]);for(let e of Object.keys(d))this.addEncoding(e,d[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};t.CoreMouseService=f=r([i(0,a.IBufferService),i(1,a.ICoreService)],f)},6975:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CoreService=void 0;let a=n(1439),o=n(8460),s=n(844),c=n(2585),l=Object.freeze({insertMode:!1}),u=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),d=t.CoreService=class extends s.Disposable{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new o.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new o.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}reset(){this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onBinary.fire(e))}};t.CoreService=d=r([i(0,c.IBufferService),i(1,c.ILogService),i(2,c.IOptionsService)],d)},9074:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.DecorationService=void 0;let r=n(8055),i=n(8460),a=n(844),o=n(6106),s=0,c=0;class l extends a.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new o.SortedList((e=>e?.marker.line)),this._onDecorationRegistered=this.register(new i.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new i.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,a.toDisposable)((()=>this.reset())))}registerDecoration(e){if(e.marker.isDisposed)return;let t=new u(e);if(t){let e=t.marker.onDispose((()=>t.dispose()));t.onDispose((()=>{t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())})),this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,(t=>{s=t.options.x??0,c=s+(t.options.width??1),e>=s&&e<c&&(!n||(t.options.layer??`bottom`)===n)&&r(t)}))}}t.DecorationService=l;class u extends a.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=r.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=r.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(e){super(),this.options=e,this.onRenderEmitter=this.register(new i.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new i.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;let r=n(2585),i=n(8343);class a{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}}t.ServiceCollection=a,t.InstantiationService=class{constructor(){this._services=new a,this._services.set(r.IInstantiationService,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=(0,i.getServiceDependencies)(e).sort(((e,t)=>e.index-t.index)),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id}.`);r.push(n)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}}},7866:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.traceCall=t.setTraceLogger=t.LogService=void 0;let a=n(844),o=n(2585),s={trace:o.LogLevelEnum.TRACE,debug:o.LogLevelEnum.DEBUG,info:o.LogLevelEnum.INFO,warn:o.LogLevelEnum.WARN,error:o.LogLevelEnum.ERROR,off:o.LogLevelEnum.OFF},c,l=t.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(e){super(),this._optionsService=e,this._logLevel=o.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange(`logLevel`,(()=>this._updateLogLevel()))),c=this}_updateLogLevel(){this._logLevel=s[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:`xterm.js: `)+t,...n)}trace(e,...t){this._logLevel<=o.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=o.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=o.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=o.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=o.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};t.LogService=l=r([i(0,o.IOptionsService)],l),t.setTraceLogger=function(e){c=e},t.traceCall=function(e,t,n){if(typeof n.value!=`function`)throw Error(`not supported`);let r=n.value;n.value=function(...e){if(c.logLevel!==o.LogLevelEnum.TRACE)return r.apply(this,e);c.trace(`GlyphRenderer#${r.name}(${e.map((e=>JSON.stringify(e))).join(`, `)})`);let t=r.apply(this,e);return c.trace(`GlyphRenderer#${r.name} return`,t),t}}},7302:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=void 0;let r=n(8460),i=n(844);t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`courier-new, courier, monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:n(6114).isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRulerWidth:0};let a=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`];class o extends i.Disposable{constructor(e){super(),this._onOptionChange=this.register(new r.EventEmitter),this.onOptionChange=this._onOptionChange.event;let n=Object.assign({},t.DEFAULT_OPTIONS);for(let t in e)if(t in n)try{let r=e[t];n[t]=this._sanitizeAndValidateOption(t,r)}catch(e){console.error(e)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(e,t){return this.onOptionChange((n=>{n===e&&t(this.rawOptions[e])}))}onMultipleOptionChange(e,t){return this.onOptionChange((n=>{e.indexOf(n)!==-1&&t()}))}_setupOptions(){let e=e=>{if(!(e in t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},n=(e,n)=>{if(!(e in t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);n=this._sanitizeAndValidateOption(e,n),this.rawOptions[e]!==n&&(this.rawOptions[e]=n,this._onOptionChange.fire(e))};for(let t in this.rawOptions){let r={get:e.bind(this,t),set:n.bind(this,t)};Object.defineProperty(this.options,t,r)}}_sanitizeAndValidateOption(e,n){switch(e){case`cursorStyle`:if(n||=t.DEFAULT_OPTIONS[e],!function(e){return e===`block`||e===`underline`||e===`bar`}(n))throw Error(`"${n}" is not a valid value for ${e}`);break;case`wordSeparator`:n||=t.DEFAULT_OPTIONS[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof n==`number`&&1<=n&&n<=1e3)break;n=a.includes(n)?n:t.DEFAULT_OPTIONS[e];break;case`cursorWidth`:n=Math.floor(n);case`lineHeight`:case`tabStopWidth`:if(n<1)throw Error(`${e} cannot be less than 1, value: ${n}`);break;case`minimumContrastRatio`:n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case`scrollback`:if((n=Math.min(n,4294967295))<0)throw Error(`${e} cannot be less than 0, value: ${n}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(n<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case`rows`:case`cols`:if(!n&&n!==0)throw Error(`${e} must be numeric, value: ${n}`);break;case`windowsPty`:n??={}}return n}}t.OptionsService=o},2660:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.OscLinkService=void 0;let a=n(2585),o=t.OscLinkService=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose((()=>this._removeMarkerFromLink(r,n))),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose((()=>this._removeMarkerFromLink(o,a))),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every((e=>e.line!==t))){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose((()=>this._removeMarkerFromLink(n,e)))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};t.OscLinkService=o=r([i(0,a.IBufferService)],o)},8343:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0;let n=`di$target`,r=`di$dependencies`;t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[r]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);let i=function(e,t,a){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);(function(e,t,i){t[n]===t?t[r].push({id:e,index:i}):(t[r]=[{id:e,index:i}],t[n]=t)})(i,e,a)};return i.toString=()=>e,t.serviceRegistry.set(e,i),i}},2585:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;let r=n(8343);var i;t.IBufferService=(0,r.createDecorator)(`BufferService`),t.ICoreMouseService=(0,r.createDecorator)(`CoreMouseService`),t.ICoreService=(0,r.createDecorator)(`CoreService`),t.ICharsetService=(0,r.createDecorator)(`CharsetService`),t.IInstantiationService=(0,r.createDecorator)(`InstantiationService`),function(e){e[e.TRACE=0]=`TRACE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARN=3]=`WARN`,e[e.ERROR=4]=`ERROR`,e[e.OFF=5]=`OFF`}(i||(t.LogLevelEnum=i={})),t.ILogService=(0,r.createDecorator)(`LogService`),t.IOptionsService=(0,r.createDecorator)(`OptionsService`),t.IOscLinkService=(0,r.createDecorator)(`OscLinkService`),t.IUnicodeService=(0,r.createDecorator)(`UnicodeService`),t.IDecorationService=(0,r.createDecorator)(`DecorationService`)},1480:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.UnicodeService=void 0;let r=n(8460),i=n(225);t.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new r.EventEmitter,this.onChange=this._onChange.event;let e=new i.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,n=e.length;for(let r=0;r<n;++r){let i=e.charCodeAt(r);if(55296<=i&&i<=56319){if(++r>=n)return t+this.wcwidth(i);let a=e.charCodeAt(r);56320<=a&&a<=57343?i=1024*(i-55296)+a-56320+65536:t+=this.wcwidth(a)}t+=this.wcwidth(i)}return t}}}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.Terminal=void 0;let t=n(9042),i=n(3236),a=n(844),o=n(5741),s=n(8285),c=n(7975),l=n(7090),u=[`cols`,`rows`];class d extends a.Disposable{constructor(e){super(),this._core=this.register(new i.Terminal(e)),this._addonManager=this.register(new o.AddonManager),this._publicOptions=Object.assign({},this._core.options);let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(u.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new c.ParserApi(this._core),this._parser}get unicode(){return this._checkProposedApi(),new l.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this.register(new s.BufferNamespaceApi(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
749
749
  `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return t}_verifyIntegers(...e){for(let t of e)if(t===1/0||isNaN(t)||t%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(let t of e)if(t&&(t===1/0||isNaN(t)||t%1!=0||t<0))throw Error(`This API only accepts positive integers`)}}e.Terminal=d})(),r})()))}))(),KT=2,qT=1,JT=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(KT,Math.floor(u/e.css.cell.width)),rows:Math.max(qT,Math.floor(l/e.css.cell.height))}}};function YT({wsUrl:e,projectDir:t,logs:n,className:r}){let i=(0,_.useRef)(null),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!i.current)return;let e=new GT.Terminal({theme:{background:`#0d1117`,foreground:`#e6edf3`,cursor:`#6366f1`,selectionBackground:`rgba(99, 102, 241, 0.3)`,black:`#0d1117`,red:`#f87171`,green:`#4ade80`,yellow:`#facc15`,blue:`#60a5fa`,magenta:`#c084fc`,cyan:`#22d3ee`,white:`#e6edf3`,brightBlack:`#484f58`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde68a`,brightBlue:`#93c5fd`,brightMagenta:`#d8b4fe`,brightCyan:`#67e8f9`,brightWhite:`#ffffff`},fontSize:12,fontFamily:`'SF Mono', Monaco, 'Cascadia Code', monospace`,cursorBlink:!0,cursorStyle:`bar`,scrollback:5e3,convertEol:!0}),t=new JT;e.loadAddon(t),e.open(i.current),t.fit(),a.current=e,o.current=t;let n=new ResizeObserver(()=>{try{t.fit()}catch{}});return n.observe(i.current),()=>{n.disconnect(),e.dispose(),a.current=null,o.current=null}},[]),(0,_.useEffect)(()=>{if(!a.current)return;let n=a.current,r=window.location.protocol===`https:`?`wss:`:`ws:`,i=e||`${r}//${window.location.host}/ws/terminal${t?`?cwd=${encodeURIComponent(t)}`:``}`,o=new WebSocket(i);return s.current=o,o.binaryType=`arraybuffer`,o.onmessage=e=>{e.data instanceof ArrayBuffer?n.write(new Uint8Array(e.data)):n.write(e.data)},o.onclose=()=>{n.write(`\r
750
750
  \x1B[90m[disconnected]\x1B[0m\r
751
- `)},n.onData(e=>{o.readyState===WebSocket.OPEN&&o.send(e)}),()=>{o.close(),s.current=null}},[e,t]),(0,_.useEffect)(()=>{if(!n||!a.current)return;let e=a.current;for(let t of n)e.writeln(t)},[n]),(0,k.jsx)(`div`,{ref:i,className:r,style:{flex:1,minHeight:0,overflow:`hidden`,background:`#0d1117`}})}function XT({tabs:e,active:t,onChange:n,className:r,buttonClassName:i,activeClassName:a}){return(0,k.jsx)(`nav`,{className:r,role:`tablist`,"aria-label":`Mobile navigation`,children:e.map(e=>{let r=e.id===t;return(0,k.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r,className:`${i??``} ${r?a??``:``}`,onClick:()=>n(e.id),children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,children:e.icon}),(0,k.jsx)(`span`,{children:e.label})]},e.id)})})}var Q={root:`_root_1wqny_2`,header:`_header_1wqny_10`,title:`_title_1wqny_21`,subtitle:`_subtitle_1wqny_28`,headerTabs:`_headerTabs_1wqny_34`,tabBtn:`_tabBtn_1wqny_40`,tabActive:`_tabActive_1wqny_51`,body:`_body_1wqny_58`,editor:`_editor_1wqny_67`,examples:`_examples_1wqny_75`,sectionLabel:`_sectionLabel_1wqny_81`,examplePills:`_examplePills_1wqny_89`,examplePill:`_examplePill_1wqny_89`,editorCols:`_editorCols_1wqny_109`,leftSidebar:`_leftSidebar_1wqny_119`,panel:`_panel_1wqny_128`,panelHeader:`_panelHeader_1wqny_135`,panelTitle:`_panelTitle_1wqny_142`,addBtn:`_addBtn_1wqny_149`,blockLabel:`_blockLabel_1wqny_160`,blockCheck:`_blockCheck_1wqny_170`,authField:`_authField_1wqny_173`,authFieldInput:`_authFieldInput_1wqny_183`,authFieldSelect:`_authFieldSelect_1wqny_193`,authFieldReq:`_authFieldReq_1wqny_204`,removeFieldBtn:`_removeFieldBtn_1wqny_205`,skillsList:`_skillsList_1wqny_208`,skillRow:`_skillRow_1wqny_210`,skillIcon:`_skillIcon_1wqny_218`,skillName:`_skillName_1wqny_220`,skillBadge:`_skillBadge_1wqny_229`,skillBadge_skill:`_skillBadge_skill_1wqny_237`,skillBadge_memory:`_skillBadge_memory_1wqny_238`,skillBadge_provider:`_skillBadge_provider_1wqny_239`,skillBadge_log:`_skillBadge_log_1wqny_240`,skillEmpty:`_skillEmpty_1wqny_242`,skillBtn:`_skillBtn_1wqny_244`,skillsEmpty:`_skillsEmpty_1wqny_246`,snapshotRow:`_snapshotRow_1wqny_249`,snapshotTs:`_snapshotTs_1wqny_258`,snapshotCount:`_snapshotCount_1wqny_259`,snapshotBtn:`_snapshotBtn_1wqny_260`,genStatus:`_genStatus_1wqny_263`,repairStatus:`_repairStatus_1wqny_265`,repairStatusTitle:`_repairStatusTitle_1wqny_266`,repairStatusProg:`_repairStatusProg_1wqny_267`,repairStatusFile:`_repairStatusFile_1wqny_268`,actionRow:`_actionRow_1wqny_271`,actionBtn:`_actionBtn_1wqny_273`,actionBtnIcon:`_actionBtnIcon_1wqny_275`,actionBtnActive:`_actionBtnActive_1wqny_276`,repairBtn:`_repairBtn_1wqny_278`,sandboxBtn:`_sandboxBtn_1wqny_280`,statsBar:`_statsBar_1wqny_282`,rightPanel:`_rightPanel_1wqny_285`,rightTabBar:`_rightTabBar_1wqny_296`,rightTab:`_rightTab_1wqny_296`,rightTabActive:`_rightTabActive_1wqny_313`,repairBar:`_repairBar_1wqny_316`,repairBarRow:`_repairBarRow_1wqny_326`,repairBarIcon:`_repairBarIcon_1wqny_327`,repairBarLabel:`_repairBarLabel_1wqny_328`,repairBarFile:`_repairBarFile_1wqny_329`,repairBarCounter:`_repairBarCounter_1wqny_330`,repairBarTime:`_repairBarTime_1wqny_331`,genBar:`_genBar_1wqny_333`,genBarRow:`_genBarRow_1wqny_343`,genBarRobot:`_genBarRobot_1wqny_344`,robotBob:`_robotBob_1wqny_1`,genBarLabel:`_genBarLabel_1wqny_345`,genBarFile:`_genBarFile_1wqny_346`,genBarCounter:`_genBarCounter_1wqny_347`,genBarTime:`_genBarTime_1wqny_348`,progressTrack:`_progressTrack_1wqny_350`,repairProgress:`_repairProgress_1wqny_351`,genProgress:`_genProgress_1wqny_352`,genDots:`_genDots_1wqny_355`,dot:`_dot_1wqny_356`,dot1:`_dot1_1wqny_357`,dotBounce:`_dotBounce_1wqny_1`,dot2:`_dot2_1wqny_358`,dot3:`_dot3_1wqny_359`,stopBtn:`_stopBtn_1wqny_362`,codeArea:`_codeArea_1wqny_365`,sandboxWrap:`_sandboxWrap_1wqny_366`,sandboxFrame:`_sandboxFrame_1wqny_367`,sandboxEmpty:`_sandboxEmpty_1wqny_368`,sandboxStartBtn:`_sandboxStartBtn_1wqny_369`,sandboxStatusBar:`_sandboxStatusBar_1wqny_372`,sandboxStatusDot:`_sandboxStatusDot_1wqny_381`,sandboxStatusText:`_sandboxStatusText_1wqny_382`,sandboxStartBtnSmall:`_sandboxStartBtnSmall_1wqny_383`,runtimeErrors:`_runtimeErrors_1wqny_386`,runtimeErrorsHeader:`_runtimeErrorsHeader_1wqny_392`,runtimeErrorsFix:`_runtimeErrorsFix_1wqny_401`,runtimeErrorsDismiss:`_runtimeErrorsDismiss_1wqny_413`,runtimeErrorLine:`_runtimeErrorLine_1wqny_414`,sandboxConsole:`_sandboxConsole_1wqny_425`,sandboxConsoleCollapsed:`_sandboxConsoleCollapsed_1wqny_434`,sandboxConsoleHeader:`_sandboxConsoleHeader_1wqny_435`,sandboxConsoleTitle:`_sandboxConsoleTitle_1wqny_447`,sandboxConsolePort:`_sandboxConsolePort_1wqny_448`,sandboxConsoleDots:`_sandboxConsoleDots_1wqny_449`,sandboxConsoleToggle:`_sandboxConsoleToggle_1wqny_450`,sandboxReloadBtn:`_sandboxReloadBtn_1wqny_451`,sandboxStopBtn:`_sandboxStopBtn_1wqny_453`,sandboxConsoleBody:`_sandboxConsoleBody_1wqny_455`,sandboxLogLine:`_sandboxLogLine_1wqny_461`,sandboxLogPhase:`_sandboxLogPhase_1wqny_470`,sandboxLogError:`_sandboxLogError_1wqny_471`,sandboxLogWarn:`_sandboxLogWarn_1wqny_472`,sandboxLogOk:`_sandboxLogOk_1wqny_473`,codeLayout:`_codeLayout_1wqny_476`,codeRow:`_codeRow_1wqny_485`,ideTabBar:`_ideTabBar_1wqny_493`,ideTab:`_ideTab_1wqny_493`,ideTabActive:`_ideTabActive_1wqny_525`,ideTabError:`_ideTabError_1wqny_530`,ideTabPending:`_ideTabPending_1wqny_531`,ideTabIcon:`_ideTabIcon_1wqny_532`,ideTabName:`_ideTabName_1wqny_533`,ideTabDot:`_ideTabDot_1wqny_534`,ideTabUnsaved:`_ideTabUnsaved_1wqny_540`,codeEditorWrap:`_codeEditorWrap_1wqny_548`,editToggleBtn:`_editToggleBtn_1wqny_559`,editToggleBtnActive:`_editToggleBtnActive_1wqny_570`,codeEditor:`_codeEditor_1wqny_548`,genCursor:`_genCursor_1wqny_592`,cursorBlink:`_cursorBlink_1wqny_1`,diffOverlay:`_diffOverlay_1wqny_601`,diffOverlayHeader:`_diffOverlayHeader_1wqny_610`,diffOverlayActions:`_diffOverlayActions_1wqny_621`,diffAcceptBtn:`_diffAcceptBtn_1wqny_622`,diffRejectBtn:`_diffRejectBtn_1wqny_623`,diffOverlayBody:`_diffOverlayBody_1wqny_624`,diffSame:`_diffSame_1wqny_625`,diffRem:`_diffRem_1wqny_626`,diffAdd:`_diffAdd_1wqny_627`,noFiles:`_noFiles_1wqny_629`,noFilesHero:`_noFilesHero_1wqny_639`,noFilesIcon:`_noFilesIcon_1wqny_646`,noFilesTitle:`_noFilesTitle_1wqny_648`,noFilesTagline:`_noFilesTagline_1wqny_655`,noFilesSteps:`_noFilesSteps_1wqny_660`,noFilesStep:`_noFilesStep_1wqny_660`,noFilesStepNum:`_noFilesStepNum_1wqny_677`,noFilesExamplesHint:`_noFilesExamplesHint_1wqny_691`,noFilesExampleBtn:`_noFilesExampleBtn_1wqny_701`,codeViewer:`_codeViewer_1wqny_713`,codeHeader:`_codeHeader_1wqny_721`,codeFileIcon:`_codeFileIcon_1wqny_734`,codeFileName:`_codeFileName_1wqny_735`,codeFileMeta:`_codeFileMeta_1wqny_736`,fileError:`_fileError_1wqny_738`,fileSyntaxError:`_fileSyntaxError_1wqny_739`,filePending:`_filePending_1wqny_740`,codeWithLines:`_codeWithLines_1wqny_743`,lineNumbers:`_lineNumbers_1wqny_750`,lineNum:`_lineNum_1wqny_750`,code:`_code_1wqny_365`,codeError:`_codeError_1wqny_781`,codeSyntaxError:`_codeSyntaxError_1wqny_782`,fileSidebar:`_fileSidebar_1wqny_785`,fileSidebarHeader:`_fileSidebarHeader_1wqny_794`,fileTab:`_fileTab_1wqny_804`,fileTabActive:`_fileTabActive_1wqny_820`,fileTabError:`_fileTabError_1wqny_821`,fileTabRow:`_fileTabRow_1wqny_823`,fileTabIcon:`_fileTabIcon_1wqny_824`,fileTabName:`_fileTabName_1wqny_825`,fileTabSize:`_fileTabSize_1wqny_826`,fileTabDir:`_fileTabDir_1wqny_827`,fileTabTokens:`_fileTabTokens_1wqny_828`,fileTabMeta:`_fileTabMeta_1wqny_829`,projectsList:`_projectsList_1wqny_832`,emptyProjects:`_emptyProjects_1wqny_834`,emptyIcon:`_emptyIcon_1wqny_835`,emptyHint:`_emptyHint_1wqny_836`,projectCard:`_projectCard_1wqny_838`,projectInfo:`_projectInfo_1wqny_839`,projectName:`_projectName_1wqny_840`,projectDesc:`_projectDesc_1wqny_841`,projectMeta:`_projectMeta_1wqny_842`,openBtn:`_openBtn_1wqny_843`,deleteBtn:`_deleteBtn_1wqny_844`,planBanner:`_planBanner_1wqny_847`,planTitle:`_planTitle_1wqny_856`,planText:`_planText_1wqny_857`,planActions:`_planActions_1wqny_858`,planApprove:`_planApprove_1wqny_859`,planReject:`_planReject_1wqny_860`,grepPanel:`_grepPanel_1wqny_863`,grepRow:`_grepRow_1wqny_872`,grepInput:`_grepInput_1wqny_873`,grepBtn:`_grepBtn_1wqny_875`,grepClose:`_grepClose_1wqny_876`,grepCount:`_grepCount_1wqny_877`,grepResults:`_grepResults_1wqny_878`,grepEmpty:`_grepEmpty_1wqny_879`,grepMatch:`_grepMatch_1wqny_880`,grepMatchFile:`_grepMatchFile_1wqny_882`,grepMatchLine:`_grepMatchLine_1wqny_883`,diffPanel:`_diffPanel_1wqny_886`,diffHeader:`_diffHeader_1wqny_895`,diffClose:`_diffClose_1wqny_896`,diffFile:`_diffFile_1wqny_897`,diffSummary:`_diffSummary_1wqny_898`,diffArrow:`_diffArrow_1wqny_899`,diffFileName:`_diffFileName_1wqny_900`,diffAdded:`_diffAdded_1wqny_901`,diffRemoved:`_diffRemoved_1wqny_902`,diffContent:`_diffContent_1wqny_903`,diffInline:`_diffInline_1wqny_906`,diffInlineHeader:`_diffInlineHeader_1wqny_907`,diffRemLine:`_diffRemLine_1wqny_908`,diffAddLine:`_diffAddLine_1wqny_909`,chatPanel:`_chatPanel_1wqny_912`,chatPanelCollapsed:`_chatPanelCollapsed_1wqny_921`,chatCollapseBtn:`_chatCollapseBtn_1wqny_922`,chatMessages:`_chatMessages_1wqny_930`,chatWelcome:`_chatWelcome_1wqny_932`,doctrineOpenBtn:`_doctrineOpenBtn_1wqny_933`,streamingPre:`_streamingPre_1wqny_936`,streamingCursor:`_streamingCursor_1wqny_949`,streamBlink:`_streamBlink_1wqny_1`,doctrineSubtitle:`_doctrineSubtitle_1wqny_956`,doctrineSection:`_doctrineSection_1wqny_957`,doctrineSectionTitle:`_doctrineSectionTitle_1wqny_962`,doctrineSectionBody:`_doctrineSectionBody_1wqny_969`,doctrineBullet:`_doctrineBullet_1wqny_978`,chatUser:`_chatUser_1wqny_988`,chatUserBubble:`_chatUserBubble_1wqny_989`,chatAttachPreviews:`_chatAttachPreviews_1wqny_990`,chatAttachBadge:`_chatAttachBadge_1wqny_991`,chatSystem:`_chatSystem_1wqny_993`,chatSystemBubble:`_chatSystemBubble_1wqny_994`,chatSyntaxErr:`_chatSyntaxErr_1wqny_995`,chatAgent:`_chatAgent_1wqny_997`,chatAgentCard:`_chatAgentCard_1wqny_998`,chatAgentHeader:`_chatAgentHeader_1wqny_999`,chatAgentRobot:`_chatAgentRobot_1wqny_1000`,chatAgentRobotAnim:`_chatAgentRobotAnim_1wqny_1001`,chatAgentLabel:`_chatAgentLabel_1wqny_1002`,chatRunningDots:`_chatRunningDots_1wqny_1003`,chatAgentText:`_chatAgentText_1wqny_1004`,chatToolBadges:`_chatToolBadges_1wqny_1005`,toolBadge:`_toolBadge_1wqny_1006`,toolBadgeOk:`_toolBadgeOk_1wqny_1007`,toolBadgeErr:`_toolBadgeErr_1wqny_1008`,cursor:`_cursor_1wqny_1010`,blink:`_blink_1wqny_1`,attachPreviews:`_attachPreviews_1wqny_1013`,attachBadge:`_attachBadge_1wqny_1014`,removeAttachBtn:`_removeAttachBtn_1wqny_1015`,projNameRow:`_projNameRow_1wqny_1018`,projNameLabel:`_projNameLabel_1wqny_1019`,projNameInput:`_projNameInput_1wqny_1020`,projActiveRow:`_projActiveRow_1wqny_1021`,projActiveName:`_projActiveName_1wqny_1022`,chatInputRow:`_chatInputRow_1wqny_1025`,attachLabel:`_attachLabel_1wqny_1026`,chatTextarea:`_chatTextarea_1wqny_1027`,chatSendCol:`_chatSendCol_1wqny_1030`,chatSendBtn:`_chatSendBtn_1wqny_1031`,chatStopBtn:`_chatStopBtn_1wqny_1033`,modalOverlay:`_modalOverlay_1wqny_1036`,modal:`_modal_1wqny_1036`,modalHeader:`_modalHeader_1wqny_1058`,modalTitle:`_modalTitle_1wqny_1059`,modalClose:`_modalClose_1wqny_1060`,modalBody:`_modalBody_1wqny_1062`,modalRow:`_modalRow_1wqny_1064`,modalField:`_modalField_1wqny_1065`,modalLabel:`_modalLabel_1wqny_1066`,modalLabelRow:`_modalLabelRow_1wqny_1067`,modalSelect:`_modalSelect_1wqny_1069`,modalInput:`_modalInput_1wqny_1070`,modalHint:`_modalHint_1wqny_1073`,modalAiBox:`_modalAiBox_1wqny_1075`,modalAiRow:`_modalAiRow_1wqny_1076`,modalAiDesc:`_modalAiDesc_1wqny_1077`,modalAiBtn:`_modalAiBtn_1wqny_1078`,modalContentArea:`_modalContentArea_1wqny_1081`,logView:`_logView_1wqny_1084`,modalFooter:`_modalFooter_1wqny_1086`,modalCancelBtn:`_modalCancelBtn_1wqny_1087`,modalSaveBtn:`_modalSaveBtn_1wqny_1088`,fileTreeWrap:`_fileTreeWrap_1wqny_1091`,headerIconBtn:`_headerIconBtn_1wqny_1101`,headerIconBtnActive:`_headerIconBtnActive_1wqny_1112`,terminalPanel:`_terminalPanel_1wqny_1115`,terminalHeader:`_terminalHeader_1wqny_1123`,terminalTitle:`_terminalTitle_1wqny_1132`,terminalClose:`_terminalClose_1wqny_1133`,scanBanner:`_scanBanner_1wqny_1136`,scanBannerIcon:`_scanBannerIcon_1wqny_1145`,scanBannerText:`_scanBannerText_1wqny_1146`,scanBannerFix:`_scanBannerFix_1wqny_1147`,findBar:`_findBar_1wqny_1150`,findInput:`_findInput_1wqny_1159`,findCount:`_findCount_1wqny_1170`,findBtn:`_findBtn_1wqny_1171`,findClose:`_findClose_1wqny_1173`,mobileTabBar:`_mobileTabBar_1wqny_1253`,mobileTabBtn:`_mobileTabBtn_1wqny_1263`,mobileTabBtnActive:`_mobileTabBtnActive_1wqny_1276`,mobileTabBtnIcon:`_mobileTabBtnIcon_1wqny_1279`},ZT=[{id:`editor`,label:`Editor`,icon:`💻`},{id:`preview`,label:`Preview`,icon:`📱`},{id:`skills`,label:`Skills`,icon:`🛠`}];function QT(e,t){if(!e)return``;let n=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`);return e.split(`
751
+ `)},n.onData(e=>{o.readyState===WebSocket.OPEN&&o.send(e)}),()=>{o.close(),s.current=null}},[e,t]),(0,_.useEffect)(()=>{if(!n||!a.current)return;let e=a.current;for(let t of n)e.writeln(t)},[n]),(0,k.jsx)(`div`,{ref:i,className:r,style:{flex:1,minHeight:0,overflow:`hidden`,background:`#0d1117`}})}function XT({tabs:e,active:t,onChange:n,className:r,buttonClassName:i,activeClassName:a}){return(0,k.jsx)(`nav`,{className:r,role:`tablist`,"aria-label":`Mobile navigation`,children:e.map(e=>{let r=e.id===t;return(0,k.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r,className:`${i??``} ${r?a??``:``}`,onClick:()=>n(e.id),children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,children:e.icon}),(0,k.jsx)(`span`,{children:e.label})]},e.id)})})}var Q={root:`_root_ex7bl_2`,header:`_header_ex7bl_10`,title:`_title_ex7bl_21`,subtitle:`_subtitle_ex7bl_28`,headerTabs:`_headerTabs_ex7bl_34`,tabBtn:`_tabBtn_ex7bl_40`,tabActive:`_tabActive_ex7bl_51`,body:`_body_ex7bl_58`,editor:`_editor_ex7bl_67`,examples:`_examples_ex7bl_75`,sectionLabel:`_sectionLabel_ex7bl_81`,examplePills:`_examplePills_ex7bl_89`,examplePill:`_examplePill_ex7bl_89`,editorCols:`_editorCols_ex7bl_109`,leftSidebar:`_leftSidebar_ex7bl_119`,panel:`_panel_ex7bl_128`,panelHeader:`_panelHeader_ex7bl_135`,panelTitle:`_panelTitle_ex7bl_142`,addBtn:`_addBtn_ex7bl_149`,blockLabel:`_blockLabel_ex7bl_160`,blockCheck:`_blockCheck_ex7bl_170`,authField:`_authField_ex7bl_173`,authFieldInput:`_authFieldInput_ex7bl_183`,authFieldSelect:`_authFieldSelect_ex7bl_193`,authFieldReq:`_authFieldReq_ex7bl_204`,removeFieldBtn:`_removeFieldBtn_ex7bl_205`,skillsList:`_skillsList_ex7bl_208`,skillRow:`_skillRow_ex7bl_210`,skillIcon:`_skillIcon_ex7bl_218`,skillName:`_skillName_ex7bl_220`,skillBadge:`_skillBadge_ex7bl_229`,skillBadge_skill:`_skillBadge_skill_ex7bl_237`,skillBadge_memory:`_skillBadge_memory_ex7bl_238`,skillBadge_provider:`_skillBadge_provider_ex7bl_239`,skillBadge_log:`_skillBadge_log_ex7bl_240`,skillEmpty:`_skillEmpty_ex7bl_242`,skillBtn:`_skillBtn_ex7bl_244`,skillsEmpty:`_skillsEmpty_ex7bl_246`,snapshotRow:`_snapshotRow_ex7bl_249`,snapshotTs:`_snapshotTs_ex7bl_258`,snapshotCount:`_snapshotCount_ex7bl_259`,snapshotBtn:`_snapshotBtn_ex7bl_260`,genStatus:`_genStatus_ex7bl_263`,repairStatus:`_repairStatus_ex7bl_265`,repairStatusTitle:`_repairStatusTitle_ex7bl_266`,repairStatusProg:`_repairStatusProg_ex7bl_267`,repairStatusFile:`_repairStatusFile_ex7bl_268`,actionRow:`_actionRow_ex7bl_271`,actionBtn:`_actionBtn_ex7bl_273`,actionBtnIcon:`_actionBtnIcon_ex7bl_275`,actionBtnActive:`_actionBtnActive_ex7bl_276`,repairBtn:`_repairBtn_ex7bl_278`,sandboxBtn:`_sandboxBtn_ex7bl_280`,statsBar:`_statsBar_ex7bl_282`,rightPanel:`_rightPanel_ex7bl_285`,rightTabBar:`_rightTabBar_ex7bl_296`,rightTab:`_rightTab_ex7bl_296`,rightTabActive:`_rightTabActive_ex7bl_313`,repairBar:`_repairBar_ex7bl_316`,repairBarRow:`_repairBarRow_ex7bl_326`,repairBarIcon:`_repairBarIcon_ex7bl_327`,repairBarLabel:`_repairBarLabel_ex7bl_328`,repairBarFile:`_repairBarFile_ex7bl_329`,repairBarCounter:`_repairBarCounter_ex7bl_330`,repairBarTime:`_repairBarTime_ex7bl_331`,genBar:`_genBar_ex7bl_333`,genBarRow:`_genBarRow_ex7bl_343`,genBarRobot:`_genBarRobot_ex7bl_344`,robotBob:`_robotBob_ex7bl_1`,genBarLabel:`_genBarLabel_ex7bl_345`,genBarFile:`_genBarFile_ex7bl_346`,genBarCounter:`_genBarCounter_ex7bl_347`,genBarTime:`_genBarTime_ex7bl_348`,progressTrack:`_progressTrack_ex7bl_350`,repairProgress:`_repairProgress_ex7bl_351`,genProgress:`_genProgress_ex7bl_352`,genDots:`_genDots_ex7bl_355`,dot:`_dot_ex7bl_356`,dot1:`_dot1_ex7bl_357`,dotBounce:`_dotBounce_ex7bl_1`,dot2:`_dot2_ex7bl_358`,dot3:`_dot3_ex7bl_359`,stopBtn:`_stopBtn_ex7bl_362`,codeArea:`_codeArea_ex7bl_365`,sandboxWrap:`_sandboxWrap_ex7bl_366`,sandboxFrame:`_sandboxFrame_ex7bl_367`,sandboxEmpty:`_sandboxEmpty_ex7bl_368`,sandboxStartBtn:`_sandboxStartBtn_ex7bl_369`,sandboxStatusBar:`_sandboxStatusBar_ex7bl_372`,sandboxStatusDot:`_sandboxStatusDot_ex7bl_381`,sandboxStatusText:`_sandboxStatusText_ex7bl_382`,sandboxStartBtnSmall:`_sandboxStartBtnSmall_ex7bl_383`,runtimeErrors:`_runtimeErrors_ex7bl_386`,runtimeErrorsHeader:`_runtimeErrorsHeader_ex7bl_392`,runtimeErrorsFix:`_runtimeErrorsFix_ex7bl_401`,runtimeErrorsDismiss:`_runtimeErrorsDismiss_ex7bl_413`,runtimeErrorLine:`_runtimeErrorLine_ex7bl_414`,sandboxConsole:`_sandboxConsole_ex7bl_425`,sandboxConsoleCollapsed:`_sandboxConsoleCollapsed_ex7bl_434`,sandboxConsoleHeader:`_sandboxConsoleHeader_ex7bl_435`,sandboxConsoleTitle:`_sandboxConsoleTitle_ex7bl_447`,sandboxConsolePort:`_sandboxConsolePort_ex7bl_448`,sandboxConsoleDots:`_sandboxConsoleDots_ex7bl_449`,sandboxConsoleToggle:`_sandboxConsoleToggle_ex7bl_450`,sandboxReloadBtn:`_sandboxReloadBtn_ex7bl_451`,sandboxStopBtn:`_sandboxStopBtn_ex7bl_453`,sandboxConsoleBody:`_sandboxConsoleBody_ex7bl_455`,sandboxLogLine:`_sandboxLogLine_ex7bl_461`,sandboxLogPhase:`_sandboxLogPhase_ex7bl_470`,sandboxLogError:`_sandboxLogError_ex7bl_471`,sandboxLogWarn:`_sandboxLogWarn_ex7bl_472`,sandboxLogOk:`_sandboxLogOk_ex7bl_473`,codeLayout:`_codeLayout_ex7bl_476`,codeRow:`_codeRow_ex7bl_485`,ideTabBar:`_ideTabBar_ex7bl_493`,ideTab:`_ideTab_ex7bl_493`,ideTabActive:`_ideTabActive_ex7bl_525`,ideTabError:`_ideTabError_ex7bl_530`,ideTabPending:`_ideTabPending_ex7bl_531`,ideTabIcon:`_ideTabIcon_ex7bl_532`,ideTabName:`_ideTabName_ex7bl_533`,ideTabDot:`_ideTabDot_ex7bl_534`,ideTabUnsaved:`_ideTabUnsaved_ex7bl_540`,codeEditorWrap:`_codeEditorWrap_ex7bl_548`,editToggleBtn:`_editToggleBtn_ex7bl_559`,editToggleBtnActive:`_editToggleBtnActive_ex7bl_570`,codeEditor:`_codeEditor_ex7bl_548`,genCursor:`_genCursor_ex7bl_592`,cursorBlink:`_cursorBlink_ex7bl_1`,diffOverlay:`_diffOverlay_ex7bl_601`,diffOverlayHeader:`_diffOverlayHeader_ex7bl_610`,diffOverlayActions:`_diffOverlayActions_ex7bl_621`,diffAcceptBtn:`_diffAcceptBtn_ex7bl_622`,diffRejectBtn:`_diffRejectBtn_ex7bl_623`,diffOverlayBody:`_diffOverlayBody_ex7bl_624`,diffSame:`_diffSame_ex7bl_625`,diffRem:`_diffRem_ex7bl_626`,diffAdd:`_diffAdd_ex7bl_627`,noFiles:`_noFiles_ex7bl_629`,noFilesHero:`_noFilesHero_ex7bl_639`,noFilesIcon:`_noFilesIcon_ex7bl_646`,noFilesTitle:`_noFilesTitle_ex7bl_648`,noFilesTagline:`_noFilesTagline_ex7bl_655`,noFilesSteps:`_noFilesSteps_ex7bl_660`,noFilesStep:`_noFilesStep_ex7bl_660`,noFilesStepNum:`_noFilesStepNum_ex7bl_677`,noFilesExamplesHint:`_noFilesExamplesHint_ex7bl_691`,noFilesExampleBtn:`_noFilesExampleBtn_ex7bl_701`,codeViewer:`_codeViewer_ex7bl_713`,codeHeader:`_codeHeader_ex7bl_721`,codeFileIcon:`_codeFileIcon_ex7bl_734`,codeFileName:`_codeFileName_ex7bl_735`,codeFileMeta:`_codeFileMeta_ex7bl_736`,fileError:`_fileError_ex7bl_738`,fileSyntaxError:`_fileSyntaxError_ex7bl_739`,filePending:`_filePending_ex7bl_740`,codeWithLines:`_codeWithLines_ex7bl_743`,lineNumbers:`_lineNumbers_ex7bl_750`,lineNum:`_lineNum_ex7bl_750`,code:`_code_ex7bl_365`,codeError:`_codeError_ex7bl_781`,codeSyntaxError:`_codeSyntaxError_ex7bl_782`,fileSidebar:`_fileSidebar_ex7bl_785`,fileSidebarHeader:`_fileSidebarHeader_ex7bl_794`,fileTab:`_fileTab_ex7bl_804`,fileTabActive:`_fileTabActive_ex7bl_820`,fileTabError:`_fileTabError_ex7bl_821`,fileTabRow:`_fileTabRow_ex7bl_823`,fileTabIcon:`_fileTabIcon_ex7bl_824`,fileTabName:`_fileTabName_ex7bl_825`,fileTabSize:`_fileTabSize_ex7bl_826`,fileTabDir:`_fileTabDir_ex7bl_827`,fileTabTokens:`_fileTabTokens_ex7bl_828`,fileTabMeta:`_fileTabMeta_ex7bl_829`,projectsList:`_projectsList_ex7bl_832`,emptyProjects:`_emptyProjects_ex7bl_834`,emptyIcon:`_emptyIcon_ex7bl_835`,emptyHint:`_emptyHint_ex7bl_836`,projectCard:`_projectCard_ex7bl_838`,projectInfo:`_projectInfo_ex7bl_839`,projectName:`_projectName_ex7bl_840`,projectDesc:`_projectDesc_ex7bl_841`,projectMeta:`_projectMeta_ex7bl_842`,openBtn:`_openBtn_ex7bl_843`,deleteBtn:`_deleteBtn_ex7bl_844`,planBanner:`_planBanner_ex7bl_847`,planTitle:`_planTitle_ex7bl_856`,planText:`_planText_ex7bl_857`,planActions:`_planActions_ex7bl_858`,planApprove:`_planApprove_ex7bl_859`,planReject:`_planReject_ex7bl_860`,grepPanel:`_grepPanel_ex7bl_863`,grepRow:`_grepRow_ex7bl_872`,grepInput:`_grepInput_ex7bl_873`,grepBtn:`_grepBtn_ex7bl_875`,grepClose:`_grepClose_ex7bl_876`,grepCount:`_grepCount_ex7bl_877`,grepResults:`_grepResults_ex7bl_878`,grepEmpty:`_grepEmpty_ex7bl_879`,grepMatch:`_grepMatch_ex7bl_880`,grepMatchFile:`_grepMatchFile_ex7bl_882`,grepMatchLine:`_grepMatchLine_ex7bl_883`,diffPanel:`_diffPanel_ex7bl_886`,diffHeader:`_diffHeader_ex7bl_895`,diffClose:`_diffClose_ex7bl_896`,diffFile:`_diffFile_ex7bl_897`,diffSummary:`_diffSummary_ex7bl_898`,diffArrow:`_diffArrow_ex7bl_899`,diffFileName:`_diffFileName_ex7bl_900`,diffAdded:`_diffAdded_ex7bl_901`,diffRemoved:`_diffRemoved_ex7bl_902`,diffContent:`_diffContent_ex7bl_903`,diffInline:`_diffInline_ex7bl_906`,diffInlineHeader:`_diffInlineHeader_ex7bl_907`,diffRemLine:`_diffRemLine_ex7bl_908`,diffAddLine:`_diffAddLine_ex7bl_909`,chatPanel:`_chatPanel_ex7bl_912`,chatPanelCollapsed:`_chatPanelCollapsed_ex7bl_921`,chatCollapseBtn:`_chatCollapseBtn_ex7bl_922`,chatMessages:`_chatMessages_ex7bl_930`,chatWelcome:`_chatWelcome_ex7bl_932`,doctrineOpenBtn:`_doctrineOpenBtn_ex7bl_933`,streamingPre:`_streamingPre_ex7bl_936`,streamingCursor:`_streamingCursor_ex7bl_949`,streamBlink:`_streamBlink_ex7bl_1`,doctrineSubtitle:`_doctrineSubtitle_ex7bl_956`,doctrineSection:`_doctrineSection_ex7bl_957`,doctrineSectionTitle:`_doctrineSectionTitle_ex7bl_962`,doctrineSectionBody:`_doctrineSectionBody_ex7bl_969`,doctrineBullet:`_doctrineBullet_ex7bl_978`,chatUser:`_chatUser_ex7bl_988`,chatUserBubble:`_chatUserBubble_ex7bl_989`,chatAttachPreviews:`_chatAttachPreviews_ex7bl_990`,chatAttachBadge:`_chatAttachBadge_ex7bl_991`,chatSystem:`_chatSystem_ex7bl_993`,chatSystemBubble:`_chatSystemBubble_ex7bl_994`,chatSyntaxErr:`_chatSyntaxErr_ex7bl_995`,chatAgent:`_chatAgent_ex7bl_997`,chatAgentCard:`_chatAgentCard_ex7bl_998`,chatAgentHeader:`_chatAgentHeader_ex7bl_999`,chatAgentRobot:`_chatAgentRobot_ex7bl_1000`,chatAgentRobotAnim:`_chatAgentRobotAnim_ex7bl_1001`,chatAgentLabel:`_chatAgentLabel_ex7bl_1002`,chatRunningDots:`_chatRunningDots_ex7bl_1003`,chatAgentText:`_chatAgentText_ex7bl_1004`,chatToolBadges:`_chatToolBadges_ex7bl_1005`,toolBadge:`_toolBadge_ex7bl_1006`,toolBadgeOk:`_toolBadgeOk_ex7bl_1007`,toolBadgeErr:`_toolBadgeErr_ex7bl_1008`,cursor:`_cursor_ex7bl_1010`,blink:`_blink_ex7bl_1`,attachPreviews:`_attachPreviews_ex7bl_1013`,attachBadge:`_attachBadge_ex7bl_1014`,removeAttachBtn:`_removeAttachBtn_ex7bl_1015`,projNameRow:`_projNameRow_ex7bl_1018`,projNameLabel:`_projNameLabel_ex7bl_1019`,projNameInput:`_projNameInput_ex7bl_1020`,projActiveRow:`_projActiveRow_ex7bl_1021`,projActiveName:`_projActiveName_ex7bl_1022`,chatInputRow:`_chatInputRow_ex7bl_1025`,attachLabel:`_attachLabel_ex7bl_1026`,chatTextarea:`_chatTextarea_ex7bl_1027`,chatSendCol:`_chatSendCol_ex7bl_1030`,chatSendBtn:`_chatSendBtn_ex7bl_1031`,chatStopBtn:`_chatStopBtn_ex7bl_1033`,modalOverlay:`_modalOverlay_ex7bl_1036`,modal:`_modal_ex7bl_1036`,modalHeader:`_modalHeader_ex7bl_1058`,modalTitle:`_modalTitle_ex7bl_1059`,modalClose:`_modalClose_ex7bl_1060`,modalBody:`_modalBody_ex7bl_1062`,modalRow:`_modalRow_ex7bl_1064`,modalField:`_modalField_ex7bl_1065`,modalLabel:`_modalLabel_ex7bl_1066`,modalLabelRow:`_modalLabelRow_ex7bl_1067`,modalSelect:`_modalSelect_ex7bl_1069`,modalInput:`_modalInput_ex7bl_1070`,modalHint:`_modalHint_ex7bl_1073`,modalAiBox:`_modalAiBox_ex7bl_1075`,modalAiRow:`_modalAiRow_ex7bl_1076`,modalAiDesc:`_modalAiDesc_ex7bl_1077`,modalAiBtn:`_modalAiBtn_ex7bl_1078`,modalContentArea:`_modalContentArea_ex7bl_1081`,logView:`_logView_ex7bl_1084`,modalFooter:`_modalFooter_ex7bl_1086`,modalCancelBtn:`_modalCancelBtn_ex7bl_1087`,modalSaveBtn:`_modalSaveBtn_ex7bl_1088`,fileTreeWrap:`_fileTreeWrap_ex7bl_1091`,headerIconBtn:`_headerIconBtn_ex7bl_1101`,headerIconBtnActive:`_headerIconBtnActive_ex7bl_1112`,terminalPanel:`_terminalPanel_ex7bl_1115`,terminalHeader:`_terminalHeader_ex7bl_1123`,terminalTitle:`_terminalTitle_ex7bl_1132`,terminalClose:`_terminalClose_ex7bl_1133`,scanBanner:`_scanBanner_ex7bl_1136`,scanBannerIcon:`_scanBannerIcon_ex7bl_1145`,scanBannerText:`_scanBannerText_ex7bl_1146`,scanBannerFix:`_scanBannerFix_ex7bl_1147`,scanBannerToggle:`_scanBannerToggle_ex7bl_1148`,problemsPanel:`_problemsPanel_ex7bl_1151`,problemsGroup:`_problemsGroup_ex7bl_1152`,problemsGroupHeader:`_problemsGroupHeader_ex7bl_1153`,problemsGroupCount:`_problemsGroupCount_ex7bl_1160`,problemsItem:`_problemsItem_ex7bl_1161`,problemsIcon:`_problemsIcon_ex7bl_1169`,problemsIconError:`_problemsIconError_ex7bl_1170`,problemsIconWarning:`_problemsIconWarning_ex7bl_1171`,problemsIconInfo:`_problemsIconInfo_ex7bl_1172`,problemsMsg:`_problemsMsg_ex7bl_1173`,problemsLine:`_problemsLine_ex7bl_1174`,findBar:`_findBar_ex7bl_1177`,findInput:`_findInput_ex7bl_1186`,findCount:`_findCount_ex7bl_1197`,findBtn:`_findBtn_ex7bl_1198`,findClose:`_findClose_ex7bl_1200`,mobileTabBar:`_mobileTabBar_ex7bl_1280`,mobileTabBtn:`_mobileTabBtn_ex7bl_1290`,mobileTabBtnActive:`_mobileTabBtnActive_ex7bl_1303`,mobileTabBtnIcon:`_mobileTabBtnIcon_ex7bl_1306`},ZT=[{id:`editor`,label:`Editor`,icon:`💻`},{id:`preview`,label:`Preview`,icon:`📱`},{id:`skills`,label:`Skills`,icon:`🛠`}];function QT(e,t){if(!e)return``;let n=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`);return e.split(`
752
752
  `).map(e=>{let r=n(e);if(t===`css`)r=r.replace(/([a-z-]+)\s*(?=:)/g,`<span style="color:#82aaff">$1</span>`),r=r.replace(/(\/\*[\s\S]*?\*\/)/g,`<span style="color:#546e7a;font-style:italic">$1</span>`);else if(t===`html`||t===`htm`)r=r.replace(/(&lt;\/?)([\w-]+)/g,`$1<span style="color:#f07178">$2</span>`),r=r.replace(/\s([\w-]+)(?==)/g,` <span style="color:#ffcb6b">$1</span>`),r=r.replace(/(["'])(?:(?!\1).)*?\1/g,`<span style="color:#c3e88d">$&</span>`);else if(t===`json`)r=r.replace(/(["'])(?:(?!\1|\\).|\\.)*?\1(?=\s*:)/g,`<span style="color:#82aaff">$&</span>`),r=r.replace(/:\s*(["'])(?:(?!\1|\\).|\\.)*?\1/g,e=>`: <span style="color:#c3e88d">`+e.slice(2)+`</span>`),r=r.replace(/:\s*(true|false|null)\b/g,`: <span style="color:#c792ea">$1</span>`),r=r.replace(/:\s*(\d+\.?\d*)/g,`: <span style="color:#f78c6c">$1</span>`);else{if(/^\s*\/\//.test(r))return`<span style="color:#546e7a;font-style:italic">`+r+`</span>`;r=r.replace(/(["'`])(?:(?!\1|\\).|\\.)*?\1/g,`<span style="color:#c3e88d">$&</span>`),r=r.replace(/\b(const|let|var|function|return|if|else|for|while|switch|case|break|continue|try|catch|throw|new|class|extends|import|export|from|default|async|await|typeof|instanceof)\b/g,`<span style="color:#c792ea">$&</span>`),r=r.replace(/\b(null|undefined|true|false)\b/g,`<span style="color:#ff5370">$&</span>`),r=r.replace(/\b(require|module|exports|console|process)\b/g,`<span style="color:#82aaff">$&</span>`)}return r}).join(`
753
753
  `)}function $T(e){if(!e)return``;let t=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`);return e.split(/(```[\s\S]*?```)/g).map(e=>{if(e.startsWith("```")&&e.endsWith("```")){let n=e.slice(3,-3),r=n.indexOf(`
754
754
  `);return`<pre style="background:rgba(0,0,0,0.3);border:1px solid rgba(255,255,255,0.08);border-radius:6px;padding:8px 10px;margin:6px 0;overflow-x:auto;font-size:11px;line-height:1.5"><code>${t(r>0?n.slice(r+1):n)}</code></pre>`}let n=t(e);return n=n.replace(/`([^`]+)`/g,`<code style="background:rgba(99,102,241,0.15);padding:1px 5px;border-radius:3px;font-size:0.9em">$1</code>`),n=n.replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`),n=n.replace(/\*([^*]+)\*/g,`<em>$1</em>`),n=n.replace(/^### (.+)$/gm,`<div style="font-weight:700;font-size:13px;margin-top:8px;color:#6366f1">$1</div>`),n=n.replace(/^## (.+)$/gm,`<div style="font-weight:700;font-size:14px;margin-top:10px;color:#818cf8">$1</div>`),n=n.replace(/^[-*] (.+)$/gm,`<div style="padding-left:12px">• $1</div>`),n=n.replace(/^\d+\. (.+)$/gm,(e,t)=>`<div style="padding-left:12px">${t}</div>`),n=n.replace(/\n/g,`<br/>`),n}).join(``)}var eE=[{name:`MySaaS`,desc:`Full-stack SaaS web application with Node.js/Express backend and vanilla JS frontend.
@@ -839,26 +839,26 @@ FRONTEND:
839
839
  - index.html: Job board homepage — (1) Hero: gradient background, large search widget (keyword input + location input + category select + Search button), quick stats bar (12,847 Jobs / 3,420 Companies / 45K Candidates). (2) Featured jobs: horizontal scroll row of 4 "Featured" cards with company logo (colored emoji), job title, company name, location + type badge + salary range + "Easy Apply" button. (3) Main layout: left sidebar filters (Job Type checkboxes, Salary Range slider, Category checkboxes, Location input, Posted Within select, Remote Only toggle) + right: jobs list (job row cards with company logo/title/company/location/type/salary/time-ago posted/Save bookmark/Apply button). (4) "Load More" button + results count "Showing 12 of 247 jobs". (5) Top companies section: 8 company cards with logo/name/industry/openings count. (6) Category browsing: 6 category cards with icon/name/count/link. (7) Job seeker CTA banner. (8) Newsletter.
840
840
  - job.html: Job detail page — company header (logo + name + industry + website + size + "Follow" button), job title + badges (Remote, Senior, Urgent), salary + location + posted date, Apply Now button (sticky on scroll), job description (markdown-rendered sections: About/Responsibilities/Requirements/Nice-to-Have/Benefits), company sidebar card (description + stats), similar jobs list (4 cards)
841
841
  - apply.html: Application modal/page — job summary header, form (Full Name / Email / Phone / LinkedIn URL / Portfolio URL / Cover Letter textarea with character count / Resume paste textarea), Submit button with loading state, success page with application reference number
842
- - public/css/main.css: Modern job board design — tag/badge system (Remote=blue, Onsite=green, Urgent=red), salary range display, company logo placeholder styles, filter sidebar collapse on mobile, job card hover effects, application form validation styles`}],tE=[{key:`auth`,label:`Auth (register/login/JWT)`,icon:`🔒`},{key:`cookieBanner`,label:`GDPR Cookie Banner`,icon:`🍪`},{key:`securityMiddleware`,label:`Security Middleware`,icon:`🛡️`},{key:`emailVerification`,label:`Email Verification`,icon:`✉️`}],nE={js:`📄`,ts:`📄`,css:`🎨`,html:`🌐`,json:`📋`,md:`📑`,sql:`🗂`,env:`🔐`,conf:`⚙`,lock:`🔒`};function rE(e){return nE[e.split(`.`).pop()?.toLowerCase()??``]??`📄`}function iE(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function aE(e){return e===`memory`?`🧠`:e===`provider`?`🤖`:e===`log`?`📄`:`📋`}function oE(){let e=j(),[t,n]=(0,_.useState)(`new`),[r,i]=(0,_.useState)(`files`),a=Ut(),[o,s]=(0,_.useState)(`editor`);(0,_.useEffect)(()=>{a&&(o===`preview`&&i(`preview`),o===`editor`&&i(`files`))},[a,o]);let[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)({auth:!0,cookieBanner:!0,securityMiddleware:!0,emailVerification:!0}),[m,h]=(0,_.useState)([{label:`Email`,type:`email`,required:!0},{label:`Password`,type:`password`,required:!0},{label:`Name`,type:`text`,required:!0}]),[g,v]=(0,_.useState)([]),[y,b]=(0,_.useState)(0),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[ee,te]=(0,_.useState)(new Set),[ne,re]=(0,_.useState)(!1),[D,ie]=(0,_.useState)(``),[O,ae]=(0,_.useState)(``),[A,oe]=(0,_.useState)(!1),[se,ce]=(0,_.useState)(null),[le,ue]=(0,_.useState)(!1),[de,M]=(0,_.useState)([]),[fe,pe]=(0,_.useState)([]),me=(0,_.useRef)(null),he=(0,_.useRef)(null),ge=(0,_.useRef)(!0),_e=(0,_.useRef)(null),ve=(0,_.useRef)(null),ye=(0,_.useRef)(null),be=(0,_.useRef)(null),[xe,Se]=(0,_.useState)(null),[N,Ce]=(0,_.useState)(!1),[we,Te]=(0,_.useState)(!1),[Ee,P]=(0,_.useState)(0),[De,Oe]=(0,_.useState)(0),[ke,F]=(0,_.useState)(``),[I,Ae]=(0,_.useState)({fi:0,total:0,name:``}),[je,Me]=(0,_.useState)({tokIn:0,tokOut:0}),[Ne,Pe]=(0,_.useState)(null),[Fe,Ie]=(0,_.useState)([]),[Le,Re]=(0,_.useState)(``),[ze,L]=(0,_.useState)(!1),[Be,Ve]=(0,_.useState)([]),[He,Ue]=(0,_.useState)(null),[We,Ge]=(0,_.useState)([]),[Ke,qe]=(0,_.useState)(!1),[Je,Ye]=(0,_.useState)(null),[Xe,Ze]=(0,_.useState)([]),[Qe,$e]=(0,_.useState)(!1),[et,tt]=(0,_.useState)(``),[nt,rt]=(0,_.useState)([]),[it,at]=(0,_.useState)([]),[ot,st]=(0,_.useState)([]),[ct,lt]=(0,_.useState)(null),[ut,dt]=(0,_.useState)(!1),[ft,pt]=(0,_.useState)(!1),[mt,ht]=(0,_.useState)(null),[gt,_t]=(0,_.useState)([]),[vt,yt]=(0,_.useState)(`0s`),[R,bt]=(0,_.useState)(`0s`),xt=(0,_.useRef)(0),St=(0,_.useRef)(0),Ct=(0,_.useRef)(null),wt=(0,_.useRef)(null),Tt=(0,_.useRef)(null),Et=(0,_.useRef)(null),z=(0,_.useRef)(null),Dt=(0,_.useRef)(!1),Ot=(0,_.useRef)(null);function kt(e){console.log(`[WC-SCAN] scanning:`,e),E(`/api/studio/webcraft/scan`,{projectName:e}).then(e=>{console.log(`[WC-SCAN] result:`,e?.issues?.length,`issues`),e?.issues!==void 0&&pe(e.issues)}).catch(e=>{console.error(`[WC-SCAN] error:`,e)})}(0,_.useEffect)(()=>{if(!ct){M([]);return}let e=setInterval(()=>{T(`/api/studio/webcraft/sandbox/errors`).then(e=>{e?.errors?.length&&M(e.errors)}).catch(()=>{})},5e3);return()=>clearInterval(e)},[ct]);let At=(0,_.useRef)(ct);At.current=ct,(0,_.useEffect)(()=>{let e=()=>{At.current&&(navigator.sendBeacon(`/api/studio/webcraft/sandbox/stop-beacon`,``),fetch(`/api/studio/webcraft/sandbox`,{method:`DELETE`,keepalive:!0}).catch(()=>{}))};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),e()}},[]),(0,_.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),re(e=>!e)),(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),C!==null&&g[y])){let e=g[y];v(e=>e.map((e,t)=>t===y?{...e,content:C}:e)),E(`/api/studio/webcraft/file/write`,{projectName:c,path:e.name,content:C}),w(null),te(t=>{let n=new Set(t);return n.delete(e.name),n})}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,y,g,c]),(0,_.useEffect)(()=>{let e=()=>{let e=C===null?ye.current:ve.current;e&&be.current&&(be.current.scrollTop=e.scrollTop)},t=C===null?ye.current:ve.current;return t&&t.addEventListener(`scroll`,e),()=>{t&&t.removeEventListener(`scroll`,e)}},[C,y]);function jt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Mt(e){let t=Math.floor((Date.now()-e)/1e3),n=Math.floor(t/60);return(n>0?`${n}m `:``)+`${t%60}s`}(0,_.useEffect)(()=>(N||we?Ct.current=setInterval(()=>{N&&yt(Mt(xt.current)),we&&bt(Mt(St.current))},1e3):Ct.current&&=(clearInterval(Ct.current),null),()=>{Ct.current&&clearInterval(Ct.current)}),[N,we]);function B(){Tt.current&&(Tt.current.scrollTop=Tt.current.scrollHeight)}(0,_.useEffect)(()=>{B()},[Fe]),(0,_.useEffect)(()=>{if(!c){Ge([]),qe(!1);return}Ge([]),qe(!1),T(`/api/studio/webcraft/skills/${encodeURIComponent(c)}`).then(e=>{e?.skills&&Ge(e.skills),qe(!0)}).catch(()=>{qe(!0)})},[c]);async function Nt(e,t){if(N||!e||e.length<5)return;Ce(!0),v([]),b(0),S(null),Ae({fi:0,total:0,name:``}),Me({tokIn:0,tokOut:0}),xt.current=Date.now(),yt(`0s`),wt.current=new AbortController;let n=Date.now();try{let r=await fetch(`/api/studio/webcraft/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},signal:wt.current.signal,body:JSON.stringify({projectName:t,description:e,blocks:f,authFields:m})});if(!r.ok||!r.body){Ce(!1);return}let i=r.body.getReader(),a=wt.current,o=new TextDecoder,s=``,u=[];for(;;){if(a?.signal?.aborted){try{i.cancel()}catch{}break}let{done:e,value:t}=await i.read();if(e)break;s+=o.decode(t,{stream:!0});let r=s.split(`
842
+ - public/css/main.css: Modern job board design — tag/badge system (Remote=blue, Onsite=green, Urgent=red), salary range display, company logo placeholder styles, filter sidebar collapse on mobile, job card hover effects, application form validation styles`}],tE=[{key:`auth`,label:`Auth (register/login/JWT)`,icon:`🔒`},{key:`cookieBanner`,label:`GDPR Cookie Banner`,icon:`🍪`},{key:`securityMiddleware`,label:`Security Middleware`,icon:`🛡️`},{key:`emailVerification`,label:`Email Verification`,icon:`✉️`}],nE={js:`📄`,ts:`📄`,css:`🎨`,html:`🌐`,json:`📋`,md:`📑`,sql:`🗂`,env:`🔐`,conf:`⚙`,lock:`🔒`};function rE(e){return nE[e.split(`.`).pop()?.toLowerCase()??``]??`📄`}function iE(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function aE(e){return e===`memory`?`🧠`:e===`provider`?`🤖`:e===`log`?`📄`:`📋`}function oE(){let e=j(),[t,n]=(0,_.useState)(`new`),[r,i]=(0,_.useState)(`files`),a=Ut(),[o,s]=(0,_.useState)(`editor`);(0,_.useEffect)(()=>{a&&(o===`preview`&&i(`preview`),o===`editor`&&i(`files`))},[a,o]);let[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)({auth:!0,cookieBanner:!0,securityMiddleware:!0,emailVerification:!0}),[m,h]=(0,_.useState)([{label:`Email`,type:`email`,required:!0},{label:`Password`,type:`password`,required:!0},{label:`Name`,type:`text`,required:!0}]),[g,v]=(0,_.useState)([]),[y,b]=(0,_.useState)(0),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[ee,te]=(0,_.useState)(new Set),[ne,re]=(0,_.useState)(!1),[D,ie]=(0,_.useState)(``),[O,ae]=(0,_.useState)(``),[A,oe]=(0,_.useState)(!1),[se,ce]=(0,_.useState)(null),[le,ue]=(0,_.useState)(!1),[de,M]=(0,_.useState)([]),[fe,pe]=(0,_.useState)([]),[me,he]=(0,_.useState)(!0),ge=(0,_.useRef)(null),_e=(0,_.useRef)(null),ve=(0,_.useRef)(!0),ye=(0,_.useRef)(null),be=(0,_.useRef)(null),xe=(0,_.useRef)(null),Se=(0,_.useRef)(null),[N,Ce]=(0,_.useState)(null),[we,Te]=(0,_.useState)(!1),[Ee,P]=(0,_.useState)(!1),[De,Oe]=(0,_.useState)(0),[ke,F]=(0,_.useState)(0),[I,Ae]=(0,_.useState)(``),[je,Me]=(0,_.useState)({fi:0,total:0,name:``}),[Ne,Pe]=(0,_.useState)({tokIn:0,tokOut:0}),[Fe,Ie]=(0,_.useState)(null),[Le,Re]=(0,_.useState)([]),[ze,L]=(0,_.useState)(``),[Be,Ve]=(0,_.useState)(!1),[He,Ue]=(0,_.useState)([]),[We,Ge]=(0,_.useState)(null),[Ke,qe]=(0,_.useState)([]),[Je,Ye]=(0,_.useState)(!1),[Xe,Ze]=(0,_.useState)(null),[Qe,$e]=(0,_.useState)([]),[et,tt]=(0,_.useState)(!1),[nt,rt]=(0,_.useState)(``),[it,at]=(0,_.useState)([]),[ot,st]=(0,_.useState)([]),[ct,lt]=(0,_.useState)([]),[ut,dt]=(0,_.useState)(null),[ft,pt]=(0,_.useState)(!1),[mt,ht]=(0,_.useState)(!1),[gt,_t]=(0,_.useState)(null),[vt,yt]=(0,_.useState)([]),[R,bt]=(0,_.useState)(`0s`),[xt,St]=(0,_.useState)(`0s`),Ct=(0,_.useRef)(0),wt=(0,_.useRef)(0),Tt=(0,_.useRef)(null),Et=(0,_.useRef)(null),z=(0,_.useRef)(null),Dt=(0,_.useRef)(null),Ot=(0,_.useRef)(null),kt=(0,_.useRef)(!1),At=(0,_.useRef)(null);function jt(e){console.log(`[WC-SCAN] scanning:`,e),E(`/api/studio/webcraft/scan`,{projectName:e}).then(e=>{console.log(`[WC-SCAN] result:`,e?.issues?.length,`issues`),e?.issues!==void 0&&pe(e.issues)}).catch(e=>{console.error(`[WC-SCAN] error:`,e)})}(0,_.useEffect)(()=>{if(!ut){M([]);return}let e=setInterval(()=>{T(`/api/studio/webcraft/sandbox/errors`).then(e=>{e?.errors?.length&&M(e.errors)}).catch(()=>{})},5e3);return()=>clearInterval(e)},[ut]);let Mt=(0,_.useRef)(ut);Mt.current=ut,(0,_.useEffect)(()=>{let e=()=>{Mt.current&&(navigator.sendBeacon(`/api/studio/webcraft/sandbox/stop-beacon`,``),fetch(`/api/studio/webcraft/sandbox`,{method:`DELETE`,keepalive:!0}).catch(()=>{}))};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),e()}},[]),(0,_.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),re(e=>!e)),(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),C!==null&&g[y])){let e=g[y];v(e=>e.map((e,t)=>t===y?{...e,content:C}:e)),E(`/api/studio/webcraft/file/write`,{projectName:c,path:e.name,content:C}),w(null),te(t=>{let n=new Set(t);return n.delete(e.name),n})}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,y,g,c]),(0,_.useEffect)(()=>{let e=()=>{let e=C===null?xe.current:be.current;e&&Se.current&&(Se.current.scrollTop=e.scrollTop)},t=C===null?xe.current:be.current;return t&&t.addEventListener(`scroll`,e),()=>{t&&t.removeEventListener(`scroll`,e)}},[C,y]);function B(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Nt(e){let t=Math.floor((Date.now()-e)/1e3),n=Math.floor(t/60);return(n>0?`${n}m `:``)+`${t%60}s`}(0,_.useEffect)(()=>(we||Ee?Tt.current=setInterval(()=>{we&&bt(Nt(Ct.current)),Ee&&St(Nt(wt.current))},1e3):Tt.current&&=(clearInterval(Tt.current),null),()=>{Tt.current&&clearInterval(Tt.current)}),[we,Ee]);function Pt(){z.current&&(z.current.scrollTop=z.current.scrollHeight)}(0,_.useEffect)(()=>{Pt()},[Le]),(0,_.useEffect)(()=>{if(!c){qe([]),Ye(!1);return}qe([]),Ye(!1),T(`/api/studio/webcraft/skills/${encodeURIComponent(c)}`).then(e=>{e?.skills&&qe(e.skills),Ye(!0)}).catch(()=>{Ye(!0)})},[c]);async function Ft(e,t){if(we||!e||e.length<5)return;Te(!0),v([]),b(0),S(null),Me({fi:0,total:0,name:``}),Pe({tokIn:0,tokOut:0}),Ct.current=Date.now(),bt(`0s`),Et.current=new AbortController;let n=Date.now();try{let r=await fetch(`/api/studio/webcraft/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},signal:Et.current.signal,body:JSON.stringify({projectName:t,description:e,blocks:f,authFields:m})});if(!r.ok||!r.body){Te(!1);return}let i=r.body.getReader(),a=Et.current,o=new TextDecoder,s=``,u=[];for(;;){if(a?.signal?.aborted){try{i.cancel()}catch{}break}let{done:e,value:t}=await i.read();if(e)break;s+=o.decode(t,{stream:!0});let r=s.split(`
843
843
 
844
- `);s=r.pop()??``;for(let e of r){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);if(e.type===`project_renamed`)l(e.name);else if(e.type===`processing`||e.type===`planning`)Ae(t=>({...t,name:e.type===`planning`?`📋 Pianificazione struttura...`:e.msg||`Avvio...`}));else if(e.type===`file_start`)u.push({name:e.name,content:``,_pending:!0}),v([...u]),Ae({fi:e.fi,total:e.total,name:e.name}),me.current=u.length-1,he.current||(b(u.length-1),S(``)),ge.current=!0;else if(e.type===`file_chunk`){let t=u.find(t=>t.name===e.name);t&&(t.content+=e.chunk,t._pending=!1),v([...u]);let n=u.findIndex(t=>t.name===e.name);n>=0&&(me.current=n,S(t?t.content:null))}else if(e.type===`file_done`){let t=u.find(t=>t.name===e.name);t&&(t._pending=!1,e.syntaxError&&(t._syntaxError=e.syntaxError)),v([...u]),Ae({fi:e.fi,total:e.total,name:e.name}),(e.cumTokIn||e.cumTokOut)&&Me({tokIn:e.cumTokIn||0,tokOut:e.cumTokOut||0})}else if(e.type===`file_error`){let t=u.find(t=>t.name===e.name);t&&(t._error=!0,t._pending=!1),v([...u])}else e.type===`phase`||e.type===`status`&&!e.op?Ae(t=>({...t,name:e.msg||e.phase||``})):e.type===`done`&&(Pe({seconds:Math.round((Date.now()-n)/1e3),tokIn:e.tokIn??0,tokOut:e.tokOut??0,files:u.length}),S(null),Ce(!1),me.current=null,he.current&&=(clearTimeout(he.current),null),c&&kt(c),ue(!0),qe(!1),Ge([]),u.some(e=>e._error||e._syntaxError)?setTimeout(()=>z.current?.(),800):setTimeout(()=>Ot.current?.(),800))}catch{}}}}catch(e){e.name!==`AbortError`&&Ie(t=>[...t,{role:`system`,text:`Errore generazione: `+e.message}]),Ce(!1)}}async function Pt(e){let t=(e??Le).trim();if(!(c&&g.length>0)){if(!t||t.length<5)return;let e=c||`MyProject`;l(e),d(t),Re(``),await Nt(t,e);return}if(!t&&Be.length===0||ze||N)return;let n=[...Be];if(Ve([]),Re(``),t.toLowerCase().startsWith(`/plan `)||t.toLowerCase().startsWith(`piano: `)){let e=t.replace(/^\/plan[ ]*/i,``).replace(/^piano:[ ]*/i,``);Ie(e=>[...e,{role:`user`,text:t}]),await Ft(`[MODALITA PIANO] Descrivi cosa modificheresti per: "${e}". Elenca i file e cosa faresti. NON applicare modifiche ancora. Rispondi con il piano in bullet list.`,e,[]);return}Ie(e=>[...e,{role:`user`,text:t,attachments:n}]),await Ft(t,null,n)}async function Ft(e,t,n){if(ze)return;L(!0),c&&g.length>0&&E(`/api/studio/webcraft/snapshot`,{projectName:c}).catch(()=>{});let r={};g.forEach(e=>{r[e.name]=e.content});try{let i=new AbortController;wt.current=i;let a=await fetch(`/api/studio/webcraft/agent`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectName:c,message:e,attachments:n.map(e=>({name:e.name,mimeType:e.mimeType,base64:e.base64}))}),signal:i.signal});if(!a.ok||!a.body){Ie(e=>[...e,{role:`agent`,text:`Errore: ${a.status}`,tools:[]}]),L(!1);return}let o={role:`agent`,text:``,tools:[]};Ie(e=>[...e,o]);let s=a.body.getReader(),l=new TextDecoder,u=``,d=!1,f=``;for(;;){if(i.signal.aborted){try{s.cancel()}catch{}break}let{done:e,value:n}=await s.read();if(e)break;u+=l.decode(n,{stream:!0});let a=u.split(`
844
+ `);s=r.pop()??``;for(let e of r){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);if(e.type===`project_renamed`)l(e.name);else if(e.type===`processing`||e.type===`planning`)Me(t=>({...t,name:e.type===`planning`?`📋 Pianificazione struttura...`:e.msg||`Avvio...`}));else if(e.type===`file_start`)u.push({name:e.name,content:``,_pending:!0}),v([...u]),Me({fi:e.fi,total:e.total,name:e.name}),ge.current=u.length-1,_e.current&&=(clearTimeout(_e.current),null),b(u.length-1),S(``),ve.current=!0;else if(e.type===`file_chunk`){let t=u.find(t=>t.name===e.name);t&&(t.content+=e.chunk,t._pending=!1),v([...u]);let n=u.findIndex(t=>t.name===e.name);n>=0&&(ge.current=n,S(t?t.content:null))}else if(e.type===`file_done`){let t=u.find(t=>t.name===e.name);t&&(t._pending=!1,e.syntaxError&&(t._syntaxError=e.syntaxError)),v([...u]),Me({fi:e.fi,total:e.total,name:e.name}),(e.cumTokIn||e.cumTokOut)&&Pe({tokIn:e.cumTokIn||0,tokOut:e.cumTokOut||0})}else if(e.type===`file_error`){let t=u.find(t=>t.name===e.name);t&&(t._error=!0,t._pending=!1),v([...u])}else e.type===`phase`||e.type===`status`&&!e.op?Me(t=>({...t,name:e.msg||e.phase||``})):e.type===`done`&&(Ie({seconds:Math.round((Date.now()-n)/1e3),tokIn:e.tokIn??0,tokOut:e.tokOut??0,files:u.length}),S(null),Te(!1),ge.current=null,_e.current&&=(clearTimeout(_e.current),null),c&&jt(c),ue(!0),Ye(!1),qe([]),u.some(e=>e._error||e._syntaxError)?setTimeout(()=>Ot.current?.(),800):setTimeout(()=>At.current?.(),800))}catch{}}}}catch(e){e.name!==`AbortError`&&Re(t=>[...t,{role:`system`,text:`Errore generazione: `+e.message}]),Te(!1)}}async function It(e){let t=(e??ze).trim();if(!(c&&g.length>0)){if(!t||t.length<5)return;let e=c||`MyProject`;l(e),d(t),L(``),await Ft(t,e);return}if(!t&&He.length===0||Be||we)return;let n=[...He];if(Ue([]),L(``),t.toLowerCase().startsWith(`/plan `)||t.toLowerCase().startsWith(`piano: `)){let e=t.replace(/^\/plan[ ]*/i,``).replace(/^piano:[ ]*/i,``);Re(e=>[...e,{role:`user`,text:t}]),await Lt(`[MODALITA PIANO] Descrivi cosa modificheresti per: "${e}". Elenca i file e cosa faresti. NON applicare modifiche ancora. Rispondi con il piano in bullet list.`,e,[]);return}Re(e=>[...e,{role:`user`,text:t,attachments:n}]),await Lt(t,null,n)}async function Lt(e,t,n){if(Be)return;Ve(!0),c&&g.length>0&&E(`/api/studio/webcraft/snapshot`,{projectName:c}).catch(()=>{});let r={};g.forEach(e=>{r[e.name]=e.content});try{let i=new AbortController;Et.current=i;let a=await fetch(`/api/studio/webcraft/agent`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectName:c,message:e,attachments:n.map(e=>({name:e.name,mimeType:e.mimeType,base64:e.base64}))}),signal:i.signal});if(!a.ok||!a.body){Re(e=>[...e,{role:`agent`,text:`Errore: ${a.status}`,tools:[]}]),Ve(!1);return}let o={role:`agent`,text:``,tools:[]};Re(e=>[...e,o]);let s=a.body.getReader(),l=new TextDecoder,u=``,d=!1,f=``;for(;;){if(i.signal.aborted){try{s.cancel()}catch{}break}let{done:e,value:n}=await s.read();if(e)break;u+=l.decode(n,{stream:!0});let a=u.split(`
845
845
 
846
- `);u=a.pop()??``;for(let e of a){let n=e.replace(/^data: /,``).trim();if(n)try{let e=JSON.parse(n);if(e.type===`text`){f+=e.token;let t=f.lastIndexOf(`<`),n;t>=0&&!f.slice(t).includes(`>`)?(n=f.slice(0,t),f=f.slice(t)):(n=f.replace(/<tool>[\s\S]*?<\/tool>/g,``).replace(/<done\s*\/>/g,``),f=``),n&&(o.text+=n)}else if(e.type===`step`)o.text+=`\n\n**[Step ${e.step}/${e.max}]** `;else if(e.type===`tool`)(e.op===`edit`||e.op===`write`)&&console.log(`[WC-DEBUG] tool event:`,e.op,e.path,`result:`,e.result,`oldSnippet:`,(e.oldSnippet||``).length,`newSnippet:`,(e.newSnippet||``).length),o.tools.push({op:e.op,path:e.path,result:e.result,oldSnippet:e.oldSnippet??``,newSnippet:e.newSnippet??``}),(e.op===`edit`||e.op===`write`)&&(e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`)&&(d=!0),Ie(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`files_changed`)e.files?.length&&await It(e.files,r);else if(e.type===`syntax_errors`)e.errors?.length&&(o.syntaxErrors=e.errors,Ie(e=>{let t=[...e];return t[t.length-1]={...o},t}));else if(e.type===`sandbox_restart`)o.text+=`
846
+ `);u=a.pop()??``;for(let e of a){let n=e.replace(/^data: /,``).trim();if(n)try{let e=JSON.parse(n);if(e.type===`text`){f+=e.token;let t=f.lastIndexOf(`<`),n;t>=0&&!f.slice(t).includes(`>`)?(n=f.slice(0,t),f=f.slice(t)):(n=f.replace(/<tool>[\s\S]*?<\/tool>/g,``).replace(/<done\s*\/>/g,``),f=``),n&&(o.text+=n)}else if(e.type===`step`)o.text+=`\n\n**[Step ${e.step}/${e.max}]** `;else if(e.type===`tool`)(e.op===`edit`||e.op===`write`)&&console.log(`[WC-DEBUG] tool event:`,e.op,e.path,`result:`,e.result,`oldSnippet:`,(e.oldSnippet||``).length,`newSnippet:`,(e.newSnippet||``).length),o.tools.push({op:e.op,path:e.path,result:e.result,oldSnippet:e.oldSnippet??``,newSnippet:e.newSnippet??``}),(e.op===`edit`||e.op===`write`)&&(e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`)&&(d=!0),Re(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`files_changed`)e.files?.length&&await Rt(e.files,r);else if(e.type===`syntax_errors`)e.errors?.length&&(o.syntaxErrors=e.errors,Re(e=>{let t=[...e];return t[t.length-1]={...o},t}));else if(e.type===`sandbox_restart`)o.text+=`
847
847
 
848
- 🔄 `+(e.msg||`Restarting sandbox...`),Ie(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`sandbox_ready`)lt(e.port),o.text+=`
849
- ✅ Sandbox ready on port `+e.port,Ie(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`sandbox_error`)o.text+=`
850
- ❌ Sandbox error: `+e.msg,Ie(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`done`){if(f){let e=f.replace(/<tool>[\s\S]*?<\/tool>/g,``).replace(/<done\s*\/>/g,``);e&&(o.text+=e),f=``}t&&!d&&Ue({plan:o.text,originalMessage:t}),L(!1),await It((o.tools??[]).filter(e=>(e.op===`edit`||e.op===`write`)&&(e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`)).map(e=>e.path),r),c&&kt(c)}else e.type===`error`&&(o.text+=`
851
- Errore: `+e.msg,L(!1))}catch{}}}}catch(e){e instanceof DOMException&&e.name===`AbortError`||Ie(t=>[...t,{role:`agent`,text:`Errore di rete: `+e.message,tools:[]}])}if(L(!1),c){try{let e=await T(`/api/studio/webcraft/projects/load/${encodeURIComponent(c)}`);e?.files&&v(e.files)}catch{}setTimeout(()=>{c&&kt(c)},200)}}async function It(e,t){if(!c)return;let n=await T(`/api/studio/webcraft/projects/load/${encodeURIComponent(c)}`);if(n?.files&&(v(n.files),c&&setTimeout(()=>kt(c),300),e.length>0)){let r=e.map(e=>{let r=n.files.find(t=>t.name===e);return r?{file:e,before:t[e]??``,after:r.content??``}:null}).filter(Boolean);at(e=>[...e,...r])}}function Lt(){wt.current&&=(wt.current.abort(),null),Dt.current=!0,Ce(!1),L(!1),Te(!1),F(``),S(null),Ie(e=>[...e,{role:`system`,text:`⏹ Generazione interrotta.`}])}async function Rt(){return c?(await E(`/api/studio/webcraft/snapshot`,{projectName:c}))?.snapshot??null:null}async function zt(){let e=await Rt();e&&(Ie(t=>[...t,{role:`system`,text:`💾 Snapshot salvato (${e.slice(0,16).replace(`T`,` `)})`}]),Bt())}async function Bt(){if(!c)return;let e=await T(`/api/studio/webcraft/snapshots/${encodeURIComponent(c)}`);e?.snapshots&&Ze(e.snapshots)}async function Vt(e){confirm(`Ripristinare lo snapshot del ${e.replace(`T`,` `).slice(0,16)}? I file attuali verranno sovrascritti.`)&&await E(`/api/studio/webcraft/restore`,{projectName:c,ts:e})!==null&&(Ie(t=>[...t,{role:`agent`,text:`Snapshot ripristinato (${e}). Ricarico i file...`}]),It([],{}))}async function Ht(){if(!c)return;let e=await E(`/api/studio/webcraft/syntax-check`,{projectName:c});if(e?.results){let t=e.results.filter(e=>!e.ok);t.length>0?Ie(e=>[...e,{role:`system`,text:`⚠ Syntax check: ${t.length} errore/i trovato/i.`,syntaxErrors:t}]):Ie(e=>[...e,{role:`system`,text:`✓ Syntax check: tutti i file JS sono validi.`}])}}async function V(){let e=g.filter(e=>e._error||e._syntaxError);if(e.length===0){Ot.current?.();return}Dt.current=!1,Te(!0),P(0),Oe(e.length),St.current=Date.now(),bt(`0s`);for(let t=0;t<e.length&&!Dt.current;t++){let n=e[t];F(n.name),P(t);let r=`FIX ERROR in ${n.name}: ${n._syntaxError??`generazione fallita`}\n\nUse the edit tool to make surgical fixes. Do NOT rewrite the entire file — only change the broken parts. Read the file first, identify the exact lines with errors, and edit only those lines.`;try{await Ft(r,null,[])}catch{if(Dt.current)break}}c&&kt(c),Dt.current||(P(e.length),setTimeout(()=>Ot.current?.(),500)),F(``),Te(!1)}async function Wt(e){if(!ft){pt(!0),ht(null),lt(null),_t([]),i(`preview`);try{let t=await fetch(`/api/studio/webcraft/sandbox/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectName:e})});if(!t.ok||!t.body){ht(t.ok?`No response body`:`HTTP ${t.status}`),pt(!1);return}let n=t.body.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:t}=await n.read();if(e)break;i+=r.decode(t,{stream:!0});let a=i.split(`
848
+ 🔄 `+(e.msg||`Restarting sandbox...`),Re(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`sandbox_ready`)dt(e.port),o.text+=`
849
+ ✅ Sandbox ready on port `+e.port,Re(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`sandbox_error`)o.text+=`
850
+ ❌ Sandbox error: `+e.msg,Re(e=>{let t=[...e];return t[t.length-1]={...o},t});else if(e.type===`done`){if(f){let e=f.replace(/<tool>[\s\S]*?<\/tool>/g,``).replace(/<done\s*\/>/g,``);e&&(o.text+=e),f=``}t&&!d&&Ge({plan:o.text,originalMessage:t}),Ve(!1),await Rt((o.tools??[]).filter(e=>(e.op===`edit`||e.op===`write`)&&(e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`)).map(e=>e.path),r),c&&jt(c)}else e.type===`error`&&(o.text+=`
851
+ Errore: `+e.msg,Ve(!1))}catch{}}}}catch(e){e instanceof DOMException&&e.name===`AbortError`||Re(t=>[...t,{role:`agent`,text:`Errore di rete: `+e.message,tools:[]}])}if(Ve(!1),c){try{let e=await T(`/api/studio/webcraft/projects/load/${encodeURIComponent(c)}`);e?.files&&v(e.files)}catch{}setTimeout(()=>{c&&jt(c)},200)}}async function Rt(e,t){if(!c)return;let n=await T(`/api/studio/webcraft/projects/load/${encodeURIComponent(c)}`);if(n?.files&&(v(n.files),c&&setTimeout(()=>jt(c),300),e.length>0)){let r=e.map(e=>{let r=n.files.find(t=>t.name===e);return r?{file:e,before:t[e]??``,after:r.content??``}:null}).filter(Boolean);st(e=>[...e,...r])}}function zt(){Et.current&&=(Et.current.abort(),null),kt.current=!0,Te(!1),Ve(!1),P(!1),Ae(``),S(null),Re(e=>[...e,{role:`system`,text:`⏹ Generazione interrotta.`}])}async function Bt(){return c?(await E(`/api/studio/webcraft/snapshot`,{projectName:c}))?.snapshot??null:null}async function Vt(){let e=await Bt();e&&(Re(t=>[...t,{role:`system`,text:`💾 Snapshot salvato (${e.slice(0,16).replace(`T`,` `)})`}]),Ht())}async function Ht(){if(!c)return;let e=await T(`/api/studio/webcraft/snapshots/${encodeURIComponent(c)}`);e?.snapshots&&$e(e.snapshots)}async function V(e){confirm(`Ripristinare lo snapshot del ${e.replace(`T`,` `).slice(0,16)}? I file attuali verranno sovrascritti.`)&&await E(`/api/studio/webcraft/restore`,{projectName:c,ts:e})!==null&&(Re(t=>[...t,{role:`agent`,text:`Snapshot ripristinato (${e}). Ricarico i file...`}]),Rt([],{}))}async function Wt(){if(!c)return;let e=await E(`/api/studio/webcraft/syntax-check`,{projectName:c});if(e?.results){let t=e.results.filter(e=>!e.ok);t.length>0?Re(e=>[...e,{role:`system`,text:`⚠ Syntax check: ${t.length} errore/i trovato/i.`,syntaxErrors:t}]):Re(e=>[...e,{role:`system`,text:`✓ Syntax check: tutti i file JS sono validi.`}])}}async function Gt(){let e=g.filter(e=>e._error||e._syntaxError);if(e.length===0){At.current?.();return}kt.current=!1,P(!0),Oe(0),F(e.length),wt.current=Date.now(),St(`0s`);for(let t=0;t<e.length&&!kt.current;t++){let n=e[t];Ae(n.name),Oe(t);let r=`FIX ERROR in ${n.name}: ${n._syntaxError??`generazione fallita`}\n\nUse the edit tool to make surgical fixes. Do NOT rewrite the entire file — only change the broken parts. Read the file first, identify the exact lines with errors, and edit only those lines.`;try{await Lt(r,null,[])}catch{if(kt.current)break}}c&&jt(c),kt.current||(Oe(e.length),setTimeout(()=>At.current?.(),500)),Ae(``),P(!1)}async function Kt(e){if(!mt){ht(!0),_t(null),dt(null),yt([]),i(`preview`);try{let t=await fetch(`/api/studio/webcraft/sandbox/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectName:e})});if(!t.ok||!t.body){_t(t.ok?`No response body`:`HTTP ${t.status}`),ht(!1);return}let n=t.body.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:t}=await n.read();if(e)break;i+=r.decode(t,{stream:!0});let a=i.split(`
852
852
 
853
- `);i=a.pop()??``;for(let e of a){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);(e.type===`phase`||e.type===`status`||e.type===`log`||e.type===`warn`||e.type===`error`)&&_t(t=>[...t.slice(-49),{kind:e.type,msg:String(e.msg||``),ts:Date.now()}]),e.type===`ready`&&e.port?(lt(e.port),pt(!1)):e.type===`error`&&ht(e.msg)}catch{}}}}catch(e){ht(e.message||`Connection failed`)}pt(!1)}}async function Gt(){c&&await Wt(c)}(0,_.useEffect)(()=>{z.current=V,Ot.current=Gt});async function Kt(){if(!et||!c)return;let e=await E(`/api/studio/webcraft/grep`,{projectName:c,query:et});e?.matches&&rt(e.matches)}function qt(e){let t=g.findIndex(t=>t.name===e);t>=0&&(b(t),i(`files`))}function Jt(){window.open(`/api/studio/webcraft/download/${encodeURIComponent(c)}`,`_blank`)}async function Yt(e,t,n,r){t.endsWith(`.md`)||(t+=`.md`);let i={name:t,content:n,type:r},a;a=e.mode===`edit`&&e.idx!==null?We.map((t,n)=>n===e.idx?i:t):[...We,i],Ge(a),Ye(null);let o=c||`MyProject`;c||l(o),await E(`/api/studio/webcraft/skills/${encodeURIComponent(o)}`,{skills:a})}async function Xt(e){let t=We[e];!t||!confirm(`Eliminare "${t.name}"?`)||(await E(`/api/studio/webcraft/skills/${encodeURIComponent(c)}/delete`,{name:t.name}),Ge(We.filter((t,n)=>n!==e)))}async function Zt(e){let t=We[e];if(!t||!confirm(`Svuotare "${t.name}"? Il file rimane ma il contenuto viene cancellato.`))return;let n=We.map((t,n)=>n===e?{...t,content:``}:t);Ge(n),await E(`/api/studio/webcraft/skills/${encodeURIComponent(c)}`,{skills:n})}async function Qt(){let e=await T(`/api/studio/webcraft/projects`);e?.projects&&st(e.projects)}async function H(e){let t=await T(`/api/studio/webcraft/projects/load/${encodeURIComponent(e.name)}`);if(!t)return;let r=t.projectName??e.name;l(r),d(t.description??``),v(t.files??[]),b(0),n(`new`),i(`files`),Ie([]),Ge([]),qe(!1),pe([]),kt(r);let a=await T(`/api/studio/webcraft/projects/chat/load/${encodeURIComponent(r)}`);a?.chat&&Ie(a.chat);let o=await T(`/api/studio/webcraft/skills/${encodeURIComponent(r)}`);o?.skills&&(Ge(o.skills),qe(!0))}async function $t(e){confirm(`Eliminare: ${e.name} - ${e.dir}?`)&&(await E(`/api/studio/webcraft/projects/${encodeURIComponent(e.name)}`,{},`DELETE`),st(ot.filter(t=>t.name!==e.name)),c===e.name&&(l(``),v([]),Ie([]),d(``)))}async function en(){if(!He)return;let e=He.originalMessage;Ue(null),await Ft(e+`
854
- [Piano approvato — procedi con le modifiche]`,null,[])}function tn(e){e&&Array.from(e).forEach(e=>{let t=new FileReader;t.onload=t=>{let n=(t.target?.result).split(`,`)[1];Ve(t=>[...t,{name:e.name,mimeType:e.type,base64:n,size:e.size}])},t.readAsDataURL(e)})}let nn=c&&g.length>0,rn=g[y],U=ze||N;return(0,k.jsxs)(`div`,{className:Q.root,children:[(0,k.jsxs)(`div`,{className:Q.header,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:Q.title,children:[`⚙ WebCraft`,c?` — ${c}`:``]}),!c&&(0,k.jsx)(`div`,{className:Q.subtitle,children:`Genera progetti web completi con agenti AI`})]}),(0,k.jsxs)(`div`,{className:Q.headerTabs,children:[(0,k.jsx)(`button`,{className:`${Q.tabBtn} ${t===`new`?Q.tabActive:``}`,onClick:async()=>{if(!(ee.size>0&&!confirm(`${ee.size} unsaved file(s). Discard changes and create new project?`))){if(ct){try{await fetch(`/api/studio/webcraft/sandbox`,{method:`DELETE`})}catch{}lt(null)}v([]),b(0),S(null),w(null),te(new Set),Ie([]),l(``),d(``),Re(``),Ge([]),qe(!1),Pe(null),Ce(!1),L(!1),oe(!1),ce(null),n(`new`)}},children:`+ Nuovo`}),(0,k.jsx)(`button`,{className:`${Q.tabBtn} ${t===`projects`?Q.tabActive:``}`,onClick:()=>{n(`projects`),Qt()},children:`📁 Progetti`})]})]}),(0,k.jsx)(`div`,{className:Q.body,children:t===`projects`?(0,k.jsx)(`div`,{className:Q.projectsList,children:ot.length===0?(0,k.jsxs)(`div`,{className:Q.emptyProjects,children:[(0,k.jsx)(`span`,{className:Q.emptyIcon,children:`📁`}),(0,k.jsx)(`span`,{children:e(`webcraft.noProjects`)}),(0,k.jsx)(`span`,{className:Q.emptyHint,children:`Crea un progetto nella tab Nuovo`})]}):ot.map(e=>(0,k.jsxs)(`div`,{className:Q.projectCard,children:[(0,k.jsxs)(`div`,{className:Q.projectInfo,children:[(0,k.jsx)(`div`,{className:Q.projectName,children:e.name}),(0,k.jsx)(`div`,{className:Q.projectDesc,children:e.description}),(0,k.jsxs)(`div`,{className:Q.projectMeta,children:[(0,k.jsxs)(`span`,{children:[`📄 `,e.fileCount,` file`]}),(0,k.jsxs)(`span`,{children:[`📅 `,e.createdAt?new Date(e.createdAt).toLocaleString():``]})]})]}),(0,k.jsx)(`button`,{className:Q.openBtn,onClick:()=>H(e),children:`↗ Apri`}),(0,k.jsx)(`button`,{className:Q.deleteBtn,onClick:()=>$t(e),children:`🗑`})]},e.name))}):(0,k.jsxs)(`div`,{className:Q.editor,"data-mobile-view":a?o:void 0,children:[(0,k.jsxs)(`div`,{className:Q.examples,children:[(0,k.jsx)(`div`,{className:Q.sectionLabel,children:`Esempi`}),(0,k.jsx)(`div`,{className:Q.examplePills,children:eE.map(e=>(0,k.jsx)(`button`,{className:Q.examplePill,onClick:()=>{l(e.name),d(e.desc),Re(e.desc)},children:e.name},e.name))})]}),(0,k.jsxs)(`div`,{className:Q.editorCols,children:[(0,k.jsxs)(`div`,{className:Q.leftSidebar,children:[(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`Blocchi`}),tE.map(e=>(0,k.jsxs)(`label`,{className:Q.blockLabel,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:f[e.key],onChange:t=>p(n=>({...n,[e.key]:t.target.checked})),className:Q.blockCheck}),(0,k.jsx)(`span`,{children:e.icon}),(0,k.jsx)(`span`,{children:e.label})]},e.key))]}),f.auth&&(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsxs)(`div`,{className:Q.panelHeader,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`Campi Auth`}),(0,k.jsx)(`button`,{className:Q.addBtn,onClick:()=>h(e=>[...e,{label:`New field`,type:`text`,required:!1}]),children:`+ Campo`})]}),m.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.authField,children:[(0,k.jsx)(`input`,{value:e.label,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,label:e.target.value}:n)),className:Q.authFieldInput}),(0,k.jsx)(`select`,{value:e.type,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,type:e.target.value}:n)),className:Q.authFieldSelect,children:[`text`,`email`,`password`,`tel`,`date`,`number`].map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))}),(0,k.jsx)(`input`,{type:`checkbox`,checked:e.required,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,required:e.target.checked}:n)),title:`Required`,className:Q.authFieldReq}),(0,k.jsx)(`button`,{onClick:()=>h(e=>e.filter((e,n)=>n!==t)),className:Q.removeFieldBtn,children:`×`})]},t))]}),(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsxs)(`div`,{className:Q.panelHeader,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`🗂 Contesto AI`}),(0,k.jsx)(`button`,{className:Q.addBtn,onClick:()=>Ye({mode:`new`,idx:null,name:``,content:``,type:`skill`,generating:!1}),children:`+ Skill`})]}),We.length>0?(0,k.jsx)(`div`,{className:Q.skillsList,children:We.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.skillRow,children:[(0,k.jsx)(`span`,{className:Q.skillIcon,children:aE(e.type)}),(0,k.jsx)(`span`,{className:Q.skillName,title:e.name,children:e.name}),(0,k.jsx)(`span`,{className:`${Q.skillBadge} ${Q[`skillBadge_`+e.type]}`,children:e.type}),!e.content&&e.type!==`log`&&(0,k.jsx)(`span`,{className:Q.skillEmpty,children:`⚠`}),(0,k.jsx)(`button`,{className:Q.skillBtn,onClick:()=>Ye({mode:e.type===`log`?`view`:`edit`,idx:t,name:e.name,content:e.content,type:e.type,generating:!1}),children:e.type===`log`?`👁`:`✏`}),e.type!==`memory`&&e.type!==`provider`&&e.type!==`log`&&(0,k.jsx)(`button`,{className:Q.skillBtn,onClick:()=>Zt(t),children:`🗑`}),e.type===`log`&&(0,k.jsx)(`button`,{className:Q.skillBtn,onClick:()=>Xt(t),children:`🗑`})]},t))}):(0,k.jsx)(`div`,{className:Q.skillsEmpty,children:Ke?`Nessun file di contesto. Clicca "+ Skill" per aggiungerne uno.`:`Crea o carica un progetto per i file di contesto.`})]}),Xe.length>0&&(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`💾 Snapshot`}),Xe.slice(0,5).map(e=>{let t=e.ts.replace(`T`,` `).slice(0,16);return(0,k.jsxs)(`div`,{className:Q.snapshotRow,children:[(0,k.jsx)(`span`,{className:Q.snapshotTs,children:t}),(0,k.jsxs)(`span`,{className:Q.snapshotCount,children:[e.fileCount,`f`]}),(0,k.jsx)(`button`,{className:Q.snapshotBtn,onClick:()=>Vt(e.ts),children:`↺`})]},e.ts)})]}),N&&(0,k.jsx)(`div`,{className:Q.genStatus,children:`⏳ Generazione...`}),we&&(0,k.jsxs)(`div`,{className:Q.repairStatus,children:[(0,k.jsx)(`div`,{className:Q.repairStatusTitle,children:`🔧 Correzione automatica...`}),(0,k.jsxs)(`div`,{className:Q.repairStatusProg,children:[Ee,` / `,De,` file`]}),(0,k.jsx)(`div`,{className:Q.repairStatusFile,children:ke})]}),g.length>0&&!N&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:Q.actionRow,children:[(0,k.jsx)(`button`,{className:Q.actionBtn,onClick:Jt,children:`⬇ ZIP`}),(0,k.jsx)(`button`,{className:Q.actionBtnIcon,title:`Syntax check`,onClick:Ht,children:`✅`}),(0,k.jsx)(`button`,{className:`${Q.actionBtnIcon} ${Qe?Q.actionBtnActive:``}`,title:`Grep`,onClick:()=>$e(!Qe),children:`🔍`}),(0,k.jsx)(`button`,{className:Q.actionBtnIcon,title:`Snapshot`,onClick:zt,children:`💾`})]}),g.some(e=>e._error||e._syntaxError)&&!we&&(0,k.jsx)(`button`,{className:Q.repairBtn,onClick:V,children:`🔧 Correggi tutti i file rossi`}),(0,k.jsx)(`button`,{className:Q.sandboxBtn,onClick:()=>{c?Wt(c):i(`preview`)},children:ft?`⏳ Starting...`:ct?`🌐 Sandbox Live`:`▶ Sandbox`}),Ne&&(0,k.jsxs)(`div`,{className:Q.statsBar,children:[(0,k.jsxs)(`span`,{children:[`⏱ `,Ne.seconds>=60?`${Math.floor(Ne.seconds/60)}m ${Ne.seconds%60}s`:`${Ne.seconds}s`]}),(0,k.jsxs)(`span`,{children:[`↑ `,Ne.tokIn.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`↓ `,Ne.tokOut.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`📄 `,Ne.files,` file`]})]})]})]}),(0,k.jsxs)(`div`,{className:Q.rightPanel,children:[(0,k.jsxs)(`div`,{className:Q.rightTabBar,children:[(0,k.jsx)(`button`,{className:`${Q.rightTab} ${r===`preview`?``:Q.rightTabActive}`,onClick:()=>i(`files`),children:`📄 File`}),(0,k.jsx)(`button`,{className:`${Q.rightTab} ${r===`preview`?Q.rightTabActive:``}`,onClick:()=>i(`preview`),children:`🌐 Sandbox`})]}),we&&(0,k.jsxs)(`div`,{className:Q.repairBar,children:[(0,k.jsxs)(`div`,{className:Q.repairBarRow,children:[(0,k.jsx)(`span`,{className:Q.repairBarIcon,children:`🔧`}),(0,k.jsx)(`span`,{className:Q.repairBarLabel,children:`Auto-fix`}),(0,k.jsx)(`span`,{className:Q.repairBarFile,children:ke}),(0,k.jsxs)(`span`,{className:Q.repairBarCounter,children:[Ee,` / `,De]}),(0,k.jsx)(`span`,{className:Q.repairBarTime,children:R}),(0,k.jsx)(`button`,{className:Q.stopBtn,onClick:Lt,children:`⏹ Stop`})]}),(0,k.jsx)(`div`,{className:Q.progressTrack,children:(0,k.jsx)(`div`,{className:Q.repairProgress,style:{width:De>0?`${Math.round(Ee/De*100)}%`:`0%`}})})]}),N&&(0,k.jsxs)(`div`,{className:Q.genBar,children:[(0,k.jsxs)(`div`,{className:Q.genBarRow,children:[(0,k.jsx)(`span`,{className:Q.genBarRobot,children:`🤖`}),(0,k.jsx)(`span`,{className:Q.genBarLabel,children:I.total===0?`Pianificazione...`:`Generazione`}),(0,k.jsx)(`span`,{className:Q.genBarFile,children:(I.name||``).split(`,`)[0].trim()}),(0,k.jsx)(`span`,{className:Q.genBarCounter,children:I.total>0?`${I.fi} / ${I.total}`:``}),(0,k.jsx)(`span`,{className:Q.genBarCounter,children:je.tokIn+je.tokOut>0?`↑${jt(je.tokIn)} ↓${jt(je.tokOut)}`:``}),(0,k.jsx)(`span`,{className:Q.genBarTime,children:vt}),(0,k.jsxs)(`span`,{className:Q.genDots,children:[(0,k.jsx)(`span`,{className:`${Q.dot} ${Q.dot1}`}),(0,k.jsx)(`span`,{className:`${Q.dot} ${Q.dot2}`}),(0,k.jsx)(`span`,{className:`${Q.dot} ${Q.dot3}`})]})]}),(0,k.jsx)(`div`,{className:Q.progressTrack,children:(0,k.jsx)(`div`,{className:Q.genProgress,style:{width:I.total>0?`${Math.round(I.fi/I.total*100)}%`:`0%`}})})]}),r===`preview`?(0,k.jsxs)(`div`,{className:Q.sandboxWrap,children:[(0,k.jsxs)(`div`,{className:Q.sandboxStatusBar,children:[(0,k.jsx)(`span`,{className:Q.sandboxStatusDot,style:{background:ct?`#4ade80`:ft?`#facc15`:`#64748b`}}),(0,k.jsx)(`span`,{className:Q.sandboxStatusText,children:ct?`Live :${ct}`:ft?`Starting...`:`Stopped`}),ct&&(0,k.jsx)(`button`,{className:Q.sandboxReloadBtn,onClick:()=>{let e=document.querySelector(`iframe[title="WebCraft Sandbox"]`);e&&(e.src=e.src)},children:`↻`}),ct&&(0,k.jsx)(`button`,{className:Q.sandboxStopBtn,onClick:async()=>{lt(null),M([]);try{await fetch(`/api/studio/webcraft/sandbox`,{method:`DELETE`})}catch{}},children:`⏹`}),!ct&&!ft&&(0,k.jsx)(`button`,{className:Q.sandboxStartBtnSmall,onClick:()=>{c&&Wt(c)},children:`▶ Start`})]}),de.length>0&&(0,k.jsxs)(`div`,{className:Q.runtimeErrors,children:[(0,k.jsxs)(`div`,{className:Q.runtimeErrorsHeader,children:[(0,k.jsxs)(`span`,{children:[`❌ `,de.length,` runtime error`,de.length>1?`s`:``]}),(0,k.jsx)(`button`,{className:Q.runtimeErrorsFix,onClick:()=>{let e=`Fix these runtime errors. Use edit_file (or create_file if the file doesn't exist) to actually modify the source — do NOT respond with text descriptions. After each fix, call check_syntax to verify. If edit_file fails because old_text doesn't match, read_file again and retry with the exact text.\n\n${de.map(e=>`${e.message} (${e.source||``}:${e.line||0})`).join(`
855
- `)}`;fetch(`/api/studio/webcraft/sandbox/errors`,{method:`DELETE`}),M([]),i(`files`),Pt(e)},children:`🔧 Auto-fix`}),(0,k.jsx)(`button`,{className:Q.runtimeErrorsDismiss,onClick:()=>{fetch(`/api/studio/webcraft/sandbox/errors`,{method:`DELETE`}),M([])},children:`✕`})]}),de.slice(0,3).map((e,t)=>(0,k.jsxs)(`div`,{className:Q.runtimeErrorLine,children:[e.message,e.source?` — ${e.source.split(`/`).pop()}:${e.line}`:``]},t))]}),ct?(0,k.jsx)(`iframe`,{src:`http://localhost:${ct}`,className:Q.sandboxFrame,title:`WebCraft Sandbox`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`}):(0,k.jsxs)(`div`,{className:Q.sandboxEmpty,children:[(0,k.jsx)(`span`,{style:{fontSize:48},children:ft?`⏳`:mt?`❌`:`🌐`}),(0,k.jsx)(`span`,{style:{fontWeight:700,fontSize:16},children:ft?`Starting sandbox...`:mt?`Sandbox Error`:`Preview`}),mt&&(0,k.jsx)(`pre`,{style:{fontSize:11,maxWidth:600,textAlign:`left`,color:`#f87171`,background:`rgba(248,113,113,0.08)`,border:`1px solid rgba(248,113,113,0.2)`,borderRadius:6,padding:`8px 12px`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,margin:`8px 0`,lineHeight:1.5,maxHeight:200,overflow:`auto`},children:mt}),gt.length>0&&(0,k.jsxs)(`div`,{style:{width:`100%`,maxWidth:720,margin:`8px 0`,textAlign:`left`},children:[(0,k.jsxs)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,letterSpacing:`0.5px`,marginBottom:4},children:[`Sandbox log (`,gt.length,`)`]}),(0,k.jsx)(`pre`,{style:{fontSize:11,lineHeight:1.5,fontFamily:`SF Mono, Monaco, monospace`,background:`rgba(15, 23, 42, 0.6)`,border:`1px solid rgba(148, 163, 184, 0.18)`,borderRadius:6,padding:`8px 12px`,maxHeight:240,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,color:`#cbd5e1`},children:gt.slice(-40).map((e,t)=>(0,k.jsx)(`div`,{style:{color:e.kind===`error`?`#f87171`:e.kind===`warn`?`#fbbf24`:e.kind===`phase`?`#60a5fa`:e.kind===`status`?`#34d399`:`#94a3b8`},children:`[${e.kind}] ${e.msg}`},t))})]}),!ft&&(0,k.jsxs)(`button`,{className:Q.sandboxStartBtn,onClick:()=>{c&&Wt(c)},children:[`▶ `,mt?`Retry`:`Start Sandbox`]})]})]}):(0,k.jsx)(`div`,{className:Q.codeArea,children:g.length===0&&N?(0,k.jsx)(`div`,{className:Q.noFiles,children:(0,k.jsxs)(`div`,{className:Q.noFilesHero,children:[(0,k.jsx)(`span`,{className:Q.noFilesIcon,children:`⏳`}),(0,k.jsx)(`span`,{className:Q.noFilesTitle,children:`Pianificazione...`}),(0,k.jsx)(`span`,{className:Q.noFilesTagline,children:I.name||`Analisi della struttura del progetto in corso`})]})}):g.length===0?(0,k.jsxs)(`div`,{className:Q.noFiles,children:[(0,k.jsxs)(`div`,{className:Q.noFilesHero,children:[(0,k.jsx)(`span`,{className:Q.noFilesIcon,children:`🔨`}),(0,k.jsx)(`span`,{className:Q.noFilesTitle,children:`WebCraft`}),(0,k.jsx)(`span`,{className:Q.noFilesTagline,children:`Genera progetti web completi con AI`})]}),(0,k.jsxs)(`div`,{className:Q.noFilesSteps,children:[(0,k.jsxs)(`div`,{className:Q.noFilesStep,children:[(0,k.jsx)(`span`,{className:Q.noFilesStepNum,children:`1`}),(0,k.jsx)(`span`,{children:`Scegli un esempio o scrivi una descrizione nel box in basso`})]}),(0,k.jsxs)(`div`,{className:Q.noFilesStep,children:[(0,k.jsx)(`span`,{className:Q.noFilesStepNum,children:`2`}),(0,k.jsxs)(`span`,{children:[`Premi `,(0,k.jsx)(`strong`,{children:`▶ Genera`}),` — l'AI crea tutti i file del progetto`]})]}),(0,k.jsxs)(`div`,{className:Q.noFilesStep,children:[(0,k.jsx)(`span`,{className:Q.noFilesStepNum,children:`3`}),(0,k.jsx)(`span`,{children:`Chiedi modifiche in chat, scarica lo ZIP o avvia il Sandbox`})]})]}),(0,k.jsxs)(`div`,{className:Q.noFilesExamplesHint,children:[`💡 Prova: `,(0,k.jsx)(`button`,{className:Q.noFilesExampleBtn,onClick:()=>{let e=eE[0];l(e.name),d(e.desc),Re(e.desc)},children:`MySaaS`}),(0,k.jsx)(`button`,{className:Q.noFilesExampleBtn,onClick:()=>{let e=eE[1];l(e.name),d(e.desc),Re(e.desc)},children:`MyShop`}),(0,k.jsx)(`button`,{className:Q.noFilesExampleBtn,onClick:()=>{let e=eE[3];l(e.name),d(e.desc),Re(e.desc)},children:`MyPortfolio`})]})]}):(0,k.jsxs)(`div`,{className:Q.codeLayout,children:[(0,k.jsx)(`div`,{className:Q.ideTabBar,children:g.map((e,t)=>{let n=e._error||!!e._syntaxError,r=t===y;return(0,k.jsxs)(`button`,{className:`${Q.ideTab} ${r?Q.ideTabActive:``} ${n?Q.ideTabError:``} ${e._pending?Q.ideTabPending:``}`,onClick:()=>{b(t),w(null),S(null),N&&me.current!==null&&t!==me.current&&(he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{me.current!==null&&(b(me.current),S(null))},1e4))},title:e.name,children:[(0,k.jsx)(`span`,{className:Q.ideTabIcon,children:e._pending?`⌛`:n?`⚠`:rE(e.name)}),(0,k.jsx)(`span`,{className:Q.ideTabName,children:(e.name||``).split(`/`).pop()}),ee.has(e.name)&&(0,k.jsx)(`span`,{className:Q.ideTabUnsaved,children:`●`}),n&&(0,k.jsx)(`span`,{className:Q.ideTabDot})]},t)})}),xe&&(0,k.jsxs)(`div`,{className:Q.diffOverlay,children:[(0,k.jsxs)(`div`,{className:Q.diffOverlayHeader,children:[(0,k.jsxs)(`span`,{children:[`✏ Modifica proposta — `,(0,k.jsx)(`strong`,{children:xe.file})]}),(0,k.jsxs)(`div`,{className:Q.diffOverlayActions,children:[(0,k.jsx)(`button`,{className:Q.diffAcceptBtn,onClick:()=>{v(e=>e.map(e=>e.name===xe.file?{...e,content:xe.after}:e)),Se(null)},children:`✓ Accetta`}),(0,k.jsx)(`button`,{className:Q.diffRejectBtn,onClick:()=>Se(null),children:`✕ Rifiuta`})]})]}),(0,k.jsx)(`div`,{className:Q.diffOverlayBody,children:(0,k.jsx)(uE,{before:xe.before,after:xe.after})})]}),(0,k.jsxs)(`div`,{className:Q.codeRow,children:[(0,k.jsxs)(`div`,{className:Q.fileTreeWrap,children:[fe.length>0&&(0,k.jsxs)(`div`,{className:Q.scanBanner,children:[(0,k.jsx)(`span`,{className:Q.scanBannerIcon,children:`⚠`}),(0,k.jsxs)(`span`,{className:Q.scanBannerText,children:[fe.length,` issue`,fe.length>1?`s`:``]}),(0,k.jsx)(`button`,{className:Q.scanBannerFix,onClick:async()=>{i(`files`);try{let e=await E(`/api/studio/webcraft/auto-repair`,{projectName:c});if(e?.summary){let t=(e.repairs||[]).slice(0,20).map(e=>` • ${e.file} (${e.kind}${e.source?` from ${e.source}`:``})`).join(`
856
- `);Ie(n=>[...n,{role:`agent`,text:`🔧 Auto-repair: ${e.summary}\n${t}`,tools:[]}])}let t=await E(`/api/studio/webcraft/complete`,{projectName:c}),n=t?.htmlRewrites?.length||0,r=t?.llmFills?.length||0,i=t?.stubFallbacks?.length||0;if(n+r+i>0){let e=[];n&&e.push(...(t.htmlRewrites||[]).map(e=>` • ${e.from}: ${e.oldHref} → ${e.newHref} (point to real file)`)),r&&e.push(...(t.llmFills||[]).map(e=>` • ${e.target} (${e.length} bytes, LLM-generated)`)),i&&e.push(...(t.stubFallbacks||[]).map(e=>` • ${e} (stub fallback — LLM unavailable)`)),Ie(t=>[...t,{role:`agent`,text:`✨ Asset completion: ${n} HTML rewrites, ${r} via LLM${i?`, ${i} as stubs`:``}\n${e.join(`
857
- `)}`,tools:[]}])}let a=await E(`/api/studio/webcraft/extend-styles`,{projectName:c});a?.extended&&Ie(e=>[...e,{role:`agent`,text:`🎨 Styles auto-extended: ${a.file} (${a.sizeBefore}→${a.sizeAfter} bytes, coverage ${((a.coverageBefore||0)*100).toFixed(0)}%→${((a.coverageAfter||0)*100).toFixed(0)}%, ${(a.missingBefore||0)-(a.missingAfter||0)} new selectors covered)`,tools:[]}]),await It([...e?.filesRepaired||[],...e?.filesCreated||[],...(t?.htmlRewrites||[]).map(e=>e.from),...(t?.llmFills||[]).map(e=>e.target),...a?.file?[a.file]:[]],{}),await kt(c)}catch(e){console.error(`[fix] failed:`,e)}},children:`Fix`})]}),(0,k.jsx)(WT,{files:g,activeIndex:y,unsavedFiles:ee,errorFiles:new Set(fe.filter(e=>e.severity===`error`).map(e=>e.file)),onSelect:e=>{b(e),w(null),S(null),N&&me.current!==null&&e!==me.current&&(he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{me.current!==null&&(b(me.current),S(null))},1e4))}})]}),(0,k.jsx)(`div`,{className:Q.codeEditorWrap,children:rn&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:Q.codeHeader,children:[(0,k.jsx)(`span`,{className:Q.codeFileIcon,children:rE(rn.name)}),(0,k.jsx)(`span`,{className:Q.codeFileName,children:rn.name}),rn.content&&!rn._error&&(0,k.jsxs)(`span`,{className:Q.codeFileMeta,children:[(rn.content||``).split(`
858
- `).length,` righe · `,iE(rn.content||``)]}),!rn._pending&&!rn._error&&rn.content&&(0,k.jsx)(`button`,{className:`${Q.editToggleBtn} ${C===null?``:Q.editToggleBtnActive}`,onClick:()=>{C===null?w(rn.content):(v(e=>e.map((e,t)=>t===y?{...e,content:C}:e)),E(`/api/studio/webcraft/file/write`,{projectName:c,path:rn.name,content:C}),w(null))},children:C===null?`✏ Modifica`:`💾 Salva`}),(0,k.jsx)(`button`,{className:Q.headerIconBtn,title:`Split view`,onClick:()=>ce(se===null?+(y===0&&g.length>1):null),children:`⫼`}),(0,k.jsx)(`button`,{className:`${Q.headerIconBtn} ${A?Q.headerIconBtnActive:``}`,title:`Terminal`,onClick:()=>oe(!A),children:`⌨`}),(0,k.jsx)(`button`,{className:Q.headerIconBtn,title:`Development Guide`,onClick:()=>ue(!0),children:`📖`})]}),ne&&(0,k.jsxs)(`div`,{className:Q.findBar,children:[(0,k.jsx)(`input`,{className:Q.findInput,value:D,onChange:e=>ie(e.target.value),placeholder:`Find...`,autoFocus:!0}),(0,k.jsx)(`input`,{className:Q.findInput,value:O,onChange:e=>ae(e.target.value),placeholder:`Replace...`}),(0,k.jsx)(`span`,{className:Q.findCount,children:D?((rn.content||``).match(new RegExp(D.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`))?.length||0)+` found`:``}),(0,k.jsx)(`button`,{className:Q.findBtn,onClick:()=>{!D||C===null||w(C.replace(new RegExp(D.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`i`),O))},children:`Replace`}),(0,k.jsx)(`button`,{className:Q.findBtn,onClick:()=>{!D||C===null||w(C.replace(new RegExp(D.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`),O))},children:`All`}),(0,k.jsx)(`button`,{className:Q.findClose,onClick:()=>re(!1),children:`×`})]}),rn._error&&(0,k.jsx)(`div`,{className:Q.fileError,children:`⚠ Generazione fallita — chiedi al modello di rigenerare questo file`}),rn._syntaxError&&!rn._error&&(0,k.jsxs)(`div`,{className:Q.fileSyntaxError,children:[`⚠ Syntax error: `,rn._syntaxError]}),N&&x!==null?(0,k.jsx)(`pre`,{className:Q.streamingPre,ref:e=>{e&&ge.current&&(e.scrollTop=e.scrollHeight)},onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<50?ge.current=!0:(ge.current=!1,_e.current&&clearTimeout(_e.current),_e.current=setTimeout(()=>{ge.current=!0},15e3))},dangerouslySetInnerHTML:{__html:QT(x||``,(rn.name.split(`.`).pop()||`js`).toLowerCase())+`<span class="`+Q.streamingCursor+`">▋</span>`}}):(0,k.jsx)(RT,{value:C===null?rn.content||``:C,filename:rn.name,readOnly:C===null,projectName:c,onChange:e=>{w(e),rn&&te(e=>new Set(e).add(rn.name))},onSave:e=>{v(t=>t.map((t,n)=>n===y?{...t,content:e}:t)),E(`/api/studio/webcraft/file/write`,{projectName:c,path:rn.name,content:e}),w(null),te(e=>{let t=new Set(e);return t.delete(rn.name),t})}})]})}),se!==null&&g[se]&&(0,k.jsxs)(`div`,{className:Q.codeEditorWrap,children:[(0,k.jsxs)(`div`,{className:Q.codeHeader,children:[(0,k.jsx)(`span`,{className:Q.codeFileIcon,children:rE(g[se].name)}),(0,k.jsx)(`span`,{className:Q.codeFileName,children:g[se].name}),(0,k.jsx)(`button`,{className:Q.headerIconBtn,onClick:()=>ce(null),children:`✕`})]}),(0,k.jsx)(RT,{value:g[se].content||``,filename:g[se].name,readOnly:!0})]})]}),A&&(0,k.jsxs)(`div`,{className:Q.terminalPanel,children:[(0,k.jsxs)(`div`,{className:Q.terminalHeader,children:[(0,k.jsx)(`span`,{className:Q.terminalTitle,children:`Terminal`}),(0,k.jsx)(`button`,{className:Q.terminalClose,onClick:()=>oe(!1),children:`✕`})]}),(0,k.jsx)(YT,{projectDir:c||void 0})]})]})})]})]})]})}),He&&t!==`projects`&&(0,k.jsxs)(`div`,{className:Q.planBanner,children:[(0,k.jsx)(`div`,{className:Q.planTitle,children:`📌 Piano proposto — approva per eseguire`}),(0,k.jsx)(`pre`,{className:Q.planText,children:He.plan}),(0,k.jsxs)(`div`,{className:Q.planActions,children:[(0,k.jsx)(`button`,{className:Q.planApprove,onClick:en,children:`✓ Esegui`}),(0,k.jsx)(`button`,{className:Q.planReject,onClick:()=>Ue(null),children:`✕ Annulla`})]})]}),Qe&&t!==`projects`&&(0,k.jsxs)(`div`,{className:Q.grepPanel,children:[(0,k.jsxs)(`div`,{className:Q.grepRow,children:[(0,k.jsx)(`input`,{className:Q.grepInput,value:et,onChange:e=>tt(e.target.value),onKeyDown:e=>e.key===`Enter`&&Kt(),placeholder:`Cerca nel codice...`}),(0,k.jsx)(`button`,{className:Q.grepBtn,onClick:Kt,children:`🔍`}),(0,k.jsx)(`button`,{className:Q.grepClose,onClick:()=>$e(!1),children:`×`})]}),nt.length>0&&(0,k.jsxs)(`div`,{className:Q.grepCount,children:[nt.length,` risultati`]}),(0,k.jsx)(`div`,{className:Q.grepResults,children:nt.length===0?(0,k.jsx)(`div`,{className:Q.grepEmpty,children:`Nessun risultato.`}):nt.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.grepMatch,onClick:()=>qt(e.file),children:[(0,k.jsxs)(`span`,{className:Q.grepMatchFile,children:[e.file,`:`,e.lineNum]}),(0,k.jsx)(`pre`,{className:Q.grepMatchLine,children:e.line})]},t))})]}),it.length>0&&t!==`projects`&&(0,k.jsxs)(`div`,{className:Q.diffPanel,children:[(0,k.jsxs)(`div`,{className:Q.diffHeader,children:[(0,k.jsxs)(`span`,{children:[`🔌 Diff — `,it.length,` file modificati`]}),(0,k.jsx)(`button`,{className:Q.diffClose,onClick:()=>at([]),children:`✕ Chiudi`})]}),it.map((e,t)=>{let n=(e.after||``).split(`
853
+ `);i=a.pop()??``;for(let e of a){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);(e.type===`phase`||e.type===`status`||e.type===`log`||e.type===`warn`||e.type===`error`)&&yt(t=>[...t.slice(-49),{kind:e.type,msg:String(e.msg||``),ts:Date.now()}]),e.type===`ready`&&e.port?(dt(e.port),ht(!1)):e.type===`error`&&_t(e.msg)}catch{}}}}catch(e){_t(e.message||`Connection failed`)}ht(!1)}}async function qt(){c&&await Kt(c)}(0,_.useEffect)(()=>{Ot.current=Gt,At.current=qt});async function Jt(){if(!nt||!c)return;let e=await E(`/api/studio/webcraft/grep`,{projectName:c,query:nt});e?.matches&&at(e.matches)}function Yt(e){let t=g.findIndex(t=>t.name===e);t>=0&&(b(t),i(`files`))}function Xt(){window.open(`/api/studio/webcraft/download/${encodeURIComponent(c)}`,`_blank`)}async function Zt(e,t,n,r){t.endsWith(`.md`)||(t+=`.md`);let i={name:t,content:n,type:r},a;a=e.mode===`edit`&&e.idx!==null?Ke.map((t,n)=>n===e.idx?i:t):[...Ke,i],qe(a),Ze(null);let o=c||`MyProject`;c||l(o),await E(`/api/studio/webcraft/skills/${encodeURIComponent(o)}`,{skills:a})}async function Qt(e){let t=Ke[e];!t||!confirm(`Eliminare "${t.name}"?`)||(await E(`/api/studio/webcraft/skills/${encodeURIComponent(c)}/delete`,{name:t.name}),qe(Ke.filter((t,n)=>n!==e)))}async function H(e){let t=Ke[e];if(!t||!confirm(`Svuotare "${t.name}"? Il file rimane ma il contenuto viene cancellato.`))return;let n=Ke.map((t,n)=>n===e?{...t,content:``}:t);qe(n),await E(`/api/studio/webcraft/skills/${encodeURIComponent(c)}`,{skills:n})}async function $t(){let e=await T(`/api/studio/webcraft/projects`);e?.projects&&lt(e.projects)}async function en(e){let t=await T(`/api/studio/webcraft/projects/load/${encodeURIComponent(e.name)}`);if(!t)return;let r=t.projectName??e.name;l(r),d(t.description??``),v(t.files??[]),b(0),n(`new`),i(`files`),Re([]),qe([]),Ye(!1),pe([]),jt(r);let a=await T(`/api/studio/webcraft/projects/chat/load/${encodeURIComponent(r)}`);a?.chat&&Re(a.chat);let o=await T(`/api/studio/webcraft/skills/${encodeURIComponent(r)}`);o?.skills&&(qe(o.skills),Ye(!0))}async function tn(e){confirm(`Eliminare: ${e.name} - ${e.dir}?`)&&(await E(`/api/studio/webcraft/projects/${encodeURIComponent(e.name)}`,{},`DELETE`),lt(ct.filter(t=>t.name!==e.name)),c===e.name&&(l(``),v([]),Re([]),d(``)))}async function nn(){if(!We)return;let e=We.originalMessage;Ge(null),await Lt(e+`
854
+ [Piano approvato — procedi con le modifiche]`,null,[])}function rn(e){e&&Array.from(e).forEach(e=>{let t=new FileReader;t.onload=t=>{let n=(t.target?.result).split(`,`)[1];Ue(t=>[...t,{name:e.name,mimeType:e.type,base64:n,size:e.size}])},t.readAsDataURL(e)})}let U=c&&g.length>0,an=g[y],on=Be||we;return(0,k.jsxs)(`div`,{className:Q.root,children:[(0,k.jsxs)(`div`,{className:Q.header,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:Q.title,children:[`⚙ WebCraft`,c?` — ${c}`:``]}),!c&&(0,k.jsx)(`div`,{className:Q.subtitle,children:`Genera progetti web completi con agenti AI`})]}),(0,k.jsxs)(`div`,{className:Q.headerTabs,children:[(0,k.jsx)(`button`,{className:`${Q.tabBtn} ${t===`new`?Q.tabActive:``}`,onClick:async()=>{if(!(ee.size>0&&!confirm(`${ee.size} unsaved file(s). Discard changes and create new project?`))){if(ut){try{await fetch(`/api/studio/webcraft/sandbox`,{method:`DELETE`})}catch{}dt(null)}v([]),b(0),S(null),w(null),te(new Set),Re([]),l(``),d(``),L(``),qe([]),Ye(!1),Ie(null),Te(!1),Ve(!1),oe(!1),ce(null),n(`new`)}},children:`+ Nuovo`}),(0,k.jsx)(`button`,{className:`${Q.tabBtn} ${t===`projects`?Q.tabActive:``}`,onClick:()=>{n(`projects`),$t()},children:`📁 Progetti`})]})]}),(0,k.jsx)(`div`,{className:Q.body,children:t===`projects`?(0,k.jsx)(`div`,{className:Q.projectsList,children:ct.length===0?(0,k.jsxs)(`div`,{className:Q.emptyProjects,children:[(0,k.jsx)(`span`,{className:Q.emptyIcon,children:`📁`}),(0,k.jsx)(`span`,{children:e(`webcraft.noProjects`)}),(0,k.jsx)(`span`,{className:Q.emptyHint,children:`Crea un progetto nella tab Nuovo`})]}):ct.map(e=>(0,k.jsxs)(`div`,{className:Q.projectCard,children:[(0,k.jsxs)(`div`,{className:Q.projectInfo,children:[(0,k.jsx)(`div`,{className:Q.projectName,children:e.name}),(0,k.jsx)(`div`,{className:Q.projectDesc,children:e.description}),(0,k.jsxs)(`div`,{className:Q.projectMeta,children:[(0,k.jsxs)(`span`,{children:[`📄 `,e.fileCount,` file`]}),(0,k.jsxs)(`span`,{children:[`📅 `,e.createdAt?new Date(e.createdAt).toLocaleString():``]})]})]}),(0,k.jsx)(`button`,{className:Q.openBtn,onClick:()=>en(e),children:`↗ Apri`}),(0,k.jsx)(`button`,{className:Q.deleteBtn,onClick:()=>tn(e),children:`🗑`})]},e.name))}):(0,k.jsxs)(`div`,{className:Q.editor,"data-mobile-view":a?o:void 0,children:[(0,k.jsxs)(`div`,{className:Q.examples,children:[(0,k.jsx)(`div`,{className:Q.sectionLabel,children:`Esempi`}),(0,k.jsx)(`div`,{className:Q.examplePills,children:eE.map(e=>(0,k.jsx)(`button`,{className:Q.examplePill,onClick:()=>{l(e.name),d(e.desc),L(e.desc)},children:e.name},e.name))})]}),(0,k.jsxs)(`div`,{className:Q.editorCols,children:[(0,k.jsxs)(`div`,{className:Q.leftSidebar,children:[(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`Blocchi`}),tE.map(e=>(0,k.jsxs)(`label`,{className:Q.blockLabel,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:f[e.key],onChange:t=>p(n=>({...n,[e.key]:t.target.checked})),className:Q.blockCheck}),(0,k.jsx)(`span`,{children:e.icon}),(0,k.jsx)(`span`,{children:e.label})]},e.key))]}),f.auth&&(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsxs)(`div`,{className:Q.panelHeader,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`Campi Auth`}),(0,k.jsx)(`button`,{className:Q.addBtn,onClick:()=>h(e=>[...e,{label:`New field`,type:`text`,required:!1}]),children:`+ Campo`})]}),m.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.authField,children:[(0,k.jsx)(`input`,{value:e.label,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,label:e.target.value}:n)),className:Q.authFieldInput}),(0,k.jsx)(`select`,{value:e.type,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,type:e.target.value}:n)),className:Q.authFieldSelect,children:[`text`,`email`,`password`,`tel`,`date`,`number`].map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))}),(0,k.jsx)(`input`,{type:`checkbox`,checked:e.required,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,required:e.target.checked}:n)),title:`Required`,className:Q.authFieldReq}),(0,k.jsx)(`button`,{onClick:()=>h(e=>e.filter((e,n)=>n!==t)),className:Q.removeFieldBtn,children:`×`})]},t))]}),(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsxs)(`div`,{className:Q.panelHeader,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`🗂 Contesto AI`}),(0,k.jsx)(`button`,{className:Q.addBtn,onClick:()=>Ze({mode:`new`,idx:null,name:``,content:``,type:`skill`,generating:!1}),children:`+ Skill`})]}),Ke.length>0?(0,k.jsx)(`div`,{className:Q.skillsList,children:Ke.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.skillRow,children:[(0,k.jsx)(`span`,{className:Q.skillIcon,children:aE(e.type)}),(0,k.jsx)(`span`,{className:Q.skillName,title:e.name,children:e.name}),(0,k.jsx)(`span`,{className:`${Q.skillBadge} ${Q[`skillBadge_`+e.type]}`,children:e.type}),!e.content&&e.type!==`log`&&(0,k.jsx)(`span`,{className:Q.skillEmpty,children:`⚠`}),(0,k.jsx)(`button`,{className:Q.skillBtn,onClick:()=>Ze({mode:e.type===`log`?`view`:`edit`,idx:t,name:e.name,content:e.content,type:e.type,generating:!1}),children:e.type===`log`?`👁`:`✏`}),e.type!==`memory`&&e.type!==`provider`&&e.type!==`log`&&(0,k.jsx)(`button`,{className:Q.skillBtn,onClick:()=>H(t),children:`🗑`}),e.type===`log`&&(0,k.jsx)(`button`,{className:Q.skillBtn,onClick:()=>Qt(t),children:`🗑`})]},t))}):(0,k.jsx)(`div`,{className:Q.skillsEmpty,children:Je?`Nessun file di contesto. Clicca "+ Skill" per aggiungerne uno.`:`Crea o carica un progetto per i file di contesto.`})]}),Qe.length>0&&(0,k.jsxs)(`div`,{className:Q.panel,children:[(0,k.jsx)(`div`,{className:Q.panelTitle,children:`💾 Snapshot`}),Qe.slice(0,5).map(e=>{let t=e.ts.replace(`T`,` `).slice(0,16);return(0,k.jsxs)(`div`,{className:Q.snapshotRow,children:[(0,k.jsx)(`span`,{className:Q.snapshotTs,children:t}),(0,k.jsxs)(`span`,{className:Q.snapshotCount,children:[e.fileCount,`f`]}),(0,k.jsx)(`button`,{className:Q.snapshotBtn,onClick:()=>V(e.ts),children:`↺`})]},e.ts)})]}),we&&(0,k.jsx)(`div`,{className:Q.genStatus,children:`⏳ Generazione...`}),Ee&&(0,k.jsxs)(`div`,{className:Q.repairStatus,children:[(0,k.jsx)(`div`,{className:Q.repairStatusTitle,children:`🔧 Correzione automatica...`}),(0,k.jsxs)(`div`,{className:Q.repairStatusProg,children:[De,` / `,ke,` file`]}),(0,k.jsx)(`div`,{className:Q.repairStatusFile,children:I})]}),g.length>0&&!we&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:Q.actionRow,children:[(0,k.jsx)(`button`,{className:Q.actionBtn,onClick:Xt,children:`⬇ ZIP`}),(0,k.jsx)(`button`,{className:Q.actionBtnIcon,title:`Syntax check`,onClick:Wt,children:`✅`}),(0,k.jsx)(`button`,{className:`${Q.actionBtnIcon} ${et?Q.actionBtnActive:``}`,title:`Grep`,onClick:()=>tt(!et),children:`🔍`}),(0,k.jsx)(`button`,{className:Q.actionBtnIcon,title:`Snapshot`,onClick:Vt,children:`💾`})]}),g.some(e=>e._error||e._syntaxError)&&!Ee&&(0,k.jsx)(`button`,{className:Q.repairBtn,onClick:Gt,children:`🔧 Correggi tutti i file rossi`}),(0,k.jsx)(`button`,{className:Q.sandboxBtn,onClick:()=>{c?Kt(c):i(`preview`)},children:mt?`⏳ Starting...`:ut?`🌐 Sandbox Live`:`▶ Sandbox`}),Fe&&(0,k.jsxs)(`div`,{className:Q.statsBar,children:[(0,k.jsxs)(`span`,{children:[`⏱ `,Fe.seconds>=60?`${Math.floor(Fe.seconds/60)}m ${Fe.seconds%60}s`:`${Fe.seconds}s`]}),(0,k.jsxs)(`span`,{children:[`↑ `,Fe.tokIn.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`↓ `,Fe.tokOut.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`📄 `,Fe.files,` file`]})]})]})]}),(0,k.jsxs)(`div`,{className:Q.rightPanel,children:[(0,k.jsxs)(`div`,{className:Q.rightTabBar,children:[(0,k.jsx)(`button`,{className:`${Q.rightTab} ${r===`preview`?``:Q.rightTabActive}`,onClick:()=>i(`files`),children:`📄 File`}),(0,k.jsx)(`button`,{className:`${Q.rightTab} ${r===`preview`?Q.rightTabActive:``}`,onClick:()=>i(`preview`),children:`🌐 Sandbox`})]}),Ee&&(0,k.jsxs)(`div`,{className:Q.repairBar,children:[(0,k.jsxs)(`div`,{className:Q.repairBarRow,children:[(0,k.jsx)(`span`,{className:Q.repairBarIcon,children:`🔧`}),(0,k.jsx)(`span`,{className:Q.repairBarLabel,children:`Auto-fix`}),(0,k.jsx)(`span`,{className:Q.repairBarFile,children:I}),(0,k.jsxs)(`span`,{className:Q.repairBarCounter,children:[De,` / `,ke]}),(0,k.jsx)(`span`,{className:Q.repairBarTime,children:xt}),(0,k.jsx)(`button`,{className:Q.stopBtn,onClick:zt,children:`⏹ Stop`})]}),(0,k.jsx)(`div`,{className:Q.progressTrack,children:(0,k.jsx)(`div`,{className:Q.repairProgress,style:{width:ke>0?`${Math.round(De/ke*100)}%`:`0%`}})})]}),we&&(0,k.jsxs)(`div`,{className:Q.genBar,children:[(0,k.jsxs)(`div`,{className:Q.genBarRow,children:[(0,k.jsx)(`span`,{className:Q.genBarRobot,children:`🤖`}),(0,k.jsx)(`span`,{className:Q.genBarLabel,children:je.total===0?`Pianificazione...`:`Generazione`}),(0,k.jsx)(`span`,{className:Q.genBarFile,children:(je.name||``).split(`,`)[0].trim()}),(0,k.jsx)(`span`,{className:Q.genBarCounter,children:je.total>0?`${je.fi} / ${je.total}`:``}),(0,k.jsx)(`span`,{className:Q.genBarCounter,children:Ne.tokIn+Ne.tokOut>0?`↑${B(Ne.tokIn)} ↓${B(Ne.tokOut)}`:``}),(0,k.jsx)(`span`,{className:Q.genBarTime,children:R}),(0,k.jsxs)(`span`,{className:Q.genDots,children:[(0,k.jsx)(`span`,{className:`${Q.dot} ${Q.dot1}`}),(0,k.jsx)(`span`,{className:`${Q.dot} ${Q.dot2}`}),(0,k.jsx)(`span`,{className:`${Q.dot} ${Q.dot3}`})]})]}),(0,k.jsx)(`div`,{className:Q.progressTrack,children:(0,k.jsx)(`div`,{className:Q.genProgress,style:{width:je.total>0?`${Math.round(je.fi/je.total*100)}%`:`0%`}})})]}),r===`preview`?(0,k.jsxs)(`div`,{className:Q.sandboxWrap,children:[(0,k.jsxs)(`div`,{className:Q.sandboxStatusBar,children:[(0,k.jsx)(`span`,{className:Q.sandboxStatusDot,style:{background:ut?`#4ade80`:mt?`#facc15`:`#64748b`}}),(0,k.jsx)(`span`,{className:Q.sandboxStatusText,children:ut?`Live :${ut}`:mt?`Starting...`:`Stopped`}),ut&&(0,k.jsx)(`button`,{className:Q.sandboxReloadBtn,onClick:()=>{let e=document.querySelector(`iframe[title="WebCraft Sandbox"]`);e&&(e.src=e.src)},children:`↻`}),ut&&(0,k.jsx)(`button`,{className:Q.sandboxStopBtn,onClick:async()=>{dt(null),M([]);try{await fetch(`/api/studio/webcraft/sandbox`,{method:`DELETE`})}catch{}},children:`⏹`}),!ut&&!mt&&(0,k.jsx)(`button`,{className:Q.sandboxStartBtnSmall,onClick:()=>{c&&Kt(c)},children:`▶ Start`})]}),de.length>0&&(0,k.jsxs)(`div`,{className:Q.runtimeErrors,children:[(0,k.jsxs)(`div`,{className:Q.runtimeErrorsHeader,children:[(0,k.jsxs)(`span`,{children:[`❌ `,de.length,` runtime error`,de.length>1?`s`:``]}),(0,k.jsx)(`button`,{className:Q.runtimeErrorsFix,onClick:()=>{let e=`Fix these runtime errors. Use edit_file (or create_file if the file doesn't exist) to actually modify the source — do NOT respond with text descriptions. After each fix, call check_syntax to verify. If edit_file fails because old_text doesn't match, read_file again and retry with the exact text.\n\n${de.map(e=>`${e.message} (${e.source||``}:${e.line||0})`).join(`
855
+ `)}`;fetch(`/api/studio/webcraft/sandbox/errors`,{method:`DELETE`}),M([]),i(`files`),It(e)},children:`🔧 Auto-fix`}),(0,k.jsx)(`button`,{className:Q.runtimeErrorsDismiss,onClick:()=>{fetch(`/api/studio/webcraft/sandbox/errors`,{method:`DELETE`}),M([])},children:`✕`})]}),de.slice(0,3).map((e,t)=>(0,k.jsxs)(`div`,{className:Q.runtimeErrorLine,children:[e.message,e.source?` — ${e.source.split(`/`).pop()}:${e.line}`:``]},t))]}),ut?(0,k.jsx)(`iframe`,{src:`http://localhost:${ut}`,className:Q.sandboxFrame,title:`WebCraft Sandbox`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`}):(0,k.jsxs)(`div`,{className:Q.sandboxEmpty,children:[(0,k.jsx)(`span`,{style:{fontSize:48},children:mt?`⏳`:gt?`❌`:`🌐`}),(0,k.jsx)(`span`,{style:{fontWeight:700,fontSize:16},children:mt?`Starting sandbox...`:gt?`Sandbox Error`:`Preview`}),gt&&(0,k.jsx)(`pre`,{style:{fontSize:11,maxWidth:600,textAlign:`left`,color:`#f87171`,background:`rgba(248,113,113,0.08)`,border:`1px solid rgba(248,113,113,0.2)`,borderRadius:6,padding:`8px 12px`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,margin:`8px 0`,lineHeight:1.5,maxHeight:200,overflow:`auto`},children:gt}),vt.length>0&&(0,k.jsxs)(`div`,{style:{width:`100%`,maxWidth:720,margin:`8px 0`,textAlign:`left`},children:[(0,k.jsxs)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,letterSpacing:`0.5px`,marginBottom:4},children:[`Sandbox log (`,vt.length,`)`]}),(0,k.jsx)(`pre`,{style:{fontSize:11,lineHeight:1.5,fontFamily:`SF Mono, Monaco, monospace`,background:`rgba(15, 23, 42, 0.6)`,border:`1px solid rgba(148, 163, 184, 0.18)`,borderRadius:6,padding:`8px 12px`,maxHeight:240,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,color:`#cbd5e1`},children:vt.slice(-40).map((e,t)=>(0,k.jsx)(`div`,{style:{color:e.kind===`error`?`#f87171`:e.kind===`warn`?`#fbbf24`:e.kind===`phase`?`#60a5fa`:e.kind===`status`?`#34d399`:`#94a3b8`},children:`[${e.kind}] ${e.msg}`},t))})]}),!mt&&(0,k.jsxs)(`button`,{className:Q.sandboxStartBtn,onClick:()=>{c&&Kt(c)},children:[`▶ `,gt?`Retry`:`Start Sandbox`]})]})]}):(0,k.jsx)(`div`,{className:Q.codeArea,children:g.length===0&&we?(0,k.jsx)(`div`,{className:Q.noFiles,children:(0,k.jsxs)(`div`,{className:Q.noFilesHero,children:[(0,k.jsx)(`span`,{className:Q.noFilesIcon,children:`⏳`}),(0,k.jsx)(`span`,{className:Q.noFilesTitle,children:`Pianificazione...`}),(0,k.jsx)(`span`,{className:Q.noFilesTagline,children:je.name||`Analisi della struttura del progetto in corso`})]})}):g.length===0?(0,k.jsxs)(`div`,{className:Q.noFiles,children:[(0,k.jsxs)(`div`,{className:Q.noFilesHero,children:[(0,k.jsx)(`span`,{className:Q.noFilesIcon,children:`🔨`}),(0,k.jsx)(`span`,{className:Q.noFilesTitle,children:`WebCraft`}),(0,k.jsx)(`span`,{className:Q.noFilesTagline,children:`Genera progetti web completi con AI`})]}),(0,k.jsxs)(`div`,{className:Q.noFilesSteps,children:[(0,k.jsxs)(`div`,{className:Q.noFilesStep,children:[(0,k.jsx)(`span`,{className:Q.noFilesStepNum,children:`1`}),(0,k.jsx)(`span`,{children:`Scegli un esempio o scrivi una descrizione nel box in basso`})]}),(0,k.jsxs)(`div`,{className:Q.noFilesStep,children:[(0,k.jsx)(`span`,{className:Q.noFilesStepNum,children:`2`}),(0,k.jsxs)(`span`,{children:[`Premi `,(0,k.jsx)(`strong`,{children:`▶ Genera`}),` — l'AI crea tutti i file del progetto`]})]}),(0,k.jsxs)(`div`,{className:Q.noFilesStep,children:[(0,k.jsx)(`span`,{className:Q.noFilesStepNum,children:`3`}),(0,k.jsx)(`span`,{children:`Chiedi modifiche in chat, scarica lo ZIP o avvia il Sandbox`})]})]}),(0,k.jsxs)(`div`,{className:Q.noFilesExamplesHint,children:[`💡 Prova: `,(0,k.jsx)(`button`,{className:Q.noFilesExampleBtn,onClick:()=>{let e=eE[0];l(e.name),d(e.desc),L(e.desc)},children:`MySaaS`}),(0,k.jsx)(`button`,{className:Q.noFilesExampleBtn,onClick:()=>{let e=eE[1];l(e.name),d(e.desc),L(e.desc)},children:`MyShop`}),(0,k.jsx)(`button`,{className:Q.noFilesExampleBtn,onClick:()=>{let e=eE[3];l(e.name),d(e.desc),L(e.desc)},children:`MyPortfolio`})]})]}):(0,k.jsxs)(`div`,{className:Q.codeLayout,children:[(0,k.jsx)(`div`,{className:Q.ideTabBar,children:g.map((e,t)=>{let n=e._error||!!e._syntaxError,r=t===y;return(0,k.jsxs)(`button`,{className:`${Q.ideTab} ${r?Q.ideTabActive:``} ${n?Q.ideTabError:``} ${e._pending?Q.ideTabPending:``}`,onClick:()=>{b(t),w(null),S(null),we&&ge.current!==null&&t!==ge.current&&(_e.current&&clearTimeout(_e.current),_e.current=setTimeout(()=>{ge.current!==null&&(b(ge.current),S(null))},1e4))},title:e.name,children:[(0,k.jsx)(`span`,{className:Q.ideTabIcon,children:e._pending?`⌛`:n?`⚠`:rE(e.name)}),(0,k.jsx)(`span`,{className:Q.ideTabName,children:(e.name||``).split(`/`).pop()}),ee.has(e.name)&&(0,k.jsx)(`span`,{className:Q.ideTabUnsaved,children:`●`}),n&&(0,k.jsx)(`span`,{className:Q.ideTabDot})]},t)})}),N&&(0,k.jsxs)(`div`,{className:Q.diffOverlay,children:[(0,k.jsxs)(`div`,{className:Q.diffOverlayHeader,children:[(0,k.jsxs)(`span`,{children:[`✏ Modifica proposta — `,(0,k.jsx)(`strong`,{children:N.file})]}),(0,k.jsxs)(`div`,{className:Q.diffOverlayActions,children:[(0,k.jsx)(`button`,{className:Q.diffAcceptBtn,onClick:()=>{v(e=>e.map(e=>e.name===N.file?{...e,content:N.after}:e)),Ce(null)},children:`✓ Accetta`}),(0,k.jsx)(`button`,{className:Q.diffRejectBtn,onClick:()=>Ce(null),children:`✕ Rifiuta`})]})]}),(0,k.jsx)(`div`,{className:Q.diffOverlayBody,children:(0,k.jsx)(uE,{before:N.before,after:N.after})})]}),(0,k.jsxs)(`div`,{className:Q.codeRow,children:[(0,k.jsxs)(`div`,{className:Q.fileTreeWrap,children:[fe.length>0&&(0,k.jsxs)(`div`,{className:Q.scanBanner,children:[(0,k.jsx)(`span`,{className:Q.scanBannerIcon,children:`⚠`}),(0,k.jsxs)(`span`,{className:Q.scanBannerText,children:[fe.length,` issue`,fe.length>1?`s`:``]}),(0,k.jsx)(`button`,{className:Q.scanBannerToggle,onClick:()=>he(!me),title:me?`Hide problems panel`:`Show problems panel`,children:me?`▴`:`▾`}),(0,k.jsx)(`button`,{className:Q.scanBannerFix,onClick:async()=>{i(`files`);try{let e=await E(`/api/studio/webcraft/auto-repair`,{projectName:c});if(e?.summary){let t=(e.repairs||[]).slice(0,20).map(e=>` • ${e.file} (${e.kind}${e.source?` from ${e.source}`:``})`).join(`
856
+ `);Re(n=>[...n,{role:`agent`,text:`🔧 Auto-repair: ${e.summary}\n${t}`,tools:[]}])}let t=await E(`/api/studio/webcraft/complete`,{projectName:c}),n=t?.htmlRewrites?.length||0,r=t?.llmFills?.length||0,i=t?.stubFallbacks?.length||0;if(n+r+i>0){let e=[];n&&e.push(...(t.htmlRewrites||[]).map(e=>` • ${e.from}: ${e.oldHref} → ${e.newHref} (point to real file)`)),r&&e.push(...(t.llmFills||[]).map(e=>` • ${e.target} (${e.length} bytes, LLM-generated)`)),i&&e.push(...(t.stubFallbacks||[]).map(e=>` • ${e} (stub fallback — LLM unavailable)`)),Re(t=>[...t,{role:`agent`,text:`✨ Asset completion: ${n} HTML rewrites, ${r} via LLM${i?`, ${i} as stubs`:``}\n${e.join(`
857
+ `)}`,tools:[]}])}let a=await E(`/api/studio/webcraft/extend-styles`,{projectName:c});a?.extended&&Re(e=>[...e,{role:`agent`,text:`🎨 Styles auto-extended: ${a.file} (${a.sizeBefore}→${a.sizeAfter} bytes, coverage ${((a.coverageBefore||0)*100).toFixed(0)}%→${((a.coverageAfter||0)*100).toFixed(0)}%, ${(a.missingBefore||0)-(a.missingAfter||0)} new selectors covered)`,tools:[]}]),await Rt([...e?.filesRepaired||[],...e?.filesCreated||[],...(t?.htmlRewrites||[]).map(e=>e.from),...(t?.llmFills||[]).map(e=>e.target),...a?.file?[a.file]:[]],{}),await jt(c)}catch(e){console.error(`[fix] failed:`,e)}},children:`Fix`})]}),fe.length>0&&me&&(()=>{let e=new Map;for(let t of fe)e.has(t.file)||e.set(t.file,[]),e.get(t.file).push(t);let t=/^Line (\d+):\s*(.+)$/;return(0,k.jsx)(`div`,{className:Q.problemsPanel,children:[...e.entries()].map(([e,n])=>{let r=n.filter(e=>e.severity===`error`).length,a=n.filter(e=>e.severity===`warning`).length;return(0,k.jsxs)(`div`,{className:Q.problemsGroup,children:[(0,k.jsxs)(`div`,{className:Q.problemsGroupHeader,onClick:()=>{let t=g.findIndex(t=>t.name===e);t>=0&&(b(t),w(null),S(null),i(`files`))},children:[(0,k.jsxs)(`span`,{children:[`📄 `,e]}),(0,k.jsxs)(`span`,{className:Q.problemsGroupCount,children:[r>0&&(0,k.jsxs)(`span`,{style:{color:`#f87171`},children:[r,` error`,r>1?`s`:``]}),r>0&&a>0&&(0,k.jsx)(`span`,{style:{color:`var(--dim)`},children:`, `}),a>0&&(0,k.jsxs)(`span`,{style:{color:`#facc15`},children:[a,` warning`,a>1?`s`:``]})]})]}),n.map((n,r)=>{let a=n.message.match(t),o=a?parseInt(a[1]):null,s=a?a[2]:n.message,c=n.severity===`error`?`✕`:n.severity===`warning`?`⚠`:`ℹ`,l=n.severity===`error`?Q.problemsIconError:n.severity===`warning`?Q.problemsIconWarning:Q.problemsIconInfo;return(0,k.jsxs)(`div`,{className:Q.problemsItem,onClick:()=>{let t=g.findIndex(t=>t.name===e);t>=0&&(b(t),w(null),S(null),i(`files`),o&&setTimeout(()=>{let e=document.querySelector(`.cm-editor .cm-scroller`);e&&(e.scrollTop=Math.max(0,(o-5)*18))},100))},title:`Click to open ${e}${o?` at line `+o:``}`,children:[(0,k.jsx)(`span`,{className:`${Q.problemsIcon} ${l}`,children:c}),(0,k.jsx)(`span`,{className:Q.problemsMsg,children:s}),o&&(0,k.jsxs)(`span`,{className:Q.problemsLine,children:[`[L`,o,`]`]})]},r)})]},e)})})})(),(0,k.jsx)(WT,{files:g,activeIndex:y,unsavedFiles:ee,errorFiles:new Set(fe.filter(e=>e.severity===`error`).map(e=>e.file)),onSelect:e=>{b(e),w(null),S(null),we&&ge.current!==null&&e!==ge.current&&(_e.current&&clearTimeout(_e.current),_e.current=setTimeout(()=>{ge.current!==null&&(b(ge.current),S(null))},1e4))}})]}),(0,k.jsx)(`div`,{className:Q.codeEditorWrap,children:an&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:Q.codeHeader,children:[(0,k.jsx)(`span`,{className:Q.codeFileIcon,children:rE(an.name)}),(0,k.jsx)(`span`,{className:Q.codeFileName,children:an.name}),an.content&&!an._error&&(0,k.jsxs)(`span`,{className:Q.codeFileMeta,children:[(an.content||``).split(`
858
+ `).length,` righe · `,iE(an.content||``)]}),!an._pending&&!an._error&&an.content&&(0,k.jsx)(`button`,{className:`${Q.editToggleBtn} ${C===null?``:Q.editToggleBtnActive}`,onClick:()=>{C===null?w(an.content):(v(e=>e.map((e,t)=>t===y?{...e,content:C}:e)),E(`/api/studio/webcraft/file/write`,{projectName:c,path:an.name,content:C}),w(null))},children:C===null?`✏ Modifica`:`💾 Salva`}),(0,k.jsx)(`button`,{className:Q.headerIconBtn,title:`Split view`,onClick:()=>ce(se===null?+(y===0&&g.length>1):null),children:`⫼`}),(0,k.jsx)(`button`,{className:`${Q.headerIconBtn} ${A?Q.headerIconBtnActive:``}`,title:`Terminal`,onClick:()=>oe(!A),children:`⌨`}),(0,k.jsx)(`button`,{className:Q.headerIconBtn,title:`Development Guide`,onClick:()=>ue(!0),children:`📖`})]}),ne&&(0,k.jsxs)(`div`,{className:Q.findBar,children:[(0,k.jsx)(`input`,{className:Q.findInput,value:D,onChange:e=>ie(e.target.value),placeholder:`Find...`,autoFocus:!0}),(0,k.jsx)(`input`,{className:Q.findInput,value:O,onChange:e=>ae(e.target.value),placeholder:`Replace...`}),(0,k.jsx)(`span`,{className:Q.findCount,children:D?((an.content||``).match(new RegExp(D.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`))?.length||0)+` found`:``}),(0,k.jsx)(`button`,{className:Q.findBtn,onClick:()=>{!D||C===null||w(C.replace(new RegExp(D.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`i`),O))},children:`Replace`}),(0,k.jsx)(`button`,{className:Q.findBtn,onClick:()=>{!D||C===null||w(C.replace(new RegExp(D.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`),O))},children:`All`}),(0,k.jsx)(`button`,{className:Q.findClose,onClick:()=>re(!1),children:`×`})]}),an._error&&(0,k.jsx)(`div`,{className:Q.fileError,children:`⚠ Generazione fallita — chiedi al modello di rigenerare questo file`}),an._syntaxError&&!an._error&&(0,k.jsxs)(`div`,{className:Q.fileSyntaxError,children:[`⚠ Syntax error: `,an._syntaxError]}),we&&x!==null&&y===ge.current?(0,k.jsx)(`pre`,{className:Q.streamingPre,ref:e=>{e&&ve.current&&(e.scrollTop=e.scrollHeight)},onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<50?ve.current=!0:(ve.current=!1,ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{ve.current=!0},15e3))},dangerouslySetInnerHTML:{__html:QT(x||``,(an.name.split(`.`).pop()||`js`).toLowerCase())+`<span class="`+Q.streamingCursor+`">▋</span>`}}):(0,k.jsx)(RT,{value:C===null?an.content||``:C,filename:an.name,readOnly:C===null,projectName:c,onChange:e=>{w(e),an&&te(e=>new Set(e).add(an.name))},onSave:e=>{v(t=>t.map((t,n)=>n===y?{...t,content:e}:t)),E(`/api/studio/webcraft/file/write`,{projectName:c,path:an.name,content:e}),w(null),te(e=>{let t=new Set(e);return t.delete(an.name),t})}})]})}),se!==null&&g[se]&&(0,k.jsxs)(`div`,{className:Q.codeEditorWrap,children:[(0,k.jsxs)(`div`,{className:Q.codeHeader,children:[(0,k.jsx)(`span`,{className:Q.codeFileIcon,children:rE(g[se].name)}),(0,k.jsx)(`span`,{className:Q.codeFileName,children:g[se].name}),(0,k.jsx)(`button`,{className:Q.headerIconBtn,onClick:()=>ce(null),children:`✕`})]}),(0,k.jsx)(RT,{value:g[se].content||``,filename:g[se].name,readOnly:!0})]})]}),A&&(0,k.jsxs)(`div`,{className:Q.terminalPanel,children:[(0,k.jsxs)(`div`,{className:Q.terminalHeader,children:[(0,k.jsx)(`span`,{className:Q.terminalTitle,children:`Terminal`}),(0,k.jsx)(`button`,{className:Q.terminalClose,onClick:()=>oe(!1),children:`✕`})]}),(0,k.jsx)(YT,{projectDir:c||void 0})]})]})})]})]})]})}),We&&t!==`projects`&&(0,k.jsxs)(`div`,{className:Q.planBanner,children:[(0,k.jsx)(`div`,{className:Q.planTitle,children:`📌 Piano proposto — approva per eseguire`}),(0,k.jsx)(`pre`,{className:Q.planText,children:We.plan}),(0,k.jsxs)(`div`,{className:Q.planActions,children:[(0,k.jsx)(`button`,{className:Q.planApprove,onClick:nn,children:`✓ Esegui`}),(0,k.jsx)(`button`,{className:Q.planReject,onClick:()=>Ge(null),children:`✕ Annulla`})]})]}),et&&t!==`projects`&&(0,k.jsxs)(`div`,{className:Q.grepPanel,children:[(0,k.jsxs)(`div`,{className:Q.grepRow,children:[(0,k.jsx)(`input`,{className:Q.grepInput,value:nt,onChange:e=>rt(e.target.value),onKeyDown:e=>e.key===`Enter`&&Jt(),placeholder:`Cerca nel codice...`}),(0,k.jsx)(`button`,{className:Q.grepBtn,onClick:Jt,children:`🔍`}),(0,k.jsx)(`button`,{className:Q.grepClose,onClick:()=>tt(!1),children:`×`})]}),it.length>0&&(0,k.jsxs)(`div`,{className:Q.grepCount,children:[it.length,` risultati`]}),(0,k.jsx)(`div`,{className:Q.grepResults,children:it.length===0?(0,k.jsx)(`div`,{className:Q.grepEmpty,children:`Nessun risultato.`}):it.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.grepMatch,onClick:()=>Yt(e.file),children:[(0,k.jsxs)(`span`,{className:Q.grepMatchFile,children:[e.file,`:`,e.lineNum]}),(0,k.jsx)(`pre`,{className:Q.grepMatchLine,children:e.line})]},t))})]}),ot.length>0&&t!==`projects`&&(0,k.jsxs)(`div`,{className:Q.diffPanel,children:[(0,k.jsxs)(`div`,{className:Q.diffHeader,children:[(0,k.jsxs)(`span`,{children:[`🔌 Diff — `,ot.length,` file modificati`]}),(0,k.jsx)(`button`,{className:Q.diffClose,onClick:()=>st([]),children:`✕ Chiudi`})]}),ot.map((e,t)=>{let n=(e.after||``).split(`
859
859
  `).length-(e.before||``).split(`
860
- `).length;return(0,k.jsxs)(`details`,{open:!0,className:Q.diffFile,children:[(0,k.jsxs)(`summary`,{className:Q.diffSummary,children:[(0,k.jsx)(`span`,{className:Q.diffArrow,children:`▲`}),(0,k.jsx)(`span`,{className:Q.diffFileName,children:e.file}),(0,k.jsxs)(`span`,{className:n>=0?Q.diffAdded:Q.diffRemoved,children:[n>=0?`+`:``,n,` linee`]})]}),(0,k.jsx)(`div`,{className:Q.diffContent,children:(0,k.jsx)(uE,{before:e.before,after:e.after})})]},t)})]}),t!==`projects`&&(0,k.jsxs)(`div`,{className:`${Q.chatPanel} ${ut?Q.chatPanelCollapsed:``}`,children:[(0,k.jsxs)(`button`,{className:Q.chatCollapseBtn,onClick:()=>dt(e=>!e),children:[(0,k.jsx)(`span`,{children:ut?`▲`:`▼`}),(0,k.jsx)(`span`,{children:ut?`Show Chat`:`Hide Chat`}),Fe.length>0&&(0,k.jsxs)(`span`,{style:{opacity:.5},children:[`(`,Fe.length,`)`]})]}),(0,k.jsxs)(`div`,{className:Q.chatMessages,ref:Tt,children:[Fe.length===0&&nn&&(0,k.jsxs)(`div`,{className:Q.chatWelcome,children:[`🤖 `,e(`webcraft.doctrine.title`),` — `,(0,k.jsx)(`button`,{className:Q.doctrineOpenBtn,onClick:()=>ue(!0),children:`📖 Open Guide`})]}),Fe.map((e,t)=>(0,k.jsxs)(`div`,{className:e.role===`user`?Q.chatUser:e.role===`system`?Q.chatSystem:Q.chatAgent,children:[e.role===`user`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:Q.chatUserBubble,children:e.text}),e.attachments&&e.attachments.length>0&&(0,k.jsx)(`div`,{className:Q.chatAttachPreviews,children:e.attachments.map((e,t)=>(0,k.jsxs)(`span`,{className:Q.chatAttachBadge,children:[`📎 `,e.name]},t))})]}),e.role===`system`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:Q.chatSystemBubble,children:e.text}),e.syntaxErrors?.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.chatSyntaxErr,children:[`✕ `,e.file,`: `,e.error]},t))]}),e.role===`agent`&&(()=>{let t=e.text.replace(/<tool>[\s\S]*?<\/tool>/g,``).replace(/<done\s*\/?>/g,``).trim(),n=(e.tools||[]).filter(e=>(e.op===`edit`||e.op===`write`)&&(e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`)),r=(e.tools||[]).filter(e=>e.result?.includes(`not_found`)||e.result?.includes(`error`)||e.result===`blocked_use_edit`),a=t.match(/^(.{10,120}?)[.\n]/),o=a?a[1]+`.`:t.slice(0,120),s=t.length>130;return(0,k.jsxs)(`div`,{className:Q.chatAgentCard,children:[n.map((e,t)=>(0,k.jsxs)(`div`,{style:{margin:`6px 0`,borderRadius:8,overflow:`hidden`,border:`1px solid rgba(255,255,255,0.08)`},children:[(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`6px 10px`,background:`rgba(99,102,241,0.1)`,fontSize:11},children:[(0,k.jsxs)(`span`,{style:{fontWeight:600,color:`#818cf8`,cursor:`pointer`},onClick:()=>{let t=g.findIndex(t=>t.name===e.path);t>=0&&(b(t),i(`files`))},children:[`✏ `,e.path]}),(0,k.jsx)(`span`,{style:{color:`#4ade80`,fontSize:10,fontWeight:600},children:e.result===`ok_fuzzy`?`applied (fuzzy)`:e.result===`ok_repaired`?`applied (repaired)`:`✓ applied`})]}),e.oldSnippet||e.newSnippet?(0,k.jsx)(uE,{before:e.oldSnippet||``,after:e.newSnippet||``,contextLines:3}):(0,k.jsx)(`div`,{style:{padding:`6px 10px`,fontSize:11,color:`#4ade80`,background:`rgba(74,222,128,0.05)`},children:`File modified successfully`})]},t)),r.length>0&&(0,k.jsx)(`div`,{style:{margin:`6px 0`,padding:`6px 10px`,background:`rgba(248,113,113,0.08)`,borderRadius:6,fontSize:11,color:`#f87171`},children:r.map((e,t)=>(0,k.jsxs)(`div`,{children:[`❌ `,e.op,` `,e.path,`: `,typeof e.result==`string`?e.result.slice(0,100):``]},t))}),t&&(s?(0,k.jsxs)(`details`,{style:{margin:`6px 0`,fontSize:11},children:[(0,k.jsx)(`summary`,{style:{cursor:`pointer`,color:`var(--dim)`,padding:`4px 0`,userSelect:`none`},children:o.slice(0,100)}),(0,k.jsx)(`div`,{className:Q.chatAgentText,style:{fontSize:11,opacity:.8,marginTop:4},dangerouslySetInnerHTML:{__html:$T(t)}})]}):(0,k.jsx)(`div`,{className:Q.chatAgentText,style:{fontSize:11,opacity:.8},dangerouslySetInnerHTML:{__html:$T(t)}}))]})})()]},t)),ze&&(()=>{let e=Fe[Fe.length-1]?.tools??[],t=e[e.length-1],n=t?t.op===`read`?`Reading ${t.path}`:t.op===`edit`?`Editing ${t.path}`:t.op===`search`?`Searching...`:t.op===`lint`?`Linting ${t.path}`:t.op===`check`?`Checking ${t.path}`:t.op===`run`?`Running command...`:t.op===`sandbox`?`Starting sandbox...`:t.op:`Thinking...`;return(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`8px 12px`,fontSize:12,color:`#818cf8`},children:[(0,k.jsx)(`span`,{className:Q.chatAgentRobotAnim,style:{fontSize:14},children:`⟳`}),(0,k.jsx)(`span`,{style:{fontWeight:500},children:n})]})})()]}),Be.length>0&&(0,k.jsx)(`div`,{className:Q.attachPreviews,children:Be.map((e,t)=>(0,k.jsxs)(`span`,{className:Q.attachBadge,children:[`📎 `,e.name,(0,k.jsx)(`button`,{className:Q.removeAttachBtn,onClick:()=>Ve(e=>e.filter((e,n)=>n!==t)),children:`×`})]},t))}),nn?(0,k.jsxs)(`div`,{className:Q.projActiveRow,children:[`📄 `,(0,k.jsx)(`strong`,{className:Q.projActiveName,children:c}),` — scrivi per modificare o migliorare il progetto`]}):(0,k.jsxs)(`div`,{className:Q.projNameRow,children:[(0,k.jsx)(`span`,{className:Q.projNameLabel,children:`Nome progetto:`}),(0,k.jsx)(`input`,{className:Q.projNameInput,value:c,onChange:e=>l(e.target.value),placeholder:`MioProgetto`})]}),(0,k.jsxs)(`div`,{className:Q.chatInputRow,children:[(0,k.jsxs)(`label`,{className:Q.attachLabel,title:`Allega immagine o PDF`,children:[`📎`,(0,k.jsx)(`input`,{ref:Et,type:`file`,multiple:!0,accept:`image/*,.pdf`,style:{display:`none`},onChange:e=>tn(e.target.files)})]}),(0,k.jsx)(`textarea`,{className:Q.chatTextarea,value:Le,onChange:e=>Re(e.target.value),placeholder:nn?`Parla con il tuo agente: chiedi correzioni, migliorie, nuove funzionalità...`:`Descrivi il progetto da creare, poi premi Genera...`,disabled:U,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Pt())},rows:4}),(0,k.jsxs)(`div`,{className:Q.chatSendCol,children:[(0,k.jsx)(`button`,{className:Q.chatSendBtn,onClick:()=>Pt(),disabled:U,children:N?`⏳`:nn?`▶`:`▶ Genera`}),U&&!we&&(0,k.jsx)(`button`,{className:Q.chatStopBtn,onClick:Lt,children:`⏹ Stop`})]})]})]}),le&&(0,k.jsx)(`div`,{className:Q.modalOverlay,onClick:()=>ue(!1),children:(0,k.jsxs)(`div`,{className:Q.modal,onClick:e=>e.stopPropagation(),style:{width:720,maxHeight:`90vh`},children:[(0,k.jsxs)(`div`,{className:Q.modalHeader,children:[(0,k.jsxs)(`span`,{className:Q.modalTitle,children:[`📖 `,e(`webcraft.doctrine.title`)]}),(0,k.jsx)(`span`,{className:Q.doctrineSubtitle,children:e(`webcraft.doctrine.subtitle`)}),(0,k.jsx)(`button`,{className:Q.modalClose,onClick:()=>ue(!1),children:`✕`})]}),(0,k.jsx)(`div`,{className:Q.modalBody,style:{gap:0},children:[`phase1`,`phase2`,`phase3`,`phase4`,`phase5`,`tools`,`golden`].map(t=>(0,k.jsxs)(`div`,{className:Q.doctrineSection,children:[(0,k.jsx)(`div`,{className:Q.doctrineSectionTitle,children:e(`webcraft.doctrine.${t}.title`)}),(0,k.jsx)(`div`,{className:Q.doctrineSectionBody,children:e(`webcraft.doctrine.${t}.desc`).split(`
861
- `).map((e,t)=>(0,k.jsx)(`p`,{className:e.startsWith(`•`)||e.startsWith(`1.`)||e.startsWith(`2.`)||e.startsWith(`3.`)||e.startsWith(`4.`)||e.startsWith(`5.`)||e.startsWith(`6.`)?Q.doctrineBullet:``,children:e},t))})]},t))}),(0,k.jsx)(`div`,{className:Q.modalFooter,children:(0,k.jsx)(`button`,{className:Q.modalSaveBtn,onClick:()=>ue(!1),style:{padding:`10px 28px`,fontSize:14},children:e(`webcraft.doctrine.close`)})})]})}),Je&&(0,k.jsx)(dE,{modal:Je,skills:We,projectName:c,onClose:()=>Ye(null),onSave:(e,t,n)=>Yt(Je,e,t,n)}),a&&t===`new`&&(0,k.jsx)(XT,{tabs:ZT,active:o,onChange:s,className:Q.mobileTabBar,buttonClassName:Q.mobileTabBtn,activeClassName:Q.mobileTabBtnActive})]})}function sE(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===r&&e.every((e,n)=>e===t[n]))return e.map((e,t)=>({type:`same`,text:e,oldLine:t+1,newLine:t+1}));if(n+r>8e3)return cE(e,t);let i=n+r,a=2*i+1,o=new Int32Array(a).fill(-1),s=i;o[s+1]=0;let c=[];outer:for(let l=0;l<=i;l++){let i=new Int32Array(a);i.set(o),c.push(i);for(let i=-l;i<=l;i+=2){let a;a=i===-l||i!==l&&o[s+i-1]<o[s+i+1]?o[s+i+1]:o[s+i-1]+1;let c=a-i;for(;a<n&&c<r&&e[a]===t[c];)a++,c++;if(o[s+i]=a,a>=n&&c>=r)break outer}}let l=[],u=n,d=r;for(let n=c.length-1;n>0;n--){let r=c[n-1],i=u-d,a;a=i===-n||i!==n&&r[s+i-1]<r[s+i+1]?i+1:i-1;let o=r[s+a],f=o-a;for(;u>o&&d>f;)u--,d--,l.push({type:`same`,text:e[u],oldLine:u+1,newLine:d+1});u>o?(u--,l.push({type:`rem`,text:e[u],oldLine:u+1})):d>f&&(d--,l.push({type:`add`,text:t[d],newLine:d+1}))}for(;u>0&&d>0;)u--,d--,l.push({type:`same`,text:e[u],oldLine:u+1,newLine:d+1});return l.reverse(),l}function cE(e,t){let n=[],r=0,i=0;for(;(r<e.length||i<t.length)&&(r>=e.length?(n.push({type:`add`,text:t[i],newLine:i+1}),i++):i>=t.length?(n.push({type:`rem`,text:e[r],oldLine:r+1}),r++):e[r]===t[i]?(n.push({type:`same`,text:e[r],oldLine:r+1,newLine:i+1}),r++,i++):(n.push({type:`rem`,text:e[r],oldLine:r+1}),n.push({type:`add`,text:t[i],newLine:i+1}),r++,i++),!(n.length>4e3)););return n}function lE(e,t){let n=(e||``).split(/(\s+)/),r=(t||``).split(/(\s+)/),i=n.length,a=r.length;if(i+a>400)return{old:(0,k.jsx)(k.Fragment,{children:e}),new:(0,k.jsx)(k.Fragment,{children:t})};let o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)o[e][t]=n[e-1]===r[t-1]?o[e-1][t-1]+1:Math.max(o[e-1][t],o[e][t-1]);let s=[],c=[],l=i,u=a,d=[],f=[];for(;l>0||u>0;)l>0&&u>0&&n[l-1]===r[u-1]?(d.push({text:n[l-1],changed:!1}),f.push({text:r[u-1],changed:!1}),l--,u--):u>0&&(l===0||o[l][u-1]>=o[l-1][u])?(f.push({text:r[u-1],changed:!0}),u--):(d.push({text:n[l-1],changed:!0}),l--);return d.reverse().forEach(e=>s.push(e)),f.reverse().forEach(e=>c.push(e)),{old:(0,k.jsx)(k.Fragment,{children:s.map((e,t)=>e.changed?(0,k.jsx)(`span`,{style:{background:`rgba(248,113,113,0.3)`,borderRadius:2},children:e.text},t):(0,k.jsx)(`span`,{children:e.text},t))}),new:(0,k.jsx)(k.Fragment,{children:c.map((e,t)=>e.changed?(0,k.jsx)(`span`,{style:{background:`rgba(74,222,128,0.3)`,borderRadius:2},children:e.text},t):(0,k.jsx)(`span`,{children:e.text},t))})}}function uE({before:e,after:t,contextLines:n=3}){let r=sE((e||``).split(`
860
+ `).length;return(0,k.jsxs)(`details`,{open:!0,className:Q.diffFile,children:[(0,k.jsxs)(`summary`,{className:Q.diffSummary,children:[(0,k.jsx)(`span`,{className:Q.diffArrow,children:`▲`}),(0,k.jsx)(`span`,{className:Q.diffFileName,children:e.file}),(0,k.jsxs)(`span`,{className:n>=0?Q.diffAdded:Q.diffRemoved,children:[n>=0?`+`:``,n,` linee`]})]}),(0,k.jsx)(`div`,{className:Q.diffContent,children:(0,k.jsx)(uE,{before:e.before,after:e.after})})]},t)})]}),t!==`projects`&&(0,k.jsxs)(`div`,{className:`${Q.chatPanel} ${ft?Q.chatPanelCollapsed:``}`,children:[(0,k.jsxs)(`button`,{className:Q.chatCollapseBtn,onClick:()=>pt(e=>!e),children:[(0,k.jsx)(`span`,{children:ft?`▲`:`▼`}),(0,k.jsx)(`span`,{children:ft?`Show Chat`:`Hide Chat`}),Le.length>0&&(0,k.jsxs)(`span`,{style:{opacity:.5},children:[`(`,Le.length,`)`]})]}),(0,k.jsxs)(`div`,{className:Q.chatMessages,ref:z,children:[Le.length===0&&U&&(0,k.jsxs)(`div`,{className:Q.chatWelcome,children:[`🤖 `,e(`webcraft.doctrine.title`),` — `,(0,k.jsx)(`button`,{className:Q.doctrineOpenBtn,onClick:()=>ue(!0),children:`📖 Open Guide`})]}),Le.map((e,t)=>(0,k.jsxs)(`div`,{className:e.role===`user`?Q.chatUser:e.role===`system`?Q.chatSystem:Q.chatAgent,children:[e.role===`user`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:Q.chatUserBubble,children:e.text}),e.attachments&&e.attachments.length>0&&(0,k.jsx)(`div`,{className:Q.chatAttachPreviews,children:e.attachments.map((e,t)=>(0,k.jsxs)(`span`,{className:Q.chatAttachBadge,children:[`📎 `,e.name]},t))})]}),e.role===`system`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:Q.chatSystemBubble,children:e.text}),e.syntaxErrors?.map((e,t)=>(0,k.jsxs)(`div`,{className:Q.chatSyntaxErr,children:[`✕ `,e.file,`: `,e.error]},t))]}),e.role===`agent`&&(()=>{let t=e.text.replace(/<tool>[\s\S]*?<\/tool>/g,``).replace(/<done\s*\/?>/g,``).trim(),n=(e.tools||[]).filter(e=>(e.op===`edit`||e.op===`write`)&&(e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`)),r=(e.tools||[]).filter(e=>e.result?.includes(`not_found`)||e.result?.includes(`error`)||e.result===`blocked_use_edit`),a=t.match(/^(.{10,120}?)[.\n]/),o=a?a[1]+`.`:t.slice(0,120),s=t.length>130;return(0,k.jsxs)(`div`,{className:Q.chatAgentCard,children:[n.map((e,t)=>(0,k.jsxs)(`div`,{style:{margin:`6px 0`,borderRadius:8,overflow:`hidden`,border:`1px solid rgba(255,255,255,0.08)`},children:[(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`6px 10px`,background:`rgba(99,102,241,0.1)`,fontSize:11},children:[(0,k.jsxs)(`span`,{style:{fontWeight:600,color:`#818cf8`,cursor:`pointer`},onClick:()=>{let t=g.findIndex(t=>t.name===e.path);t>=0&&(b(t),i(`files`))},children:[`✏ `,e.path]}),(0,k.jsx)(`span`,{style:{color:`#4ade80`,fontSize:10,fontWeight:600},children:e.result===`ok_fuzzy`?`applied (fuzzy)`:e.result===`ok_repaired`?`applied (repaired)`:`✓ applied`})]}),e.oldSnippet||e.newSnippet?(0,k.jsx)(uE,{before:e.oldSnippet||``,after:e.newSnippet||``,contextLines:3}):(0,k.jsx)(`div`,{style:{padding:`6px 10px`,fontSize:11,color:`#4ade80`,background:`rgba(74,222,128,0.05)`},children:`File modified successfully`})]},t)),r.length>0&&(0,k.jsx)(`div`,{style:{margin:`6px 0`,padding:`6px 10px`,background:`rgba(248,113,113,0.08)`,borderRadius:6,fontSize:11,color:`#f87171`},children:r.map((e,t)=>(0,k.jsxs)(`div`,{children:[`❌ `,e.op,` `,e.path,`: `,typeof e.result==`string`?e.result.slice(0,100):``]},t))}),t&&(s?(0,k.jsxs)(`details`,{style:{margin:`6px 0`,fontSize:11},children:[(0,k.jsx)(`summary`,{style:{cursor:`pointer`,color:`var(--dim)`,padding:`4px 0`,userSelect:`none`},children:o.slice(0,100)}),(0,k.jsx)(`div`,{className:Q.chatAgentText,style:{fontSize:11,opacity:.8,marginTop:4},dangerouslySetInnerHTML:{__html:$T(t)}})]}):(0,k.jsx)(`div`,{className:Q.chatAgentText,style:{fontSize:11,opacity:.8},dangerouslySetInnerHTML:{__html:$T(t)}}))]})})()]},t)),Be&&(()=>{let e=Le[Le.length-1]?.tools??[],t=e[e.length-1],n=t?t.op===`read`?`Reading ${t.path}`:t.op===`edit`?`Editing ${t.path}`:t.op===`search`?`Searching...`:t.op===`lint`?`Linting ${t.path}`:t.op===`check`?`Checking ${t.path}`:t.op===`run`?`Running command...`:t.op===`sandbox`?`Starting sandbox...`:t.op:`Thinking...`;return(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`8px 12px`,fontSize:12,color:`#818cf8`},children:[(0,k.jsx)(`span`,{className:Q.chatAgentRobotAnim,style:{fontSize:14},children:`⟳`}),(0,k.jsx)(`span`,{style:{fontWeight:500},children:n})]})})()]}),He.length>0&&(0,k.jsx)(`div`,{className:Q.attachPreviews,children:He.map((e,t)=>(0,k.jsxs)(`span`,{className:Q.attachBadge,children:[`📎 `,e.name,(0,k.jsx)(`button`,{className:Q.removeAttachBtn,onClick:()=>Ue(e=>e.filter((e,n)=>n!==t)),children:`×`})]},t))}),U?(0,k.jsxs)(`div`,{className:Q.projActiveRow,children:[`📄 `,(0,k.jsx)(`strong`,{className:Q.projActiveName,children:c}),` — scrivi per modificare o migliorare il progetto`]}):(0,k.jsxs)(`div`,{className:Q.projNameRow,children:[(0,k.jsx)(`span`,{className:Q.projNameLabel,children:`Nome progetto:`}),(0,k.jsx)(`input`,{className:Q.projNameInput,value:c,onChange:e=>l(e.target.value),placeholder:`MioProgetto`})]}),(0,k.jsxs)(`div`,{className:Q.chatInputRow,children:[(0,k.jsxs)(`label`,{className:Q.attachLabel,title:`Allega immagine o PDF`,children:[`📎`,(0,k.jsx)(`input`,{ref:Dt,type:`file`,multiple:!0,accept:`image/*,.pdf`,style:{display:`none`},onChange:e=>rn(e.target.files)})]}),(0,k.jsx)(`textarea`,{className:Q.chatTextarea,value:ze,onChange:e=>L(e.target.value),placeholder:U?`Parla con il tuo agente: chiedi correzioni, migliorie, nuove funzionalità...`:`Descrivi il progetto da creare, poi premi Genera...`,disabled:on,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),It())},rows:4}),(0,k.jsxs)(`div`,{className:Q.chatSendCol,children:[(0,k.jsx)(`button`,{className:Q.chatSendBtn,onClick:()=>It(),disabled:on,children:we?`⏳`:U?`▶`:`▶ Genera`}),on&&!Ee&&(0,k.jsx)(`button`,{className:Q.chatStopBtn,onClick:zt,children:`⏹ Stop`})]})]})]}),le&&(0,k.jsx)(`div`,{className:Q.modalOverlay,onClick:()=>ue(!1),children:(0,k.jsxs)(`div`,{className:Q.modal,onClick:e=>e.stopPropagation(),style:{width:720,maxHeight:`90vh`},children:[(0,k.jsxs)(`div`,{className:Q.modalHeader,children:[(0,k.jsxs)(`span`,{className:Q.modalTitle,children:[`📖 `,e(`webcraft.doctrine.title`)]}),(0,k.jsx)(`span`,{className:Q.doctrineSubtitle,children:e(`webcraft.doctrine.subtitle`)}),(0,k.jsx)(`button`,{className:Q.modalClose,onClick:()=>ue(!1),children:`✕`})]}),(0,k.jsx)(`div`,{className:Q.modalBody,style:{gap:0},children:[`phase1`,`phase2`,`phase3`,`phase4`,`phase5`,`tools`,`golden`].map(t=>(0,k.jsxs)(`div`,{className:Q.doctrineSection,children:[(0,k.jsx)(`div`,{className:Q.doctrineSectionTitle,children:e(`webcraft.doctrine.${t}.title`)}),(0,k.jsx)(`div`,{className:Q.doctrineSectionBody,children:e(`webcraft.doctrine.${t}.desc`).split(`
861
+ `).map((e,t)=>(0,k.jsx)(`p`,{className:e.startsWith(`•`)||e.startsWith(`1.`)||e.startsWith(`2.`)||e.startsWith(`3.`)||e.startsWith(`4.`)||e.startsWith(`5.`)||e.startsWith(`6.`)?Q.doctrineBullet:``,children:e},t))})]},t))}),(0,k.jsx)(`div`,{className:Q.modalFooter,children:(0,k.jsx)(`button`,{className:Q.modalSaveBtn,onClick:()=>ue(!1),style:{padding:`10px 28px`,fontSize:14},children:e(`webcraft.doctrine.close`)})})]})}),Xe&&(0,k.jsx)(dE,{modal:Xe,skills:Ke,projectName:c,onClose:()=>Ze(null),onSave:(e,t,n)=>Zt(Xe,e,t,n)}),a&&t===`new`&&(0,k.jsx)(XT,{tabs:ZT,active:o,onChange:s,className:Q.mobileTabBar,buttonClassName:Q.mobileTabBtn,activeClassName:Q.mobileTabBtnActive})]})}function sE(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===r&&e.every((e,n)=>e===t[n]))return e.map((e,t)=>({type:`same`,text:e,oldLine:t+1,newLine:t+1}));if(n+r>8e3)return cE(e,t);let i=n+r,a=2*i+1,o=new Int32Array(a).fill(-1),s=i;o[s+1]=0;let c=[];outer:for(let l=0;l<=i;l++){let i=new Int32Array(a);i.set(o),c.push(i);for(let i=-l;i<=l;i+=2){let a;a=i===-l||i!==l&&o[s+i-1]<o[s+i+1]?o[s+i+1]:o[s+i-1]+1;let c=a-i;for(;a<n&&c<r&&e[a]===t[c];)a++,c++;if(o[s+i]=a,a>=n&&c>=r)break outer}}let l=[],u=n,d=r;for(let n=c.length-1;n>0;n--){let r=c[n-1],i=u-d,a;a=i===-n||i!==n&&r[s+i-1]<r[s+i+1]?i+1:i-1;let o=r[s+a],f=o-a;for(;u>o&&d>f;)u--,d--,l.push({type:`same`,text:e[u],oldLine:u+1,newLine:d+1});u>o?(u--,l.push({type:`rem`,text:e[u],oldLine:u+1})):d>f&&(d--,l.push({type:`add`,text:t[d],newLine:d+1}))}for(;u>0&&d>0;)u--,d--,l.push({type:`same`,text:e[u],oldLine:u+1,newLine:d+1});return l.reverse(),l}function cE(e,t){let n=[],r=0,i=0;for(;(r<e.length||i<t.length)&&(r>=e.length?(n.push({type:`add`,text:t[i],newLine:i+1}),i++):i>=t.length?(n.push({type:`rem`,text:e[r],oldLine:r+1}),r++):e[r]===t[i]?(n.push({type:`same`,text:e[r],oldLine:r+1,newLine:i+1}),r++,i++):(n.push({type:`rem`,text:e[r],oldLine:r+1}),n.push({type:`add`,text:t[i],newLine:i+1}),r++,i++),!(n.length>4e3)););return n}function lE(e,t){let n=(e||``).split(/(\s+)/),r=(t||``).split(/(\s+)/),i=n.length,a=r.length;if(i+a>400)return{old:(0,k.jsx)(k.Fragment,{children:e}),new:(0,k.jsx)(k.Fragment,{children:t})};let o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)o[e][t]=n[e-1]===r[t-1]?o[e-1][t-1]+1:Math.max(o[e-1][t],o[e][t-1]);let s=[],c=[],l=i,u=a,d=[],f=[];for(;l>0||u>0;)l>0&&u>0&&n[l-1]===r[u-1]?(d.push({text:n[l-1],changed:!1}),f.push({text:r[u-1],changed:!1}),l--,u--):u>0&&(l===0||o[l][u-1]>=o[l-1][u])?(f.push({text:r[u-1],changed:!0}),u--):(d.push({text:n[l-1],changed:!0}),l--);return d.reverse().forEach(e=>s.push(e)),f.reverse().forEach(e=>c.push(e)),{old:(0,k.jsx)(k.Fragment,{children:s.map((e,t)=>e.changed?(0,k.jsx)(`span`,{style:{background:`rgba(248,113,113,0.3)`,borderRadius:2},children:e.text},t):(0,k.jsx)(`span`,{children:e.text},t))}),new:(0,k.jsx)(k.Fragment,{children:c.map((e,t)=>e.changed?(0,k.jsx)(`span`,{style:{background:`rgba(74,222,128,0.3)`,borderRadius:2},children:e.text},t):(0,k.jsx)(`span`,{children:e.text},t))})}}function uE({before:e,after:t,contextLines:n=3}){let r=sE((e||``).split(`
862
862
  `),(t||``).split(`
863
863
  `)),i=new Set;r.forEach((e,t)=>{e.type!==`same`&&i.add(t)});let a=new Set;if(i.forEach(e=>{for(let t=Math.max(0,e-n);t<=Math.min(r.length-1,e+n);t++)a.add(t)}),i.size===0)for(let e=0;e<Math.min(5,r.length);e++)a.add(e);let o=new Map;for(let e=0;e<r.length-1;e++)r[e].type===`rem`&&r[e+1].type===`add`&&o.set(e,lE(r[e].text,r[e+1].text));let s=[],c=-1;for(let e=0;e<r.length;e++){if(!a.has(e))continue;if(c>=0&&e-c>1){let t=e-c-1;s.push((0,k.jsxs)(`div`,{style:{padding:`2px 8px`,background:`rgba(99,102,241,0.08)`,color:`#6366f1`,fontSize:9,textAlign:`center`,borderTop:`1px solid rgba(99,102,241,0.15)`,borderBottom:`1px solid rgba(99,102,241,0.15)`,userSelect:`none`},children:[`@@ `,t,` righe nascoste @@`]},`fold-${e}`))}c=e;let t=r[e],n=t.type===`add`?`rgba(74,222,128,0.08)`:t.type===`rem`?`rgba(248,113,113,0.08)`:`transparent`,i=t.type===`add`?`3px solid #4ade80`:t.type===`rem`?`3px solid #f87171`:`3px solid transparent`,l=t.type===`add`?`#4ade80`:t.type===`rem`?`#f87171`:`var(--dim)`,u=t.type===`add`?`+`:t.type===`rem`?`-`:` `,d=t.text,f=o.get(e);f&&t.type===`rem`&&(d=f.old);let p=o.get(e-1);p&&t.type===`add`&&(d=p.new),s.push((0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`stretch`,background:n,borderLeft:i,fontFamily:`var(--mono)`,fontSize:11,lineHeight:`18px`},children:[(0,k.jsx)(`span`,{style:{width:36,textAlign:`right`,padding:`0 4px`,color:`rgba(255,255,255,0.2)`,fontSize:10,flexShrink:0,userSelect:`none`},children:t.oldLine??``}),(0,k.jsx)(`span`,{style:{width:36,textAlign:`right`,padding:`0 4px`,color:`rgba(255,255,255,0.2)`,fontSize:10,flexShrink:0,userSelect:`none`},children:t.newLine??``}),(0,k.jsx)(`span`,{style:{width:14,textAlign:`center`,color:l,fontWeight:700,flexShrink:0,userSelect:`none`},children:u}),(0,k.jsx)(`span`,{style:{flex:1,padding:`0 4px`,color:l,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:d})]},e))}return(0,k.jsx)(`div`,{style:{overflow:`auto`,maxHeight:400},children:s})}function dE({modal:e,skills:t,projectName:n,onClose:r,onSave:i}){let[a,o]=(0,_.useState)(e.name),[s,c]=(0,_.useState)(e.content),[l,u]=(0,_.useState)(e.type),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),h=l===`skill`?6e3:4e3,g=s.length>h;async function v(){if(!d.trim())return;m(!0);let e={skill:`Sei un esperto di sviluppo web fullstack. Genera un file Markdown "skill" per il WebCraft Agent. Deve contenere istruzioni, pattern di codice, best practice e snippet pronti all uso come contesto persistente. Scrivi SOLO il contenuto Markdown, niente altro.`,memory:`Sei un assistente tecnico. Genera un file Markdown "memory" per il WebCraft Agent. Deve riassumere decisioni architetturali, preferenze dello sviluppatore e contesto generale del progetto. Scrivi SOLO il Markdown.`,provider:`Sei un esperto di prompt engineering. Genera un file Markdown con istruzioni specifiche per calibrare il comportamento del modello AI. Scrivi SOLO il Markdown.`},t=await E(`/api/studio/webcraft`,{system:e[l]??e.skill,user:`Progetto: ${n}\n\n${d}`,max_tokens:2048});t?.text&&(c(t.text),a||o(l===`memory`?`memory.md`:l===`provider`?`liara.md`:d.toLowerCase().replace(/[^a-z0-9]+/g,`-`).slice(0,30)+`.md`)),m(!1)}function y(){if(!a.trim()){alert(`Inserisci un nome per il file.`);return}let n=a.endsWith(`.md`)?a:a+`.md`;if((l===`memory`||l===`provider`)&&e.mode===`new`&&t.findIndex(e=>e.type===l)>=0){alert(`Esiste già un file di tipo "${l}". Modificalo direttamente.`);return}i(n,s,l)}return(0,k.jsx)(`div`,{className:Q.modalOverlay,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,k.jsxs)(`div`,{className:Q.modal,children:[(0,k.jsxs)(`div`,{className:Q.modalHeader,children:[(0,k.jsxs)(`span`,{className:Q.modalTitle,children:[aE(l),` `,e.mode===`new`?`Nuovo file di contesto`:`Modifica ${e.name}`]}),(0,k.jsx)(`button`,{className:Q.modalClose,onClick:r,children:`×`})]}),(0,k.jsx)(`div`,{className:Q.modalBody,children:e.mode===`view`?(0,k.jsx)(`pre`,{className:Q.logView,children:s}):(0,k.jsxs)(k.Fragment,{children:[e.mode===`new`&&(0,k.jsxs)(`div`,{className:Q.modalRow,children:[(0,k.jsxs)(`div`,{className:Q.modalField,children:[(0,k.jsx)(`div`,{className:Q.modalLabel,children:`TIPO`}),(0,k.jsx)(`select`,{value:l,onChange:e=>{let t=e.target.value;u(t),t===`memory`?o(`memory.md`):t===`provider`&&o(`liara.md`)},className:Q.modalSelect,children:[`skill`,`memory`,`provider`].map(e=>{let n=(e===`memory`||e===`provider`)&&t.some(t=>t.type===e);return(0,k.jsxs)(`option`,{value:e,disabled:n,children:[e,n?` (esiste già)`:``]},e)})})]}),(0,k.jsxs)(`div`,{className:Q.modalField,style:{flex:2},children:[(0,k.jsx)(`div`,{className:Q.modalLabel,children:`NOME FILE`}),(0,k.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:l===`memory`?`memory.md`:l===`provider`?`liara.md`:`nome-skill.md`,className:Q.modalInput})]})]}),(0,k.jsxs)(`div`,{className:Q.modalHint,children:[`💡 `,l===`skill`?`Istruzioni tecniche, snippet, pattern di codice specifici. Max ~6000 caratteri.`:l===`memory`?`Note persistenti sul progetto: decisioni architetturali, preferenze. Solo UN file. Max ~4000 caratteri.`:`Istruzioni specifiche per il modello AI (tono, formato, vincoli). Solo UN file. Max ~4000 caratteri.`]}),(0,k.jsxs)(`div`,{className:Q.modalAiBox,children:[(0,k.jsx)(`div`,{className:Q.modalLabel,children:`🤖 GENERA CON AI`}),(0,k.jsxs)(`div`,{className:Q.modalAiRow,children:[(0,k.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:2,placeholder:`Descrivi cosa deve contenere questo file...`,className:Q.modalAiDesc}),(0,k.jsx)(`button`,{onClick:v,disabled:p,className:Q.modalAiBtn,children:p?`⏳ ...`:`▶ Genera`})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:Q.modalLabelRow,children:[(0,k.jsx)(`span`,{children:`CONTENUTO (markdown)`}),(0,k.jsxs)(`span`,{style:{color:g?`#e05050`:`var(--dim)`},children:[s.length,` car.`,g?` ⚠ Troppo lungo`:``]})]}),(0,k.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:14,placeholder:`# Titolo
864
864
  Scrivi le istruzioni in Markdown...`,className:Q.modalContentArea,style:{borderColor:g?`#e05050`:`var(--border2)`}})]})]})}),(0,k.jsxs)(`div`,{className:Q.modalFooter,children:[(0,k.jsx)(`button`,{onClick:r,className:Q.modalCancelBtn,children:`Annulla`}),e.mode!==`view`&&(0,k.jsx)(`button`,{onClick:y,className:Q.modalSaveBtn,children:`✓ Salva`})]})]})})}var fE={root:`_root_x9yvu_1`,loading:`_loading_x9yvu_7`,empty:`_empty_x9yvu_18`,emptyIcon:`_emptyIcon_x9yvu_29`,emptyTitle:`_emptyTitle_x9yvu_30`,emptySub:`_emptySub_x9yvu_31`,generateBtn:`_generateBtn_x9yvu_33`,summary:`_summary_x9yvu_46`,sectionTitle:`_sectionTitle_x9yvu_57`,alertTitle:`_alertTitle_x9yvu_68`,actionCard:`_actionCard_x9yvu_70`,actionTime:`_actionTime_x9yvu_81`,actionText:`_actionText_x9yvu_89`,schedCard:`_schedCard_x9yvu_95`,schedTime:`_schedTime_x9yvu_106`,schedTitle:`_schedTitle_x9yvu_114`,alertCard:`_alertCard_x9yvu_119`,alertSev:`_alertSev_x9yvu_129`,alertAction:`_alertAction_x9yvu_135`,insight:`_insight_x9yvu_141`,regenRow:`_regenRow_x9yvu_148`,regenBtn:`_regenBtn_x9yvu_153`};function pE(){let e=j(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),l=()=>{i(!0),c(!1),T(`/api/plan`).then(e=>{e?.plan?(n(e.plan),c(!1)):(n(null),c(!0)),i(!1)}).catch(()=>{i(!1),c(!0)})},u=async()=>{o(!0),i(!0),n(null);try{await E(`/api/plan/refresh`,{}),l()}catch{i(!1)}finally{o(!1)}};if((0,_.useEffect)(()=>{l()},[]),r)return(0,k.jsxs)(`div`,{className:fE.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),(0,k.jsx)(`div`,{children:a?`Generating plan with 5 agents...`:`Loading plan...`})]});if(s||!t)return(0,k.jsxs)(`div`,{className:fE.empty,children:[(0,k.jsx)(`div`,{className:fE.emptyIcon,children:`🗓️`}),(0,k.jsxs)(`div`,{className:fE.emptyTitle,children:[e(`plan.noplan`),` generated yet`]}),(0,k.jsx)(`div`,{className:fE.emptySub,children:`Generate a daily plan using your calendar, tasks, and emails.`}),(0,k.jsx)(`button`,{className:fE.generateBtn,onClick:u,children:e(`plan.generate`)})]});let d=e=>typeof e==`string`?e:e.description??e.message??e.action_required??`Alert`,f=e=>typeof e==`object`&&e.severity?` [${e.severity.toUpperCase()}]`:``,p=e=>typeof e==`object`&&e.action_required&&e.action_required!==d(e)?e.action_required:``,m=e=>typeof e==`string`?e:e.message??e.insight??``;return(0,k.jsxs)(`div`,{className:fE.root,children:[t.executive_summary&&(0,k.jsx)(`div`,{className:fE.summary,children:t.executive_summary}),t.priority_actions&&t.priority_actions.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:fE.sectionTitle,children:`Priority Actions`}),t.priority_actions.map((e,t)=>(0,k.jsxs)(`div`,{className:fE.actionCard,children:[e.time&&(0,k.jsx)(`span`,{className:fE.actionTime,children:e.time}),(0,k.jsx)(`span`,{className:fE.actionText,children:e.action})]},t))]}),t.schedule&&t.schedule.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:fE.sectionTitle,children:`Schedule`}),t.schedule.map((e,t)=>(0,k.jsxs)(`div`,{className:fE.schedCard,children:[(0,k.jsxs)(`span`,{className:fE.schedTime,children:[e.time_start,`–`,e.time_end]}),(0,k.jsx)(`span`,{className:fE.schedTitle,children:e.title})]},t))]}),t.security_alerts&&t.security_alerts.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`${fE.sectionTitle} ${fE.alertTitle}`,children:`Security Alerts`}),t.security_alerts.map((e,t)=>(0,k.jsxs)(`div`,{className:fE.alertCard,children:[(0,k.jsxs)(`span`,{className:fE.alertSev,children:[`!`,f(e)]}),(0,k.jsx)(`span`,{children:d(e)}),p(e)&&(0,k.jsxs)(`div`,{className:fE.alertAction,children:[`Action: `,p(e)]})]},t))]}),t.insights&&t.insights.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:fE.sectionTitle,children:`Insights`}),t.insights.map((e,t)=>(0,k.jsxs)(`div`,{className:fE.insight,children:[`→ `,m(e)]},t))]}),(0,k.jsx)(`div`,{className:fE.regenRow,children:(0,k.jsx)(`button`,{className:fE.regenBtn,onClick:u,disabled:a,children:a?`Regenerating…`:`↺ Regenerate`})})]})}function mE(e){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:e===`sheet`?`📊`:e===`slides`?`📽`:`📄`}function hE(){let e=j(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=(e=``)=>{i(!0),T(e?`/api/onedrive?q=${encodeURIComponent(e)}`:`/api/onedrive`).then(e=>{n(e??{files:[]}),i(!1)}).catch(()=>{o(`Could not load OneDrive. Run nha microsoft auth in the terminal to connect.`),i(!1)})};if((0,_.useEffect)(()=>{l()},[]),a)return(0,k.jsx)(`div`,{className:G.error,children:a});let u=t?.files??[],d=t?.quota;return(0,k.jsxs)(`div`,{className:G.root,children:[d&&(0,k.jsxs)(`div`,{className:G.quotaBar,children:[(0,k.jsxs)(`div`,{className:G.quotaText,children:[(0,k.jsxs)(`span`,{className:G.quotaUsed,children:[d.usage,` of `,d.limit,` used`]}),(0,k.jsxs)(`span`,{className:G.quotaPct,children:[d.percentUsed,`%`]})]}),(0,k.jsx)(`div`,{className:G.quotaTrack,children:(0,k.jsx)(`div`,{className:G.quotaFill,style:{width:`${Math.min(d.percentUsed,100)}%`,background:d.percentUsed>90?`var(--red)`:d.percentUsed>70?`var(--amber)`:`var(--cyan)`}})})]}),(0,k.jsxs)(`div`,{className:G.searchRow,children:[(0,k.jsx)(`input`,{className:G.searchInput,value:s,onChange:e=>c(e.target.value),placeholder:`Search OneDrive files…`,onKeyDown:e=>e.key===`Enter`&&l(s)}),(0,k.jsx)(`button`,{className:G.searchBtn,onClick:()=>l(s),children:`Search`})]}),r&&(0,k.jsxs)(`div`,{className:G.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!r&&u.length===0&&(0,k.jsx)(`div`,{className:G.empty,children:e(`drive.noFiles`)}),(0,k.jsx)(`div`,{className:G.fileList,children:u.map(e=>(0,k.jsxs)(`div`,{className:G.fileRow,children:[(0,k.jsx)(`span`,{className:G.fileIcon,children:mE(e.type)}),(0,k.jsxs)(`div`,{className:G.fileInfo,children:[(0,k.jsx)(`div`,{className:G.fileName,children:e.name}),(0,k.jsxs)(`div`,{className:G.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``]})]}),(0,k.jsx)(`div`,{className:G.fileBtns,children:e.webViewLink&&(0,k.jsx)(`a`,{className:G.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,children:`Open`})})]},e.id))})]})}var gE={root:`_root_1vbmp_1`,loading:`_loading_1vbmp_2`,error:`_error_1vbmp_3`,empty:`_empty_1vbmp_4`,addRow:`_addRow_1vbmp_6`,addInput:`_addInput_1vbmp_7`,addBtn:`_addBtn_1vbmp_8`,list:`_list_1vbmp_10`,taskRow:`_taskRow_1vbmp_11`,checkBtn:`_checkBtn_1vbmp_12`,taskInfo:`_taskInfo_1vbmp_14`,taskTitle:`_taskTitle_1vbmp_15`,taskDue:`_taskDue_1vbmp_16`,taskImp:`_taskImp_1vbmp_17`};function _E(){let e=j(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=()=>{T(`/api/mstodo`).then(e=>{n(e?.tasks??[]),i(!1)}).catch(()=>{o(`Microsoft To Do requires Microsoft authentication. Run nha microsoft auth in the terminal.`),i(!1)})};(0,_.useEffect)(()=>{l()},[]);let u=()=>{let e=s.trim();e&&(c(``),E(`/api/mstodo`,{title:e}).then(e=>{e?.task&&l()}))},d=(e,t)=>{E(`/api/mstodo/${e}/complete`,{listId:t}).then(()=>l())};return r?(0,k.jsxs)(`div`,{className:gE.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):a?(0,k.jsx)(`div`,{className:gE.error,children:a}):(0,k.jsxs)(`div`,{className:gE.root,children:[(0,k.jsxs)(`div`,{className:gE.addRow,children:[(0,k.jsx)(`input`,{className:gE.addInput,value:s,onChange:e=>c(e.target.value),placeholder:`Add a new task…`,onKeyDown:e=>e.key===`Enter`&&u()}),(0,k.jsx)(`button`,{className:gE.addBtn,onClick:u,children:`+ Add`})]}),t.length===0&&(0,k.jsx)(`div`,{className:gE.empty,children:`No active tasks`}),(0,k.jsx)(`div`,{className:gE.list,children:t.map(e=>{let t=e.importance===`high`?`var(--red)`:e.importance===`low`?`var(--dim)`:`var(--amber)`;return(0,k.jsxs)(`div`,{className:gE.taskRow,children:[(0,k.jsx)(`button`,{className:gE.checkBtn,onClick:()=>d(e.id,e.listId)}),(0,k.jsxs)(`div`,{className:gE.taskInfo,children:[(0,k.jsx)(`div`,{className:gE.taskTitle,children:e.title}),e.dueDate&&(0,k.jsxs)(`div`,{className:gE.taskDue,children:[`Due: `,e.dueDate.split(`T`)[0]]})]}),e.importance&&(0,k.jsx)(`span`,{className:gE.taskImp,style:{color:t},children:e.importance})]},e.id)})})]})}var vE={root:`_root_1ag4s_1`,header:`_header_1ag4s_3`,title:`_title_1ag4s_4`,subtitle:`_subtitle_1ag4s_5`,controls:`_controls_1ag4s_7`,monitorRow:`_monitorRow_1ag4s_8`,label:`_label_1ag4s_9`,monitorBtn:`_monitorBtn_1ag4s_10`,monitorActive:`_monitorActive_1ag4s_11`,captureBtn:`_captureBtn_1ag4s_12`,analyzeSection:`_analyzeSection_1ag4s_15`,sectionTitle:`_sectionTitle_1ag4s_16`,presets:`_presets_1ag4s_17`,preset:`_preset_1ag4s_17`,presetActive:`_presetActive_1ag4s_20`,questionRow:`_questionRow_1ag4s_21`,questionInput:`_questionInput_1ag4s_22`,analyzeBtn:`_analyzeBtn_1ag4s_23`,error:`_error_1ag4s_26`,screenshotContainer:`_screenshotContainer_1ag4s_28`,screenshot:`_screenshot_1ag4s_28`,screenshotMeta:`_screenshotMeta_1ag4s_30`,analysis:`_analysis_1ag4s_32`,analysisTitle:`_analysisTitle_1ag4s_33`,analysisText:`_analysisText_1ag4s_34`,continueInChat:`_continueInChat_1ag4s_35`,history:`_history_1ag4s_37`,historyGrid:`_historyGrid_1ag4s_38`,historyItem:`_historyItem_1ag4s_39`,historyThumb:`_historyThumb_1ag4s_40`,historyMeta:`_historyMeta_1ag4s_41`,historyTs:`_historyTs_1ag4s_42`,historyQ:`_historyQ_1ag4s_43`,historyA:`_historyA_1ag4s_44`},yE=[`Describe exactly what you see on the screen`,`Identify any errors, warnings, or issues visible`,`What application is open and what is the user doing?`,`Summarize the content visible on screen and suggest next actions`,`Read and extract all visible text from the screen`,`Analyze the code visible on screen and identify bugs or improvements`,`What financial data or charts are visible? Summarize key numbers`,`Is there anything sensitive or that should be kept private?`];function bE(){let e=j(),t=ne(e=>e.setView),n=ne(e=>e.apiBase),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(1),[p,m]=(0,_.useState)([]),h=async()=>{i(!0),c(null);try{let e=await E(`/api/screen/capture`,{monitor:d});c(e),(e?.base64||e?.file)&&m(t=>[{ts:new Date().toLocaleTimeString(),question:`Screenshot`,analysis:``,src:e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:`${n}/api/screenshots/${e.file}`},...t.slice(0,9)])}catch(e){c({error:e.message})}i(!1)},g=async()=>{if(l.trim()){o(!0);try{let e=await E(`/api/screen/analyze`,{question:l.trim(),monitor:d});if(c(e),e?.analysis){let t=e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:e.file?`${n}/api/screenshots/${e.file}`:``;m(n=>[{ts:new Date().toLocaleTimeString(),question:l.trim(),analysis:e.analysis??``,src:t},...n.slice(0,9)])}}catch(e){c({error:e.message})}o(!1)}},v=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},y=s?.base64?`data:image/${s.format??`jpeg`};base64,${s.base64}`:s?.file?`${n}/api/screenshots/${s.file}`:null;return(0,k.jsxs)(`div`,{className:vE.root,children:[(0,k.jsx)(`div`,{className:vE.header,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:vE.title,children:`🖥️ Screen Capture`}),(0,k.jsxs)(`div`,{className:vE.subtitle,children:[e(`screen.capture`),` and analyze your desktop screen with AI vision`]})]})}),(0,k.jsxs)(`div`,{className:vE.controls,children:[(0,k.jsxs)(`div`,{className:vE.monitorRow,children:[(0,k.jsx)(`label`,{className:vE.label,children:`Monitor`}),[1,2,3].map(e=>(0,k.jsxs)(`button`,{className:`${vE.monitorBtn} ${d===e?vE.monitorActive:``}`,onClick:()=>f(e),children:[`Monitor `,e]},e))]}),(0,k.jsx)(`button`,{className:vE.captureBtn,onClick:h,disabled:r||a,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`spinner`}),` Capturing…`]}):`📷 Capture Screen`})]}),(0,k.jsxs)(`div`,{className:vE.analyzeSection,children:[(0,k.jsx)(`div`,{className:vE.sectionTitle,children:`Capture + Analyze`}),(0,k.jsx)(`div`,{className:vE.presets,children:yE.map(e=>(0,k.jsxs)(`button`,{className:`${vE.preset} ${l===e?vE.presetActive:``}`,onClick:()=>u(e),children:[e.slice(0,50),e.length>50?`…`:``]},e))}),(0,k.jsxs)(`div`,{className:vE.questionRow,children:[(0,k.jsx)(`input`,{className:vE.questionInput,value:l,onChange:e=>u(e.target.value),placeholder:`Ask something about your screen…`,onKeyDown:e=>e.key===`Enter`&&g()}),(0,k.jsx)(`button`,{className:vE.analyzeBtn,onClick:g,disabled:!l.trim()||r||a,children:a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`spinner`}),` Analyzing…`]}):`🔍 Analyze`})]})]}),s?.error&&(0,k.jsx)(`div`,{className:vE.error,children:s.error}),y&&(0,k.jsxs)(`div`,{className:vE.screenshotContainer,children:[(0,k.jsx)(`img`,{src:y,className:vE.screenshot,alt:`Screen capture`}),s?.width&&s?.height&&(0,k.jsxs)(`div`,{className:vE.screenshotMeta,children:[s.width,` × `,s.height,`px`]})]}),s?.analysis&&(0,k.jsxs)(`div`,{className:vE.analysis,children:[(0,k.jsx)(`div`,{className:vE.analysisTitle,children:`AI Analysis`}),(0,k.jsx)(`div`,{className:vE.analysisText,children:s.analysis}),(0,k.jsx)(`button`,{className:vE.continueInChat,onClick:()=>v(`I captured my screen. Here's what the AI saw:\n\n${s.analysis}\n\nCan you help me with this?`),children:`Continue in Chat →`})]}),p.length>0&&(0,k.jsxs)(`div`,{className:vE.history,children:[(0,k.jsx)(`div`,{className:vE.sectionTitle,children:`Recent Captures`}),(0,k.jsx)(`div`,{className:vE.historyGrid,children:p.map((e,t)=>(0,k.jsxs)(`div`,{className:vE.historyItem,children:[e.src&&(0,k.jsx)(`img`,{src:e.src,className:vE.historyThumb,alt:e.question}),(0,k.jsxs)(`div`,{className:vE.historyMeta,children:[(0,k.jsx)(`div`,{className:vE.historyTs,children:e.ts}),(0,k.jsx)(`div`,{className:vE.historyQ,children:e.question}),e.analysis&&(0,k.jsxs)(`div`,{className:vE.historyA,children:[e.analysis.slice(0,120),`…`]})]})]},t))})]})]})}var xE={root:`_root_v12qq_1`,header:`_header_v12qq_3`,title:`_title_v12qq_4`,subtitle:`_subtitle_v12qq_5`,section:`_section_v12qq_7`,sectionTitle:`_sectionTitle_v12qq_8`,quickBtns:`_quickBtns_v12qq_10`,quickBtn:`_quickBtn_v12qq_10`,searchRow:`_searchRow_v12qq_14`,searchInput:`_searchInput_v12qq_15`,searchBtn:`_searchBtn_v12qq_16`,modeRow:`_modeRow_v12qq_19`,modeBtn:`_modeBtn_v12qq_20`,modeActive:`_modeActive_v12qq_21`,routeInputs:`_routeInputs_v12qq_23`,inputWrapper:`_inputWrapper_v12qq_24`,inputIcon:`_inputIcon_v12qq_25`,routeInput:`_routeInput_v12qq_23`,swapBtn:`_swapBtn_v12qq_27`,dirBtns:`_dirBtns_v12qq_29`,dirBtn:`_dirBtn_v12qq_29`,openMapsBtn:`_openMapsBtn_v12qq_32`,error:`_error_v12qq_34`,resultCard:`_resultCard_v12qq_36`,routeSummary:`_routeSummary_v12qq_37`,routeDistance:`_routeDistance_v12qq_38`,routeDuration:`_routeDuration_v12qq_39`,routeMode:`_routeMode_v12qq_40`,steps:`_steps_v12qq_41`,step:`_step_v12qq_41`,stepNum:`_stepNum_v12qq_43`,stepText:`_stepText_v12qq_44`,mapLink:`_mapLink_v12qq_45`,askChatBtn:`_askChatBtn_v12qq_47`,savedRoute:`_savedRoute_v12qq_49`,savedFrom:`_savedFrom_v12qq_51`,savedArrow:`_savedArrow_v12qq_52`,savedTo:`_savedTo_v12qq_53`,savedTs:`_savedTs_v12qq_54`},SE=[`driving`,`walking`,`bicycling`,`transit`],CE={driving:`🚗`,walking:`🚶`,bicycling:`🚲`,transit:`🚌`},wE=[{label:`🏥 Nearest Hospital`,query:`nearest hospital`},{label:`⛽ Gas Station`,query:`gas station near me`},{label:`🛒 Supermarket`,query:`supermarket near me`},{label:`☕ Coffee Shop`,query:`coffee shop near me`},{label:`🏧 ATM`,query:`ATM near me`},{label:`🍕 Pizza`,query:`pizza restaurant near me`}];function TE(e,t,n){try{let r=JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`),i=[{from:e,to:t,label:n,ts:new Date().toISOString()},...r.filter(n=>!(n.from===e&&n.to===t))].slice(0,10);localStorage.setItem(`nha_maps_routes`,JSON.stringify(i))}catch{}}function EE(){try{return JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`)}catch{return[]}}function DE(){let e=j(),t=ne(e=>e.setView),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(`driving`),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(EE),[m,h]=(0,_.useState)(``),g=async()=>{if(!(!n.trim()||!i.trim())){l(!0),d(null);try{let e=await T(`/api/maps/directions?from=${encodeURIComponent(n.trim())}&to=${encodeURIComponent(i.trim())}&mode=${o}`);e&&(d(e),e.error||(TE(n.trim(),i.trim()),p(EE())))}catch{d({url:`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`}),TE(n.trim(),i.trim()),p(EE())}l(!1)}},v=e=>{let t=`https://www.google.com/maps/search/${encodeURIComponent(e)}`;window.open(t,`_blank`)},y=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},b=e=>{r(e.from),a(e.to)},x=n.trim()&&i.trim()?`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`:null;return(0,k.jsxs)(`div`,{className:xE.root,children:[(0,k.jsx)(`div`,{className:xE.header,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:xE.title,children:`🗺️ Maps & Directions`}),(0,k.jsx)(`div`,{className:xE.subtitle,children:e(`maps.directions`)})]})}),(0,k.jsxs)(`div`,{className:xE.section,children:[(0,k.jsx)(`div`,{className:xE.sectionTitle,children:e(`common.search`)}),(0,k.jsx)(`div`,{className:xE.quickBtns,children:wE.map(e=>(0,k.jsx)(`button`,{className:xE.quickBtn,onClick:()=>v(e.query),children:e.label},e.label))}),(0,k.jsxs)(`div`,{className:xE.searchRow,children:[(0,k.jsx)(`input`,{className:xE.searchInput,value:m,onChange:e=>h(e.target.value),placeholder:`Search for a place, address, or business…`,onKeyDown:e=>e.key===`Enter`&&v(m)}),(0,k.jsx)(`button`,{className:xE.searchBtn,onClick:()=>v(m),disabled:!m.trim(),children:`Search ↗`})]})]}),(0,k.jsxs)(`div`,{className:xE.section,children:[(0,k.jsx)(`div`,{className:xE.sectionTitle,children:`Directions`}),(0,k.jsx)(`div`,{className:xE.modeRow,children:SE.map(e=>(0,k.jsxs)(`button`,{className:`${xE.modeBtn} ${o===e?xE.modeActive:``}`,onClick:()=>s(e),title:e,children:[CE[e],` `,e.charAt(0).toUpperCase()+e.slice(1)]},e))}),(0,k.jsxs)(`div`,{className:xE.routeInputs,children:[(0,k.jsxs)(`div`,{className:xE.inputWrapper,children:[(0,k.jsx)(`span`,{className:xE.inputIcon,children:`A`}),(0,k.jsx)(`input`,{className:xE.routeInput,value:n,onChange:e=>r(e.target.value),placeholder:`From (address, city, or 'my location')`,onKeyDown:e=>e.key===`Enter`&&g()})]}),(0,k.jsx)(`button`,{className:xE.swapBtn,onClick:()=>{r(i),a(n)},title:`Swap`,children:`⇅`}),(0,k.jsxs)(`div`,{className:xE.inputWrapper,children:[(0,k.jsx)(`span`,{className:xE.inputIcon,children:`B`}),(0,k.jsx)(`input`,{className:xE.routeInput,value:i,onChange:e=>a(e.target.value),placeholder:`To (address, city, or landmark)`,onKeyDown:e=>e.key===`Enter`&&g()})]})]}),(0,k.jsxs)(`div`,{className:xE.dirBtns,children:[(0,k.jsx)(`button`,{className:xE.dirBtn,onClick:g,disabled:c||!n.trim()||!i.trim(),children:c?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`spinner`}),` Getting route…`]}):`🗺️ Get Directions`}),x&&(0,k.jsx)(`a`,{className:xE.openMapsBtn,href:x,target:`_blank`,rel:`noreferrer`,children:`Open in Google Maps ↗`})]})]}),u?.error&&(0,k.jsx)(`div`,{className:xE.error,children:u.error}),u&&!u.error&&(0,k.jsxs)(`div`,{className:xE.resultCard,children:[(u.distance||u.duration)&&(0,k.jsxs)(`div`,{className:xE.routeSummary,children:[u.distance&&(0,k.jsxs)(`span`,{className:xE.routeDistance,children:[`📏 `,u.distance]}),u.duration&&(0,k.jsxs)(`span`,{className:xE.routeDuration,children:[`⏱ `,u.duration]}),(0,k.jsxs)(`span`,{className:xE.routeMode,children:[CE[o],` `,o]})]}),u.steps&&u.steps.length>0&&(0,k.jsx)(`div`,{className:xE.steps,children:u.steps.map((e,t)=>(0,k.jsxs)(`div`,{className:xE.step,children:[(0,k.jsx)(`span`,{className:xE.stepNum,children:t+1}),(0,k.jsx)(`span`,{className:xE.stepText,children:e})]},t))}),u.url&&(0,k.jsx)(`a`,{className:xE.mapLink,href:u.url,target:`_blank`,rel:`noreferrer`,children:`View full route on Google Maps ↗`}),(0,k.jsx)(`button`,{className:xE.askChatBtn,onClick:()=>y(`Give me directions from "${n}" to "${i}" by ${o}. Include estimated time, distance, and any traffic alerts or alternative routes.`),children:`Ask AI for detailed route advice →`})]}),f.length>0&&(0,k.jsxs)(`div`,{className:xE.section,children:[(0,k.jsx)(`div`,{className:xE.sectionTitle,children:`Recent Routes`}),f.map((e,t)=>(0,k.jsxs)(`div`,{className:xE.savedRoute,onClick:()=>b(e),children:[(0,k.jsx)(`span`,{className:xE.savedFrom,children:e.from}),(0,k.jsx)(`span`,{className:xE.savedArrow,children:`→`}),(0,k.jsx)(`span`,{className:xE.savedTo,children:e.to}),(0,k.jsx)(`span`,{className:xE.savedTs,children:new Date(e.ts).toLocaleDateString()})]},t))]})]})}var $={root:`_root_esnjz_1`,header:`_header_esnjz_3`,title:`_title_esnjz_4`,subtitle:`_subtitle_esnjz_5`,addBtn:`_addBtn_esnjz_6`,quickAdd:`_quickAdd_esnjz_8`,quickLabel:`_quickLabel_esnjz_9`,quickPresets:`_quickPresets_esnjz_10`,quickPreset:`_quickPreset_esnjz_10`,section:`_section_esnjz_14`,sectionTitle:`_sectionTitle_esnjz_15`,loading:`_loading_esnjz_17`,empty:`_empty_esnjz_18`,card:`_card_esnjz_20`,cardPast:`_cardPast_esnjz_21`,cardLeft:`_cardLeft_esnjz_22`,reminderMsg:`_reminderMsg_esnjz_23`,reminderTime:`_reminderTime_esnjz_24`,timeBadge:`_timeBadge_esnjz_25`,countdown:`_countdown_esnjz_26`,timePast:`_timePast_esnjz_27`,sentBadge:`_sentBadge_esnjz_28`,cancelledBadge:`_cancelledBadge_esnjz_29`,cancelBtn:`_cancelBtn_esnjz_30`,repeatBtn:`_repeatBtn_esnjz_31`,aiButtons:`_aiButtons_esnjz_33`,aiBtn:`_aiBtn_esnjz_34`,overlay:`_overlay_esnjz_38`,modal:`_modal_esnjz_39`,modalTitle:`_modalTitle_esnjz_40`,label:`_label_esnjz_41`,input:`_input_esnjz_42`,msgTemplates:`_msgTemplates_esnjz_44`,msgTemplate:`_msgTemplate_esnjz_44`,msgTemplateActive:`_msgTemplateActive_esnjz_47`,typeTabs:`_typeTabs_esnjz_49`,typeTab:`_typeTab_esnjz_49`,typeTabActive:`_typeTabActive_esnjz_51`,relRow:`_relRow_esnjz_53`,inLabel:`_inLabel_esnjz_54`,relInput:`_relInput_esnjz_55`,relSelect:`_relSelect_esnjz_56`,formErr:`_formErr_esnjz_58`,formOk:`_formOk_esnjz_59`,modalBtns:`_modalBtns_esnjz_60`,cancelModalBtn:`_cancelModalBtn_esnjz_61`,saveBtn:`_saveBtn_esnjz_62`},OE=[{label:`In 5 min`,value:`in 5 minutes`},{label:`In 15 min`,value:`in 15 minutes`},{label:`In 30 min`,value:`in 30 minutes`},{label:`In 1 hour`,value:`in 1 hour`},{label:`In 2 hours`,value:`in 2 hours`},{label:`In 3 hours`,value:`in 3 hours`},{label:`Tomorrow 9am`,value:`tomorrow at 09:00`},{label:`Tomorrow noon`,value:`tomorrow at 12:00`}],kE=[`Take a break and stretch`,`Check emails`,`Join the standup call`,`Review and respond to messages`,`Take your medication`,`Drink water`,`Focus review — what did you accomplish in the last hour?`,`Follow up on pending tasks`,`End of work day — log your achievements`,`Weekly review — prepare for next week`];function AE(e){if(e<1)return`now`;if(e<60)return`in ${e}m`;let t=Math.floor(e/60),n=e%60;return n>0?`in ${t}h ${n}m`:`in ${t}h`}function jE(){let e=j(),t=ne(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)({message:``,atTime:``,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`}),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(!1),g=()=>{a(!0),T(`/api/reminders`).then(e=>{r(e?.reminders??[]),a(!1)}).catch(()=>{r([]),a(!1)})};(0,_.useEffect)(()=>{g()},[]);let v=async()=>{if(!o.message.trim()){d(`Message is required`);return}let e=``;if(o.atTimeType===`relative`)e=`in ${o.relValue} ${o.relUnit}`;else{if(!o.atTime){d(`Time is required`);return}e=o.atTime}l(!0),d(``);try{await E(`/api/reminders`,{message:o.message.trim(),atTime:e}),p(`Reminder set!`),setTimeout(()=>{p(``),h(!1)},1500),g()}catch(e){d(e.message??`Failed to set reminder`)}l(!1)},y=e=>{confirm(`Cancel this reminder?`)&&E(`/api/reminders/cancel`,{id:e}).then(g)},b=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},x=n.filter(e=>e.status===`pending`),S=n.filter(e=>e.status!==`pending`);return(0,k.jsxs)(`div`,{className:$.root,children:[(0,k.jsxs)(`div`,{className:$.header,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:$.title,children:`🔔 Reminders`}),(0,k.jsx)(`div`,{className:$.subtitle,children:`Set one-time notifications via the NHA daemon`})]}),(0,k.jsx)(`button`,{className:$.addBtn,onClick:()=>{h(!0),d(``),p(``)},children:`+ New Reminder`})]}),(0,k.jsxs)(`div`,{className:$.quickAdd,children:[(0,k.jsx)(`div`,{className:$.quickLabel,children:`Quick reminder for now:`}),(0,k.jsx)(`div`,{className:$.quickPresets,children:OE.map(e=>(0,k.jsx)(`button`,{className:$.quickPreset,onClick:()=>{s(e=>({...e,atTimeType:`relative`,atTime:``,message:e.message||`Reminder`})),h(!0),d(``),p(``)},children:e.label},e.value))})]}),i&&(0,k.jsxs)(`div`,{className:$.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!i&&(0,k.jsxs)(`div`,{className:$.section,children:[(0,k.jsxs)(`div`,{className:$.sectionTitle,children:[`Pending (`,x.length,`)`]}),x.length===0&&(0,k.jsx)(`div`,{className:$.empty,children:`No pending reminders. Set one to get notified.`}),x.map(e=>(0,k.jsxs)(`div`,{className:$.card,children:[(0,k.jsxs)(`div`,{className:$.cardLeft,children:[(0,k.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,k.jsxs)(`div`,{className:$.reminderTime,children:[(0,k.jsx)(`span`,{className:$.timeBadge,children:new Date(e.atTime).toLocaleString()}),e.minutesUntil!==void 0&&(0,k.jsx)(`span`,{className:$.countdown,children:AE(e.minutesUntil)})]})]}),(0,k.jsx)(`button`,{className:$.cancelBtn,onClick:()=>y(e.id),children:`Cancel`})]},e.id))]}),S.length>0&&(0,k.jsxs)(`div`,{className:$.section,children:[(0,k.jsxs)(`div`,{className:$.sectionTitle,children:[`Recent (`,S.length,`)`]}),S.slice(0,10).map(e=>(0,k.jsxs)(`div`,{className:`${$.card} ${$.cardPast}`,children:[(0,k.jsxs)(`div`,{className:$.cardLeft,children:[(0,k.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,k.jsxs)(`div`,{className:$.reminderTime,children:[(0,k.jsx)(`span`,{className:e.status===`sent`?$.sentBadge:$.cancelledBadge,children:e.status}),(0,k.jsx)(`span`,{className:$.timePast,children:new Date(e.atTime).toLocaleString()})]})]}),(0,k.jsx)(`button`,{className:$.repeatBtn,onClick:()=>{s(t=>({...t,message:e.message,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`})),h(!0)},children:`Repeat`})]},e.id))]}),(0,k.jsxs)(`div`,{className:$.section,children:[(0,k.jsx)(`div`,{className:$.sectionTitle,children:`AI-Powered Reminders`}),(0,k.jsxs)(`div`,{className:$.aiButtons,children:[(0,k.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder to check my emails in 30 minutes`),children:`📧 Email check in 30min`}),(0,k.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder every hour to take a break and drink water`),children:`💧 Hourly water break`}),(0,k.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder at the end of the work day (6pm) to do an evening review of my tasks and prepare tomorrow's plan`),children:`🌆 Evening review 6pm`}),(0,k.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Look at my calendar and set reminders for all events today`),children:`📅 Remind me of today's events`})]})]}),m&&(0,k.jsx)(`div`,{className:$.overlay,onClick:e=>{e.target===e.currentTarget&&h(!1)},children:(0,k.jsxs)(`div`,{className:$.modal,children:[(0,k.jsx)(`div`,{className:$.modalTitle,children:e(`reminders.new`)}),(0,k.jsx)(`div`,{className:$.label,children:`Message *`}),(0,k.jsx)(`div`,{className:$.msgTemplates,children:kE.map(e=>(0,k.jsx)(`button`,{className:`${$.msgTemplate} ${o.message===e?$.msgTemplateActive:``}`,onClick:()=>s(t=>({...t,message:e})),children:e},e))}),(0,k.jsx)(`input`,{className:$.input,value:o.message,onChange:e=>s(t=>({...t,message:e.target.value})),placeholder:`Reminder message (e.g. Call John)`}),(0,k.jsx)(`div`,{className:$.label,children:`When *`}),(0,k.jsxs)(`div`,{className:$.typeTabs,children:[(0,k.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`relative`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`relative`})),children:`Relative`}),(0,k.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`absolute`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`absolute`})),children:`Exact time`})]}),o.atTimeType===`relative`?(0,k.jsxs)(`div`,{className:$.relRow,children:[(0,k.jsx)(`span`,{className:$.inLabel,children:`in`}),(0,k.jsx)(`input`,{className:$.relInput,type:`number`,min:`1`,value:o.relValue,onChange:e=>s(t=>({...t,relValue:e.target.value}))}),(0,k.jsxs)(`select`,{className:$.relSelect,value:o.relUnit,onChange:e=>s(t=>({...t,relUnit:e.target.value})),children:[(0,k.jsx)(`option`,{value:`minutes`,children:`minutes`}),(0,k.jsx)(`option`,{value:`hours`,children:`hours`}),(0,k.jsx)(`option`,{value:`days`,children:`days`})]})]}):(0,k.jsx)(`input`,{className:$.input,type:`datetime-local`,value:o.atTime,onChange:e=>s(t=>({...t,atTime:e.target.value}))}),u&&(0,k.jsx)(`div`,{className:$.formErr,children:u}),f&&(0,k.jsx)(`div`,{className:$.formOk,children:f}),(0,k.jsxs)(`div`,{className:$.modalBtns,children:[(0,k.jsx)(`button`,{className:$.cancelModalBtn,onClick:()=>h(!1),children:`Cancel`}),(0,k.jsx)(`button`,{className:$.saveBtn,onClick:v,disabled:c,children:c?`Setting…`:`🔔 Set Reminder`})]})]})})]})}var ME={root:`_root_atgeb_1`,icon:`_icon_atgeb_10`,title:`_title_atgeb_11`,sub:`_sub_atgeb_12`},NE={dashboard:`⚡`,email:`📧`,calendar:`📅`,tasks:`✅`,contacts:`👤`,notes:`📝`,drive:`💾`,onedrive:`☁️`,mstodo:`📋`,github:`🐙`,slack:`💬`,notion:`📋`,collab:`🏛️`,maps:`🗺️`,cron:`⏰`,screen:`🖥️`,reminders:`🔔`,birthdays:`🎂`,settings:`⚙️`,agents:`🤖`,plan:`🗓️`,webcraft:`🔨`,connectors:`🔗`};function PE({view:e}){let t=j();return(0,k.jsxs)(`div`,{className:ME.root,children:[(0,k.jsx)(`div`,{className:ME.icon,children:NE[e]??`🔧`}),(0,k.jsx)(`div`,{className:ME.title,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,k.jsx)(`div`,{className:ME.sub,children:t(`common.comingSoon`)})]})}function FE({activeView:e}){switch(e){case`dashboard`:return(0,k.jsx)(wt,{});case`chat`:return(0,k.jsx)(Ee,{});case`email`:return(0,k.jsx)(rn,{});case`calendar`:return(0,k.jsx)(cn,{});case`tasks`:return(0,k.jsx)(Et,{});case`notes`:return(0,k.jsx)(Rt,{});case`contacts`:return(0,k.jsx)(Vt,{});case`birthdays`:return(0,k.jsx)(Mt,{});case`cron`:return(0,k.jsx)(It,{});case`connectors`:return(0,k.jsx)(Yt,{});case`agents`:return(0,k.jsx)(fn,{});case`drive`:return(0,k.jsx)(mn,{});case`onedrive`:return(0,k.jsx)(hE,{});case`mstodo`:return(0,k.jsx)(_E,{});case`github`:return(0,k.jsx)(gn,{});case`slack`:return(0,k.jsx)(yn,{});case`notion`:return(0,k.jsx)(bn,{});case`collab`:return(0,k.jsx)(wn,{});case`plan`:return(0,k.jsx)(pE,{});case`screen`:return(0,k.jsx)(bE,{});case`maps`:return(0,k.jsx)(DE,{});case`reminders`:return(0,k.jsx)(jE,{});case`settings`:return(0,k.jsx)(At,{});default:return(0,k.jsx)(PE,{view:e})}}function IE(){let{activeView:e}=ne();return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{style:{display:e===`studio`?`contents`:`none`},children:(0,k.jsx)(yt,{})}),(0,k.jsx)(`div`,{style:{display:e===`webcraft`?`contents`:`none`},children:(0,k.jsx)(oE,{})}),e!==`studio`&&e!==`webcraft`&&(0,k.jsx)(FE,{activeView:e})]})}(0,v.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(_.StrictMode,{children:(0,k.jsx)(me,{children:(0,k.jsx)(IE,{})})}));