vibora 8.3.0 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/vibora.js
CHANGED
|
@@ -32635,7 +32635,7 @@ function installUv() {
|
|
|
32635
32635
|
var package_default = {
|
|
32636
32636
|
name: "vibora",
|
|
32637
32637
|
private: true,
|
|
32638
|
-
version: "8.
|
|
32638
|
+
version: "8.4.0",
|
|
32639
32639
|
description: "Harness Attention. Orchestrate Agents. Ship.",
|
|
32640
32640
|
license: "PolyForm-Shield-1.0.0",
|
|
32641
32641
|
type: "module",
|
|
@@ -42,7 +42,7 @@ WARNING: This link could potentially be dangerous`)){const y=window.open();if(y)
|
|
|
42
42
|
`,d.VT="\v",d.FF="\f",d.CR="\r",d.SO="",d.SI="",d.DLE="",d.DC1="",d.DC2="",d.DC3="",d.DC4="",d.NAK="",d.SYN="",d.ETB="",d.CAN="",d.EM="",d.SUB="",d.ESC="\x1B",d.FS="",d.GS="",d.RS="",d.US="",d.SP=" ",d.DEL=""})(l||(o.C0=l={})),(function(d){d.PAD="",d.HOP="",d.BPH="",d.NBH="",d.IND="",d.NEL="
",d.SSA="",d.ESA="",d.HTS="",d.HTJ="",d.VTS="",d.PLD="",d.PLU="",d.RI="",d.SS2="",d.SS3="",d.DCS="",d.PU1="",d.PU2="",d.STS="",d.CCH="",d.MW="",d.SPA="",d.EPA="",d.SOS="",d.SGCI="",d.SCI="",d.CSI="",d.ST="",d.OSC="",d.PM="",d.APC=""})(u||(o.C1=u={})),(function(d){d.ST=`${l.ESC}\\`})(p||(o.C1_ESCAPED=p={}))},7399:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.evaluateKeyboardEvent=void 0;const u=l(2584),p={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:["'",'"']};o.evaluateKeyboardEvent=function(d,m,g,x){const _={type:0,cancel:!1,key:void 0},b=(d.shiftKey?1:0)|(d.altKey?2:0)|(d.ctrlKey?4:0)|(d.metaKey?8:0);switch(d.keyCode){case 0:d.key==="UIKeyInputUpArrow"?_.key=m?u.C0.ESC+"OA":u.C0.ESC+"[A":d.key==="UIKeyInputLeftArrow"?_.key=m?u.C0.ESC+"OD":u.C0.ESC+"[D":d.key==="UIKeyInputRightArrow"?_.key=m?u.C0.ESC+"OC":u.C0.ESC+"[C":d.key==="UIKeyInputDownArrow"&&(_.key=m?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:_.key=d.ctrlKey?"\b":u.C0.DEL,d.altKey&&(_.key=u.C0.ESC+_.key);break;case 9:if(d.shiftKey){_.key=u.C0.ESC+"[Z";break}_.key=u.C0.HT,_.cancel=!0;break;case 13:_.key=d.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,_.cancel=!0;break;case 27:_.key=u.C0.ESC,d.altKey&&(_.key=u.C0.ESC+u.C0.ESC),_.cancel=!0;break;case 37:if(d.metaKey)break;b?(_.key=u.C0.ESC+"[1;"+(b+1)+"D",_.key===u.C0.ESC+"[1;3D"&&(_.key=u.C0.ESC+(g?"b":"[1;5D"))):_.key=m?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(d.metaKey)break;b?(_.key=u.C0.ESC+"[1;"+(b+1)+"C",_.key===u.C0.ESC+"[1;3C"&&(_.key=u.C0.ESC+(g?"f":"[1;5C"))):_.key=m?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(d.metaKey)break;b?(_.key=u.C0.ESC+"[1;"+(b+1)+"A",g||_.key!==u.C0.ESC+"[1;3A"||(_.key=u.C0.ESC+"[1;5A")):_.key=m?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(d.metaKey)break;b?(_.key=u.C0.ESC+"[1;"+(b+1)+"B",g||_.key!==u.C0.ESC+"[1;3B"||(_.key=u.C0.ESC+"[1;5B")):_.key=m?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:d.shiftKey||d.ctrlKey||(_.key=u.C0.ESC+"[2~");break;case 46:_.key=b?u.C0.ESC+"[3;"+(b+1)+"~":u.C0.ESC+"[3~";break;case 36:_.key=b?u.C0.ESC+"[1;"+(b+1)+"H":m?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:_.key=b?u.C0.ESC+"[1;"+(b+1)+"F":m?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:d.shiftKey?_.type=2:d.ctrlKey?_.key=u.C0.ESC+"[5;"+(b+1)+"~":_.key=u.C0.ESC+"[5~";break;case 34:d.shiftKey?_.type=3:d.ctrlKey?_.key=u.C0.ESC+"[6;"+(b+1)+"~":_.key=u.C0.ESC+"[6~";break;case 112:_.key=b?u.C0.ESC+"[1;"+(b+1)+"P":u.C0.ESC+"OP";break;case 113:_.key=b?u.C0.ESC+"[1;"+(b+1)+"Q":u.C0.ESC+"OQ";break;case 114:_.key=b?u.C0.ESC+"[1;"+(b+1)+"R":u.C0.ESC+"OR";break;case 115:_.key=b?u.C0.ESC+"[1;"+(b+1)+"S":u.C0.ESC+"OS";break;case 116:_.key=b?u.C0.ESC+"[15;"+(b+1)+"~":u.C0.ESC+"[15~";break;case 117:_.key=b?u.C0.ESC+"[17;"+(b+1)+"~":u.C0.ESC+"[17~";break;case 118:_.key=b?u.C0.ESC+"[18;"+(b+1)+"~":u.C0.ESC+"[18~";break;case 119:_.key=b?u.C0.ESC+"[19;"+(b+1)+"~":u.C0.ESC+"[19~";break;case 120:_.key=b?u.C0.ESC+"[20;"+(b+1)+"~":u.C0.ESC+"[20~";break;case 121:_.key=b?u.C0.ESC+"[21;"+(b+1)+"~":u.C0.ESC+"[21~";break;case 122:_.key=b?u.C0.ESC+"[23;"+(b+1)+"~":u.C0.ESC+"[23~";break;case 123:_.key=b?u.C0.ESC+"[24;"+(b+1)+"~":u.C0.ESC+"[24~";break;default:if(!d.ctrlKey||d.shiftKey||d.altKey||d.metaKey)if(g&&!x||!d.altKey||d.metaKey)!g||d.altKey||d.ctrlKey||d.shiftKey||!d.metaKey?d.key&&!d.ctrlKey&&!d.altKey&&!d.metaKey&&d.keyCode>=48&&d.key.length===1?_.key=d.key:d.key&&d.ctrlKey&&(d.key==="_"&&(_.key=u.C0.US),d.key==="@"&&(_.key=u.C0.NUL)):d.keyCode===65&&(_.type=1);else{const y=p[d.keyCode],v=y?.[d.shiftKey?1:0];if(v)_.key=u.C0.ESC+v;else if(d.keyCode>=65&&d.keyCode<=90){const E=d.ctrlKey?d.keyCode-64:d.keyCode+32;let C=String.fromCharCode(E);d.shiftKey&&(C=C.toUpperCase()),_.key=u.C0.ESC+C}else if(d.keyCode===32)_.key=u.C0.ESC+(d.ctrlKey?u.C0.NUL:" ");else if(d.key==="Dead"&&d.code.startsWith("Key")){let E=d.code.slice(3,4);d.shiftKey||(E=E.toLowerCase()),_.key=u.C0.ESC+E,_.cancel=!0}}else d.keyCode>=65&&d.keyCode<=90?_.key=String.fromCharCode(d.keyCode-64):d.keyCode===32?_.key=u.C0.NUL:d.keyCode>=51&&d.keyCode<=55?_.key=String.fromCharCode(d.keyCode-51+27):d.keyCode===56?_.key=u.C0.DEL:d.keyCode===219?_.key=u.C0.ESC:d.keyCode===220?_.key=u.C0.FS:d.keyCode===221&&(_.key=u.C0.GS)}return _}},482:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Utf8ToUtf32=o.StringToUtf32=o.utf32ToString=o.stringFromCodePoint=void 0,o.stringFromCodePoint=function(l){return l>65535?(l-=65536,String.fromCharCode(55296+(l>>10))+String.fromCharCode(l%1024+56320)):String.fromCharCode(l)},o.utf32ToString=function(l,u=0,p=l.length){let d="";for(let m=u;m<p;++m){let g=l[m];g>65535?(g-=65536,d+=String.fromCharCode(55296+(g>>10))+String.fromCharCode(g%1024+56320)):d+=String.fromCharCode(g)}return d},o.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(l,u){const p=l.length;if(!p)return 0;let d=0,m=0;if(this._interim){const g=l.charCodeAt(m++);56320<=g&&g<=57343?u[d++]=1024*(this._interim-55296)+g-56320+65536:(u[d++]=this._interim,u[d++]=g),this._interim=0}for(let g=m;g<p;++g){const x=l.charCodeAt(g);if(55296<=x&&x<=56319){if(++g>=p)return this._interim=x,d;const _=l.charCodeAt(g);56320<=_&&_<=57343?u[d++]=1024*(x-55296)+_-56320+65536:(u[d++]=x,u[d++]=_)}else x!==65279&&(u[d++]=x)}return d}},o.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(l,u){const p=l.length;if(!p)return 0;let d,m,g,x,_=0,b=0,y=0;if(this.interim[0]){let C=!1,w=this.interim[0];w&=(224&w)==192?31:(240&w)==224?15:7;let A,R=0;for(;(A=63&this.interim[++R])&&R<4;)w<<=6,w|=A;const O=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,N=O-R;for(;y<N;){if(y>=p)return 0;if(A=l[y++],(192&A)!=128){y--,C=!0;break}this.interim[R++]=A,w<<=6,w|=63&A}C||(O===2?w<128?y--:u[_++]=w:O===3?w<2048||w>=55296&&w<=57343||w===65279||(u[_++]=w):w<65536||w>1114111||(u[_++]=w)),this.interim.fill(0)}const v=p-4;let E=y;for(;E<p;){for(;!(!(E<v)||128&(d=l[E])||128&(m=l[E+1])||128&(g=l[E+2])||128&(x=l[E+3]));)u[_++]=d,u[_++]=m,u[_++]=g,u[_++]=x,E+=4;if(d=l[E++],d<128)u[_++]=d;else if((224&d)==192){if(E>=p)return this.interim[0]=d,_;if(m=l[E++],(192&m)!=128){E--;continue}if(b=(31&d)<<6|63&m,b<128){E--;continue}u[_++]=b}else if((240&d)==224){if(E>=p)return this.interim[0]=d,_;if(m=l[E++],(192&m)!=128){E--;continue}if(E>=p)return this.interim[0]=d,this.interim[1]=m,_;if(g=l[E++],(192&g)!=128){E--;continue}if(b=(15&d)<<12|(63&m)<<6|63&g,b<2048||b>=55296&&b<=57343||b===65279)continue;u[_++]=b}else if((248&d)==240){if(E>=p)return this.interim[0]=d,_;if(m=l[E++],(192&m)!=128){E--;continue}if(E>=p)return this.interim[0]=d,this.interim[1]=m,_;if(g=l[E++],(192&g)!=128){E--;continue}if(E>=p)return this.interim[0]=d,this.interim[1]=m,this.interim[2]=g,_;if(x=l[E++],(192&x)!=128){E--;continue}if(b=(7&d)<<18|(63&m)<<12|(63&g)<<6|63&x,b<65536||b>1114111)continue;u[_++]=b}}return _}}},225:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const u=l(1480),p=[[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]],d=[[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]];let m;o.UnicodeV6=class{constructor(){if(this.version="6",!m){m=new Uint8Array(65536),m.fill(1),m[0]=0,m.fill(0,1,32),m.fill(0,127,160),m.fill(2,4352,4448),m[9001]=2,m[9002]=2,m.fill(2,11904,42192),m[12351]=1,m.fill(2,44032,55204),m.fill(2,63744,64256),m.fill(2,65040,65050),m.fill(2,65072,65136),m.fill(2,65280,65377),m.fill(2,65504,65511);for(let g=0;g<p.length;++g)m.fill(0,p[g][0],p[g][1]+1)}}wcwidth(g){return g<32?0:g<127?1:g<65536?m[g]:(function(x,_){let b,y=0,v=_.length-1;if(x<_[0][0]||x>_[v][1])return!1;for(;v>=y;)if(b=y+v>>1,x>_[b][1])y=b+1;else{if(!(x<_[b][0]))return!0;v=b-1}return!1})(g,d)?0:g>=131072&&g<=196605||g>=196608&&g<=262141?2:1}charProperties(g,x){let _=this.wcwidth(g),b=_===0&&x!==0;if(b){const y=u.UnicodeService.extractWidth(x);y===0?b=!1:y>_&&(_=y)}return u.UnicodeService.createPropertyValue(0,_,b)}}},5981:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WriteBuffer=void 0;const u=l(8460),p=l(844);class d extends p.Disposable{constructor(g){super(),this._action=g,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(g,x){if(x!==void 0&&this._syncCalls>x)return void(this._syncCalls=0);if(this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const b=this._callbacks.shift();b&&b()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(g,x){if(this._pendingData>5e7)throw new 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+=g.length,this._writeBuffer.push(g),this._callbacks.push(x),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(x)}_innerWrite(g=0,x=!0){const _=g||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const b=this._writeBuffer[this._bufferOffset],y=this._action(b,x);if(y){const E=C=>Date.now()-_>=12?setTimeout((()=>this._innerWrite(0,C))):this._innerWrite(_,C);return void y.catch((C=>(queueMicrotask((()=>{throw C})),Promise.resolve(!1)))).then(E)}const v=this._callbacks[this._bufferOffset];if(v&&v(),this._bufferOffset++,this._pendingData-=b.length,Date.now()-_>=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()}}o.WriteBuffer=d},5941:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.toRgbString=o.parseColor=void 0;const l=/^([\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})$/,u=/^[\da-f]+$/;function p(d,m){const g=d.toString(16),x=g.length<2?"0"+g:g;switch(m){case 4:return g[0];case 8:return x;case 12:return(x+x).slice(0,3);default:return x+x}}o.parseColor=function(d){if(!d)return;let m=d.toLowerCase();if(m.indexOf("rgb:")===0){m=m.slice(4);const g=l.exec(m);if(g){const x=g[1]?15:g[4]?255:g[7]?4095:65535;return[Math.round(parseInt(g[1]||g[4]||g[7]||g[10],16)/x*255),Math.round(parseInt(g[2]||g[5]||g[8]||g[11],16)/x*255),Math.round(parseInt(g[3]||g[6]||g[9]||g[12],16)/x*255)]}}else if(m.indexOf("#")===0&&(m=m.slice(1),u.exec(m)&&[3,6,9,12].includes(m.length))){const g=m.length/3,x=[0,0,0];for(let _=0;_<3;++_){const b=parseInt(m.slice(g*_,g*_+g),16);x[_]=g===1?b<<4:g===2?b:g===3?b>>4:b>>8}return x}},o.toRgbString=function(d,m=16){const[g,x,_]=d;return`rgb:${p(g,m)}/${p(x,m)}/${p(_,m)}`}},5770:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.PAYLOAD_LIMIT=void 0,o.PAYLOAD_LIMIT=1e7},6351:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DcsHandler=o.DcsParser=void 0;const u=l(482),p=l(8742),d=l(5770),m=[];o.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=m,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}registerHandler(x,_){this._handlers[x]===void 0&&(this._handlers[x]=[]);const b=this._handlers[x];return b.push(_),{dispose:()=>{const y=b.indexOf(_);y!==-1&&b.splice(y,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}reset(){if(this._active.length)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].unhook(!1);this._stack.paused=!1,this._active=m,this._ident=0}hook(x,_){if(this.reset(),this._ident=x,this._active=this._handlers[x]||m,this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].hook(_);else this._handlerFb(this._ident,"HOOK",_)}put(x,_,b){if(this._active.length)for(let y=this._active.length-1;y>=0;y--)this._active[y].put(x,_,b);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(x,_,b))}unhook(x,_=!0){if(this._active.length){let b=!1,y=this._active.length-1,v=!1;if(this._stack.paused&&(y=this._stack.loopPosition-1,b=_,v=this._stack.fallThrough,this._stack.paused=!1),!v&&b===!1){for(;y>=0&&(b=this._active[y].unhook(x),b!==!0);y--)if(b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!1,b;y--}for(;y>=0;y--)if(b=this._active[y].unhook(!1),b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!0,b}else this._handlerFb(this._ident,"UNHOOK",x);this._active=m,this._ident=0}};const g=new p.Params;g.addParam(0),o.DcsHandler=class{constructor(x){this._handler=x,this._data="",this._params=g,this._hitLimit=!1}hook(x){this._params=x.length>1||x.params[0]?x.clone():g,this._data="",this._hitLimit=!1}put(x,_,b){this._hitLimit||(this._data+=(0,u.utf32ToString)(x,_,b),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(x){let _=!1;if(this._hitLimit)_=!1;else if(x&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((b=>(this._params=g,this._data="",this._hitLimit=!1,b)));return this._params=g,this._data="",this._hitLimit=!1,_}}},2015:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.EscapeSequenceParser=o.VT500_TRANSITION_TABLE=o.TransitionTable=void 0;const u=l(844),p=l(8742),d=l(6242),m=l(6351);class g{constructor(y){this.table=new Uint8Array(y)}setDefault(y,v){this.table.fill(y<<4|v)}add(y,v,E,C){this.table[v<<8|y]=E<<4|C}addMany(y,v,E,C){for(let w=0;w<y.length;w++)this.table[v<<8|y[w]]=E<<4|C}}o.TransitionTable=g;const x=160;o.VT500_TRANSITION_TABLE=(function(){const b=new g(4095),y=Array.apply(null,Array(256)).map(((R,O)=>O)),v=(R,O)=>y.slice(R,O),E=v(32,127),C=v(0,24);C.push(25),C.push.apply(C,v(28,32));const w=v(0,14);let A;for(A in b.setDefault(1,0),b.addMany(E,0,2,0),w)b.addMany([24,26,153,154],A,3,0),b.addMany(v(128,144),A,3,0),b.addMany(v(144,152),A,3,0),b.add(156,A,0,0),b.add(27,A,11,1),b.add(157,A,4,8),b.addMany([152,158,159],A,0,7),b.add(155,A,11,3),b.add(144,A,11,9);return b.addMany(C,0,3,0),b.addMany(C,1,3,1),b.add(127,1,0,1),b.addMany(C,8,0,8),b.addMany(C,3,3,3),b.add(127,3,0,3),b.addMany(C,4,3,4),b.add(127,4,0,4),b.addMany(C,6,3,6),b.addMany(C,5,3,5),b.add(127,5,0,5),b.addMany(C,2,3,2),b.add(127,2,0,2),b.add(93,1,4,8),b.addMany(E,8,5,8),b.add(127,8,5,8),b.addMany([156,27,24,26,7],8,6,0),b.addMany(v(28,32),8,0,8),b.addMany([88,94,95],1,0,7),b.addMany(E,7,0,7),b.addMany(C,7,0,7),b.add(156,7,0,0),b.add(127,7,0,7),b.add(91,1,11,3),b.addMany(v(64,127),3,7,0),b.addMany(v(48,60),3,8,4),b.addMany([60,61,62,63],3,9,4),b.addMany(v(48,60),4,8,4),b.addMany(v(64,127),4,7,0),b.addMany([60,61,62,63],4,0,6),b.addMany(v(32,64),6,0,6),b.add(127,6,0,6),b.addMany(v(64,127),6,0,0),b.addMany(v(32,48),3,9,5),b.addMany(v(32,48),5,9,5),b.addMany(v(48,64),5,0,6),b.addMany(v(64,127),5,7,0),b.addMany(v(32,48),4,9,5),b.addMany(v(32,48),1,9,2),b.addMany(v(32,48),2,9,2),b.addMany(v(48,127),2,10,0),b.addMany(v(48,80),1,10,0),b.addMany(v(81,88),1,10,0),b.addMany([89,90,92],1,10,0),b.addMany(v(96,127),1,10,0),b.add(80,1,11,9),b.addMany(C,9,0,9),b.add(127,9,0,9),b.addMany(v(28,32),9,0,9),b.addMany(v(32,48),9,9,12),b.addMany(v(48,60),9,8,10),b.addMany([60,61,62,63],9,9,10),b.addMany(C,11,0,11),b.addMany(v(32,128),11,0,11),b.addMany(v(28,32),11,0,11),b.addMany(C,10,0,10),b.add(127,10,0,10),b.addMany(v(28,32),10,0,10),b.addMany(v(48,60),10,8,10),b.addMany([60,61,62,63],10,0,11),b.addMany(v(32,48),10,9,12),b.addMany(C,12,0,12),b.add(127,12,0,12),b.addMany(v(28,32),12,0,12),b.addMany(v(32,48),12,9,12),b.addMany(v(48,64),12,0,11),b.addMany(v(64,127),12,12,13),b.addMany(v(64,127),10,12,13),b.addMany(v(64,127),9,12,13),b.addMany(C,13,13,13),b.addMany(E,13,13,13),b.add(127,13,0,13),b.addMany([27,156,24,26],13,14,0),b.add(x,0,2,0),b.add(x,8,5,8),b.add(x,6,0,6),b.add(x,11,0,11),b.add(x,13,13,13),b})();class _ extends u.Disposable{constructor(y=o.VT500_TRANSITION_TABLE){super(),this._transitions=y,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(v,E,C)=>{},this._executeHandlerFb=v=>{},this._csiHandlerFb=(v,E)=>{},this._escHandlerFb=v=>{},this._errorHandlerFb=v=>v,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,u.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new d.OscParser),this._dcsParser=this.register(new m.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(y,v=[64,126]){let E=0;if(y.prefix){if(y.prefix.length>1)throw new Error("only one byte as prefix supported");if(E=y.prefix.charCodeAt(0),E&&60>E||E>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(y.intermediates){if(y.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let w=0;w<y.intermediates.length;++w){const A=y.intermediates.charCodeAt(w);if(32>A||A>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");E<<=8,E|=A}}if(y.final.length!==1)throw new Error("final must be a single byte");const C=y.final.charCodeAt(0);if(v[0]>C||C>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return E<<=8,E|=C,E}identToString(y){const v=[];for(;y;)v.push(String.fromCharCode(255&y)),y>>=8;return v.reverse().join("")}setPrintHandler(y){this._printHandler=y}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(y,v){const E=this._identifier(y,[48,126]);this._escHandlers[E]===void 0&&(this._escHandlers[E]=[]);const C=this._escHandlers[E];return C.push(v),{dispose:()=>{const w=C.indexOf(v);w!==-1&&C.splice(w,1)}}}clearEscHandler(y){this._escHandlers[this._identifier(y,[48,126])]&&delete this._escHandlers[this._identifier(y,[48,126])]}setEscHandlerFallback(y){this._escHandlerFb=y}setExecuteHandler(y,v){this._executeHandlers[y.charCodeAt(0)]=v}clearExecuteHandler(y){this._executeHandlers[y.charCodeAt(0)]&&delete this._executeHandlers[y.charCodeAt(0)]}setExecuteHandlerFallback(y){this._executeHandlerFb=y}registerCsiHandler(y,v){const E=this._identifier(y);this._csiHandlers[E]===void 0&&(this._csiHandlers[E]=[]);const C=this._csiHandlers[E];return C.push(v),{dispose:()=>{const w=C.indexOf(v);w!==-1&&C.splice(w,1)}}}clearCsiHandler(y){this._csiHandlers[this._identifier(y)]&&delete this._csiHandlers[this._identifier(y)]}setCsiHandlerFallback(y){this._csiHandlerFb=y}registerDcsHandler(y,v){return this._dcsParser.registerHandler(this._identifier(y),v)}clearDcsHandler(y){this._dcsParser.clearHandler(this._identifier(y))}setDcsHandlerFallback(y){this._dcsParser.setHandlerFallback(y)}registerOscHandler(y,v){return this._oscParser.registerHandler(y,v)}clearOscHandler(y){this._oscParser.clearHandler(y)}setOscHandlerFallback(y){this._oscParser.setHandlerFallback(y)}setErrorHandler(y){this._errorHandler=y}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.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(y,v,E,C,w){this._parseStack.state=y,this._parseStack.handlers=v,this._parseStack.handlerPos=E,this._parseStack.transition=C,this._parseStack.chunkPos=w}parse(y,v,E){let C,w=0,A=0,R=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,R=this._parseStack.chunkPos+1;else{if(E===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const O=this._parseStack.handlers;let N=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(E===!1&&N>-1){for(;N>=0&&(C=O[N](this._params),C!==!0);N--)if(C instanceof Promise)return this._parseStack.handlerPos=N,C}this._parseStack.handlers=[];break;case 4:if(E===!1&&N>-1){for(;N>=0&&(C=O[N](),C!==!0);N--)if(C instanceof Promise)return this._parseStack.handlerPos=N,C}this._parseStack.handlers=[];break;case 6:if(w=y[this._parseStack.chunkPos],C=this._dcsParser.unhook(w!==24&&w!==26,E),C)return C;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(w=y[this._parseStack.chunkPos],C=this._oscParser.end(w!==24&&w!==26,E),C)return C;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,R=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let O=R;O<v;++O){switch(w=y[O],A=this._transitions.table[this.currentState<<8|(w<160?w:x)],A>>4){case 2:for(let P=O+1;;++P){if(P>=v||(w=y[P])<32||w>126&&w<x){this._printHandler(y,O,P),O=P-1;break}if(++P>=v||(w=y[P])<32||w>126&&w<x){this._printHandler(y,O,P),O=P-1;break}if(++P>=v||(w=y[P])<32||w>126&&w<x){this._printHandler(y,O,P),O=P-1;break}if(++P>=v||(w=y[P])<32||w>126&&w<x){this._printHandler(y,O,P),O=P-1;break}}break;case 3:this._executeHandlers[w]?this._executeHandlers[w]():this._executeHandlerFb(w),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:O,code:w,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const N=this._csiHandlers[this._collect<<8|w];let D=N?N.length-1:-1;for(;D>=0&&(C=N[D](this._params),C!==!0);D--)if(C instanceof Promise)return this._preserveStack(3,N,D,A,O),C;D<0&&this._csiHandlerFb(this._collect<<8|w,this._params),this.precedingJoinState=0;break;case 8:do switch(w){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(w-48)}while(++O<v&&(w=y[O])>47&&w<60);O--;break;case 9:this._collect<<=8,this._collect|=w;break;case 10:const L=this._escHandlers[this._collect<<8|w];let z=L?L.length-1:-1;for(;z>=0&&(C=L[z](),C!==!0);z--)if(C instanceof Promise)return this._preserveStack(4,L,z,A,O),C;z<0&&this._escHandlerFb(this._collect<<8|w),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|w,this._params);break;case 13:for(let P=O+1;;++P)if(P>=v||(w=y[P])===24||w===26||w===27||w>127&&w<x){this._dcsParser.put(y,O,P),O=P-1;break}break;case 14:if(C=this._dcsParser.unhook(w!==24&&w!==26),C)return this._preserveStack(6,[],0,A,O),C;w===27&&(A|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let P=O+1;;P++)if(P>=v||(w=y[P])<32||w>127&&w<x){this._oscParser.put(y,O,P),O=P-1;break}break;case 6:if(C=this._oscParser.end(w!==24&&w!==26),C)return this._preserveStack(5,[],0,A,O),C;w===27&&(A|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&A}}}o.EscapeSequenceParser=_},6242:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OscHandler=o.OscParser=void 0;const u=l(5770),p=l(482),d=[];o.OscParser=class{constructor(){this._state=0,this._active=d,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(m,g){this._handlers[m]===void 0&&(this._handlers[m]=[]);const x=this._handlers[m];return x.push(g),{dispose:()=>{const _=x.indexOf(g);_!==-1&&x.splice(_,1)}}}clearHandler(m){this._handlers[m]&&delete this._handlers[m]}setHandlerFallback(m){this._handlerFb=m}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}reset(){if(this._state===2)for(let m=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;m>=0;--m)this._active[m].end(!1);this._stack.paused=!1,this._active=d,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||d,this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].start();else this._handlerFb(this._id,"START")}_put(m,g,x){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(m,g,x);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(m,g,x))}start(){this.reset(),this._state=1}put(m,g,x){if(this._state!==3){if(this._state===1)for(;g<x;){const _=m[g++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&x-g>0&&this._put(m,g,x)}}end(m,g=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let x=!1,_=this._active.length-1,b=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,x=g,b=this._stack.fallThrough,this._stack.paused=!1),!b&&x===!1){for(;_>=0&&(x=this._active[_].end(m),x!==!0);_--)if(x instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,x;_--}for(;_>=0;_--)if(x=this._active[_].end(!1),x instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,x}else this._handlerFb(this._id,"END",m);this._active=d,this._id=-1,this._state=0}}},o.OscHandler=class{constructor(m){this._handler=m,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(m,g,x){this._hitLimit||(this._data+=(0,p.utf32ToString)(m,g,x),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(m){let g=!1;if(this._hitLimit)g=!1;else if(m&&(g=this._handler(this._data),g instanceof Promise))return g.then((x=>(this._data="",this._hitLimit=!1,x)));return this._data="",this._hitLimit=!1,g}}},8742:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Params=void 0;const l=2147483647;class u{static fromArray(d){const m=new u;if(!d.length)return m;for(let g=Array.isArray(d[0])?1:0;g<d.length;++g){const x=d[g];if(Array.isArray(x))for(let _=0;_<x.length;++_)m.addSubParam(x[_]);else m.addParam(x)}return m}constructor(d=32,m=32){if(this.maxLength=d,this.maxSubParamsLength=m,m>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(d),this.length=0,this._subParams=new Int32Array(m),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(d),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const d=new u(this.maxLength,this.maxSubParamsLength);return d.params.set(this.params),d.length=this.length,d._subParams.set(this._subParams),d._subParamsLength=this._subParamsLength,d._subParamsIdx.set(this._subParamsIdx),d._rejectDigits=this._rejectDigits,d._rejectSubDigits=this._rejectSubDigits,d._digitIsSub=this._digitIsSub,d}toArray(){const d=[];for(let m=0;m<this.length;++m){d.push(this.params[m]);const g=this._subParamsIdx[m]>>8,x=255&this._subParamsIdx[m];x-g>0&&d.push(Array.prototype.slice.call(this._subParams,g,x))}return d}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(d){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=d>l?l:d}}addSubParam(d){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=d>l?l:d,this._subParamsIdx[this.length-1]++}}hasSubParams(d){return(255&this._subParamsIdx[d])-(this._subParamsIdx[d]>>8)>0}getSubParams(d){const m=this._subParamsIdx[d]>>8,g=255&this._subParamsIdx[d];return g-m>0?this._subParams.subarray(m,g):null}getSubParamsAll(){const d={};for(let m=0;m<this.length;++m){const g=this._subParamsIdx[m]>>8,x=255&this._subParamsIdx[m];x-g>0&&(d[m]=this._subParams.slice(g,x))}return d}addDigit(d){let m;if(this._rejectDigits||!(m=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const g=this._digitIsSub?this._subParams:this.params,x=g[m-1];g[m-1]=~x?Math.min(10*x+d,l):d}}o.Params=u},5741:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.AddonManager=void 0,o.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let l=this._addons.length-1;l>=0;l--)this._addons[l].instance.dispose()}loadAddon(l,u){const p={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(p),u.dispose=()=>this._wrappedAddonDispose(p),u.activate(l)}_wrappedAddonDispose(l){if(l.isDisposed)return;let u=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===l){u=p;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");l.isDisposed=!0,l.dispose.apply(l.instance),this._addons.splice(u,1)}}},8771:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferApiView=void 0;const u=l(3785),p=l(511);o.BufferApiView=class{constructor(d,m){this._buffer=d,this.type=m}init(d){return this._buffer=d,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(d){const m=this._buffer.lines.get(d);if(m)return new u.BufferLineApiView(m)}getNullCell(){return new p.CellData}}},3785:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLineApiView=void 0;const u=l(511);o.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,d){if(!(p<0||p>=this._line.length))return d?(this._line.loadCell(p,d),d):this._line.loadCell(p,new u.CellData)}translateToString(p,d,m){return this._line.translateToString(p,d,m)}}},8285:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferNamespaceApi=void 0;const u=l(8771),p=l(8460),d=l(844);class m extends d.Disposable{constructor(x){super(),this._core=x,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.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 new 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)}}o.BufferNamespaceApi=m},7975:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ParserApi=void 0,o.ParserApi=class{constructor(l){this._core=l}registerCsiHandler(l,u){return this._core.registerCsiHandler(l,(p=>u(p.toArray())))}addCsiHandler(l,u){return this.registerCsiHandler(l,u)}registerDcsHandler(l,u){return this._core.registerDcsHandler(l,((p,d)=>u(p,d.toArray())))}addDcsHandler(l,u){return this.registerDcsHandler(l,u)}registerEscHandler(l,u){return this._core.registerEscHandler(l,u)}addEscHandler(l,u){return this.registerEscHandler(l,u)}registerOscHandler(l,u){return this._core.registerOscHandler(l,u)}addOscHandler(l,u){return this.registerOscHandler(l,u)}}},7090:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeApi=void 0,o.UnicodeApi=class{constructor(l){this._core=l}register(l){this._core.unicodeService.register(l)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(l){this._core.unicodeService.activeVersion=l}}},744:function(s,o,l){var u=this&&this.__decorate||function(b,y,v,E){var C,w=arguments.length,A=w<3?y:E===null?E=Object.getOwnPropertyDescriptor(y,v):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,y,v,E);else for(var R=b.length-1;R>=0;R--)(C=b[R])&&(A=(w<3?C(A):w>3?C(y,v,A):C(y,v))||A);return w>3&&A&&Object.defineProperty(y,v,A),A},p=this&&this.__param||function(b,y){return function(v,E){y(v,E,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferService=o.MINIMUM_ROWS=o.MINIMUM_COLS=void 0;const d=l(8460),m=l(844),g=l(5295),x=l(2585);o.MINIMUM_COLS=2,o.MINIMUM_ROWS=1;let _=o.BufferService=class extends m.Disposable{get buffer(){return this.buffers.active}constructor(b){super(),this.isUserScrolling=!1,this._onResize=this.register(new d.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(b.rawOptions.cols||0,o.MINIMUM_COLS),this.rows=Math.max(b.rawOptions.rows||0,o.MINIMUM_ROWS),this.buffers=this.register(new g.BufferSet(b,this))}resize(b,y){this.cols=b,this.rows=y,this.buffers.resize(b,y),this._onResize.fire({cols:b,rows:y})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(b,y=!1){const v=this.buffer;let E;E=this._cachedBlankLine,E&&E.length===this.cols&&E.getFg(0)===b.fg&&E.getBg(0)===b.bg||(E=v.getBlankLine(b,y),this._cachedBlankLine=E),E.isWrapped=y;const C=v.ybase+v.scrollTop,w=v.ybase+v.scrollBottom;if(v.scrollTop===0){const A=v.lines.isFull;w===v.lines.length-1?A?v.lines.recycle().copyFrom(E):v.lines.push(E.clone()):v.lines.splice(w+1,0,E.clone()),A?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const A=w-C+1;v.lines.shiftElements(C+1,A-1,-1),v.lines.set(w,E.clone())}this.isUserScrolling||(v.ydisp=v.ybase),this._onScroll.fire(v.ydisp)}scrollLines(b,y,v){const E=this.buffer;if(b<0){if(E.ydisp===0)return;this.isUserScrolling=!0}else b+E.ydisp>=E.ybase&&(this.isUserScrolling=!1);const C=E.ydisp;E.ydisp=Math.max(Math.min(E.ydisp+b,E.ybase),0),C!==E.ydisp&&(y||this._onScroll.fire(E.ydisp))}};o.BufferService=_=u([p(0,x.IOptionsService)],_)},7994:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CharsetService=void 0,o.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(l){this.glevel=l,this.charset=this._charsets[l]}setgCharset(l,u){this._charsets[l]=u,this.glevel===l&&(this.charset=u)}}},1753:function(s,o,l){var u=this&&this.__decorate||function(E,C,w,A){var R,O=arguments.length,N=O<3?C:A===null?A=Object.getOwnPropertyDescriptor(C,w):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(E,C,w,A);else for(var D=E.length-1;D>=0;D--)(R=E[D])&&(N=(O<3?R(N):O>3?R(C,w,N):R(C,w))||N);return O>3&&N&&Object.defineProperty(C,w,N),N},p=this&&this.__param||function(E,C){return function(w,A){C(w,A,E)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreMouseService=void 0;const d=l(2585),m=l(8460),g=l(844),x={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 _(E,C){let w=(E.ctrl?16:0)|(E.shift?4:0)|(E.alt?8:0);return E.button===4?(w|=64,w|=E.action):(w|=3&E.button,4&E.button&&(w|=64),8&E.button&&(w|=128),E.action===32?w|=32:E.action!==0||C||(w|=3)),w}const b=String.fromCharCode,y={DEFAULT:E=>{const C=[_(E,!1)+32,E.col+32,E.row+32];return C[0]>255||C[1]>255||C[2]>255?"":`\x1B[M${b(C[0])}${b(C[1])}${b(C[2])}`},SGR:E=>{const C=E.action===0&&E.button!==4?"m":"M";return`\x1B[<${_(E,!0)};${E.col};${E.row}${C}`},SGR_PIXELS:E=>{const C=E.action===0&&E.button!==4?"m":"M";return`\x1B[<${_(E,!0)};${E.x};${E.y}${C}`}};let v=o.CoreMouseService=class extends g.Disposable{constructor(E,C){super(),this._bufferService=E,this._coreService=C,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new m.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const w of Object.keys(x))this.addProtocol(w,x[w]);for(const w of Object.keys(y))this.addEncoding(w,y[w]);this.reset()}addProtocol(E,C){this._protocols[E]=C}addEncoding(E,C){this._encodings[E]=C}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(E){if(!this._protocols[E])throw new 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 new 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;const C=this._encodings[this._activeEncoding](E);return C&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(C):this._coreService.triggerDataEvent(C,!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,C,w){if(w){if(E.x!==C.x||E.y!==C.y)return!1}else if(E.col!==C.col||E.row!==C.row)return!1;return E.button===C.button&&E.action===C.action&&E.ctrl===C.ctrl&&E.alt===C.alt&&E.shift===C.shift}};o.CoreMouseService=v=u([p(0,d.IBufferService),p(1,d.ICoreService)],v)},6975:function(s,o,l){var u=this&&this.__decorate||function(v,E,C,w){var A,R=arguments.length,O=R<3?E:w===null?w=Object.getOwnPropertyDescriptor(E,C):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,E,C,w);else for(var N=v.length-1;N>=0;N--)(A=v[N])&&(O=(R<3?A(O):R>3?A(E,C,O):A(E,C))||O);return R>3&&O&&Object.defineProperty(E,C,O),O},p=this&&this.__param||function(v,E){return function(C,w){E(C,w,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreService=void 0;const d=l(1439),m=l(8460),g=l(844),x=l(2585),_=Object.freeze({insertMode:!1}),b=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let y=o.CoreService=class extends g.Disposable{constructor(v,E,C){super(),this._bufferService=v,this._logService=E,this._optionsService=C,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new m.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new m.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new m.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new m.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,d.clone)(_),this.decPrivateModes=(0,d.clone)(b)}reset(){this.modes=(0,d.clone)(_),this.decPrivateModes=(0,d.clone)(b)}triggerDataEvent(v,E=!1){if(this._optionsService.rawOptions.disableStdin)return;const C=this._bufferService.buffer;E&&this._optionsService.rawOptions.scrollOnUserInput&&C.ybase!==C.ydisp&&this._onRequestScrollToBottom.fire(),E&&this._onUserInput.fire(),this._logService.debug(`sending data "${v}"`,(()=>v.split("").map((w=>w.charCodeAt(0))))),this._onData.fire(v)}triggerBinaryEvent(v){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${v}"`,(()=>v.split("").map((E=>E.charCodeAt(0))))),this._onBinary.fire(v))}};o.CoreService=y=u([p(0,x.IBufferService),p(1,x.ILogService),p(2,x.IOptionsService)],y)},9074:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DecorationService=void 0;const u=l(8055),p=l(8460),d=l(844),m=l(6106);let g=0,x=0;class _ extends d.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new m.SortedList((v=>v?.marker.line)),this._onDecorationRegistered=this.register(new p.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new p.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,d.toDisposable)((()=>this.reset())))}registerDecoration(v){if(v.marker.isDisposed)return;const E=new b(v);if(E){const C=E.marker.onDispose((()=>E.dispose()));E.onDispose((()=>{E&&(this._decorations.delete(E)&&this._onDecorationRemoved.fire(E),C.dispose())})),this._decorations.insert(E),this._onDecorationRegistered.fire(E)}return E}reset(){for(const v of this._decorations.values())v.dispose();this._decorations.clear()}*getDecorationsAtCell(v,E,C){let w=0,A=0;for(const R of this._decorations.getKeyIterator(E))w=R.options.x??0,A=w+(R.options.width??1),v>=w&&v<A&&(!C||(R.options.layer??"bottom")===C)&&(yield R)}forEachDecorationAtCell(v,E,C,w){this._decorations.forEachByKey(E,(A=>{g=A.options.x??0,x=g+(A.options.width??1),v>=g&&v<x&&(!C||(A.options.layer??"bottom")===C)&&w(A)}))}}o.DecorationService=_;class b extends d.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=u.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=u.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(v){super(),this.options=v,this.onRenderEmitter=this.register(new p.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new p.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=v.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.InstantiationService=o.ServiceCollection=void 0;const u=l(2585),p=l(8343);class d{constructor(...g){this._entries=new Map;for(const[x,_]of g)this.set(x,_)}set(g,x){const _=this._entries.get(g);return this._entries.set(g,x),_}forEach(g){for(const[x,_]of this._entries.entries())g(x,_)}has(g){return this._entries.has(g)}get(g){return this._entries.get(g)}}o.ServiceCollection=d,o.InstantiationService=class{constructor(){this._services=new d,this._services.set(u.IInstantiationService,this)}setService(m,g){this._services.set(m,g)}getService(m){return this._services.get(m)}createInstance(m,...g){const x=(0,p.getServiceDependencies)(m).sort(((y,v)=>y.index-v.index)),_=[];for(const y of x){const v=this._services.get(y.id);if(!v)throw new Error(`[createInstance] ${m.name} depends on UNKNOWN service ${y.id}.`);_.push(v)}const b=x.length>0?x[0].index:g.length;if(g.length!==b)throw new Error(`[createInstance] First service dependency of ${m.name} at position ${b+1} conflicts with ${g.length} static arguments`);return new m(...g,..._)}}},7866:function(s,o,l){var u=this&&this.__decorate||function(b,y,v,E){var C,w=arguments.length,A=w<3?y:E===null?E=Object.getOwnPropertyDescriptor(y,v):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,y,v,E);else for(var R=b.length-1;R>=0;R--)(C=b[R])&&(A=(w<3?C(A):w>3?C(y,v,A):C(y,v))||A);return w>3&&A&&Object.defineProperty(y,v,A),A},p=this&&this.__param||function(b,y){return function(v,E){y(v,E,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.traceCall=o.setTraceLogger=o.LogService=void 0;const d=l(844),m=l(2585),g={trace:m.LogLevelEnum.TRACE,debug:m.LogLevelEnum.DEBUG,info:m.LogLevelEnum.INFO,warn:m.LogLevelEnum.WARN,error:m.LogLevelEnum.ERROR,off:m.LogLevelEnum.OFF};let x,_=o.LogService=class extends d.Disposable{get logLevel(){return this._logLevel}constructor(b){super(),this._optionsService=b,this._logLevel=m.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),x=this}_updateLogLevel(){this._logLevel=g[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(b){for(let y=0;y<b.length;y++)typeof b[y]=="function"&&(b[y]=b[y]())}_log(b,y,v){this._evalLazyOptionalParams(v),b.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+y,...v)}trace(b,...y){this._logLevel<=m.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,b,y)}debug(b,...y){this._logLevel<=m.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,b,y)}info(b,...y){this._logLevel<=m.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,b,y)}warn(b,...y){this._logLevel<=m.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,b,y)}error(b,...y){this._logLevel<=m.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,b,y)}};o.LogService=_=u([p(0,m.IOptionsService)],_),o.setTraceLogger=function(b){x=b},o.traceCall=function(b,y,v){if(typeof v.value!="function")throw new Error("not supported");const E=v.value;v.value=function(...C){if(x.logLevel!==m.LogLevelEnum.TRACE)return E.apply(this,C);x.trace(`GlyphRenderer#${E.name}(${C.map((A=>JSON.stringify(A))).join(", ")})`);const w=E.apply(this,C);return x.trace(`GlyphRenderer#${E.name} return`,w),w}}},7302:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OptionsService=o.DEFAULT_OPTIONS=void 0;const u=l(8460),p=l(844),d=l(6114);o.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,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:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:d.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const m=["normal","bold","100","200","300","400","500","600","700","800","900"];class g extends p.Disposable{constructor(_){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const b={...o.DEFAULT_OPTIONS};for(const y in _)if(y in b)try{const v=_[y];b[y]=this._sanitizeAndValidateOption(y,v)}catch(v){console.error(v)}this.rawOptions=b,this.options={...b},this._setupOptions(),this.register((0,p.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(_,b){return this.onOptionChange((y=>{y===_&&b(this.rawOptions[_])}))}onMultipleOptionChange(_,b){return this.onOptionChange((y=>{_.indexOf(y)!==-1&&b()}))}_setupOptions(){const _=y=>{if(!(y in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${y}"`);return this.rawOptions[y]},b=(y,v)=>{if(!(y in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${y}"`);v=this._sanitizeAndValidateOption(y,v),this.rawOptions[y]!==v&&(this.rawOptions[y]=v,this._onOptionChange.fire(y))};for(const y in this.rawOptions){const v={get:_.bind(this,y),set:b.bind(this,y)};Object.defineProperty(this.options,y,v)}}_sanitizeAndValidateOption(_,b){switch(_){case"cursorStyle":if(b||(b=o.DEFAULT_OPTIONS[_]),!(function(y){return y==="block"||y==="underline"||y==="bar"})(b))throw new Error(`"${b}" is not a valid value for ${_}`);break;case"wordSeparator":b||(b=o.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof b=="number"&&1<=b&&b<=1e3)break;b=m.includes(b)?b:o.DEFAULT_OPTIONS[_];break;case"cursorWidth":b=Math.floor(b);case"lineHeight":case"tabStopWidth":if(b<1)throw new Error(`${_} cannot be less than 1, value: ${b}`);break;case"minimumContrastRatio":b=Math.max(1,Math.min(21,Math.round(10*b)/10));break;case"scrollback":if((b=Math.min(b,4294967295))<0)throw new Error(`${_} cannot be less than 0, value: ${b}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(b<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${b}`);break;case"rows":case"cols":if(!b&&b!==0)throw new Error(`${_} must be numeric, value: ${b}`);break;case"windowsPty":b=b??{}}return b}}o.OptionsService=g},2660:function(s,o,l){var u=this&&this.__decorate||function(g,x,_,b){var y,v=arguments.length,E=v<3?x:b===null?b=Object.getOwnPropertyDescriptor(x,_):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(g,x,_,b);else for(var C=g.length-1;C>=0;C--)(y=g[C])&&(E=(v<3?y(E):v>3?y(x,_,E):y(x,_))||E);return v>3&&E&&Object.defineProperty(x,_,E),E},p=this&&this.__param||function(g,x){return function(_,b){x(_,b,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkService=void 0;const d=l(2585);let m=o.OscLinkService=class{constructor(g){this._bufferService=g,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(g){const x=this._bufferService.buffer;if(g.id===void 0){const C=x.addMarker(x.ybase+x.y),w={data:g,id:this._nextId++,lines:[C]};return C.onDispose((()=>this._removeMarkerFromLink(w,C))),this._dataByLinkId.set(w.id,w),w.id}const _=g,b=this._getEntryIdKey(_),y=this._entriesWithId.get(b);if(y)return this.addLineToLink(y.id,x.ybase+x.y),y.id;const v=x.addMarker(x.ybase+x.y),E={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(E,v))),this._entriesWithId.set(E.key,E),this._dataByLinkId.set(E.id,E),E.id}addLineToLink(g,x){const _=this._dataByLinkId.get(g);if(_&&_.lines.every((b=>b.line!==x))){const b=this._bufferService.buffer.addMarker(x);_.lines.push(b),b.onDispose((()=>this._removeMarkerFromLink(_,b)))}}getLinkData(g){return this._dataByLinkId.get(g)?.data}_getEntryIdKey(g){return`${g.id};;${g.uri}`}_removeMarkerFromLink(g,x){const _=g.lines.indexOf(x);_!==-1&&(g.lines.splice(_,1),g.lines.length===0&&(g.data.id!==void 0&&this._entriesWithId.delete(g.key),this._dataByLinkId.delete(g.id)))}};o.OscLinkService=m=u([p(0,d.IBufferService)],m)},8343:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createDecorator=o.getServiceDependencies=o.serviceRegistry=void 0;const l="di$target",u="di$dependencies";o.serviceRegistry=new Map,o.getServiceDependencies=function(p){return p[u]||[]},o.createDecorator=function(p){if(o.serviceRegistry.has(p))return o.serviceRegistry.get(p);const d=function(m,g,x){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,b,y){b[l]===b?b[u].push({id:_,index:y}):(b[u]=[{id:_,index:y}],b[l]=b)})(d,m,x)};return d.toString=()=>p,o.serviceRegistry.set(p,d),d}},2585:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.IDecorationService=o.IUnicodeService=o.IOscLinkService=o.IOptionsService=o.ILogService=o.LogLevelEnum=o.IInstantiationService=o.ICharsetService=o.ICoreService=o.ICoreMouseService=o.IBufferService=void 0;const u=l(8343);var p;o.IBufferService=(0,u.createDecorator)("BufferService"),o.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),o.ICoreService=(0,u.createDecorator)("CoreService"),o.ICharsetService=(0,u.createDecorator)("CharsetService"),o.IInstantiationService=(0,u.createDecorator)("InstantiationService"),(function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.OFF=5]="OFF"})(p||(o.LogLevelEnum=p={})),o.ILogService=(0,u.createDecorator)("LogService"),o.IOptionsService=(0,u.createDecorator)("OptionsService"),o.IOscLinkService=(0,u.createDecorator)("OscLinkService"),o.IUnicodeService=(0,u.createDecorator)("UnicodeService"),o.IDecorationService=(0,u.createDecorator)("DecorationService")},1480:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeService=void 0;const u=l(8460),p=l(225);class d{static extractShouldJoin(g){return(1&g)!=0}static extractWidth(g){return g>>1&3}static extractCharKind(g){return g>>3}static createPropertyValue(g,x,_=!1){return(16777215&g)<<3|(3&x)<<1|(_?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new u.EventEmitter,this.onChange=this._onChange.event;const g=new p.UnicodeV6;this.register(g),this._active=g.version,this._activeProvider=g}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(g){if(!this._providers[g])throw new Error(`unknown Unicode version "${g}"`);this._active=g,this._activeProvider=this._providers[g],this._onChange.fire(g)}register(g){this._providers[g.version]=g}wcwidth(g){return this._activeProvider.wcwidth(g)}getStringCellWidth(g){let x=0,_=0;const b=g.length;for(let y=0;y<b;++y){let v=g.charCodeAt(y);if(55296<=v&&v<=56319){if(++y>=b)return x+this.wcwidth(v);const w=g.charCodeAt(y);56320<=w&&w<=57343?v=1024*(v-55296)+w-56320+65536:x+=this.wcwidth(w)}const E=this.charProperties(v,_);let C=d.extractWidth(E);d.extractShouldJoin(E)&&(C-=d.extractWidth(_)),x+=C,_=E}return x}charProperties(g,x){return this._activeProvider.charProperties(g,x)}}o.UnicodeService=d}},r={};function i(s){var o=r[s];if(o!==void 0)return o.exports;var l=r[s]={exports:{}};return n[s].call(l.exports,l,l.exports,i),l.exports}var a={};return(()=>{var s=a;Object.defineProperty(s,"__esModule",{value:!0}),s.Terminal=void 0;const o=i(9042),l=i(3236),u=i(844),p=i(5741),d=i(8285),m=i(7975),g=i(7090),x=["cols","rows"];class _ extends u.Disposable{constructor(y){super(),this._core=this.register(new l.Terminal(y)),this._addonManager=this.register(new p.AddonManager),this._publicOptions={...this._core.options};const v=C=>this._core.options[C],E=(C,w)=>{this._checkReadonlyOptions(C),this._core.options[C]=w};for(const C in this._core.options){const w={get:v.bind(this,C),set:E.bind(this,C)};Object.defineProperty(this._publicOptions,C,w)}}_checkReadonlyOptions(y){if(x.includes(y))throw new Error(`Option "${y}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new 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||(this._parser=new m.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new g.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._buffer=this.register(new d.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const y=this._core.coreService.decPrivateModes;let v="none";switch(this._core.coreMouseService.activeProtocol){case"X10":v="x10";break;case"VT200":v="vt200";break;case"DRAG":v="drag";break;case"ANY":v="any"}return{applicationCursorKeysMode:y.applicationCursorKeys,applicationKeypadMode:y.applicationKeypad,bracketedPasteMode:y.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:v,originMode:y.origin,reverseWraparoundMode:y.reverseWraparound,sendFocusMode:y.sendFocus,wraparoundMode:y.wraparound}}get options(){return this._publicOptions}set options(y){for(const v in y)this._publicOptions[v]=y[v]}blur(){this._core.blur()}focus(){this._core.focus()}input(y,v=!0){this._core.input(y,v)}resize(y,v){this._verifyIntegers(y,v),this._core.resize(y,v)}open(y){this._core.open(y)}attachCustomKeyEventHandler(y){this._core.attachCustomKeyEventHandler(y)}attachCustomWheelEventHandler(y){this._core.attachCustomWheelEventHandler(y)}registerLinkProvider(y){return this._core.registerLinkProvider(y)}registerCharacterJoiner(y){return this._checkProposedApi(),this._core.registerCharacterJoiner(y)}deregisterCharacterJoiner(y){this._checkProposedApi(),this._core.deregisterCharacterJoiner(y)}registerMarker(y=0){return this._verifyIntegers(y),this._core.registerMarker(y)}registerDecoration(y){return this._checkProposedApi(),this._verifyPositiveIntegers(y.x??0,y.width??0,y.height??0),this._core.registerDecoration(y)}hasSelection(){return this._core.hasSelection()}select(y,v,E){this._verifyIntegers(y,v,E),this._core.select(y,v,E)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(y,v){this._verifyIntegers(y,v),this._core.selectLines(y,v)}dispose(){super.dispose()}scrollLines(y){this._verifyIntegers(y),this._core.scrollLines(y)}scrollPages(y){this._verifyIntegers(y),this._core.scrollPages(y)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(y){this._verifyIntegers(y),this._core.scrollToLine(y)}clear(){this._core.clear()}write(y,v){this._core.write(y,v)}writeln(y,v){this._core.write(y),this._core.write(`\r
|
|
43
43
|
`,v)}paste(y){this._core.paste(y)}refresh(y,v){this._verifyIntegers(y,v),this._core.refresh(y,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(y){this._addonManager.loadAddon(this,y)}static get strings(){return o}_verifyIntegers(...y){for(const v of y)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...y){for(const v of y)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}s.Terminal=_})(),a})()))})(f2)),f2.exports}var gse=gLe(),p2={exports:{}},wW;function bLe(){return wW||(wW=1,(function(e,t){(function(n,r){e.exports=r()})(self,(()=>(()=>{var n={};return(()=>{var r=n;Object.defineProperty(r,"__esModule",{value:!0}),r.FitAddon=void 0,r.FitAddon=class{activate(i){this._terminal=i}dispose(){}fit(){const i=this.proposeDimensions();if(!i||!this._terminal||isNaN(i.cols)||isNaN(i.rows))return;const a=this._terminal._core;this._terminal.rows===i.rows&&this._terminal.cols===i.cols||(a._renderService.clear(),this._terminal.resize(i.cols,i.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const i=this._terminal._core,a=i._renderService.dimensions;if(a.css.cell.width===0||a.css.cell.height===0)return;const s=this._terminal.options.scrollback===0?0:i.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(o.getPropertyValue("height")),u=Math.max(0,parseInt(o.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),d=l-(parseInt(p.getPropertyValue("padding-top"))+parseInt(p.getPropertyValue("padding-bottom"))),m=u-(parseInt(p.getPropertyValue("padding-right"))+parseInt(p.getPropertyValue("padding-left")))-s;return{cols:Math.max(2,Math.floor(m/a.css.cell.width)),rows:Math.max(1,Math.floor(d/a.css.cell.height))}}}})(),n})()))})(p2)),p2.exports}var bse=bLe(),h2={exports:{}},CW;function vLe(){return CW||(CW=1,(function(e,t){(function(n,r){e.exports=r()})(self,(()=>(()=>{var n={6:(s,o)=>{function l(p){try{const d=new URL(p),m=d.password&&d.username?`${d.protocol}//${d.username}:${d.password}@${d.host}`:d.username?`${d.protocol}//${d.username}@${d.host}`:`${d.protocol}//${d.host}`;return p.toLocaleLowerCase().startsWith(m.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(o,"__esModule",{value:!0}),o.LinkComputer=o.WebLinkProvider=void 0,o.WebLinkProvider=class{constructor(p,d,m,g={}){this._terminal=p,this._regex=d,this._handler=m,this._options=g}provideLinks(p,d){const m=u.computeLink(p,this._regex,this._terminal,this._handler);d(this._addCallbacks(m))}_addCallbacks(p){return p.map((d=>(d.leave=this._options.leave,d.hover=(m,g)=>{if(this._options.hover){const{range:x}=d;this._options.hover(m,g,x)}},d)))}};class u{static computeLink(d,m,g,x){const _=new RegExp(m.source,(m.flags||"")+"g"),[b,y]=u._getWindowedLineStrings(d-1,g),v=b.join("");let E;const C=[];for(;E=_.exec(v);){const w=E[0];if(!l(w))continue;const[A,R]=u._mapStrIdx(g,y,0,E.index),[O,N]=u._mapStrIdx(g,A,R,w.length);if(A===-1||R===-1||O===-1||N===-1)continue;const D={start:{x:R+1,y:A+1},end:{x:N,y:O+1}};C.push({range:D,text:w,activate:x})}return C}static _getWindowedLineStrings(d,m){let g,x=d,_=d,b=0,y="";const v=[];if(g=m.buffer.active.getLine(d)){const E=g.translateToString(!0);if(g.isWrapped&&E[0]!==" "){for(b=0;(g=m.buffer.active.getLine(--x))&&b<2048&&(y=g.translateToString(!0),b+=y.length,v.push(y),g.isWrapped&&y.indexOf(" ")===-1););v.reverse()}for(v.push(E),b=0;(g=m.buffer.active.getLine(++_))&&g.isWrapped&&b<2048&&(y=g.translateToString(!0),b+=y.length,v.push(y),y.indexOf(" ")===-1););}return[v,x]}static _mapStrIdx(d,m,g,x){const _=d.buffer.active,b=_.getNullCell();let y=g;for(;x;){const v=_.getLine(m);if(!v)return[-1,-1];for(let E=y;E<v.length;++E){v.getCell(E,b);const C=b.getChars();if(b.getWidth()&&(x-=C.length||1,E===v.length-1&&C==="")){const w=_.getLine(m+1);w&&w.isWrapped&&(w.getCell(0,b),b.getWidth()===2&&(x+=1))}if(x<0)return[m,E]}m++,y=0}return[m,y]}}o.LinkComputer=u}},r={};function i(s){var o=r[s];if(o!==void 0)return o.exports;var l=r[s]={exports:{}};return n[s](l,l.exports,i),l.exports}var a={};return(()=>{var s=a;Object.defineProperty(s,"__esModule",{value:!0}),s.WebLinksAddon=void 0;const o=i(6),l=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(p,d){const m=window.open();if(m){try{m.opener=null}catch{}m.location.href=d}else console.warn("Opening link blocked as opener could not be cleared")}s.WebLinksAddon=class{constructor(p=u,d={}){this._handler=p,this._options=d}activate(p){this._terminal=p;const d=this._options,m=d.urlRegex||l;this._linkProvider=this._terminal.registerLinkProvider(new o.WebLinkProvider(this._terminal,m,this._handler,d))}dispose(){this._linkProvider?.dispose()}}})(),a})()))})(h2)),h2.exports}var vse=vLe();function tC(){const[e,t]=T.useState(!1);return T.useEffect(()=>{const n=window.matchMedia("(max-width: 639px)");t(n.matches);const r=i=>t(i.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const yLe=[{label:"Esc",icon:Mr,data:"\x1B"},{label:"Up",icon:a3,data:"\x1B[A"},{label:"Down",icon:L0,data:"\x1B[B"},{label:"Tab",icon:null,data:" "},{label:"Enter",icon:null,data:"\r"}];function WS({onSend:e}){return tC()?f.jsx("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t border-border bg-card px-3 py-2",children:yLe.map(n=>f.jsxs(Ae,{variant:"outline",className:"h-11 min-w-11 touch-manipulation",onClick:()=>e(n.data),children:[n.icon?f.jsx(J,{icon:n.icon,size:20,strokeWidth:2}):f.jsx("span",{className:"text-xs font-medium",children:n.label}),f.jsx("span",{className:"sr-only",children:n.label})]},n.label))}):null}const yse={background:"#faf9f5",foreground:"#2a2a27",cursor:"#2a2a27",cursorAccent:"#faf9f5",selectionBackground:"#d1d5db",black:"#2a2a27",red:"#dd403a",green:"#0d5c63",yellow:"#dd403a",blue:"#0d5c63",magenta:"#5c5c59",cyan:"#0d5c63",white:"#5c5c59",brightBlack:"#5c5c59",brightRed:"#dd403a",brightGreen:"#0d5c63",brightYellow:"#dd403a",brightBlue:"#0d5c63",brightMagenta:"#5c5c59",brightCyan:"#0d5c63",brightWhite:"#5c5c59"},xse={background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"};function oL({className:e,onReady:t,onResize:n,onContainerReady:r,terminalId:i,setupImagePaste:a,onSend:s,onFocus:o}){const l=T.useRef(null),u=T.useRef(null),p=T.useRef(null),d=T.useRef(n),m=T.useRef(o),g=T.useRef(t),x=T.useRef(r),{setTerminalFocused:_}=d3(),{resolvedTheme:b}=_p(),y=b==="dark",v=y?xse:yse;T.useEffect(()=>{d.current=n},[n]),T.useEffect(()=>{m.current=o},[o]),T.useEffect(()=>{g.current=t},[t]),T.useEffect(()=>{x.current=r},[r]);const E=T.useCallback(()=>{if(!p.current||!u.current)return;p.current.fit();const{cols:w,rows:A}=u.current;d.current?.(w,A)},[]);T.useEffect(()=>{if(!l.current||u.current)return;const w=new gse.Terminal({cursorBlink:!0,fontSize:Math.round(13*Qc),fontFamily:"JetBrains Mono Variable, PureNerdFont, Menlo, Monaco, monospace",lineHeight:1.2,theme:v}),A=new bse.FitAddon,R=new vse.WebLinksAddon;w.loadAddon(A),w.loadAddon(R),w.open(l.current),u.current=w,p.current=A,requestAnimationFrame(()=>{E(),g.current?.(w),l.current&&x.current?.(l.current)});const O=()=>{_(!0),m.current?.()},N=()=>_(!1);w.textarea&&(w.textarea.addEventListener("focus",O),w.textarea.addEventListener("blur",N));const D=setTimeout(()=>{E(),w.refresh(0,w.rows-1)},100),L=()=>{requestAnimationFrame(E)};window.addEventListener("resize",L);const z=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{E(),w.refresh(0,w.rows-1)})};document.addEventListener("visibilitychange",z);const P=new ResizeObserver(L);P.observe(l.current);const V=new IntersectionObserver(H=>{H[0]?.isIntersecting&&requestAnimationFrame(()=>{E(),w.refresh(0,w.rows-1)})},{threshold:.1});return V.observe(l.current),()=>{clearTimeout(D),window.removeEventListener("resize",L),document.removeEventListener("visibilitychange",z),P.disconnect(),V.disconnect(),w.textarea&&(w.textarea.removeEventListener("focus",O),w.textarea.removeEventListener("blur",N)),_(!1),w.dispose(),u.current=null,p.current=null}},[E,_]),T.useEffect(()=>!l.current||!i||!a?void 0:a(l.current,i),[i,a]),T.useEffect(()=>{u.current&&(u.current.options.theme=v)},[v]);const C=T.useCallback(()=>{u.current?.scrollToBottom()},[]);return f.jsxs("div",{className:"flex h-full w-full max-w-full flex-col",children:[f.jsxs("div",{className:"relative min-h-0 flex-1",children:[f.jsx("div",{ref:l,className:Be("h-full w-full max-w-full overflow-hidden p-2 bg-terminal-background",e)}),f.jsx("button",{onClick:C,className:Be("absolute top-2 right-5 p-1 transition-colors",y?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:f.jsx(J,{icon:Cne,size:20,strokeWidth:2})})]}),s&&f.jsx(WS,{onSend:s})]})}function xLe({name:e,status:t,exitCode:n,className:r,onRename:i}){const[a,s]=T.useState(!1),[o,l]=T.useState(e),u=T.useRef(null);T.useEffect(()=>{a&&u.current&&(u.current.focus(),u.current.select())},[a]);const p=()=>{i&&(l(e),s(!0))},d=()=>{const g=o.trim();g&&g!==e&&i&&i(g),s(!1)},m=g=>{g.key==="Enter"?d():g.key==="Escape"&&s(!1)};return f.jsxs("div",{className:Be("flex h-6 items-center gap-2 border-b border-border bg-card px-2 text-xs",r),children:[f.jsx("span",{className:Be("h-2 w-2 shrink-0 rounded-full",{"bg-accent":t==="running","bg-muted-foreground":t==="exited"&&n===0,"bg-destructive":t==="exited"&&n!==0||t==="error"})}),a?f.jsx("input",{ref:u,type:"text",value:o,onChange:g=>l(g.target.value),onBlur:d,onKeyDown:m,className:"h-4 w-24 rounded border border-border bg-background px-1 text-xs font-medium text-foreground outline-none focus:border-primary"}):f.jsx("span",{className:Be("font-medium text-foreground",i&&"cursor-pointer hover:text-primary"),onDoubleClick:p,title:i?"Double-click to rename":void 0,children:e}),t==="exited"&&n!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"ml-auto text-muted-foreground",children:"·"}),f.jsxs("span",{className:Be({"text-muted-foreground":n===0,"text-destructive":n!==0}),children:["exit ",n]})]})]})}function am({...e}){return f.jsx($we,{"data-slot":"dropdown-menu",...e})}function sm({...e}){return f.jsx(Hwe,{"data-slot":"dropdown-menu-trigger",...e})}function om({align:e="start",alignOffset:t=0,side:n="bottom",sideOffset:r=4,className:i,...a}){return f.jsx(Owe,{children:f.jsx(Rwe,{className:"isolate z-50 outline-none",align:e,alignOffset:t,side:n,sideOffset:r,children:f.jsx(Awe,{"data-slot":"dropdown-menu-content",className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden",i),...a})})})}function Tr({className:e,inset:t,variant:n="default",...r}){return f.jsx(Cwe,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Be("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...r})}function TW({...e}){return f.jsx(Iwe,{"data-slot":"dropdown-menu-radio-group",...e})}function AW({className:e,children:t,...n}){return f.jsxs(Lwe,{"data-slot":"dropdown-menu-radio-item",className:Be("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground min-h-7 gap-2 rounded-md py-1.5 pr-8 pl-2 text-xs [&_svg:not([class*='size-'])]:size-3.5 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...n,children:[f.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center pointer-events-none","data-slot":"dropdown-menu-radio-item-indicator",children:f.jsx(Pwe,{children:f.jsx(J,{icon:Dr,strokeWidth:2})})}),t]})}function kW({className:e,...t}){return f.jsx(p3,{"data-slot":"dropdown-menu-separator",className:Be("bg-border/50 -mx-1 my-1 h-px",e),...t})}const _Le="";function tj(){return tn({mutationFn:async e=>{const t=await fetch(`${_Le}/api/git/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();throw new Error(n.error||"Sync failed")}return t.json()}})}const SLe="";function nj(){return tn({mutationFn:async e=>{const t=await fetch(`${SLe}/api/git/merge-to-main`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();throw new Error(n.error||"Merge failed")}return t.json()}})}const ELe="";function rj(){return tn({mutationFn:async e=>{const t=await fetch(`${ELe}/api/git/push`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();throw new Error(n.error||"Push failed")}return t.json()}})}const wLe="";function ij(){return tn({mutationFn:async e=>{const t=await fetch(`${wLe}/api/git/sync-parent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();throw new Error(n.error||"Sync parent failed")}return t.json()}})}const CLe="";function aj(){return tn({mutationFn:async e=>{const t=await fetch(`${CLe}/api/git/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();if(n.prAlreadyExists&&n.existingPrUrl){const r=new Error(n.error||"PR already exists");throw r.existingPrUrl=n.existingPrUrl,r}throw new Error(n.error||"Failed to create PR")}return t.json()}})}const TLe="";function sj(){return tn({mutationFn:async e=>{const t=await fetch(`${TLe}/api/tasks/${e}/kill-claude`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to kill Claude")}return t.json()}})}function ALe({repoPath:e,worktreePath:t,baseBranch:n,taskId:r,title:i,prUrl:a,isMobile:s,terminalId:o,sendInputToTerminal:l}){const{t:u}=wt("common"),p=tj(),d=nj(),m=rj(),g=ij(),x=aj(),_=Bw(),b=sj(),y=N=>{o&&l?(l(o,N),_t.info(u("git.sentToClaude"))):_t.error(u("git.noTerminal"))},v=async()=>{try{await p.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),_t.success(u("git.syncedFromMain"))}catch(N){const D=N instanceof Error?N.message:"Sync failed",L=n||"main";_t.error(D,{action:o&&l?{label:"Resolve with Claude",onClick:()=>y(`Rebase this worktree onto the parent repo's ${L} branch. Error: "${D}". Steps: 1) Check for uncommitted changes - stash or commit them first, 2) git fetch origin (in parent repo at ${e}) to ensure ${L} is current, 3) git rebase ${L} (in worktree), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) If stashed, git stash pop. Worktree: ${t}, Parent repo: ${e}.`)}:void 0})}},E=async()=>{try{await d.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),_t.success(u("git.mergedToMain")),b.mutate(r),_.mutate({taskId:r,updates:{status:"DONE"}})}catch(N){const D=N instanceof Error?N.message:"Merge failed",L=n||"main";_t.error(D,{action:o&&l?{label:"Resolve with Claude",onClick:()=>y(`Merge this worktree's branch into the parent repo's ${L}. Error: "${D}". Steps: 1) Ensure all changes in worktree are committed, 2) In parent repo at ${e}, checkout ${L} and pull latest from origin, 3) Squash merge the worktree branch into ${L} (use git merge --squash, then commit), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Push ${L} to origin. Worktree: ${t}, Parent repo: ${e}.`)}:void 0})}},C=async()=>{try{await m.mutateAsync({worktreePath:t}),_t.success(u("git.pushedToOrigin"))}catch(N){const D=N instanceof Error?N.message:"Push failed";_t.error(D,{action:o&&l?{label:"Resolve with Claude",onClick:()=>y(`Push this worktree's branch to origin. Error: "${D}". Steps: 1) Check for uncommitted changes and commit them, 2) If push is rejected, pull the latest changes first and resolve any conflicts, 3) Push to origin again. Worktree: ${t}.`)}:void 0})}},w=async()=>{try{await g.mutateAsync({repoPath:e,baseBranch:n}),_t.success(u("git.parentSynced"))}catch(N){const D=N instanceof Error?N.message:"Sync parent failed",L=n||"main";_t.error(D,{action:o&&l?{label:"Resolve with Claude",onClick:()=>y(`Sync the parent repo's ${L} branch with origin. Error: "${D}". Steps: 1) git fetch origin, 2) git pull origin ${L} --ff-only, 3) If that fails, rebase with git rebase origin/${L}, 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Once in sync, git push origin ${L}. Work in the parent repo at ${e}, not the worktree.`)}:void 0})}},A=()=>{o&&l&&l(o,"commit")},R=async()=>{try{const N=await x.mutateAsync({worktreePath:t,title:i,baseBranch:n});_.mutate({taskId:r,updates:{prUrl:N.prUrl}}),_t.success(u("git.prCreated"),{action:{label:"View PR",onClick:()=>Al(N.prUrl)}})}catch(N){const D=N instanceof Error?N.message:"Failed to create PR",L=N&&typeof N=="object"&&"existingPrUrl"in N?N.existingPrUrl:void 0;if(L){_.mutate({taskId:r,updates:{prUrl:L}}),_t.info(u("git.prExists"),{action:{label:"View PR",onClick:()=>Al(L)}});return}const z=D.split(`
|
|
44
44
|
`).filter(Boolean).pop()||D;_t.error(z,{action:{label:"Resolve with Claude",onClick:()=>y(`Create a PR for this task. Error: "${D}". After creating, link it using: vibora current-task pr <url>. Worktree: ${t}.`)}})}},O=p.isPending||d.isPending||m.isPending||g.isPending||x.isPending;return s?f.jsxs(am,{children:[f.jsx(sm,{className:"flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:o3,size:12,strokeWidth:2,className:O?"animate-pulse":""})}),f.jsxs(om,{align:"end",children:[f.jsxs(Tr,{onClick:v,disabled:p.isPending,children:[f.jsx(J,{icon:dy,size:12,strokeWidth:2,className:p.isPending?"animate-spin":""}),"Pull from main"]}),f.jsxs(Tr,{onClick:E,disabled:d.isPending,children:[f.jsx(J,{icon:cy,size:12,strokeWidth:2,className:d.isPending?"animate-pulse":""}),"Merge to main"]}),f.jsxs(Tr,{onClick:C,disabled:m.isPending,children:[f.jsx(J,{icon:fy,size:12,strokeWidth:2,className:m.isPending?"animate-pulse":""}),"Push to origin"]}),f.jsxs(Tr,{onClick:w,disabled:g.isPending,children:[f.jsx(J,{icon:hy,size:12,strokeWidth:2,className:g.isPending?"animate-spin":""}),"Sync parent with origin"]}),o&&l&&f.jsxs(Tr,{onClick:A,children:[f.jsx(J,{icon:py,size:12,strokeWidth:2}),"Commit"]}),!a&&f.jsxs(Tr,{onClick:R,disabled:x.isPending,children:[f.jsx(J,{icon:ju,size:12,strokeWidth:2,className:x.isPending?"animate-pulse":""}),"Create PR"]})]})]}):f.jsxs(f.Fragment,{children:[f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:v,disabled:p.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Pull from main",children:f.jsx(J,{icon:dy,size:12,strokeWidth:2,className:p.isPending?"animate-spin":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:E,disabled:d.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Merge to main",children:f.jsx(J,{icon:cy,size:12,strokeWidth:2,className:d.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:C,disabled:m.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Push to origin",children:f.jsx(J,{icon:fy,size:12,strokeWidth:2,className:m.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:w,disabled:g.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Sync parent with origin",children:f.jsx(J,{icon:hy,size:12,strokeWidth:2,className:g.isPending?"animate-spin":""})}),o&&l&&f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:A,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Commit",children:f.jsx(J,{icon:py,size:12,strokeWidth:2})}),!a&&f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:R,disabled:x.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Create Pull Request",children:f.jsx(J,{icon:ju,size:12,strokeWidth:2,className:x.isPending?"animate-pulse":""})})]})}function kLe({repoPath:e,worktreePath:t,baseBranch:n,taskId:r,title:i,prUrl:a,repoId:s,repoName:o,terminalId:l,sendInputToTerminal:u}){const{t:p}=wt("common"),d=Br(),m=tj(),g=nj(),x=rj(),_=ij(),b=aj(),y=Bw(),v=Uw(),E=sj(),[C,w]=T.useState(!1),A=j=>{l&&u?(u(l,j),_t.info(p("git.sentToClaude"))):_t.error(p("git.noTerminal"))},R=async()=>{try{await m.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),_t.success(p("git.syncedFromMain"))}catch(j){const G=j instanceof Error?j.message:"Sync failed",q=n||"main";_t.error(G,{action:l&&u?{label:"Resolve with Claude",onClick:()=>A(`Rebase this worktree onto the parent repo's ${q} branch. Error: "${G}". Steps: 1) Check for uncommitted changes - stash or commit them first, 2) git fetch origin (in parent repo at ${e}) to ensure ${q} is current, 3) git rebase ${q} (in worktree), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) If stashed, git stash pop. Worktree: ${t}, Parent repo: ${e}.`)}:void 0})}},O=async()=>{try{await g.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),_t.success(p("git.mergedToMain")),E.mutate(r),y.mutate({taskId:r,updates:{status:"DONE"}})}catch(j){const G=j instanceof Error?j.message:"Merge failed",q=n||"main";_t.error(G,{action:l&&u?{label:"Resolve with Claude",onClick:()=>A(`Merge this worktree's branch into the parent repo's ${q}. Error: "${G}". Steps: 1) Ensure all changes in worktree are committed, 2) In parent repo at ${e}, checkout ${q} and pull latest from origin, 3) Squash merge the worktree branch into ${q} (use git merge --squash, then commit), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Push ${q} to origin. Worktree: ${t}, Parent repo: ${e}.`)}:void 0})}},N=async()=>{try{await x.mutateAsync({worktreePath:t}),_t.success(p("git.pushedToOrigin"))}catch(j){const G=j instanceof Error?j.message:"Push failed";_t.error(G,{action:l&&u?{label:"Resolve with Claude",onClick:()=>A(`Push this worktree's branch to origin. Error: "${G}". Steps: 1) Check for uncommitted changes and commit them, 2) If push is rejected, pull the latest changes first and resolve any conflicts, 3) Push to origin again. Worktree: ${t}.`)}:void 0})}},D=async()=>{try{await _.mutateAsync({repoPath:e,baseBranch:n}),_t.success(p("git.parentSynced"))}catch(j){const G=j instanceof Error?j.message:"Sync parent failed",q=n||"main";_t.error(G,{action:l&&u?{label:"Resolve with Claude",onClick:()=>A(`Sync the parent repo's ${q} branch with origin. Error: "${G}". Steps: 1) git fetch origin, 2) git pull origin ${q} --ff-only, 3) If that fails, rebase with git rebase origin/${q}, 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Once in sync, git push origin ${q}. Work in the parent repo at ${e}, not the worktree.`)}:void 0})}},L=()=>{l&&u&&u(l,"commit")},z=()=>{d(s?{to:"/repositories/$repoId",params:{repoId:s}}:{to:"/repositories"})},P=()=>{v.mutate({taskId:r,deleteLinkedWorktree:!0}),w(!1)},V=async()=>{try{const j=await b.mutateAsync({worktreePath:t,title:i,baseBranch:n});y.mutate({taskId:r,updates:{prUrl:j.prUrl}}),_t.success(p("git.prCreated"),{action:{label:"View PR",onClick:()=>Al(j.prUrl)}})}catch(j){const G=j instanceof Error?j.message:"Failed to create PR",q=j&&typeof j=="object"&&"existingPrUrl"in j?j.existingPrUrl:void 0;if(q){y.mutate({taskId:r,updates:{prUrl:q}}),_t.info(p("git.prExists"),{action:{label:"View PR",onClick:()=>Al(q)}});return}const B=G.split(`
|
|
45
|
-
`).filter(Boolean).pop()||G;_t.error(B,{action:{label:"Resolve with Claude",onClick:()=>A(`Create a PR for this task. Error: "${G}". After creating, link it using: vibora current-task pr <url>. Worktree: ${t}.`)}})}},H=m.isPending||g.isPending||x.isPending||_.isPending||b.isPending;return f.jsxs(f.Fragment,{children:[f.jsxs(am,{children:[f.jsx(sm,{className:"flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:o3,size:12,strokeWidth:2,className:H?"animate-pulse":""})}),f.jsxs(om,{align:"end",children:[f.jsxs(Tr,{onClick:R,disabled:m.isPending,children:[f.jsx(J,{icon:dy,size:12,strokeWidth:2,className:m.isPending?"animate-spin":""}),"Pull from main"]}),f.jsxs(Tr,{onClick:O,disabled:g.isPending,children:[f.jsx(J,{icon:cy,size:12,strokeWidth:2,className:g.isPending?"animate-pulse":""}),"Merge to main"]}),f.jsxs(Tr,{onClick:N,disabled:x.isPending,children:[f.jsx(J,{icon:fy,size:12,strokeWidth:2,className:x.isPending?"animate-pulse":""}),"Push to origin"]}),f.jsxs(Tr,{onClick:D,disabled:_.isPending,children:[f.jsx(J,{icon:hy,size:12,strokeWidth:2,className:_.isPending?"animate-spin":""}),"Sync parent with origin"]}),l&&u&&f.jsxs(Tr,{onClick:L,children:[f.jsx(J,{icon:py,size:12,strokeWidth:2}),"Commit"]}),!a&&f.jsxs(Tr,{onClick:V,disabled:b.isPending,children:[f.jsx(J,{icon:ju,size:12,strokeWidth:2,className:b.isPending?"animate-pulse":""}),"Create PR"]}),f.jsx(kW,{}),f.jsxs(Tr,{onClick:z,children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),o]}),f.jsx(kW,{}),f.jsxs(Tr,{onClick:()=>w(!0),disabled:v.isPending,className:"text-destructive focus:text-destructive",children:[f.jsx(J,{icon:rs,size:12,strokeWidth:2}),"Delete task"]})]})]}),f.jsx(Oa,{open:C,onOpenChange:w,children:f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsx(La,{children:"This will permanently delete this task and its worktree."})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{children:"Cancel"}),f.jsx(ec,{onClick:P,variant:"destructive",disabled:v.isPending,children:v.isPending?"Deleting...":"Delete"})]})]})})]})}function lm({worktreePath:e}){const{data:t,isLoading:n}=QCe(e);if(!e||n||!t)return null;if(t.clean)return f.jsxs(Jr,{className:"bg-accent/20 text-accent border-transparent",children:[f.jsx(J,{icon:Dr,size:12,strokeWidth:2}),"Clean"]});const r=t.files.length;return f.jsxs(Jr,{className:"bg-amber-500/20 text-amber-600 dark:text-amber-400 border-transparent",children:[f.jsx(J,{icon:er,size:12,strokeWidth:2}),r," ",r===1?"change":"changes"]})}const OLe=350,RLe=250;function NLe({taskInfo:e,terminalId:t,terminalCwd:n,isMobile:r,sendInputToTerminal:i}){const a=T.useRef(null),[s,o]=T.useState(1/0),l=Uw();T.useEffect(()=>{const m=a.current;if(!m)return;const g=new ResizeObserver(x=>{for(const _ of x)o(_.contentRect.width)});return g.observe(m),()=>g.disconnect()},[]);const u=r||s<OLe,p=s>=RLe,d=()=>{l.mutate({taskId:e.taskId,deleteLinkedWorktree:!0})};return f.jsx("div",{ref:a,className:"flex shrink-0 items-center justify-between border-b border-border bg-card",children:f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2 py-1",children:[f.jsxs(Rn,{to:"/tasks/$taskId",params:{taskId:e.taskId},className:"flex shrink-0 items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 max-w-[50%]",children:[f.jsx(J,{icon:l3,size:14,strokeWidth:2,className:"shrink-0"}),f.jsx("span",{className:"truncate",children:e.title})]}),u?f.jsxs(f.Fragment,{children:[p&&f.jsx(lm,{worktreePath:e.worktreePath}),f.jsx("div",{className:"ml-auto flex items-center",children:f.jsx(kLe,{repoPath:e.repoPath,worktreePath:e.worktreePath,baseBranch:e.baseBranch,taskId:e.taskId,title:e.title,prUrl:e.prUrl,repoId:e.repoId,repoName:e.repoName,terminalId:t,sendInputToTerminal:i})})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Rn,{to:e.repoId?"/repositories/$repoId":"/repositories",params:e.repoId?{repoId:e.repoId}:void 0,className:"flex min-w-0 items-center gap-1 text-xs font-medium text-foreground cursor-pointer hover:underline",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2,className:"shrink-0"}),f.jsx("span",{className:"truncate",children:e.repoName})]}),n&&f.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[f.jsx(J,{icon:Rw,size:12,strokeWidth:2,className:"shrink-0"}),f.jsx("span",{className:"truncate",children:n.split("/").pop()})]}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsx(lm,{worktreePath:e.worktreePath}),f.jsx(ALe,{repoPath:e.repoPath,worktreePath:e.worktreePath,baseBranch:e.baseBranch,taskId:e.taskId,title:e.title,prUrl:e.prUrl,isMobile:r,terminalId:t,sendInputToTerminal:i}),f.jsxs(Oa,{children:[f.jsx(Ju,{render:f.jsx(Ae,{variant:"ghost",size:"icon-xs",className:"h-5 w-5 text-muted-foreground hover:text-destructive",title:"Delete task",disabled:l.isPending}),children:f.jsx(J,{icon:rs,size:12,strokeWidth:2})}),f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsx(La,{children:"This will permanently delete this task and its worktree."})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{children:"Cancel"}),f.jsx(ec,{onClick:d,variant:"destructive",disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})]})]})]})]})})}function ILe({terminals:e,activeIndex:t,onSelect:n,taskInfoByCwd:r}){const i=T.useRef(null),a=T.useRef(null);T.useEffect(()=>{a.current&&i.current&&a.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[t]);const s=(o,l)=>{if(o.cwd&&r){const u=r.get(o.cwd);if(u)return u.title}return o.name||`Terminal ${l+1}`};return f.jsx("div",{ref:i,className:"flex shrink-0 gap-1 overflow-x-auto border-b border-border bg-card px-2 py-1.5",style:{WebkitOverflowScrolling:"touch"},children:e.map((o,l)=>{const u=l===t,p=s(o,l);return f.jsx("button",{ref:u?a:null,onClick:()=>n(l),className:Be("shrink-0 rounded-md px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation","max-w-[150px] truncate",u?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"),children:p},o.id)})})}const DLe=Np(function({terminal:t,taskInfo:n,isMobile:r,onClose:i,onReady:a,onResize:s,onRename:o,onContainerReady:l,setupImagePaste:u,onFocus:p,sendInputToTerminal:d,isMaximized:m,onMaximize:g,onMinimize:x,canMaximize:_}){const b=Rp(),{resolvedTheme:y}=_p(),v=y==="dark",E=n?b.terminals.get(t.id):null,C=E?.isStartingUp??!1;return T.useEffect(()=>{n&&jt.terminal.info("TerminalPane isStartingUp check",{terminalId:t.id,hasTaskInfo:!!n,hasTerminalModel:!!E,isStartingUp:E?.isStartingUp,isStartingClaude:C})},[t.id,n,E,C,E?.isStartingUp]),f.jsxs("div",{className:"flex h-full min-w-0 flex-col overflow-hidden",children:[n?f.jsx(NLe,{taskInfo:n,terminalId:t.id,terminalCwd:t.cwd,isMobile:r,sendInputToTerminal:d}):f.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-card",children:[f.jsx(xLe,{name:t.name,status:t.status,exitCode:t.exitCode,className:"flex-1 border-b-0",onRename:o}),f.jsxs("div",{className:"flex items-center gap-1 mr-1",children:[_&&f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:m?x:g,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:m?"Restore":"Maximize",children:f.jsx(J,{icon:m?x_e:M_e,size:12,strokeWidth:2})}),i&&f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:i,className:"h-5 w-5 text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:Mr,size:12,strokeWidth:2})})]})]}),f.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[f.jsx(oL,{onReady:a,onResize:s,onContainerReady:l,terminalId:t.id,setupImagePaste:u,onFocus:p}),C&&f.jsx("div",{className:"pointer-events-auto absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:Be("animate-spin",v?"text-white/60":"text-black/60")}),f.jsx("span",{className:Be("font-mono text-sm",v?"text-white/60":"text-black/60"),children:"Starting Claude Code..."})]})})]})]})});function LLe({onAdd:e}){return f.jsx("div",{className:"flex h-full items-center justify-center bg-terminal-background",children:e?f.jsxs(Ae,{variant:"outline",size:"sm",onClick:e,className:"gap-2",children:[f.jsx(J,{icon:Ed,size:14,strokeWidth:2}),"New Terminal"]}):f.jsx("p",{className:"text-xs text-muted-foreground",children:"No terminals"})})}function PLe(e){return e<=1?{rows:1,cols:1}:e<=2?{rows:1,cols:2}:e<=4?{rows:2,cols:2}:e<=6?{rows:2,cols:3}:e<=9?{rows:3,cols:3}:{rows:3,cols:4}}function MLe({terminals:e,onTerminalClose:t,onTerminalAdd:n,onTerminalReady:r,onTerminalResize:i,onTerminalRename:a,onTerminalContainerReady:s,setupImagePaste:o,writeToTerminal:l,sendInputToTerminal:u,taskInfoByCwd:p}){const d=tC(),[m,g]=T.useState(e.length>0?e[0].id:null),[x,_]=T.useState(0),[b,y]=T.useState(null);if(T.useEffect(()=>{x>=e.length&&e.length>0&&_(e.length-1)},[e.length,x]),T.useEffect(()=>{b&&!e.find(O=>O.id===b)&&y(null)},[e,b]),e.length===0)return f.jsx(LLe,{onAdd:n});const{rows:v,cols:E}=PLe(e.length),C=[];for(let O=0;O<v;O++){const N=O*E,D=Math.min(N+E,e.length);N<e.length&&C.push(e.slice(N,D))}const w=O=>{const N=d&&e.length>1?e[x]?.id:m;N&&l&&l(N,O)},A=O=>{const N=O.cwd?p?.get(O.cwd):void 0,D=!N&&e.length>1;return f.jsx(DLe,{terminal:O,taskInfo:N,isMobile:d,onClose:t?()=>t(O.id):void 0,onReady:r?L=>r(O.id,L):void 0,onResize:i?(L,z)=>i(O.id,L,z):void 0,onRename:a?L=>a(O.id,L):void 0,onContainerReady:s?L=>s(O.id,L):void 0,setupImagePaste:o,onFocus:()=>g(O.id),sendInputToTerminal:u,isMaximized:b===O.id,onMaximize:()=>y(O.id),onMinimize:()=>y(null),canMaximize:D})},R=O=>f.jsxs("div",{className:"flex h-full w-full flex-col",children:[f.jsx("div",{className:"min-h-0 flex-1",children:O}),d&&l&&f.jsx(WS,{onSend:w})]});if(d&&e.length>1){const O=e[x]??e[0];return f.jsxs("div",{className:"flex h-full w-full flex-col",children:[f.jsx(ILe,{terminals:e,activeIndex:x,onSelect:_,taskInfoByCwd:p}),f.jsx("div",{className:"min-h-0 flex-1",children:A(O)},O.id),l&&f.jsx(WS,{onSend:w})]})}if(e.length===1)return R(f.jsx("div",{className:"h-full w-full max-w-full min-w-0 overflow-hidden",children:A(e[0])},e[0].id));if(b){const O=e.find(N=>N.id===b);if(O)return R(f.jsx("div",{className:"h-full w-full max-w-full min-w-0 overflow-hidden",children:A(O)},O.id))}return e.length===2?R(f.jsxs(wf,{direction:d?"vertical":"horizontal",className:"h-full max-w-full",children:[f.jsx(no,{defaultSize:50,minSize:15,children:A(e[0])},e[0].id),f.jsx(Cf,{}),f.jsx(no,{defaultSize:50,minSize:15,children:A(e[1])},e[1].id)]})):e.length===3?R(f.jsxs(wf,{direction:"horizontal",className:"h-full max-w-full",children:[f.jsx(no,{defaultSize:50,minSize:15,children:A(e[0])},e[0].id),f.jsx(Cf,{}),f.jsx(no,{defaultSize:50,minSize:15,children:f.jsxs(wf,{direction:"vertical",className:"h-full max-w-full",children:[f.jsx(no,{defaultSize:50,minSize:15,children:A(e[1])},e[1].id),f.jsx(Cf,{}),f.jsx(no,{defaultSize:50,minSize:15,children:A(e[2])},e[2].id)]})})]})):R(f.jsx(wf,{direction:"vertical",className:"h-full max-w-full",children:C.map((O,N)=>f.jsxs(T.Fragment,{children:[N>0&&f.jsx(Cf,{}),f.jsx(no,{defaultSize:100/C.length,minSize:15,children:O.length===1?A(O[0]):f.jsx(wf,{direction:"horizontal",className:"h-full max-w-full",children:O.map((D,L)=>f.jsxs(T.Fragment,{children:[L>0&&f.jsx(Cf,{}),f.jsx(no,{defaultSize:100/E,minSize:15,children:A(D)})]},D.id))})})]},`row-${N}`))}))}function jLe(e){if(Array.isArray(e))return e}function FLe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,s,o=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(p){u=!0,i=p}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return o}}function lL(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _se(e,t){if(e){if(typeof e=="string")return lL(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?lL(e,t):void 0}}function BLe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
45
|
+
`).filter(Boolean).pop()||G;_t.error(B,{action:{label:"Resolve with Claude",onClick:()=>A(`Create a PR for this task. Error: "${G}". After creating, link it using: vibora current-task pr <url>. Worktree: ${t}.`)}})}},H=m.isPending||g.isPending||x.isPending||_.isPending||b.isPending;return f.jsxs(f.Fragment,{children:[f.jsxs(am,{children:[f.jsx(sm,{className:"flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:o3,size:12,strokeWidth:2,className:H?"animate-pulse":""})}),f.jsxs(om,{align:"end",children:[f.jsxs(Tr,{onClick:R,disabled:m.isPending,children:[f.jsx(J,{icon:dy,size:12,strokeWidth:2,className:m.isPending?"animate-spin":""}),"Pull from main"]}),f.jsxs(Tr,{onClick:O,disabled:g.isPending,children:[f.jsx(J,{icon:cy,size:12,strokeWidth:2,className:g.isPending?"animate-pulse":""}),"Merge to main"]}),f.jsxs(Tr,{onClick:N,disabled:x.isPending,children:[f.jsx(J,{icon:fy,size:12,strokeWidth:2,className:x.isPending?"animate-pulse":""}),"Push to origin"]}),f.jsxs(Tr,{onClick:D,disabled:_.isPending,children:[f.jsx(J,{icon:hy,size:12,strokeWidth:2,className:_.isPending?"animate-spin":""}),"Sync parent with origin"]}),l&&u&&f.jsxs(Tr,{onClick:L,children:[f.jsx(J,{icon:py,size:12,strokeWidth:2}),"Commit"]}),!a&&f.jsxs(Tr,{onClick:V,disabled:b.isPending,children:[f.jsx(J,{icon:ju,size:12,strokeWidth:2,className:b.isPending?"animate-pulse":""}),"Create PR"]}),f.jsx(kW,{}),f.jsxs(Tr,{onClick:z,children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),o]}),f.jsx(kW,{}),f.jsxs(Tr,{onClick:()=>w(!0),disabled:v.isPending,className:"text-destructive focus:text-destructive",children:[f.jsx(J,{icon:rs,size:12,strokeWidth:2}),"Delete task"]})]})]}),f.jsx(Oa,{open:C,onOpenChange:w,children:f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsx(La,{children:"This will permanently delete this task and its worktree."})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{children:"Cancel"}),f.jsx(ec,{onClick:P,variant:"destructive",disabled:v.isPending,children:v.isPending?"Deleting...":"Delete"})]})]})})]})}function lm({worktreePath:e}){const{data:t,isLoading:n}=QCe(e);if(!e||n||!t)return null;if(t.clean)return f.jsxs(Jr,{className:"bg-accent/20 text-accent border-transparent",children:[f.jsx(J,{icon:Dr,size:12,strokeWidth:2}),"Clean"]});const r=t.files.length;return f.jsxs(Jr,{className:"bg-amber-500/20 text-amber-600 dark:text-amber-400 border-transparent",children:[f.jsx(J,{icon:er,size:12,strokeWidth:2}),r," ",r===1?"change":"changes"]})}const OLe=350,RLe=250;function NLe({taskInfo:e,terminalId:t,terminalCwd:n,isMobile:r,sendInputToTerminal:i}){const a=T.useRef(null),[s,o]=T.useState(1/0),l=Uw();T.useEffect(()=>{const m=a.current;if(!m)return;const g=new ResizeObserver(x=>{for(const _ of x)o(_.contentRect.width)});return g.observe(m),()=>g.disconnect()},[]);const u=r||s<OLe,p=s>=RLe,d=()=>{l.mutate({taskId:e.taskId,deleteLinkedWorktree:!0})};return f.jsx("div",{ref:a,className:"flex shrink-0 items-center justify-between border-b border-border bg-card",children:f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2 py-1",children:[f.jsxs(Rn,{to:"/tasks/$taskId",params:{taskId:e.taskId},className:"flex shrink-0 items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 max-w-[50%]",children:[f.jsx(J,{icon:l3,size:14,strokeWidth:2,className:"shrink-0"}),f.jsx("span",{className:"truncate",children:e.title})]}),u?f.jsxs(f.Fragment,{children:[p&&f.jsx(lm,{worktreePath:e.worktreePath}),f.jsx("div",{className:"ml-auto flex items-center",children:f.jsx(kLe,{repoPath:e.repoPath,worktreePath:e.worktreePath,baseBranch:e.baseBranch,taskId:e.taskId,title:e.title,prUrl:e.prUrl,repoId:e.repoId,repoName:e.repoName,terminalId:t,sendInputToTerminal:i})})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Rn,{to:e.repoId?"/repositories/$repoId":"/repositories",params:e.repoId?{repoId:e.repoId}:void 0,className:"flex min-w-0 items-center gap-1 text-xs font-medium text-foreground cursor-pointer hover:underline",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2,className:"shrink-0"}),f.jsx("span",{className:"truncate",children:e.repoName})]}),n&&f.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[f.jsx(J,{icon:Rw,size:12,strokeWidth:2,className:"shrink-0"}),f.jsx("span",{className:"truncate",children:n.split("/").pop()})]}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsx(lm,{worktreePath:e.worktreePath}),f.jsx(ALe,{repoPath:e.repoPath,worktreePath:e.worktreePath,baseBranch:e.baseBranch,taskId:e.taskId,title:e.title,prUrl:e.prUrl,isMobile:r,terminalId:t,sendInputToTerminal:i}),f.jsxs(Oa,{children:[f.jsx(Ju,{render:f.jsx(Ae,{variant:"ghost",size:"icon-xs",className:"h-5 w-5 text-muted-foreground hover:text-destructive",title:"Delete task",disabled:l.isPending}),children:f.jsx(J,{icon:rs,size:12,strokeWidth:2})}),f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsx(La,{children:"This will permanently delete this task and its worktree."})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{children:"Cancel"}),f.jsx(ec,{onClick:d,variant:"destructive",disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})]})]})]})]})})}function ILe({terminals:e,activeIndex:t,onSelect:n,taskInfoByCwd:r}){const i=T.useRef(null),a=T.useRef(null);T.useEffect(()=>{a.current&&i.current&&a.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[t]);const s=(o,l)=>{if(o.cwd&&r){const u=r.get(o.cwd);if(u)return u.title}return o.name||`Terminal ${l+1}`};return f.jsx("div",{ref:i,className:"flex shrink-0 gap-1 overflow-x-auto border-b border-border bg-card px-2 py-1.5",style:{WebkitOverflowScrolling:"touch"},children:e.map((o,l)=>{const u=l===t,p=s(o,l);return f.jsx("button",{ref:u?a:null,onClick:()=>n(l),className:Be("shrink-0 rounded-md px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation","max-w-[150px] truncate",u?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"),children:p},o.id)})})}const DLe=Np(function({terminal:t,taskInfo:n,isMobile:r,onClose:i,onReady:a,onResize:s,onRename:o,onContainerReady:l,setupImagePaste:u,onFocus:p,sendInputToTerminal:d,isMaximized:m,onMaximize:g,onMinimize:x,canMaximize:_}){const b=Rp(),{resolvedTheme:y}=_p(),v=y==="dark",E=n?b.terminals.get(t.id):null,C=E?.isStartingUp??!1;return T.useEffect(()=>{n&&jt.terminal.info("TerminalPane isStartingUp check",{terminalId:t.id,hasTaskInfo:!!n,hasTerminalModel:!!E,isStartingUp:E?.isStartingUp,isStartingClaude:C})},[t.id,n,E,C,E?.isStartingUp]),f.jsxs("div",{className:"flex h-full min-w-0 flex-col overflow-hidden",children:[n?f.jsx(NLe,{taskInfo:n,terminalId:t.id,terminalCwd:t.cwd,isMobile:r,sendInputToTerminal:d}):f.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-card",children:[f.jsx(xLe,{name:t.name,status:t.status,exitCode:t.exitCode,className:"flex-1 border-b-0",onRename:o}),f.jsxs("div",{className:"flex items-center gap-1 mr-1",children:[_&&f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:m?x:g,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:m?"Restore":"Maximize",children:f.jsx(J,{icon:m?x_e:M_e,size:12,strokeWidth:2})}),i&&f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:i,className:"h-5 w-5 text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:Mr,size:12,strokeWidth:2})})]})]}),f.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[f.jsx(oL,{onReady:a,onResize:s,onContainerReady:l,terminalId:t.id,setupImagePaste:u,onFocus:p}),C&&f.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:Be("animate-spin",v?"text-white/60":"text-black/60")}),f.jsx("span",{className:Be("font-mono text-sm",v?"text-white/60":"text-black/60"),children:"Starting Claude Code..."})]})})]})]})});function LLe({onAdd:e}){return f.jsx("div",{className:"flex h-full items-center justify-center bg-terminal-background",children:e?f.jsxs(Ae,{variant:"outline",size:"sm",onClick:e,className:"gap-2",children:[f.jsx(J,{icon:Ed,size:14,strokeWidth:2}),"New Terminal"]}):f.jsx("p",{className:"text-xs text-muted-foreground",children:"No terminals"})})}function PLe(e){return e<=1?{rows:1,cols:1}:e<=2?{rows:1,cols:2}:e<=4?{rows:2,cols:2}:e<=6?{rows:2,cols:3}:e<=9?{rows:3,cols:3}:{rows:3,cols:4}}function MLe({terminals:e,onTerminalClose:t,onTerminalAdd:n,onTerminalReady:r,onTerminalResize:i,onTerminalRename:a,onTerminalContainerReady:s,setupImagePaste:o,writeToTerminal:l,sendInputToTerminal:u,taskInfoByCwd:p}){const d=tC(),[m,g]=T.useState(e.length>0?e[0].id:null),[x,_]=T.useState(0),[b,y]=T.useState(null);if(T.useEffect(()=>{x>=e.length&&e.length>0&&_(e.length-1)},[e.length,x]),T.useEffect(()=>{b&&!e.find(O=>O.id===b)&&y(null)},[e,b]),e.length===0)return f.jsx(LLe,{onAdd:n});const{rows:v,cols:E}=PLe(e.length),C=[];for(let O=0;O<v;O++){const N=O*E,D=Math.min(N+E,e.length);N<e.length&&C.push(e.slice(N,D))}const w=O=>{const N=d&&e.length>1?e[x]?.id:m;N&&l&&l(N,O)},A=O=>{const N=O.cwd?p?.get(O.cwd):void 0,D=!N&&e.length>1;return f.jsx(DLe,{terminal:O,taskInfo:N,isMobile:d,onClose:t?()=>t(O.id):void 0,onReady:r?L=>r(O.id,L):void 0,onResize:i?(L,z)=>i(O.id,L,z):void 0,onRename:a?L=>a(O.id,L):void 0,onContainerReady:s?L=>s(O.id,L):void 0,setupImagePaste:o,onFocus:()=>g(O.id),sendInputToTerminal:u,isMaximized:b===O.id,onMaximize:()=>y(O.id),onMinimize:()=>y(null),canMaximize:D})},R=O=>f.jsxs("div",{className:"flex h-full w-full flex-col",children:[f.jsx("div",{className:"min-h-0 flex-1",children:O}),d&&l&&f.jsx(WS,{onSend:w})]});if(d&&e.length>1){const O=e[x]??e[0];return f.jsxs("div",{className:"flex h-full w-full flex-col",children:[f.jsx(ILe,{terminals:e,activeIndex:x,onSelect:_,taskInfoByCwd:p}),f.jsx("div",{className:"min-h-0 flex-1",children:A(O)},O.id),l&&f.jsx(WS,{onSend:w})]})}if(e.length===1)return R(f.jsx("div",{className:"h-full w-full max-w-full min-w-0 overflow-hidden",children:A(e[0])},e[0].id));if(b){const O=e.find(N=>N.id===b);if(O)return R(f.jsx("div",{className:"h-full w-full max-w-full min-w-0 overflow-hidden",children:A(O)},O.id))}return e.length===2?R(f.jsxs(wf,{direction:d?"vertical":"horizontal",className:"h-full max-w-full",children:[f.jsx(no,{defaultSize:50,minSize:15,children:A(e[0])},e[0].id),f.jsx(Cf,{}),f.jsx(no,{defaultSize:50,minSize:15,children:A(e[1])},e[1].id)]})):e.length===3?R(f.jsxs(wf,{direction:"horizontal",className:"h-full max-w-full",children:[f.jsx(no,{defaultSize:50,minSize:15,children:A(e[0])},e[0].id),f.jsx(Cf,{}),f.jsx(no,{defaultSize:50,minSize:15,children:f.jsxs(wf,{direction:"vertical",className:"h-full max-w-full",children:[f.jsx(no,{defaultSize:50,minSize:15,children:A(e[1])},e[1].id),f.jsx(Cf,{}),f.jsx(no,{defaultSize:50,minSize:15,children:A(e[2])},e[2].id)]})})]})):R(f.jsx(wf,{direction:"vertical",className:"h-full max-w-full",children:C.map((O,N)=>f.jsxs(T.Fragment,{children:[N>0&&f.jsx(Cf,{}),f.jsx(no,{defaultSize:100/C.length,minSize:15,children:O.length===1?A(O[0]):f.jsx(wf,{direction:"horizontal",className:"h-full max-w-full",children:O.map((D,L)=>f.jsxs(T.Fragment,{children:[L>0&&f.jsx(Cf,{}),f.jsx(no,{defaultSize:100/E,minSize:15,children:A(D)})]},D.id))})})]},`row-${N}`))}))}function jLe(e){if(Array.isArray(e))return e}function FLe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,s,o=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(p){u=!0,i=p}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return o}}function lL(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _se(e,t){if(e){if(typeof e=="string")return lL(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?lL(e,t):void 0}}function BLe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
46
46
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sse(e,t){return jLe(e)||FLe(e,t)||_se(e,t)||BLe()}var m2={},Zb={},OW;function Ese(){if(OW)return Zb;OW=1,Object.defineProperty(Zb,"__esModule",{value:!0}),Zb.bind=void 0;function e(t,n){var r=n.type,i=n.listener,a=n.options;return t.addEventListener(r,i,a),function(){t.removeEventListener(r,i,a)}}return Zb.bind=e,Zb}var mf={},RW;function ULe(){if(RW)return mf;RW=1;var e=mf&&mf.__assign||function(){return e=Object.assign||function(a){for(var s,o=1,l=arguments.length;o<l;o++){s=arguments[o];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(a[u]=s[u])}return a},e.apply(this,arguments)};Object.defineProperty(mf,"__esModule",{value:!0}),mf.bindAll=void 0;var t=Ese();function n(a){if(!(typeof a>"u"))return typeof a=="boolean"?{capture:a}:a}function r(a,s){if(s==null)return a;var o=e(e({},a),{options:e(e({},n(s)),n(a.options))});return o}function i(a,s,o){var l=s.map(function(u){var p=r(u,o);return(0,t.bind)(a,p)});return function(){l.forEach(function(p){return p()})}}return mf.bindAll=i,mf}var NW;function $Le(){return NW||(NW=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=e.bind=void 0;var t=Ese();Object.defineProperty(e,"bind",{enumerable:!0,get:function(){return t.bind}});var n=ULe();Object.defineProperty(e,"bindAll",{enumerable:!0,get:function(){return n.bindAll}})})(m2)),m2}var jm=$Le(),wse="data-pdnd-honey-pot";function Cse(e){return e instanceof Element&&e.hasAttribute(wse)}function Tse(e){var t=document.elementsFromPoint(e.x,e.y),n=Sse(t,2),r=n[0],i=n[1];return r?Cse(r)?i??null:r:null}function Cy(e){"@babel/helpers - typeof";return Cy=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cy(e)}function zLe(e,t){if(Cy(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Cy(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function HLe(e){var t=zLe(e,"string");return Cy(t)=="symbol"?t:t+""}function K0(e,t,n){return(t=HLe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ase=2147483647;function IW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function DW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?IW(Object(n),!0).forEach(function(r){K0(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):IW(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Ty=2,LW=Ty/2;function WLe(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function VLe(e){return{x:e.x-LW,y:e.y-LW}}function qLe(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function GLe(e){return{x:Math.min(e.x,window.innerWidth-Ty),y:Math.min(e.y,window.innerHeight-Ty)}}function PW(e){var t=e.client,n=GLe(qLe(VLe(WLe(t))));return DOMRect.fromRect({x:n.x,y:n.y,width:Ty,height:Ty})}function MW(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}function KLe(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function YLe(e){var t=e.initial,n=document.createElement("div");n.setAttribute(wse,"true");var r=PW({client:t});Object.assign(n.style,DW(DW({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},MW({clientRect:r})),{},{pointerEvents:"auto",zIndex:Ase})),document.body.appendChild(n);var i=jm.bind(window,{type:"pointermove",listener:function(s){var o={x:s.clientX,y:s.clientY};r=PW({client:o}),Object.assign(n.style,MW({clientRect:r}))},options:{capture:!0}});return function(s){var o=s.current;if(i(),KLe({client:o,clientRect:r})){n.remove();return}function l(){u(),n.remove()}var u=jm.bindAll(window,[{type:"pointerdown",listener:l},{type:"pointermove",listener:l},{type:"focusin",listener:l},{type:"focusout",listener:l},{type:"dragstart",listener:l},{type:"dragenter",listener:l},{type:"dragover",listener:l}],{capture:!0})}}function XLe(){var e=null;function t(){return e=null,jm.bind(window,{type:"pointermove",listener:function(i){e={x:i.clientX,y:i.clientY}},options:{capture:!0}})}function n(){var r=null;return function(a){var s=a.eventName,o=a.payload;if(s==="onDragStart"){var l=o.location.initial.input,u=e??{x:l.clientX,y:l.clientY};r=YLe({initial:u})}if(s==="onDrop"){var p,d=o.location.current.input;(p=r)===null||p===void 0||p({current:{x:d.clientX,y:d.clientY}}),r=null,e=null}}}return{bindEvents:t,getOnPostDispatch:n}}function ZLe(e){if(Array.isArray(e))return lL(e)}function QLe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function JLe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
47
47
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kse(e){return ZLe(e)||QLe(e)||_se(e)||JLe()}function Dp(e){var t=null;return function(){if(!t){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];var s=e.apply(this,i);t={result:s}}return t.result}}var ePe=Dp(function(){return navigator.userAgent.includes("Firefox")}),Y0=Dp(function(){var t=navigator,n=t.userAgent;return n.includes("AppleWebKit")&&!n.includes("Chrome")}),uL={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function tPe(e){var t=e.dragLeave;return Y0()?t.hasOwnProperty(uL.isLeavingWindow):!1}(function(){if(typeof window>"u"||!Y0())return;function t(){return{enterCount:0,isOverWindow:!1}}var n=t();function r(){n=t()}jm.bindAll(window,[{type:"dragstart",listener:function(){n.enterCount=0,n.isOverWindow=!0}},{type:"drop",listener:r},{type:"dragend",listener:r},{type:"dragenter",listener:function(a){!n.isOverWindow&&n.enterCount===0&&(a[uL.isEnteringWindow]=!0),n.isOverWindow=!0,n.enterCount++}},{type:"dragleave",listener:function(a){n.enterCount--,n.isOverWindow&&n.enterCount===0&&(a[uL.isLeavingWindow]=!0,n.isOverWindow=!1)}}],{capture:!0})})();function nPe(e){return"nodeName"in e}function rPe(e){return nPe(e)&&e.ownerDocument!==document}function iPe(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n!=="dragleave"?!1:Y0()?tPe({dragLeave:t}):r==null?!0:ePe()?rPe(r):r instanceof HTMLIFrameElement}function aPe(e){var t=e.onDragEnd;return[{type:"pointermove",listener:(function(){var n=0;return function(){if(n<20){n++;return}t()}})()},{type:"pointerdown",listener:t}]}function Mv(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var sPe=function(t){var n=[],r=null,i=function(){for(var s=arguments.length,o=new Array(s),l=0;l<s;l++)o[l]=arguments[l];n=o,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i},g2=sPe(function(e){return e()}),d_=(function(){var e=null;function t(r){var i=requestAnimationFrame(function(){e=null,r()});e={frameId:i,fn:r}}function n(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return{schedule:t,flush:n}})();function oPe(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function a(o){r(o),i={dropTargets:o.payload.location.current.dropTargets}}var s={start:function(l){var u=l.nativeSetDragImage,p={current:n,previous:i,initial:n};a({eventName:"onGenerateDragPreview",payload:{source:t,location:p,nativeSetDragImage:u}}),d_.schedule(function(){a({eventName:"onDragStart",payload:{source:t,location:p}})})},dragUpdate:function(l){var u=l.current;d_.flush(),g2.cancel(),a({eventName:"onDropTargetChange",payload:{source:t,location:{initial:n,previous:i,current:u}}})},drag:function(l){var u=l.current;g2(function(){d_.flush();var p={initial:n,previous:i,current:u};a({eventName:"onDrag",payload:{source:t,location:p}})})},drop:function(l){var u=l.current,p=l.updatedSourcePayload;d_.flush(),g2.cancel(),a({eventName:"onDrop",payload:{source:p??t,location:{current:u,previous:i,initial:n}}})}};return s}var cL={isActive:!1};function Ose(){return!cL.isActive}function lPe(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function uPe(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function cPe(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!Ose())return;var a=dPe({event:t,dragType:n,getDropTargetsOver:r});cL.isActive=!0;var s={current:a};b2({event:t,current:a.dropTargets});var o=oPe({source:n.payload,dispatchEvent:i,initial:a});function l(g){var x=uPe({current:s.current.dropTargets,next:g.dropTargets});s.current=g,x&&o.dragUpdate({current:s.current})}function u(g){var x=Mv(g),_=Cse(g.target)?Tse({x:x.clientX,y:x.clientY}):g.target,b=r({target:_,input:x,source:n.payload,current:s.current.dropTargets});b.length&&(g.preventDefault(),b2({event:g,current:b})),l({dropTargets:b,input:x})}function p(){s.current.dropTargets.length&&l({dropTargets:[],input:s.current.input}),o.drop({current:s.current,updatedSourcePayload:null}),d()}function d(){cL.isActive=!1,m()}var m=jm.bindAll(window,[{type:"dragover",listener:function(x){u(x),o.drag({current:s.current})}},{type:"dragenter",listener:u},{type:"dragleave",listener:function(x){iPe({dragLeave:x})&&(l({input:s.current.input,dropTargets:[]}),n.startedFrom==="external"&&p())}},{type:"drop",listener:function(x){if(s.current={dropTargets:s.current.dropTargets,input:Mv(x)},!s.current.dropTargets.length){p();return}x.preventDefault(),b2({event:x,current:s.current.dropTargets}),o.drop({current:s.current,updatedSourcePayload:n.type==="external"?n.getDropPayload(x):null}),d()}},{type:"dragend",listener:function(x){s.current={dropTargets:s.current.dropTargets,input:Mv(x)},p()}}].concat(kse(aPe({onDragEnd:p}))),{capture:!0});o.start({nativeSetDragImage:lPe(t)})}function b2(e){var t,n=e.event,r=e.current,i=(t=r[0])===null||t===void 0?void 0:t.dropEffect;i!=null&&n.dataTransfer&&(n.dataTransfer.dropEffect=i)}function dPe(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=Mv(t);if(n.startedFrom==="external")return{input:i,dropTargets:[]};var a=r({input:i,source:n.payload,target:t.target,current:[]});return{input:i,dropTargets:a}}var jW={canStart:Ose,start:cPe},dL=new Map;function fPe(e){var t=e.typeKey,n=e.mount,r=dL.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return dL.set(t,i),i}function pPe(e){var t=fPe(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),dL.delete(e.typeKey))}}function X0(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){t.forEach(function(i){return i()})}}function Rse(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function FW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Vc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?FW(Object(n),!0).forEach(function(r){K0(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):FW(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function v2(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=hPe(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
48
48
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return s=u.done,u},e:function(u){o=!0,a=u},f:function(){try{s||n.return==null||n.return()}finally{if(o)throw a}}}}function hPe(e,t){if(e){if(typeof e=="string")return BW(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?BW(e,t):void 0}}function BW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function y2(e){return e.slice(0).reverse()}function mPe(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i="data-drop-target-for-".concat(t),a="[".concat(i,"]");function s(g){return r.set(g.element,g),function(){return r.delete(g.element)}}function o(g){var x=X0(Rse(g.element,{attribute:i,value:"true"}),s(g));return Dp(x)}function l(g){var x,_,b,y,v=g.source,E=g.target,C=g.input,w=g.result,A=w===void 0?[]:w;if(E==null)return A;if(!(E instanceof Element))return E instanceof Node?l({source:v,target:E.parentElement,input:C,result:A}):A;var R=E.closest(a);if(R==null)return A;var O=r.get(R);if(O==null)return A;var N={input:C,source:v,element:O.element};if(O.canDrop&&!O.canDrop(N))return l({source:v,target:O.element.parentElement,input:C,result:A});var D=(x=(_=O.getData)===null||_===void 0?void 0:_.call(O,N))!==null&&x!==void 0?x:{},L=(b=(y=O.getDropEffect)===null||y===void 0?void 0:y.call(O,N))!==null&&b!==void 0?b:n,z={data:D,element:O.element,dropEffect:L,isActiveDueToStickiness:!1};return l({source:v,target:O.element.parentElement,input:C,result:[].concat(kse(A),[z])})}function u(g){var x=g.eventName,_=g.payload,b=v2(_.location.current.dropTargets),y;try{for(b.s();!(y=b.n()).done;){var v,E=y.value,C=r.get(E.element),w=Vc(Vc({},_),{},{self:E});C==null||(v=C[x])===null||v===void 0||v.call(C,w)}}catch(A){b.e(A)}finally{b.f()}}var p={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:function(x){var _=x.payload,b=new Set(_.location.current.dropTargets.map(function(G){return G.element})),y=new Set,v=v2(_.location.previous.dropTargets),E;try{for(v.s();!(E=v.n()).done;){var C,w=E.value;y.add(w.element);var A=r.get(w.element),R=b.has(w.element),O=Vc(Vc({},_),{},{self:w});if(A==null||(C=A.onDropTargetChange)===null||C===void 0||C.call(A,O),!R){var N;A==null||(N=A.onDragLeave)===null||N===void 0||N.call(A,O)}}}catch(G){v.e(G)}finally{v.f()}var D=v2(_.location.current.dropTargets),L;try{for(D.s();!(L=D.n()).done;){var z,P,V=L.value;if(!y.has(V.element)){var H=Vc(Vc({},_),{},{self:V}),j=r.get(V.element);j==null||(z=j.onDropTargetChange)===null||z===void 0||z.call(j,H),j==null||(P=j.onDragEnter)===null||P===void 0||P.call(j,H)}}}catch(G){D.e(G)}finally{D.f()}}};function d(g){p[g.eventName](g)}function m(g){var x=g.source,_=g.target,b=g.input,y=g.current,v=l({source:x,target:_,input:b});if(v.length>=y.length)return v;for(var E=y2(y),C=y2(v),w=[],A=0;A<E.length;A++){var R,O=E[A],N=C[A];if(N!=null){w.push(N);continue}var D=w[A-1],L=E[A-1];if(D?.element!==L?.element)break;var z=r.get(O.element);if(!z)break;var P={input:b,source:x,element:z.element};if(z.canDrop&&!z.canDrop(P)||!((R=z.getIsSticky)!==null&&R!==void 0&&R.call(z,P)))break;w.push(Vc(Vc({},O),{},{isActiveDueToStickiness:!0}))}return y2(w)}return{dropTargetForConsumers:o,getIsOver:m,dispatchEvent:d}}function gPe(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=bPe(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
@@ -120,7 +120,7 @@ ${n.map(([a,s])=>{const o=s.theme?.[r]||s.color;return o?` --color-${a}: ${o};`
|
|
|
120
120
|
|
|
121
121
|
${e}`,l=mm(o);return`opencode --agent ${a} --prompt ${l}${s}`},notFoundPatterns:[/opencode: command not found/,/opencode: not found/,/'opencode' is not recognized/,/command not found: opencode/],processPattern:/\bopencode\b/i},PP={claude:WGe,opencode:VGe};function qGe(e,t){return PP[e].buildCommand(t)}function GGe(e,t){if(t)return PP[t].notFoundPatterns.some(r=>r.test(e))?t:null;for(const[n,r]of Object.entries(PP))if(r.notFoundPatterns.some(i=>i.test(e)))return n;return null}function aQ({taskName:e,cwd:t,className:n,agent:r="claude",aiMode:i,description:a,startupScript:s,agentOptions:o,opencodeModel:l,serverPort:u=7777,autoFocus:p=!1}){const d=T.useRef(null),m=T.useRef(null),g=T.useRef(!1),x=T.useRef(p),_=T.useRef(null),b=T.useRef(!1),y=T.useRef(!1),[v,E]=T.useState(null),[C,w]=T.useState(!1),[A,R]=T.useState(!1),[O,N]=T.useState(!1),[D,L]=T.useState(null),{resolvedTheme:z}=_p(),P=z==="dark",V=P?xse:yse;T.useEffect(()=>{jt.taskTerminal.debug("cwd changed, resetting refs",{cwd:t}),b.current=!1,y.current=!1,g.current=!1,E(null),w(!1)},[t]);const{setTerminalFocused:H}=d3(),{terminals:j,terminalsLoaded:G,connected:q,createTerminal:B,attachXterm:F,resizeTerminal:U,setupImagePaste:K,writeToTerminal:W,consumePendingStartup:ee,clearStartingUp:oe}=y5(),ne=T.useRef(F),Z=T.useRef(K),Y=T.useRef(W),Q=T.useRef(ee),re=T.useRef(oe);T.useEffect(()=>{ne.current=F},[F]),T.useEffect(()=>{Z.current=K},[K]),T.useEffect(()=>{Y.current=W},[W]),T.useEffect(()=>{Q.current=ee},[ee]),T.useEffect(()=>{re.current=oe},[oe]),T.useEffect(()=>{x.current=p},[p]);const se=v?j.find(ce=>ce.id===v):null,te=se?.status;T.useEffect(()=>{if(!d.current||m.current)return;const ce=new gse.Terminal({cursorBlink:!0,fontSize:Math.round(13*Qc),fontFamily:"JetBrains Mono Variable, PureNerdFont, Menlo, Monaco, monospace",lineHeight:1.2,theme:V}),ye=new bse.FitAddon,me=new vse.WebLinksAddon;ce.loadAddon(ye),ce.loadAddon(me),ce.open(d.current),m.current=ce,_.current=ye,N(!0),requestAnimationFrame(()=>{ye.fit()});const Pe=setTimeout(()=>{ye.fit(),ce.refresh(0,ce.rows-1)},100),Ie=()=>H(!0),We=()=>H(!1);return ce.textarea&&(ce.textarea.addEventListener("focus",Ie),ce.textarea.addEventListener("blur",We)),()=>{clearTimeout(Pe),ce.textarea&&(ce.textarea.removeEventListener("focus",Ie),ce.textarea.removeEventListener("blur",We)),H(!1),ce.dispose(),m.current=null,_.current=null,N(!1)}},[H]);const xe=T.useCallback(()=>{if(!_.current||!m.current)return;_.current.fit();const{cols:ce,rows:ye}=m.current;v&&U(v,ce,ye)},[v,U]);T.useEffect(()=>{if(!d.current)return;const ce=()=>{requestAnimationFrame(xe)};window.addEventListener("resize",ce);const ye=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{xe(),m.current&&m.current.refresh(0,m.current.rows-1)})};document.addEventListener("visibilitychange",ye);const me=new ResizeObserver(ce);me.observe(d.current);const Pe=new IntersectionObserver(Ie=>{Ie[0]?.isIntersecting&&requestAnimationFrame(()=>{xe(),m.current&&m.current.refresh(0,m.current.rows-1)})},{threshold:.1});return Pe.observe(d.current),()=>{window.removeEventListener("resize",ce),document.removeEventListener("visibilitychange",ye),me.disconnect(),Pe.disconnect()}},[xe]),T.useEffect(()=>{if(!q||!t||!O||!G)return;const ce=j.find(ye=>ye.cwd===t);if(ce){E(ce.id);return}if(!b.current&&m.current){b.current=!0,w(!0);const{cols:ye,rows:me}=m.current;B({name:e,cols:ye,rows:me,cwd:t,startup:{startupScript:s,agent:r,agentOptions:o,opencodeModel:l,aiMode:i,description:a,taskName:e,serverPort:u}})}},[q,t,O,G,j,e,B]),T.useEffect(()=>{if(!t)return;const ce=j.find(me=>me.cwd===t);if(!ce)return;const ye=v&&j.some(me=>me.id===v);(!v||!ye)&&(jt.taskTerminal.debug("setting terminalId",{newId:ce.id,prevId:v,reason:v?"tempId replaced":"initial",cwd:t,terminalCount:j.length}),E(ce.id),w(!1),v&&!ye&&(y.current=!1))},[j,t,v]),T.useEffect(()=>{if(jt.taskTerminal.debug("attach effect",{terminalId:v,hasTermRef:!!m.current,hasContainerRef:!!d.current,attachedRef:y.current}),!v||!m.current||!d.current||y.current)return;jt.taskTerminal.debug("attach effect passed guards, calling attachXterm",{terminalId:v});const ce=Pe=>{requestAnimationFrame(xe);const Ie=Q.current(Pe);if(jt.taskTerminal.debug("onAttached checking pending startup",{terminalId:Pe,hasPendingStartup:!!Ie}),!Ie){if(x.current&&!g.current&&m.current){const Qe=()=>{const Fe=m.current;!g.current&&Fe&&(Fe.focus(),Fe.textarea===document.activeElement&&(g.current=!0))};setTimeout(Qe,50),setTimeout(Qe,200),setTimeout(Qe,500)}return}jt.taskTerminal.info("onAttached: running startup commands",{terminalId:Pe}),R(!0);const{startupScript:We,agent:Te="claude",agentOptions:he,opencodeModel:fe,aiMode:ke,description:_e,taskName:pe,serverPort:Oe}=Ie;We&&setTimeout(()=>{const Qe="VIBORA_STARTUP_"+Date.now(),Fe=`source /dev/stdin <<'${Qe}'
|
|
122
122
|
${We}
|
|
123
|
-
${Qe}`;Y.current(Pe,Fe+"\r")},100);const Se=Oe??7777,Ue=Se!==7777?` --port=${Se}`:"",Ge=`You are working in a Vibora task worktree. Commit after completing each logical unit of work (feature, fix, refactor) to preserve progress. When you finish working and need user input, run: vibora current-task review${Ue}. When linking a PR: vibora current-task pr <url>${Ue}. When linking a Linear ticket: vibora current-task linear <url-or-ticket>${Ue}. For notifications: vibora notify "Title" "Message"${Ue}.`,ze=_e?`${pe}: ${_e}`:pe,Xe=qGe(Te,{prompt:ze,systemPrompt:Ge,sessionId:Pe,mode:ke==="plan"?"plan":"default",additionalOptions:he??{},opencodeModel:fe});setTimeout(()=>{if(Y.current(Pe,Xe+"\r"),R(!1),re.current(Pe),x.current&&!g.current&&m.current){const Qe=()=>{const Fe=m.current;!g.current&&Fe&&(Fe.focus(),Fe.textarea===document.activeElement&&(g.current=!0))};setTimeout(Qe,50),setTimeout(Qe,200),setTimeout(Qe,500)}},We?5e3:100)},ye=ne.current(v,m.current,{onAttached:ce}),me=Z.current(d.current,v);return y.current=!0,jt.taskTerminal.debug("attachedRef set to true",{terminalId:v}),()=>{jt.taskTerminal.debug("cleanup running, setting attachedRef to false",{terminalId:v}),ye(),me(),y.current=!1}},[v,xe]),T.useEffect(()=>{m.current&&(m.current.options.theme=V)},[V]),T.useEffect(()=>{if(!p||g.current||!m.current||!v||C||A)return;const ce=[0,50,150,300,500],ye=[];return ce.forEach(me=>{const Pe=setTimeout(()=>{const Ie=m.current;!g.current&&Ie&&(Ie.focus(),Ie.textarea===document.activeElement&&(g.current=!0))},me);ye.push(Pe)}),()=>{ye.forEach(clearTimeout)}},[p,C,A,v]),T.useEffect(()=>{if(!m.current||D)return;const ce=m.current,ye=()=>{const Pe=ce.buffer.active;for(let Ie=Math.max(0,Pe.cursorY-3);Ie<=Pe.cursorY;Ie++){const We=Pe.getLine(Ie);if(We){const Te=We.translateToString(),he=GGe(Te,r);if(he){L(he);return}}}},me=ce.onLineFeed(ye);return()=>{me.dispose()}},[D,r]);const be=T.useCallback(ce=>{v&&Y.current(v,ce)},[v]);return t?f.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[!q&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:"Connecting to terminal server..."}),te==="error"&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-destructive/20 text-destructive text-xs",children:"Terminal failed to start. The worktree directory may not exist."}),te==="exited"&&f.jsxs("div",{className:"shrink-0 px-2 py-1 bg-muted text-muted-foreground text-xs",children:["Terminal exited (code: ",se?.exitCode,")"]}),f.jsxs("div",{className:"relative min-h-0 flex-1",children:[f.jsx("div",{ref:d,className:Be("h-full w-full overflow-hidden p-2 bg-terminal-background",n)}),C&&!v&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-terminal-background",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:Be("animate-spin",P?"text-white/50":"text-black/50")}),f.jsx("span",{className:Be("font-mono text-sm",P?"text-white/50":"text-black/50"),children:"Initializing terminal..."})]})}),A&&f.jsx("div",{className:"pointer-events-auto absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:Be("animate-spin",P?"text-white/60":"text-black/60")}),f.jsxs("span",{className:Be("font-mono text-sm",P?"text-white/60":"text-black/60"),children:["Starting ",Pl[r],"..."]})]})}),D&&f.jsx("div",{className:"absolute bottom-4 left-4 right-4 z-10",children:f.jsxs("div",{className:Be("flex items-start gap-3 rounded-lg border p-4","bg-amber-500/10 border-amber-500/30"),children:[f.jsx(J,{icon:er,size:18,strokeWidth:2,className:"shrink-0 mt-0.5 text-amber-600 dark:text-amber-400"}),f.jsxs("div",{className:"flex-1 space-y-2",children:[f.jsxs("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[Pl[D]," CLI not found"]}),f.jsxs("p",{className:"text-xs text-amber-600/80 dark:text-amber-400/80",children:["Install it with:"," ",f.jsx("code",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 font-mono",children:gTe[D]})]}),f.jsx("a",{href:bTe[D],target:"_blank",rel:"noopener noreferrer",className:"inline-block text-xs font-medium text-amber-600 hover:text-amber-700 dark:text-amber-400 dark:hover:text-amber-300 underline",children:"View documentation"})]}),f.jsx("button",{onClick:()=>L(null),className:"shrink-0 p-1 rounded text-amber-600 hover:text-amber-700 hover:bg-amber-500/20 dark:text-amber-400 dark:hover:text-amber-300",children:f.jsx(J,{icon:Mr,size:14,strokeWidth:2})})]})}),f.jsx("button",{onClick:()=>m.current?.scrollToBottom(),className:Be("absolute top-2 right-5 p-1 transition-colors",P?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:f.jsx(J,{icon:Cne,size:20,strokeWidth:2})})]}),f.jsx(WS,{onSend:be})]}):f.jsx("div",{className:Be("flex h-full items-center justify-center text-muted-foreground text-sm bg-terminal-background",n),children:"No worktree path configured for this task"})}function KGe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}function YGe(e,t=[]){let n=[];function r(a,s){const o=T.createContext(s),l=n.length;n=[...n,s];const u=d=>{const{scope:m,children:g,...x}=d,_=m?.[e]?.[l]||o,b=T.useMemo(()=>x,Object.values(x));return f.jsx(_.Provider,{value:b,children:g})};u.displayName=a+"Provider";function p(d,m){const g=m?.[e]?.[l]||o,x=T.useContext(g);if(x)return x;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[u,p]}const i=()=>{const a=n.map(s=>T.createContext(s));return function(o){const l=o?.[e]||a;return T.useMemo(()=>({[`__scope${e}`]:{...o,[e]:l}}),[o,l])}};return i.scopeName=e,[r,XGe(i,...t)]}function XGe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const s=r.reduce((o,{useScope:l,scopeName:u})=>{const d=l(a)[`__scope${u}`];return{...o,...d}},{});return T.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}var d0=globalThis?.document?T.useLayoutEffect:()=>{},ZGe=iw[" useInsertionEffect ".trim().toString()]||d0;function QGe({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,a,s]=JGe({defaultProp:t,onChange:n}),o=e!==void 0,l=o?e:i;{const p=T.useRef(e!==void 0);T.useEffect(()=>{const d=p.current;d!==o&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=o},[o,r])}const u=T.useCallback(p=>{if(o){const d=eKe(p)?p(e):p;d!==e&&s.current?.(d)}else a(p)},[o,e,a,s]);return[l,u]}function JGe({defaultProp:e,onChange:t}){const[n,r]=T.useState(e),i=T.useRef(n),a=T.useRef(t);return ZGe(()=>{a.current=t},[t]),T.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function eKe(e){return typeof e=="function"}function sQ(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ace(...e){return t=>{let n=!1;const r=e.map(i=>{const a=sQ(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():sQ(e[i],null)}}}}function kce(...e){return T.useCallback(Ace(...e),e)}function tKe(e){const t=nKe(e),n=T.forwardRef((r,i)=>{const{children:a,...s}=r,o=T.Children.toArray(a),l=o.find(iKe);if(l){const u=l.props.children,p=o.map(d=>d===l?T.Children.count(u)>1?T.Children.only(null):T.isValidElement(u)?u.props.children:null:d);return f.jsx(t,{...s,ref:i,children:T.isValidElement(u)?T.cloneElement(u,void 0,p):null})}return f.jsx(t,{...s,ref:i,children:a})});return n.displayName=`${e}.Slot`,n}function nKe(e){const t=T.forwardRef((n,r)=>{const{children:i,...a}=n;if(T.isValidElement(i)){const s=sKe(i),o=aKe(a,i.props);return i.type!==T.Fragment&&(o.ref=r?Ace(r,s):s),T.cloneElement(i,o)}return T.Children.count(i)>1?T.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rKe=Symbol("radix.slottable");function iKe(e){return T.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rKe}function aKe(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...o)=>{const l=a(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function sKe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var oKe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],x5=oKe.reduce((e,t)=>{const n=tKe(`Primitive.${t}`),r=T.forwardRef((i,a)=>{const{asChild:s,...o}=i,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(l,{...o,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function lKe(e,t){return T.useReducer((n,r)=>t[n][r]??n,e)}var Oce=e=>{const{present:t,children:n}=e,r=uKe(t),i=typeof n=="function"?n({present:r.isPresent}):T.Children.only(n),a=kce(r.ref,cKe(i));return typeof n=="function"||r.isPresent?T.cloneElement(i,{ref:a}):null};Oce.displayName="Presence";function uKe(e){const[t,n]=T.useState(),r=T.useRef(null),i=T.useRef(e),a=T.useRef("none"),s=e?"mounted":"unmounted",[o,l]=lKe(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const u=T_(r.current);a.current=o==="mounted"?u:"none"},[o]),d0(()=>{const u=r.current,p=i.current;if(p!==e){const m=a.current,g=T_(u);e?l("MOUNT"):g==="none"||u?.display==="none"?l("UNMOUNT"):l(p&&m!==g?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),d0(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,d=g=>{const _=T_(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&_&&(l("ANIMATION_END"),!i.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=g=>{g.target===t&&(a.current=T_(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:T.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function T_(e){return e?.animationName||"none"}function cKe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var dKe=iw[" useId ".trim().toString()]||(()=>{}),fKe=0;function pKe(e){const[t,n]=T.useState(dKe());return d0(()=>{n(r=>r??String(fKe++))},[e]),e||(t?`radix-${t}`:"")}var FC="Collapsible",[hKe]=YGe(FC),[mKe,_5]=hKe(FC),Rce=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:s,...o}=e,[l,u]=QGe({prop:r,defaultProp:i??!1,onChange:s,caller:FC});return f.jsx(mKe,{scope:n,disabled:a,contentId:pKe(),open:l,onOpenToggle:T.useCallback(()=>u(p=>!p),[u]),children:f.jsx(x5.div,{"data-state":E5(l),"data-disabled":a?"":void 0,...o,ref:t})})});Rce.displayName=FC;var Nce="CollapsibleTrigger",Ice=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_5(Nce,n);return f.jsx(x5.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":E5(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:KGe(e.onClick,i.onOpenToggle)})});Ice.displayName=Nce;var S5="CollapsibleContent",Dce=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_5(S5,e.__scopeCollapsible);return f.jsx(Oce,{present:n||i.open,children:({present:a})=>f.jsx(gKe,{...r,ref:t,present:a})})});Dce.displayName=S5;var gKe=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...a}=e,s=_5(S5,n),[o,l]=T.useState(r),u=T.useRef(null),p=kce(t,u),d=T.useRef(0),m=d.current,g=T.useRef(0),x=g.current,_=s.open||o,b=T.useRef(_),y=T.useRef(void 0);return T.useEffect(()=>{const v=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(v)},[]),d0(()=>{const v=u.current;if(v){y.current=y.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const E=v.getBoundingClientRect();d.current=E.height,g.current=E.width,b.current||(v.style.transitionDuration=y.current.transitionDuration,v.style.animationName=y.current.animationName),l(r)}},[s.open,r]),f.jsx(x5.div,{"data-state":E5(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!_,...a,ref:p,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:_&&i})});function E5(e){return e?"open":"closed"}var bKe=Rce;const vKe=bKe,yKe=Ice,xKe=Dce;function _Ke(e){const{viewState:t,setDiffOptions:n}=v5(e),{collapsedFiles:r}=t.diffOptions,i=T.useCallback(l=>{const u=r.includes(l);n({collapsedFiles:u?r.filter(p=>p!==l):[...r,l]})},[r,n]),a=T.useCallback(l=>{n({collapsedFiles:l})},[n]),s=T.useCallback(()=>{n({collapsedFiles:[]})},[n]),o=T.useCallback(l=>r.includes(l),[r]);return{options:t.diffOptions,setOption:(l,u)=>{n({[l]:u})},setOptions:n,toggleFileCollapse:i,collapseAll:a,expandAll:s,isFileCollapsed:o}}function SKe(e){const t=[];let n=null,r=0,i=0;for(const a of e.split(`
|
|
123
|
+
${Qe}`;Y.current(Pe,Fe+"\r")},100);const Se=Oe??7777,Ue=Se!==7777?` --port=${Se}`:"",Ge=`You are working in a Vibora task worktree. Commit after completing each logical unit of work (feature, fix, refactor) to preserve progress. When you finish working and need user input, run: vibora current-task review${Ue}. When linking a PR: vibora current-task pr <url>${Ue}. When linking a Linear ticket: vibora current-task linear <url-or-ticket>${Ue}. For notifications: vibora notify "Title" "Message"${Ue}.`,ze=_e?`${pe}: ${_e}`:pe,Xe=qGe(Te,{prompt:ze,systemPrompt:Ge,sessionId:Pe,mode:ke==="plan"?"plan":"default",additionalOptions:he??{},opencodeModel:fe});setTimeout(()=>{if(Y.current(Pe,Xe+"\r"),R(!1),re.current(Pe),x.current&&!g.current&&m.current){const Qe=()=>{const Fe=m.current;!g.current&&Fe&&(Fe.focus(),Fe.textarea===document.activeElement&&(g.current=!0))};setTimeout(Qe,50),setTimeout(Qe,200),setTimeout(Qe,500)}},We?5e3:100)},ye=ne.current(v,m.current,{onAttached:ce}),me=Z.current(d.current,v);return y.current=!0,jt.taskTerminal.debug("attachedRef set to true",{terminalId:v}),()=>{jt.taskTerminal.debug("cleanup running, setting attachedRef to false",{terminalId:v}),ye(),me(),y.current=!1}},[v,xe]),T.useEffect(()=>{m.current&&(m.current.options.theme=V)},[V]),T.useEffect(()=>{if(!p||g.current||!m.current||!v||C||A)return;const ce=[0,50,150,300,500],ye=[];return ce.forEach(me=>{const Pe=setTimeout(()=>{const Ie=m.current;!g.current&&Ie&&(Ie.focus(),Ie.textarea===document.activeElement&&(g.current=!0))},me);ye.push(Pe)}),()=>{ye.forEach(clearTimeout)}},[p,C,A,v]),T.useEffect(()=>{if(!m.current||D)return;const ce=m.current,ye=()=>{const Pe=ce.buffer.active;for(let Ie=Math.max(0,Pe.cursorY-3);Ie<=Pe.cursorY;Ie++){const We=Pe.getLine(Ie);if(We){const Te=We.translateToString(),he=GGe(Te,r);if(he){L(he);return}}}},me=ce.onLineFeed(ye);return()=>{me.dispose()}},[D,r]);const be=T.useCallback(ce=>{v&&Y.current(v,ce)},[v]);return t?f.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[!q&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:"Connecting to terminal server..."}),te==="error"&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-destructive/20 text-destructive text-xs",children:"Terminal failed to start. The worktree directory may not exist."}),te==="exited"&&f.jsxs("div",{className:"shrink-0 px-2 py-1 bg-muted text-muted-foreground text-xs",children:["Terminal exited (code: ",se?.exitCode,")"]}),f.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[f.jsx("div",{ref:d,className:Be("h-full w-full overflow-hidden p-2 bg-terminal-background",n)}),C&&!v&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-terminal-background",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:Be("animate-spin",P?"text-white/50":"text-black/50")}),f.jsx("span",{className:Be("font-mono text-sm",P?"text-white/50":"text-black/50"),children:"Initializing terminal..."})]})}),A&&f.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:Be("animate-spin",P?"text-white/60":"text-black/60")}),f.jsxs("span",{className:Be("font-mono text-sm",P?"text-white/60":"text-black/60"),children:["Starting ",Pl[r],"..."]})]})}),D&&f.jsx("div",{className:"pointer-events-none absolute bottom-4 left-4 right-4 z-10",children:f.jsxs("div",{className:Be("pointer-events-auto flex items-start gap-3 rounded-lg border p-4","bg-amber-500/10 border-amber-500/30"),children:[f.jsx(J,{icon:er,size:18,strokeWidth:2,className:"shrink-0 mt-0.5 text-amber-600 dark:text-amber-400"}),f.jsxs("div",{className:"flex-1 space-y-2",children:[f.jsxs("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[Pl[D]," CLI not found"]}),f.jsxs("p",{className:"text-xs text-amber-600/80 dark:text-amber-400/80",children:["Install it with:"," ",f.jsx("code",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 font-mono",children:gTe[D]})]}),f.jsx("a",{href:bTe[D],target:"_blank",rel:"noopener noreferrer",className:"inline-block text-xs font-medium text-amber-600 hover:text-amber-700 dark:text-amber-400 dark:hover:text-amber-300 underline",children:"View documentation"})]}),f.jsx("button",{onClick:()=>L(null),className:"shrink-0 p-1 rounded text-amber-600 hover:text-amber-700 hover:bg-amber-500/20 dark:text-amber-400 dark:hover:text-amber-300",children:f.jsx(J,{icon:Mr,size:14,strokeWidth:2})})]})}),f.jsx("button",{onClick:()=>m.current?.scrollToBottom(),className:Be("absolute top-2 right-5 p-1 transition-colors",P?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:f.jsx(J,{icon:Cne,size:20,strokeWidth:2})})]}),f.jsx(WS,{onSend:be})]}):f.jsx("div",{className:Be("flex h-full items-center justify-center text-muted-foreground text-sm bg-terminal-background",n),children:"No worktree path configured for this task"})}function KGe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}function YGe(e,t=[]){let n=[];function r(a,s){const o=T.createContext(s),l=n.length;n=[...n,s];const u=d=>{const{scope:m,children:g,...x}=d,_=m?.[e]?.[l]||o,b=T.useMemo(()=>x,Object.values(x));return f.jsx(_.Provider,{value:b,children:g})};u.displayName=a+"Provider";function p(d,m){const g=m?.[e]?.[l]||o,x=T.useContext(g);if(x)return x;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[u,p]}const i=()=>{const a=n.map(s=>T.createContext(s));return function(o){const l=o?.[e]||a;return T.useMemo(()=>({[`__scope${e}`]:{...o,[e]:l}}),[o,l])}};return i.scopeName=e,[r,XGe(i,...t)]}function XGe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const s=r.reduce((o,{useScope:l,scopeName:u})=>{const d=l(a)[`__scope${u}`];return{...o,...d}},{});return T.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}var d0=globalThis?.document?T.useLayoutEffect:()=>{},ZGe=iw[" useInsertionEffect ".trim().toString()]||d0;function QGe({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,a,s]=JGe({defaultProp:t,onChange:n}),o=e!==void 0,l=o?e:i;{const p=T.useRef(e!==void 0);T.useEffect(()=>{const d=p.current;d!==o&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=o},[o,r])}const u=T.useCallback(p=>{if(o){const d=eKe(p)?p(e):p;d!==e&&s.current?.(d)}else a(p)},[o,e,a,s]);return[l,u]}function JGe({defaultProp:e,onChange:t}){const[n,r]=T.useState(e),i=T.useRef(n),a=T.useRef(t);return ZGe(()=>{a.current=t},[t]),T.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function eKe(e){return typeof e=="function"}function sQ(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ace(...e){return t=>{let n=!1;const r=e.map(i=>{const a=sQ(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():sQ(e[i],null)}}}}function kce(...e){return T.useCallback(Ace(...e),e)}function tKe(e){const t=nKe(e),n=T.forwardRef((r,i)=>{const{children:a,...s}=r,o=T.Children.toArray(a),l=o.find(iKe);if(l){const u=l.props.children,p=o.map(d=>d===l?T.Children.count(u)>1?T.Children.only(null):T.isValidElement(u)?u.props.children:null:d);return f.jsx(t,{...s,ref:i,children:T.isValidElement(u)?T.cloneElement(u,void 0,p):null})}return f.jsx(t,{...s,ref:i,children:a})});return n.displayName=`${e}.Slot`,n}function nKe(e){const t=T.forwardRef((n,r)=>{const{children:i,...a}=n;if(T.isValidElement(i)){const s=sKe(i),o=aKe(a,i.props);return i.type!==T.Fragment&&(o.ref=r?Ace(r,s):s),T.cloneElement(i,o)}return T.Children.count(i)>1?T.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rKe=Symbol("radix.slottable");function iKe(e){return T.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rKe}function aKe(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...o)=>{const l=a(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function sKe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var oKe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],x5=oKe.reduce((e,t)=>{const n=tKe(`Primitive.${t}`),r=T.forwardRef((i,a)=>{const{asChild:s,...o}=i,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(l,{...o,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function lKe(e,t){return T.useReducer((n,r)=>t[n][r]??n,e)}var Oce=e=>{const{present:t,children:n}=e,r=uKe(t),i=typeof n=="function"?n({present:r.isPresent}):T.Children.only(n),a=kce(r.ref,cKe(i));return typeof n=="function"||r.isPresent?T.cloneElement(i,{ref:a}):null};Oce.displayName="Presence";function uKe(e){const[t,n]=T.useState(),r=T.useRef(null),i=T.useRef(e),a=T.useRef("none"),s=e?"mounted":"unmounted",[o,l]=lKe(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const u=T_(r.current);a.current=o==="mounted"?u:"none"},[o]),d0(()=>{const u=r.current,p=i.current;if(p!==e){const m=a.current,g=T_(u);e?l("MOUNT"):g==="none"||u?.display==="none"?l("UNMOUNT"):l(p&&m!==g?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),d0(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,d=g=>{const _=T_(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&_&&(l("ANIMATION_END"),!i.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=g=>{g.target===t&&(a.current=T_(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:T.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function T_(e){return e?.animationName||"none"}function cKe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var dKe=iw[" useId ".trim().toString()]||(()=>{}),fKe=0;function pKe(e){const[t,n]=T.useState(dKe());return d0(()=>{n(r=>r??String(fKe++))},[e]),e||(t?`radix-${t}`:"")}var FC="Collapsible",[hKe]=YGe(FC),[mKe,_5]=hKe(FC),Rce=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:s,...o}=e,[l,u]=QGe({prop:r,defaultProp:i??!1,onChange:s,caller:FC});return f.jsx(mKe,{scope:n,disabled:a,contentId:pKe(),open:l,onOpenToggle:T.useCallback(()=>u(p=>!p),[u]),children:f.jsx(x5.div,{"data-state":E5(l),"data-disabled":a?"":void 0,...o,ref:t})})});Rce.displayName=FC;var Nce="CollapsibleTrigger",Ice=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_5(Nce,n);return f.jsx(x5.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":E5(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:KGe(e.onClick,i.onOpenToggle)})});Ice.displayName=Nce;var S5="CollapsibleContent",Dce=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_5(S5,e.__scopeCollapsible);return f.jsx(Oce,{present:n||i.open,children:({present:a})=>f.jsx(gKe,{...r,ref:t,present:a})})});Dce.displayName=S5;var gKe=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...a}=e,s=_5(S5,n),[o,l]=T.useState(r),u=T.useRef(null),p=kce(t,u),d=T.useRef(0),m=d.current,g=T.useRef(0),x=g.current,_=s.open||o,b=T.useRef(_),y=T.useRef(void 0);return T.useEffect(()=>{const v=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(v)},[]),d0(()=>{const v=u.current;if(v){y.current=y.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const E=v.getBoundingClientRect();d.current=E.height,g.current=E.width,b.current||(v.style.transitionDuration=y.current.transitionDuration,v.style.animationName=y.current.animationName),l(r)}},[s.open,r]),f.jsx(x5.div,{"data-state":E5(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!_,...a,ref:p,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:_&&i})});function E5(e){return e?"open":"closed"}var bKe=Rce;const vKe=bKe,yKe=Ice,xKe=Dce;function _Ke(e){const{viewState:t,setDiffOptions:n}=v5(e),{collapsedFiles:r}=t.diffOptions,i=T.useCallback(l=>{const u=r.includes(l);n({collapsedFiles:u?r.filter(p=>p!==l):[...r,l]})},[r,n]),a=T.useCallback(l=>{n({collapsedFiles:l})},[n]),s=T.useCallback(()=>{n({collapsedFiles:[]})},[n]),o=T.useCallback(l=>r.includes(l),[r]);return{options:t.diffOptions,setOption:(l,u)=>{n({[l]:u})},setOptions:n,toggleFileCollapse:i,collapseAll:a,expandAll:s,isFileCollapsed:o}}function SKe(e){const t=[];let n=null,r=0,i=0;for(const a of e.split(`
|
|
124
124
|
`))if(a.startsWith("diff --git"))n={path:a.match(/diff --git a\/(.+?) b\//)?.[1]??"unknown",lines:[],additions:0,deletions:0},t.push(n),n.lines.push({type:"header",content:a});else if(a.startsWith("index ")||a.startsWith("---")||a.startsWith("+++"))n?.lines.push({type:"header",content:a});else if(a.startsWith("@@")){const s=a.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);s&&(r=parseInt(s[1],10),i=parseInt(s[2],10)),n?.lines.push({type:"hunk",content:a})}else a.startsWith("+")?n&&(n.additions++,n.lines.push({type:"added",content:a.slice(1),newLineNumber:i++})):a.startsWith("-")?n&&(n.deletions++,n.lines.push({type:"removed",content:a.slice(1),oldLineNumber:r++})):a.startsWith(" ")&&n?.lines.push({type:"context",content:a.slice(1),oldLineNumber:r++,newLineNumber:i++});return t}function EKe({file:e,wrap:t,isCollapsed:n,onToggle:r}){return f.jsxs(vKe,{open:!n,onOpenChange:()=>r(),children:[f.jsx(yKe,{asChild:!0,children:f.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 bg-card border-b border-border cursor-pointer hover:bg-muted select-none",children:[f.jsx(J,{icon:n?Mu:L0,size:12,strokeWidth:2,className:"text-muted-foreground shrink-0"}),f.jsx("span",{className:"font-mono text-xs text-foreground truncate flex-1",children:e.path}),f.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[e.additions>0&&f.jsxs("span",{className:"text-accent",children:["+",e.additions]}),e.additions>0&&e.deletions>0&&" ",e.deletions>0&&f.jsxs("span",{className:"text-destructive",children:["-",e.deletions]})]})]})}),f.jsx(xKe,{children:f.jsx("div",{className:"font-mono text-xs",children:e.lines.slice(1).map((i,a)=>f.jsxs("div",{className:Be("flex px-2 py-0.5",i.type==="added"&&"bg-accent/10",i.type==="removed"&&"bg-destructive/10",i.type==="header"&&"bg-muted/50 text-muted-foreground",i.type==="hunk"&&"bg-accent/10 text-accent"),children:[(i.type==="added"||i.type==="removed"||i.type==="context")&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.oldLineNumber??""}),f.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.newLineNumber??""})]}),f.jsxs("span",{className:Be("w-4 shrink-0 select-none text-center",i.type==="added"&&"text-accent",i.type==="removed"&&"text-destructive"),children:[i.type==="added"&&"+",i.type==="removed"&&"-"]}),f.jsx("span",{className:Be("flex-1",t?"whitespace-pre-wrap break-all":"whitespace-pre",i.type==="added"&&"text-accent",i.type==="removed"&&"text-destructive"),children:i.content})]},a))})})]})}function oQ({taskId:e,worktreePath:t,baseBranch:n}){const{options:r,setOption:i,toggleFileCollapse:a,collapseAll:s,expandAll:o,isFileCollapsed:l}=_Ke(e),{wrap:u,ignoreWhitespace:p,includeUntracked:d,collapsedFiles:m}=r,{data:g,isLoading:x,error:_}=ZCe(t,{ignoreWhitespace:p,includeUntracked:d,baseBranch:n}),b=T.useMemo(()=>g?.diff?SKe(g.diff):[],[g?.diff]),y=T.useMemo(()=>b.map(A=>A.path),[b]),v=b.length>0&&m.length===b.length,E=T.useMemo(()=>b.reduce((A,R)=>A+R.additions,0),[b]),C=T.useMemo(()=>b.reduce((A,R)=>A+R.deletions,0),[b]);if(T.useEffect(()=>{const A=R=>{if(R.shiftKey&&R.key==="C"&&!R.ctrlKey&&!R.metaKey&&!R.altKey){const O=R.target;if(O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.isContentEditable)return;R.preventDefault(),v?o():s(y)}};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[v,y,s,o]),!t)return f.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"No worktree selected"});if(x)return f.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading diff..."});if(_)return f.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:_.message});const w=g?.files?.some(A=>A.status==="untracked")??!1;return b.length===0?f.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-muted-foreground text-sm gap-2",children:[f.jsx("p",{children:"No changes detected"}),g?.files&&g.files.length>0&&f.jsxs("div",{className:"text-xs",children:[f.jsx("p",{className:"text-center mb-2",children:"Modified files:"}),f.jsxs("div",{className:"flex flex-col gap-1",children:[g.files.map(A=>f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("span",{className:Be("w-4 text-center",A.status==="added"&&"text-accent",A.status==="deleted"&&"text-destructive",A.status==="modified"&&"text-muted-foreground",A.status==="untracked"&&"text-muted-foreground"),children:[A.status==="added"&&"A",A.status==="deleted"&&"D",A.status==="modified"&&"M",A.status==="untracked"&&"?"]}),f.jsx("span",{children:A.path})]},A.path)),w&&f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-muted-foreground hover:text-foreground mt-1",children:[f.jsx("input",{type:"checkbox",checked:d,onChange:A=>i("includeUntracked",A.target.checked),className:"w-4 h-3"}),f.jsx("span",{children:"Show untracked files"})]})]})]})]}):f.jsxs("div",{className:"flex flex-col h-full bg-background",children:[f.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-card border-b border-border text-xs",children:[g?.branch&&f.jsxs("span",{className:"text-muted-foreground",children:[g.branch,g.isBranchDiff&&g.baseBranch&&f.jsxs("span",{className:"opacity-70",children:[" (vs ",g.baseBranch,")"]})]}),(E>0||C>0)&&f.jsxs("span",{className:"text-muted-foreground",children:[f.jsxs("span",{className:"text-accent",children:["+",E]})," ",f.jsxs("span",{className:"text-destructive",children:["-",C]})]}),f.jsx("div",{className:"flex-1"}),f.jsxs("button",{onClick:()=>v?o():s(y),className:"flex items-center gap-1 px-1.5 py-0.5 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:v?"Expand all (Shift+C)":"Collapse all (Shift+C)",children:[f.jsx(J,{icon:v?Mne:Dne,size:12,strokeWidth:2}),f.jsx("span",{className:"hidden sm:inline",children:v?"Expand":"Collapse"})]}),f.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[f.jsx("input",{type:"checkbox",checked:u,onChange:A=>i("wrap",A.target.checked),className:"w-3 h-3"}),"Wrap"]}),f.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[f.jsx("input",{type:"checkbox",checked:p,onChange:A=>i("ignoreWhitespace",A.target.checked),className:"w-3 h-3"}),"Ignore whitespace"]}),f.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[f.jsx("input",{type:"checkbox",checked:d,onChange:A=>i("includeUntracked",A.target.checked),className:"w-3 h-3"}),"Untracked"]})]}),f.jsx(Cg,{className:"flex-1 min-h-0",children:b.map(A=>f.jsx(EKe,{file:A,wrap:u,isCollapsed:l(A.path),onToggle:()=>a(A.path)},A.path))})]})}function wKe(e){const{viewState:t,setBrowserUrl:n}=v5(e);return{url:t.browserUrl,setUrl:n}}function lQ({taskId:e}){const{url:t,setUrl:n}=wKe(e),[r,i]=T.useState(t),[a,s]=T.useState(0);T.useEffect(()=>{i(t)},[t]);const o=T.useCallback(()=>{s(u=>u+1)},[]),l=T.useCallback(u=>{u.preventDefault();let p=r.trim();!p.startsWith("http://")&&!p.startsWith("https://")&&(p=`http://${p}`),n(p),s(d=>d+1)},[r,n]);return f.jsxs("div",{className:"flex h-full flex-col bg-background",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card px-2 py-1.5",children:[f.jsx(Ae,{variant:"ghost",size:"icon-xs",disabled:!0,children:f.jsx(J,{icon:qu,size:14,strokeWidth:2})}),f.jsx(Ae,{variant:"ghost",size:"icon-xs",disabled:!0,children:f.jsx(J,{icon:Mu,size:14,strokeWidth:2})}),f.jsx(Ae,{variant:"ghost",size:"icon-xs",onClick:o,children:f.jsx(J,{icon:Nw,size:14,strokeWidth:2})}),f.jsx("form",{onSubmit:l,className:"flex-1",children:f.jsx($t,{value:r,onChange:u=>i(u.target.value),className:"h-7 bg-background text-xs",placeholder:"Enter URL..."})})]}),f.jsx("div",{className:"flex-1 overflow-hidden bg-card",children:f.jsx("iframe",{src:t,className:"h-full w-full border-0",title:"Browser Preview",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},a)})]})}function CKe(e){const t=[];function n(r){for(const i of r)i.type==="file"?t.push({name:i.name,path:i.path}):i.children&&n(i.children)}return n(e),t}function Lce(e){const t=e.split(".").pop()?.toLowerCase()||"";return["png","jpg","jpeg","gif","svg","webp","ico"].includes(t)?I_e:["ts","tsx","js","jsx","json","css","html","md","yaml","yml","toml","sh","py","rs","go","sql"].includes(t)?C_e:k_e}function Pce({entry:e,depth:t,selectedFile:n,expandedDirs:r,onSelectFile:i,onToggleDir:a}){const s=r.includes(e.path),o=n===e.path,l=e.type==="directory",u=T.useCallback(()=>{l?a(e.path):i(e.path)},[l,e.path,i,a]);return f.jsxs("div",{children:[f.jsxs("div",{className:Be("flex items-center gap-1.5 px-2 py-0.5 cursor-pointer text-sm hover:bg-muted/50",o&&"bg-primary/10 text-primary"),style:{paddingLeft:`${t*12+8}px`},onClick:u,children:[f.jsx(J,{icon:l?s?PD:ua:Lce(e.name),size:14,strokeWidth:2,className:Be("shrink-0",l?"text-accent":"text-muted-foreground")}),f.jsx("span",{className:"break-all",children:e.name})]}),l&&s&&e.children&&f.jsx("div",{children:e.children.map(p=>f.jsx(Pce,{entry:p,depth:t+1,selectedFile:n,expandedDirs:r,onSelectFile:i,onToggleDir:a},p.path))})]})}function TKe({entries:e,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i,onCollapseAll:a}){const[s,o]=T.useState(""),l=T.useMemo(()=>CKe(e),[e]),u=T.useMemo(()=>{if(!s.trim())return null;const d=s.trim();return l.map(m=>({...m,score:Math.max(Ki(m.name,d),Ki(m.path,d))})).filter(m=>m.score>0).sort((m,g)=>g.score-m.score)},[l,s]),p=T.useCallback(()=>{o("")},[]);return e.length===0?f.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"No files"}):f.jsxs("div",{className:"flex flex-col h-full bg-background",children:[f.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1 border-b border-border bg-card",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"Files"}),f.jsx("button",{onClick:a,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Collapse all folders",children:f.jsx(J,{icon:Dne,size:14,strokeWidth:2})})]}),f.jsx("div",{className:"shrink-0 px-2 py-1.5 border-b border-border bg-card",children:f.jsxs("div",{className:"relative",children:[f.jsx("input",{type:"text",value:s,onChange:d=>o(d.target.value),placeholder:"Search files...",className:"w-full text-sm bg-muted/50 border border-border rounded px-2 py-1 pr-7 placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),s&&f.jsx("button",{onClick:p,className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-muted-foreground hover:text-foreground rounded hover:bg-muted",children:f.jsx(J,{icon:Mr,size:12,strokeWidth:2})})]})}),f.jsx("div",{className:"py-1 flex-1 overflow-auto",children:u?u.length>0?u.map(d=>f.jsxs("div",{className:Be("flex items-center gap-1.5 px-2 py-0.5 cursor-pointer text-sm hover:bg-muted/50",t===d.path&&"bg-primary/10 text-primary"),onClick:()=>r(d.path),children:[f.jsx(J,{icon:Lce(d.name),size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),f.jsx("span",{className:"truncate",title:d.path,children:d.name}),f.jsx("span",{className:"text-xs text-muted-foreground truncate ml-auto",children:d.path.split("/").slice(0,-1).join("/")})]},d.path)):f.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No matching files"}):e.map(d=>f.jsx(Pce,{entry:d,depth:0,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i},d.path))})]})}function uQ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function AKe(e){if(Array.isArray(e))return e}function kKe(e,t,n){return(t=PKe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function OKe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,s,o=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(p){u=!0,i=p}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return o}}function RKe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
125
125
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function dQ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?cQ(Object(n),!0).forEach(function(r){kKe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cQ(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function NKe(e,t){if(e==null)return{};var n,r,i=IKe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function IKe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function DKe(e,t){return AKe(e)||OKe(e,t)||MKe(e,t)||RKe()}function LKe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function PKe(e){var t=LKe(e,"string");return typeof t=="symbol"?t:t+""}function MKe(e,t){if(e){if(typeof e=="string")return uQ(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uQ(e,t):void 0}}function jKe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function pQ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?fQ(Object(n),!0).forEach(function(r){jKe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fQ(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function FKe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(i,a){return a(i)},r)}}function wv(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,o=new Array(s),l=0;l<s;l++)o[l]=arguments[l];return t.apply(n,[].concat(i,o))}}}function GE(e){return{}.toString.call(e).includes("Object")}function BKe(e){return!Object.keys(e).length}function f0(e){return typeof e=="function"}function UKe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $Ke(e,t){return GE(t)||_d("changeType"),Object.keys(t).some(function(n){return!UKe(e,n)})&&_d("changeField"),t}function zKe(e){f0(e)||_d("selectorType")}function HKe(e){f0(e)||GE(e)||_d("handlerType"),GE(e)&&Object.values(e).some(function(t){return!f0(t)})&&_d("handlersType")}function WKe(e){e||_d("initialIsRequired"),GE(e)||_d("initialType"),BKe(e)&&_d("initialContent")}function VKe(e,t){throw new Error(e[t]||e.default)}var qKe={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},_d=wv(VKe)(qKe),A_={changes:$Ke,selector:zKe,handler:HKe,initial:WKe};function GKe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};A_.initial(e),A_.handler(t);var n={current:e},r=wv(XKe)(n,t),i=wv(YKe)(n),a=wv(A_.changes)(e),s=wv(KKe)(n);function o(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(p){return p};return A_.selector(u),u(n.current)}function l(u){FKe(r,i,a,s)(u)}return[o,l]}function KKe(e,t){return f0(t)?t(e.current):t}function YKe(e,t){return e.current=pQ(pQ({},e.current),t),t}function XKe(e,t,n){return f0(t)?t(e.current):Object.keys(n).forEach(function(r){var i;return(i=t[r])===null||i===void 0?void 0:i.call(t,e.current[r])}),n}var ZKe={create:GKe},QKe={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function JKe(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,o=new Array(s),l=0;l<s;l++)o[l]=arguments[l];return t.apply(n,[].concat(i,o))}}}function eYe(e){return{}.toString.call(e).includes("Object")}function tYe(e){return e||hQ("configIsRequired"),eYe(e)||hQ("configType"),e.urls?(nYe(),{paths:{vs:e.urls.monacoBase}}):e}function nYe(){console.warn(Mce.deprecation)}function rYe(e,t){throw new Error(e[t]||e.default)}var Mce={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
126
126
|
You are using deprecated way of configuration.
|
|
@@ -173,7 +173,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
173
173
|
`))}function l(g,x,_,b){const y=_.enter("tableCell"),v=_.enter("phrasing"),E=_.containerPhrasing(g,{...b,before:a,after:a});return v(),y(),E}function u(g,x){return qat(g,{align:x,alignDelimiters:r,padding:n,stringLength:i})}function p(g,x,_){const b=g.children;let y=-1;const v=[],E=x.enter("table");for(;++y<b.length;)v[y]=d(b[y],x,_);return E(),v}function d(g,x,_){const b=g.children;let y=-1;const v=[],E=x.enter("tableRow");for(;++y<b.length;)v[y]=l(b[y],g,x,_);return E(),v}function m(g,x,_){let b=Yfe.inlineCode(g,x,_);return _.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function Dst(){return{exit:{taskListCheckValueChecked:VJ,taskListCheckValueUnchecked:VJ,paragraph:Pst}}}function Lst(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Mst}}}function VJ(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Pst(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let a=-1,s;for(;++a<i.length;){const o=i[a];if(o.type==="paragraph"){s=o;break}}s===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Mst(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",s="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);a&&o.move(s);let l=Yfe.listItem(e,t,n,{...r,...o.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(p){return p+s}}function jst(){return[mat(),Mat(),Uat(),Tst(),Dst()]}function Fst(e){return{extensions:[gat(),jat(e),$at(),Ist(e),Lst()]}}const Bst={tokenize:Vst,partial:!0},Xfe={tokenize:qst,partial:!0},Zfe={tokenize:Gst,partial:!0},Qfe={tokenize:Kst,partial:!0},Ust={tokenize:Yst,partial:!0},Jfe={name:"wwwAutolink",tokenize:Hst,previous:tpe},epe={name:"protocolAutolink",tokenize:Wst,previous:npe},bc={name:"emailAutolink",tokenize:zst,previous:rpe},Zl={};function $st(){return{text:Zl}}let yf=48;for(;yf<123;)Zl[yf]=bc,yf++,yf===58?yf=65:yf===91&&(yf=97);Zl[43]=bc;Zl[45]=bc;Zl[46]=bc;Zl[95]=bc;Zl[72]=[bc,epe];Zl[104]=[bc,epe];Zl[87]=[bc,Jfe];Zl[119]=[bc,Jfe];function zst(e,t,n){const r=this;let i,a;return s;function s(d){return!rM(d)||!rpe.call(r,r.previous)||DB(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return rM(d)?(e.consume(d),o):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(Ust,p,u)(d):d===45||d===95||la(d)?(a=!0,e.consume(d),l):p(d)}function u(d){return e.consume(d),i=!0,l}function p(d){return a&&i&&Ca(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function Hst(e,t,n){const r=this;return i;function i(s){return s!==87&&s!==119||!tpe.call(r,r.previous)||DB(r.events)?n(s):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Bst,e.attempt(Xfe,e.attempt(Zfe,a),n),n)(s))}function a(s){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(s)}}function Wst(e,t,n){const r=this;let i="",a=!1;return s;function s(d){return(d===72||d===104)&&npe.call(r,r.previous)&&!DB(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(Ca(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const m=i.toLowerCase();if(m==="http"||m==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),a?u:(a=!0,l)):n(d)}function u(d){return d===null||tw(d)||ur(d)||xp(d)||pT(d)?n(d):e.attempt(Xfe,e.attempt(Zfe,p),n)(d)}function p(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function Vst(e,t,n){let r=0;return i;function i(s){return(s===87||s===119)&&r<3?(r++,e.consume(s),i):s===46&&r===3?(e.consume(s),a):n(s)}function a(s){return s===null?n(s):t(s)}}function qst(e,t,n){let r,i,a;return s;function s(u){return u===46||u===95?e.check(Qfe,l,o)(u):u===null||ur(u)||xp(u)||u!==45&&pT(u)?l(u):(a=!0,e.consume(u),s)}function o(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),s}function l(u){return i||r||!a?n(u):t(u)}}function Gst(e,t){let n=0,r=0;return i;function i(s){return s===40?(n++,e.consume(s),i):s===41&&r<n?a(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?e.check(Qfe,t,a)(s):s===null||ur(s)||xp(s)?t(s):(e.consume(s),i)}function a(s){return s===41&&r++,e.consume(s),i}}function Kst(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||ur(o)||xp(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||ur(o)||xp(o)?t(o):r(o)}function a(o){return Ca(o)?s(o):n(o)}function s(o){return o===59?(e.consume(o),r):Ca(o)?(e.consume(o),s):n(o)}}function Yst(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return la(a)?n(a):t(a)}}function tpe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ur(e)}function npe(e){return!Ca(e)}function rpe(e){return!(e===47||rM(e))}function rM(e){return e===43||e===45||e===46||e===95||la(e)}function DB(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Xst={tokenize:iot,partial:!0};function Zst(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:tot,continuation:{tokenize:not},exit:rot}},text:{91:{name:"gfmFootnoteCall",tokenize:eot},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Qst,resolveTo:Jst}}}}function Qst(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){s=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!s||!s._balanced)return n(l);const u=zo(r.sliceSerialize({start:s.end,end:r.now()}));return u.codePointAt(0)!==94||!a.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Jst(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",s,t],["exit",s,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function eot(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,s;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(a>999||d===93&&!s||d===null||d===91||ur(d))return n(d);if(d===93){e.exit("chunkString");const m=e.exit("gfmFootnoteCallString");return i.includes(zo(r.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ur(d)||(s=!0),a++,e.consume(d),d===92?p:u}function p(d){return d===91||d===92||d===93?(e.consume(d),a++,u):u(d)}}function tot(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,s=0,o;return l;function l(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(x)}function p(x){if(s>999||x===93&&!o||x===null||x===91||ur(x))return n(x);if(x===93){e.exit("chunkString");const _=e.exit("gfmFootnoteDefinitionLabelString");return a=zo(r.sliceSerialize(_)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return ur(x)||(o=!0),s++,e.consume(x),x===92?d:p}function d(x){return x===91||x===92||x===93?(e.consume(x),s++,p):p(x)}function m(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),i.includes(a)||i.push(a),On(e,g,"gfmFootnoteDefinitionWhitespace")):n(x)}function g(x){return t(x)}}function not(e,t,n){return e.check(E1,t,e.attempt(Xst,t,n))}function rot(e){e.exit("gfmFootnoteDefinition")}function iot(e,t,n){const r=this;return On(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const s=r.events[r.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(a):n(a)}}function aot(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(s,o){let l=-1;for(;++l<s.length;)if(s[l][0]==="enter"&&s[l][1].type==="strikethroughSequenceTemporary"&&s[l][1]._close){let u=l;for(;u--;)if(s[u][0]==="exit"&&s[u][1].type==="strikethroughSequenceTemporary"&&s[u][1]._open&&s[l][1].end.offset-s[l][1].start.offset===s[u][1].end.offset-s[u][1].start.offset){s[l][1].type="strikethroughSequence",s[u][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},s[u][1].start),end:Object.assign({},s[l][1].end)},d={type:"strikethroughText",start:Object.assign({},s[u][1].end),end:Object.assign({},s[l][1].start)},m=[["enter",p,o],["enter",s[u][1],o],["exit",s[u][1],o],["enter",d,o]],g=o.parser.constructs.insideSpan.null;g&&Ps(m,m.length,0,hT(g,s.slice(u+1,l),o)),Ps(m,m.length,0,[["exit",d,o],["enter",s[l][1],o],["exit",s[l][1],o],["exit",p,o]]),Ps(s,u-1,l-u+3,m),l=u+m.length-2;break}}for(l=-1;++l<s.length;)s[l][1].type==="strikethroughSequenceTemporary"&&(s[l][1].type="data");return s}function a(s,o,l){const u=this.previous,p=this.events;let d=0;return m;function m(x){return u===126&&p[p.length-1][1].type!=="characterEscape"?l(x):(s.enter("strikethroughSequenceTemporary"),g(x))}function g(x){const _=fg(u);if(x===126)return d>1?l(x):(s.consume(x),d++,g);if(d<2&&!n)return l(x);const b=s.exit("strikethroughSequenceTemporary"),y=fg(x);return b._open=!y||y===2&&!!_,b._close=!_||_===2&&!!y,o(x)}}}class sot{constructor(){this.map=[]}add(t,n,r){oot(this,t,n,r)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function oot(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function lot(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function uot(){return{flow:{null:{name:"table",tokenize:cot,resolveAll:dot}}}}function cot(e,t,n){const r=this;let i=0,a=0,s;return o;function o(D){let L=r.events.length-1;for(;L>-1;){const V=r.events[L][1].type;if(V==="lineEnding"||V==="linePrefix")L--;else break}const z=L>-1?r.events[L][1].type:null,P=z==="tableHead"||z==="tableRow"?A:l;return P===A&&r.parser.lazy[r.now().line]?n(D):P(D)}function l(D){return e.enter("tableHead"),e.enter("tableRow"),u(D)}function u(D){return D===124||(s=!0,a+=1),p(D)}function p(D){return D===null?n(D):zt(D)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),g):n(D):_n(D)?On(e,p,"whitespace")(D):(a+=1,s&&(s=!1,i+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),s=!0,p):(e.enter("data"),d(D)))}function d(D){return D===null||D===124||ur(D)?(e.exit("data"),p(D)):(e.consume(D),D===92?m:d)}function m(D){return D===92||D===124?(e.consume(D),d):d(D)}function g(D){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(D):(e.enter("tableDelimiterRow"),s=!1,_n(D)?On(e,x,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):x(D))}function x(D){return D===45||D===58?b(D):D===124?(s=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),_):w(D)}function _(D){return _n(D)?On(e,b,"whitespace")(D):b(D)}function b(D){return D===58?(a+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),y):D===45?(a+=1,y(D)):D===null||zt(D)?C(D):w(D)}function y(D){return D===45?(e.enter("tableDelimiterFiller"),v(D)):w(D)}function v(D){return D===45?(e.consume(D),v):D===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(D))}function E(D){return _n(D)?On(e,C,"whitespace")(D):C(D)}function C(D){return D===124?x(D):D===null||zt(D)?!s||i!==a?w(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(D)):w(D)}function w(D){return n(D)}function A(D){return e.enter("tableRow"),R(D)}function R(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),R):D===null||zt(D)?(e.exit("tableRow"),t(D)):_n(D)?On(e,R,"whitespace")(D):(e.enter("data"),O(D))}function O(D){return D===null||D===124||ur(D)?(e.exit("data"),R(D)):(e.consume(D),D===92?N:O)}function N(D){return D===92||D===124?(e.consume(D),O):O(D)}}function dot(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,l=0,u,p,d;const m=new sot;for(;++n<e.length;){const g=e[n],x=g[1];g[0]==="enter"?x.type==="tableHead"?(o=!1,l!==0&&(qJ(m,t,l,u,p),p=void 0,l=0),u={type:"table",start:Object.assign({},x.start),end:Object.assign({},x.end)},m.add(n,0,[["enter",u,t]])):x.type==="tableRow"||x.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],s=[0,n+1,0,0],o&&(o=!1,p={type:"tableBody",start:Object.assign({},x.start),end:Object.assign({},x.end)},m.add(n,0,[["enter",p,t]])),i=x.type==="tableDelimiterRow"?2:p?3:1):i&&(x.type==="data"||x.type==="tableDelimiterMarker"||x.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],d=j_(m,t,a,i,void 0,d),a=[0,0,0,0]),s[2]=n)):x.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],d=j_(m,t,a,i,void 0,d)),a=s,s=[a[1],n,0,0])):x.type==="tableHead"?(o=!0,l=n):x.type==="tableRow"||x.type==="tableDelimiterRow"?(l=n,a[1]!==0?(s[0]=s[1],d=j_(m,t,a,i,n,d)):s[1]!==0&&(d=j_(m,t,s,i,n,d)),i=0):i&&(x.type==="data"||x.type==="tableDelimiterMarker"||x.type==="tableDelimiterFiller")&&(s[3]=n)}for(l!==0&&qJ(m,t,l,u,p),m.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=lot(t.events,n))}return e}function j_(e,t,n,r,i,a){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(a.end=Object.assign({},Fh(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=Fh(t.events,n[1]);if(a={type:s,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const u=Fh(t.events,n[2]),p=Fh(t.events,n[3]),d={type:o,start:Object.assign({},u),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const m=t.events[n[2]],g=t.events[n[3]];if(m[1].end=Object.assign({},g[1].end),m[1].type="chunkText",m[1].contentType="text",n[3]>n[2]+1){const x=n[2]+1,_=n[3]-n[2]-1;e.add(x,_,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(a.end=Object.assign({},Fh(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function qJ(e,t,n,r,i){const a=[],s=Fh(t.events,n);i&&(i.end=Object.assign({},s),a.push(["exit",i,t])),r.end=Object.assign({},s),a.push(["exit",r,t]),e.add(n+1,0,a)}function Fh(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const fot={name:"tasklistCheck",tokenize:hot};function pot(){return{text:{91:fot}}}function hot(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),a)}function a(l){return ur(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),s):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),s):n(l)}function s(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return zt(l)?t(l):_n(l)?e.check({tokenize:mot},t,n)(l):n(l)}}function mot(e,t,n){return On(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function got(e){return yfe([$st(),Zst(),aot(e),uot(),pot()])}const bot={};function vot(e){const t=this,n=e||bot,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(got(n)),a.push(jst()),s.push(Fst(n))}const yot=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/i,xot=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)(\/.*)?\]/i,_ot=({legacyTitle:e=!1,tagName:t="div"}={})=>n=>{Ma(n,"blockquote",(r,i,a)=>{let s="",o="",l=!0,u=r.children.map(p=>{if(l&&p.type==="paragraph"){const d=p.children[0],m=d.type==="text"?d.value:"",g=e?xot:yot,x=m.match(g);if(x&&(l=!1,s=x[1].toLocaleLowerCase(),o=e&&x[2]||s.toLocaleUpperCase(),m.includes(`
|
|
174
174
|
`)&&(p.children[0]={type:"text",value:m.replace(g,"").replace(/^\n+/,"")}),!m.includes(`
|
|
175
175
|
`))){const _=[];p.children.forEach((b,y)=>{y!=0&&(y==1&&b.type==="break"||_.push(b))}),p.children=[..._]}}return p});s&&(r.data={hName:t,hProperties:{class:`markdown-alert markdown-alert-${s}`,dir:"auto"}},u.unshift({type:"paragraph",children:[Sot(s),{type:"text",value:o.replace(/^\//,"")}],data:{hProperties:{class:"markdown-alert-title",dir:"auto"}}})),r.children=[...u]})};function Sot(e){let t=Eot[e]??"";return{type:"emphasis",data:{hName:"svg",hProperties:{class:"octicon",viewBox:"0 0 16 16",width:"16",height:"16",ariaHidden:"true"}},children:[{type:"emphasis",data:{hName:"path",hProperties:{d:t}},children:[]}]}}const Eot={note:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z",tip:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z",important:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",warning:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",caution:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"};function wot(e,t){if(typeof document>"u")return;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style={position:"absolute",left:"-9999px"},document.body.appendChild(n);const r=document.getSelection().rangeCount>0?document.getSelection().getRangeAt(0):!1;n.select();let i=!1;try{i=!!document.execCommand("copy")}catch{i=!1}document.body.removeChild(n),r&&document.getSelection&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(r)),t&&t(i)}function ipe(e){if(!e)return null;var t=e;return t.dataset.code&&t.classList.contains("copied")?t:t.parentElement?ipe(t.parentElement):null}function Cot(e){var t=n=>{var r=ipe(n.target);r&&(r.classList.add("active"),wot(r.dataset.code,function(){setTimeout(()=>{r.classList.remove("active")},2e3)}))};T.useEffect(()=>{var n,r;return(n=e.current)==null||n.removeEventListener("click",t,!1),(r=e.current)==null||r.addEventListener("click",t,!1),()=>{var i;(i=e.current)==null||i.removeEventListener("click",t,!1)}},[e])}var Tot=["prefixCls","className","source","style","disableCopy","skipHtml","onScroll","onMouseOver","pluginsFilter","rehypeRewrite","wrapperElement","warpperElement","urlTransform"],Aot=e=>e;const kot=le.forwardRef((e,t)=>{var{prefixCls:n="wmde-markdown wmde-markdown-color",className:r,source:i,style:a,disableCopy:s=!1,skipHtml:o=!0,onScroll:l,onMouseOver:u,pluginsFilter:p,wrapperElement:d={},warpperElement:m={},urlTransform:g}=e,x=o$e(e,Tot),_=le.useRef(null);T.useImperativeHandle(t,()=>Du({},e,{mdp:_}),[_,e]);var b=(n||"")+" "+(r||"");Cot(_);var y=[...x.rehypePlugins||[]],v={allowElement:(w,A,R)=>x.allowElement?x.allowElement(w,A,R):/^[A-Za-z0-9]+$/.test(w.tagName)};o||y.push(pfe);var E=[_ot,...x.remarkPlugins||[],vot],C=Du({},m,d);return f.jsx("div",Du({ref:_,onScroll:l,onMouseOver:u},C,{className:b,style:a,children:f.jsx(lat,Du({},v,x,{skipHtml:!o,urlTransform:g||Aot,rehypePlugins:p?p("rehype",y):y,remarkPlugins:p?p("remark",E):E,children:i||""}))}))});var Oot=function(t){return n=>{Ma(n,r=>{r.type==="element"&&r.tagName==="code"&&r.data&&r.data.meta&&(r.properties=Du({},r.properties,{"data-meta":String(r.data.meta)}))})}},Rot=function(t){return n=>{Ma(n,r=>{if(r.type==="element"&&r.tagName==="code"&&r.properties&&r.properties.dataMeta){r.data||(r.data={});var i=r.properties.dataMeta;typeof i=="string"&&(r.data.meta=i),delete r.properties.dataMeta}})}};const Not=/[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g,Iot=Object.hasOwnProperty;class Dot{constructor(){this.occurrences,this.reset()}slug(t,n){const r=this;let i=Lot(t,n===!0);const a=i;for(;Iot.call(r.occurrences,i);)r.occurrences[a]++,i=a+"-"+r.occurrences[a];return r.occurrences[i]=0,i}reset(){this.occurrences=Object.create(null)}}function Lot(e,t){return typeof e!="string"?"":(t||(e=e.toLowerCase()),e.replace(Not,"").replace(/ /g,"-"))}function ape(e){const t=e.type==="element"?e.tagName.toLowerCase():"",n=t.length===2&&t.charCodeAt(0)===104?t.charCodeAt(1):0;return n>48&&n<55?n-48:void 0}const Pot={},GJ=new Dot;function Mot(e){const n=(e||Pot).prefix||"";return function(r){GJ.reset(),Ma(r,"element",function(i){ape(i)&&!i.properties.id&&(i.properties.id=n+GJ.slug(Zh(i)))})}}const spe=(function(e){if(e==null)return Bot;if(typeof e=="string")return Fot(e);if(typeof e=="object")return jot(e);if(typeof e=="function")return LB(e);throw new Error("Expected function, string, or array as `test`")});function jot(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=spe(e[n]);return LB(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function Fot(e){return LB(t);function t(n){return n.tagName===e}}function LB(e){return t;function t(n,r,i){return!!(Uot(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Bot(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function Uot(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const KJ={type:"element",tagName:"span",properties:{className:["icon","icon-link"]},children:[]},$ot={};function zot(e){const t=e||$ot;let n=t.properties;const r=t.headingProperties,i=t.behavior||"prepend",a=t.content,s=t.group,o=spe(t.test);let l;return i==="after"||i==="before"?l=p:i==="wrap"?l=d:(l=u,n||(n={ariaHidden:"true",tabIndex:-1})),function(m){Ma(m,"element",function(g,x,_){if(ape(g)&&g.properties.id&&o(g,x,_))return Object.assign(g.properties,F_(r,g)),l(g,x,_)})};function u(m){const g=YJ(a||KJ,m);return m.children[i==="prepend"?"unshift":"push"](tD(m,F_(n,m),g)),[Wv]}function p(m,g,x){if(typeof g!="number"||!x)return;const _=YJ(a||KJ,m),b=tD(m,F_(n,m),_);let y=i==="before"?[b,m]:[m,b];if(s){const v=ope(s,m);v&&!Array.isArray(v)&&v.type==="element"&&(v.children=y,y=[v])}return x.children.splice(g,1,...y),[Wv,g+y.length]}function d(m){let g=m.children,x=[];return typeof a=="function"?(g=[],x=a(m)):a&&(x=PB(a)),m.children=[tD(m,F_(n,m),Array.isArray(x)?[...g,...x]:[...g,x])],[Wv]}}function PB(e){return yp(e)}function tD(e,t,n){return{type:"element",tagName:"a",properties:{...t,href:"#"+e.properties.id},children:n}}function YJ(e,t){const n=ope(e,t);return Array.isArray(n)?n:[n]}function ope(e,t){return typeof e=="function"?e(t):PB(e)}function F_(e,t){return typeof e=="function"?e(t):e?PB(e):{}}const Hot=(e={})=>{const{openDelimiter:t="rehype:ignore:start",closeDelimiter:n="rehype:ignore:end"}=e;return r=>{Ma(r,(i,a,s)=>{if(i.type==="element"||i.type==="root"){let o=!1;i.children=i.children.filter(l=>{if(l.type==="raw"||l.type==="comment"){let u=(l.value||"").trim();if(u=u.replace(/^<!--(.*?)-->/,"$1"),u===t)return o=!0,!1;if(u===n)return o=!1,!1}return!o})}})}};var Wot={type:"element",tagName:"svg",properties:{className:"octicon octicon-link",viewBox:"0 0 16 16",version:"1.1",width:"16",height:"16",ariaHidden:"true"},children:[{type:"element",tagName:"path",children:[],properties:{fillRule:"evenodd",d:"M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"}}]};function Vot(e){return e===void 0&&(e=""),{type:"element",tagName:"div",properties:{class:"copied","data-code":e},children:[{type:"element",tagName:"svg",properties:{className:"octicon-copy",ariaHidden:"true",viewBox:"0 0 16 16",fill:"currentColor",height:12,width:12},children:[{type:"element",tagName:"path",properties:{fillRule:"evenodd",d:"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"},children:[]},{type:"element",tagName:"path",properties:{fillRule:"evenodd",d:"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"},children:[]}]},{type:"element",tagName:"svg",properties:{className:"octicon-check",ariaHidden:"true",viewBox:"0 0 16 16",fill:"currentColor",height:12,width:12},children:[{type:"element",tagName:"path",properties:{fillRule:"evenodd",d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"},children:[]}]}]}}var qot=(e,t)=>(n,r,i)=>{if(n.type==="element"&&i&&i.type==="root"&&/h(1|2|3|4|5|6)/.test(n.tagName)){var a=n.children&&n.children[0];a&&a.properties&&a.properties.ariaHidden==="true"&&(a.properties=Du({class:"anchor"},a.properties),a.children=[Wot])}if(n.type==="element"&&n.tagName==="pre"&&!e){var s=Tde(n.children);n.children.push(Vot(s))}t&&t(n,r===null?void 0:r,i===null?void 0:i)},Got=[Mot,zot,Hot];const Kot=le.forwardRef((e,t)=>{var n,r=[Oot,pfe,Rot,...Got,[rQe,{rewrite:qot((n=e.disableCopy)!=null?n:!1,e.rehypeRewrite)}],[sQe,{properties:"attr"}],...e.rehypePlugins||[],[DXe,{ignoreMissing:!0}]];return f.jsx(kot,Du({},e,{rehypePlugins:r,ref:t}))});function Yot(e,t){if(e.startsWith("/")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:"))return e;const n=t.includes("/")?t.substring(0,t.lastIndexOf("/")):"",r=n?n.split("/"):[],i=e.split("/");for(const a of i)a===".."?r.pop():a!=="."&&r.push(a);return r.join("/")}function Xot(e,t,n){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("/api/"))return e;const r=Yot(e,n);return`/api/fs/image?${new URLSearchParams({path:r,root:t})}`}function Zot({content:e,worktreePath:t,filePath:n}){const{resolvedTheme:r}=_p(),i=T.useMemo(()=>({img:({src:a,alt:s,...o})=>{if(!a)return null;const l=Xot(a,t,n);return f.jsx("img",{src:l,alt:s||"",loading:"lazy",style:{maxWidth:"100%"},...o})},a:({href:a,children:s,...o})=>f.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...o,children:s})}),[t,n]);return f.jsx(Cg,{className:"h-full",children:f.jsx("div",{className:"p-4","data-color-mode":r==="light"?"light":"dark",children:f.jsx(Kot,{source:e,style:{backgroundColor:"transparent",fontSize:"14px"},components:i})})})}const Qot=1e3,Jot=Np(function({onBack:t}){const{worktreePath:n,readOnly:r,selectedFile:i,currentFile:a,isLoading:s,isSaving:o,loadError:l,isDirty:u,updateContent:p,saveFile:d,closeFile:m,toggleMarkdownView:g}=$ae(),x=T.useRef(null);T.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const _=T.useCallback(w=>{!i||r||(p(i,w),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{d(i).catch(A=>{console.error("Auto-save failed:",A)})},Qot))},[i,r,p,d]),b=T.useCallback(()=>{i&&(x.current&&(clearTimeout(x.current),x.current=null),m(i)),t?.()},[i,m,t]),y=T.useCallback(()=>{i&&g(i)},[i,g]);if(!i)return f.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Select a file to view"});if(s)return f.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading file..."});if(l)return f.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:l});if(!a)return f.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Unable to load file"});if(a.isBinary)return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-muted-foreground text-sm gap-2",children:[f.jsx("p",{children:"Binary file"}),f.jsxs("p",{className:"text-xs",children:[(a.size/1024).toFixed(1)," KB"]})]});if(a.isImage)return f.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[f.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1.5 bg-card border-b border-border text-xs",children:[f.jsx("span",{className:"text-muted-foreground truncate",title:i,children:i.split("/").pop()||i}),f.jsx("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Close file",children:f.jsx(J,{icon:Mr,size:14,strokeWidth:2})})]}),f.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted",children:f.jsx("img",{src:a.content,alt:i,className:"block mx-auto"})})]});const v=i.split("/").pop()||i,E=a.isMarkdown,C=E&&a.isMarkdownView;return f.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-3 px-2 py-1.5 bg-card border-b border-border text-xs",children:[f.jsxs("span",{className:"text-muted-foreground truncate flex-1 flex items-center gap-1",title:i,children:[v,!r&&u&&f.jsx("span",{className:"text-amber-500",children:"*"}),!r&&o&&f.jsx("span",{className:"text-muted-foreground italic",children:"(saving...)"})]}),a.truncated&&f.jsxs("span",{className:"text-destructive",children:["Truncated (",a.lineCount.toLocaleString()," lines)"]}),f.jsxs("span",{className:"text-muted-foreground",children:[(a.size/1024).toFixed(1)," KB"]}),E&&f.jsx("button",{onClick:y,className:Be("p-1 rounded hover:bg-muted/50 transition-colors",C?"text-primary":"text-muted-foreground hover:text-foreground"),title:C?"Show code":"Preview markdown",children:f.jsx(J,{icon:C?U_e:$_e,size:14,strokeWidth:2})}),f.jsx("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Close file",children:f.jsx(J,{icon:Mr,size:14,strokeWidth:2})})]}),f.jsx("div",{className:"flex-1 min-h-0",children:C?f.jsx(Zot,{content:a.content,worktreePath:n||"",filePath:i}):f.jsx(Hce,{filePath:i,content:a.content,onChange:_,readOnly:r||!a.isEditable})})]})}),lpe=T.createContext(void 0),elt=Np(function(){const t=T.useContext(lpe),{selectedFile:n,expandedDirs:r,fileTree:i,isLoadingTree:a,treeError:s,selectFile:o,loadFile:l,toggleDir:u,collapseAll:p}=$ae(),d=T.useCallback(x=>{o(x),l(x),t?.(x)},[o,l,t]),m=T.useCallback(x=>{u(x)},[u]),g=T.useCallback(()=>{o(null),t?.(null)},[o,t]);return a?f.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading files..."}):s?f.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:s}):n?f.jsx("div",{className:"flex h-full flex-col bg-background",children:f.jsx(Jot,{onBack:g})}):f.jsx(TKe,{entries:i||[],selectedFile:n,expandedDirs:r,onSelectFile:d,onToggleDir:m,onCollapseAll:p})});function rw({worktreePath:e,readOnly:t=!1,initialSelectedFile:n,onFileChange:r}){const i=DIe(e,t,n);return e?f.jsx(Uae.Provider,{value:i,children:f.jsx(lpe.Provider,{value:r,children:f.jsx(elt,{})})}):f.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"No worktree selected"})}const iM=Di("/tasks/$taskId")({component:tlt,validateSearch:e=>({tab:["diff","browser","files"].includes(e.tab)?e.tab:void 0,file:typeof e.file=="string"?e.file:void 0})}),B_={IN_PROGRESS:"In Progress",IN_REVIEW:"In Review",DONE:"Done",CANCELED:"Canceled"},XJ={IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function tlt(){const{t:e}=wt("common"),{taskId:t}=iM.useParams(),n=iM.useSearch(),r=Br(),i=abe(),{data:a,isLoading:s}=nie(t),o=Bw(),l=Uw(),{viewState:u,setActiveTab:p,setFilesViewState:d}=v5(t),m=tj(),g=nj(),x=rj(),_=ij(),b=aj(),y=sj(),{data:v}=B0(),{data:E}=U0(),{data:C}=$0(),{data:w}=iie(),{data:A}=k3(),{data:R}=$Ge(a?.linearTicketId??null),{data:O=[]}=wg(),N=O.find(ze=>ze.path===a?.repoPath),D=a?.opencodeModel??N?.opencodeModel??A,L=i.state,z=a?.aiMode??L?.aiMode,P=a?.description??L?.description,V=T.useRef(void 0);V.current===void 0&&L?.focusTerminal!==void 0&&(V.current=L.focusTerminal);const H=V.current??!1,[j,G]=T.useState(!1),[q,B]=T.useState(!1),[F,U]=T.useState(!0),[K,W]=T.useState("terminal"),[ee,oe]=T.useState(0),[ne,Z]=T.useState(null),Y=tC(),Q=n.tab??u.activeTab,re=n.file??u.filesViewState.selectedFile,se=T.useRef(null);T.useEffect(()=>{se.current===t||n.tab||(se.current=t,u.activeTab&&r({to:"/tasks/$taskId",params:{taskId:t},search:{tab:u.activeTab==="diff"?void 0:u.activeTab,file:u.filesViewState.selectedFile||void 0},replace:!0}))},[t,n.tab,u.activeTab,u.filesViewState.selectedFile,r]);const te=T.useCallback(ze=>{const Xe=ze;p(Xe),r({to:"/tasks/$taskId",params:{taskId:t},search:{tab:Xe==="diff"?void 0:Xe,file:Xe==="files"&&re||void 0},replace:!0})},[t,r,p,re]),xe=T.useCallback(ze=>{d({selectedFile:ze}),r({to:"/tasks/$taskId",params:{taskId:t},search:{tab:"files",file:ze||void 0},replace:!0})},[t,r,d]),{terminals:be,sendInputToTerminal:ce,destroyTerminal:ye}=y5(),me=Rp(),Pe=be.find(ze=>a?.worktreePath&&ze.cwd.startsWith(a.worktreePath));T.useEffect(()=>ne?Rm(()=>me.terminals.items.some(Xe=>Xe.id===ne),Xe=>{Xe||(Z(null),oe(Qe=>Qe+1))},{fireImmediately:!0}):void 0,[ne,me]);const Ie=()=>{if(!a?.worktreePath)return;const ze=me.terminals.items.find(Xe=>Xe.cwd.startsWith(a.worktreePath));ze?(Z(ze.id),ye(ze.id,{force:!0,reason:"retry"})):oe(Xe=>Xe+1)},We=ze=>{Pe?(ce(Pe.id,ze),_t.info(e("git.sentToClaude"))):_t.error(e("git.noTerminal"))},Te=async()=>{if(!(!a?.repoPath||!a?.worktreePath))try{await m.mutateAsync({repoPath:a.repoPath,worktreePath:a.worktreePath,baseBranch:a.baseBranch}),_t.success(e("git.syncedFromMain"))}catch(ze){const Xe=ze instanceof Error?ze.message:"Sync failed",Qe=a.baseBranch||"main";_t.error(Xe,{action:Pe?{label:"Resolve with Claude",onClick:()=>We(`Rebase this worktree onto the parent repo's ${Qe} branch. Error: "${Xe}". Steps: 1) Check for uncommitted changes - stash or commit them first, 2) git fetch origin (in parent repo at ${a.repoPath}) to ensure ${Qe} is current, 3) git rebase ${Qe} (in worktree), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) If stashed, git stash pop. Worktree: ${a.worktreePath}, Parent repo: ${a.repoPath}.`)}:void 0})}},he=async()=>{if(!(!a?.repoPath||!a?.worktreePath))try{await g.mutateAsync({repoPath:a.repoPath,worktreePath:a.worktreePath,baseBranch:a.baseBranch}),_t.success(e("git.mergedToMain")),y.mutate(a.id),o.mutate({taskId:a.id,updates:{status:"DONE"}})}catch(ze){const Xe=ze instanceof Error?ze.message:"Merge failed",Qe=a.baseBranch||"main";_t.error(Xe,{action:Pe?{label:"Resolve with Claude",onClick:()=>We(`Merge this worktree's branch into the parent repo's ${Qe}. Error: "${Xe}". Steps: 1) Ensure all changes in worktree are committed, 2) In parent repo at ${a.repoPath}, checkout ${Qe} and pull latest from origin, 3) Squash merge the worktree branch into ${Qe} (use git merge --squash, then commit), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Push ${Qe} to origin. Worktree: ${a.worktreePath}, Parent repo: ${a.repoPath}.`)}:void 0})}},fe=async()=>{if(a?.worktreePath)try{await x.mutateAsync({worktreePath:a.worktreePath}),_t.success(e("git.pushedToOrigin"))}catch(ze){const Xe=ze instanceof Error?ze.message:"Push failed";_t.error(Xe,{action:Pe?{label:"Resolve with Claude",onClick:()=>We(`Push this worktree's branch to origin. Error: "${Xe}". Steps: 1) Check for uncommitted changes and commit them, 2) If push is rejected, pull the latest changes first and resolve any conflicts, 3) Push to origin again. Worktree: ${a.worktreePath}.`)}:void 0})}},ke=async()=>{if(a?.repoPath)try{await _.mutateAsync({repoPath:a.repoPath,baseBranch:a.baseBranch}),_t.success(e("git.parentSynced"))}catch(ze){const Xe=ze instanceof Error?ze.message:"Sync parent failed",Qe=a.baseBranch||"main";_t.error(Xe,{action:Pe?{label:"Resolve with Claude",onClick:()=>We(`Sync the parent repo's ${Qe} branch with origin. Error: "${Xe}". Steps: 1) git fetch origin, 2) git pull origin ${Qe} --ff-only, 3) If that fails, rebase with git rebase origin/${Qe}, 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Once in sync, git push origin ${Qe}. Work in the parent repo at ${a.repoPath}, not the worktree.`)}:void 0})}},_e=()=>{Pe&&ce(Pe.id,"commit")},pe=async()=>{if(a?.worktreePath)try{const ze=await b.mutateAsync({worktreePath:a.worktreePath,title:a.title,baseBranch:a.baseBranch});o.mutate({taskId:a.id,updates:{prUrl:ze.prUrl}}),_t.success(e("git.prCreated"),{action:{label:"View PR",onClick:()=>Al(ze.prUrl)}})}catch(ze){const Xe=ze instanceof Error?ze.message:"Failed to create PR",Qe=ze&&typeof ze=="object"&&"existingPrUrl"in ze?ze.existingPrUrl:void 0;if(Qe){o.mutate({taskId:a.id,updates:{prUrl:Qe}}),_t.info(e("git.prExists"),{action:{label:"View PR",onClick:()=>Al(Qe)}});return}const Fe=Xe.split(`
|
|
176
|
-
`).filter(Boolean).pop()||Xe;_t.error(Fe,{action:{label:"Resolve with Claude",onClick:()=>We(`Create a PR for this task. Error: "${Xe}". After creating, link it using: vibora current-task pr <url>. Worktree: ${a.worktreePath}.`)}})}},Oe=()=>{if(!a?.worktreePath)return;const ze=eC(a.worktreePath,v,E,C);Al(ze)},Se=ze=>{a&&o.mutate({taskId:a.id,updates:{status:ze}})},Ue=()=>{a&&l.mutate({taskId:a.id,deleteLinkedWorktree:F},{onSuccess:()=>{r({to:"/tasks"})}})},Ge=ze=>{B(ze),ze||U(!1)};return s?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx("p",{className:"text-muted-foreground",children:"Loading task..."})}):a?f.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f.jsxs("div",{className:"shrink-0 border-b border-border bg-background px-4 py-2",children:[f.jsxs("div",{className:"flex flex-col gap-1 sm:hidden",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:a.title}),f.jsxs(am,{children:[f.jsx(sm,{render:f.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${XJ[a.status]}`}),children:B_[a.status]}),f.jsx(om,{align:"end",children:f.jsx(TW,{value:a.status,onValueChange:Se,children:Object.entries(B_).map(([ze,Xe])=>f.jsx(AW,{value:ze,children:Xe},ze))})})]}),f.jsxs(am,{children:[f.jsx(sm,{render:f.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),children:f.jsx(J,{icon:Lne,size:16,strokeWidth:2})}),f.jsxs(om,{align:"end",children:[f.jsxs(Tr,{onClick:Te,disabled:m.isPending||!a.worktreePath,children:[f.jsx(J,{icon:dy,size:14,strokeWidth:2}),"Pull from ",a.baseBranch]}),f.jsxs(Tr,{onClick:he,disabled:g.isPending||!a.worktreePath,children:[f.jsx(J,{icon:cy,size:14,strokeWidth:2}),"Merge to ",a.baseBranch]}),f.jsxs(Tr,{onClick:fe,disabled:x.isPending||!a.worktreePath,children:[f.jsx(J,{icon:fy,size:14,strokeWidth:2}),"Push to origin"]}),f.jsxs(Tr,{onClick:ke,disabled:_.isPending||!a.repoPath,children:[f.jsx(J,{icon:hy,size:14,strokeWidth:2}),"Sync parent"]}),f.jsxs(Tr,{onClick:_e,disabled:!Pe,children:[f.jsx(J,{icon:py,size:14,strokeWidth:2}),"Commit"]}),!a.prUrl&&f.jsxs(Tr,{onClick:pe,disabled:b.isPending,children:[f.jsx(J,{icon:ju,size:14,strokeWidth:2,className:b.isPending?"animate-pulse":""}),"Create PR"]})]})]}),f.jsxs(Oa,{open:q,onOpenChange:Ge,children:[f.jsx(Ju,{render:f.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive"}),children:f.jsx(J,{icon:rs,size:16,strokeWidth:2})}),f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsxs(La,{children:['This will permanently delete "',a.title,'" and close its terminal.',F&&a.worktreePath&&" The linked worktree will also be removed."," ","This action cannot be undone."]}),a.worktreePath&&f.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[f.jsx(Rr,{checked:F,onCheckedChange:ze=>U(ze===!0),disabled:l.isPending}),"Also delete linked worktree"]})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{disabled:l.isPending,children:"Cancel"}),f.jsx(ec,{onClick:Ue,variant:"destructive",disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:()=>G(!0),title:"Task settings",children:f.jsx(J,{icon:MD,size:14,strokeWidth:2})}),f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:Ie,title:"New task terminal",children:f.jsx(J,{icon:lH,size:14,strokeWidth:2})}),N?f.jsxs(Rn,{to:"/repositories/$repoId",params:{repoId:N.id},className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}):f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}),f.jsx("div",{className:"ml-auto",children:f.jsx(lm,{worktreePath:a.worktreePath})})]})]}),f.jsxs("div",{className:"hidden items-center gap-3 sm:flex",children:[f.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("h1",{className:"text-sm font-medium",children:a.title}),f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:()=>G(!0),title:"Task settings",children:f.jsx(J,{icon:MD,size:14,strokeWidth:2})}),f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:Ie,title:"New task terminal",children:f.jsx(J,{icon:lH,size:14,strokeWidth:2})})]}),f.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[N?f.jsxs(Rn,{to:"/repositories/$repoId",params:{repoId:N.id},className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}):f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}),f.jsx(J,{icon:Rw,size:12,strokeWidth:2}),f.jsx("span",{className:"font-mono",children:a.branch}),a.prUrl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-muted-foreground/50",children:"•"}),f.jsxs("a",{href:a.prUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-foreground hover:text-primary font-medium",onClick:ze=>ze.stopPropagation(),children:[f.jsx(J,{icon:ju,size:14,strokeWidth:2}),f.jsxs("span",{children:["#",a.prUrl.match(/\/pull\/(\d+)/)?.[1]??"PR"]})]})]}),a.linearTicketUrl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-muted-foreground/50",children:"•"}),f.jsxs("a",{href:R?.url??a.linearTicketUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-foreground hover:text-primary font-medium",onClick:ze=>ze.stopPropagation(),title:R?.title,children:[f.jsx(J,{icon:l3,size:14,strokeWidth:2}),f.jsx("span",{children:a.linearTicketId}),R?.status&&f.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",R.status,")"]})]})]})]})]}),f.jsxs(am,{children:[f.jsx(sm,{render:f.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${XJ[a.status]}`}),children:B_[a.status]}),f.jsx(om,{align:"end",children:f.jsx(TW,{value:a.status,onValueChange:Se,children:Object.entries(B_).map(([ze,Xe])=>f.jsx(AW,{value:ze,children:Xe},ze))})})]}),f.jsxs("div",{className:"flex items-center gap-0",children:[f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:Te,disabled:m.isPending||!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Pull from ${a.baseBranch}`,children:f.jsx(J,{icon:dy,size:16,strokeWidth:2,className:m.isPending?"animate-spin":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:he,disabled:g.isPending||!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Merge to ${a.baseBranch}`,children:f.jsx(J,{icon:cy,size:16,strokeWidth:2,className:g.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:fe,disabled:x.isPending||!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Push to origin",children:f.jsx(J,{icon:fy,size:16,strokeWidth:2,className:x.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:ke,disabled:_.isPending||!a.repoPath,className:"text-muted-foreground hover:text-foreground",title:"Sync parent with origin",children:f.jsx(J,{icon:hy,size:16,strokeWidth:2,className:_.isPending?"animate-spin":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:_e,disabled:!Pe,className:"text-muted-foreground hover:text-foreground",title:"Commit",children:f.jsx(J,{icon:py,size:16,strokeWidth:2})}),!a.prUrl&&f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:pe,disabled:b.isPending,className:"text-muted-foreground hover:text-foreground",title:"Create Pull Request",children:f.jsx(J,{icon:ju,size:16,strokeWidth:2,className:b.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:Oe,disabled:!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Open in editor",children:f.jsx(J,{icon:c3,size:16,strokeWidth:2})})]}),f.jsxs(Oa,{open:q,onOpenChange:Ge,children:[f.jsx(Ju,{render:f.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive"}),children:f.jsx(J,{icon:rs,size:16,strokeWidth:2})}),f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsxs(La,{children:['This will permanently delete "',a.title,'" and close its terminal.',F&&a.worktreePath&&" The linked worktree will also be removed."," ","This action cannot be undone."]}),a.worktreePath&&f.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[f.jsx(Rr,{checked:F,onCheckedChange:ze=>U(ze===!0),disabled:l.isPending}),"Also delete linked worktree"]})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{disabled:l.isPending,children:"Cancel"}),f.jsx(ec,{onClick:Ue,variant:"destructive",disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})]})]})]}),Y?f.jsxs(mo,{value:K,onValueChange:ze=>W(ze),className:"flex min-h-0 flex-1 flex-col",children:[f.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:f.jsxs(go,{className:"w-full",children:[f.jsx(ar,{value:"terminal",className:"flex-1",children:"Terminal"}),f.jsx(ar,{value:"details",className:"flex-1",children:"Details"})]})}),f.jsx(_r,{value:"terminal",className:"flex-1 min-h-0",children:f.jsx(aQ,{taskName:a.title,cwd:a.worktreePath,agent:a.agent,aiMode:z,description:P,startupScript:a.startupScript,agentOptions:a.agentOptions,opencodeModel:D,serverPort:w,autoFocus:H},ee)}),f.jsx(_r,{value:"details",className:"flex-1 min-h-0 bg-background",children:f.jsxs(mo,{value:Q,onValueChange:te,className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between shrink-0 border-b border-border bg-background px-2 py-1",children:[f.jsxs(go,{variant:"line",children:[f.jsxs(ar,{value:"diff",children:[f.jsx(J,{icon:LD,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),f.jsxs(ar,{value:"browser",children:[f.jsx(J,{icon:DD,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),f.jsxs(ar,{value:"files",children:[f.jsx(J,{icon:ua,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]})]}),f.jsx(lm,{worktreePath:a.worktreePath})]}),f.jsx(_r,{value:"diff",className:"flex-1 overflow-hidden",children:f.jsx(oQ,{taskId:a.id,worktreePath:a.worktreePath,baseBranch:a.baseBranch})}),f.jsx(_r,{value:"browser",className:"flex-1 overflow-hidden",children:f.jsx(lQ,{taskId:a.id})}),f.jsx(_r,{value:"files",className:"flex-1 overflow-hidden",children:f.jsx(rw,{worktreePath:a.worktreePath,initialSelectedFile:re,onFileChange:xe})})]})})]}):f.jsxs(wf,{direction:"horizontal",className:"min-h-0 flex-1",children:[f.jsx(no,{defaultSize:50,minSize:30,children:f.jsx(aQ,{taskName:a.title,cwd:a.worktreePath,agent:a.agent,aiMode:z,description:P,startupScript:a.startupScript,agentOptions:a.agentOptions,opencodeModel:D,serverPort:w,autoFocus:H},ee)}),f.jsx(Cf,{withHandle:!0}),f.jsx(no,{defaultSize:50,minSize:30,className:"bg-background",children:f.jsxs(mo,{value:Q,onValueChange:te,className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between shrink-0 border-b border-border bg-background px-2 py-1",children:[f.jsxs(go,{variant:"line",children:[f.jsxs(ar,{value:"diff",children:[f.jsx(J,{icon:LD,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),f.jsxs(ar,{value:"browser",children:[f.jsx(J,{icon:DD,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),f.jsxs(ar,{value:"files",children:[f.jsx(J,{icon:ua,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]})]}),f.jsx(lm,{worktreePath:a.worktreePath})]}),f.jsx(_r,{value:"diff",className:"flex-1 overflow-hidden",children:f.jsx(oQ,{taskId:a.id,worktreePath:a.worktreePath,baseBranch:a.baseBranch})}),f.jsx(_r,{value:"browser",className:"flex-1 overflow-hidden",children:f.jsx(lQ,{taskId:a.id})}),f.jsx(_r,{value:"files",className:"flex-1 overflow-hidden",children:f.jsx(rw,{worktreePath:a.worktreePath,initialSelectedFile:re,onFileChange:xe})})]})})]}),f.jsx(Bse,{task:a,open:j,onOpenChange:G})]}):f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[f.jsx("p",{className:"text-muted-foreground",children:"Task not found"}),f.jsx(Rn,{to:"/tasks",children:f.jsx(Ae,{variant:"outline",children:"Back to Tasks"})})]})}function ZJ({value:e,onChange:t}){const{t:n}=wt("repositories"),[r,i]=T.useState(()=>{const p=Object.entries(e);return p.length===0?[]:p.map(([d,m])=>({id:crypto.randomUUID(),key:d,value:m}))}),a=T.useRef(null);T.useEffect(()=>{const p=Object.entries(e);if(p.length===0&&r.length===0)return;const d=s(r);JSON.stringify(d)!==JSON.stringify(e)&&i(p.map(([m,g])=>({id:crypto.randomUUID(),key:m,value:g})))},[e]);const s=p=>{const d={};for(const m of p){const g=m.key.trim();g&&(d[g]=m.value)}return d},o=(p,d,m)=>{const g=r.map(x=>x.id===p?{...x,[d]:m}:x);i(g),t(s(g))},l=()=>{const p={id:crypto.randomUUID(),key:"",value:""};i([...r,p]),setTimeout(()=>{a.current?.focus()},0)},u=p=>{const d=r.filter(m=>m.id!==p);i(d),t(s(d))};return f.jsxs("div",{className:"space-y-2",children:[r.length>0&&f.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:f.jsxs("table",{className:"w-full text-sm",children:[f.jsx("thead",{children:f.jsxs("tr",{className:"bg-muted/50",children:[f.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground w-[40%]",children:n("detailView.settings.agentOptionsFlag")}),f.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:n("detailView.settings.agentOptionsValue")}),f.jsx("th",{className:"w-10"})]})}),f.jsx("tbody",{children:r.map((p,d)=>f.jsxs("tr",{className:"border-t border-border",children:[f.jsx("td",{className:"px-2 py-1",children:f.jsx($t,{ref:d===r.length-1?a:void 0,value:p.key,onChange:m=>o(p.id,"key",m.target.value),placeholder:"model",className:"h-8 font-mono text-xs"})}),f.jsx("td",{className:"px-2 py-1",children:f.jsx($t,{value:p.value,onChange:m=>o(p.id,"value",m.target.value),placeholder:"haiku",className:"h-8 font-mono text-xs"})}),f.jsx("td",{className:"px-2 py-1",children:f.jsx(Ae,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>u(p.id),children:f.jsx(J,{icon:rs,size:14,strokeWidth:2})})})]},p.id))})]})}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:l,className:"w-full",children:[f.jsx(J,{icon:v_e,size:14,strokeWidth:2,"data-slot":"icon"}),n("detailView.settings.addAgentOption")]})]})}function nlt(e){const t=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return t?`https://${t[1]}/${t[2]}`:e.replace(/\.git$/,"")}function rlt(e){return ln({queryKey:["git-remote",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/git/remote?path=${encodeURIComponent(e)}`);return t.ok?(await t.json()).remoteUrl:null},enabled:!!e,staleTime:60*1e3})}function ilt(){const{t:e}=wt("repositories"),{repoId:t}=aM.useParams(),{tab:n,file:r}=aM.useSearch(),i=Br(),{data:a,isLoading:s,error:o}=vTe(t),l=xTe(),u=uie(),{data:p}=rlt(a?.path),d=Gae(a?.id??null),{data:m,isLoading:g}=V3(a?.id??null),[x,_]=T.useState(""),[b,y]=T.useState(""),[v,E]=T.useState(""),[C,w]=T.useState({}),[A,R]=T.useState({}),[O,N]=T.useState(null),[D,L]=T.useState(null),[z,P]=T.useState(!1),[V,H]=T.useState(!1),[j,G]=T.useState(!1),[q,B]=T.useState(!1),[F,U]=T.useState(!1),[K,W]=T.useState(!1),[ee,oe]=T.useState("terminal"),[ne,Z]=T.useState(null),[Y,Q]=T.useState(!1),[re,se]=T.useState(!1),[te,xe]=T.useState(!1),be=T.useRef(null),ce=T.useRef(null),ye=T.useRef(!1),me=T.useRef(!1),{terminals:Pe,terminalsLoaded:Ie,connected:We,createTerminal:Te,attachXterm:he,resizeTerminal:fe,setupImagePaste:ke,writeToTerminal:_e}=y5(),pe=n||"settings",Oe=tC(),{openInTerminal:Se}=zse(),{data:Ue}=B0(),{data:Ge}=U0(),{data:ze}=$0(),Xe=()=>{if(!a)return;const rt=eC(a.path,Ue,Ge,ze);Al(rt)},Qe=()=>{g||(m?.found?i({to:"/apps/new",search:{repoId:t}}):U(!0))};T.useEffect(()=>{jt.repoTerminal.info("component mounted",{repoId:t,tab:n,activeTab:pe})},[t,n,pe]),T.useEffect(()=>{jt.repoTerminal.debug("state changed",{terminalId:ne,xtermReady:re,containerReady:te,connected:We,terminalsLoaded:Ie,terminalCount:Pe.length,repoPath:a?.path})},[ne,re,te,We,Ie,Pe.length,a?.path]);const Fe=T.useCallback(rt=>{i({to:"/repositories/$repoId",params:{repoId:t},search:rt==="settings"?{}:{tab:rt,file:r},replace:!0})},[i,t,r]),bt=T.useCallback(rt=>{i({to:"/repositories/$repoId",params:{repoId:t},search:{tab:"workspace",file:rt??void 0},replace:!0})},[i,t]);T.useEffect(()=>{a&&(_(a.displayName),y(a.startupScript||""),E(a.copyFiles||""),w(a.claudeOptions||{}),R(a.opencodeOptions||{}),N(a.opencodeModel??null),L(a.defaultAgent??null),P(a.isCopierTemplate??!1),H(!1))},[a]),T.useEffect(()=>{if(a){const rt=x!==a.displayName||b!==(a.startupScript||"")||v!==(a.copyFiles||"")||JSON.stringify(C)!==JSON.stringify(a.claudeOptions||{})||JSON.stringify(A)!==JSON.stringify(a.opencodeOptions||{})||O!==(a.opencodeModel??null)||D!==(a.defaultAgent??null)||z!==(a.isCopierTemplate??!1);H(rt)}},[x,b,v,C,A,O,D,z,a]);const Ne=()=>{a&&l.mutate({id:a.id,updates:{displayName:x.trim()||a.path.split("/").pop()||"repo",startupScript:b.trim()||null,copyFiles:v.trim()||null,claudeOptions:Object.keys(C).length>0?C:null,opencodeOptions:Object.keys(A).length>0?A:null,opencodeModel:O,defaultAgent:D,isCopierTemplate:z}},{onSuccess:()=>{_t.success(e("detailView.saved")),H(!1)},onError:rt=>{_t.error(e("detailView.failedToSave"),{description:rt instanceof Error?rt.message:"Unknown error"})}})},qe=async rt=>{a&&(await u.mutateAsync({id:a.id,deleteDirectory:rt}),i({to:"/repositories"}))};T.useEffect(()=>{ye.current=!1,me.current=!1,Z(null),Q(!1)},[a?.path]),T.useEffect(()=>{if(!We||!a?.path||!Ie||pe!=="workspace"||!re){jt.repoTerminal.debug("find/create: waiting",{connected:We,path:a?.path,terminalsLoaded:Ie,activeTab:pe,xtermReady:re});return}const rt=Pe.find(Et=>Et.cwd===a.path&&Et.status==="running");if(rt){jt.repoTerminal.info("found existing terminal",{id:rt.id,cwd:rt.cwd}),Z(rt.id);return}if(!ye.current&&be.current){ye.current=!0,Q(!0);const{cols:Et,rows:pt}=be.current;jt.repoTerminal.info("creating terminal",{name:a.displayName,cwd:a.path,cols:Et,rows:pt}),Te({name:a.displayName,cols:Et,rows:pt,cwd:a.path})}},[We,a?.path,a?.displayName,Ie,Pe,pe,Te,re]),T.useEffect(()=>{if(!a?.path)return;const rt=Pe.find(pt=>pt.cwd===a.path&&pt.status==="running");if(!rt)return;const Et=ne&&Pe.some(pt=>pt.id===ne);(!ne||!Et)&&(Z(rt.id),Q(!1),ne&&!Et&&(me.current=!1))},[Pe,a?.path,ne]);const nt=T.useCallback(rt=>{jt.repoTerminal.info("xterm ready"),be.current=rt,se(!0)},[]),ht=T.useCallback((rt,Et)=>{ne&&fe(ne,rt,Et)},[ne,fe]),gt=T.useCallback(rt=>{jt.repoTerminal.info("container ready"),ce.current=rt,xe(!0)},[]),fn=T.useCallback(rt=>{ne&&_e(ne,rt)},[ne,_e]);return T.useEffect(()=>{if(!ne||!re||!te){jt.repoTerminal.debug("attach effect: waiting",{terminalId:ne,xtermReady:re,containerReady:te});return}if(!be.current||!ce.current){jt.repoTerminal.warn("attach effect: refs not set despite ready states",{terminalId:ne});return}if(me.current){jt.repoTerminal.debug("attach effect: already attached",{terminalId:ne});return}return jt.repoTerminal.info("attaching terminal",{terminalId:ne}),he(ne,be.current),ke(ce.current,ne),me.current=!0,()=>{jt.repoTerminal.debug("detaching terminal",{terminalId:ne}),me.current=!1}},[ne,re,te,he,ke]),s?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):o||!a?f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border bg-background px-4 py-2",children:f.jsxs(Rn,{to:"/repositories",className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:y_e,size:16,strokeWidth:2}),e("detailView.breadcrumb")]})}),f.jsx("div",{className:"flex flex-1 items-center justify-center",children:f.jsxs("div",{className:"flex items-center gap-3 text-destructive",children:[f.jsx(J,{icon:er,size:20,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:e("detailView.notFound")})]})})]}):f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-background px-4 py-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>G(!0),className:"text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:u3,size:16,strokeWidth:2,"data-slot":"icon",className:"-translate-y-px"}),f.jsx("span",{className:"max-sm:hidden",children:e("newTask")})]}),a.isCopierTemplate&&f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>W(!0),className:"text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:O_e,size:16,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("newProject.button")})]}),f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>i({to:"/tasks",search:{repo:a.displayName}}),className:"text-muted-foreground hover:text-foreground",title:e("viewTasks"),children:[f.jsx(J,{icon:wm,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("viewTasks")})]}),f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>Se(a.path,a.displayName),className:"text-muted-foreground hover:text-foreground",title:e("openInTerminal"),children:[f.jsx(J,{icon:Aw,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("terminal")})]}),f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:Xe,className:"text-muted-foreground hover:text-foreground",title:e("openInEditor",{editor:Y3(Ue)}),children:[f.jsx(J,{icon:c3,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("editor")})]}),d?f.jsx(Rn,{to:"/apps",search:{repo:a.displayName},children:f.jsxs(Ae,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:lp,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("applications")})]})}):f.jsxs(Ae,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",onClick:Qe,disabled:g,children:[f.jsx(J,{icon:lp,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("createApp")})]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(lm,{worktreePath:a.path}),f.jsx("span",{className:"text-sm font-medium",children:a.displayName}),p&&f.jsx("a",{href:nlt(p),target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors",title:p,children:f.jsx(J,{icon:p.includes("github.com")?R_e:s3,size:14,strokeWidth:2})}),f.jsx(Ae,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-destructive",onClick:()=>B(!0),children:f.jsx(J,{icon:rs,size:14,strokeWidth:2})})]})]}),f.jsxs(mo,{value:pe,onValueChange:rt=>Fe(rt),className:"flex flex-1 flex-col overflow-hidden",children:[f.jsx("div",{className:"shrink-0 border-b border-border bg-muted/50 px-4",children:f.jsxs(go,{variant:"line",children:[f.jsx(ar,{value:"settings",className:"px-3 py-1.5",children:e("detailView.tabs.settings")}),f.jsx(ar,{value:"workspace",className:"px-3 py-1.5",children:e("detailView.tabs.workspace")})]})}),f.jsx(_r,{value:"settings",className:"flex-1 overflow-hidden mt-0",children:f.jsx(Cg,{className:"h-full",children:f.jsxs("div",{className:"p-4",children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[f.jsx(J,{icon:ua,size:14,strokeWidth:2}),f.jsx("span",{className:"font-mono break-all",children:a.path})]}),f.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[f.jsxs("div",{className:"flex-1 bg-card rounded-lg p-6 border border-border",children:[f.jsx("h3",{className:"text-sm font-medium mb-4",children:e("detailView.settings.generalTitle")}),f.jsxs(up,{children:[f.jsxs(Hn,{children:[f.jsx(Wn,{htmlFor:"displayName",children:e("detailView.settings.displayName")}),f.jsx($t,{id:"displayName",value:x,onChange:rt=>_(rt.target.value),placeholder:a.path.split("/").pop()||"My Project"})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.defaultAgent")}),f.jsxs(Kr,{value:D??"inherit",onValueChange:rt=>L(rt==="inherit"?null:rt),children:[f.jsx(Xr,{className:"w-full",children:f.jsx(Yr,{})}),f.jsxs(Zr,{alignItemWithTrigger:!1,children:[f.jsx(on,{value:"inherit",children:e("detailView.settings.defaultAgentInherit")}),Object.keys(Pl).map(rt=>f.jsx(on,{value:rt,children:Pl[rt]},rt))]})]}),f.jsx(Sa,{children:e("detailView.settings.defaultAgentDescription")})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{htmlFor:"startupScript",children:e("detailView.settings.startupScript")}),f.jsx(M0,{id:"startupScript",value:b,onChange:rt=>y(rt.target.value),placeholder:e("detailView.settings.startupScriptPlaceholder"),rows:3}),f.jsx(Sa,{children:e("detailView.settings.startupScriptDescription")})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{htmlFor:"copyFiles",children:e("detailView.settings.copyFiles")}),f.jsx($t,{id:"copyFiles",value:v,onChange:rt=>E(rt.target.value),placeholder:e("detailView.settings.copyFilesPlaceholder")}),f.jsx(Sa,{children:e("detailView.settings.copyFilesDescription")})]}),f.jsxs(Hn,{children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Rr,{checked:z,onCheckedChange:rt=>P(rt===!0)}),f.jsx(Wn,{className:"cursor-pointer",children:e("detailView.settings.isCopierTemplate")})]}),f.jsx(Sa,{children:e("detailView.settings.isCopierTemplateDescription")})]})]})]}),f.jsxs("div",{className:"flex-1 bg-card rounded-lg p-6 border border-border",children:[f.jsx("h3",{className:"text-sm font-medium mb-4",children:e("detailView.settings.agentTitle")}),f.jsxs(up,{children:[f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.claudeOptions")}),f.jsx(Sa,{className:"mb-2",children:e("detailView.settings.claudeOptionsDescription")}),f.jsx(ZJ,{value:C,onChange:w})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.opencodeOptions")}),f.jsx(Sa,{className:"mb-2",children:e("detailView.settings.opencodeOptionsDescription")}),f.jsx(ZJ,{value:A,onChange:R})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.opencodeModel")}),f.jsx(O3,{value:O,onChange:N,placeholder:e("detailView.settings.opencodeModelPlaceholder")}),f.jsx(Sa,{children:e("detailView.settings.opencodeModelDescription")})]})]})]})]}),f.jsx("div",{className:"flex items-center justify-end mt-4",children:f.jsxs(Ae,{size:"sm",onClick:Ne,disabled:!V||l.isPending,children:[f.jsx(J,{icon:Dr,size:14,strokeWidth:2,"data-slot":"icon"}),l.isPending?e("detailView.saving"):e("detailView.save")]})})]})})}),f.jsx(_r,{value:"workspace",className:"flex-1 overflow-hidden mt-0",children:Oe?f.jsxs(mo,{value:ee,onValueChange:rt=>oe(rt),className:"flex min-h-0 flex-1 flex-col h-full",children:[f.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:f.jsxs(go,{className:"w-full",children:[f.jsx(ar,{value:"terminal",className:"flex-1",children:e("detailView.mobileWorkspace.terminal")}),f.jsx(ar,{value:"files",className:"flex-1",children:e("detailView.mobileWorkspace.files")})]})}),f.jsx(_r,{value:"terminal",className:"flex-1 min-h-0",children:f.jsxs("div",{className:"h-full flex flex-col",children:[!We&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:e("detailView.workspace.connectingToTerminal")}),Y&&!ne&&f.jsx("div",{className:"flex-1 flex items-center justify-center bg-terminal-background",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"}),f.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:e("detailView.workspace.initializingTerminal")})]})}),f.jsx(oL,{className:"flex-1",onReady:nt,onResize:ht,onContainerReady:gt,terminalId:ne??void 0,setupImagePaste:ke,onSend:fn})]})}),f.jsx(_r,{value:"files",className:"flex-1 min-h-0",children:f.jsx(rw,{worktreePath:a.path,initialSelectedFile:r,onFileChange:bt})})]}):f.jsxs(wf,{direction:"horizontal",className:"h-full",children:[f.jsx(no,{defaultSize:50,minSize:30,children:f.jsxs("div",{className:"h-full flex flex-col",children:[!We&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:e("detailView.workspace.connectingToTerminal")}),Y&&!ne&&f.jsx("div",{className:"flex-1 flex items-center justify-center bg-terminal-background",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"}),f.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:e("detailView.workspace.initializingTerminal")})]})}),f.jsx(oL,{className:"flex-1",onReady:nt,onResize:ht,onContainerReady:gt,terminalId:ne??void 0,setupImagePaste:ke,onSend:fn})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(no,{defaultSize:50,minSize:30,children:f.jsx(rw,{worktreePath:a.path,initialSelectedFile:r,onFileChange:bt})})]})})]}),f.jsx(R3,{open:j,onOpenChange:G,defaultRepository:a,showTrigger:!1}),f.jsx(Vse,{repository:a,open:q,onOpenChange:B,onDelete:qe}),f.jsx(Wse,{initialTemplateSource:a.id,open:K,onOpenChange:W}),f.jsx(Xo,{open:F,onOpenChange:U,children:f.jsxs(Zo,{children:[f.jsxs(Ul,{children:[f.jsx($l,{children:e("createAppDialog.title")}),f.jsx(Cp,{children:e("createAppDialog.description")})]}),f.jsx("p",{className:"text-sm",children:e("createAppDialog.instructions")}),f.jsx(Fu,{children:f.jsx(Ae,{onClick:()=>U(!1),children:e("createAppDialog.close")})})]})})]})}const aM=Di("/repositories/$repoId")({component:ilt,validateSearch:e=>({tab:e.tab==="workspace"?"workspace":void 0,file:typeof e.file=="string"?e.file:void 0})}),alt=Di("/jobs/new")({component:slt});function slt(){const{t:e}=wt("jobs"),t=Br(),n=uGe(),[r,i]=T.useState(""),[a,s]=T.useState(""),[o,l]=T.useState(""),[u,p]=T.useState(""),[d,m]=T.useState(""),[g,x]=T.useState(!0),[_,b]=T.useState({}),y=()=>{const E={};return r.trim()?/^[a-zA-Z0-9_-]+$/.test(r)||(E.name="Name must contain only alphanumeric characters, hyphens, and underscores"):E.name="Name is required",a.trim()||(E.description="Description is required"),o.trim()||(E.schedule="Schedule is required"),u.trim()||(E.command="Command is required"),b(E),Object.keys(E).length===0},v=async E=>{if(E.preventDefault(),!!y())try{await n.mutateAsync({name:r.trim(),description:a.trim(),schedule:o.trim(),command:u.trim(),workingDirectory:d.trim()||void 0,persistent:g}),_t.success("Job created successfully"),t({to:"/monitoring",search:{tab:"jobs"}})}catch(C){_t.error(C instanceof Error?C.message:"Failed to create job")}};return f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-4 border-b border-border bg-background px-4 py-3",children:[f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},className:"text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:qu,size:20,strokeWidth:2})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(J,{icon:Tw,size:20,strokeWidth:2,className:"text-muted-foreground"}),f.jsx("h1",{className:"text-lg font-semibold",children:e("create.title")})]})]}),f.jsx("div",{className:"flex-1 overflow-auto p-4",children:f.jsxs("form",{onSubmit:v,className:"mx-auto max-w-2xl space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"name",children:e("create.name")}),f.jsx($t,{id:"name",value:r,onChange:E=>i(E.target.value),placeholder:e("create.namePlaceholder"),className:_.name?"border-destructive":""}),_.name?f.jsx("p",{className:"text-sm text-destructive",children:_.name}):f.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.nameHelp")})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"description",children:e("create.description")}),f.jsx($t,{id:"description",value:a,onChange:E=>s(E.target.value),placeholder:e("create.descriptionPlaceholder"),className:_.description?"border-destructive":""}),_.description&&f.jsx("p",{className:"text-sm text-destructive",children:_.description})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"schedule",children:e("create.schedule")}),f.jsx($t,{id:"schedule",value:o,onChange:E=>l(E.target.value),placeholder:"*-*-* 02:00:00",className:_.schedule?"border-destructive":""}),_.schedule?f.jsx("p",{className:"text-sm text-destructive",children:_.schedule}):f.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.scheduleHelp")}),f.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[f.jsx("span",{className:"text-muted-foreground",children:"Examples:"}),f.jsx("button",{type:"button",onClick:()=>l("daily"),className:"text-primary hover:underline",children:"daily"}),f.jsx("button",{type:"button",onClick:()=>l("weekly"),className:"text-primary hover:underline",children:"weekly"}),f.jsx("button",{type:"button",onClick:()=>l("*-*-* 02:00:00"),className:"text-primary hover:underline",children:"*-*-* 02:00:00"}),f.jsx("button",{type:"button",onClick:()=>l("Mon..Fri 09:00"),className:"text-primary hover:underline",children:"Mon..Fri 09:00"})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"command",children:e("create.command")}),f.jsx(M0,{id:"command",value:u,onChange:E=>p(E.target.value),placeholder:e("create.commandPlaceholder"),className:`font-mono ${_.command?"border-destructive":""}`,rows:3}),_.command&&f.jsx("p",{className:"text-sm text-destructive",children:_.command})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"workingDir",children:e("create.workingDir")}),f.jsx($t,{id:"workingDir",value:d,onChange:E=>m(E.target.value),placeholder:e("create.workingDirPlaceholder")})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Rr,{id:"persistent",checked:g,onCheckedChange:E=>x(E===!0)}),f.jsxs("div",{className:"grid gap-1.5 leading-none",children:[f.jsx(Vi,{htmlFor:"persistent",className:"cursor-pointer",children:e("create.persistent")}),f.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.persistentHelp")})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2 pt-4",children:[f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},children:f.jsx(Ae,{type:"button",variant:"outline",children:e("create.cancel")})}),f.jsxs(Ae,{type:"submit",disabled:n.isPending,children:[n.isPending&&f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin","data-slot":"icon"}),e("create.create")]})]})]})})]})}const sM=Di("/jobs/$jobId")({component:clt,validateSearch:e=>({tab:["general","logs"].includes(e.tab)?e.tab:void 0,scope:["user","system"].includes(e.scope)?e.scope:void 0})});function olt(e,t){if(!t)return"bg-gray-400";switch(e){case"active":return"bg-green-500";case"waiting":return"bg-blue-500";case"failed":return"bg-red-500";default:return"bg-gray-400"}}function llt(e,t){if(!t)return"outline";switch(e){case"active":return"default";case"waiting":return"secondary";case"failed":return"destructive";default:return"outline"}}function QJ(e){return e?new Date(e).toLocaleString():"-"}function JJ(e){if(!e)return"-";const t=new Date(e),n=new Date,r=t.getTime()-n.getTime(),i=r<0,a=Math.abs(r),s=Math.floor(a/6e4),o=Math.floor(s/60),l=Math.floor(o/24);let u;return s<60?u=`${s}m`:o<24?u=`${o}h ${s%60}m`:u=`${l}d ${o%24}h`,i?`${u} ago`:`in ${u}`}function eee(e){if(e===null||e<0)return"-";const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m ${t%60}s`:n>0?`${n}m ${t%60}s`:t>0?`${t}.${Math.floor(e%1e3/100)}s`:`${e}ms`}function bv(e){const t={us:"microsecond",usec:"microsecond",ms:"millisecond",msec:"millisecond",s:"second",sec:"second",second:"second",seconds:"second",m:"minute",min:"minute",minute:"minute",minutes:"minute",h:"hour",hr:"hour",hour:"hour",hours:"hour",d:"day",day:"day",days:"day",w:"week",week:"week",weeks:"week",M:"month",month:"month",months:"month",y:"year",year:"year",years:"year"},n=/(\d+)\s*(us|usec|ms|msec|s|sec|seconds?|m|min|minutes?|h|hr|hours?|d|days?|w|weeks?|M|months?|y|years?)/gi,r=[];let i;for(;(i=n.exec(e))!==null;){const a=parseInt(i[1],10),s=i[2].toLowerCase(),o=t[s]||s,l=a!==1?"s":"";r.push(`${a} ${o}${l}`)}return r.length>0?r.join(" "):e}function tee(e){if(!e)return[];const t=[],n=e.split(/,\s*/);for(const r of n){const i=r.trim();if(i.startsWith("OnStartupSec=")){const a=i.replace("OnStartupSec=","");t.push(`${bv(a)} after startup`)}else if(i.startsWith("OnBootSec=")){const a=i.replace("OnBootSec=","");t.push(`${bv(a)} after boot`)}else if(i.startsWith("OnUnitActiveSec=")){const a=i.replace("OnUnitActiveSec=","");t.push(`Every ${bv(a)}`)}else if(i.startsWith("OnUnitInactiveSec=")){const a=i.replace("OnUnitInactiveSec=","");t.push(`${bv(a)} after becoming inactive`)}else if(i.startsWith("OnActiveSec=")){const a=i.replace("OnActiveSec=","");t.push(`${bv(a)} after timer activation`)}else i&&t.push(i)}return t}function ult({entry:e}){const t={error:"text-red-500",warning:"text-yellow-500",info:"text-foreground"}[e.priority],n=new Date(e.timestamp).toLocaleTimeString();return f.jsxs("div",{className:`font-mono text-xs ${t}`,children:[f.jsx("span",{className:"text-muted-foreground",children:n})," ",f.jsx("span",{children:e.message})]})}function clt(){const{t:e}=wt("jobs"),{jobId:t}=sM.useParams(),{tab:n,scope:r="user"}=sM.useSearch(),i=Br(),a=n||"general",{data:s,isLoading:o,error:l,refetch:u}=oGe(t,r),{data:p,refetch:d}=lGe(t,r,200),m=_ce(),g=Sce(),x=Ece(),_=xce(),[b,y]=T.useState(!1),v=t.replace(".timer",""),E=r==="system",C=O=>{i({to:"/jobs/$jobId",params:{jobId:t},search:{tab:O!=="general"?O:void 0,scope:r},replace:!0})},w=async()=>{if(s)try{s.enabled?(await g.mutateAsync({name:s.name,scope:s.scope}),_t.success(e("actions.disable")+" successful")):(await m.mutateAsync({name:s.name,scope:s.scope}),_t.success(e("actions.enable")+" successful")),u()}catch(O){_t.error(O instanceof Error?O.message:"Failed")}},A=async()=>{if(s)try{await x.mutateAsync({name:s.name,scope:s.scope}),_t.success(e("actions.runNow")+" triggered"),u(),d()}catch(O){_t.error(O instanceof Error?O.message:"Failed")}},R=async()=>{if(s){try{await _.mutateAsync(s.name),_t.success("Job deleted"),i({to:"/monitoring",search:{tab:"jobs"}})}catch(O){_t.error(O instanceof Error?O.message:"Failed to delete")}y(!1)}};return o?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):l||!s?f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[f.jsx(J,{icon:er,size:48,strokeWidth:1.5,className:"text-destructive opacity-50"}),f.jsx("p",{className:"text-muted-foreground",children:l?.message||"Job not found"}),f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},children:f.jsxs(Ae,{variant:"outline",children:[f.jsx(J,{icon:qu,size:16,strokeWidth:2,"data-slot":"icon"}),e("title")]})})]}):f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"shrink-0 border-b border-border bg-background px-4 py-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},className:"shrink-0 text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:qu,size:20,strokeWidth:2})}),f.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full ${olt(s.state,s.enabled)}`}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("h1",{className:"truncate text-lg font-semibold",children:v}),f.jsx(Jr,{variant:llt(s.state,s.enabled),children:s.enabled?e(`status.${s.state}`):e("status.disabled")}),E&&f.jsxs(Jr,{variant:"outline",className:"gap-1",children:[f.jsx(J,{icon:Ine,size:10,strokeWidth:2}),e("scope.system")]})]}),s.description&&f.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground line-clamp-2",children:s.description})]})]}),!E&&f.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[f.jsxs(Ae,{variant:"outline",size:"sm",onClick:A,disabled:x.isPending,children:[x.isPending?f.jsx(J,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin","data-slot":"icon"}):f.jsx(J,{icon:Cm,size:14,strokeWidth:2,"data-slot":"icon"}),e("actions.runNow")]}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:w,disabled:m.isPending||g.isPending,children:[f.jsx(J,{icon:s.enabled?Tm:Cm,size:14,strokeWidth:2,"data-slot":"icon"}),s.enabled?e("actions.disable"):e("actions.enable")]}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:()=>y(!0),className:"text-destructive hover:text-destructive",children:[f.jsx(J,{icon:rs,size:14,strokeWidth:2,"data-slot":"icon"}),e("actions.delete")]})]})]}),f.jsxs(mo,{value:a,onValueChange:O=>C(O),className:"flex flex-1 flex-col overflow-hidden",children:[f.jsxs(go,{className:"mx-4 mt-2 w-fit",children:[f.jsx(ar,{value:"general",children:e("detail.tabs.general")}),f.jsx(ar,{value:"logs",children:e("detail.tabs.logs")})]}),f.jsx(_r,{value:"general",className:"flex-1 overflow-auto p-4",children:f.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[f.jsxs("div",{className:"space-y-4 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.schedule")}),f.jsxs("div",{className:"rounded-lg border p-4 space-y-3 overflow-hidden",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(J,{icon:Tw,size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground mt-0.5"}),f.jsx("div",{className:"min-w-0 flex-1 flex flex-col gap-1",children:tee(s.schedule).length>0?tee(s.schedule).map((O,N)=>f.jsx("span",{className:"break-all text-sm",children:O},N)):f.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),f.jsxs("div",{className:`grid gap-4 text-sm ${s.nextRun?"grid-cols-1 sm:grid-cols-2":"grid-cols-1"}`,children:[s.nextRun&&f.jsxs("div",{children:[f.jsx("div",{className:"text-muted-foreground",children:e("detail.nextRun")}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx(J,{icon:One,size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),f.jsx("span",{children:JJ(s.nextRun)})]}),f.jsx("div",{className:"text-xs text-muted-foreground",children:QJ(s.nextRun)})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-muted-foreground",children:e("detail.lastRun")}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s.lastResult==="success"&&f.jsx(J,{icon:vo,size:14,strokeWidth:2,className:"shrink-0 text-green-500"}),s.lastResult==="failed"&&f.jsx(J,{icon:Mr,size:14,strokeWidth:2,className:"shrink-0 text-red-500"}),f.jsx("span",{children:JJ(s.lastRun)})]}),f.jsx("div",{className:"text-xs text-muted-foreground",children:QJ(s.lastRun)})]})]})]})]}),f.jsxs("div",{className:"space-y-4 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.command")}),f.jsxs("div",{className:"rounded-lg border p-4 space-y-3 overflow-hidden",children:[s.command?f.jsx("code",{className:"block whitespace-pre-wrap break-all rounded bg-muted px-2 py-1 text-sm font-mono",children:s.command}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"-"}),s.workingDirectory&&f.jsxs("div",{className:"text-sm break-all",children:[f.jsxs("span",{className:"text-muted-foreground",children:[e("detail.workingDir"),": "]}),f.jsx("code",{className:"font-mono break-all",children:s.workingDirectory})]})]})]}),(s.lastRunDurationMs!==null||s.lastRunCpuTimeMs!==null)&&f.jsxs("div",{className:"space-y-4",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.executionStats")}),f.jsx("div",{className:"rounded-lg border p-4 space-y-3",children:f.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[f.jsx(J,{icon:z_e,size:14,strokeWidth:2}),e("detail.duration")]}),f.jsx("div",{className:"font-mono",children:eee(s.lastRunDurationMs)})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[f.jsx(J,{icon:E_e,size:14,strokeWidth:2}),e("detail.cpuTime")]}),f.jsx("div",{className:"font-mono",children:eee(s.lastRunCpuTimeMs)})]})]})})]}),!E&&s.timerContent&&f.jsxs("div",{className:"space-y-4 md:col-span-2 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.timerFile")}),f.jsx("pre",{className:"rounded-lg border bg-muted p-4 text-xs font-mono overflow-y-auto max-h-48 whitespace-pre-wrap break-all",children:s.timerContent})]}),!E&&s.serviceContent&&f.jsxs("div",{className:"space-y-4 md:col-span-2 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.serviceFile")}),f.jsx("pre",{className:"rounded-lg border bg-muted p-4 text-xs font-mono overflow-y-auto max-h-48 whitespace-pre-wrap break-all",children:s.serviceContent})]})]})}),f.jsxs(_r,{value:"logs",className:"flex flex-1 flex-col overflow-hidden p-4",children:[f.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("logs.title")}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:()=>d(),children:[f.jsx(J,{icon:Nw,size:14,strokeWidth:2,"data-slot":"icon"}),e("logs.refresh")]})]}),f.jsx("div",{className:"flex-1 overflow-auto rounded-lg border bg-muted p-4",children:p?.entries&&p.entries.length>0?f.jsx("div",{className:"space-y-1",children:p.entries.map((O,N)=>f.jsx(ult,{entry:O},N))}):f.jsx("p",{className:"text-center text-muted-foreground text-sm",children:e("logs.noLogs")})})]})]}),f.jsx(Oa,{open:b,onOpenChange:y,children:f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:e("delete.title")}),f.jsx(La,{children:e("delete.confirm",{name:v})})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{children:e("delete.cancel")}),f.jsx(ec,{onClick:R,className:"bg-destructive text-destructive-foreground",children:e("delete.delete")})]})]})})]})}function dlt({className:e,...t}){return f.jsx(tCe,{"data-slot":"radio-group",className:Be("grid gap-3 w-full",e),...t})}function nee({className:e,...t}){return f.jsx(Qwe,{"data-slot":"radio-group-item",className:Be("border-input text-primary dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 data-checked:bg-primary data-checked:border-primary flex size-4 rounded-full transition-none focus-visible:ring-[2px] aria-invalid:ring-[2px] group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:f.jsx(Jwe,{"data-slot":"radio-group-indicator",className:"group-aria-invalid/radio-group-item:text-destructive flex size-4 items-center justify-center text-white",children:f.jsx(J,{icon:__e,strokeWidth:2,className:"absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 fill-current"})})})}const upe=Di("/apps/new")({component:flt,validateSearch:e=>({repoId:typeof e.repoId=="string"?e.repoId:void 0})});function flt(){const e=Br(),{repoId:t}=upe.useSearch(),{data:n,isLoading:r}=wg(),{data:i}=G3(),a=MIe(),s=i?.tunnelsAvailable??!1,[o,l]=T.useState("select-repo"),[u,p]=T.useState(null),[d,m]=T.useState(""),g=T.useRef(null),[x,_]=T.useState(""),[b,y]=T.useState(""),[v,E]=T.useState(!1),[C,w]=T.useState([]);T.useEffect(()=>{if(t&&n&&!u){const q=n.find(B=>B.id===t);q&&(p(q),_(q.displayName))}},[t,n,u,_]),T.useEffect(()=>{if(t&&u&&g.current){const q=g.current.querySelector(`[data-repo-id="${u.id}"]`);q&&q.scrollIntoView({behavior:"smooth",block:"nearest"})}},[t,u]);const{data:A,isLoading:R,error:O}=V3(u?.id??null),{data:N,isLoading:D}=BIe(A?.found?u?.id??null:null),{data:L}=rie(u?.path??null);T.useEffect(()=>{L?.defaultBranch&&!b&&y(L.defaultBranch)},[L?.defaultBranch,b]);const z=T.useMemo(()=>n?d?.trim()?n.map(q=>({repo:q,score:Math.max(Ki(q.displayName,d),Ki(q.path,d))})).filter(({score:q})=>q>0).sort((q,B)=>B.score-q.score).map(({repo:q})=>q):n:[],[n,d]),P=q=>{w(q.map(B=>({serviceName:B.name,containerPort:B.ports?.[0]?.container??null,exposed:!1,domain:"",exposureMethod:"dns"})))},V=q=>{p(q),_(q.displayName),y("")},H=()=>{N&&P(N.services),l("configure-services")},j=(q,B)=>{w(F=>F.map((U,K)=>K===q?{...U,...B}:U))},G=async()=>{if(!(!u||!N))try{const q=await a.mutateAsync({name:x,repositoryId:u.id,branch:b||L?.defaultBranch||"main",composeFile:N.file,autoDeployEnabled:v,services:C.map(B=>({serviceName:B.serviceName,containerPort:B.containerPort??void 0,exposed:B.exposed,domain:B.domain||void 0,exposureMethod:B.exposureMethod}))});e({to:"/apps/$appId",params:{appId:q.id}})}catch{}};return f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border bg-background px-4 py-2",children:[f.jsxs(Rn,{to:"/apps",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:qu,size:16,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:"Apps"})]}),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"text-sm text-muted-foreground",children:["Step ",o==="select-repo"?"1":"2"," of 2"]})]}),f.jsx("div",{className:"flex-1 overflow-auto p-4",children:o==="select-repo"?f.jsx("div",{className:"mx-auto max-w-2xl",children:f.jsxs(ei,{children:[f.jsx(zS,{children:f.jsx(HS,{children:"Select Repository"})}),f.jsxs(ka,{className:"space-y-4",children:[f.jsxs("div",{className:"relative",children:[f.jsx(J,{icon:wp,size:14,strokeWidth:2,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),f.jsx($t,{value:d,onChange:q=>m(q.target.value),placeholder:"Search repositories...",className:"pl-9"})]}),r?f.jsx("div",{className:"flex items-center justify-center py-8",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):f.jsxs("div",{ref:g,className:"space-y-2 max-h-80 overflow-auto",children:[z.map(q=>f.jsx(plt,{repo:q,selected:u?.id===q.id,onSelect:()=>V(q)},q.id)),z.length===0&&f.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:"No repositories found"})]}),u&&f.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:R||D?f.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),f.jsx("span",{className:"text-sm",children:"Checking for compose file..."})]}):O?f.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[f.jsx(J,{icon:er,size:16,strokeWidth:2}),f.jsxs("span",{className:"text-sm",children:["Error: ",O.message]})]}):A?.found?f.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[f.jsx(J,{icon:vo,size:16,strokeWidth:2}),f.jsxs("span",{className:"text-sm",children:["Found ",A.file,N&&` with ${N.services.length} service(s)`]})]}):f.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[f.jsx(J,{icon:Mr,size:16,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:"No compose file found in this repository"})]})}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Rn,{to:"/apps",children:f.jsx(Ae,{variant:"outline",children:"Cancel"})}),f.jsxs(Ae,{onClick:H,disabled:!u||!A?.found||!N,children:["Next",f.jsx(J,{icon:Mu,size:16,strokeWidth:2})]})]})]})]})}):f.jsx("div",{className:"mx-auto max-w-2xl",children:f.jsxs(ei,{children:[f.jsxs(zS,{children:[f.jsx(HS,{children:"Configure App"}),f.jsxs("p",{className:"text-sm text-muted-foreground",children:[u?.displayName," · ",N?.file]})]}),f.jsxs(ka,{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"appName",children:"App Name"}),f.jsx($t,{id:"appName",value:x,onChange:q=>_(q.target.value),placeholder:"my-app"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"branch",children:"Branch"}),f.jsx($t,{id:"branch",value:b,onChange:q=>y(q.target.value),placeholder:L?.defaultBranch??"main"})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsx(Vi,{children:"Services"}),f.jsx("div",{className:"space-y-3",children:C.map((q,B)=>f.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-medium",children:q.serviceName}),q.containerPort&&f.jsxs(Jr,{variant:"secondary",children:[":",q.containerPort]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Rr,{id:`expose-${B}`,checked:q.exposed,onCheckedChange:F=>j(B,{exposed:F===!0})}),f.jsx(Vi,{htmlFor:`expose-${B}`,className:"text-sm",children:"Expose"})]})]}),q.exposed&&f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:`domain-${B}`,className:"text-sm",children:"Domain"}),f.jsx($t,{id:`domain-${B}`,value:q.domain,onChange:F=>j(B,{domain:F.target.value}),placeholder:"app.example.com"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{className:"text-sm",children:"Exposure Method"}),f.jsxs(dlt,{value:q.exposureMethod,onValueChange:F=>j(B,{exposureMethod:F}),className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(nee,{value:"dns",id:`dns-${B}`}),f.jsx(Vi,{htmlFor:`dns-${B}`,className:"text-sm font-normal cursor-pointer",children:"DNS (requires public IP and port forwarding)"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(nee,{value:"tunnel",id:`tunnel-${B}`,disabled:!s}),f.jsx(Vi,{htmlFor:`tunnel-${B}`,className:`text-sm font-normal cursor-pointer ${s?"":"text-muted-foreground"}`,children:"Cloudflare Tunnel (no public IP required)"})]})]}),!s&&f.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure Cloudflare Account ID in settings to enable tunnels"})]})]})]},q.serviceName))})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Rr,{id:"autoDeployEnabled",checked:v,onCheckedChange:q=>E(q===!0)}),f.jsxs(Vi,{htmlFor:"autoDeployEnabled",children:["Auto-deploy on push to ",b]})]}),f.jsxs("div",{className:"flex justify-between gap-2",children:[f.jsxs(Ae,{variant:"outline",onClick:()=>l("select-repo"),children:[f.jsx(J,{icon:qu,size:16,strokeWidth:2}),"Back"]}),f.jsx(Ae,{onClick:G,disabled:!x||a.isPending,children:a.isPending?f.jsxs(f.Fragment,{children:[f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Creating..."]}):"Create App"})]}),a.error&&f.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[f.jsx(J,{icon:er,size:16,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:a.error.message})]})]})]})})})]})}function plt({repo:e,selected:t,onSelect:n}){return f.jsxs("button",{type:"button","data-repo-id":e.id,onClick:n,className:`w-full rounded-lg border p-3 text-left transition-colors ${t?"border-primary bg-primary/5":"border-border hover:border-foreground/20 hover:bg-muted/50"}`,children:[f.jsx("div",{className:"font-medium",children:e.displayName}),f.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:e.path})]})}const hlt=/error|exception|failed|uncaught|fatal|crash|errno|reject/i,mlt=/warning|deprecated|caution|unstable|⚠️/i,glt=/successfully|completed|listening|connected|ready|started|✓|✅|done|healthy|pulled|created|recreated/i,blt=/debug|version|config|import|GET|POST|PUT|DELETE/i;function vlt(e){return hlt.test(e)?"error":mlt.test(e)?"warning":glt.test(e)?"success":blt.test(e)?"debug":"info"}function MB(e){return e.split(`
|
|
176
|
+
`).filter(Boolean).pop()||Xe;_t.error(Fe,{action:{label:"Resolve with Claude",onClick:()=>We(`Create a PR for this task. Error: "${Xe}". After creating, link it using: vibora current-task pr <url>. Worktree: ${a.worktreePath}.`)}})}},Oe=()=>{if(!a?.worktreePath)return;const ze=eC(a.worktreePath,v,E,C);Al(ze)},Se=ze=>{a&&o.mutate({taskId:a.id,updates:{status:ze}})},Ue=()=>{a&&l.mutate({taskId:a.id,deleteLinkedWorktree:F},{onSuccess:()=>{r({to:"/tasks"})}})},Ge=ze=>{B(ze),ze||U(!1)};return s?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx("p",{className:"text-muted-foreground",children:"Loading task..."})}):a?f.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f.jsxs("div",{className:"shrink-0 border-b border-border bg-background px-4 py-2",children:[f.jsxs("div",{className:"flex flex-col gap-1 sm:hidden",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:a.title}),f.jsxs(am,{children:[f.jsx(sm,{render:f.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${XJ[a.status]}`}),children:B_[a.status]}),f.jsx(om,{align:"end",children:f.jsx(TW,{value:a.status,onValueChange:Se,children:Object.entries(B_).map(([ze,Xe])=>f.jsx(AW,{value:ze,children:Xe},ze))})})]}),f.jsxs(am,{children:[f.jsx(sm,{render:f.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),children:f.jsx(J,{icon:Lne,size:16,strokeWidth:2})}),f.jsxs(om,{align:"end",children:[f.jsxs(Tr,{onClick:Te,disabled:m.isPending||!a.worktreePath,children:[f.jsx(J,{icon:dy,size:14,strokeWidth:2}),"Pull from ",a.baseBranch]}),f.jsxs(Tr,{onClick:he,disabled:g.isPending||!a.worktreePath,children:[f.jsx(J,{icon:cy,size:14,strokeWidth:2}),"Merge to ",a.baseBranch]}),f.jsxs(Tr,{onClick:fe,disabled:x.isPending||!a.worktreePath,children:[f.jsx(J,{icon:fy,size:14,strokeWidth:2}),"Push to origin"]}),f.jsxs(Tr,{onClick:ke,disabled:_.isPending||!a.repoPath,children:[f.jsx(J,{icon:hy,size:14,strokeWidth:2}),"Sync parent"]}),f.jsxs(Tr,{onClick:_e,disabled:!Pe,children:[f.jsx(J,{icon:py,size:14,strokeWidth:2}),"Commit"]}),!a.prUrl&&f.jsxs(Tr,{onClick:pe,disabled:b.isPending,children:[f.jsx(J,{icon:ju,size:14,strokeWidth:2,className:b.isPending?"animate-pulse":""}),"Create PR"]})]})]}),f.jsxs(Oa,{open:q,onOpenChange:Ge,children:[f.jsx(Ju,{render:f.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive"}),children:f.jsx(J,{icon:rs,size:16,strokeWidth:2})}),f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsxs(La,{children:['This will permanently delete "',a.title,'" and close its terminal.',F&&a.worktreePath&&" The linked worktree will also be removed."," ","This action cannot be undone."]}),a.worktreePath&&f.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[f.jsx(Rr,{checked:F,onCheckedChange:ze=>U(ze===!0),disabled:l.isPending}),"Also delete linked worktree"]})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{disabled:l.isPending,children:"Cancel"}),f.jsx(ec,{onClick:Ue,variant:"destructive",disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:()=>G(!0),title:"Task settings",children:f.jsx(J,{icon:MD,size:14,strokeWidth:2})}),f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:Ie,title:"New task terminal",children:f.jsx(J,{icon:lH,size:14,strokeWidth:2})}),N?f.jsxs(Rn,{to:"/repositories/$repoId",params:{repoId:N.id},className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}):f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}),f.jsx("div",{className:"ml-auto",children:f.jsx(lm,{worktreePath:a.worktreePath})})]})]}),f.jsxs("div",{className:"hidden items-center gap-3 sm:flex",children:[f.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("h1",{className:"text-sm font-medium",children:a.title}),f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:()=>G(!0),title:"Task settings",children:f.jsx(J,{icon:MD,size:14,strokeWidth:2})}),f.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:Ie,title:"New task terminal",children:f.jsx(J,{icon:lH,size:14,strokeWidth:2})})]}),f.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[N?f.jsxs(Rn,{to:"/repositories/$repoId",params:{repoId:N.id},className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}):f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(J,{icon:Ou,size:12,strokeWidth:2}),f.jsx("span",{children:a.repoName})]}),f.jsx(J,{icon:Rw,size:12,strokeWidth:2}),f.jsx("span",{className:"font-mono",children:a.branch}),a.prUrl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-muted-foreground/50",children:"•"}),f.jsxs("a",{href:a.prUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-foreground hover:text-primary font-medium",onClick:ze=>ze.stopPropagation(),children:[f.jsx(J,{icon:ju,size:14,strokeWidth:2}),f.jsxs("span",{children:["#",a.prUrl.match(/\/pull\/(\d+)/)?.[1]??"PR"]})]})]}),a.linearTicketUrl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-muted-foreground/50",children:"•"}),f.jsxs("a",{href:R?.url??a.linearTicketUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-foreground hover:text-primary font-medium",onClick:ze=>ze.stopPropagation(),title:R?.title,children:[f.jsx(J,{icon:l3,size:14,strokeWidth:2}),f.jsx("span",{children:a.linearTicketId}),R?.status&&f.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",R.status,")"]})]})]})]})]}),f.jsxs(am,{children:[f.jsx(sm,{render:f.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${XJ[a.status]}`}),children:B_[a.status]}),f.jsx(om,{align:"end",children:f.jsx(TW,{value:a.status,onValueChange:Se,children:Object.entries(B_).map(([ze,Xe])=>f.jsx(AW,{value:ze,children:Xe},ze))})})]}),f.jsxs("div",{className:"flex items-center gap-0",children:[f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:Te,disabled:m.isPending||!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Pull from ${a.baseBranch}`,children:f.jsx(J,{icon:dy,size:16,strokeWidth:2,className:m.isPending?"animate-spin":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:he,disabled:g.isPending||!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Merge to ${a.baseBranch}`,children:f.jsx(J,{icon:cy,size:16,strokeWidth:2,className:g.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:fe,disabled:x.isPending||!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Push to origin",children:f.jsx(J,{icon:fy,size:16,strokeWidth:2,className:x.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:ke,disabled:_.isPending||!a.repoPath,className:"text-muted-foreground hover:text-foreground",title:"Sync parent with origin",children:f.jsx(J,{icon:hy,size:16,strokeWidth:2,className:_.isPending?"animate-spin":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:_e,disabled:!Pe,className:"text-muted-foreground hover:text-foreground",title:"Commit",children:f.jsx(J,{icon:py,size:16,strokeWidth:2})}),!a.prUrl&&f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:pe,disabled:b.isPending,className:"text-muted-foreground hover:text-foreground",title:"Create Pull Request",children:f.jsx(J,{icon:ju,size:16,strokeWidth:2,className:b.isPending?"animate-pulse":""})}),f.jsx(Ae,{variant:"ghost",size:"icon-sm",onClick:Oe,disabled:!a.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Open in editor",children:f.jsx(J,{icon:c3,size:16,strokeWidth:2})})]}),f.jsxs(Oa,{open:q,onOpenChange:Ge,children:[f.jsx(Ju,{render:f.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive"}),children:f.jsx(J,{icon:rs,size:16,strokeWidth:2})}),f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:"Delete Task"}),f.jsxs(La,{children:['This will permanently delete "',a.title,'" and close its terminal.',F&&a.worktreePath&&" The linked worktree will also be removed."," ","This action cannot be undone."]}),a.worktreePath&&f.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[f.jsx(Rr,{checked:F,onCheckedChange:ze=>U(ze===!0),disabled:l.isPending}),"Also delete linked worktree"]})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{disabled:l.isPending,children:"Cancel"}),f.jsx(ec,{onClick:Ue,variant:"destructive",disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})]})]})]}),Y?f.jsxs(mo,{value:K,onValueChange:ze=>W(ze),className:"flex min-h-0 flex-1 flex-col",children:[f.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:f.jsxs(go,{className:"w-full",children:[f.jsx(ar,{value:"terminal",className:"flex-1",children:"Terminal"}),f.jsx(ar,{value:"details",className:"flex-1",children:"Details"})]})}),f.jsx(_r,{value:"terminal",className:"flex-1 min-h-0",children:f.jsx(aQ,{taskName:a.title,cwd:a.worktreePath,agent:a.agent,aiMode:z,description:P,startupScript:a.startupScript,agentOptions:a.agentOptions,opencodeModel:D,serverPort:w,autoFocus:H},ee)}),f.jsx(_r,{value:"details",className:"flex-1 min-h-0 bg-background",children:f.jsxs(mo,{value:Q,onValueChange:te,className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between shrink-0 border-b border-border bg-background px-2 py-1",children:[f.jsxs(go,{variant:"line",children:[f.jsxs(ar,{value:"diff",children:[f.jsx(J,{icon:LD,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),f.jsxs(ar,{value:"browser",children:[f.jsx(J,{icon:DD,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),f.jsxs(ar,{value:"files",children:[f.jsx(J,{icon:ua,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]})]}),f.jsx(lm,{worktreePath:a.worktreePath})]}),f.jsx(_r,{value:"diff",className:"flex-1 overflow-hidden",children:f.jsx(oQ,{taskId:a.id,worktreePath:a.worktreePath,baseBranch:a.baseBranch})}),f.jsx(_r,{value:"browser",className:"flex-1 overflow-hidden",children:f.jsx(lQ,{taskId:a.id})}),f.jsx(_r,{value:"files",className:"flex-1 overflow-hidden",children:f.jsx(rw,{worktreePath:a.worktreePath,initialSelectedFile:re,onFileChange:xe})})]})})]}):f.jsxs(wf,{direction:"horizontal",className:"min-h-0 flex-1",children:[f.jsx(no,{defaultSize:50,minSize:30,children:f.jsx(aQ,{taskName:a.title,cwd:a.worktreePath,agent:a.agent,aiMode:z,description:P,startupScript:a.startupScript,agentOptions:a.agentOptions,opencodeModel:D,serverPort:w,autoFocus:H},ee)}),f.jsx(Cf,{withHandle:!0}),f.jsx(no,{defaultSize:50,minSize:30,className:"bg-background",children:f.jsxs(mo,{value:Q,onValueChange:te,className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between shrink-0 border-b border-border bg-background px-2 py-1",children:[f.jsxs(go,{variant:"line",children:[f.jsxs(ar,{value:"diff",children:[f.jsx(J,{icon:LD,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),f.jsxs(ar,{value:"browser",children:[f.jsx(J,{icon:DD,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),f.jsxs(ar,{value:"files",children:[f.jsx(J,{icon:ua,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]})]}),f.jsx(lm,{worktreePath:a.worktreePath})]}),f.jsx(_r,{value:"diff",className:"flex-1 overflow-hidden",children:f.jsx(oQ,{taskId:a.id,worktreePath:a.worktreePath,baseBranch:a.baseBranch})}),f.jsx(_r,{value:"browser",className:"flex-1 overflow-hidden",children:f.jsx(lQ,{taskId:a.id})}),f.jsx(_r,{value:"files",className:"flex-1 overflow-hidden",children:f.jsx(rw,{worktreePath:a.worktreePath,initialSelectedFile:re,onFileChange:xe})})]})})]}),f.jsx(Bse,{task:a,open:j,onOpenChange:G})]}):f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[f.jsx("p",{className:"text-muted-foreground",children:"Task not found"}),f.jsx(Rn,{to:"/tasks",children:f.jsx(Ae,{variant:"outline",children:"Back to Tasks"})})]})}function ZJ({value:e,onChange:t}){const{t:n}=wt("repositories"),[r,i]=T.useState(()=>{const p=Object.entries(e);return p.length===0?[]:p.map(([d,m])=>({id:crypto.randomUUID(),key:d,value:m}))}),a=T.useRef(null);T.useEffect(()=>{const p=Object.entries(e);if(p.length===0&&r.length===0)return;const d=s(r);JSON.stringify(d)!==JSON.stringify(e)&&i(p.map(([m,g])=>({id:crypto.randomUUID(),key:m,value:g})))},[e]);const s=p=>{const d={};for(const m of p){const g=m.key.trim();g&&(d[g]=m.value)}return d},o=(p,d,m)=>{const g=r.map(x=>x.id===p?{...x,[d]:m}:x);i(g),t(s(g))},l=()=>{const p={id:crypto.randomUUID(),key:"",value:""};i([...r,p]),setTimeout(()=>{a.current?.focus()},0)},u=p=>{const d=r.filter(m=>m.id!==p);i(d),t(s(d))};return f.jsxs("div",{className:"space-y-2",children:[r.length>0&&f.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:f.jsxs("table",{className:"w-full text-sm",children:[f.jsx("thead",{children:f.jsxs("tr",{className:"bg-muted/50",children:[f.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground w-[40%]",children:n("detailView.settings.agentOptionsFlag")}),f.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:n("detailView.settings.agentOptionsValue")}),f.jsx("th",{className:"w-10"})]})}),f.jsx("tbody",{children:r.map((p,d)=>f.jsxs("tr",{className:"border-t border-border",children:[f.jsx("td",{className:"px-2 py-1",children:f.jsx($t,{ref:d===r.length-1?a:void 0,value:p.key,onChange:m=>o(p.id,"key",m.target.value),placeholder:"model",className:"h-8 font-mono text-xs"})}),f.jsx("td",{className:"px-2 py-1",children:f.jsx($t,{value:p.value,onChange:m=>o(p.id,"value",m.target.value),placeholder:"haiku",className:"h-8 font-mono text-xs"})}),f.jsx("td",{className:"px-2 py-1",children:f.jsx(Ae,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>u(p.id),children:f.jsx(J,{icon:rs,size:14,strokeWidth:2})})})]},p.id))})]})}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:l,className:"w-full",children:[f.jsx(J,{icon:v_e,size:14,strokeWidth:2,"data-slot":"icon"}),n("detailView.settings.addAgentOption")]})]})}function nlt(e){const t=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return t?`https://${t[1]}/${t[2]}`:e.replace(/\.git$/,"")}function rlt(e){return ln({queryKey:["git-remote",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/git/remote?path=${encodeURIComponent(e)}`);return t.ok?(await t.json()).remoteUrl:null},enabled:!!e,staleTime:60*1e3})}function ilt(){const{t:e}=wt("repositories"),{repoId:t}=aM.useParams(),{tab:n,file:r}=aM.useSearch(),i=Br(),{data:a,isLoading:s,error:o}=vTe(t),l=xTe(),u=uie(),{data:p}=rlt(a?.path),d=Gae(a?.id??null),{data:m,isLoading:g}=V3(a?.id??null),[x,_]=T.useState(""),[b,y]=T.useState(""),[v,E]=T.useState(""),[C,w]=T.useState({}),[A,R]=T.useState({}),[O,N]=T.useState(null),[D,L]=T.useState(null),[z,P]=T.useState(!1),[V,H]=T.useState(!1),[j,G]=T.useState(!1),[q,B]=T.useState(!1),[F,U]=T.useState(!1),[K,W]=T.useState(!1),[ee,oe]=T.useState("terminal"),[ne,Z]=T.useState(null),[Y,Q]=T.useState(!1),[re,se]=T.useState(!1),[te,xe]=T.useState(!1),be=T.useRef(null),ce=T.useRef(null),ye=T.useRef(!1),me=T.useRef(!1),{terminals:Pe,terminalsLoaded:Ie,connected:We,createTerminal:Te,attachXterm:he,resizeTerminal:fe,setupImagePaste:ke,writeToTerminal:_e}=y5(),pe=n||"settings",Oe=tC(),{openInTerminal:Se}=zse(),{data:Ue}=B0(),{data:Ge}=U0(),{data:ze}=$0(),Xe=()=>{if(!a)return;const rt=eC(a.path,Ue,Ge,ze);Al(rt)},Qe=()=>{g||(m?.found?i({to:"/apps/new",search:{repoId:t}}):U(!0))};T.useEffect(()=>{jt.repoTerminal.info("component mounted",{repoId:t,tab:n,activeTab:pe})},[t,n,pe]),T.useEffect(()=>{jt.repoTerminal.debug("state changed",{terminalId:ne,xtermReady:re,containerReady:te,connected:We,terminalsLoaded:Ie,terminalCount:Pe.length,repoPath:a?.path})},[ne,re,te,We,Ie,Pe.length,a?.path]);const Fe=T.useCallback(rt=>{i({to:"/repositories/$repoId",params:{repoId:t},search:rt==="settings"?{}:{tab:rt,file:r},replace:!0})},[i,t,r]),bt=T.useCallback(rt=>{i({to:"/repositories/$repoId",params:{repoId:t},search:{tab:"workspace",file:rt??void 0},replace:!0})},[i,t]);T.useEffect(()=>{a&&(_(a.displayName),y(a.startupScript||""),E(a.copyFiles||""),w(a.claudeOptions||{}),R(a.opencodeOptions||{}),N(a.opencodeModel??null),L(a.defaultAgent??null),P(a.isCopierTemplate??!1),H(!1))},[a]),T.useEffect(()=>{if(a){const rt=x!==a.displayName||b!==(a.startupScript||"")||v!==(a.copyFiles||"")||JSON.stringify(C)!==JSON.stringify(a.claudeOptions||{})||JSON.stringify(A)!==JSON.stringify(a.opencodeOptions||{})||O!==(a.opencodeModel??null)||D!==(a.defaultAgent??null)||z!==(a.isCopierTemplate??!1);H(rt)}},[x,b,v,C,A,O,D,z,a]);const Ne=()=>{a&&l.mutate({id:a.id,updates:{displayName:x.trim()||a.path.split("/").pop()||"repo",startupScript:b.trim()||null,copyFiles:v.trim()||null,claudeOptions:Object.keys(C).length>0?C:null,opencodeOptions:Object.keys(A).length>0?A:null,opencodeModel:O,defaultAgent:D,isCopierTemplate:z}},{onSuccess:()=>{_t.success(e("detailView.saved")),H(!1)},onError:rt=>{_t.error(e("detailView.failedToSave"),{description:rt instanceof Error?rt.message:"Unknown error"})}})},qe=async rt=>{a&&(await u.mutateAsync({id:a.id,deleteDirectory:rt}),i({to:"/repositories"}))};T.useEffect(()=>{ye.current=!1,me.current=!1,Z(null),Q(!1)},[a?.path]),T.useEffect(()=>{if(!We||!a?.path||!Ie||pe!=="workspace"||!re){jt.repoTerminal.debug("find/create: waiting",{connected:We,path:a?.path,terminalsLoaded:Ie,activeTab:pe,xtermReady:re});return}const rt=Pe.find(Et=>Et.cwd===a.path&&Et.status==="running");if(rt){jt.repoTerminal.info("found existing terminal",{id:rt.id,cwd:rt.cwd}),Z(rt.id);return}if(!ye.current&&be.current){ye.current=!0,Q(!0);const{cols:Et,rows:pt}=be.current;jt.repoTerminal.info("creating terminal",{name:a.displayName,cwd:a.path,cols:Et,rows:pt}),Te({name:a.displayName,cols:Et,rows:pt,cwd:a.path})}},[We,a?.path,a?.displayName,Ie,Pe,pe,Te,re]),T.useEffect(()=>{if(!a?.path)return;const rt=Pe.find(pt=>pt.cwd===a.path&&pt.status==="running");if(!rt)return;const Et=ne&&Pe.some(pt=>pt.id===ne);(!ne||!Et)&&(Z(rt.id),Q(!1),ne&&!Et&&(me.current=!1))},[Pe,a?.path,ne]);const nt=T.useCallback(rt=>{jt.repoTerminal.info("xterm ready"),be.current=rt,se(!0)},[]),ht=T.useCallback((rt,Et)=>{ne&&fe(ne,rt,Et)},[ne,fe]),gt=T.useCallback(rt=>{jt.repoTerminal.info("container ready"),ce.current=rt,xe(!0)},[]),fn=T.useCallback(rt=>{ne&&_e(ne,rt)},[ne,_e]);return T.useEffect(()=>{if(!ne||!re||!te){jt.repoTerminal.debug("attach effect: waiting",{terminalId:ne,xtermReady:re,containerReady:te});return}if(!be.current||!ce.current){jt.repoTerminal.warn("attach effect: refs not set despite ready states",{terminalId:ne});return}if(me.current){jt.repoTerminal.debug("attach effect: already attached",{terminalId:ne});return}return jt.repoTerminal.info("attaching terminal",{terminalId:ne}),he(ne,be.current),ke(ce.current,ne),me.current=!0,()=>{jt.repoTerminal.debug("detaching terminal",{terminalId:ne}),me.current=!1}},[ne,re,te,he,ke]),s?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):o||!a?f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border bg-background px-4 py-2",children:f.jsxs(Rn,{to:"/repositories",className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:y_e,size:16,strokeWidth:2}),e("detailView.breadcrumb")]})}),f.jsx("div",{className:"flex flex-1 items-center justify-center",children:f.jsxs("div",{className:"flex items-center gap-3 text-destructive",children:[f.jsx(J,{icon:er,size:20,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:e("detailView.notFound")})]})})]}):f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-background px-4 py-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>G(!0),className:"text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:u3,size:16,strokeWidth:2,"data-slot":"icon",className:"-translate-y-px"}),f.jsx("span",{className:"max-sm:hidden",children:e("newTask")})]}),a.isCopierTemplate&&f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>W(!0),className:"text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:O_e,size:16,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("newProject.button")})]}),f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>i({to:"/tasks",search:{repo:a.displayName}}),className:"text-muted-foreground hover:text-foreground",title:e("viewTasks"),children:[f.jsx(J,{icon:wm,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("viewTasks")})]}),f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>Se(a.path,a.displayName),className:"text-muted-foreground hover:text-foreground",title:e("openInTerminal"),children:[f.jsx(J,{icon:Aw,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("terminal")})]}),f.jsxs(Ae,{variant:"ghost",size:"sm",onClick:Xe,className:"text-muted-foreground hover:text-foreground",title:e("openInEditor",{editor:Y3(Ue)}),children:[f.jsx(J,{icon:c3,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("editor")})]}),d?f.jsx(Rn,{to:"/apps",search:{repo:a.displayName},children:f.jsxs(Ae,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:lp,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("applications")})]})}):f.jsxs(Ae,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",onClick:Qe,disabled:g,children:[f.jsx(J,{icon:lp,size:14,strokeWidth:2,"data-slot":"icon"}),f.jsx("span",{className:"max-sm:hidden",children:e("createApp")})]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(lm,{worktreePath:a.path}),f.jsx("span",{className:"text-sm font-medium",children:a.displayName}),p&&f.jsx("a",{href:nlt(p),target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors",title:p,children:f.jsx(J,{icon:p.includes("github.com")?R_e:s3,size:14,strokeWidth:2})}),f.jsx(Ae,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-destructive",onClick:()=>B(!0),children:f.jsx(J,{icon:rs,size:14,strokeWidth:2})})]})]}),f.jsxs(mo,{value:pe,onValueChange:rt=>Fe(rt),className:"flex flex-1 flex-col overflow-hidden",children:[f.jsx("div",{className:"shrink-0 border-b border-border bg-muted/50 px-4",children:f.jsxs(go,{variant:"line",children:[f.jsx(ar,{value:"settings",className:"px-3 py-1.5",children:e("detailView.tabs.settings")}),f.jsx(ar,{value:"workspace",className:"px-3 py-1.5",children:e("detailView.tabs.workspace")})]})}),f.jsx(_r,{value:"settings",className:"flex-1 overflow-hidden mt-0",children:f.jsx(Cg,{className:"h-full",children:f.jsxs("div",{className:"p-4",children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[f.jsx(J,{icon:ua,size:14,strokeWidth:2}),f.jsx("span",{className:"font-mono break-all",children:a.path})]}),f.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[f.jsxs("div",{className:"flex-1 bg-card rounded-lg p-6 border border-border",children:[f.jsx("h3",{className:"text-sm font-medium mb-4",children:e("detailView.settings.generalTitle")}),f.jsxs(up,{children:[f.jsxs(Hn,{children:[f.jsx(Wn,{htmlFor:"displayName",children:e("detailView.settings.displayName")}),f.jsx($t,{id:"displayName",value:x,onChange:rt=>_(rt.target.value),placeholder:a.path.split("/").pop()||"My Project"})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{htmlFor:"startupScript",children:e("detailView.settings.startupScript")}),f.jsx(M0,{id:"startupScript",value:b,onChange:rt=>y(rt.target.value),placeholder:e("detailView.settings.startupScriptPlaceholder"),rows:3}),f.jsx(Sa,{children:e("detailView.settings.startupScriptDescription")})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{htmlFor:"copyFiles",children:e("detailView.settings.copyFiles")}),f.jsx($t,{id:"copyFiles",value:v,onChange:rt=>E(rt.target.value),placeholder:e("detailView.settings.copyFilesPlaceholder")}),f.jsx(Sa,{children:e("detailView.settings.copyFilesDescription")})]}),f.jsxs(Hn,{children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Rr,{checked:z,onCheckedChange:rt=>P(rt===!0)}),f.jsx(Wn,{className:"cursor-pointer",children:e("detailView.settings.isCopierTemplate")})]}),f.jsx(Sa,{children:e("detailView.settings.isCopierTemplateDescription")})]})]})]}),f.jsxs("div",{className:"flex-1 bg-card rounded-lg p-6 border border-border",children:[f.jsx("h3",{className:"text-sm font-medium mb-4",children:e("detailView.settings.agentTitle")}),f.jsxs(up,{children:[f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.defaultAgent")}),f.jsxs(Kr,{value:D??"inherit",onValueChange:rt=>L(rt==="inherit"?null:rt),children:[f.jsx(Xr,{className:"w-full",children:f.jsx(Yr,{})}),f.jsxs(Zr,{alignItemWithTrigger:!1,children:[f.jsx(on,{value:"inherit",children:e("detailView.settings.defaultAgentInherit")}),Object.keys(Pl).map(rt=>f.jsx(on,{value:rt,children:Pl[rt]},rt))]})]}),f.jsx(Sa,{children:e("detailView.settings.defaultAgentDescription")})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.claudeOptions")}),f.jsx(Sa,{className:"mb-2",children:e("detailView.settings.claudeOptionsDescription")}),f.jsx(ZJ,{value:C,onChange:w})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.opencodeOptions")}),f.jsx(Sa,{className:"mb-2",children:e("detailView.settings.opencodeOptionsDescription")}),f.jsx(ZJ,{value:A,onChange:R})]}),f.jsxs(Hn,{children:[f.jsx(Wn,{children:e("detailView.settings.opencodeModel")}),f.jsx(O3,{value:O,onChange:N,placeholder:e("detailView.settings.opencodeModelPlaceholder")}),f.jsx(Sa,{children:e("detailView.settings.opencodeModelDescription")})]})]})]})]}),f.jsx("div",{className:"flex items-center justify-end mt-4",children:f.jsxs(Ae,{size:"sm",onClick:Ne,disabled:!V||l.isPending,children:[f.jsx(J,{icon:Dr,size:14,strokeWidth:2,"data-slot":"icon"}),l.isPending?e("detailView.saving"):e("detailView.save")]})})]})})}),f.jsx(_r,{value:"workspace",className:"flex-1 overflow-hidden mt-0",children:Oe?f.jsxs(mo,{value:ee,onValueChange:rt=>oe(rt),className:"flex min-h-0 flex-1 flex-col h-full",children:[f.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:f.jsxs(go,{className:"w-full",children:[f.jsx(ar,{value:"terminal",className:"flex-1",children:e("detailView.mobileWorkspace.terminal")}),f.jsx(ar,{value:"files",className:"flex-1",children:e("detailView.mobileWorkspace.files")})]})}),f.jsx(_r,{value:"terminal",className:"flex-1 min-h-0",children:f.jsxs("div",{className:"h-full flex flex-col",children:[!We&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:e("detailView.workspace.connectingToTerminal")}),Y&&!ne&&f.jsx("div",{className:"flex-1 flex items-center justify-center bg-terminal-background",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"}),f.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:e("detailView.workspace.initializingTerminal")})]})}),f.jsx(oL,{className:"flex-1",onReady:nt,onResize:ht,onContainerReady:gt,terminalId:ne??void 0,setupImagePaste:ke,onSend:fn})]})}),f.jsx(_r,{value:"files",className:"flex-1 min-h-0",children:f.jsx(rw,{worktreePath:a.path,initialSelectedFile:r,onFileChange:bt})})]}):f.jsxs(wf,{direction:"horizontal",className:"h-full",children:[f.jsx(no,{defaultSize:50,minSize:30,children:f.jsxs("div",{className:"h-full flex flex-col",children:[!We&&f.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:e("detailView.workspace.connectingToTerminal")}),Y&&!ne&&f.jsx("div",{className:"flex-1 flex items-center justify-center bg-terminal-background",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"}),f.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:e("detailView.workspace.initializingTerminal")})]})}),f.jsx(oL,{className:"flex-1",onReady:nt,onResize:ht,onContainerReady:gt,terminalId:ne??void 0,setupImagePaste:ke,onSend:fn})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(no,{defaultSize:50,minSize:30,children:f.jsx(rw,{worktreePath:a.path,initialSelectedFile:r,onFileChange:bt})})]})})]}),f.jsx(R3,{open:j,onOpenChange:G,defaultRepository:a,showTrigger:!1}),f.jsx(Vse,{repository:a,open:q,onOpenChange:B,onDelete:qe}),f.jsx(Wse,{initialTemplateSource:a.id,open:K,onOpenChange:W}),f.jsx(Xo,{open:F,onOpenChange:U,children:f.jsxs(Zo,{children:[f.jsxs(Ul,{children:[f.jsx($l,{children:e("createAppDialog.title")}),f.jsx(Cp,{children:e("createAppDialog.description")})]}),f.jsx("p",{className:"text-sm",children:e("createAppDialog.instructions")}),f.jsx(Fu,{children:f.jsx(Ae,{onClick:()=>U(!1),children:e("createAppDialog.close")})})]})})]})}const aM=Di("/repositories/$repoId")({component:ilt,validateSearch:e=>({tab:e.tab==="workspace"?"workspace":void 0,file:typeof e.file=="string"?e.file:void 0})}),alt=Di("/jobs/new")({component:slt});function slt(){const{t:e}=wt("jobs"),t=Br(),n=uGe(),[r,i]=T.useState(""),[a,s]=T.useState(""),[o,l]=T.useState(""),[u,p]=T.useState(""),[d,m]=T.useState(""),[g,x]=T.useState(!0),[_,b]=T.useState({}),y=()=>{const E={};return r.trim()?/^[a-zA-Z0-9_-]+$/.test(r)||(E.name="Name must contain only alphanumeric characters, hyphens, and underscores"):E.name="Name is required",a.trim()||(E.description="Description is required"),o.trim()||(E.schedule="Schedule is required"),u.trim()||(E.command="Command is required"),b(E),Object.keys(E).length===0},v=async E=>{if(E.preventDefault(),!!y())try{await n.mutateAsync({name:r.trim(),description:a.trim(),schedule:o.trim(),command:u.trim(),workingDirectory:d.trim()||void 0,persistent:g}),_t.success("Job created successfully"),t({to:"/monitoring",search:{tab:"jobs"}})}catch(C){_t.error(C instanceof Error?C.message:"Failed to create job")}};return f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-4 border-b border-border bg-background px-4 py-3",children:[f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},className:"text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:qu,size:20,strokeWidth:2})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(J,{icon:Tw,size:20,strokeWidth:2,className:"text-muted-foreground"}),f.jsx("h1",{className:"text-lg font-semibold",children:e("create.title")})]})]}),f.jsx("div",{className:"flex-1 overflow-auto p-4",children:f.jsxs("form",{onSubmit:v,className:"mx-auto max-w-2xl space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"name",children:e("create.name")}),f.jsx($t,{id:"name",value:r,onChange:E=>i(E.target.value),placeholder:e("create.namePlaceholder"),className:_.name?"border-destructive":""}),_.name?f.jsx("p",{className:"text-sm text-destructive",children:_.name}):f.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.nameHelp")})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"description",children:e("create.description")}),f.jsx($t,{id:"description",value:a,onChange:E=>s(E.target.value),placeholder:e("create.descriptionPlaceholder"),className:_.description?"border-destructive":""}),_.description&&f.jsx("p",{className:"text-sm text-destructive",children:_.description})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"schedule",children:e("create.schedule")}),f.jsx($t,{id:"schedule",value:o,onChange:E=>l(E.target.value),placeholder:"*-*-* 02:00:00",className:_.schedule?"border-destructive":""}),_.schedule?f.jsx("p",{className:"text-sm text-destructive",children:_.schedule}):f.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.scheduleHelp")}),f.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[f.jsx("span",{className:"text-muted-foreground",children:"Examples:"}),f.jsx("button",{type:"button",onClick:()=>l("daily"),className:"text-primary hover:underline",children:"daily"}),f.jsx("button",{type:"button",onClick:()=>l("weekly"),className:"text-primary hover:underline",children:"weekly"}),f.jsx("button",{type:"button",onClick:()=>l("*-*-* 02:00:00"),className:"text-primary hover:underline",children:"*-*-* 02:00:00"}),f.jsx("button",{type:"button",onClick:()=>l("Mon..Fri 09:00"),className:"text-primary hover:underline",children:"Mon..Fri 09:00"})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"command",children:e("create.command")}),f.jsx(M0,{id:"command",value:u,onChange:E=>p(E.target.value),placeholder:e("create.commandPlaceholder"),className:`font-mono ${_.command?"border-destructive":""}`,rows:3}),_.command&&f.jsx("p",{className:"text-sm text-destructive",children:_.command})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"workingDir",children:e("create.workingDir")}),f.jsx($t,{id:"workingDir",value:d,onChange:E=>m(E.target.value),placeholder:e("create.workingDirPlaceholder")})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Rr,{id:"persistent",checked:g,onCheckedChange:E=>x(E===!0)}),f.jsxs("div",{className:"grid gap-1.5 leading-none",children:[f.jsx(Vi,{htmlFor:"persistent",className:"cursor-pointer",children:e("create.persistent")}),f.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.persistentHelp")})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2 pt-4",children:[f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},children:f.jsx(Ae,{type:"button",variant:"outline",children:e("create.cancel")})}),f.jsxs(Ae,{type:"submit",disabled:n.isPending,children:[n.isPending&&f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin","data-slot":"icon"}),e("create.create")]})]})]})})]})}const sM=Di("/jobs/$jobId")({component:clt,validateSearch:e=>({tab:["general","logs"].includes(e.tab)?e.tab:void 0,scope:["user","system"].includes(e.scope)?e.scope:void 0})});function olt(e,t){if(!t)return"bg-gray-400";switch(e){case"active":return"bg-green-500";case"waiting":return"bg-blue-500";case"failed":return"bg-red-500";default:return"bg-gray-400"}}function llt(e,t){if(!t)return"outline";switch(e){case"active":return"default";case"waiting":return"secondary";case"failed":return"destructive";default:return"outline"}}function QJ(e){return e?new Date(e).toLocaleString():"-"}function JJ(e){if(!e)return"-";const t=new Date(e),n=new Date,r=t.getTime()-n.getTime(),i=r<0,a=Math.abs(r),s=Math.floor(a/6e4),o=Math.floor(s/60),l=Math.floor(o/24);let u;return s<60?u=`${s}m`:o<24?u=`${o}h ${s%60}m`:u=`${l}d ${o%24}h`,i?`${u} ago`:`in ${u}`}function eee(e){if(e===null||e<0)return"-";const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m ${t%60}s`:n>0?`${n}m ${t%60}s`:t>0?`${t}.${Math.floor(e%1e3/100)}s`:`${e}ms`}function bv(e){const t={us:"microsecond",usec:"microsecond",ms:"millisecond",msec:"millisecond",s:"second",sec:"second",second:"second",seconds:"second",m:"minute",min:"minute",minute:"minute",minutes:"minute",h:"hour",hr:"hour",hour:"hour",hours:"hour",d:"day",day:"day",days:"day",w:"week",week:"week",weeks:"week",M:"month",month:"month",months:"month",y:"year",year:"year",years:"year"},n=/(\d+)\s*(us|usec|ms|msec|s|sec|seconds?|m|min|minutes?|h|hr|hours?|d|days?|w|weeks?|M|months?|y|years?)/gi,r=[];let i;for(;(i=n.exec(e))!==null;){const a=parseInt(i[1],10),s=i[2].toLowerCase(),o=t[s]||s,l=a!==1?"s":"";r.push(`${a} ${o}${l}`)}return r.length>0?r.join(" "):e}function tee(e){if(!e)return[];const t=[],n=e.split(/,\s*/);for(const r of n){const i=r.trim();if(i.startsWith("OnStartupSec=")){const a=i.replace("OnStartupSec=","");t.push(`${bv(a)} after startup`)}else if(i.startsWith("OnBootSec=")){const a=i.replace("OnBootSec=","");t.push(`${bv(a)} after boot`)}else if(i.startsWith("OnUnitActiveSec=")){const a=i.replace("OnUnitActiveSec=","");t.push(`Every ${bv(a)}`)}else if(i.startsWith("OnUnitInactiveSec=")){const a=i.replace("OnUnitInactiveSec=","");t.push(`${bv(a)} after becoming inactive`)}else if(i.startsWith("OnActiveSec=")){const a=i.replace("OnActiveSec=","");t.push(`${bv(a)} after timer activation`)}else i&&t.push(i)}return t}function ult({entry:e}){const t={error:"text-red-500",warning:"text-yellow-500",info:"text-foreground"}[e.priority],n=new Date(e.timestamp).toLocaleTimeString();return f.jsxs("div",{className:`font-mono text-xs ${t}`,children:[f.jsx("span",{className:"text-muted-foreground",children:n})," ",f.jsx("span",{children:e.message})]})}function clt(){const{t:e}=wt("jobs"),{jobId:t}=sM.useParams(),{tab:n,scope:r="user"}=sM.useSearch(),i=Br(),a=n||"general",{data:s,isLoading:o,error:l,refetch:u}=oGe(t,r),{data:p,refetch:d}=lGe(t,r,200),m=_ce(),g=Sce(),x=Ece(),_=xce(),[b,y]=T.useState(!1),v=t.replace(".timer",""),E=r==="system",C=O=>{i({to:"/jobs/$jobId",params:{jobId:t},search:{tab:O!=="general"?O:void 0,scope:r},replace:!0})},w=async()=>{if(s)try{s.enabled?(await g.mutateAsync({name:s.name,scope:s.scope}),_t.success(e("actions.disable")+" successful")):(await m.mutateAsync({name:s.name,scope:s.scope}),_t.success(e("actions.enable")+" successful")),u()}catch(O){_t.error(O instanceof Error?O.message:"Failed")}},A=async()=>{if(s)try{await x.mutateAsync({name:s.name,scope:s.scope}),_t.success(e("actions.runNow")+" triggered"),u(),d()}catch(O){_t.error(O instanceof Error?O.message:"Failed")}},R=async()=>{if(s){try{await _.mutateAsync(s.name),_t.success("Job deleted"),i({to:"/monitoring",search:{tab:"jobs"}})}catch(O){_t.error(O instanceof Error?O.message:"Failed to delete")}y(!1)}};return o?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):l||!s?f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[f.jsx(J,{icon:er,size:48,strokeWidth:1.5,className:"text-destructive opacity-50"}),f.jsx("p",{className:"text-muted-foreground",children:l?.message||"Job not found"}),f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},children:f.jsxs(Ae,{variant:"outline",children:[f.jsx(J,{icon:qu,size:16,strokeWidth:2,"data-slot":"icon"}),e("title")]})})]}):f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"shrink-0 border-b border-border bg-background px-4 py-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Rn,{to:"/monitoring",search:{tab:"jobs"},className:"shrink-0 text-muted-foreground hover:text-foreground",children:f.jsx(J,{icon:qu,size:20,strokeWidth:2})}),f.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full ${olt(s.state,s.enabled)}`}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("h1",{className:"truncate text-lg font-semibold",children:v}),f.jsx(Jr,{variant:llt(s.state,s.enabled),children:s.enabled?e(`status.${s.state}`):e("status.disabled")}),E&&f.jsxs(Jr,{variant:"outline",className:"gap-1",children:[f.jsx(J,{icon:Ine,size:10,strokeWidth:2}),e("scope.system")]})]}),s.description&&f.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground line-clamp-2",children:s.description})]})]}),!E&&f.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[f.jsxs(Ae,{variant:"outline",size:"sm",onClick:A,disabled:x.isPending,children:[x.isPending?f.jsx(J,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin","data-slot":"icon"}):f.jsx(J,{icon:Cm,size:14,strokeWidth:2,"data-slot":"icon"}),e("actions.runNow")]}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:w,disabled:m.isPending||g.isPending,children:[f.jsx(J,{icon:s.enabled?Tm:Cm,size:14,strokeWidth:2,"data-slot":"icon"}),s.enabled?e("actions.disable"):e("actions.enable")]}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:()=>y(!0),className:"text-destructive hover:text-destructive",children:[f.jsx(J,{icon:rs,size:14,strokeWidth:2,"data-slot":"icon"}),e("actions.delete")]})]})]}),f.jsxs(mo,{value:a,onValueChange:O=>C(O),className:"flex flex-1 flex-col overflow-hidden",children:[f.jsxs(go,{className:"mx-4 mt-2 w-fit",children:[f.jsx(ar,{value:"general",children:e("detail.tabs.general")}),f.jsx(ar,{value:"logs",children:e("detail.tabs.logs")})]}),f.jsx(_r,{value:"general",className:"flex-1 overflow-auto p-4",children:f.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[f.jsxs("div",{className:"space-y-4 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.schedule")}),f.jsxs("div",{className:"rounded-lg border p-4 space-y-3 overflow-hidden",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(J,{icon:Tw,size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground mt-0.5"}),f.jsx("div",{className:"min-w-0 flex-1 flex flex-col gap-1",children:tee(s.schedule).length>0?tee(s.schedule).map((O,N)=>f.jsx("span",{className:"break-all text-sm",children:O},N)):f.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),f.jsxs("div",{className:`grid gap-4 text-sm ${s.nextRun?"grid-cols-1 sm:grid-cols-2":"grid-cols-1"}`,children:[s.nextRun&&f.jsxs("div",{children:[f.jsx("div",{className:"text-muted-foreground",children:e("detail.nextRun")}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx(J,{icon:One,size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),f.jsx("span",{children:JJ(s.nextRun)})]}),f.jsx("div",{className:"text-xs text-muted-foreground",children:QJ(s.nextRun)})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-muted-foreground",children:e("detail.lastRun")}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s.lastResult==="success"&&f.jsx(J,{icon:vo,size:14,strokeWidth:2,className:"shrink-0 text-green-500"}),s.lastResult==="failed"&&f.jsx(J,{icon:Mr,size:14,strokeWidth:2,className:"shrink-0 text-red-500"}),f.jsx("span",{children:JJ(s.lastRun)})]}),f.jsx("div",{className:"text-xs text-muted-foreground",children:QJ(s.lastRun)})]})]})]})]}),f.jsxs("div",{className:"space-y-4 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.command")}),f.jsxs("div",{className:"rounded-lg border p-4 space-y-3 overflow-hidden",children:[s.command?f.jsx("code",{className:"block whitespace-pre-wrap break-all rounded bg-muted px-2 py-1 text-sm font-mono",children:s.command}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"-"}),s.workingDirectory&&f.jsxs("div",{className:"text-sm break-all",children:[f.jsxs("span",{className:"text-muted-foreground",children:[e("detail.workingDir"),": "]}),f.jsx("code",{className:"font-mono break-all",children:s.workingDirectory})]})]})]}),(s.lastRunDurationMs!==null||s.lastRunCpuTimeMs!==null)&&f.jsxs("div",{className:"space-y-4",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.executionStats")}),f.jsx("div",{className:"rounded-lg border p-4 space-y-3",children:f.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[f.jsx(J,{icon:z_e,size:14,strokeWidth:2}),e("detail.duration")]}),f.jsx("div",{className:"font-mono",children:eee(s.lastRunDurationMs)})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5",children:[f.jsx(J,{icon:E_e,size:14,strokeWidth:2}),e("detail.cpuTime")]}),f.jsx("div",{className:"font-mono",children:eee(s.lastRunCpuTimeMs)})]})]})})]}),!E&&s.timerContent&&f.jsxs("div",{className:"space-y-4 md:col-span-2 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.timerFile")}),f.jsx("pre",{className:"rounded-lg border bg-muted p-4 text-xs font-mono overflow-y-auto max-h-48 whitespace-pre-wrap break-all",children:s.timerContent})]}),!E&&s.serviceContent&&f.jsxs("div",{className:"space-y-4 md:col-span-2 min-w-0",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("detail.serviceFile")}),f.jsx("pre",{className:"rounded-lg border bg-muted p-4 text-xs font-mono overflow-y-auto max-h-48 whitespace-pre-wrap break-all",children:s.serviceContent})]})]})}),f.jsxs(_r,{value:"logs",className:"flex flex-1 flex-col overflow-hidden p-4",children:[f.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[f.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:e("logs.title")}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:()=>d(),children:[f.jsx(J,{icon:Nw,size:14,strokeWidth:2,"data-slot":"icon"}),e("logs.refresh")]})]}),f.jsx("div",{className:"flex-1 overflow-auto rounded-lg border bg-muted p-4",children:p?.entries&&p.entries.length>0?f.jsx("div",{className:"space-y-1",children:p.entries.map((O,N)=>f.jsx(ult,{entry:O},N))}):f.jsx("p",{className:"text-center text-muted-foreground text-sm",children:e("logs.noLogs")})})]})]}),f.jsx(Oa,{open:b,onOpenChange:y,children:f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:e("delete.title")}),f.jsx(La,{children:e("delete.confirm",{name:v})})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{children:e("delete.cancel")}),f.jsx(ec,{onClick:R,className:"bg-destructive text-destructive-foreground",children:e("delete.delete")})]})]})})]})}function dlt({className:e,...t}){return f.jsx(tCe,{"data-slot":"radio-group",className:Be("grid gap-3 w-full",e),...t})}function nee({className:e,...t}){return f.jsx(Qwe,{"data-slot":"radio-group-item",className:Be("border-input text-primary dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 data-checked:bg-primary data-checked:border-primary flex size-4 rounded-full transition-none focus-visible:ring-[2px] aria-invalid:ring-[2px] group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:f.jsx(Jwe,{"data-slot":"radio-group-indicator",className:"group-aria-invalid/radio-group-item:text-destructive flex size-4 items-center justify-center text-white",children:f.jsx(J,{icon:__e,strokeWidth:2,className:"absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 fill-current"})})})}const upe=Di("/apps/new")({component:flt,validateSearch:e=>({repoId:typeof e.repoId=="string"?e.repoId:void 0})});function flt(){const e=Br(),{repoId:t}=upe.useSearch(),{data:n,isLoading:r}=wg(),{data:i}=G3(),a=MIe(),s=i?.tunnelsAvailable??!1,[o,l]=T.useState("select-repo"),[u,p]=T.useState(null),[d,m]=T.useState(""),g=T.useRef(null),[x,_]=T.useState(""),[b,y]=T.useState(""),[v,E]=T.useState(!1),[C,w]=T.useState([]);T.useEffect(()=>{if(t&&n&&!u){const q=n.find(B=>B.id===t);q&&(p(q),_(q.displayName))}},[t,n,u,_]),T.useEffect(()=>{if(t&&u&&g.current){const q=g.current.querySelector(`[data-repo-id="${u.id}"]`);q&&q.scrollIntoView({behavior:"smooth",block:"nearest"})}},[t,u]);const{data:A,isLoading:R,error:O}=V3(u?.id??null),{data:N,isLoading:D}=BIe(A?.found?u?.id??null:null),{data:L}=rie(u?.path??null);T.useEffect(()=>{L?.defaultBranch&&!b&&y(L.defaultBranch)},[L?.defaultBranch,b]);const z=T.useMemo(()=>n?d?.trim()?n.map(q=>({repo:q,score:Math.max(Ki(q.displayName,d),Ki(q.path,d))})).filter(({score:q})=>q>0).sort((q,B)=>B.score-q.score).map(({repo:q})=>q):n:[],[n,d]),P=q=>{w(q.map(B=>({serviceName:B.name,containerPort:B.ports?.[0]?.container??null,exposed:!1,domain:"",exposureMethod:"dns"})))},V=q=>{p(q),_(q.displayName),y("")},H=()=>{N&&P(N.services),l("configure-services")},j=(q,B)=>{w(F=>F.map((U,K)=>K===q?{...U,...B}:U))},G=async()=>{if(!(!u||!N))try{const q=await a.mutateAsync({name:x,repositoryId:u.id,branch:b||L?.defaultBranch||"main",composeFile:N.file,autoDeployEnabled:v,services:C.map(B=>({serviceName:B.serviceName,containerPort:B.containerPort??void 0,exposed:B.exposed,domain:B.domain||void 0,exposureMethod:B.exposureMethod}))});e({to:"/apps/$appId",params:{appId:q.id}})}catch{}};return f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border bg-background px-4 py-2",children:[f.jsxs(Rn,{to:"/apps",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[f.jsx(J,{icon:qu,size:16,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:"Apps"})]}),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"text-sm text-muted-foreground",children:["Step ",o==="select-repo"?"1":"2"," of 2"]})]}),f.jsx("div",{className:"flex-1 overflow-auto p-4",children:o==="select-repo"?f.jsx("div",{className:"mx-auto max-w-2xl",children:f.jsxs(ei,{children:[f.jsx(zS,{children:f.jsx(HS,{children:"Select Repository"})}),f.jsxs(ka,{className:"space-y-4",children:[f.jsxs("div",{className:"relative",children:[f.jsx(J,{icon:wp,size:14,strokeWidth:2,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),f.jsx($t,{value:d,onChange:q=>m(q.target.value),placeholder:"Search repositories...",className:"pl-9"})]}),r?f.jsx("div",{className:"flex items-center justify-center py-8",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):f.jsxs("div",{ref:g,className:"space-y-2 max-h-80 overflow-auto",children:[z.map(q=>f.jsx(plt,{repo:q,selected:u?.id===q.id,onSelect:()=>V(q)},q.id)),z.length===0&&f.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:"No repositories found"})]}),u&&f.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:R||D?f.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),f.jsx("span",{className:"text-sm",children:"Checking for compose file..."})]}):O?f.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[f.jsx(J,{icon:er,size:16,strokeWidth:2}),f.jsxs("span",{className:"text-sm",children:["Error: ",O.message]})]}):A?.found?f.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[f.jsx(J,{icon:vo,size:16,strokeWidth:2}),f.jsxs("span",{className:"text-sm",children:["Found ",A.file,N&&` with ${N.services.length} service(s)`]})]}):f.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[f.jsx(J,{icon:Mr,size:16,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:"No compose file found in this repository"})]})}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Rn,{to:"/apps",children:f.jsx(Ae,{variant:"outline",children:"Cancel"})}),f.jsxs(Ae,{onClick:H,disabled:!u||!A?.found||!N,children:["Next",f.jsx(J,{icon:Mu,size:16,strokeWidth:2})]})]})]})]})}):f.jsx("div",{className:"mx-auto max-w-2xl",children:f.jsxs(ei,{children:[f.jsxs(zS,{children:[f.jsx(HS,{children:"Configure App"}),f.jsxs("p",{className:"text-sm text-muted-foreground",children:[u?.displayName," · ",N?.file]})]}),f.jsxs(ka,{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"appName",children:"App Name"}),f.jsx($t,{id:"appName",value:x,onChange:q=>_(q.target.value),placeholder:"my-app"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:"branch",children:"Branch"}),f.jsx($t,{id:"branch",value:b,onChange:q=>y(q.target.value),placeholder:L?.defaultBranch??"main"})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsx(Vi,{children:"Services"}),f.jsx("div",{className:"space-y-3",children:C.map((q,B)=>f.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-medium",children:q.serviceName}),q.containerPort&&f.jsxs(Jr,{variant:"secondary",children:[":",q.containerPort]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Rr,{id:`expose-${B}`,checked:q.exposed,onCheckedChange:F=>j(B,{exposed:F===!0})}),f.jsx(Vi,{htmlFor:`expose-${B}`,className:"text-sm",children:"Expose"})]})]}),q.exposed&&f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{htmlFor:`domain-${B}`,className:"text-sm",children:"Domain"}),f.jsx($t,{id:`domain-${B}`,value:q.domain,onChange:F=>j(B,{domain:F.target.value}),placeholder:"app.example.com"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vi,{className:"text-sm",children:"Exposure Method"}),f.jsxs(dlt,{value:q.exposureMethod,onValueChange:F=>j(B,{exposureMethod:F}),className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(nee,{value:"dns",id:`dns-${B}`}),f.jsx(Vi,{htmlFor:`dns-${B}`,className:"text-sm font-normal cursor-pointer",children:"DNS (requires public IP and port forwarding)"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(nee,{value:"tunnel",id:`tunnel-${B}`,disabled:!s}),f.jsx(Vi,{htmlFor:`tunnel-${B}`,className:`text-sm font-normal cursor-pointer ${s?"":"text-muted-foreground"}`,children:"Cloudflare Tunnel (no public IP required)"})]})]}),!s&&f.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure Cloudflare Account ID in settings to enable tunnels"})]})]})]},q.serviceName))})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Rr,{id:"autoDeployEnabled",checked:v,onCheckedChange:q=>E(q===!0)}),f.jsxs(Vi,{htmlFor:"autoDeployEnabled",children:["Auto-deploy on push to ",b]})]}),f.jsxs("div",{className:"flex justify-between gap-2",children:[f.jsxs(Ae,{variant:"outline",onClick:()=>l("select-repo"),children:[f.jsx(J,{icon:qu,size:16,strokeWidth:2}),"Back"]}),f.jsx(Ae,{onClick:G,disabled:!x||a.isPending,children:a.isPending?f.jsxs(f.Fragment,{children:[f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Creating..."]}):"Create App"})]}),a.error&&f.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[f.jsx(J,{icon:er,size:16,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:a.error.message})]})]})]})})})]})}function plt({repo:e,selected:t,onSelect:n}){return f.jsxs("button",{type:"button","data-repo-id":e.id,onClick:n,className:`w-full rounded-lg border p-3 text-left transition-colors ${t?"border-primary bg-primary/5":"border-border hover:border-foreground/20 hover:bg-muted/50"}`,children:[f.jsx("div",{className:"font-medium",children:e.displayName}),f.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:e.path})]})}const hlt=/error|exception|failed|uncaught|fatal|crash|errno|reject/i,mlt=/warning|deprecated|caution|unstable|⚠️/i,glt=/successfully|completed|listening|connected|ready|started|✓|✅|done|healthy|pulled|created|recreated/i,blt=/debug|version|config|import|GET|POST|PUT|DELETE/i;function vlt(e){return hlt.test(e)?"error":mlt.test(e)?"warning":glt.test(e)?"success":blt.test(e)?"debug":"info"}function MB(e){return e.split(`
|
|
177
177
|
`).filter(t=>t.trim()).map(t=>({message:t,type:vlt(t)}))}var nD,ree;function ylt(){if(ree)return nD;ree=1;var e=/["'&<>]/;nD=t;function t(n){var r=""+n,i=e.exec(r);if(!i)return r;var a,s="",o=0,l=0;for(o=i.index;o<r.length;o++){switch(r.charCodeAt(o)){case 34:a=""";break;case 38:a="&";break;case 39:a="'";break;case 60:a="<";break;case 62:a=">";break;default:continue}l!==o&&(s+=r.substring(l,o)),l=o+1,s+=a}return l!==o?s+r.substring(l,o):s}return nD}var xlt=ylt();const _lt=An(xlt),Nn={black:"#2e3436",red:"#cc0000",green:"#4e9a06",yellow:"#c4a000",blue:"#3465a4",magenta:"#75507b",cyan:"#06989a",white:"#d3d7cf","bright-black":"#555753","bright-red":"#ef2929","bright-green":"#8ae234","bright-yellow":"#fce94f","bright-blue":"#729fcf","bright-magenta":"#ad7fa8","bright-cyan":"#34e2e2","bright-white":"#eeeeec"};function cpe({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}const Slt=/^(?:\x1b\[([\x3c-\x3f]?)([\d;]*)([\x20-\x2f]?[\x40-\x7e]))|(?:\x1b\[[\x20-\x7e]*([\x00-\x1f:]))/,Elt=/^\x1b\]8;[\x20-\x3a\x3c-\x7e]*;([\x21-\x7e]{0,512})(?:(?:\x1b\\)|(?:\x07))([\x20-\x7e]+)\x1b\]8;;(?:(?:\x1b\\)|(?:\x07))/,wlt=/(?:(\x1b\\)|(\x07))|([\x00-\x06]|[\x08-\x1a]|[\x1c-\x1f])/g;class Clt{constructor(t){this.lastIndex=0,this.input=t}next(){const t=this.input.substring(this.lastIndex),n=t.length;if(n===0)return{value:null,done:!0};const r={kind:0,text:"",url:""},i=t.indexOf("\x1B");if(i===-1)return r.kind=1,r.text=t,this.lastIndex+=n,{value:r,done:!1};if(i>0)return r.kind=1,r.text=t.slice(0,i),this.lastIndex+=i,{value:r,done:!1};if(n<3)return{value:null,done:!0};const a=t.charAt(1);if(a!=="["&&a!=="]"&&a!=="(")return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1};if(a==="["){const s=t.match(Slt);return s===null?{value:null,done:!0}:s[4]?(r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}):(s[1]!==""||s[3]!=="m"?r.kind=3:r.kind=4,r.text=s[2],this.lastIndex+=s[0].length,{value:r,done:!1})}if(a==="]"){if(n<4)return{value:null,done:!0};if(t.charAt(2)!=="8"||t.charAt(3)!==";")return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1};const s=new RegExp(wlt);{const l=s.exec(t);if(l===null)return{value:null,done:!0};if(l[3])return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}}{const l=s.exec(t);if(l===null)return{value:null,done:!0};if(l[3])return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}}const o=t.match(Elt);return o===null?(r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}):(r.kind=5,r.url=o[1],r.text=o[2],this.lastIndex+=o[0].length,{value:r,done:!1})}return a==="("?(r.kind=3,this.lastIndex+=3,{value:r,done:!1}):{value:null,done:!0}}[Symbol.iterator](){return this}}const dpe=14,Fa=new Array(dpe);Fa[0]="background-color";Fa[1]="color";Fa[2]="font-family";Fa[3]="font-size";Fa[4]="font-style";Fa[5]="font-weight";Fa[6]="opacity";Fa[7]="outline";Fa[8]="text-decoration";Fa[9]="text-decoration-color";Fa[10]="text-decoration-line";Fa[11]="text-decoration-style";Fa[12]="vertical-align";Fa[13]="visibility";class ma{constructor(){this.attrArray=new Array(dpe),this._size=0}get(t){return this.attrArray[t]}set(t,n){const r=this.attrArray[t];this.attrArray[t]=n,r===void 0&&n!==void 0&&(this._size+=1)}delete(t){const n=this.attrArray[t];this.attrArray[t]=void 0,n!==void 0&&(this._size-=1)}update(t){for(const n in t)if(t.hasOwnProperty(n)){const r=t[n];this.attrArray[n]=r,r!==void 0&&(this._size+=1)}}clear(){this.attrArray.fill(void 0),this._size=0}get size(){return this._size}toString(){let t="";return this.attrArray.forEach((n,r)=>{n!==void 0&&(t+=`${Fa[r]}:${n};`)}),t}static delete(...t){return n=>{t.forEach(r=>{n.delete(r)})}}static appendVal(t,n){return r=>{const i=r.get(t),a=i?i.split(" "):[];a.includes(n)||a.push(n),r.set(t,a.join(" "))}}static removeVal(t,n){return r=>{const i=r.get(t);let a=i?i.split(" "):[];a=a.filter(s=>s!==n),a.length?r.set(t,a.join(" ")):r.delete(t)}}}cpe();cpe({onlyFirst:!0});const kt=new Array(108);kt[0]={5:"var(--ansi-bold-font-weight, 600)"};kt[1]={5:"var(--ansi-bold-font-weight, 600)"};kt[2]={6:"var(--ansi-dim-opacity, 0.7)"};kt[3]={4:"italic"};kt[4]=ma.appendVal(8,"underline");kt[8]={13:"hidden"};kt[9]=ma.appendVal(8,"line-through");kt[10]=ma.delete(2);kt[11]={2:"var(--ansi-font-1)"};kt[12]={2:"var(--ansi-font-2)"};kt[13]={2:"var(--ansi-font-3)"};kt[14]={2:"var(--ansi-font-4)"};kt[15]={2:"var(--ansi-font-5)"};kt[16]={2:"var(--ansi-font-6)"};kt[17]={2:"var(--ansi-font-7)"};kt[18]={2:"var(--ansi-font-8)"};kt[19]={2:"var(--ansi-font-9)"};kt[21]={10:"underline",11:"double"};kt[22]=ma.delete(5);kt[23]=ma.delete(4);kt[24]=ma.removeVal(8,"underline");kt[28]=ma.delete(13);kt[29]=ma.removeVal(8,"line-through");kt[30]={1:`var(--ansi-black, ${Nn.black})`};kt[31]={1:`var(--ansi-red, ${Nn.red})`};kt[32]={1:`var(--ansi-green, ${Nn.green})`};kt[33]={1:`var(--ansi-yellow, ${Nn.yellow})`};kt[34]={1:`var(--ansi-blue, ${Nn.blue})`};kt[35]={1:`var(--ansi-magenta, ${Nn.magenta})`};kt[36]={1:`var(--ansi-cyan, ${Nn.cyan})`};kt[37]={1:`var(--ansi-white, ${Nn.white})`};kt[39]=ma.delete(1);kt[40]={0:`var(--ansi-black, ${Nn.black})`};kt[41]={0:`var(--ansi-red, ${Nn.red})`};kt[42]={0:`var(--ansi-green, ${Nn.green})`};kt[43]={0:`var(--ansi-yellow, ${Nn.yellow})`};kt[44]={0:`var(--ansi-blue, ${Nn.blue})`};kt[45]={0:`var(--ansi-magenta, ${Nn.magenta})`};kt[46]={0:`var(--ansi-cyan, ${Nn.cyan})`};kt[47]={0:`var(--ansi-white, ${Nn.white})`};kt[49]=ma.delete(0);kt[51]={7:"var(--ansi-frame-outline, 1px solid)"};kt[53]=ma.appendVal(8,"overline");kt[54]=ma.delete(7);kt[55]=ma.removeVal(8,"overline");kt[59]=ma.delete(9);kt[73]={12:"super",3:"var(--ansi-superscript-font-size, 80%)"};kt[74]={12:"sub",3:"var(--ansi-subscript-font-size, 80%)"};kt[75]=ma.delete(12,3);kt[90]={1:`var(--ansi-bright-black, ${Nn["bright-black"]})`};kt[91]={1:`var(--ansi-bright-red, ${Nn["bright-red"]})`};kt[92]={1:`var(--ansi-bright-green, ${Nn["bright-green"]})`};kt[93]={1:`var(--ansi-bright-yellow, ${Nn["bright-yellow"]})`};kt[94]={1:`var(--ansi-bright-blue, ${Nn["bright-blue"]})`};kt[95]={1:`var(--ansi-bright-magenta, ${Nn["bright-magenta"]})`};kt[96]={1:`var(--ansi-bright-cyan, ${Nn["bright-cyan"]})`};kt[97]={1:`var(--ansi-bright-white, ${Nn["bright-white"]})`};kt[100]={0:`var(--ansi-bright-black, ${Nn["bright-black"]})`};kt[101]={0:`var(--ansi-bright-red, ${Nn["bright-red"]})`};kt[102]={0:`var(--ansi-bright-green, ${Nn["bright-green"]})`};kt[103]={0:`var(--ansi-bright-yellow, ${Nn["bright-yellow"]})`};kt[104]={0:`var(--ansi-bright-blue, ${Nn["bright-blue"]})`};kt[105]={0:`var(--ansi-bright-magenta, ${Nn["bright-magenta"]})`};kt[106]={0:`var(--ansi-bright-cyan, ${Nn["bright-cyan"]})`};kt[107]={0:`var(--ansi-bright-white, ${Nn["bright-white"]})`};const Ji=new Array(16);Ji[0]="black";Ji[1]="red";Ji[2]="green";Ji[3]="yellow";Ji[4]="blue";Ji[5]="magenta";Ji[6]="cyan";Ji[7]="white";Ji[8]="bright-black";Ji[9]="bright-red";Ji[10]="bright-green";Ji[11]="bright-yellow";Ji[12]="bright-blue";Ji[13]="bright-magenta";Ji[14]="bright-cyan";Ji[15]="bright-white";function fpe(e){switch(e){case"38":return 1;case"48":return 0;case"58":return 9;default:throw new Error("not implemented")}}function Tlt(e,t){const n=e.text.split(";");if(n.length!==3)return;const r=fpe(n[0]),i=parseInt(n[2],10);if(0<=i&&i<=15){const a=Ji[i];t.set(r,`var(--ansi-${a}, ${Nn[a]})`)}else if(16<=i&&i<=231){const a=i-16,s=[0,95,135,175,215,255],o=s[a/36%6|0],l=s[a/6%6|0],u=s[a%6];t.set(r,`rgb(${o},${l},${u})`)}else if(232<=i&&i<=255){const a=8+(i-232)*10;t.set(r,`var(--ansi-gray-${256-i}, rgb(${a},${a},${a}))`)}}function Alt(e,t){const n=e.text.split(";");if(n.length!==5)return;const r=fpe(n[0]),[,,i,a,s]=n;t.set(r,`rgb(${i},${a},${s})`)}function klt(e,t){if(/^(38|48|58);(2|5);/.test(e.text)){e.text[3]==="2"?Alt(e,t):Tlt(e,t);return}e.text.split(";").forEach(n=>{const r=parseInt(n||"0",10);if(r===0){t.clear();return}const i=kt[r];i&&(typeof i=="function"?i(t):t.update(i))})}class Olt{toHtml(t){const n=new ma;let r="",i=!1;return Array.from(new Clt(t)).forEach(a=>{switch(a.kind){case 1:r+=_lt(a.text);break;case 4:i&&(r+="</span>",i=!1),klt(a,n),n.size&&(r+=`<span style="${n.toString()}">`,i=!0);break}}),i&&(r+="</span>"),r}}const Rlt=new Olt,Nlt={error:{bg:"bg-red-500/10 hover:bg-red-500/15",badge:"bg-red-600/20 text-red-600 dark:bg-red-500/15 dark:text-red-400",border:"bg-red-500"},warning:{bg:"bg-yellow-500/10 hover:bg-yellow-500/15",badge:"bg-yellow-600/20 text-yellow-600 dark:bg-yellow-500/15 dark:text-yellow-400",border:"bg-yellow-500"},success:{bg:"bg-green-500/10 hover:bg-green-500/15",badge:"bg-emerald-600/20 text-emerald-600 dark:bg-emerald-500/15 dark:text-emerald-400",border:"bg-green-500"},info:{bg:"hover:bg-muted/50",badge:"bg-blue-600/20 text-blue-600 dark:bg-blue-500/15 dark:text-blue-400",border:"bg-blue-500"},debug:{bg:"bg-orange-500/10 hover:bg-orange-500/15",badge:"bg-orange-600/20 text-orange-600 dark:bg-orange-500/15 dark:text-orange-400",border:"bg-orange-500"}};function jB({message:e,type:t}){const n=Nlt[t],r=Rlt.toHtml(e);return f.jsxs("div",{className:Be("flex items-start gap-2 py-0.5 font-mono text-xs",n.bg),children:[f.jsx("div",{className:Be("w-0.5 self-stretch rounded-full shrink-0",n.border)}),f.jsx("span",{className:Be("shrink-0 rounded px-1 py-0.5 text-[10px] font-medium w-12 text-center",n.badge),children:t}),f.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",dangerouslySetInnerHTML:{__html:r}})]})}function Ilt(){return f.jsx(qIe,{children:f.jsx(Plt,{})})}const oM=Di("/apps/$appId")({component:Ilt,validateSearch:e=>({tab:["general","deployments","logs","monitoring"].includes(e.tab)?e.tab:void 0,action:e.action==="deploy"?"deploy":void 0})});function Dlt(e,t){const n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.floor((r-n)/1e3);if(i<60)return`${i}s`;const a=Math.floor(i/60),s=i%60;return s===0?`${a}m`:`${a}m ${s}s`}function Llt(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,i=Math.floor(r/6e4);if(i<1)return"just now";if(i<60)return`about ${i} min ago`;const a=Math.floor(i/60);return a<24?`about ${a}h ago`:`about ${Math.floor(a/24)}d ago`}const Plt=Np(function(){const{t}=wt("common"),{appId:n}=oM.useParams(),{tab:r,action:i}=oM.useSearch(),a=Br(),{data:s,isLoading:o,error:l}=PIe(n),{data:u}=q3(),p=Hae(),d=r||"general",[m,g]=T.useState(!1),x=K3(),[_,b]=T.useState(!1),y=T.useCallback(()=>{s&&(x.deploy(s.id),b(!0))},[s,x]),v=T.useCallback(R=>{b(R),!R&&!x.isDeploying&&x.logs.length===0&&!x.error&&setTimeout(()=>x.reset(),300)},[x]),E=T.useRef(!1);T.useEffect(()=>{i==="deploy"&&s&&!E.current&&!x.isDeploying&&(E.current=!0,a({to:"/apps/$appId",params:{appId:n},search:r?{tab:r}:{},replace:!0}),x.deploy(n),b(!0))},[i,s,n,x,a,r]),T.useEffect(()=>{E.current=!1},[n]);const C=u&&!u.settings.cloudflareConfigured,w=T.useCallback(R=>{a({to:"/apps/$appId",params:{appId:n},search:R==="general"?{}:{tab:R},replace:!0})},[a,n]),A=async()=>{await p.mutateAsync({id:n}),a({to:"/apps"})};return o?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):l||!s?f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[f.jsx(J,{icon:er,size:48,strokeWidth:1.5,className:"text-destructive"}),f.jsx("p",{className:"text-muted-foreground",children:l?.message??"App not found"}),f.jsx(Rn,{to:"/apps",children:f.jsxs(Ae,{variant:"outline",children:[f.jsx(J,{icon:qu,size:16,strokeWidth:2}),t("apps.backToApps")]})})]}):f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs(mo,{value:d,onValueChange:R=>w(R),className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-4 border-b border-border bg-background px-4 py-2",children:[f.jsxs(am,{children:[f.jsxs(sm,{className:"flex items-center gap-2 sm:hidden",children:[f.jsx(J,{icon:o3,size:18,strokeWidth:2}),f.jsx("span",{className:"text-sm font-medium",children:t(`apps.tabs.${d}`)})]}),f.jsxs(om,{align:"start",children:[f.jsx(Tr,{onClick:()=>w("general"),children:t("apps.tabs.general")}),f.jsx(Tr,{onClick:()=>w("deployments"),children:t("apps.tabs.deployments")}),f.jsx(Tr,{onClick:()=>w("logs"),children:t("apps.tabs.logs")}),f.jsx(Tr,{onClick:()=>w("monitoring"),children:t("apps.tabs.monitoring")})]})]}),f.jsxs(go,{variant:"line",className:"hidden sm:inline-flex",children:[f.jsx(ar,{value:"general",className:"px-3 py-1.5",children:t("apps.tabs.general")}),f.jsx(ar,{value:"deployments",className:"px-3 py-1.5",children:t("apps.tabs.deployments")}),f.jsx(ar,{value:"logs",className:"px-3 py-1.5",children:t("apps.tabs.logs")}),f.jsx(ar,{value:"monitoring",className:"px-3 py-1.5",children:t("apps.tabs.monitoring")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-medium text-sm",children:s.name}),s.repository&&f.jsx(Rn,{to:"/repositories/$repoId",params:{repoId:s.repository.id},className:"text-muted-foreground hover:text-foreground transition-colors",title:s.repository.displayName,children:f.jsx(J,{icon:Ou,size:14,strokeWidth:2})}),f.jsx("div",{className:`h-2 w-2 rounded-full ${s.status==="running"?"bg-green-500":s.status==="building"?"bg-yellow-500":s.status==="failed"?"bg-red-500":"bg-gray-400"}`,title:t(`apps.status.${s.status}`)}),C&&f.jsxs(uj,{children:[f.jsx(cj,{className:"p-1 text-amber-500 hover:text-amber-400 transition-colors",children:f.jsx(J,{icon:er,size:14,strokeWidth:2})}),f.jsxs(dj,{side:"bottom",className:"max-w-xs",children:[f.jsx("p",{className:"font-medium",children:t("apps.manualDnsRequired")}),f.jsx("p",{className:"text-muted-foreground mt-1",children:t("apps.manualDnsRequiredDesc")})]})]}),f.jsx(Ae,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>g(!0),children:f.jsx(J,{icon:rs,size:14,strokeWidth:2})})]})]}),f.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[f.jsx(_r,{value:"general",className:"mt-0",children:f.jsx(Mlt,{app:s,onDeploy:y})}),f.jsx(_r,{value:"deployments",className:"mt-0",children:f.jsx(Ult,{appId:n,deployStore:x,onViewStreamingLogs:()=>b(!0)})}),f.jsx(_r,{value:"logs",className:"mt-0",children:f.jsx(Blt,{appId:n,services:s.services})}),f.jsx(_r,{value:"monitoring",className:"mt-0",children:f.jsx(Klt,{appId:s.id,repoDisplayName:s.repository?.displayName})})]})]}),f.jsx(jlt,{appId:n,open:_,onOpenChange:v}),f.jsx(Oa,{open:m,onOpenChange:g,children:f.jsxs(Ra,{children:[f.jsxs(Na,{children:[f.jsx(Da,{children:t("apps.deleteApp")}),f.jsx(La,{children:t("apps.deleteAppConfirm",{name:s.name})})]}),f.jsxs(Ia,{children:[f.jsx(Pa,{children:t("apps.cancel")}),f.jsx(ec,{onClick:A,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:p.isPending?t("apps.deleting"):t("apps.delete")})]})]})})]})}),Mlt=Np(function({app:t,onDeploy:n}){const{t:r}=wt("common"),i=Wae(),a=Vae(),s=W3(),o=K3(),l=async()=>{await i.mutateAsync(t.id)},u=async()=>{await a.mutateAsync(t.id)},p=o.isDeploying||t.status==="building",d=async x=>{await s.mutateAsync({id:t.id,updates:{autoDeployEnabled:x}})},m=async x=>{await s.mutateAsync({id:t.id,updates:{noCacheBuild:x}})},g=async x=>{await s.mutateAsync({id:t.id,updates:{notificationsEnabled:x}})};return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[f.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:r("apps.general.deploy")}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs(Ae,{size:"sm",onClick:n,disabled:p,children:[p?f.jsx(J,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):f.jsx(J,{icon:Cm,size:14,strokeWidth:2}),o.isDeploying?r("apps.deploying"):t.status==="building"?r("apps.building"):r("apps.deploy")]}),p?f.jsxs(Ae,{variant:"destructive",size:"sm",onClick:u,disabled:a.isPending,children:[a.isPending?f.jsx(J,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):f.jsx(J,{icon:Tm,size:14,strokeWidth:2}),a.isPending?r("apps.cancelling"):r("apps.cancelDeploy")]}):f.jsxs(Ae,{variant:"destructive",size:"sm",onClick:l,disabled:i.isPending||t.status!=="running",children:[i.isPending?f.jsx(J,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):f.jsx(J,{icon:Tm,size:14,strokeWidth:2}),r("apps.stop")]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[f.jsx(Rr,{checked:t.autoDeployEnabled??!1,onCheckedChange:x=>d(x===!0)}),f.jsx("span",{children:r("apps.general.autodeploy")})]}),f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[f.jsx(Rr,{checked:t.noCacheBuild??!1,onCheckedChange:x=>m(x===!0)}),f.jsx("span",{children:r("apps.general.noCache")})]}),f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[f.jsx(Rr,{checked:t.notificationsEnabled??!0,onCheckedChange:x=>g(x===!0)}),f.jsx("span",{children:r("apps.general.notifications")})]})]})]}),f.jsx(Wlt,{app:t,onDeploy:n})]}),f.jsx(Hlt,{app:t}),f.jsx(Flt,{app:t})]})});function jlt({appId:e,open:t,onOpenChange:n}){const{t:r}=wt("common"),[i,a]=T.useState(!1),s=T.useRef(null),o=Vae(),l=K3(),[u,p]=T.useState(()=>l.logsSnapshot),[d,m]=T.useState(l.typedStage),[g,x]=T.useState(l.error),[_,b]=T.useState(l.isDeploying);T.useEffect(()=>{p(l.logsSnapshot),m(l.typedStage),x(l.error),b(l.isDeploying);const w=Rm(()=>l.logCount,()=>{console.log("[StreamingDeploymentModal] reaction: logs changed",l.logCount),p(l.logsSnapshot)}),A=Rm(()=>({stage:l.typedStage,error:l.error,isDeploying:l.isDeploying}),R=>{console.log("[StreamingDeploymentModal] reaction: state changed",R),m(R.stage),x(R.error),b(R.isDeploying)});return()=>{w(),A()}},[l]),console.log("[StreamingDeploymentModal] render",{logCount:u.length,isDeploying:_,stage:d,open:t});const y=MB(u.join(`
|
|
178
178
|
`));T.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[u.length]);const v=async()=>{await navigator.clipboard.writeText(u.join(`
|
|
179
179
|
`)),a(!0),setTimeout(()=>a(!1),2e3)},E=async()=>{await o.mutateAsync(e)},C=w=>{switch(w){case"pulling":return r("apps.streaming.pulling");case"building":return r("apps.streaming.building");case"starting":return r("apps.streaming.starting");case"configuring":return r("apps.streaming.configuring");case"done":return r("apps.streaming.done");case"failed":return r("apps.streaming.failed");case"cancelled":return r("apps.streaming.cancelled");default:return r("apps.streaming.preparing")}};return f.jsx(Xo,{open:t,onOpenChange:n,children:f.jsxs(Zo,{className:"!max-w-[90vw] w-[90vw] h-[85vh] flex flex-col",children:[f.jsxs(Ul,{children:[f.jsxs($l,{className:"flex items-center gap-2",children:[r("apps.deployments.deployment"),_&&f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),!_&&!g&&d==="done"&&f.jsx(J,{icon:vo,size:16,strokeWidth:2,className:"text-green-500"}),g&&f.jsx(J,{icon:er,size:16,strokeWidth:2,className:"text-destructive"})]}),f.jsxs(Cp,{className:"flex items-center gap-2",children:[C(d),_&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-muted-foreground",children:"|"}),f.jsxs(Ae,{variant:"destructive",size:"sm",onClick:E,disabled:o.isPending,children:[o.isPending?f.jsx(J,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):f.jsx(J,{icon:Tm,size:14,strokeWidth:2}),o.isPending?r("apps.cancelling"):r("apps.cancelDeploy")]})]}),f.jsx("span",{className:"text-muted-foreground",children:"|"}),f.jsxs("span",{children:[y.length," ",r("apps.logs.lines")]}),f.jsx(Ae,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:v,disabled:u.length===0,children:f.jsx(J,{icon:i?vo:kw,size:14,strokeWidth:2,className:i?"text-green-500":""})})]})]}),f.jsxs("div",{ref:s,className:"flex-1 overflow-auto rounded-lg border bg-muted/30 p-2 custom-logs-scrollbar",children:[y.length>0?y.map((w,A)=>f.jsx(jB,{message:w.message,type:w.type},A)):_?f.jsx("span",{className:"text-muted-foreground p-2",children:r("apps.streaming.waitingForLogs")}):f.jsx("span",{className:"text-muted-foreground p-2",children:r("apps.deployments.noBuildLogs")}),g&&f.jsxs("div",{className:"mt-2 p-2 rounded bg-destructive/10 text-destructive text-sm",children:[r("status.error"),": ",g]})]})]})})}function Flt({app:e}){const{t}=wt("common"),n=e.repository?.path??null,{data:r,isLoading:i,error:a}=UIe(n,e.composeFile),s=$Ie(),o=zIe(),[l,u]=T.useState(""),[p,d]=T.useState(!1),[m,g]=T.useState(!1),[x,_]=T.useState(!1),b=T.useRef(void 0);T.useEffect(()=>{r?.content!==void 0&&(u(r.content),g(!1))},[r?.content]);const y=T.useCallback(E=>{u(E),g(!0),_(!1),b.current&&clearTimeout(b.current),p&&n&&e.composeFile&&(b.current=setTimeout(()=>{s.mutate({repoPath:n,composeFile:e.composeFile,content:E},{onSuccess:()=>{g(!1),_(!0),setTimeout(()=>_(!1),2e3),o.mutate(e.id)}})},1e3))},[p,n,e.composeFile,e.id,s,o]);T.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const v=()=>{p&&m&&n&&e.composeFile&&s.mutate({repoPath:n,composeFile:e.composeFile,content:l},{onSuccess:()=>{g(!1),_(!0),setTimeout(()=>_(!1),2e3),o.mutate(e.id)}}),d(!p)};return n?i?f.jsxs("div",{className:"rounded-lg border p-4",children:[f.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3",children:t("apps.compose.title")}),f.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[f.jsx(J,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),f.jsx("span",{className:"text-sm",children:t("status.loading")})]})]}):a?f.jsxs("div",{className:"rounded-lg border p-4",children:[f.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3",children:t("apps.compose.title")}),f.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[f.jsx(J,{icon:er,size:16,strokeWidth:2}),f.jsx("span",{className:"text-sm",children:a.message})]})]}):f.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:t("apps.compose.title")}),f.jsxs("div",{className:"flex items-center gap-2",children:[m&&p&&f.jsx("span",{className:"text-xs text-muted-foreground",children:t("apps.compose.unsaved")}),x&&f.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-500",children:[f.jsx(J,{icon:vo,size:12,strokeWidth:2}),t("status.saved")]}),s.isPending&&f.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[f.jsx(J,{icon:Nt,size:12,strokeWidth:2,className:"animate-spin"}),t("status.saving")]}),f.jsx("span",{className:"text-sm text-muted-foreground",children:e.composeFile}),f.jsxs(Ae,{variant:p?"default":"outline",size:"sm",onClick:v,children:[f.jsx(J,{icon:T_e,size:14,strokeWidth:2}),t(p?"apps.compose.done":"apps.compose.edit")]})]})]}),f.jsx("div",{className:"h-[400px] rounded-md border overflow-hidden",children:f.jsx(Hce,{filePath:e.composeFile,content:l,onChange:y,readOnly:!p})})]}):f.jsxs("div",{className:"rounded-lg border p-4",children:[f.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3",children:t("apps.compose.title")}),f.jsx("p",{className:"text-sm text-muted-foreground",children:t("apps.compose.repoNotFound")})]})}function Blt({appId:e,services:t}){const{t:n}=wt("common"),{data:r}=qae(e),[i,a]=T.useState(),[s,o]=T.useState(100),{data:l,isLoading:u,refetch:p}=jIe(e,i,s),[d,m]=T.useState(!1),g=T.useMemo(()=>MB(l?.logs??""),[l?.logs]),x=async()=>{l?.logs&&(await navigator.clipboard.writeText(l.logs),m(!0),setTimeout(()=>m(!1),2e3))},_=()=>{if(l?.logs){const y=new Blob([l.logs],{type:"text/plain"}),v=URL.createObjectURL(y),E=document.createElement("a");E.href=v,E.download=`${e}-${i??"all"}-logs.txt`,document.body.appendChild(E),E.click(),document.body.removeChild(E),URL.revokeObjectURL(v)}},b=r?.containers??[];return f.jsxs("div",{className:"space-y-4 max-w-4xl",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold",children:n("apps.logs.title")}),f.jsx("p",{className:"text-sm text-muted-foreground",children:n("apps.logs.description")})]}),f.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[f.jsxs("select",{value:i??"",onChange:y=>a(y.target.value||void 0),className:"rounded-md border bg-background px-3 py-2 text-sm min-w-[240px]",children:[f.jsx("option",{value:"",children:n("apps.logs.allContainers")}),b.length>0?b.map(y=>f.jsxs("option",{value:y.service,children:[y.service," (",y.name.slice(-12),") [",y.status,"]"]},y.name)):t?.map(y=>f.jsx("option",{value:y.serviceName,children:y.serviceName},y.id))]}),f.jsxs("select",{value:s,onChange:y=>o(parseInt(y.target.value,10)),className:"rounded-md border bg-background px-3 py-2 text-sm",children:[f.jsxs("option",{value:50,children:["50 ",n("apps.logs.lines")]}),f.jsxs("option",{value:100,children:["100 ",n("apps.logs.lines")]}),f.jsxs("option",{value:500,children:["500 ",n("apps.logs.lines")]}),f.jsxs("option",{value:1e3,children:["1000 ",n("apps.logs.lines")]})]}),f.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[f.jsxs(Ae,{variant:"outline",size:"sm",onClick:x,disabled:!l?.logs,children:[f.jsx(J,{icon:d?vo:kw,size:14,strokeWidth:2,className:d?"text-green-500":""}),n(d?"apps.logs.copied":"apps.logs.copy")]}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:_,disabled:!l?.logs,children:[f.jsx(J,{icon:qu,size:14,strokeWidth:2,className:"rotate-[-90deg]"}),n("apps.logs.download")]}),f.jsxs(Ae,{variant:"outline",size:"sm",onClick:()=>p(),children:[f.jsx(J,{icon:Nw,size:14,strokeWidth:2}),n("apps.logs.refresh")]})]})]}),f.jsx("div",{className:"rounded-lg border bg-muted/30 p-2 overflow-auto max-h-[600px] min-h-[300px] custom-logs-scrollbar",children:u?f.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground p-2",children:[f.jsx(J,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}),n("status.loading")]}):g.length>0?g.map((y,v)=>f.jsx(jB,{message:y.message,type:y.type},v)):f.jsx("span",{className:"text-muted-foreground p-2",children:n("apps.logs.noLogs")})})]})}function Ult({appId:e,deployStore:t,onViewStreamingLogs:n}){const{t:r}=wt("common"),{data:i,isLoading:a}=FIe(e),[s,o]=T.useState(null),l=u=>{u.status==="building"||u.status==="pending"?((!t.isDeploying||t.appId!==e)&&t.watchDeployment(e),n()):o(u)};return a?f.jsx("div",{className:"flex items-center justify-center py-8",children:f.jsx(J,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):f.jsxs("div",{className:"max-w-3xl",children:[f.jsxs("div",{className:"mb-4",children:[f.jsx("h3",{className:"text-lg font-semibold",children:r("apps.deployments.title")}),f.jsx("p",{className:"text-sm text-muted-foreground",children:r("apps.deployments.description")})]}),i?.length?f.jsx("div",{className:"border rounded-lg divide-y",children:i.map((u,p)=>f.jsx($lt,{deployment:u,number:p+1,onViewLogs:()=>l(u)},u.id))}):f.jsx("div",{className:"py-8 text-center text-muted-foreground border rounded-lg",children:f.jsx("p",{children:r("apps.deployments.noDeployments")})}),f.jsx(zlt,{deployment:s,open:!!s,onOpenChange:u=>!u&&o(null)})]})}function $lt({deployment:e,number:t,onViewLogs:n}){const{t:r}=wt("common"),i=e.status==="building"||e.status==="pending",[,a]=T.useState(0);T.useEffect(()=>{if(!i)return;const u=setInterval(()=>a(p=>p+1),1e3);return()=>clearInterval(u)},[i]);const s=()=>{switch(e.status){case"running":return{text:r("apps.deployments.statusDone"),color:"bg-green-500"};case"failed":return{text:r("apps.deployments.statusError"),color:"bg-red-500"};case"building":case"pending":return{text:r("apps.deployments.statusBuilding"),color:"bg-yellow-500"};default:return{text:e.status,color:"bg-gray-400"}}},{text:o,color:l}=s();return f.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("span",{className:"text-muted-foreground w-6",children:[t,"."]}),f.jsx("span",{className:"font-medium",children:o}),f.jsx("div",{className:`h-2 w-2 rounded-full ${l}`})]}),f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:Llt(e.startedAt)}),f.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:["⏱ ",Dlt(e.startedAt,e.completedAt)]}),f.jsx(Ae,{size:"sm",onClick:n,children:r("apps.deployments.view")})]})]})}function zlt({deployment:e,open:t,onOpenChange:n}){const{t:r}=wt("common"),[i,a]=T.useState(!1),s=T.useMemo(()=>MB(e?.buildLogs??""),[e?.buildLogs]),o=async()=>{e?.buildLogs&&(await navigator.clipboard.writeText(e.buildLogs),a(!0),setTimeout(()=>a(!1),2e3))};return f.jsx(Xo,{open:t,onOpenChange:n,children:f.jsxs(Zo,{className:"!max-w-[90vw] w-[90vw] h-[85vh] flex flex-col",children:[f.jsxs(Ul,{children:[f.jsx($l,{children:r("apps.deployments.deployment")}),f.jsxs(Cp,{className:"flex items-center gap-2",children:[r("apps.deployments.seeDetails"),f.jsx("span",{className:"text-muted-foreground",children:"|"}),f.jsxs("span",{children:[s.length," ",r("apps.logs.lines")]}),f.jsx(Ae,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:o,children:f.jsx(J,{icon:i?vo:kw,size:14,strokeWidth:2,className:i?"text-green-500":""})})]})]}),f.jsx("div",{className:"flex-1 overflow-auto rounded-lg border bg-muted/30 p-2 custom-logs-scrollbar",children:s.length>0?s.map((l,u)=>f.jsx(jB,{message:l.message,type:l.type},u)):f.jsx("span",{className:"text-muted-foreground p-2",children:r("apps.deployments.noBuildLogs")})})]})})}function Hlt({app:e}){const{t}=wt("common"),n=W3(),r=_=>Object.entries(_??{}).map(([b,y])=>`${b}=${y}`).join(`
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="/logo.png" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Vibora - Harness Attention. Ship.</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-DZpi5F0r.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-CfTPmrF1.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|